Bug 1351535 - Part 5.1: Move TraversalFlags into SharedStyleContext. r=bholley

MozReview-Commit-ID: IfLzJ9h6vKT

--HG--
extra : rebase_source : ef70203c3c2f891cc8b13f4d63caaebfa3d176e7
This commit is contained in:
Cameron McCormack 2017-04-08 16:36:09 +08:00
Родитель d52f48a6c4
Коммит e18ef453ec
5 изменённых файлов: 19 добавлений и 19 удалений

Просмотреть файл

@ -523,7 +523,7 @@ impl LayoutThread {
local_context_creation_data: Mutex::new(thread_local_style_context_creation_data),
timer: self.timer.clone(),
quirks_mode: self.quirks_mode.unwrap(),
animation_only_restyle: false,
traversal_flags: TraversalFlags::empty(),
},
image_cache: self.image_cache.clone(),
font_cache_thread: Mutex::new(self.font_cache_thread.clone()),

Просмотреть файл

@ -29,7 +29,7 @@ use stylist::Stylist;
use thread_state;
use time;
use timer::Timer;
use traversal::DomTraversal;
use traversal::{DomTraversal, TraversalFlags};
/// This structure is used to create a local style context from a shared one.
pub struct ThreadLocalStyleContextCreationInfo {
@ -89,8 +89,8 @@ pub struct SharedStyleContext<'a> {
/// The QuirksMode state which the document needs to be rendered with
pub quirks_mode: QuirksMode,
/// True if the traversal is processing only animation restyles.
pub animation_only_restyle: bool,
/// Flags controlling how we traverse the tree.
pub traversal_flags: TraversalFlags,
}
impl<'a> SharedStyleContext<'a> {

Просмотреть файл

@ -1038,7 +1038,7 @@ pub trait MatchMethods : TElement {
// in the name of animation-only traversal. Rest of restyle hints
// will be processed in a subsequent normal traversal.
if hint.contains(RESTYLE_CSS_ANIMATIONS) {
debug_assert!(context.shared.animation_only_restyle);
debug_assert!(context.shared.traversal_flags.for_animation_only());
let animation_rule = self.get_animation_rule(None);
replace_rule_node(CascadeLevel::Animations,

Просмотреть файл

@ -175,7 +175,7 @@ pub trait DomTraversal<E: TElement> : Sync {
}
PreTraverseToken {
traverse: Self::node_needs_traversal(root.as_node(), traversal_flags.for_animation_only()),
traverse: Self::node_needs_traversal(root.as_node(), traversal_flags),
unstyled_children_only: false,
}
}
@ -189,7 +189,7 @@ pub trait DomTraversal<E: TElement> : Sync {
}
/// Returns true if traversal is needed for the given node and subtree.
fn node_needs_traversal(node: E::ConcreteNode, animation_only: bool) -> bool {
fn node_needs_traversal(node: E::ConcreteNode, traversal_flags: TraversalFlags) -> bool {
// Non-incremental layout visits every node.
if is_servo_nonincremental_layout() {
return true;
@ -216,7 +216,7 @@ pub trait DomTraversal<E: TElement> : Sync {
// In case of animation-only traversal we need to traverse
// the element if the element has animation only dirty
// descendants bit, animation-only restyle hint or recascade.
if animation_only {
if traversal_flags.for_animation_only() {
if el.has_animation_only_dirty_descendants() {
return true;
}
@ -341,7 +341,7 @@ pub trait DomTraversal<E: TElement> : Sync {
}
for kid in parent.as_node().children() {
if Self::node_needs_traversal(kid, self.shared_context().animation_only_restyle) {
if Self::node_needs_traversal(kid, self.shared_context().traversal_flags) {
let el = kid.as_element();
if el.as_ref().and_then(|el| el.borrow_data())
.map_or(false, |d| d.has_styles())
@ -517,7 +517,7 @@ pub fn recalc_style_at<E, D>(traversal: &D,
let propagated_hint = match data.get_restyle_mut() {
None => StoredRestyleHint::empty(),
Some(r) => {
debug_assert!(context.shared.animation_only_restyle ||
debug_assert!(context.shared.traversal_flags.for_animation_only() ||
!r.hint.has_animation_hint(),
"animation restyle hint should be handled during \
animation-only restyles");
@ -525,13 +525,14 @@ pub fn recalc_style_at<E, D>(traversal: &D,
r.hint.propagate()
},
};
debug_assert!(data.has_current_styles() || context.shared.animation_only_restyle,
debug_assert!(data.has_current_styles() ||
context.shared.traversal_flags.for_animation_only(),
"Should have computed style or haven't yet valid computed style in case of animation-only restyle");
trace!("propagated_hint={:?}, inherited_style_changed={:?}",
propagated_hint, inherited_style_changed);
let has_dirty_descendants_for_this_restyle =
if context.shared.animation_only_restyle {
if context.shared.traversal_flags.for_animation_only() {
element.has_animation_only_dirty_descendants()
} else {
element.has_dirty_descendants()
@ -556,7 +557,7 @@ pub fn recalc_style_at<E, D>(traversal: &D,
inherited_style_changed);
}
if context.shared.animation_only_restyle {
if context.shared.traversal_flags.for_animation_only() {
unsafe { element.unset_animation_only_dirty_descendants(); }
}

Просмотреть файл

@ -141,7 +141,7 @@ unsafe fn dummy_url_data() -> &'static RefPtr<URLExtraData> {
fn create_shared_context<'a>(guard: &'a SharedRwLockReadGuard,
per_doc_data: &PerDocumentStyleDataImpl,
animation_only: bool) -> SharedStyleContext<'a> {
traversal_flags: TraversalFlags) -> SharedStyleContext<'a> {
let local_context_data =
ThreadLocalStyleContextCreationInfo::new(per_doc_data.new_animations_sender.clone());
@ -156,7 +156,7 @@ fn create_shared_context<'a>(guard: &'a SharedRwLockReadGuard,
timer: Timer::new(),
// FIXME Find the real QuirksMode information for this document
quirks_mode: QuirksMode::NoQuirks,
animation_only_restyle: animation_only,
traversal_flags: traversal_flags,
}
}
@ -183,8 +183,7 @@ fn traverse_subtree(element: GeckoElement, raw_data: RawServoStyleSetBorrowed,
let global_style_data = &*GLOBAL_STYLE_DATA;
let guard = global_style_data.shared_lock.read();
let shared_style_context = create_shared_context(&guard, &per_doc_data,
traversal_flags.for_animation_only());
let shared_style_context = create_shared_context(&guard, &per_doc_data, traversal_flags);
let traversal_driver = if global_style_data.style_thread_pool.is_none() {
TraversalDriver::Sequential
@ -398,7 +397,7 @@ pub extern "C" fn Servo_StyleSet_GetBaseComputedValuesForElement(raw_data: RawSe
let doc_data = PerDocumentStyleData::from_ffi(raw_data).borrow();
let global_style_data = &*GLOBAL_STYLE_DATA;
let guard = global_style_data.shared_lock.read();
let shared_context = &create_shared_context(&guard, &doc_data, false);
let shared_context = &create_shared_context(&guard, &doc_data, TraversalFlags::empty());
let element = GeckoElement(element);
let element_data = element.borrow_data().unwrap();
@ -1631,7 +1630,7 @@ pub extern "C" fn Servo_ResolveStyleLazily(element: RawGeckoElementBorrowed,
}
// We don't have the style ready. Go ahead and compute it as necessary.
let shared = create_shared_context(&guard, &mut doc_data.borrow_mut(), false);
let shared = create_shared_context(&guard, &mut doc_data.borrow_mut(), TraversalFlags::empty());
let mut tlc = ThreadLocalStyleContext::new(&shared);
let mut context = StyleContext {
shared: &shared,