aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/layout_wrapper.rs
diff options
context:
space:
mode:
authorBobby Holley <bobbyholley@gmail.com>2016-11-14 12:05:17 -0800
committerBobby Holley <bobbyholley@gmail.com>2016-11-14 13:04:13 -0800
commitdda29283862481786805993b9dee7f8b37ad36b4 (patch)
tree29d9941645f0658da2941e4a0a566b40bce983a4 /components/script/layout_wrapper.rs
parentb7eb36fa84e6c6c77727ea2cd02c57f6750dc7af (diff)
downloadservo-dda29283862481786805993b9dee7f8b37ad36b4.tar.gz
servo-dda29283862481786805993b9dee7f8b37ad36b4.zip
Remove TDocument from the style and layout crates.
The style system never actually does anything with the document. This allows us to remove a bunch of stubbing on the Gecko side and streamline some things on the Servo side in future patches.
Diffstat (limited to 'components/script/layout_wrapper.rs')
-rw-r--r--components/script/layout_wrapper.rs33
1 files changed, 12 insertions, 21 deletions
diff --git a/components/script/layout_wrapper.rs b/components/script/layout_wrapper.rs
index 00c7ce1413c..fb31965d45d 100644
--- a/components/script/layout_wrapper.rs
+++ b/components/script/layout_wrapper.rs
@@ -46,7 +46,7 @@ use parking_lot::RwLock;
use range::Range;
use script_layout_interface::{HTMLCanvasData, LayoutNodeType, SVGSVGData, TrustedNodeAddress};
use script_layout_interface::{OpaqueStyleAndLayoutData, PartialPersistentLayoutData};
-use script_layout_interface::wrapper_traits::{DangerousThreadSafeLayoutNode, GetLayoutData, LayoutElement, LayoutNode};
+use script_layout_interface::wrapper_traits::{DangerousThreadSafeLayoutNode, GetLayoutData, LayoutNode};
use script_layout_interface::wrapper_traits::{PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode};
use selectors::matching::ElementFlags;
use selectors::parser::{AttrSelector, NamespaceConstraint};
@@ -61,7 +61,7 @@ use style::attr::AttrValue;
use style::computed_values::display;
use style::context::SharedStyleContext;
use style::data::ElementData;
-use style::dom::{LayoutIterator, NodeInfo, OpaqueNode, PresentationalHintsSynthetizer, TDocument, TElement, TNode};
+use style::dom::{LayoutIterator, NodeInfo, OpaqueNode, PresentationalHintsSynthetizer, TElement, TNode};
use style::dom::{TRestyleDamage, UnsafeNode};
use style::element_state::*;
use style::properties::{ComputedValues, PropertyDeclarationBlock};
@@ -112,6 +112,10 @@ impl<'ln> ServoLayoutNode<'ln> {
self.node.type_id_for_layout()
}
}
+
+ pub fn as_document(&self) -> Option<ServoLayoutDocument<'ln>> {
+ self.node.downcast().map(ServoLayoutDocument::from_layout_js)
+ }
}
impl<'ln> NodeInfo for ServoLayoutNode<'ln> {
@@ -128,7 +132,6 @@ impl<'ln> NodeInfo for ServoLayoutNode<'ln> {
impl<'ln> TNode for ServoLayoutNode<'ln> {
type ConcreteElement = ServoLayoutElement<'ln>;
- type ConcreteDocument = ServoLayoutDocument<'ln>;
type ConcreteChildrenIterator = ServoChildrenIterator<'ln>;
fn to_unsafe(&self) -> UnsafeNode {
@@ -177,10 +180,6 @@ impl<'ln> TNode for ServoLayoutNode<'ln> {
as_element(self.node)
}
- fn as_document(&self) -> Option<ServoLayoutDocument<'ln>> {
- self.node.downcast().map(ServoLayoutDocument::from_layout_js)
- }
-
fn needs_dirty_on_viewport_size_changed(&self) -> bool {
unsafe { self.node.get_flag(DIRTY_ON_VIEWPORT_SIZE_CHANGE) }
}
@@ -369,34 +368,29 @@ pub struct ServoLayoutDocument<'ld> {
chain: PhantomData<&'ld ()>,
}
-impl<'ld> TDocument for ServoLayoutDocument<'ld> {
- type ConcreteNode = ServoLayoutNode<'ld>;
- type ConcreteElement = ServoLayoutElement<'ld>;
-
+impl<'ld> ServoLayoutDocument<'ld> {
fn as_node(&self) -> ServoLayoutNode<'ld> {
ServoLayoutNode::from_layout_js(self.document.upcast())
}
- fn root_node(&self) -> Option<ServoLayoutNode<'ld>> {
+ pub fn root_node(&self) -> Option<ServoLayoutNode<'ld>> {
self.as_node().children().find(ServoLayoutNode::is_element)
}
- fn drain_modified_elements(&self) -> Vec<(ServoLayoutElement<'ld>, Snapshot)> {
+ pub fn drain_modified_elements(&self) -> Vec<(ServoLayoutElement<'ld>, Snapshot)> {
let elements = unsafe { self.document.drain_modified_elements() };
elements.into_iter().map(|(el, snapshot)| (ServoLayoutElement::from_layout_js(el), snapshot)).collect()
}
- fn needs_paint_from_layout(&self) {
+ pub fn needs_paint_from_layout(&self) {
unsafe { self.document.needs_paint_from_layout(); }
}
- fn will_paint(&self) {
+ pub fn will_paint(&self) {
unsafe { self.document.will_paint(); }
}
-}
-impl<'ld> ServoLayoutDocument<'ld> {
- fn from_layout_js(doc: LayoutJS<Document>) -> ServoLayoutDocument<'ld> {
+ pub fn from_layout_js(doc: LayoutJS<Document>) -> ServoLayoutDocument<'ld> {
ServoLayoutDocument {
document: doc,
chain: PhantomData,
@@ -433,7 +427,6 @@ impl<'le> PresentationalHintsSynthetizer for ServoLayoutElement<'le> {
impl<'le> TElement for ServoLayoutElement<'le> {
type ConcreteNode = ServoLayoutNode<'le>;
- type ConcreteDocument = ServoLayoutDocument<'le>;
fn as_node(&self) -> ServoLayoutNode<'le> {
ServoLayoutNode::from_layout_js(self.element.upcast())
@@ -1069,8 +1062,6 @@ impl<'le> ThreadSafeLayoutElement for ServoThreadSafeLayoutElement<'le> {
}
}
-impl<'le> LayoutElement for ServoLayoutElement<'le> {}
-
/// This implementation of `::selectors::Element` is used for implementing lazy
/// pseudo-elements.
///