mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Implement CSS parsing for the @font-palette-values rule
Not yet hooked up to any rendering functionality. The intention is for both the @font-palette-values at-rule and the font-palette property to be behind the same pref being introduced here. Differential Revision: https://phabricator.services.mozilla.com/D157953
This commit is contained in:
parent
ab4580e112
commit
a4ad5e19b0
12 changed files with 353 additions and 30 deletions
|
@ -32,7 +32,9 @@ use crate::stylesheets::keyframes_rule::KeyframesAnimation;
|
|||
use crate::stylesheets::layer_rule::{LayerName, LayerOrder};
|
||||
use crate::stylesheets::viewport_rule::{self, MaybeNew, ViewportRule};
|
||||
#[cfg(feature = "gecko")]
|
||||
use crate::stylesheets::{CounterStyleRule, FontFaceRule, FontFeatureValuesRule, PageRule};
|
||||
use crate::stylesheets::{
|
||||
CounterStyleRule, FontFaceRule, FontFeatureValuesRule, FontPaletteValuesRule, PageRule,
|
||||
};
|
||||
use crate::stylesheets::{
|
||||
CssRule, EffectiveRulesIterator, Origin, OriginSet, PageRule, PerOrigin, PerOriginIter,
|
||||
};
|
||||
|
@ -1679,6 +1681,10 @@ pub struct ExtraStyleData {
|
|||
#[cfg(feature = "gecko")]
|
||||
pub font_feature_values: LayerOrderedVec<Arc<Locked<FontFeatureValuesRule>>>,
|
||||
|
||||
/// A list of effective font-palette-values rules.
|
||||
#[cfg(feature = "gecko")]
|
||||
pub font_palette_values: LayerOrderedVec<Arc<Locked<FontPaletteValuesRule>>>,
|
||||
|
||||
/// A map of effective counter-style rules.
|
||||
#[cfg(feature = "gecko")]
|
||||
pub counter_styles: LayerOrderedMap<Arc<Locked<CounterStyleRule>>>,
|
||||
|
@ -1704,6 +1710,15 @@ impl ExtraStyleData {
|
|||
self.font_feature_values.push(rule.clone(), layer);
|
||||
}
|
||||
|
||||
/// Add the given @font-palette-values rule.
|
||||
fn add_font_palette_values(
|
||||
&mut self,
|
||||
rule: &Arc<Locked<FontPaletteValuesRule>>,
|
||||
layer: LayerId,
|
||||
) {
|
||||
self.font_palette_values.push(rule.clone(), layer);
|
||||
}
|
||||
|
||||
/// Add the given @counter-style rule.
|
||||
fn add_counter_style(
|
||||
&mut self,
|
||||
|
@ -1745,6 +1760,7 @@ impl ExtraStyleData {
|
|||
fn sort_by_layer(&mut self, layers: &[CascadeLayer]) {
|
||||
self.font_faces.sort(layers);
|
||||
self.font_feature_values.sort(layers);
|
||||
self.font_palette_values.sort(layers);
|
||||
self.counter_styles.sort(layers);
|
||||
self.pages.global.sort(layers);
|
||||
}
|
||||
|
@ -1754,6 +1770,7 @@ impl ExtraStyleData {
|
|||
{
|
||||
self.font_faces.clear();
|
||||
self.font_feature_values.clear();
|
||||
self.font_palette_values.clear();
|
||||
self.counter_styles.clear();
|
||||
self.pages.clear();
|
||||
}
|
||||
|
@ -1790,6 +1807,7 @@ impl MallocSizeOf for ExtraStyleData {
|
|||
let mut n = 0;
|
||||
n += self.font_faces.shallow_size_of(ops);
|
||||
n += self.font_feature_values.shallow_size_of(ops);
|
||||
n += self.font_palette_values.shallow_size_of(ops);
|
||||
n += self.counter_styles.shallow_size_of(ops);
|
||||
n += self.pages.shallow_size_of(ops);
|
||||
n
|
||||
|
@ -2638,6 +2656,11 @@ impl CascadeData {
|
|||
.add_font_feature_values(rule, containing_rule_state.layer_id);
|
||||
},
|
||||
#[cfg(feature = "gecko")]
|
||||
CssRule::FontPaletteValues(ref rule) => {
|
||||
self.extra_data
|
||||
.add_font_palette_values(rule, containing_rule_state.layer_id);
|
||||
},
|
||||
#[cfg(feature = "gecko")]
|
||||
CssRule::CounterStyle(ref rule) => {
|
||||
self.extra_data.add_counter_style(
|
||||
guard,
|
||||
|
@ -2888,6 +2911,7 @@ impl CascadeData {
|
|||
CssRule::Document(..) |
|
||||
CssRule::LayerBlock(..) |
|
||||
CssRule::LayerStatement(..) |
|
||||
CssRule::FontPaletteValues(..) |
|
||||
CssRule::FontFeatureValues(..) => {
|
||||
// Not affected by device changes.
|
||||
continue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue