aboutsummaryrefslogtreecommitdiffstats
path: root/components/style
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <me@emiliocobos.me>2016-05-03 18:50:25 +0200
committerEmilio Cobos Álvarez <me@emiliocobos.me>2016-05-04 00:33:58 +0200
commit028f9b6cd26f0cd2835166d96ffd30d69a39e7cb (patch)
tree1beb0bcf4072a078593e6ba17f9618aad71a944c /components/style
parent18c1fee3c7cd2fb36064bdb06a130b16785db128 (diff)
downloadservo-028f9b6cd26f0cd2835166d96ffd30d69a39e7cb.tar.gz
servo-028f9b6cd26f0cd2835166d96ffd30d69a39e7cb.zip
style: layout: Allow a lazy pseudo-element implementation in Servo.
Diffstat (limited to 'components/style')
-rw-r--r--components/style/dom.rs10
-rw-r--r--components/style/selector_impl.rs12
-rw-r--r--components/style/selector_matching.rs7
3 files changed, 12 insertions, 17 deletions
diff --git a/components/style/dom.rs b/components/style/dom.rs
index fed1597c627..badd4f31065 100644
--- a/components/style/dom.rs
+++ b/components/style/dom.rs
@@ -195,7 +195,12 @@ pub trait TDocument : Sized + Copy + Clone {
fn drain_modified_elements(&self) -> Vec<(Self::ConcreteElement, ElementSnapshot)>;
}
-pub trait TElement : Sized + Copy + Clone + ElementExt {
+pub trait PresentationalHintsSynthetizer {
+ fn synthesize_presentational_hints_for_legacy_attributes<V>(&self, hints: &mut V)
+ where V: VecLike<DeclarationBlock<Vec<PropertyDeclaration>>>;
+}
+
+pub trait TElement : Sized + Copy + Clone + ElementExt + PresentationalHintsSynthetizer {
type ConcreteNode: TNode<ConcreteElement = Self, ConcreteDocument = Self::ConcreteDocument>;
type ConcreteDocument: TDocument<ConcreteNode = Self::ConcreteNode, ConcreteElement = Self>;
@@ -205,9 +210,6 @@ pub trait TElement : Sized + Copy + Clone + ElementExt {
fn get_state(&self) -> ElementState;
- fn synthesize_presentational_hints_for_legacy_attributes<V>(&self, &mut V)
- where V: VecLike<DeclarationBlock<Vec<PropertyDeclaration>>>;
-
fn get_attr<'a>(&'a self, namespace: &Namespace, attr: &Atom) -> Option<&'a str>;
fn get_attrs<'a>(&'a self, attr: &Atom) -> Vec<&'a str>;
diff --git a/components/style/selector_impl.rs b/components/style/selector_impl.rs
index e0c1b2c3f98..b424affb101 100644
--- a/components/style/selector_impl.rs
+++ b/components/style/selector_impl.rs
@@ -104,19 +104,11 @@ pub enum PseudoElement {
impl PseudoElement {
#[inline]
pub fn cascade_type(&self) -> PseudoElementCascadeType {
- // TODO: Make PseudoElementCascadeType::Lazy work for Servo.
- //
- // This can't be done right now since it would require
- // ServoThreadSafeLayoutElement to implement ::selectors::Element,
- // and it might not be thread-safe.
- //
- // After that, we'd probably want ::selection and
- // ::-servo-details-summary to be lazy.
match *self {
PseudoElement::Before |
PseudoElement::After |
- PseudoElement::Selection |
- PseudoElement::DetailsSummary => PseudoElementCascadeType::Eager,
+ PseudoElement::Selection => PseudoElementCascadeType::Eager,
+ PseudoElement::DetailsSummary => PseudoElementCascadeType::Lazy,
PseudoElement::DetailsContent => PseudoElementCascadeType::Precomputed,
}
}
diff --git a/components/style/selector_matching.rs b/components/style/selector_matching.rs
index e59955f3a0e..4faf9aa0eb4 100644
--- a/components/style/selector_matching.rs
+++ b/components/style/selector_matching.rs
@@ -5,7 +5,7 @@
// For lazy_static
#![allow(unsafe_code)]
-use dom::TElement;
+use dom::PresentationalHintsSynthetizer;
use element_state::*;
use error_reporting::{ParseErrorReporter, StdoutErrorReporter};
use media_queries::{Device, MediaType};
@@ -281,7 +281,8 @@ impl<Impl: SelectorImplExt> Stylist<Impl> {
pseudo: &Impl::PseudoElement,
parent: &Arc<Impl::ComputedValues>)
-> Option<Arc<Impl::ComputedValues>>
- where E: Element<Impl=Impl> + TElement {
+ where E: Element<Impl=Impl> +
+ PresentationalHintsSynthetizer {
debug_assert!(Impl::pseudo_element_cascade_type(pseudo).is_lazy());
if self.pseudos_map.get(pseudo).is_none() {
return None;
@@ -358,7 +359,7 @@ impl<Impl: SelectorImplExt> Stylist<Impl> {
pseudo_element: Option<&Impl::PseudoElement>,
applicable_declarations: &mut V)
-> bool
- where E: Element<Impl=Impl> + TElement,
+ where E: Element<Impl=Impl> + PresentationalHintsSynthetizer,
V: VecLike<DeclarationBlock> {
assert!(!self.is_device_dirty);
assert!(style_attribute.is_none() || pseudo_element.is_none(),