mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
style: More ComputedValuesInner cleanup.
MozReview-Commit-ID: 8rkAP3pMEpD
This commit is contained in:
parent
07e1c6e75a
commit
fe8638a618
8 changed files with 34 additions and 33 deletions
|
@ -15,7 +15,7 @@ use data::ElementData;
|
||||||
use element_state::ElementState;
|
use element_state::ElementState;
|
||||||
use font_metrics::FontMetricsProvider;
|
use font_metrics::FontMetricsProvider;
|
||||||
use media_queries::Device;
|
use media_queries::Device;
|
||||||
use properties::{AnimationRules, ComputedValues, ComputedValuesInner, PropertyDeclarationBlock};
|
use properties::{AnimationRules, ComputedValues, PropertyDeclarationBlock};
|
||||||
#[cfg(feature = "gecko")] use properties::animated_properties::AnimationValue;
|
#[cfg(feature = "gecko")] use properties::animated_properties::AnimationValue;
|
||||||
#[cfg(feature = "gecko")] use properties::animated_properties::TransitionProperty;
|
#[cfg(feature = "gecko")] use properties::animated_properties::TransitionProperty;
|
||||||
use rule_tree::CascadeLevel;
|
use rule_tree::CascadeLevel;
|
||||||
|
@ -437,7 +437,7 @@ pub trait TElement : Eq + PartialEq + Debug + Hash + Sized + Copy + Clone +
|
||||||
fn may_generate_pseudo(
|
fn may_generate_pseudo(
|
||||||
&self,
|
&self,
|
||||||
pseudo: &PseudoElement,
|
pseudo: &PseudoElement,
|
||||||
_primary_style: &ComputedValuesInner,
|
_primary_style: &ComputedValues,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
// ::before/::after are always supported for now, though we could try to
|
// ::before/::after are always supported for now, though we could try to
|
||||||
// optimize out leaf elements.
|
// optimize out leaf elements.
|
||||||
|
|
|
@ -110,13 +110,13 @@ impl<'a> Iterator for PropertyDeclarationIterator<'a> {
|
||||||
pub struct AnimationValueIterator<'a, 'cx, 'cx_a:'cx> {
|
pub struct AnimationValueIterator<'a, 'cx, 'cx_a:'cx> {
|
||||||
iter: Iter<'a, (PropertyDeclaration, Importance)>,
|
iter: Iter<'a, (PropertyDeclaration, Importance)>,
|
||||||
context: &'cx mut Context<'cx_a>,
|
context: &'cx mut Context<'cx_a>,
|
||||||
default_values: &'a ComputedValuesInner,
|
default_values: &'a ComputedValues,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'cx, 'cx_a:'cx> AnimationValueIterator<'a, 'cx, 'cx_a> {
|
impl<'a, 'cx, 'cx_a:'cx> AnimationValueIterator<'a, 'cx, 'cx_a> {
|
||||||
fn new(declarations: &'a PropertyDeclarationBlock,
|
fn new(declarations: &'a PropertyDeclarationBlock,
|
||||||
context: &'cx mut Context<'cx_a>,
|
context: &'cx mut Context<'cx_a>,
|
||||||
default_values: &'a ComputedValuesInner) -> AnimationValueIterator<'a, 'cx, 'cx_a> {
|
default_values: &'a ComputedValues) -> AnimationValueIterator<'a, 'cx, 'cx_a> {
|
||||||
AnimationValueIterator {
|
AnimationValueIterator {
|
||||||
iter: declarations.declarations().iter(),
|
iter: declarations.declarations().iter(),
|
||||||
context: context,
|
context: context,
|
||||||
|
@ -204,7 +204,7 @@ impl PropertyDeclarationBlock {
|
||||||
/// Return an iterator of (AnimatableLonghand, AnimationValue).
|
/// Return an iterator of (AnimatableLonghand, AnimationValue).
|
||||||
pub fn to_animation_value_iter<'a, 'cx, 'cx_a:'cx>(&'a self,
|
pub fn to_animation_value_iter<'a, 'cx, 'cx_a:'cx>(&'a self,
|
||||||
context: &'cx mut Context<'cx_a>,
|
context: &'cx mut Context<'cx_a>,
|
||||||
default_values: &'a ComputedValuesInner)
|
default_values: &'a ComputedValues)
|
||||||
-> AnimationValueIterator<'a, 'cx, 'cx_a> {
|
-> AnimationValueIterator<'a, 'cx, 'cx_a> {
|
||||||
AnimationValueIterator::new(self, context, default_values)
|
AnimationValueIterator::new(self, context, default_values)
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ use smallvec::SmallVec;
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
#[cfg(feature = "gecko")] use fnv::FnvHashMap;
|
#[cfg(feature = "gecko")] use fnv::FnvHashMap;
|
||||||
use style_traits::ParseError;
|
use style_traits::ParseError;
|
||||||
use super::ComputedValuesInner;
|
use super::ComputedValues;
|
||||||
#[cfg(any(feature = "gecko", feature = "testing"))]
|
#[cfg(any(feature = "gecko", feature = "testing"))]
|
||||||
use values::Auto;
|
use values::Auto;
|
||||||
use values::{CSSFloat, CustomIdent, Either};
|
use values::{CSSFloat, CustomIdent, Either};
|
||||||
|
@ -394,7 +394,7 @@ impl AnimatedProperty {
|
||||||
|
|
||||||
/// Update `style` with the proper computed style corresponding to this
|
/// Update `style` with the proper computed style corresponding to this
|
||||||
/// animation at `progress`.
|
/// animation at `progress`.
|
||||||
pub fn update(&self, style: &mut ComputedValuesInner, progress: f64) {
|
pub fn update(&self, style: &mut ComputedValues, progress: f64) {
|
||||||
match *self {
|
match *self {
|
||||||
% for prop in data.longhands:
|
% for prop in data.longhands:
|
||||||
% if prop.animatable:
|
% if prop.animatable:
|
||||||
|
@ -427,8 +427,8 @@ impl AnimatedProperty {
|
||||||
/// Get an animatable value from a transition-property, an old style, and a
|
/// Get an animatable value from a transition-property, an old style, and a
|
||||||
/// new style.
|
/// new style.
|
||||||
pub fn from_animatable_longhand(property: &AnimatableLonghand,
|
pub fn from_animatable_longhand(property: &AnimatableLonghand,
|
||||||
old_style: &ComputedValuesInner,
|
old_style: &ComputedValues,
|
||||||
new_style: &ComputedValuesInner)
|
new_style: &ComputedValues)
|
||||||
-> AnimatedProperty {
|
-> AnimatedProperty {
|
||||||
match *property {
|
match *property {
|
||||||
% for prop in data.longhands:
|
% for prop in data.longhands:
|
||||||
|
@ -521,7 +521,7 @@ impl AnimationValue {
|
||||||
|
|
||||||
/// Construct an AnimationValue from a property declaration
|
/// Construct an AnimationValue from a property declaration
|
||||||
pub fn from_declaration(decl: &PropertyDeclaration, context: &mut Context,
|
pub fn from_declaration(decl: &PropertyDeclaration, context: &mut Context,
|
||||||
initial: &ComputedValuesInner) -> Option<Self> {
|
initial: &ComputedValues) -> Option<Self> {
|
||||||
use properties::LonghandId;
|
use properties::LonghandId;
|
||||||
|
|
||||||
match *decl {
|
match *decl {
|
||||||
|
@ -593,7 +593,7 @@ impl AnimationValue {
|
||||||
|
|
||||||
/// Get an AnimationValue for an AnimatableLonghand from a given computed values.
|
/// Get an AnimationValue for an AnimatableLonghand from a given computed values.
|
||||||
pub fn from_computed_values(property: &AnimatableLonghand,
|
pub fn from_computed_values(property: &AnimatableLonghand,
|
||||||
computed_values: &ComputedValuesInner)
|
computed_values: &ComputedValues)
|
||||||
-> Self {
|
-> Self {
|
||||||
match *property {
|
match *property {
|
||||||
% for prop in data.longhands:
|
% for prop in data.longhands:
|
||||||
|
|
|
@ -124,6 +124,11 @@ impl FontComputationData {
|
||||||
pub fn default_font_size_keyword() -> Option<(longhands::font_size::KeywordSize, f32)> {
|
pub fn default_font_size_keyword() -> Option<(longhands::font_size::KeywordSize, f32)> {
|
||||||
Some((Default::default(), 1.))
|
Some((Default::default(), 1.))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Gets a FontComputationData with the default values.
|
||||||
|
pub fn default_values() -> Self {
|
||||||
|
Self::new(Self::default_font_size_keyword())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> MaybeBoxed<T> for T {
|
impl<T> MaybeBoxed<T> for T {
|
||||||
|
@ -1953,10 +1958,6 @@ impl ComputedValues {
|
||||||
|
|
||||||
/// Get the initial computed values.
|
/// Get the initial computed values.
|
||||||
pub fn initial_values() -> &'static Self { &*INITIAL_SERVO_VALUES }
|
pub fn initial_values() -> &'static Self { &*INITIAL_SERVO_VALUES }
|
||||||
|
|
||||||
/// Servo doesn't track the pseudo-element, so no need to do anything fancy
|
|
||||||
/// here.
|
|
||||||
fn pseudo(&self) -> Option<<&PseudoElement> { None }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
|
|
|
@ -62,7 +62,7 @@ impl Device {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the default computed values for this device.
|
/// Return the default computed values for this device.
|
||||||
pub fn default_computed_values(&self) -> &ComputedValues{
|
pub fn default_computed_values(&self) -> &ComputedValues {
|
||||||
// FIXME(bz): This isn't really right, but it's no more wrong
|
// FIXME(bz): This isn't really right, but it's no more wrong
|
||||||
// than what we used to do. See
|
// than what we used to do. See
|
||||||
// https://github.com/servo/servo/issues/14773 for fixing it properly.
|
// https://github.com/servo/servo/issues/14773 for fixing it properly.
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
//! a computed style needs in order for it to adhere to the CSS spec.
|
//! a computed style needs in order for it to adhere to the CSS spec.
|
||||||
|
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use properties::{self, CascadeFlags, ComputedValuesInner};
|
use properties::{self, CascadeFlags, ComputedValues};
|
||||||
use properties::{IS_ROOT_ELEMENT, SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP, StyleBuilder};
|
use properties::{IS_ROOT_ELEMENT, SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP, StyleBuilder};
|
||||||
use properties::longhands::display::computed_value::T as display;
|
use properties::longhands::display::computed_value::T as display;
|
||||||
use properties::longhands::float::computed_value::T as float;
|
use properties::longhands::float::computed_value::T as float;
|
||||||
|
@ -54,7 +54,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
/// Apply the blockification rules based on the table in CSS 2.2 section 9.7.
|
/// Apply the blockification rules based on the table in CSS 2.2 section 9.7.
|
||||||
/// https://drafts.csswg.org/css2/visuren.html#dis-pos-flo
|
/// https://drafts.csswg.org/css2/visuren.html#dis-pos-flo
|
||||||
fn blockify_if_necessary(&mut self,
|
fn blockify_if_necessary(&mut self,
|
||||||
layout_parent_style: &ComputedValuesInner,
|
layout_parent_style: &ComputedValues,
|
||||||
flags: CascadeFlags) {
|
flags: CascadeFlags) {
|
||||||
let mut blockify = false;
|
let mut blockify = false;
|
||||||
macro_rules! blockify_if {
|
macro_rules! blockify_if {
|
||||||
|
@ -136,7 +136,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
/// https://lists.w3.org/Archives/Public/www-style/2017Mar/0045.html
|
/// https://lists.w3.org/Archives/Public/www-style/2017Mar/0045.html
|
||||||
/// https://github.com/servo/servo/issues/15754
|
/// https://github.com/servo/servo/issues/15754
|
||||||
fn adjust_for_writing_mode(&mut self,
|
fn adjust_for_writing_mode(&mut self,
|
||||||
layout_parent_style: &ComputedValuesInner) {
|
layout_parent_style: &ComputedValues) {
|
||||||
let our_writing_mode = self.style.get_inheritedbox().clone_writing_mode();
|
let our_writing_mode = self.style.get_inheritedbox().clone_writing_mode();
|
||||||
let parent_writing_mode = layout_parent_style.get_inheritedbox().clone_writing_mode();
|
let parent_writing_mode = layout_parent_style.get_inheritedbox().clone_writing_mode();
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
///
|
///
|
||||||
/// See https://github.com/servo/servo/issues/15229
|
/// See https://github.com/servo/servo/issues/15229
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
fn adjust_for_alignment(&mut self, layout_parent_style: &ComputedValuesInner) {
|
fn adjust_for_alignment(&mut self, layout_parent_style: &ComputedValues) {
|
||||||
use computed_values::align_items::T as align_items;
|
use computed_values::align_items::T as align_items;
|
||||||
use computed_values::align_self::T as align_self;
|
use computed_values::align_self::T as align_self;
|
||||||
|
|
||||||
|
@ -295,7 +295,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
/// this type into its ::-moz-fieldset-content anonymous box.
|
/// this type into its ::-moz-fieldset-content anonymous box.
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
fn adjust_for_fieldset_content(&mut self,
|
fn adjust_for_fieldset_content(&mut self,
|
||||||
layout_parent_style: &ComputedValuesInner,
|
layout_parent_style: &ComputedValues,
|
||||||
flags: CascadeFlags) {
|
flags: CascadeFlags) {
|
||||||
use properties::IS_FIELDSET_CONTENT;
|
use properties::IS_FIELDSET_CONTENT;
|
||||||
if !flags.contains(IS_FIELDSET_CONTENT) {
|
if !flags.contains(IS_FIELDSET_CONTENT) {
|
||||||
|
@ -340,7 +340,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the HAS_TEXT_DECORATION_LINES flag based on parent style.
|
/// Set the HAS_TEXT_DECORATION_LINES flag based on parent style.
|
||||||
fn adjust_for_text_decoration_lines(&mut self, layout_parent_style: &ComputedValuesInner) {
|
fn adjust_for_text_decoration_lines(&mut self, layout_parent_style: &ComputedValues) {
|
||||||
use properties::computed_value_flags::HAS_TEXT_DECORATION_LINES;
|
use properties::computed_value_flags::HAS_TEXT_DECORATION_LINES;
|
||||||
if layout_parent_style.flags.contains(HAS_TEXT_DECORATION_LINES) ||
|
if layout_parent_style.flags.contains(HAS_TEXT_DECORATION_LINES) ||
|
||||||
!self.style.get_text().clone_text_decoration_line().is_empty() {
|
!self.style.get_text().clone_text_decoration_line().is_empty() {
|
||||||
|
@ -349,7 +349,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
fn should_suppress_linebreak(&self, layout_parent_style: &ComputedValuesInner) -> bool {
|
fn should_suppress_linebreak(&self, layout_parent_style: &ComputedValues) -> bool {
|
||||||
use properties::computed_value_flags::SHOULD_SUPPRESS_LINEBREAK;
|
use properties::computed_value_flags::SHOULD_SUPPRESS_LINEBREAK;
|
||||||
// Line break suppression should only be propagated to in-flow children.
|
// Line break suppression should only be propagated to in-flow children.
|
||||||
if self.style.floated() || self.style.out_of_flow_positioned() {
|
if self.style.floated() || self.style.out_of_flow_positioned() {
|
||||||
|
@ -386,8 +386,8 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
/// * correct unicode-bidi.
|
/// * correct unicode-bidi.
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
fn adjust_for_ruby(&mut self,
|
fn adjust_for_ruby(&mut self,
|
||||||
layout_parent_style: &ComputedValuesInner,
|
layout_parent_style: &ComputedValues,
|
||||||
default_computed_values: &'b ComputedValuesInner,
|
default_computed_values: &'b ComputedValues,
|
||||||
flags: CascadeFlags) {
|
flags: CascadeFlags) {
|
||||||
use properties::SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP;
|
use properties::SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP;
|
||||||
use properties::computed_value_flags::SHOULD_SUPPRESS_LINEBREAK;
|
use properties::computed_value_flags::SHOULD_SUPPRESS_LINEBREAK;
|
||||||
|
@ -431,8 +431,8 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
/// When comparing to Gecko, this is similar to the work done by
|
/// When comparing to Gecko, this is similar to the work done by
|
||||||
/// `nsStyleContext::ApplyStyleFixups`.
|
/// `nsStyleContext::ApplyStyleFixups`.
|
||||||
pub fn adjust(&mut self,
|
pub fn adjust(&mut self,
|
||||||
layout_parent_style: &ComputedValuesInner,
|
layout_parent_style: &ComputedValues,
|
||||||
_default_computed_values: &'b ComputedValuesInner,
|
_default_computed_values: &'b ComputedValues,
|
||||||
flags: CascadeFlags) {
|
flags: CascadeFlags) {
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
{
|
{
|
||||||
|
|
|
@ -723,15 +723,16 @@ pub extern "C" fn Servo_StyleSet_GetBaseComputedValuesForElement(raw_data: RawSe
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_ComputedValues_ExtractAnimationValue(computed_values: ServoComputedValuesBorrowed,
|
pub extern "C" fn Servo_ComputedValues_ExtractAnimationValue(computed_values: ServoStyleContextBorrowed,
|
||||||
property_id: nsCSSPropertyID)
|
property_id: nsCSSPropertyID)
|
||||||
-> RawServoAnimationValueStrong
|
-> RawServoAnimationValueStrong
|
||||||
{
|
{
|
||||||
let property = match AnimatableLonghand::from_nscsspropertyid(property_id) {
|
let property = match AnimatableLonghand::from_nscsspropertyid(property_id) {
|
||||||
Some(longhand) => longhand,
|
Some(longhand) => longhand,
|
||||||
None => { return Strong::null(); }
|
None => return Strong::null(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let computed_values = ComputedValues::as_arc(&computed_values);
|
||||||
Arc::new(AnimationValue::from_computed_values(&property, computed_values)).into_strong()
|
Arc::new(AnimationValue::from_computed_values(&property, computed_values)).into_strong()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ use style::context::QuirksMode;
|
||||||
use style::font_metrics::ServoMetricsProvider;
|
use style::font_metrics::ServoMetricsProvider;
|
||||||
use style::media_queries::{Device, MediaType};
|
use style::media_queries::{Device, MediaType};
|
||||||
use style::parser::ParserContext;
|
use style::parser::ParserContext;
|
||||||
use style::properties::{ComputedValues, ComputedValuesInner, StyleBuilder};
|
use style::properties::{ComputedValues, StyleBuilder};
|
||||||
use style::stylesheets::{CssRuleType, Origin};
|
use style::stylesheets::{CssRuleType, Origin};
|
||||||
use style::values::computed::{Context, ToComputedValue};
|
use style::values::computed::{Context, ToComputedValue};
|
||||||
use style_traits::{PARSING_MODE_DEFAULT, ToCss, ParseError};
|
use style_traits::{PARSING_MODE_DEFAULT, ToCss, ParseError};
|
||||||
|
@ -49,15 +49,14 @@ fn assert_computed_serialization<C, F, T>(f: F, input: &'static str, output: &st
|
||||||
T: ToComputedValue<ComputedValue=C>, C: ToCss
|
T: ToComputedValue<ComputedValue=C>, C: ToCss
|
||||||
{
|
{
|
||||||
let viewport_size = TypedSize2D::new(0., 0.);
|
let viewport_size = TypedSize2D::new(0., 0.);
|
||||||
let initial_style = ComputedValuesInner::initial_values();
|
let initial_style = ComputedValues::initial_values();
|
||||||
let device = Device::new(MediaType::Screen, viewport_size);
|
let device = Device::new(MediaType::Screen, viewport_size);
|
||||||
|
|
||||||
let context = Context {
|
let context = Context {
|
||||||
is_root_element: true,
|
is_root_element: true,
|
||||||
device: &device,
|
device: &device,
|
||||||
inherited_style: initial_style,
|
inherited_style: initial_style,
|
||||||
layout_parent_style: initial_style,
|
style: StyleBuilder::for_derived_style(&device, initial_style, None),
|
||||||
style: StyleBuilder::for_derived_style(&initial_style),
|
|
||||||
cached_system_font: None,
|
cached_system_font: None,
|
||||||
font_metrics_provider: &ServoMetricsProvider,
|
font_metrics_provider: &ServoMetricsProvider,
|
||||||
in_media_query: false,
|
in_media_query: false,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue