mirror of
https://github.com/servo/servo.git
synced 2025-06-20 15:18:58 +01:00
style: Unify Gecko and Servo EventState/ElementState bits
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:
parent
949fd0e172
commit
1ce75ff7dd
17 changed files with 70 additions and 220 deletions
|
@ -33,6 +33,7 @@ app_units = { workspace = true }
|
||||||
content-security-policy = { workspace = true, optional = true }
|
content-security-policy = { workspace = true, optional = true }
|
||||||
crossbeam-channel = { workspace = true, optional = true }
|
crossbeam-channel = { workspace = true, optional = true }
|
||||||
cssparser = { workspace = true }
|
cssparser = { workspace = true }
|
||||||
|
dom = { path = "../../../dom/base/rust" }
|
||||||
euclid = { workspace = true }
|
euclid = { workspace = true }
|
||||||
http = { workspace = true, optional = true }
|
http = { workspace = true, optional = true }
|
||||||
hyper_serde = { workspace = true, optional = true }
|
hyper_serde = { workspace = true, optional = true }
|
||||||
|
|
|
@ -792,6 +792,8 @@ malloc_size_of_is_0!(app_units::Au);
|
||||||
|
|
||||||
malloc_size_of_is_0!(cssparser::RGBA, cssparser::TokenSerializationType);
|
malloc_size_of_is_0!(cssparser::RGBA, cssparser::TokenSerializationType);
|
||||||
|
|
||||||
|
malloc_size_of_is_0!(dom::ElementState, dom::DocumentState);
|
||||||
|
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
malloc_size_of_is_0!(csp::Destination);
|
malloc_size_of_is_0!(csp::Destination);
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ bitflags = "1.0"
|
||||||
byteorder = "1.0"
|
byteorder = "1.0"
|
||||||
cssparser = "0.29"
|
cssparser = "0.29"
|
||||||
derive_more = "0.99"
|
derive_more = "0.99"
|
||||||
|
dom = { path = "../../../dom/base/rust" }
|
||||||
encoding_rs = { version = "0.8", optional = true }
|
encoding_rs = { version = "0.8", optional = true }
|
||||||
euclid = "0.22"
|
euclid = "0.22"
|
||||||
fxhash = "0.2"
|
fxhash = "0.2"
|
||||||
|
|
|
@ -12,7 +12,6 @@ use crate::context::SharedStyleContext;
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
use crate::context::{PostAnimationTasks, UpdateAnimationsTasks};
|
use crate::context::{PostAnimationTasks, UpdateAnimationsTasks};
|
||||||
use crate::data::ElementData;
|
use crate::data::ElementData;
|
||||||
use crate::element_state::ElementState;
|
|
||||||
use crate::media_queries::Device;
|
use crate::media_queries::Device;
|
||||||
use crate::properties::{AnimationDeclarations, ComputedValues, PropertyDeclarationBlock};
|
use crate::properties::{AnimationDeclarations, ComputedValues, PropertyDeclarationBlock};
|
||||||
use crate::selector_parser::{AttrValue, Lang, PseudoElement, SelectorImpl};
|
use crate::selector_parser::{AttrValue, Lang, PseudoElement, SelectorImpl};
|
||||||
|
@ -22,6 +21,7 @@ use crate::traversal_flags::TraversalFlags;
|
||||||
use crate::values::AtomIdent;
|
use crate::values::AtomIdent;
|
||||||
use crate::{LocalName, Namespace, WeakAtom};
|
use crate::{LocalName, Namespace, WeakAtom};
|
||||||
use atomic_refcell::{AtomicRef, AtomicRefMut};
|
use atomic_refcell::{AtomicRef, AtomicRefMut};
|
||||||
|
use dom::ElementState;
|
||||||
use selectors::matching::{QuirksMode, VisitedHandlingMode};
|
use selectors::matching::{QuirksMode, VisitedHandlingMode};
|
||||||
use selectors::sink::Push;
|
use selectors::sink::Push;
|
||||||
use selectors::Element as SelectorsElement;
|
use selectors::Element as SelectorsElement;
|
||||||
|
|
|
@ -1,152 +0,0 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
//! States elements can be in.
|
|
||||||
|
|
||||||
bitflags! {
|
|
||||||
/// Event-based element states.
|
|
||||||
///
|
|
||||||
/// NB: Is important for this to remain in sync with Gecko's
|
|
||||||
/// dom/events/EventStates.h.
|
|
||||||
///
|
|
||||||
/// Please keep in that order in order for this to be easily auditable.
|
|
||||||
///
|
|
||||||
/// TODO(emilio): We really really want to use the NS_EVENT_STATE bindings
|
|
||||||
/// for this.
|
|
||||||
#[derive(MallocSizeOf)]
|
|
||||||
pub struct ElementState: u64 {
|
|
||||||
/// The mouse is down on this element.
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#selector-active>
|
|
||||||
/// FIXME(#7333): set/unset this when appropriate
|
|
||||||
const IN_ACTIVE_STATE = 1 << 0;
|
|
||||||
/// This element has focus.
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#selector-focus>
|
|
||||||
const IN_FOCUS_STATE = 1 << 1;
|
|
||||||
/// The mouse is hovering over this element.
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#selector-hover>
|
|
||||||
const IN_HOVER_STATE = 1 << 2;
|
|
||||||
/// Content is enabled (and can be disabled).
|
|
||||||
/// <http://www.whatwg.org/html/#selector-enabled>
|
|
||||||
const IN_ENABLED_STATE = 1 << 3;
|
|
||||||
/// Content is disabled.
|
|
||||||
/// <http://www.whatwg.org/html/#selector-disabled>
|
|
||||||
const IN_DISABLED_STATE = 1 << 4;
|
|
||||||
/// Content is checked.
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#selector-checked>
|
|
||||||
const IN_CHECKED_STATE = 1 << 5;
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#selector-indeterminate>
|
|
||||||
const IN_INDETERMINATE_STATE = 1 << 6;
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#selector-placeholder-shown>
|
|
||||||
const IN_PLACEHOLDER_SHOWN_STATE = 1 << 7;
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#selector-target>
|
|
||||||
const IN_TARGET_STATE = 1 << 8;
|
|
||||||
/// <https://fullscreen.spec.whatwg.org/#%3Afullscreen-pseudo-class>
|
|
||||||
const IN_FULLSCREEN_STATE = 1 << 9;
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#selector-valid>
|
|
||||||
const IN_VALID_STATE = 1 << 10;
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#selector-invalid>
|
|
||||||
const IN_INVALID_STATE = 1 << 11;
|
|
||||||
/// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-ui-valid
|
|
||||||
const IN_MOZ_UI_VALID_STATE = 1 << 12;
|
|
||||||
/// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-ui-invalid
|
|
||||||
const IN_MOZ_UI_INVALID_STATE = 1 << 13;
|
|
||||||
/// 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 << 15;
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#selector-required>
|
|
||||||
const IN_REQUIRED_STATE = 1 << 16;
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#selector-optional>
|
|
||||||
const IN_OPTIONAL_STATE = 1 << 17;
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#selector-defined>
|
|
||||||
const IN_DEFINED_STATE = 1 << 18;
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#selector-visited>
|
|
||||||
const IN_VISITED_STATE = 1 << 19;
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#selector-link>
|
|
||||||
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 << 21;
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#selector-in-range>
|
|
||||||
const IN_INRANGE_STATE = 1 << 22;
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#selector-out-of-range>
|
|
||||||
const IN_OUTOFRANGE_STATE = 1 << 23;
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#selector-read-only>
|
|
||||||
const IN_READONLY_STATE = 1 << 24;
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#selector-read-write>
|
|
||||||
const IN_READWRITE_STATE = 1 << 25;
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#selector-default>
|
|
||||||
const IN_DEFAULT_STATE = 1 << 26;
|
|
||||||
/// Non-standard & undocumented.
|
|
||||||
const IN_OPTIMUM_STATE = 1 << 28;
|
|
||||||
/// Non-standard & undocumented.
|
|
||||||
const IN_SUB_OPTIMUM_STATE = 1 << 29;
|
|
||||||
/// Non-standard & undocumented.
|
|
||||||
const IN_SUB_SUB_OPTIMUM_STATE = 1 << 30;
|
|
||||||
/// Non-standard & undocumented.
|
|
||||||
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 << 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 << 34;
|
|
||||||
/// State that elements that match :dir(rtl) are in.
|
|
||||||
const IN_RTL_STATE = 1 << 35;
|
|
||||||
/// State that HTML elements that have a "dir" attr are in.
|
|
||||||
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 << 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 << 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 << 39;
|
|
||||||
/// Non-standard & undocumented.
|
|
||||||
const IN_AUTOFILL_STATE = 1 << 40;
|
|
||||||
/// Non-standard & undocumented.
|
|
||||||
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 << 42;
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#inert-subtrees>
|
|
||||||
const IN_MOZINERT_STATE = 1 << 43;
|
|
||||||
/// State for the topmost modal element in top layer
|
|
||||||
const IN_TOPMOST_MODAL_TOP_LAYER_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;
|
|
||||||
/// For :-moz-value-empty (to show widgets like the reveal password
|
|
||||||
/// button or the clear button).
|
|
||||||
const IN_VALUE_EMPTY_STATE = 1 << 47;
|
|
||||||
/// For :-moz-revealed.
|
|
||||||
const IN_REVEALED_STATE = 1 << 48;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bitflags! {
|
|
||||||
/// Event-based document states.
|
|
||||||
///
|
|
||||||
/// NB: Is important for this to remain in sync with Gecko's
|
|
||||||
/// dom/base/Document.h.
|
|
||||||
#[derive(MallocSizeOf)]
|
|
||||||
pub struct DocumentState: u64 {
|
|
||||||
/// Window activation status
|
|
||||||
const WINDOW_INACTIVE = 1 << 0;
|
|
||||||
/// RTL locale: specific to the XUL localedir attribute
|
|
||||||
const RTL_LOCALE = 1 << 1;
|
|
||||||
/// LTR locale: specific to the XUL localedir attribute
|
|
||||||
const LTR_LOCALE = 1 << 2;
|
|
||||||
/// LWTheme status
|
|
||||||
const LWTHEME = 1 << 3;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -33,56 +33,56 @@ macro_rules! apply_non_ts_list {
|
||||||
("-moz-table-border-nonzero", MozTableBorderNonzero, _, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS),
|
("-moz-table-border-nonzero", MozTableBorderNonzero, _, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS),
|
||||||
("-moz-browser-frame", MozBrowserFrame, _, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME),
|
("-moz-browser-frame", MozBrowserFrame, _, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME),
|
||||||
("-moz-select-list-box", MozSelectListBox, _, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS),
|
("-moz-select-list-box", MozSelectListBox, _, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS),
|
||||||
("link", Link, IN_UNVISITED_STATE, _),
|
("link", Link, UNVISITED, _),
|
||||||
("any-link", AnyLink, IN_VISITED_OR_UNVISITED_STATE, _),
|
("any-link", AnyLink, VISITED_OR_UNVISITED, _),
|
||||||
("visited", Visited, IN_VISITED_STATE, _),
|
("visited", Visited, VISITED, _),
|
||||||
("active", Active, IN_ACTIVE_STATE, _),
|
("active", Active, ACTIVE, _),
|
||||||
("autofill", Autofill, IN_AUTOFILL_STATE, _),
|
("autofill", Autofill, AUTOFILL, _),
|
||||||
("checked", Checked, IN_CHECKED_STATE, _),
|
("checked", Checked, CHECKED, _),
|
||||||
("defined", Defined, IN_DEFINED_STATE, _),
|
("defined", Defined, DEFINED, _),
|
||||||
("disabled", Disabled, IN_DISABLED_STATE, _),
|
("disabled", Disabled, DISABLED, _),
|
||||||
("enabled", Enabled, IN_ENABLED_STATE, _),
|
("enabled", Enabled, ENABLED, _),
|
||||||
("focus", Focus, IN_FOCUS_STATE, _),
|
("focus", Focus, FOCUS, _),
|
||||||
("focus-within", FocusWithin, IN_FOCUS_WITHIN_STATE, _),
|
("focus-within", FocusWithin, FOCUS_WITHIN, _),
|
||||||
("focus-visible", FocusVisible, IN_FOCUSRING_STATE, _),
|
("focus-visible", FocusVisible, FOCUSRING, _),
|
||||||
("hover", Hover, IN_HOVER_STATE, _),
|
("hover", Hover, HOVER, _),
|
||||||
("-moz-drag-over", MozDragOver, IN_DRAGOVER_STATE, _),
|
("-moz-drag-over", MozDragOver, DRAGOVER, _),
|
||||||
("target", Target, IN_TARGET_STATE, _),
|
("target", Target, URLTARGET, _),
|
||||||
("indeterminate", Indeterminate, IN_INDETERMINATE_STATE, _),
|
("indeterminate", Indeterminate, INDETERMINATE, _),
|
||||||
("-moz-inert", MozInert, IN_MOZINERT_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS),
|
("-moz-inert", MozInert, INERT, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS),
|
||||||
("-moz-devtools-highlighted", MozDevtoolsHighlighted, IN_DEVTOOLS_HIGHLIGHTED_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS),
|
("-moz-devtools-highlighted", MozDevtoolsHighlighted, DEVTOOLS_HIGHLIGHTED, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS),
|
||||||
("-moz-styleeditor-transitioning", MozStyleeditorTransitioning, IN_STYLEEDITOR_TRANSITIONING_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS),
|
("-moz-styleeditor-transitioning", MozStyleeditorTransitioning, STYLEEDITOR_TRANSITIONING, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS),
|
||||||
("fullscreen", Fullscreen, IN_FULLSCREEN_STATE, _),
|
("fullscreen", Fullscreen, FULLSCREEN, _),
|
||||||
("-moz-modal-dialog", MozModalDialog, IN_MODAL_DIALOG_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS),
|
("-moz-modal-dialog", MozModalDialog, MODAL_DIALOG, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS),
|
||||||
("-moz-topmost-modal", MozTopmostModal, IN_TOPMOST_MODAL_TOP_LAYER_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS),
|
("-moz-topmost-modal", MozTopmostModal, TOPMOST_MODAL, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS),
|
||||||
("-moz-broken", MozBroken, IN_BROKEN_STATE, _),
|
("-moz-broken", MozBroken, BROKEN, _),
|
||||||
("-moz-loading", MozLoading, IN_LOADING_STATE, _),
|
("-moz-loading", MozLoading, LOADING, _),
|
||||||
("-moz-has-dir-attr", MozHasDirAttr, IN_HAS_DIR_ATTR_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS),
|
("-moz-has-dir-attr", MozHasDirAttr, HAS_DIR_ATTR, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS),
|
||||||
("-moz-dir-attr-ltr", MozDirAttrLTR, IN_HAS_DIR_ATTR_LTR_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS),
|
("-moz-dir-attr-ltr", MozDirAttrLTR, HAS_DIR_ATTR_LTR, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS),
|
||||||
("-moz-dir-attr-rtl", MozDirAttrRTL, IN_HAS_DIR_ATTR_RTL_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS),
|
("-moz-dir-attr-rtl", MozDirAttrRTL, HAS_DIR_ATTR_RTL, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS),
|
||||||
("-moz-dir-attr-like-auto", MozDirAttrLikeAuto, IN_HAS_DIR_ATTR_LIKE_AUTO_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS),
|
("-moz-dir-attr-like-auto", MozDirAttrLikeAuto, HAS_DIR_ATTR_LIKE_AUTO, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS),
|
||||||
|
|
||||||
("-moz-autofill-preview", MozAutofillPreview, IN_AUTOFILL_PREVIEW_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME),
|
("-moz-autofill-preview", MozAutofillPreview, AUTOFILL_PREVIEW, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME),
|
||||||
("-moz-value-empty", MozValueEmpty, IN_VALUE_EMPTY_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS),
|
("-moz-value-empty", MozValueEmpty, VALUE_EMPTY, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS),
|
||||||
("-moz-revealed", MozRevealed, IN_REVEALED_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS),
|
("-moz-revealed", MozRevealed, REVEALED, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS),
|
||||||
|
|
||||||
("-moz-math-increment-script-level", MozMathIncrementScriptLevel, IN_INCREMENT_SCRIPT_LEVEL_STATE, _),
|
("-moz-math-increment-script-level", MozMathIncrementScriptLevel, INCREMENT_SCRIPT_LEVEL, _),
|
||||||
|
|
||||||
("required", Required, IN_REQUIRED_STATE, _),
|
("required", Required, REQUIRED, _),
|
||||||
("optional", Optional, IN_OPTIONAL_STATE, _),
|
("optional", Optional, OPTIONAL_, _),
|
||||||
("valid", Valid, IN_VALID_STATE, _),
|
("valid", Valid, VALID, _),
|
||||||
("invalid", Invalid, IN_INVALID_STATE, _),
|
("invalid", Invalid, INVALID, _),
|
||||||
("in-range", InRange, IN_INRANGE_STATE, _),
|
("in-range", InRange, INRANGE, _),
|
||||||
("out-of-range", OutOfRange, IN_OUTOFRANGE_STATE, _),
|
("out-of-range", OutOfRange, OUTOFRANGE, _),
|
||||||
("default", Default, IN_DEFAULT_STATE, _),
|
("default", Default, DEFAULT, _),
|
||||||
("placeholder-shown", PlaceholderShown, IN_PLACEHOLDER_SHOWN_STATE, _),
|
("placeholder-shown", PlaceholderShown, PLACEHOLDER_SHOWN, _),
|
||||||
("read-only", ReadOnly, IN_READONLY_STATE, _),
|
("read-only", ReadOnly, READONLY, _),
|
||||||
("read-write", ReadWrite, IN_READWRITE_STATE, _),
|
("read-write", ReadWrite, READWRITE, _),
|
||||||
("user-valid", UserValid, IN_MOZ_UI_VALID_STATE, _),
|
("user-valid", UserValid, MOZ_UI_VALID, _),
|
||||||
("user-invalid", UserInvalid, IN_MOZ_UI_INVALID_STATE, _),
|
("user-invalid", UserInvalid, MOZ_UI_INVALID, _),
|
||||||
("-moz-meter-optimum", MozMeterOptimum, IN_OPTIMUM_STATE, _),
|
("-moz-meter-optimum", MozMeterOptimum, OPTIMUM, _),
|
||||||
("-moz-meter-sub-optimum", MozMeterSubOptimum, IN_SUB_OPTIMUM_STATE, _),
|
("-moz-meter-sub-optimum", MozMeterSubOptimum, SUB_OPTIMUM, _),
|
||||||
("-moz-meter-sub-sub-optimum", MozMeterSubSubOptimum, IN_SUB_SUB_OPTIMUM_STATE, _),
|
("-moz-meter-sub-sub-optimum", MozMeterSubSubOptimum, SUB_SUB_OPTIMUM, _),
|
||||||
|
|
||||||
("-moz-first-node", MozFirstNode, _, _),
|
("-moz-first-node", MozFirstNode, _, _),
|
||||||
("-moz-last-node", MozLastNode, _, _),
|
("-moz-last-node", MozLastNode, _, _),
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
//! Gecko-specific bits for selector-parsing.
|
//! Gecko-specific bits for selector-parsing.
|
||||||
|
|
||||||
use crate::element_state::{DocumentState, ElementState};
|
|
||||||
use crate::gecko_bindings::structs::RawServoSelectorList;
|
use crate::gecko_bindings::structs::RawServoSelectorList;
|
||||||
use crate::gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI};
|
use crate::gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI};
|
||||||
use crate::invalidation::element::document_state::InvalidationMatchingData;
|
use crate::invalidation::element::document_state::InvalidationMatchingData;
|
||||||
|
@ -14,6 +13,7 @@ use crate::string_cache::{Atom, Namespace, WeakAtom, WeakNamespace};
|
||||||
use crate::values::{AtomIdent, AtomString};
|
use crate::values::{AtomIdent, AtomString};
|
||||||
use cssparser::{BasicParseError, BasicParseErrorKind, Parser};
|
use cssparser::{BasicParseError, BasicParseErrorKind, Parser};
|
||||||
use cssparser::{CowRcStr, SourceLocation, ToCss, Token};
|
use cssparser::{CowRcStr, SourceLocation, ToCss, Token};
|
||||||
|
use dom::{DocumentState, ElementState};
|
||||||
use selectors::parser::SelectorParseErrorKind;
|
use selectors::parser::SelectorParseErrorKind;
|
||||||
use selectors::SelectorList;
|
use selectors::SelectorList;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
//! change in order to properly calculate restyle hints.
|
//! change in order to properly calculate restyle hints.
|
||||||
|
|
||||||
use crate::dom::TElement;
|
use crate::dom::TElement;
|
||||||
use crate::element_state::ElementState;
|
|
||||||
use crate::gecko::snapshot_helpers;
|
use crate::gecko::snapshot_helpers;
|
||||||
use crate::gecko::wrapper::{GeckoElement, NamespaceConstraintHelpers};
|
use crate::gecko::wrapper::{GeckoElement, NamespaceConstraintHelpers};
|
||||||
use crate::gecko_bindings::bindings;
|
use crate::gecko_bindings::bindings;
|
||||||
|
@ -19,6 +18,7 @@ use crate::string_cache::{Atom, Namespace};
|
||||||
use crate::values::{AtomIdent, AtomString};
|
use crate::values::{AtomIdent, AtomString};
|
||||||
use crate::LocalName;
|
use crate::LocalName;
|
||||||
use crate::WeakAtom;
|
use crate::WeakAtom;
|
||||||
|
use dom::ElementState;
|
||||||
use selectors::attr::{AttrSelectorOperation, AttrSelectorOperator};
|
use selectors::attr::{AttrSelectorOperation, AttrSelectorOperator};
|
||||||
use selectors::attr::{CaseSensitivity, NamespaceConstraint};
|
use selectors::attr::{CaseSensitivity, NamespaceConstraint};
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ use crate::author_styles::AuthorStyles;
|
||||||
use crate::context::{PostAnimationTasks, QuirksMode, SharedStyleContext, UpdateAnimationsTasks};
|
use crate::context::{PostAnimationTasks, QuirksMode, SharedStyleContext, UpdateAnimationsTasks};
|
||||||
use crate::data::ElementData;
|
use crate::data::ElementData;
|
||||||
use crate::dom::{LayoutIterator, NodeInfo, OpaqueNode, TDocument, TElement, TNode, TShadowRoot};
|
use crate::dom::{LayoutIterator, NodeInfo, OpaqueNode, TDocument, TElement, TNode, TShadowRoot};
|
||||||
use crate::element_state::{DocumentState, ElementState};
|
use dom::{DocumentState, ElementState};
|
||||||
use crate::gecko::data::GeckoStyleSheet;
|
use crate::gecko::data::GeckoStyleSheet;
|
||||||
use crate::gecko::selector_parser::{NonTSPseudoClass, PseudoElement, SelectorImpl};
|
use crate::gecko::selector_parser::{NonTSPseudoClass, PseudoElement, SelectorImpl};
|
||||||
use crate::gecko::snapshot_helpers;
|
use crate::gecko::snapshot_helpers;
|
||||||
|
@ -732,14 +732,14 @@ impl<'le> GeckoElement<'le> {
|
||||||
.as_node()
|
.as_node()
|
||||||
.get_bool_flag(nsINode_BooleanFlag::ElementHasLockedStyleStates)
|
.get_bool_flag(nsINode_BooleanFlag::ElementHasLockedStyleStates)
|
||||||
{
|
{
|
||||||
return self.0.mState.mStates;
|
return self.0.mState.bits;
|
||||||
}
|
}
|
||||||
unsafe { Gecko_ElementState(self.0) }
|
unsafe { Gecko_ElementState(self.0) }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn document_state(&self) -> DocumentState {
|
fn document_state(&self) -> DocumentState {
|
||||||
DocumentState::from_bits_truncate(self.as_node().owner_doc().0.mDocumentState.mStates)
|
DocumentState::from_bits_truncate(self.as_node().owner_doc().0.mDocumentState.bits)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -1336,7 +1336,7 @@ impl<'le> TElement for GeckoElement<'le> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_visited_link(&self) -> bool {
|
fn is_visited_link(&self) -> bool {
|
||||||
self.state().intersects(ElementState::IN_VISITED_STATE)
|
self.state().intersects(ElementState::VISITED)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This logic is duplicated in Gecko's nsINode::IsInNativeAnonymousSubtree.
|
/// This logic is duplicated in Gecko's nsINode::IsInNativeAnonymousSubtree.
|
||||||
|
@ -2107,8 +2107,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_link(&self) -> bool {
|
fn is_link(&self) -> bool {
|
||||||
self.state()
|
self.state().intersects(ElementState::VISITED_OR_UNVISITED)
|
||||||
.intersects(ElementState::IN_VISITED_OR_UNVISITED_STATE)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -5,12 +5,12 @@
|
||||||
//! An invalidation processor for style changes due to document state changes.
|
//! An invalidation processor for style changes due to document state changes.
|
||||||
|
|
||||||
use crate::dom::TElement;
|
use crate::dom::TElement;
|
||||||
use crate::element_state::DocumentState;
|
|
||||||
use crate::invalidation::element::invalidation_map::Dependency;
|
use crate::invalidation::element::invalidation_map::Dependency;
|
||||||
use crate::invalidation::element::invalidator::{DescendantInvalidationLists, InvalidationVector};
|
use crate::invalidation::element::invalidator::{DescendantInvalidationLists, InvalidationVector};
|
||||||
use crate::invalidation::element::invalidator::{Invalidation, InvalidationProcessor};
|
use crate::invalidation::element::invalidator::{Invalidation, InvalidationProcessor};
|
||||||
use crate::invalidation::element::state_and_attributes;
|
use crate::invalidation::element::state_and_attributes;
|
||||||
use crate::stylist::CascadeData;
|
use crate::stylist::CascadeData;
|
||||||
|
use dom::DocumentState;
|
||||||
use selectors::matching::{MatchingContext, MatchingMode, QuirksMode, VisitedHandlingMode, NeedsSelectorFlags};
|
use selectors::matching::{MatchingContext, MatchingMode, QuirksMode, VisitedHandlingMode, NeedsSelectorFlags};
|
||||||
|
|
||||||
/// A struct holding the members necessary to invalidate document state
|
/// A struct holding the members necessary to invalidate document state
|
||||||
|
|
|
@ -6,11 +6,11 @@
|
||||||
//! against a past state of the element.
|
//! against a past state of the element.
|
||||||
|
|
||||||
use crate::dom::TElement;
|
use crate::dom::TElement;
|
||||||
use crate::element_state::ElementState;
|
|
||||||
use crate::selector_parser::{AttrValue, NonTSPseudoClass, PseudoElement, SelectorImpl};
|
use crate::selector_parser::{AttrValue, NonTSPseudoClass, PseudoElement, SelectorImpl};
|
||||||
use crate::selector_parser::{Snapshot, SnapshotMap};
|
use crate::selector_parser::{Snapshot, SnapshotMap};
|
||||||
use crate::values::AtomIdent;
|
use crate::values::AtomIdent;
|
||||||
use crate::{CaseSensitivityExt, LocalName, Namespace, WeakAtom};
|
use crate::{CaseSensitivityExt, LocalName, Namespace, WeakAtom};
|
||||||
|
use dom::ElementState;
|
||||||
use selectors::attr::{AttrSelectorOperation, CaseSensitivity, NamespaceConstraint};
|
use selectors::attr::{AttrSelectorOperation, CaseSensitivity, NamespaceConstraint};
|
||||||
use selectors::matching::{ElementSelectorFlags, MatchingContext};
|
use selectors::matching::{ElementSelectorFlags, MatchingContext};
|
||||||
use selectors::{Element, OpaqueElement};
|
use selectors::{Element, OpaqueElement};
|
||||||
|
@ -252,7 +252,7 @@ where
|
||||||
|
|
||||||
fn is_link(&self) -> bool {
|
fn is_link(&self) -> bool {
|
||||||
match self.snapshot().and_then(|s| s.state()) {
|
match self.snapshot().and_then(|s| s.state()) {
|
||||||
Some(state) => state.intersects(ElementState::IN_VISITED_OR_UNVISITED_STATE),
|
Some(state) => state.intersects(ElementState::VISITED_OR_UNVISITED),
|
||||||
None => self.element.is_link(),
|
None => self.element.is_link(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,13 +5,13 @@
|
||||||
//! Code for invalidations due to state or attribute changes.
|
//! Code for invalidations due to state or attribute changes.
|
||||||
|
|
||||||
use crate::context::QuirksMode;
|
use crate::context::QuirksMode;
|
||||||
use crate::element_state::{DocumentState, ElementState};
|
|
||||||
use crate::selector_map::{
|
use crate::selector_map::{
|
||||||
MaybeCaseInsensitiveHashMap, PrecomputedHashMap, SelectorMap, SelectorMapEntry,
|
MaybeCaseInsensitiveHashMap, PrecomputedHashMap, SelectorMap, SelectorMapEntry,
|
||||||
};
|
};
|
||||||
use crate::selector_parser::SelectorImpl;
|
use crate::selector_parser::SelectorImpl;
|
||||||
use crate::AllocErr;
|
use crate::AllocErr;
|
||||||
use crate::{Atom, LocalName, Namespace, ShrinkIfNeeded};
|
use crate::{Atom, LocalName, Namespace, ShrinkIfNeeded};
|
||||||
|
use dom::{DocumentState, ElementState};
|
||||||
use selectors::attr::NamespaceConstraint;
|
use selectors::attr::NamespaceConstraint;
|
||||||
use selectors::parser::{Combinator, Component};
|
use selectors::parser::{Combinator, Component};
|
||||||
use selectors::parser::{Selector, SelectorIter};
|
use selectors::parser::{Selector, SelectorIter};
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
use crate::context::SharedStyleContext;
|
use crate::context::SharedStyleContext;
|
||||||
use crate::data::ElementData;
|
use crate::data::ElementData;
|
||||||
use crate::dom::TElement;
|
use crate::dom::TElement;
|
||||||
use crate::element_state::ElementState;
|
|
||||||
use crate::invalidation::element::element_wrapper::{ElementSnapshot, ElementWrapper};
|
use crate::invalidation::element::element_wrapper::{ElementSnapshot, ElementWrapper};
|
||||||
use crate::invalidation::element::invalidation_map::*;
|
use crate::invalidation::element::invalidation_map::*;
|
||||||
use crate::invalidation::element::invalidator::{DescendantInvalidationLists, InvalidationVector};
|
use crate::invalidation::element::invalidator::{DescendantInvalidationLists, InvalidationVector};
|
||||||
|
@ -18,6 +17,7 @@ use crate::selector_map::SelectorMap;
|
||||||
use crate::selector_parser::Snapshot;
|
use crate::selector_parser::Snapshot;
|
||||||
use crate::stylesheets::origin::OriginSet;
|
use crate::stylesheets::origin::OriginSet;
|
||||||
use crate::{Atom, WeakAtom};
|
use crate::{Atom, WeakAtom};
|
||||||
|
use dom::ElementState;
|
||||||
use selectors::attr::CaseSensitivity;
|
use selectors::attr::CaseSensitivity;
|
||||||
use selectors::matching::{matches_selector, MatchingContext, MatchingMode, VisitedHandlingMode, NeedsSelectorFlags};
|
use selectors::matching::{matches_selector, MatchingContext, MatchingMode, VisitedHandlingMode, NeedsSelectorFlags};
|
||||||
use selectors::NthIndexCache;
|
use selectors::NthIndexCache;
|
||||||
|
@ -201,7 +201,7 @@ where
|
||||||
// TODO(emilio): This piece of code should be removed when
|
// TODO(emilio): This piece of code should be removed when
|
||||||
// layout.css.always-repaint-on-unvisited is true, since we cannot get
|
// layout.css.always-repaint-on-unvisited is true, since we cannot get
|
||||||
// into this situation in that case.
|
// into this situation in that case.
|
||||||
if state_changes.contains(ElementState::IN_VISITED_OR_UNVISITED_STATE) {
|
if state_changes.contains(ElementState::VISITED_OR_UNVISITED) {
|
||||||
trace!(" > visitedness change, force subtree restyle");
|
trace!(" > visitedness change, force subtree restyle");
|
||||||
// We can't just return here because there may also be attribute
|
// We can't just return here because there may also be attribute
|
||||||
// changes as well that imply additional hints for siblings.
|
// changes as well that imply additional hints for siblings.
|
||||||
|
|
|
@ -89,7 +89,6 @@ pub mod data;
|
||||||
pub mod dom;
|
pub mod dom;
|
||||||
pub mod dom_apis;
|
pub mod dom_apis;
|
||||||
pub mod driver;
|
pub mod driver;
|
||||||
pub mod element_state;
|
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
mod encoding_support;
|
mod encoding_support;
|
||||||
pub mod error_reporting;
|
pub mod error_reporting;
|
||||||
|
|
|
@ -6,11 +6,11 @@
|
||||||
|
|
||||||
#![deny(missing_docs)]
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
use crate::element_state::ElementState;
|
|
||||||
use crate::stylesheets::{Namespaces, Origin, UrlExtraData};
|
use crate::stylesheets::{Namespaces, Origin, UrlExtraData};
|
||||||
use crate::values::serialize_atom_identifier;
|
use crate::values::serialize_atom_identifier;
|
||||||
use crate::Atom;
|
use crate::Atom;
|
||||||
use cssparser::{Parser as CssParser, ParserInput};
|
use cssparser::{Parser as CssParser, ParserInput};
|
||||||
|
use dom::ElementState;
|
||||||
use selectors::parser::SelectorList;
|
use selectors::parser::SelectorList;
|
||||||
use std::fmt::{self, Debug, Write};
|
use std::fmt::{self, Debug, Write};
|
||||||
use style_traits::{CssWriter, ParseError, ToCss};
|
use style_traits::{CssWriter, ParseError, ToCss};
|
||||||
|
@ -220,8 +220,8 @@ impl Direction {
|
||||||
/// Gets the element state relevant to this :dir() selector.
|
/// Gets the element state relevant to this :dir() selector.
|
||||||
pub fn element_state(&self) -> ElementState {
|
pub fn element_state(&self) -> ElementState {
|
||||||
match self.as_horizontal_direction() {
|
match self.as_horizontal_direction() {
|
||||||
Some(HorizontalDirection::Ltr) => ElementState::IN_LTR_STATE,
|
Some(HorizontalDirection::Ltr) => ElementState::LTR,
|
||||||
Some(HorizontalDirection::Rtl) => ElementState::IN_RTL_STATE,
|
Some(HorizontalDirection::Rtl) => ElementState::RTL,
|
||||||
None => ElementState::empty(),
|
None => ElementState::empty(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
use crate::attr::{AttrIdentifier, AttrValue};
|
use crate::attr::{AttrIdentifier, AttrValue};
|
||||||
use crate::dom::{OpaqueNode, TElement, TNode};
|
use crate::dom::{OpaqueNode, TElement, TNode};
|
||||||
use crate::element_state::{DocumentState, ElementState};
|
|
||||||
use crate::invalidation::element::document_state::InvalidationMatchingData;
|
use crate::invalidation::element::document_state::InvalidationMatchingData;
|
||||||
use crate::invalidation::element::element_wrapper::ElementSnapshot;
|
use crate::invalidation::element::element_wrapper::ElementSnapshot;
|
||||||
use crate::properties::longhands::display::computed_value::T as Display;
|
use crate::properties::longhands::display::computed_value::T as Display;
|
||||||
|
@ -18,6 +17,7 @@ use crate::selector_parser::{PseudoElementCascadeType, SelectorParser};
|
||||||
use crate::values::{AtomIdent, AtomString};
|
use crate::values::{AtomIdent, AtomString};
|
||||||
use crate::{Atom, CaseSensitivityExt, LocalName, Namespace, Prefix};
|
use crate::{Atom, CaseSensitivityExt, LocalName, Namespace, Prefix};
|
||||||
use cssparser::{serialize_identifier, CowRcStr, Parser as CssParser, SourceLocation, ToCss};
|
use cssparser::{serialize_identifier, CowRcStr, Parser as CssParser, SourceLocation, ToCss};
|
||||||
|
use dom::{DocumentState, ElementState};
|
||||||
use fxhash::FxHashMap;
|
use fxhash::FxHashMap;
|
||||||
use selectors::attr::{AttrSelectorOperation, CaseSensitivity, NamespaceConstraint};
|
use selectors::attr::{AttrSelectorOperation, CaseSensitivity, NamespaceConstraint};
|
||||||
use selectors::parser::SelectorParseErrorKind;
|
use selectors::parser::SelectorParseErrorKind;
|
||||||
|
|
|
@ -9,7 +9,6 @@ use crate::applicable_declarations::{
|
||||||
};
|
};
|
||||||
use crate::context::{CascadeInputs, QuirksMode};
|
use crate::context::{CascadeInputs, QuirksMode};
|
||||||
use crate::dom::{TElement, TShadowRoot};
|
use crate::dom::{TElement, TShadowRoot};
|
||||||
use crate::element_state::{DocumentState, ElementState};
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
use crate::gecko_bindings::structs::{ServoStyleSetSizes, StyleRuleInclusion};
|
use crate::gecko_bindings::structs::{ServoStyleSetSizes, StyleRuleInclusion};
|
||||||
use crate::invalidation::element::invalidation_map::InvalidationMap;
|
use crate::invalidation::element::invalidation_map::InvalidationMap;
|
||||||
|
@ -42,6 +41,7 @@ use crate::stylesheets::{
|
||||||
use crate::stylesheets::{StyleRule, StylesheetContents, StylesheetInDocument};
|
use crate::stylesheets::{StyleRule, StylesheetContents, StylesheetInDocument};
|
||||||
use crate::AllocErr;
|
use crate::AllocErr;
|
||||||
use crate::{Atom, LocalName, Namespace, ShrinkIfNeeded, WeakAtom};
|
use crate::{Atom, LocalName, Namespace, ShrinkIfNeeded, WeakAtom};
|
||||||
|
use dom::{DocumentState, ElementState};
|
||||||
use fxhash::FxHashMap;
|
use fxhash::FxHashMap;
|
||||||
use malloc_size_of::{MallocSizeOf, MallocShallowSizeOf, MallocSizeOfOps};
|
use malloc_size_of::{MallocSizeOf, MallocShallowSizeOf, MallocSizeOfOps};
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue