Bug 1707597 - Garbage-collect event state bits. r=smaug

We had about 9 gaps / unused bits. I moved the devtools ones at the end
because I think we should be able to remove them (but separate bug).

Differential Revision: https://phabricator.services.mozilla.com/D113365
This commit is contained in:
Emilio Cobos Álvarez 2021-04-26 15:46:52 +00:00
parent 513e659b72
commit 5c9bd32723
5 changed files with 75 additions and 84 deletions

View File

@ -763,7 +763,7 @@ async function waitUntilVisitedState(tab, selectors) {
tab.linkedBrowser,
selectors,
args => {
const NS_EVENT_STATE_VISITED = 1 << 24;
const NS_EVENT_STATE_VISITED = 1 << 19;
for (const selector of args) {
const target = content.wrappedJSObject.document.querySelector(

View File

@ -527,7 +527,7 @@ function hasVisitedState(node) {
return false;
}
const NS_EVENT_STATE_VISITED = 1 << 24;
const NS_EVENT_STATE_VISITED = 1 << 19;
return (
!!(InspectorUtils.getContentState(node) & NS_EVENT_STATE_VISITED) ||

View File

@ -199,57 +199,50 @@ class EventStates {
#define NS_EVENT_STATE_MOZ_UI_INVALID NS_DEFINE_EVENT_STATE_MACRO(13)
// Content could not be rendered (image/object/etc).
#define NS_EVENT_STATE_BROKEN NS_DEFINE_EVENT_STATE_MACRO(14)
// There are two free bits here.
// Content is still loading such that there is nothing to show the
// user (eg an image which hasn't started coming in yet).
#define NS_EVENT_STATE_LOADING NS_DEFINE_EVENT_STATE_MACRO(17)
#define NS_EVENT_STATE_LOADING NS_DEFINE_EVENT_STATE_MACRO(15)
// Content is required.
#define NS_EVENT_STATE_REQUIRED NS_DEFINE_EVENT_STATE_MACRO(21)
#define NS_EVENT_STATE_REQUIRED NS_DEFINE_EVENT_STATE_MACRO(16)
// Content is optional (and can be required).
#define NS_EVENT_STATE_OPTIONAL NS_DEFINE_EVENT_STATE_MACRO(22)
#define NS_EVENT_STATE_OPTIONAL NS_DEFINE_EVENT_STATE_MACRO(17)
// Element is either a defined custom element or uncustomized element.
#define NS_EVENT_STATE_DEFINED NS_DEFINE_EVENT_STATE_MACRO(23)
#define NS_EVENT_STATE_DEFINED NS_DEFINE_EVENT_STATE_MACRO(18)
// Link has been visited.
#define NS_EVENT_STATE_VISITED NS_DEFINE_EVENT_STATE_MACRO(24)
#define NS_EVENT_STATE_VISITED NS_DEFINE_EVENT_STATE_MACRO(19)
// Link hasn't been visited.
#define NS_EVENT_STATE_UNVISITED NS_DEFINE_EVENT_STATE_MACRO(25)
#define NS_EVENT_STATE_UNVISITED NS_DEFINE_EVENT_STATE_MACRO(20)
// Drag is hovering over content.
#define NS_EVENT_STATE_DRAGOVER NS_DEFINE_EVENT_STATE_MACRO(26)
#define NS_EVENT_STATE_DRAGOVER NS_DEFINE_EVENT_STATE_MACRO(21)
// Content value is in-range (and can be out-of-range).
#define NS_EVENT_STATE_INRANGE NS_DEFINE_EVENT_STATE_MACRO(27)
#define NS_EVENT_STATE_INRANGE NS_DEFINE_EVENT_STATE_MACRO(22)
// Content value is out-of-range.
#define NS_EVENT_STATE_OUTOFRANGE NS_DEFINE_EVENT_STATE_MACRO(28)
#define NS_EVENT_STATE_OUTOFRANGE NS_DEFINE_EVENT_STATE_MACRO(23)
// Content is read-only.
// TODO(emilio): This is always the inverse of READWRITE. With some style system
// work we could remove one of the two bits.
#define NS_EVENT_STATE_READONLY NS_DEFINE_EVENT_STATE_MACRO(29)
#define NS_EVENT_STATE_READONLY NS_DEFINE_EVENT_STATE_MACRO(24)
// Content is editable.
#define NS_EVENT_STATE_READWRITE NS_DEFINE_EVENT_STATE_MACRO(30)
#define NS_EVENT_STATE_READWRITE NS_DEFINE_EVENT_STATE_MACRO(25)
// Content is the default one (meaning depends of the context).
#define NS_EVENT_STATE_DEFAULT NS_DEFINE_EVENT_STATE_MACRO(31)
#define NS_EVENT_STATE_DEFAULT NS_DEFINE_EVENT_STATE_MACRO(26)
// Content is a submit control and the form isn't valid.
#define NS_EVENT_STATE_MOZ_SUBMITINVALID NS_DEFINE_EVENT_STATE_MACRO(32)
#define NS_EVENT_STATE_MOZ_SUBMITINVALID NS_DEFINE_EVENT_STATE_MACRO(27)
// Content is in the optimum region.
#define NS_EVENT_STATE_OPTIMUM NS_DEFINE_EVENT_STATE_MACRO(33)
#define NS_EVENT_STATE_OPTIMUM NS_DEFINE_EVENT_STATE_MACRO(28)
// Content is in the suboptimal region.
#define NS_EVENT_STATE_SUB_OPTIMUM NS_DEFINE_EVENT_STATE_MACRO(34)
#define NS_EVENT_STATE_SUB_OPTIMUM NS_DEFINE_EVENT_STATE_MACRO(29)
// Content is in the sub-suboptimal region.
#define NS_EVENT_STATE_SUB_SUB_OPTIMUM NS_DEFINE_EVENT_STATE_MACRO(35)
// Element is highlighted (devtools inspector)
#define NS_EVENT_STATE_DEVTOOLS_HIGHLIGHTED NS_DEFINE_EVENT_STATE_MACRO(36)
// Element is transitioning for rules changed by style editor
#define NS_EVENT_STATE_STYLEEDITOR_TRANSITIONING NS_DEFINE_EVENT_STATE_MACRO(37)
#define NS_EVENT_STATE_INCREMENT_SCRIPT_LEVEL NS_DEFINE_EVENT_STATE_MACRO(38)
#define NS_EVENT_STATE_SUB_SUB_OPTIMUM NS_DEFINE_EVENT_STATE_MACRO(30)
#define NS_EVENT_STATE_INCREMENT_SCRIPT_LEVEL NS_DEFINE_EVENT_STATE_MACRO(31)
// Content has focus and should show a ring.
#define NS_EVENT_STATE_FOCUSRING NS_DEFINE_EVENT_STATE_MACRO(39)
#define NS_EVENT_STATE_FOCUSRING NS_DEFINE_EVENT_STATE_MACRO(32)
// Element has focus-within.
#define NS_EVENT_STATE_FOCUS_WITHIN NS_DEFINE_EVENT_STATE_MACRO(43)
#define NS_EVENT_STATE_FOCUS_WITHIN NS_DEFINE_EVENT_STATE_MACRO(33)
// Element is ltr (for :dir pseudo-class)
#define NS_EVENT_STATE_LTR NS_DEFINE_EVENT_STATE_MACRO(44)
#define NS_EVENT_STATE_LTR NS_DEFINE_EVENT_STATE_MACRO(34)
// Element is rtl (for :dir pseudo-class)
#define NS_EVENT_STATE_RTL NS_DEFINE_EVENT_STATE_MACRO(45)
#define NS_EVENT_STATE_RTL NS_DEFINE_EVENT_STATE_MACRO(35)
// States for tracking the state of the "dir" attribute for HTML elements. We
// use these to avoid having to get "dir" attributes all the time during
// selector matching for some parts of the UA stylesheet.
@ -260,28 +253,31 @@ class EventStates {
// Element is HTML and has a "dir" attibute. This state might go away depending
// on how https://github.com/whatwg/html/issues/2769 gets resolved. The value
// could be anything.
#define NS_EVENT_STATE_HAS_DIR_ATTR NS_DEFINE_EVENT_STATE_MACRO(46)
#define NS_EVENT_STATE_HAS_DIR_ATTR NS_DEFINE_EVENT_STATE_MACRO(36)
// Element is HTML, has a "dir" attribute, and the attribute's value is
// case-insensitively equal to "ltr".
#define NS_EVENT_STATE_DIR_ATTR_LTR NS_DEFINE_EVENT_STATE_MACRO(47)
#define NS_EVENT_STATE_DIR_ATTR_LTR NS_DEFINE_EVENT_STATE_MACRO(37)
// Element is HTML, has a "dir" attribute, and the attribute's value is
// case-insensitively equal to "rtl".
#define NS_EVENT_STATE_DIR_ATTR_RTL NS_DEFINE_EVENT_STATE_MACRO(48)
#define NS_EVENT_STATE_DIR_ATTR_RTL NS_DEFINE_EVENT_STATE_MACRO(38)
// Element is HTML, and is either a <bdi> element with no valid-valued "dir"
// attribute or any HTML element which has a "dir" attribute whose value is
// "auto".
#define NS_EVENT_STATE_DIR_ATTR_LIKE_AUTO NS_DEFINE_EVENT_STATE_MACRO(49)
#define NS_EVENT_STATE_DIR_ATTR_LIKE_AUTO NS_DEFINE_EVENT_STATE_MACRO(39)
// Element is filled by Autofill feature.
#define NS_EVENT_STATE_AUTOFILL NS_DEFINE_EVENT_STATE_MACRO(50)
#define NS_EVENT_STATE_AUTOFILL NS_DEFINE_EVENT_STATE_MACRO(40)
// Element is filled with preview data by Autofill feature.
#define NS_EVENT_STATE_AUTOFILL_PREVIEW NS_DEFINE_EVENT_STATE_MACRO(51)
// There's a free bit here.
#define NS_EVENT_STATE_AUTOFILL_PREVIEW NS_DEFINE_EVENT_STATE_MACRO(41)
// Modal <dialog> element
#define NS_EVENT_STATE_MODAL_DIALOG NS_DEFINE_EVENT_STATE_MACRO(53)
#define NS_EVENT_STATE_MODAL_DIALOG NS_DEFINE_EVENT_STATE_MACRO(42)
// Inert subtrees
#define NS_EVENT_STATE_MOZINERT NS_DEFINE_EVENT_STATE_MACRO(54)
#define NS_EVENT_STATE_MOZINERT NS_DEFINE_EVENT_STATE_MACRO(43)
// Topmost Modal <dialog> element in top layer
#define NS_EVENT_STATE_TOPMOST_MODAL_DIALOG NS_DEFINE_EVENT_STATE_MACRO(55)
#define NS_EVENT_STATE_TOPMOST_MODAL_DIALOG NS_DEFINE_EVENT_STATE_MACRO(44)
// Devtools highlighter (but it's used for something else atm).
#define NS_EVENT_STATE_DEVTOOLS_HIGHLIGHTED NS_DEFINE_EVENT_STATE_MACRO(45)
// Devtools style inspector stuff.
#define NS_EVENT_STATE_STYLEEDITOR_TRANSITIONING NS_DEFINE_EVENT_STATE_MACRO(46)
/**
* NOTE: do not go over 63 without updating EventStates::InternalType!
*/

View File

@ -54,84 +54,79 @@ bitflags! {
/// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-broken
const IN_BROKEN_STATE = 1 << 14;
/// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-loading
const IN_LOADING_STATE = 1 << 17;
const IN_LOADING_STATE = 1 << 15;
/// <https://html.spec.whatwg.org/multipage/#selector-required>
const IN_REQUIRED_STATE = 1 << 21;
const IN_REQUIRED_STATE = 1 << 16;
/// <https://html.spec.whatwg.org/multipage/#selector-optional>
const IN_OPTIONAL_STATE = 1 << 22;
/// <https://html.spec.whatwg.org/multipage/#selector-read-write>
const IN_READ_WRITE_STATE = 1 << 22;
const IN_OPTIONAL_STATE = 1 << 17;
/// <https://html.spec.whatwg.org/multipage/#selector-defined>
const IN_DEFINED_STATE = 1 << 23;
const IN_DEFINED_STATE = 1 << 18;
/// <https://html.spec.whatwg.org/multipage/#selector-visited>
const IN_VISITED_STATE = 1 << 24;
const IN_VISITED_STATE = 1 << 19;
/// <https://html.spec.whatwg.org/multipage/#selector-link>
const IN_UNVISITED_STATE = 1 << 25;
const IN_UNVISITED_STATE = 1 << 20;
/// <https://drafts.csswg.org/selectors-4/#the-any-link-pseudo>
const IN_VISITED_OR_UNVISITED_STATE = ElementState::IN_VISITED_STATE.bits |
ElementState::IN_UNVISITED_STATE.bits;
/// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-drag-over
const IN_DRAGOVER_STATE = 1 << 26;
const IN_DRAGOVER_STATE = 1 << 21;
/// <https://html.spec.whatwg.org/multipage/#selector-in-range>
const IN_INRANGE_STATE = 1 << 27;
const IN_INRANGE_STATE = 1 << 22;
/// <https://html.spec.whatwg.org/multipage/#selector-out-of-range>
const IN_OUTOFRANGE_STATE = 1 << 28;
const IN_OUTOFRANGE_STATE = 1 << 23;
/// <https://html.spec.whatwg.org/multipage/#selector-read-only>
const IN_READONLY_STATE = 1 << 29;
const IN_READONLY_STATE = 1 << 24;
/// <https://html.spec.whatwg.org/multipage/#selector-read-write>
const IN_READWRITE_STATE = 1 << 30;
const IN_READWRITE_STATE = 1 << 25;
/// <https://html.spec.whatwg.org/multipage/#selector-default>
const IN_DEFAULT_STATE = 1 << 31;
const IN_DEFAULT_STATE = 1 << 26;
/// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-submit-invalid
const IN_MOZ_SUBMITINVALID_STATE = 1 << 32;
const IN_MOZ_SUBMITINVALID_STATE = 1 << 27;
/// Non-standard & undocumented.
const IN_OPTIMUM_STATE = 1 << 33;
const IN_OPTIMUM_STATE = 1 << 28;
/// Non-standard & undocumented.
const IN_SUB_OPTIMUM_STATE = 1 << 34;
const IN_SUB_OPTIMUM_STATE = 1 << 29;
/// Non-standard & undocumented.
const IN_SUB_SUB_OPTIMUM_STATE = 1 << 35;
const IN_SUB_SUB_OPTIMUM_STATE = 1 << 30;
/// Non-standard & undocumented.
const IN_DEVTOOLS_HIGHLIGHTED_STATE = 1 << 36;
/// Non-standard & undocumented.
const IN_STYLEEDITOR_TRANSITIONING_STATE = 1 << 37;
/// Non-standard & undocumented.
const IN_INCREMENT_SCRIPT_LEVEL_STATE = 1 << 38;
/// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-focusring
///
/// But also https://drafts.csswg.org/selectors-4/#the-focus-visible-pseudo
const IN_FOCUSRING_STATE = 1 << 39;
const IN_INCREMENT_SCRIPT_LEVEL_STATE = 1 << 31;
/// <https://drafts.csswg.org/selectors-4/#the-focus-visible-pseudo>
const IN_FOCUSRING_STATE = 1 << 32;
/// <https://drafts.csswg.org/selectors-4/#the-focus-within-pseudo>
const IN_FOCUS_WITHIN_STATE = 1 << 43;
const IN_FOCUS_WITHIN_STATE = 1 << 33;
/// :dir matching; the states are used for dynamic change detection.
/// State that elements that match :dir(ltr) are in.
const IN_LTR_STATE = 1 << 44;
const IN_LTR_STATE = 1 << 34;
/// State that elements that match :dir(rtl) are in.
const IN_RTL_STATE = 1 << 45;
const IN_RTL_STATE = 1 << 35;
/// State that HTML elements that have a "dir" attr are in.
const IN_HAS_DIR_ATTR_STATE = 1 << 46;
const IN_HAS_DIR_ATTR_STATE = 1 << 36;
/// State that HTML elements with dir="ltr" (or something
/// case-insensitively equal to "ltr") are in.
const IN_HAS_DIR_ATTR_LTR_STATE = 1 << 47;
const IN_HAS_DIR_ATTR_LTR_STATE = 1 << 37;
/// State that HTML elements with dir="rtl" (or something
/// case-insensitively equal to "rtl") are in.
const IN_HAS_DIR_ATTR_RTL_STATE = 1 << 48;
const IN_HAS_DIR_ATTR_RTL_STATE = 1 << 38;
/// State that HTML <bdi> elements without a valid-valued "dir" attr or
/// any HTML elements (including <bdi>) with dir="auto" (or something
/// case-insensitively equal to "auto") are in.
const IN_HAS_DIR_ATTR_LIKE_AUTO_STATE = 1 << 49;
const IN_HAS_DIR_ATTR_LIKE_AUTO_STATE = 1 << 39;
/// Non-standard & undocumented.
const IN_AUTOFILL_STATE = 1 << 50;
const IN_AUTOFILL_STATE = 1 << 40;
/// Non-standard & undocumented.
const IN_AUTOFILL_PREVIEW_STATE = 1 << 51;
const IN_AUTOFILL_PREVIEW_STATE = 1 << 41;
/// State that dialog element is modal, for centered alignment
///
/// https://html.spec.whatwg.org/multipage/#centered-alignment
const IN_MODAL_DIALOG_STATE = 1 << 53;
/// https://html.spec.whatwg.org/multipage/#inert-subtrees
const IN_MOZINERT_STATE = 1 << 54;
/// <https://html.spec.whatwg.org/multipage/#centered-alignment>
const IN_MODAL_DIALOG_STATE = 1 << 42;
/// <https://html.spec.whatwg.org/multipage/#inert-subtrees>
const IN_MOZINERT_STATE = 1 << 43;
/// State for the topmost dialog element in top layer
const IN_TOPMOST_MODAL_DIALOG_STATE = 1 << 55;
const IN_TOPMOST_MODAL_DIALOG_STATE = 1 << 44;
/// Initially used for the devtools highlighter, but now somehow only
/// used for the devtools accessibility inspector.
const IN_DEVTOOLS_HIGHLIGHTED_STATE = 1 << 45;
/// Used for the devtools style editor. Probably should go away.
const IN_STYLEEDITOR_TRANSITIONING_STATE = 1 << 46;
}
}

View File

@ -372,7 +372,7 @@ impl NonTSPseudoClass {
Disabled => ElementState::IN_DISABLED_STATE,
Checked => ElementState::IN_CHECKED_STATE,
Indeterminate => ElementState::IN_INDETERMINATE_STATE,
ReadOnly | ReadWrite => ElementState::IN_READ_WRITE_STATE,
ReadOnly | ReadWrite => ElementState::IN_READWRITE_STATE,
PlaceholderShown => ElementState::IN_PLACEHOLDER_SHOWN_STATE,
Target => ElementState::IN_TARGET_STATE,