From 69fc5ca9fd2f8410999a83159c20b852b6c22ecd Mon Sep 17 00:00:00 2001 From: Oriol Brufau Date: Wed, 17 May 2023 00:33:24 +0200 Subject: [PATCH] style: Garbage-collect event state bits 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 --- components/style/element_state.rs | 81 +++++++++++------------ components/style/servo/selector_parser.rs | 2 +- 2 files changed, 39 insertions(+), 44 deletions(-) diff --git a/components/style/element_state.rs b/components/style/element_state.rs index 853d4039b2a..8a9f4065b8b 100644 --- a/components/style/element_state.rs +++ b/components/style/element_state.rs @@ -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; /// - const IN_REQUIRED_STATE = 1 << 21; + const IN_REQUIRED_STATE = 1 << 16; /// - const IN_OPTIONAL_STATE = 1 << 22; - /// - const IN_READ_WRITE_STATE = 1 << 22; + const IN_OPTIONAL_STATE = 1 << 17; /// - const IN_DEFINED_STATE = 1 << 23; + const IN_DEFINED_STATE = 1 << 18; /// - const IN_VISITED_STATE = 1 << 24; + const IN_VISITED_STATE = 1 << 19; /// - const IN_UNVISITED_STATE = 1 << 25; + const IN_UNVISITED_STATE = 1 << 20; /// 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; /// - const IN_INRANGE_STATE = 1 << 27; + const IN_INRANGE_STATE = 1 << 22; /// - const IN_OUTOFRANGE_STATE = 1 << 28; + const IN_OUTOFRANGE_STATE = 1 << 23; /// - const IN_READONLY_STATE = 1 << 29; + const IN_READONLY_STATE = 1 << 24; /// - const IN_READWRITE_STATE = 1 << 30; + const IN_READWRITE_STATE = 1 << 25; /// - 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; + /// + const IN_FOCUSRING_STATE = 1 << 32; /// - 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 elements without a valid-valued "dir" attr or /// any HTML elements (including ) 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; + /// + const IN_MODAL_DIALOG_STATE = 1 << 42; + /// + 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; } } diff --git a/components/style/servo/selector_parser.rs b/components/style/servo/selector_parser.rs index ce61c172553..7d5b8c5772a 100644 --- a/components/style/servo/selector_parser.rs +++ b/components/style/servo/selector_parser.rs @@ -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,