mirror of
https://github.com/servo/servo.git
synced 2025-06-08 00:23:30 +00:00
The primary idea of this patch is to ditch the rigid enum of Previous/Current styles, and replace it with a series of indicators for the various types of work that needs to be performed (expanding snapshots, rematching, recascading, and damage processing). This loses us a little bit of sanity checking (since the up-to-date-ness of our style is no longer baked into the type system), but gives us a lot more flexibility that we'll need going forward (especially when we separate matching from cascading). We also eliminate get_styling_mode in favor of a method on the traversal. This patch does a few other things as ridealongs: * Temporarily eliminates the handling for transfering ownership of styles to the frame. We'll need this again at some point, but for now it's causing too much complexity for a half-implemented feature. * Ditches TRestyleDamage, which is no longer necessary post-crate-merge, and is a constant source of compilation failures from either needing to be imported or being unnecessarily imported (which varies between gecko and servo). * Expands Snapshots for the traversal root, which was missing before. * Fixes up the skip_root stuff to avoid visiting the skipped root. * Unifies parallel traversal and avoids spawning for a single work item. * Adds an explicit pre_traverse step do any pre-processing and determine whether we need to traverse at all. MozReview-Commit-ID: IKhLAkAigXE
79 lines
3.3 KiB
Rust
79 lines
3.3 KiB
Rust
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
use flow::{self, AFFECTS_COUNTERS, Flow, HAS_COUNTER_AFFECTING_CHILDREN, IS_ABSOLUTELY_POSITIONED};
|
|
use style::computed_values::float;
|
|
use style::selector_parser::RestyleDamage;
|
|
use style::servo::restyle_damage::{REFLOW, RECONSTRUCT_FLOW};
|
|
|
|
bitflags! {
|
|
pub flags SpecialRestyleDamage: u8 {
|
|
#[doc = "If this flag is set, we need to reflow the entire document. This is more or less a \
|
|
temporary hack to deal with cases that we don't handle incrementally yet."]
|
|
const REFLOW_ENTIRE_DOCUMENT = 0x01,
|
|
}
|
|
}
|
|
|
|
pub trait LayoutDamageComputation {
|
|
fn compute_layout_damage(self) -> SpecialRestyleDamage;
|
|
fn reflow_entire_document(self);
|
|
}
|
|
|
|
impl<'a> LayoutDamageComputation for &'a mut Flow {
|
|
fn compute_layout_damage(self) -> SpecialRestyleDamage {
|
|
let mut special_damage = SpecialRestyleDamage::empty();
|
|
let is_absolutely_positioned = flow::base(self).flags.contains(IS_ABSOLUTELY_POSITIONED);
|
|
|
|
// In addition to damage, we use this phase to compute whether nodes affect CSS counters.
|
|
let mut has_counter_affecting_children = false;
|
|
|
|
{
|
|
let self_base = flow::mut_base(self);
|
|
// Take a snapshot of the parent damage before updating it with damage from children.
|
|
let parent_damage = self_base.restyle_damage;
|
|
|
|
for kid in self_base.children.iter_mut() {
|
|
let child_is_absolutely_positioned =
|
|
flow::base(kid).flags.contains(IS_ABSOLUTELY_POSITIONED);
|
|
flow::mut_base(kid).restyle_damage.insert(
|
|
parent_damage.damage_for_child(is_absolutely_positioned,
|
|
child_is_absolutely_positioned));
|
|
{
|
|
let kid: &mut Flow = kid;
|
|
special_damage.insert(kid.compute_layout_damage());
|
|
}
|
|
self_base.restyle_damage
|
|
.insert(flow::base(kid).restyle_damage.damage_for_parent(
|
|
child_is_absolutely_positioned));
|
|
|
|
has_counter_affecting_children = has_counter_affecting_children ||
|
|
flow::base(kid).flags.intersects(AFFECTS_COUNTERS |
|
|
HAS_COUNTER_AFFECTING_CHILDREN);
|
|
}
|
|
}
|
|
|
|
let self_base = flow::mut_base(self);
|
|
if self_base.flags.float_kind() != float::T::none &&
|
|
self_base.restyle_damage.intersects(REFLOW) {
|
|
special_damage.insert(REFLOW_ENTIRE_DOCUMENT);
|
|
}
|
|
|
|
if has_counter_affecting_children {
|
|
self_base.flags.insert(HAS_COUNTER_AFFECTING_CHILDREN)
|
|
} else {
|
|
self_base.flags.remove(HAS_COUNTER_AFFECTING_CHILDREN)
|
|
}
|
|
|
|
special_damage
|
|
}
|
|
|
|
fn reflow_entire_document(self) {
|
|
let self_base = flow::mut_base(self);
|
|
self_base.restyle_damage.insert(RestyleDamage::rebuild_and_reflow());
|
|
self_base.restyle_damage.remove(RECONSTRUCT_FLOW);
|
|
for kid in self_base.children.iter_mut() {
|
|
kid.reflow_entire_document();
|
|
}
|
|
}
|
|
}
|