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

@@ -13,7 +13,6 @@
#include "mozilla/dom/HTMLTextAreaElementBinding.h"
#include "mozilla/dom/MutationEventBinding.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/EventStates.h"
#include "mozilla/MappedDeclarations.h"
#include "mozilla/MouseEvents.h"
#include "mozilla/PresState.h"
@@ -68,8 +67,8 @@ HTMLTextAreaElement::HTMLTextAreaElement(
// right now), optional, and valid. We are NOT readwrite by default
// until someone calls UpdateEditableState on us, apparently! Also
// by default we don't have to show validity UI and so forth.
AddStatesSilently(NS_EVENT_STATE_ENABLED | NS_EVENT_STATE_OPTIONAL |
NS_EVENT_STATE_VALID);
AddStatesSilently(ElementState::ENABLED | ElementState::OPTIONAL_ |
ElementState::VALID);
}
HTMLTextAreaElement::~HTMLTextAreaElement() {
@@ -749,20 +748,20 @@ bool HTMLTextAreaElement::RestoreState(PresState* aState) {
return false;
}
EventStates HTMLTextAreaElement::IntrinsicState() const {
EventStates state =
ElementState HTMLTextAreaElement::IntrinsicState() const {
ElementState state =
nsGenericHTMLFormControlElementWithState::IntrinsicState();
if (IsCandidateForConstraintValidation()) {
if (IsValid()) {
state |= NS_EVENT_STATE_VALID;
state |= ElementState::VALID;
} else {
state |= NS_EVENT_STATE_INVALID;
state |= ElementState::INVALID;
// :-moz-ui-invalid always apply if the element suffers from a custom
// error.
if (GetValidityState(VALIDITY_STATE_CUSTOM_ERROR) ||
(mCanShowInvalidUI && ShouldShowValidityUI())) {
state |= NS_EVENT_STATE_MOZ_UI_INVALID;
state |= ElementState::MOZ_UI_INVALID;
}
}
@@ -774,14 +773,14 @@ EventStates HTMLTextAreaElement::IntrinsicState() const {
// 3. The element has already been modified or the user tried to submit the
// form owner while invalid.
if (mCanShowValidUI && ShouldShowValidityUI() &&
(IsValid() || (state.HasState(NS_EVENT_STATE_MOZ_UI_INVALID) &&
(IsValid() || (state.HasState(ElementState::MOZ_UI_INVALID) &&
!mCanShowInvalidUI))) {
state |= NS_EVENT_STATE_MOZ_UI_VALID;
state |= ElementState::MOZ_UI_VALID;
}
}
if (HasAttr(nsGkAtoms::placeholder) && IsValueEmpty()) {
state |= NS_EVENT_STATE_PLACEHOLDERSHOWN;
state |= ElementState::PLACEHOLDER_SHOWN;
}
return state;