mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Bug 1325734 - Parameterize the style traversal on TElement instead of TNode. r=emilio
This works around the issue described in https://github.com/rust-lang/rust/issues/38917
This commit is contained in:
parent
962a4a79bb
commit
3060865577
6 changed files with 62 additions and 59 deletions
|
@ -14,7 +14,7 @@ use script_layout_interface::wrapper_traits::{LayoutNode, ThreadSafeLayoutNode};
|
|||
use servo_config::opts;
|
||||
use style::context::{SharedStyleContext, StyleContext};
|
||||
use style::data::ElementData;
|
||||
use style::dom::{TElement, TNode};
|
||||
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, recalc_style_at};
|
||||
|
@ -48,14 +48,14 @@ impl RecalcStyleAndConstructFlows {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
impl<N> DomTraversal<N> for RecalcStyleAndConstructFlows
|
||||
where N: LayoutNode + TNode,
|
||||
N::ConcreteElement: TElement
|
||||
impl<E> DomTraversal<E> for RecalcStyleAndConstructFlows
|
||||
where E: TElement,
|
||||
E::ConcreteNode: LayoutNode,
|
||||
{
|
||||
type ThreadLocalContext = ScopedThreadLocalLayoutContext<N::ConcreteElement>;
|
||||
type ThreadLocalContext = ScopedThreadLocalLayoutContext<E>;
|
||||
|
||||
fn process_preorder(&self, traversal_data: &mut PerLevelTraversalData,
|
||||
thread_local: &mut Self::ThreadLocalContext, node: N) {
|
||||
thread_local: &mut Self::ThreadLocalContext, node: E::ConcreteNode) {
|
||||
// FIXME(pcwalton): Stop allocating here. Ideally this should just be
|
||||
// done by the HTML parser.
|
||||
node.initialize_data();
|
||||
|
@ -71,12 +71,12 @@ impl<N> DomTraversal<N> for RecalcStyleAndConstructFlows
|
|||
}
|
||||
}
|
||||
|
||||
fn process_postorder(&self, thread_local: &mut Self::ThreadLocalContext, node: N) {
|
||||
fn process_postorder(&self, thread_local: &mut Self::ThreadLocalContext, node: E::ConcreteNode) {
|
||||
let context = LayoutContext::new(&self.shared);
|
||||
construct_flows_at(&context, thread_local, node);
|
||||
}
|
||||
|
||||
fn text_node_needs_traversal(node: N) -> bool {
|
||||
fn text_node_needs_traversal(node: E::ConcreteNode) -> bool {
|
||||
// Text nodes never need styling. However, there are two cases they may need
|
||||
// flow construction:
|
||||
// (1) They child doesn't yet have layout data (preorder traversal initializes it).
|
||||
|
@ -85,12 +85,12 @@ impl<N> DomTraversal<N> for RecalcStyleAndConstructFlows
|
|||
node.parent_node().unwrap().to_threadsafe().restyle_damage() != RestyleDamage::empty()
|
||||
}
|
||||
|
||||
unsafe fn ensure_element_data(element: &N::ConcreteElement) -> &AtomicRefCell<ElementData> {
|
||||
unsafe fn ensure_element_data(element: &E) -> &AtomicRefCell<ElementData> {
|
||||
element.as_node().initialize_data();
|
||||
element.get_data().unwrap()
|
||||
}
|
||||
|
||||
unsafe fn clear_element_data(element: &N::ConcreteElement) {
|
||||
unsafe fn clear_element_data(element: &E) {
|
||||
element.as_node().clear_data();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue