layout: Stop parameterizing on N for RecalcStyleAndConstructFlows

This is unfortunate, but making that useful would require parameterizing
`SharedLayoutContext` and `LayoutContext` depending on the
`SelectorImpl` (which is a **huge** work right now).

Probably the easier way to do it, and probably the one that keeps the
layout code more legible, and since there won't be multiple
implementations at the same compilation unit, would be "defining" a
default implementation for layout via feature flags.

That should allow us to remove the components/style/servo.rs file.
This commit is contained in:
Emilio Cobos Álvarez 2016-02-13 13:31:38 +01:00
parent 61e04df266
commit 04d2db5747

View file

@ -16,20 +16,18 @@ use incremental::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, REPAINT, RestyleDam
use std::mem; use std::mem;
use style::context::{StyleContext, ReflowGoal}; use style::context::{StyleContext, ReflowGoal};
use style::matching::MatchMethods; use style::matching::MatchMethods;
use style::selector_impl::ServoSelectorImpl;
use style::traversal::{DomTraversalContext, STYLE_BLOOM}; use style::traversal::{DomTraversalContext, STYLE_BLOOM};
use style::traversal::{put_thread_local_bloom_filter, recalc_style_at}; use style::traversal::{put_thread_local_bloom_filter, recalc_style_at};
use util::opts; use util::opts;
use util::tid::tid; use util::tid::tid;
use wrapper::{LayoutNode, ThreadSafeLayoutNode}; use wrapper::{LayoutNode, ServoLayoutNode, ThreadSafeLayoutNode};
pub struct RecalcStyleAndConstructFlows<'lc> { pub struct RecalcStyleAndConstructFlows<'lc> {
context: LayoutContext<'lc>, context: LayoutContext<'lc>,
root: OpaqueNode, root: OpaqueNode,
} }
impl<'lc, 'ln, N: LayoutNode<'ln>> DomTraversalContext<'ln, N> for RecalcStyleAndConstructFlows<'lc> impl<'lc, 'ln> DomTraversalContext<'ln, ServoLayoutNode<'ln>> for RecalcStyleAndConstructFlows<'lc> {
where N::ConcreteElement: ::selectors::Element<Impl=ServoSelectorImpl> {
type SharedContext = SharedLayoutContext; type SharedContext = SharedLayoutContext;
#[allow(unsafe_code)] #[allow(unsafe_code)]
fn new<'a>(shared: &'a Self::SharedContext, root: OpaqueNode) -> Self { fn new<'a>(shared: &'a Self::SharedContext, root: OpaqueNode) -> Self {
@ -69,8 +67,8 @@ impl<'lc, 'ln, N: LayoutNode<'ln>> DomTraversalContext<'ln, N> for RecalcStyleAn
} }
} }
fn process_preorder(&self, node: N) { recalc_style_at(&self.context, self.root, node); } fn process_preorder(&self, node: ServoLayoutNode<'ln>) { recalc_style_at(&self.context, self.root, node); }
fn process_postorder(&self, node: N) { construct_flows_at(&self.context, self.root, node); } fn process_postorder(&self, node: ServoLayoutNode<'ln>) { construct_flows_at(&self.context, self.root, node); }
} }
/// A bottom-up, parallelizable traversal. /// A bottom-up, parallelizable traversal.