style: More ComputedValuesInner cleanup.

MozReview-Commit-ID: 8rkAP3pMEpD
This commit is contained in:
Emilio Cobos Álvarez 2017-07-18 16:47:13 +02:00
parent 07e1c6e75a
commit fe8638a618
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
8 changed files with 34 additions and 33 deletions

View file

@ -15,7 +15,7 @@ use data::ElementData;
use element_state::ElementState;
use font_metrics::FontMetricsProvider;
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::TransitionProperty;
use rule_tree::CascadeLevel;
@ -437,7 +437,7 @@ pub trait TElement : Eq + PartialEq + Debug + Hash + Sized + Copy + Clone +
fn may_generate_pseudo(
&self,
pseudo: &PseudoElement,
_primary_style: &ComputedValuesInner,
_primary_style: &ComputedValues,
) -> bool {
// ::before/::after are always supported for now, though we could try to
// optimize out leaf elements.

View file

@ -110,13 +110,13 @@ impl<'a> Iterator for PropertyDeclarationIterator<'a> {
pub struct AnimationValueIterator<'a, 'cx, 'cx_a:'cx> {
iter: Iter<'a, (PropertyDeclaration, Importance)>,
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> {
fn new(declarations: &'a PropertyDeclarationBlock,
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 {
iter: declarations.declarations().iter(),
context: context,
@ -204,7 +204,7 @@ impl PropertyDeclarationBlock {
/// Return an iterator of (AnimatableLonghand, AnimationValue).
pub fn to_animation_value_iter<'a, 'cx, 'cx_a:'cx>(&'a self,
context: &'cx mut Context<'cx_a>,
default_values: &'a ComputedValuesInner)
default_values: &'a ComputedValues)
-> AnimationValueIterator<'a, 'cx, 'cx_a> {
AnimationValueIterator::new(self, context, default_values)
}

View file

@ -29,7 +29,7 @@ use smallvec::SmallVec;
use std::cmp;
#[cfg(feature = "gecko")] use fnv::FnvHashMap;
use style_traits::ParseError;
use super::ComputedValuesInner;
use super::ComputedValues;
#[cfg(any(feature = "gecko", feature = "testing"))]
use values::Auto;
use values::{CSSFloat, CustomIdent, Either};
@ -394,7 +394,7 @@ impl AnimatedProperty {
/// Update `style` with the proper computed style corresponding to this
/// animation at `progress`.
pub fn update(&self, style: &mut ComputedValuesInner, progress: f64) {
pub fn update(&self, style: &mut ComputedValues, progress: f64) {
match *self {
% for prop in data.longhands:
% if prop.animatable:
@ -427,8 +427,8 @@ impl AnimatedProperty {
/// Get an animatable value from a transition-property, an old style, and a
/// new style.
pub fn from_animatable_longhand(property: &AnimatableLonghand,
old_style: &ComputedValuesInner,
new_style: &ComputedValuesInner)
old_style: &ComputedValues,
new_style: &ComputedValues)
-> AnimatedProperty {
match *property {
% for prop in data.longhands:
@ -521,7 +521,7 @@ impl AnimationValue {
/// Construct an AnimationValue from a property declaration
pub fn from_declaration(decl: &PropertyDeclaration, context: &mut Context,
initial: &ComputedValuesInner) -> Option<Self> {
initial: &ComputedValues) -> Option<Self> {
use properties::LonghandId;
match *decl {
@ -593,7 +593,7 @@ impl AnimationValue {
/// Get an AnimationValue for an AnimatableLonghand from a given computed values.
pub fn from_computed_values(property: &AnimatableLonghand,
computed_values: &ComputedValuesInner)
computed_values: &ComputedValues)
-> Self {
match *property {
% for prop in data.longhands:

View file

@ -124,6 +124,11 @@ impl FontComputationData {
pub fn default_font_size_keyword() -> Option<(longhands::font_size::KeywordSize, f32)> {
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 {
@ -1953,10 +1958,6 @@ impl ComputedValues {
/// Get the initial computed 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")]

View file

@ -6,7 +6,7 @@
//! a computed style needs in order for it to adhere to the CSS spec.
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::longhands::display::computed_value::T as display;
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.
/// https://drafts.csswg.org/css2/visuren.html#dis-pos-flo
fn blockify_if_necessary(&mut self,
layout_parent_style: &ComputedValuesInner,
layout_parent_style: &ComputedValues,
flags: CascadeFlags) {
let mut blockify = false;
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://github.com/servo/servo/issues/15754
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 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
#[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_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.
#[cfg(feature = "gecko")]
fn adjust_for_fieldset_content(&mut self,
layout_parent_style: &ComputedValuesInner,
layout_parent_style: &ComputedValues,
flags: CascadeFlags) {
use properties::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.
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;
if layout_parent_style.flags.contains(HAS_TEXT_DECORATION_LINES) ||
!self.style.get_text().clone_text_decoration_line().is_empty() {
@ -349,7 +349,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
}
#[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;
// Line break suppression should only be propagated to in-flow children.
if self.style.floated() || self.style.out_of_flow_positioned() {
@ -386,8 +386,8 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
/// * correct unicode-bidi.
#[cfg(feature = "gecko")]
fn adjust_for_ruby(&mut self,
layout_parent_style: &ComputedValuesInner,
default_computed_values: &'b ComputedValuesInner,
layout_parent_style: &ComputedValues,
default_computed_values: &'b ComputedValues,
flags: CascadeFlags) {
use properties::SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP;
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
/// `nsStyleContext::ApplyStyleFixups`.
pub fn adjust(&mut self,
layout_parent_style: &ComputedValuesInner,
_default_computed_values: &'b ComputedValuesInner,
layout_parent_style: &ComputedValues,
_default_computed_values: &'b ComputedValues,
flags: CascadeFlags) {
#[cfg(feature = "gecko")]
{

View file

@ -723,15 +723,16 @@ pub extern "C" fn Servo_StyleSet_GetBaseComputedValuesForElement(raw_data: RawSe
}
#[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)
-> RawServoAnimationValueStrong
{
let property = match AnimatableLonghand::from_nscsspropertyid(property_id) {
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()
}

View file

@ -11,7 +11,7 @@ use style::context::QuirksMode;
use style::font_metrics::ServoMetricsProvider;
use style::media_queries::{Device, MediaType};
use style::parser::ParserContext;
use style::properties::{ComputedValues, ComputedValuesInner, StyleBuilder};
use style::properties::{ComputedValues, StyleBuilder};
use style::stylesheets::{CssRuleType, Origin};
use style::values::computed::{Context, ToComputedValue};
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
{
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 context = Context {
is_root_element: true,
device: &device,
inherited_style: initial_style,
layout_parent_style: initial_style,
style: StyleBuilder::for_derived_style(&initial_style),
style: StyleBuilder::for_derived_style(&device, initial_style, None),
cached_system_font: None,
font_metrics_provider: &ServoMetricsProvider,
in_media_query: false,