Bug 1773070 - Unify Gecko and Servo EventState/ElementState bits. r=smaug

Add a dom/base/rust crate called just "dom" where we can share these.

Most of the changes are automatic:

  s/mozilla::EventStates/mozilla::dom::ElementState/
  s/EventStates/ElementState/
  s/NS_EVENT_STATE_/ElementState::/
  s/NS_DOCUMENT_STATE_/DocumentState::/

And so on. This requires a new cbindgen version to avoid ugly casts for
large shifts.

Differential Revision: https://phabricator.services.mozilla.com/D148537
This commit is contained in:
Emilio Cobos Álvarez
2022-06-07 23:09:52 +00:00
parent 0b0fd89a89
commit 1c58e2a928
172 changed files with 1243 additions and 1501 deletions

View File

@@ -15,7 +15,6 @@
#include "mozilla/Components.h"
#include "mozilla/ContentEvents.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/EventStates.h"
#include "mozilla/PresShell.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/dom/BindContext.h"
@@ -120,7 +119,7 @@ HTMLFormElement::HTMLFormElement(
mIsConstructingEntryList(false),
mIsFiringSubmissionEvents(false) {
// We start out valid.
AddStatesSilently(NS_EVENT_STATE_VALID);
AddStatesSilently(ElementState::VALID);
}
HTMLFormElement::~HTMLFormElement() {
@@ -1916,7 +1915,7 @@ bool HTMLFormElement::CheckValidFormSubmission() {
// for the anonymous textnode inside, but not the number control
// itself. We can use the focus state, though, because that gets
// synced to the number control by the anonymous text control.
mControls->mElements[i]->State().HasState(NS_EVENT_STATE_FOCUS)) {
mControls->mElements[i]->State().HasState(ElementState::FOCUS)) {
static_cast<HTMLInputElement*>(mControls->mElements[i])
->UpdateValidityUIBits(true);
}
@@ -2034,13 +2033,13 @@ void HTMLFormElement::SetValueMissingState(const nsAString& aName,
RadioGroupManager::SetValueMissingState(aName, aValue);
}
EventStates HTMLFormElement::IntrinsicState() const {
EventStates state = nsGenericHTMLElement::IntrinsicState();
ElementState HTMLFormElement::IntrinsicState() const {
ElementState state = nsGenericHTMLElement::IntrinsicState();
if (mInvalidElementsCount) {
state |= NS_EVENT_STATE_INVALID;
state |= ElementState::INVALID;
} else {
state |= NS_EVENT_STATE_VALID;
state |= ElementState::VALID;
}
return state;