aboutsummaryrefslogtreecommitdiffstats
path: root/components/style/servo/selector_parser.rs
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2018-01-22 23:53:03 +0100
committerEmilio Cobos Álvarez <emilio@crisal.io>2018-01-23 13:18:54 +0100
commitcd04664fb987ebfab063cbbff1a2516bd16b8cd4 (patch)
tree7014c16a4f6b214623bba8a91cb91777e29e56f6 /components/style/servo/selector_parser.rs
parent104f5c2553606d0b26d7cf2ad9b90eb2efd94792 (diff)
downloadservo-cd04664fb987ebfab063cbbff1a2516bd16b8cd4.tar.gz
servo-cd04664fb987ebfab063cbbff1a2516bd16b8cd4.zip
style: Use CascadeFlags for what they're for.
Now that we have an Element around on cascade, we can stop using the cascade flags mechanism to pass various element-related state, like "is this element the root", or "should it use the item-based display fixup". That fixes handwaviness in the handling of those flags from style reparenting, and code duplication to handle tricky stuff like :visited. There are a number of other changes that are worth noticing: * skip_root_and_item_based_display_fixup is renamed to skip_item_display_fixup: TElement::is_root() already implies being the document element, which by definition is not native anonymous and not a pseudo-element. Thus, you never get fixed-up if your NAC or a pseudo, which is what the code tried to avoid, so the only fixup with a point is the item one, which is necessary. * The pseudo-element probing code was refactored to return early a Option::<CascadeInputs>::None, which is nicer than what it was doing. * The visited_links_enabled check has moved to selector-matching time. The rest of the checks aren't based on whether the element is a link, or are properly guarded by parent_style.visited_style().is_some() or visited_rules.is_some(). Thus you can transitively infer that no element will end up with a :visited style, not even from style reparenting. Anyway, the underlying reason why I want the element in StyleAdjuster is because we're going to implement an adjustment in there depending on the tag of the element (converting display: contents to display: none depending on the tag), so computing that information eagerly, including a hash lookup, wouldn't be nice.
Diffstat (limited to 'components/style/servo/selector_parser.rs')
-rw-r--r--components/style/servo/selector_parser.rs46
1 files changed, 41 insertions, 5 deletions
diff --git a/components/style/servo/selector_parser.rs b/components/style/servo/selector_parser.rs
index bc6cc31cf7d..04c164e290d 100644
--- a/components/style/servo/selector_parser.rs
+++ b/components/style/servo/selector_parser.rs
@@ -14,8 +14,7 @@ use element_state::{DocumentState, ElementState};
use fnv::FnvHashMap;
use invalidation::element::document_state::InvalidationMatchingData;
use invalidation::element::element_wrapper::ElementSnapshot;
-use properties::ComputedValues;
-use properties::PropertyFlags;
+use properties::{CascadeFlags, ComputedValues, PropertyFlags};
use properties::longhands::display::computed_value::T as Display;
use selector_parser::{AttrValue as SelectorAttrValue, PseudoElementCascadeType, SelectorParser};
use selectors::attr::{AttrSelectorOperation, NamespaceConstraint, CaseSensitivity};
@@ -174,10 +173,10 @@ impl PseudoElement {
self.is_precomputed()
}
- /// Whether this pseudo-element skips flex/grid container
- /// display-based fixup.
+ /// Whether this pseudo-element skips flex/grid container display-based
+ /// fixup.
#[inline]
- pub fn skip_item_based_display_fixup(&self) -> bool {
+ pub fn skip_item_display_fixup(&self) -> bool {
!self.is_before_or_after()
}
@@ -213,6 +212,43 @@ impl PseudoElement {
}
}
+ /// For most (but not all) anon-boxes, we inherit all values from the
+ /// parent, this is the hook in the style system to allow this.
+ ///
+ /// FIXME(emilio): It's likely that this is broken in a variety of
+ /// situations, and what it really wants is just inherit some reset
+ /// properties... Also, I guess it just could do all: inherit on the
+ /// stylesheet, though chances are that'd be kinda slow if we don't cache
+ /// them...
+ pub fn cascade_flags(&self) -> CascadeFlags {
+ match *self {
+ PseudoElement::After |
+ PseudoElement::Before |
+ PseudoElement::Selection |
+ PseudoElement::DetailsContent |
+ PseudoElement::DetailsSummary => CascadeFlags::empty(),
+ // Anonymous table flows shouldn't inherit their parents properties in order
+ // to avoid doubling up styles such as transformations.
+ PseudoElement::ServoAnonymousTableCell |
+ PseudoElement::ServoAnonymousTableRow |
+ PseudoElement::ServoText |
+ PseudoElement::ServoInputText => CascadeFlags::empty(),
+
+ // For tables, we do want style to inherit, because TableWrapper is
+ // responsible for handling clipping and scrolling, while Table is
+ // responsible for creating stacking contexts.
+ //
+ // StackingContextCollectionFlags makes sure this is processed
+ // properly.
+ PseudoElement::ServoAnonymousTable |
+ PseudoElement::ServoAnonymousTableWrapper |
+ PseudoElement::ServoTableWrapper |
+ PseudoElement::ServoAnonymousBlock |
+ PseudoElement::ServoInlineBlockWrapper |
+ PseudoElement::ServoInlineAbsolute => CascadeFlags::INHERIT_ALL,
+ }
+ }
+
/// Covert non-canonical pseudo-element to canonical one, and keep a
/// canonical one as it is.
pub fn canonical(&self) -> PseudoElement {