mirror of
https://github.com/servo/servo.git
synced 2025-07-02 21:13:39 +01:00
Cargoify servo
This commit is contained in:
parent
db2f642c32
commit
c6ab60dbfc
1761 changed files with 8423 additions and 2294 deletions
44
components/layout/extra.rs
Normal file
44
components/layout/extra.rs
Normal file
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue