mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
script: Move the layout_wrapper outside of script.
This allows us to have ensure_data() and clear_data() functions on the TElement trait, instead of hacking around it adding methods in random traits. This also allows us to do some further cleanup, which I'd rather do in a followup.
This commit is contained in:
parent
f9642b36bd
commit
bf9369b29d
17 changed files with 128 additions and 166 deletions
|
@ -4,7 +4,6 @@
|
|||
|
||||
//! Traversals over the DOM and flow trees, running the layout computations.
|
||||
|
||||
use atomic_refcell::AtomicRefCell;
|
||||
use construct::FlowConstructor;
|
||||
use context::LayoutContext;
|
||||
use display_list_builder::DisplayListBuildState;
|
||||
|
@ -13,13 +12,12 @@ use flow::{CAN_BE_FRAGMENTED, Flow, ImmutableFlowUtils, PostorderFlowTraversal};
|
|||
use script_layout_interface::wrapper_traits::{LayoutNode, ThreadSafeLayoutNode};
|
||||
use servo_config::opts;
|
||||
use style::context::{SharedStyleContext, StyleContext};
|
||||
use style::data::ElementData;
|
||||
use style::dom::{NodeInfo, TElement, TNode};
|
||||
use style::selector_parser::RestyleDamage;
|
||||
use style::servo::restyle_damage::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, REPAINT};
|
||||
use style::traversal::{DomTraversal, TraversalDriver, recalc_style_at};
|
||||
use style::traversal::PerLevelTraversalData;
|
||||
use wrapper::{GetRawData, LayoutNodeHelpers, LayoutNodeLayoutData};
|
||||
use wrapper::{GetRawData, LayoutNodeLayoutData};
|
||||
use wrapper::ThreadSafeLayoutNodeHelpers;
|
||||
|
||||
pub struct RecalcStyleAndConstructFlows<'a> {
|
||||
|
@ -59,7 +57,7 @@ impl<'a, E> DomTraversal<E> for RecalcStyleAndConstructFlows<'a>
|
|||
context: &mut StyleContext<E>, node: E::ConcreteNode) {
|
||||
// FIXME(pcwalton): Stop allocating here. Ideally this should just be
|
||||
// done by the HTML parser.
|
||||
node.initialize_data();
|
||||
unsafe { node.initialize_data() };
|
||||
|
||||
if !node.is_text_node() {
|
||||
let el = node.as_element().unwrap();
|
||||
|
@ -81,15 +79,6 @@ impl<'a, E> DomTraversal<E> for RecalcStyleAndConstructFlows<'a>
|
|||
node.parent_node().unwrap().to_threadsafe().restyle_damage() != RestyleDamage::empty()
|
||||
}
|
||||
|
||||
unsafe fn ensure_element_data(element: &E) -> &AtomicRefCell<ElementData> {
|
||||
element.as_node().initialize_data();
|
||||
element.get_data().unwrap()
|
||||
}
|
||||
|
||||
unsafe fn clear_element_data(element: &E) {
|
||||
element.as_node().clear_data();
|
||||
}
|
||||
|
||||
fn shared_context(&self) -> &SharedStyleContext {
|
||||
&self.context.style_context
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue