style: Expose the traversal kind to the style system.

This way we'll be able to take different paths for the sequential and parallel
traversals in some concrete cases.

This is a preliminar patch to fix bug 1332525.
This commit is contained in:
Emilio Cobos Álvarez 2017-01-23 19:55:06 +01:00
parent 7e2329ea4e
commit f00b628c3a
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
7 changed files with 64 additions and 13 deletions

View file

@ -17,13 +17,14 @@ 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, recalc_style_at};
use style::traversal::{DomTraversal, TraversalDriver, recalc_style_at};
use style::traversal::PerLevelTraversalData;
use wrapper::{GetRawData, LayoutNodeHelpers, LayoutNodeLayoutData};
use wrapper::ThreadSafeLayoutNodeHelpers;
pub struct RecalcStyleAndConstructFlows {
shared: SharedLayoutContext,
driver: TraversalDriver,
}
impl RecalcStyleAndConstructFlows {
@ -34,9 +35,10 @@ impl RecalcStyleAndConstructFlows {
impl RecalcStyleAndConstructFlows {
/// Creates a traversal context, taking ownership of the shared layout context.
pub fn new(shared: SharedLayoutContext) -> Self {
pub fn new(shared: SharedLayoutContext, driver: TraversalDriver) -> Self {
RecalcStyleAndConstructFlows {
shared: shared,
driver: driver,
}
}
@ -101,6 +103,10 @@ impl<E> DomTraversal<E> for RecalcStyleAndConstructFlows
fn create_thread_local_context(&self) -> Self::ThreadLocalContext {
ScopedThreadLocalLayoutContext::new(&self.shared)
}
fn is_parallel(&self) -> bool {
self.driver.is_parallel()
}
}
/// A bottom-up, parallelizable traversal.