diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2018-03-03 22:14:36 +0100 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2018-03-03 23:52:49 +0100 |
commit | 2f0df1b421014ee2d024aea6bc2961e31debd328 (patch) | |
tree | 040f6d1914babcd26f4dd0ff5609e028ba93543b /components/layout_thread | |
parent | df079286c232f49c5317a3d18a1052b1a6d274cd (diff) | |
download | servo-2f0df1b421014ee2d024aea6bc2961e31debd328.tar.gz servo-2f0df1b421014ee2d024aea6bc2961e31debd328.zip |
style: Add bindings for ShadowRoot.
This adds TShadowRoot to the `dom` module.
Right now it barely adds uses of it, but this is a prerequisite to fix a bunch
of Shadow DOM bugs and separate it from the XBL mess.
Diffstat (limited to 'components/layout_thread')
-rw-r--r-- | components/layout_thread/dom_wrapper.rs | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/components/layout_thread/dom_wrapper.rs b/components/layout_thread/dom_wrapper.rs index 1eaf74e4e9d..b9baea95b0e 100644 --- a/components/layout_thread/dom_wrapper.rs +++ b/components/layout_thread/dom_wrapper.rs @@ -66,7 +66,7 @@ use style::attr::AttrValue; use style::context::SharedStyleContext; use style::data::ElementData; use style::dom::{DomChildren, LayoutIterator, NodeInfo, OpaqueNode}; -use style::dom::{TDocument, TElement, TNode}; +use style::dom::{TDocument, TElement, TNode, TShadowRoot}; use style::element_state::*; use style::font_metrics::ServoMetricsProvider; use style::properties::{ComputedValues, PropertyDeclarationBlock}; @@ -150,9 +150,28 @@ impl<'ln> NodeInfo for ServoLayoutNode<'ln> { } } +#[derive(Clone, Copy)] +enum Impossible { } + +#[derive(Clone, Copy)] +pub struct ShadowRoot<'lr>(Impossible, PhantomData<&'lr ()>); + +impl<'lr> TShadowRoot for ShadowRoot<'lr> { + type ConcreteNode = ServoLayoutNode<'lr>; + + fn as_node(&self) -> Self::ConcreteNode { + match self.0 { } + } + + fn host(&self) -> ServoLayoutElement<'lr> { + match self.0 { } + } +} + impl<'ln> TNode for ServoLayoutNode<'ln> { type ConcreteDocument = ServoLayoutDocument<'ln>; type ConcreteElement = ServoLayoutElement<'ln>; + type ConcreteShadowRoot = ShadowRoot<'ln>; fn parent_node(&self) -> Option<Self> { unsafe { @@ -208,6 +227,10 @@ impl<'ln> TNode for ServoLayoutNode<'ln> { self.node.downcast().map(ServoLayoutDocument::from_layout_js) } + fn as_shadow_root(&self) -> Option<ShadowRoot<'ln>> { + None + } + fn is_in_document(&self) -> bool { unsafe { self.node.get_flag(NodeFlags::IS_IN_DOC) } } @@ -489,11 +512,11 @@ impl<'le> TElement for ServoLayoutElement<'le> { .map(|v| String::from(v as &str)) } - fn match_element_lang(&self, - override_lang: Option<Option<SelectorAttrValue>>, - value: &PseudoClassStringArg) - -> bool - { + fn match_element_lang( + &self, + override_lang: Option<Option<SelectorAttrValue>>, + value: &PseudoClassStringArg, + ) -> bool { // Servo supports :lang() from CSS Selectors 4, which can take a comma- // separated list of language tags in the pseudo-class, and which // performs RFC 4647 extended filtering matching on them. @@ -535,6 +558,10 @@ impl<'le> TElement for ServoLayoutElement<'le> { self.element.synthesize_presentational_hints_for_legacy_attributes(hints); } } + + fn shadow_root(&self) -> Option<ShadowRoot<'le>> { + None + } } impl<'le> PartialEq for ServoLayoutElement<'le> { |