mirror of
https://github.com/servo/servo.git
synced 2025-06-24 17:14:33 +01: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
60 lines
1.7 KiB
Rust
60 lines
1.7 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 gecko_bindings::bindings;
|
|
use gecko_bindings::structs;
|
|
use gecko_bindings::structs::{nsChangeHint, nsStyleContext};
|
|
use gecko_bindings::sugar::ownership::FFIArcHelpers;
|
|
use properties::ComputedValues;
|
|
use std::ops::{BitOr, BitOrAssign};
|
|
use std::sync::Arc;
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
|
pub struct GeckoRestyleDamage(nsChangeHint);
|
|
|
|
impl GeckoRestyleDamage {
|
|
pub fn new(raw: nsChangeHint) -> Self {
|
|
GeckoRestyleDamage(raw)
|
|
}
|
|
|
|
pub fn as_change_hint(&self) -> nsChangeHint {
|
|
self.0
|
|
}
|
|
|
|
pub fn empty() -> Self {
|
|
GeckoRestyleDamage(nsChangeHint(0))
|
|
}
|
|
|
|
pub fn is_empty(&self) -> bool {
|
|
self.0 == nsChangeHint(0)
|
|
}
|
|
|
|
pub fn compute(source: &nsStyleContext,
|
|
new_style: &Arc<ComputedValues>) -> Self {
|
|
let context = source as *const nsStyleContext as *mut nsStyleContext;
|
|
let hint = unsafe {
|
|
bindings::Gecko_CalcStyleDifference(context,
|
|
new_style.as_borrowed_opt().unwrap())
|
|
};
|
|
GeckoRestyleDamage(hint)
|
|
}
|
|
|
|
pub fn rebuild_and_reflow() -> Self {
|
|
GeckoRestyleDamage(structs::nsChangeHint_nsChangeHint_ReconstructFrame)
|
|
}
|
|
}
|
|
|
|
impl BitOr for GeckoRestyleDamage {
|
|
type Output = Self;
|
|
|
|
fn bitor(self, other: Self) -> Self {
|
|
GeckoRestyleDamage(self.0 | other.0)
|
|
}
|
|
}
|
|
|
|
impl BitOrAssign for GeckoRestyleDamage {
|
|
fn bitor_assign(&mut self, other: Self) {
|
|
*self = *self | other;
|
|
}
|
|
}
|