aboutsummaryrefslogtreecommitdiffstats
path: root/components/script_layout_interface/wrapper_traits.rs
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2018-01-22 21:49:18 +0100
committerEmilio Cobos Álvarez <emilio@crisal.io>2018-01-23 00:57:54 +0100
commit5ac12b5df4406dbde1ceeb6be36be5c3162401a2 (patch)
tree173742ffb60360fc56f39a5b05b53890e84853ee /components/script_layout_interface/wrapper_traits.rs
parent6f543d3de1658e3cacf7fc2caed7b9bda69e1d23 (diff)
downloadservo-5ac12b5df4406dbde1ceeb6be36be5c3162401a2.tar.gz
servo-5ac12b5df4406dbde1ceeb6be36be5c3162401a2.zip
style: Make the TElement type arrive to the `cascade` function.
Not super-proud of this one, but it's the easiest way I could think of. The changeset looks bigger than what it is, because while at it I've rewrapped a fair amount of functions around to use proper block indentation. Alternatives are parameterizing Stylist by <E>, which is not fun, or moving the concrete element from layout_thread to layout, but that implies layout depending on script, which isn't fun either. Other alternative is implementing an empty enum and making anon boxes work on it. It has the advantage of removing the annoying type parameter, but the disadvantage of instantiating `cascade` twice, which isn't great, and having to maintain all the boilerplate of a `TElement` implementation that just does nothing.
Diffstat (limited to 'components/script_layout_interface/wrapper_traits.rs')
-rw-r--r--components/script_layout_interface/wrapper_traits.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/components/script_layout_interface/wrapper_traits.rs b/components/script_layout_interface/wrapper_traits.rs
index dc1f5db4c54..17a9172cd71 100644
--- a/components/script_layout_interface/wrapper_traits.rs
+++ b/components/script_layout_interface/wrapper_traits.rs
@@ -19,7 +19,7 @@ use std::fmt::Debug;
use style::attr::AttrValue;
use style::context::SharedStyleContext;
use style::data::ElementData;
-use style::dom::{LayoutIterator, NodeInfo, TNode};
+use style::dom::{LayoutIterator, NodeInfo, TElement, TNode};
use style::dom::OpaqueNode;
use style::font_metrics::ServoMetricsProvider;
use style::properties::{CascadeFlags, ComputedValues};
@@ -148,6 +148,8 @@ impl<ConcreteNode> Iterator for TreeIterator<ConcreteNode>
/// node does not allow any parents or siblings of nodes to be accessed, to avoid races.
pub trait ThreadSafeLayoutNode: Clone + Copy + Debug + GetLayoutData + NodeInfo + PartialEq + Sized {
type ConcreteNode: LayoutNode<ConcreteThreadSafeLayoutNode = Self>;
+ type ConcreteElement: TElement = <Self::ConcreteNode as TNode>::ConcreteElement;
+
type ConcreteThreadSafeLayoutElement:
ThreadSafeLayoutElement<ConcreteThreadSafeLayoutNode = Self>
+ ::selectors::Element<Impl=SelectorImpl>;
@@ -291,6 +293,10 @@ pub trait ThreadSafeLayoutElement
{
type ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode<ConcreteThreadSafeLayoutElement = Self>;
+ /// This type alias is just a hack to avoid writing the monstrosity after it
+ /// twice.
+ type ConcreteElement: TElement = <Self::ConcreteThreadSafeLayoutNode as ThreadSafeLayoutNode>::ConcreteElement;
+
fn as_node(&self) -> Self::ConcreteThreadSafeLayoutNode;
/// Creates a new `ThreadSafeLayoutElement` for the same `LayoutElement`
@@ -307,8 +313,7 @@ pub trait ThreadSafeLayoutElement
///
/// We need this so that the functions defined on this trait can call
/// lazily_compute_pseudo_element_style, which operates on TElement.
- unsafe fn unsafe_get(self) ->
- <<Self::ConcreteThreadSafeLayoutNode as ThreadSafeLayoutNode>::ConcreteNode as TNode>::ConcreteElement;
+ unsafe fn unsafe_get(self) -> Self::ConcreteElement;
#[inline]
fn get_attr(&self, namespace: &Namespace, name: &LocalName) -> Option<&str>;
@@ -382,7 +387,7 @@ pub trait ThreadSafeLayoutElement
.unwrap().clone()
},
PseudoElementCascadeType::Precomputed => {
- context.stylist.precomputed_values_for_pseudo(
+ context.stylist.precomputed_values_for_pseudo::<Self::ConcreteElement>(
&context.guards,
&style_pseudo,
Some(data.styles.primary()),