style: Support lazy pseudo-elements

These can't be supported in Servo as of right now, because I'm not
totally sure the accesses that should be done in layout would be
thread-safe.

It can be revisited later though.
This commit is contained in:
Emilio Cobos Álvarez 2016-04-29 22:29:59 +02:00
parent 3f2ceeff5d
commit 9caaa6004e
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
7 changed files with 206 additions and 72 deletions

View file

@ -267,7 +267,7 @@ pub extern "C" fn Servo_GetComputedValuesForAnonymousBox(parent_style_or_null: *
type Helpers = ArcHelpers<ServoComputedValues, GeckoComputedValues>;
Helpers::maybe_with(parent_style_or_null, |maybe_parent| {
let new_computed = data.stylist.computed_values_for_pseudo(&pseudo, maybe_parent);
let new_computed = data.stylist.precomputed_values_for_pseudo(&pseudo, maybe_parent);
new_computed.map_or(ptr::null_mut(), |c| Helpers::from(c))
})
}

View file

@ -6,7 +6,7 @@ use properties::GeckoComputedValues;
use selectors::parser::{ParserContext, SelectorImpl};
use style;
use style::element_state::ElementState;
use style::selector_impl::SelectorImplExt;
use style::selector_impl::{PseudoElementCascadeType, SelectorImplExt};
pub type Stylist = style::selector_matching::Stylist<GeckoSelectorImpl>;
pub type Stylesheet = style::stylesheets::Stylesheet<GeckoSelectorImpl>;
@ -89,6 +89,36 @@ pub enum PseudoElement {
MozSVGText,
}
impl PseudoElement {
fn is_anon_box_pseudo(&self) -> bool {
use self::PseudoElement::*;
match *self {
MozNonElement | MozAnonymousBlock | MozAnonymousPositionedBlock |
MozMathMLAnonymousBlock | MozXULAnonymousBlock |
MozHorizontalFramesetBorder | MozVerticalFramesetBorder |
MozLineFrame | MozButtonContent | MozButtonLabel | MozCellContent |
MozDropdownList | MozFieldsetContent | MozFramesetBlank |
MozDisplayComboboxControlFrame |
MozHTMLCanvasContent | MozInlineTable | MozTable | MozTableCell |
MozTableColumnGroup | MozTableColumn | MozTableOuter |
MozTableRowGroup | MozTableRow | MozCanvas | MozPageBreak |
MozPage | MozPageContent | MozPageSequence | MozScrolledContent |
MozScrolledCanvas | MozScrolledPageSequence | MozColumnContent |
MozViewport | MozViewportScroll | MozAnonymousFlexItem |
MozAnonymousGridItem | MozRuby | MozRubyBase |
MozRubyBaseContainer | MozRubyText | MozRubyTextContainer |
MozTreeColumn | MozTreeRow | MozTreeSeparator | MozTreeCell |
MozTreeIndentation | MozTreeLine | MozTreeTwisty | MozTreeImage |
MozTreeCellText | MozTreeCheckbox | MozTreeProgressMeter |
MozTreeDropFeedback | MozSVGMarkerAnonChild |
MozSVGOuterSVGAnonChild | MozSVGForeignContent |
MozSVGText => true,
_ => false,
}
}
}
#[derive(Clone, Debug, PartialEq, Eq, HeapSizeOf, Hash)]
pub enum NonTSPseudoClass {
AnyLink,
@ -243,12 +273,17 @@ impl SelectorImplExt for GeckoSelectorImpl {
type ComputedValues = GeckoComputedValues;
#[inline]
fn is_eagerly_cascaded_pseudo_element(pseudo: &PseudoElement) -> bool {
fn pseudo_element_cascade_type(pseudo: &PseudoElement) -> PseudoElementCascadeType {
match *pseudo {
PseudoElement::Before |
PseudoElement::After |
PseudoElement::FirstLine => true,
_ => false,
PseudoElement::After => PseudoElementCascadeType::Eager,
_ => {
if pseudo.is_anon_box_pseudo() {
PseudoElementCascadeType::Precomputed
} else {
PseudoElementCascadeType::Lazy
}
}
}
}