aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/style/build_gecko.rs4
-rw-r--r--components/style/gecko_bindings/bindings.rs4
-rw-r--r--components/style/gecko_bindings/structs_debug.rs2
-rw-r--r--components/style/gecko_bindings/structs_release.rs2
-rw-r--r--components/style/parallel.rs16
-rw-r--r--components/style/sequential.rs8
-rw-r--r--components/style/traversal.rs20
-rw-r--r--ports/geckolib/glue.rs9
8 files changed, 37 insertions, 28 deletions
diff --git a/components/style/build_gecko.rs b/components/style/build_gecko.rs
index a96a92e9871..119d3b30f9d 100644
--- a/components/style/build_gecko.rs
+++ b/components/style/build_gecko.rs
@@ -220,7 +220,7 @@ mod bindings {
"mozilla::ConsumeStyleBehavior",
"mozilla::LazyComputeBehavior",
"mozilla::css::SheetParsingMode",
- "mozilla::SkipRootBehavior",
+ "mozilla::TraversalRootBehavior",
"mozilla::DisplayItemClip", // Needed because bindgen generates
// specialization tests for this even
// though it shouldn't.
@@ -444,7 +444,7 @@ mod bindings {
"ThreadSafePrincipalHolder",
"ConsumeStyleBehavior",
"LazyComputeBehavior",
- "SkipRootBehavior",
+ "TraversalRootBehavior",
"FontFamilyList",
"FontFamilyType",
"ServoElementSnapshot",
diff --git a/components/style/gecko_bindings/bindings.rs b/components/style/gecko_bindings/bindings.rs
index d7ad23ff955..877dab3ef51 100644
--- a/components/style/gecko_bindings/bindings.rs
+++ b/components/style/gecko_bindings/bindings.rs
@@ -70,7 +70,7 @@ use gecko_bindings::structs::ThreadSafeURIHolder;
use gecko_bindings::structs::ThreadSafePrincipalHolder;
use gecko_bindings::structs::ConsumeStyleBehavior;
use gecko_bindings::structs::LazyComputeBehavior;
-use gecko_bindings::structs::SkipRootBehavior;
+use gecko_bindings::structs::TraversalRootBehavior;
use gecko_bindings::structs::FontFamilyList;
use gecko_bindings::structs::FontFamilyType;
use gecko_bindings::structs::ServoElementSnapshot;
@@ -1197,7 +1197,7 @@ extern "C" {
extern "C" {
pub fn Servo_TraverseSubtree(root: RawGeckoElementBorrowed,
set: RawServoStyleSetBorrowed,
- skip_root: SkipRootBehavior);
+ behavior: TraversalRootBehavior);
}
extern "C" {
pub fn Servo_AssertTreeIsClean(root: RawGeckoElementBorrowed);
diff --git a/components/style/gecko_bindings/structs_debug.rs b/components/style/gecko_bindings/structs_debug.rs
index 25960347510..d2081917576 100644
--- a/components/style/gecko_bindings/structs_debug.rs
+++ b/components/style/gecko_bindings/structs_debug.rs
@@ -2493,7 +2493,7 @@ pub mod root {
}
#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
- pub enum SkipRootBehavior { Skip = 0, DontSkip = 1, }
+ pub enum TraversalRootBehavior { Normal = 0, UnstyledChildrenOnly = 1, }
pub mod a11y {
#[allow(unused_imports)]
use self::super::super::super::root;
diff --git a/components/style/gecko_bindings/structs_release.rs b/components/style/gecko_bindings/structs_release.rs
index 587d932ba69..c6fdf8d127d 100644
--- a/components/style/gecko_bindings/structs_release.rs
+++ b/components/style/gecko_bindings/structs_release.rs
@@ -2475,7 +2475,7 @@ pub mod root {
}
#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
- pub enum SkipRootBehavior { Skip = 0, DontSkip = 1, }
+ pub enum TraversalRootBehavior { Normal = 0, UnstyledChildrenOnly = 1, }
pub mod a11y {
#[allow(unused_imports)]
use self::super::super::super::root;
diff --git a/components/style/parallel.rs b/components/style/parallel.rs
index a93c0006f5f..3bc888a5230 100644
--- a/components/style/parallel.rs
+++ b/components/style/parallel.rs
@@ -28,13 +28,17 @@ pub fn traverse_dom<N, C>(root: N::ConcreteElement,
STYLE_SHARING_CACHE_MISSES.store(0, Ordering::SeqCst);
}
- // Handle root skipping. We don't currently support it in conjunction with
- // bottom-up traversal. If we did, we'd need to put it on the context to make
- // it available to the bottom-up phase.
- debug_assert!(!token.should_skip_root() || !C::needs_postorder_traversal());
- let (nodes, depth) = if token.should_skip_root() {
+ // Handle Gecko's eager initial styling. We don't currently support it
+ // in conjunction with bottom-up traversal. If we did, we'd need to put
+ // it on the context to make it available to the bottom-up phase.
+ let (nodes, depth) = if token.traverse_unstyled_children_only() {
+ debug_assert!(!C::needs_postorder_traversal());
let mut children = vec![];
- C::traverse_children(root, |kid| children.push(kid.to_unsafe()));
+ for kid in root.as_node().children() {
+ if kid.as_element().map_or(false, |el| el.get_data().is_none()) {
+ children.push(kid.to_unsafe());
+ }
+ }
(children, known_root_dom_depth.map(|x| x + 1))
} else {
(vec![root.as_node().to_unsafe()], known_root_dom_depth)
diff --git a/components/style/sequential.rs b/components/style/sequential.rs
index 01632a2d917..614b3d6509d 100644
--- a/components/style/sequential.rs
+++ b/components/style/sequential.rs
@@ -42,8 +42,12 @@ pub fn traverse_dom<N, C>(root: N::ConcreteElement,
};
let context = C::new(shared, root.as_node().opaque());
- if token.should_skip_root() {
- C::traverse_children(root, |kid| doit::<N, C>(&context, kid, &mut data));
+ if token.traverse_unstyled_children_only() {
+ for kid in root.as_node().children() {
+ if kid.as_element().map_or(false, |el| el.get_data().is_none()) {
+ doit::<N, C>(&context, kid, &mut data);
+ }
+ }
} else {
doit::<N, C>(&context, root.as_node(), &mut data);
}
diff --git a/components/style/traversal.rs b/components/style/traversal.rs
index 1fa35ed3605..5de8c726348 100644
--- a/components/style/traversal.rs
+++ b/components/style/traversal.rs
@@ -104,7 +104,7 @@ pub struct PerLevelTraversalData {
/// to pass information from the pre-traversal into the primary traversal.
pub struct PreTraverseToken {
traverse: bool,
- skip_root: bool,
+ unstyled_children_only: bool,
}
impl PreTraverseToken {
@@ -112,8 +112,8 @@ impl PreTraverseToken {
self.traverse
}
- pub fn should_skip_root(&self) -> bool {
- self.skip_root
+ pub fn traverse_unstyled_children_only(&self) -> bool {
+ self.unstyled_children_only
}
}
@@ -140,16 +140,16 @@ pub trait DomTraversalContext<N: TNode> {
/// a traversal is needed. Returns a token that allows the caller to prove
/// that the call happened.
///
- /// The skip_root parameter is used in Gecko to style newly-appended children
- /// without restyling the parent.
- fn pre_traverse(root: N::ConcreteElement, stylist: &Stylist, skip_root: bool)
+ /// The unstyled_children_only parameter is used in Gecko to style newly-
+ /// appended children without restyling the parent.
+ fn pre_traverse(root: N::ConcreteElement, stylist: &Stylist,
+ unstyled_children_only: bool)
-> PreTraverseToken
{
- // If we should skip the root, traverse unconditionally.
- if skip_root {
+ if unstyled_children_only {
return PreTraverseToken {
traverse: true,
- skip_root: true,
+ unstyled_children_only: true,
};
}
@@ -168,7 +168,7 @@ pub trait DomTraversalContext<N: TNode> {
PreTraverseToken {
traverse: Self::node_needs_traversal(root.as_node()),
- skip_root: false,
+ unstyled_children_only: false,
}
}
diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs
index 3e6bcdbf446..8d832d393a9 100644
--- a/ports/geckolib/glue.rs
+++ b/ports/geckolib/glue.rs
@@ -118,7 +118,7 @@ fn create_shared_context(mut per_doc_data: &mut AtomicRefMut<PerDocumentStyleDat
}
fn traverse_subtree(element: GeckoElement, raw_data: RawServoStyleSetBorrowed,
- skip_root: bool) {
+ unstyled_children_only: bool) {
// Force the creation of our lazily-constructed initial computed values on
// the main thread, since it's not safe to call elsewhere.
//
@@ -139,7 +139,7 @@ fn traverse_subtree(element: GeckoElement, raw_data: RawServoStyleSetBorrowed,
let mut per_doc_data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
- let token = RecalcStyleOnly::pre_traverse(element, &per_doc_data.stylist, skip_root);
+ let token = RecalcStyleOnly::pre_traverse(element, &per_doc_data.stylist, unstyled_children_only);
if !token.should_traverse() {
error!("Unnecessary call to traverse_subtree");
return;
@@ -160,10 +160,11 @@ fn traverse_subtree(element: GeckoElement, raw_data: RawServoStyleSetBorrowed,
#[no_mangle]
pub extern "C" fn Servo_TraverseSubtree(root: RawGeckoElementBorrowed,
raw_data: RawServoStyleSetBorrowed,
- skip_root: structs::SkipRootBehavior) -> () {
+ behavior: structs::TraversalRootBehavior) -> () {
let element = GeckoElement(root);
debug!("Servo_TraverseSubtree: {:?}", element);
- traverse_subtree(element, raw_data, skip_root == structs::SkipRootBehavior::Skip);
+ traverse_subtree(element, raw_data,
+ behavior == structs::TraversalRootBehavior::UnstyledChildrenOnly);
}
#[no_mangle]