aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/extra.rs
diff options
context:
space:
mode:
authorJack Moffitt <jack@metajack.im>2014-08-28 09:34:23 -0600
committerJack Moffitt <jack@metajack.im>2014-09-08 20:21:42 -0600
commitc6ab60dbfc6da7b4f800c9e40893c8b58413960c (patch)
treed1d74076cf7fa20e4f77ec7cb82cae98b67362cb /components/layout/extra.rs
parentdb2f642c32fc5bed445bb6f2e45b0f6f0b4342cf (diff)
downloadservo-c6ab60dbfc6da7b4f800c9e40893c8b58413960c.tar.gz
servo-c6ab60dbfc6da7b4f800c9e40893c8b58413960c.zip
Cargoify servo
Diffstat (limited to 'components/layout/extra.rs')
-rw-r--r--components/layout/extra.rs44
1 files changed, 44 insertions, 0 deletions
diff --git a/components/layout/extra.rs b/components/layout/extra.rs
new file mode 100644
index 00000000000..7b731185272
--- /dev/null
+++ b/components/layout/extra.rs
@@ -0,0 +1,44 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+//! Code for managing the layout data in the DOM.
+
+use util::{PrivateLayoutData, LayoutDataAccess, LayoutDataWrapper};
+use wrapper::LayoutNode;
+use script::dom::node::SharedLayoutData;
+use script::layout_interface::LayoutChan;
+
+/// Functionality useful for querying the layout-specific data on DOM nodes.
+pub trait LayoutAuxMethods {
+ fn initialize_layout_data(&self, chan: LayoutChan);
+ fn initialize_style_for_subtree(&self, chan: LayoutChan);
+}
+
+impl<'ln> LayoutAuxMethods for LayoutNode<'ln> {
+ /// Resets layout data and styles for the node.
+ ///
+ /// FIXME(pcwalton): Do this as part of fragment building instead of in a traversal.
+ fn initialize_layout_data(&self, chan: LayoutChan) {
+ let mut layout_data_ref = self.mutate_layout_data();
+ match *layout_data_ref {
+ None => {
+ *layout_data_ref = Some(LayoutDataWrapper {
+ chan: Some(chan),
+ shared_data: SharedLayoutData { style: None },
+ data: box PrivateLayoutData::new(),
+ });
+ }
+ Some(_) => {}
+ }
+ }
+
+ /// Resets layout data and styles for a Node tree.
+ ///
+ /// FIXME(pcwalton): Do this as part of fragment building instead of in a traversal.
+ fn initialize_style_for_subtree(&self, chan: LayoutChan) {
+ for n in self.traverse_preorder() {
+ n.initialize_layout_data(chan.clone());
+ }
+ }
+}