Simplify our setup for font metric queries from style

This is a backport of https://phabricator.services.mozilla.com/D157589,
by Emilio Cobos Álvarez, plus some additions so that Servo compiles,
and some parts from https://phabricator.services.mozilla.com/D144455.

Should have no change in behavior.
This commit is contained in:
Oriol Brufau 2023-05-10 03:34:29 +02:00
parent feaa66b597
commit ab2ba273e3
21 changed files with 172 additions and 322 deletions

View file

@ -9,7 +9,6 @@ use crate::animation::DocumentAnimationSet;
use crate::bloom::StyleBloom;
use crate::data::{EagerPseudoStyles, ElementData};
use crate::dom::{SendElement, TElement};
use crate::font_metrics::FontMetricsProvider;
#[cfg(feature = "gecko")]
use crate::gecko_bindings::structs;
use crate::parallel::{STACK_SAFETY_MARGIN_KB, STYLE_THREAD_STACK_SIZE_KB};
@ -720,9 +719,6 @@ pub struct ThreadLocalStyleContext<E: TElement> {
pub selector_flags: SelectorFlagsMap<E>,
/// Statistics about the traversal.
pub statistics: PerThreadTraversalStatistics,
/// The struct used to compute and cache font metrics from style
/// for evaluation of the font-relative em/ch units and font-size
pub font_metrics_provider: E::FontMetricsProvider,
/// A checker used to ensure that parallel.rs does not recurse indefinitely
/// even on arbitrarily deep trees. See Gecko bug 1376883.
pub stack_limit_checker: StackLimitChecker,
@ -731,9 +727,8 @@ pub struct ThreadLocalStyleContext<E: TElement> {
}
impl<E: TElement> ThreadLocalStyleContext<E> {
/// Creates a new `ThreadLocalStyleContext` from a shared one.
#[cfg(feature = "servo")]
pub fn new(shared: &SharedStyleContext) -> Self {
/// Creates a new `ThreadLocalStyleContext`
pub fn new() -> Self {
ThreadLocalStyleContext {
sharing_cache: StyleSharingCache::new(),
rule_cache: RuleCache::new(),
@ -741,25 +736,6 @@ impl<E: TElement> ThreadLocalStyleContext<E> {
tasks: SequentialTaskList(Vec::new()),
selector_flags: SelectorFlagsMap::new(),
statistics: PerThreadTraversalStatistics::default(),
font_metrics_provider: E::FontMetricsProvider::create_from(shared),
stack_limit_checker: StackLimitChecker::new(
(STYLE_THREAD_STACK_SIZE_KB - STACK_SAFETY_MARGIN_KB) * 1024,
),
nth_index_cache: NthIndexCache::default(),
}
}
#[cfg(feature = "gecko")]
/// Creates a new `ThreadLocalStyleContext` from a shared one.
pub fn new(shared: &SharedStyleContext) -> Self {
ThreadLocalStyleContext {
sharing_cache: StyleSharingCache::new(),
rule_cache: RuleCache::new(),
bloom_filter: StyleBloom::new(),
tasks: SequentialTaskList(Vec::new()),
selector_flags: SelectorFlagsMap::new(),
statistics: PerThreadTraversalStatistics::default(),
font_metrics_provider: E::FontMetricsProvider::create_from(shared),
stack_limit_checker: StackLimitChecker::new(
(STYLE_THREAD_STACK_SIZE_KB - STACK_SAFETY_MARGIN_KB) * 1024,
),