Auto merge of #17924 - emilio:die-getparentallowservo-die, r=heycam

stylo: Get rid of GetParentAllowServo

Bug: 1384542

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17924)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-07-31 05:27:56 -05:00 committed by GitHub
commit b35791f86f
11 changed files with 1243 additions and 566 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -324,15 +324,19 @@ trait PrivateMatchMethods: TElement {
restyle.damage |= difference.damage;
}
// We need to cascade the children in order to ensure the correct
// propagation of computed value flags.
//
// FIXME(emilio): If we start optimizing changes to reset-only
// properties that aren't explicitly inherited, we'd need to add a flag
// to handle justify-items: auto correctly when there's a legacy
// justify-items.
if old_values.flags != new_values.flags {
return ChildCascadeRequirement::MustCascadeChildren;
}
match difference.change {
StyleChange::Unchanged => {
// We need to cascade the children in order to ensure the
// correct propagation of computed value flags.
if old_values.flags != new_values.flags {
return ChildCascadeRequirement::MustCascadeChildren;
}
ChildCascadeRequirement::CanSkipCascade
},
StyleChange::Unchanged => ChildCascadeRequirement::CanSkipCascade,
StyleChange::Changed => ChildCascadeRequirement::MustCascadeChildren,
}
}

View file

@ -60,7 +60,7 @@ use selector_parser::PseudoElement;
use servo_arc::{Arc, RawOffsetArc};
use std::mem::{forget, uninitialized, transmute, zeroed};
use std::{cmp, ops, ptr};
use values::{Auto, CustomIdent, Either, KeyframesName};
use values::{self, Auto, CustomIdent, Either, KeyframesName};
use values::computed::ToComputedValue;
use values::computed::effects::{BoxShadow, Filter, SimpleShadow};
use values::computed::length::Percentage;
@ -398,6 +398,11 @@ impl ${style_struct.gecko_struct_name} {
self.${on_set}();
% endif
}
#[allow(non_snake_case)]
pub fn reset_${ident}(&mut self, other: &Self) {
self.copy_${ident}_from(other)
}
</%def>
<%def name="impl_coord_copy(ident, gecko_ffi_name)">
@ -405,6 +410,11 @@ impl ${style_struct.gecko_struct_name} {
pub fn copy_${ident}_from(&mut self, other: &Self) {
self.gecko.${gecko_ffi_name}.copy_from(&other.gecko.${gecko_ffi_name});
}
#[allow(non_snake_case)]
pub fn reset_${ident}(&mut self, other: &Self) {
self.copy_${ident}_from(other)
}
</%def>
<%!
@ -482,6 +492,11 @@ def set_gecko_property(ffi_name, expr):
let color = ${get_gecko_property(gecko_ffi_name, self_param = "other")};
${set_gecko_property(gecko_ffi_name, "color")};
}
#[allow(non_snake_case)]
pub fn reset_${ident}(&mut self, other: &Self) {
self.copy_${ident}_from(other)
}
</%def>
<%def name="impl_color_clone(ident, gecko_ffi_name)">
@ -610,6 +625,11 @@ def set_gecko_property(ffi_name, expr):
}
}
#[allow(non_snake_case)]
pub fn reset_${ident}(&mut self, other: &Self) {
self.copy_${ident}_from(other)
}
#[allow(non_snake_case)]
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
use values::generics::{SVGPaint, SVGPaintKind};
@ -673,12 +693,20 @@ def set_gecko_property(ffi_name, expr):
//
// In practice, this means that we may have an incorrect value here, but
// we'll adjust that properly in the style fixup phase.
//
// FIXME(emilio): We could clean this up a bit special-casing the reset_
// function below.
self.gecko.${gecko_ffi_name} = other.gecko.${inherit_from};
% else:
self.gecko.${gecko_ffi_name} = other.gecko.${gecko_ffi_name};
% endif
}
#[allow(non_snake_case)]
pub fn reset_${ident}(&mut self, other: &Self) {
self.copy_${ident}_from(other)
}
%if need_clone:
#[allow(non_snake_case)]
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
@ -696,6 +724,10 @@ def set_gecko_property(ffi_name, expr):
pub fn copy_${ident}_from(&mut self, other: &Self) {
self.gecko.${gecko_ffi_name}.data_at_mut(${index}).copy_from(&other.gecko.${gecko_ffi_name}.data_at(${index}));
}
#[allow(non_snake_case)]
pub fn reset_${ident}(&mut self, other: &Self) {
self.copy_${ident}_from(other)
}
% if need_clone:
#[allow(non_snake_case)]
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
@ -715,6 +747,10 @@ def set_gecko_property(ffi_name, expr):
pub fn copy_${ident}_from(&mut self, other: &Self) {
self.gecko.${gecko_ffi_name}.copy_from(&other.gecko.${gecko_ffi_name});
}
#[allow(non_snake_case)]
pub fn reset_${ident}(&mut self, other: &Self) {
self.copy_${ident}_from(other)
}
% if need_clone:
#[allow(non_snake_case)]
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
@ -752,6 +788,11 @@ def set_gecko_property(ffi_name, expr):
% endfor
${ caller.body() }
}
#[allow(non_snake_case)]
pub fn reset_${ident}(&mut self, other: &Self) {
self.copy_${ident}_from(other)
}
</%def>
<%def name="impl_corner_style_coord(ident, gecko_ffi_name, x_index, y_index, need_clone)">
@ -767,6 +808,10 @@ def set_gecko_property(ffi_name, expr):
self.gecko.${gecko_ffi_name}.data_at_mut(${y_index})
.copy_from(&other.gecko.${gecko_ffi_name}.data_at(${y_index}));
}
#[allow(non_snake_case)]
pub fn reset_${ident}(&mut self, other: &Self) {
self.copy_${ident}_from(other)
}
% if need_clone:
#[allow(non_snake_case)]
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
@ -811,6 +856,10 @@ def set_gecko_property(ffi_name, expr):
self.gecko.${gecko_ffi_name}.set(&other.gecko.${gecko_ffi_name});
}
}
#[allow(non_snake_case)]
pub fn reset_${ident}(&mut self, other: &Self) {
self.copy_${ident}_from(other)
}
% if need_clone:
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
use values::specified::url::SpecifiedUrl;
@ -989,6 +1038,10 @@ impl ${style_struct.gecko_struct_name} {
pub fn copy_${longhand.ident}_from(&mut self, _: &Self) {
warn!("stylo: Unimplemented property setter: ${longhand.name}");
}
#[allow(non_snake_case)]
pub fn reset_${longhand.ident}(&mut self, other: &Self) {
self.copy_${longhand.ident}_from(other)
}
% if longhand.need_clone:
#[allow(non_snake_case)]
pub fn clone_${longhand.ident}(&self) -> longhands::${longhand.ident}::computed_value::T {
@ -1164,6 +1217,11 @@ fn static_assert() {
}
}
#[allow(non_snake_case)]
pub fn reset__moz_border_${side.ident}_colors(&mut self, other: &Self) {
self.copy__moz_border_${side.ident}_colors_from(other)
}
#[allow(non_snake_case)]
pub fn clone__moz_border_${side.ident}_colors(&self)
-> longhands::_moz_border_${side.ident}_colors::computed_value::T {
@ -1215,6 +1273,10 @@ fn static_assert() {
}
}
pub fn reset_border_image_source(&mut self, other: &Self) {
self.copy_border_image_source_from(other)
}
pub fn clone_border_image_source(&self) -> longhands::border_image_source::computed_value::T {
use values::None_;
@ -1250,6 +1312,10 @@ fn static_assert() {
self.gecko.mBorderImageRepeatV = other.gecko.mBorderImageRepeatV;
}
pub fn reset_border_image_repeat(&mut self, other: &Self) {
self.copy_border_image_repeat_from(other)
}
pub fn clone_border_image_repeat(&self) -> longhands::border_image_repeat::computed_value::T {
use properties::longhands::border_image_repeat::computed_value::RepeatKeyword;
use gecko_bindings::structs;
@ -1352,6 +1418,10 @@ fn static_assert() {
}
}
pub fn reset_z_index(&mut self, other: &Self) {
self.copy_z_index_from(other)
}
pub fn clone_z_index(&self) -> longhands::z_index::computed_value::T {
return match self.gecko.mZIndex.as_value() {
CoordDataValue::Integer(n) => Either::First(n),
@ -1366,8 +1436,35 @@ fn static_assert() {
% for kind in ["align", "justify"]:
${impl_simple_type_with_conversion(kind + "_content")}
${impl_simple_type_with_conversion(kind + "_self")}
${impl_simple_type_with_conversion(kind + "_items")}
% endfor
${impl_simple_type_with_conversion("align_items")}
pub fn set_justify_items(&mut self, v: longhands::justify_items::computed_value::T) {
self.gecko.mSpecifiedJustifyItems = v.specified.into();
self.set_computed_justify_items(v.computed);
}
pub fn set_computed_justify_items(&mut self, v: values::specified::JustifyItems) {
debug_assert!(v.0 != ::values::specified::align::ALIGN_AUTO);
self.gecko.mJustifyItems = v.into();
}
pub fn reset_justify_items(&mut self, reset_style: &Self) {
self.gecko.mJustifyItems = reset_style.gecko.mJustifyItems;
self.gecko.mSpecifiedJustifyItems = reset_style.gecko.mSpecifiedJustifyItems;
}
pub fn copy_justify_items_from(&mut self, other: &Self) {
self.gecko.mJustifyItems = other.gecko.mJustifyItems;
self.gecko.mSpecifiedJustifyItems = other.gecko.mJustifyItems;
}
pub fn clone_justify_items(&self) -> longhands::justify_items::computed_value::T {
longhands::justify_items::computed_value::T {
computed: self.gecko.mJustifyItems.into(),
specified: self.gecko.mSpecifiedJustifyItems.into(),
}
}
pub fn set_order(&mut self, v: longhands::order::computed_value::T) {
self.gecko.mOrder = v;
@ -1399,6 +1496,10 @@ fn static_assert() {
self.gecko.${value.gecko}.mLineName.assign(&*other.gecko.${value.gecko}.mLineName);
}
pub fn reset_${value.name}(&mut self, other: &Self) {
self.copy_${value.name}_from(other)
}
pub fn clone_${value.name}(&self) -> longhands::${value.name}::computed_value::T {
use gecko_bindings::structs::{nsStyleGridLine_kMinLine, nsStyleGridLine_kMaxLine};
use string_cache::Atom;
@ -1437,6 +1538,10 @@ fn static_assert() {
self.gecko.mGridAuto${kind.title()}Max.copy_from(&other.gecko.mGridAuto${kind.title()}Max);
}
pub fn reset_grid_auto_${kind}(&mut self, other: &Self) {
self.copy_grid_auto_${kind}_from(other)
}
pub fn clone_grid_auto_${kind}(&self) -> longhands::grid_auto_${kind}::computed_value::T {
::values::generics::grid::TrackSize::from_gecko_style_coords(&self.gecko.mGridAuto${kind.title()}Min,
&self.gecko.mGridAuto${kind.title()}Max)
@ -1574,6 +1679,10 @@ fn static_assert() {
&other.gecko.mGridTemplate${kind.title()});
}
}
pub fn reset_grid_template_${kind}(&mut self, other: &Self) {
self.copy_grid_template_${kind}_from(other)
}
% endfor
${impl_simple_type_with_conversion("grid_auto_flow")}
@ -1613,6 +1722,10 @@ fn static_assert() {
pub fn copy_grid_template_areas_from(&mut self, other: &Self) {
unsafe { self.gecko.mGridTemplateAreas.set(&other.gecko.mGridTemplateAreas) }
}
pub fn reset_grid_template_areas(&mut self, other: &Self) {
self.copy_grid_template_areas_from(other)
}
</%self:impl_trait>
<% skip_outline_longhands = " ".join("outline-style outline-width".split() +
@ -1647,6 +1760,11 @@ fn static_assert() {
self.gecko.mOutlineStyle = other.gecko.mOutlineStyle;
}
#[allow(non_snake_case)]
pub fn reset_outline_style(&mut self, other: &Self) {
self.copy_outline_style_from(other)
}
#[allow(non_snake_case)]
pub fn clone_outline_style(&self) -> longhands::outline_style::computed_value::T {
// FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts
@ -1710,7 +1828,7 @@ fn static_assert() {
};
}
pub fn copy_font_feature_settings_from(&mut self, other: &Self ) {
pub fn copy_font_feature_settings_from(&mut self, other: &Self) {
let current_settings = &mut self.gecko.mFont.fontFeatureSettings;
let feature_settings = &other.gecko.mFont.fontFeatureSettings;
let settings_length = feature_settings.len() as u32;
@ -1724,6 +1842,10 @@ fn static_assert() {
}
}
pub fn reset_font_feature_settings(&mut self, other: &Self) {
self.copy_font_feature_settings_from(other)
}
pub fn clone_font_feature_settings(&self) -> longhands::font_feature_settings::computed_value::T {
use values::generics::{FontSettings, FontSettingTag, FontSettingTagInt} ;
@ -1775,6 +1897,10 @@ fn static_assert() {
}
}
pub fn reset_font_variation_settings(&mut self, other: &Self) {
self.copy_font_variation_settings_from(other)
}
pub fn fixup_none_generic(&mut self, device: &Device) {
unsafe {
bindings::Gecko_nsStyleFont_FixupNoneGeneric(&mut self.gecko, device.pres_context())
@ -1818,6 +1944,10 @@ fn static_assert() {
self.gecko.mGenericID = other.gecko.mGenericID;
}
pub fn reset_font_family(&mut self, other: &Self) {
self.copy_font_family_from(other)
}
pub fn clone_font_family(&self) -> longhands::font_family::computed_value::T {
use properties::longhands::font_family::computed_value::{FontFamily, FamilyName};
use gecko_bindings::structs::FontFamilyType;
@ -2055,6 +2185,10 @@ fn static_assert() {
self.gecko.mFont.sizeAdjust = other.gecko.mFont.sizeAdjust;
}
pub fn reset_font_size_adjust(&mut self, other: &Self) {
self.copy_font_size_adjust_from(other)
}
pub fn clone_font_size_adjust(&self) -> longhands::font_size_adjust::computed_value::T {
use properties::longhands::font_size_adjust::computed_value::T;
T::from_gecko_adjust(self.gecko.mFont.sizeAdjust)
@ -2076,6 +2210,11 @@ fn static_assert() {
}
}
#[allow(non_snake_case)]
pub fn reset__x_lang(&mut self, other: &Self) {
self.copy__x_lang_from(other)
}
<% impl_simple_type_with_conversion("font_language_override", "mFont.languageOverride") %>
pub fn set_font_variant_alternates(&mut self, v: longhands::font_variant_alternates::computed_value::T) {
@ -2134,6 +2273,10 @@ fn static_assert() {
}
}
pub fn reset_font_variant_alternates(&mut self, other: &Self) {
self.copy_font_variant_alternates_from(other)
}
pub fn clone_font_variant_alternates(&self) -> longhands::font_variant_alternates::computed_value::T {
use Atom;
% for value in "normal swash stylistic ornaments annotation styleset character_variant historical".split():
@ -2221,6 +2364,11 @@ fn static_assert() {
gecko.m${gecko_ffi_name} = other.gecko.m${type.capitalize()}s[index].m${gecko_ffi_name};
}
}
#[allow(non_snake_case)]
pub fn reset_${type}_${ident}(&mut self, other: &Self) {
self.copy_${type}_${ident}_from(other)
}
</%def>
<%def name="impl_animation_or_transition_count(type, ident, gecko_ffi_name)">
@ -2410,6 +2558,10 @@ fn static_assert() {
self.gecko.mOriginalDisplay = other.gecko.mDisplay;
}
pub fn reset_display(&mut self, other: &Self) {
self.copy_display_from(other)
}
<%call expr="impl_keyword_clone('display', 'mDisplay', display_keyword)"></%call>
<% overflow_x = data.longhands_by_name["overflow-x"] %>
@ -2530,6 +2682,10 @@ fn static_assert() {
}
}
pub fn reset_scroll_snap_coordinate(&mut self, other: &Self) {
self.copy_scroll_snap_coordinate_from(other)
}
pub fn clone_scroll_snap_coordinate(&self) -> longhands::scroll_snap_coordinate::computed_value::T {
let vec = self.gecko.mScrollSnapCoordinate.iter().map(|f| f.into()).collect();
longhands::scroll_snap_coordinate::computed_value::T(vec)
@ -2653,6 +2809,10 @@ fn static_assert() {
unsafe { self.gecko.mSpecifiedTransform.set(&other.gecko.mSpecifiedTransform); }
}
pub fn reset_transform(&mut self, other: &Self) {
self.copy_transform_from(other)
}
<%def name="computed_operation_arm(name, keyword, items)">
<%
# %s is substituted with the call to GetArrayItem.
@ -2842,6 +3002,11 @@ fn static_assert() {
}
}
}
pub fn reset_transition_property(&mut self, other: &Self) {
self.copy_transition_property_from(other)
}
${impl_transition_count('property', 'Property')}
pub fn animations_equals(&self, other: &Self) -> bool {
@ -2889,6 +3054,11 @@ fn static_assert() {
animation.mName.assign(&*other.gecko.mAnimations[index].mName);
}
}
pub fn reset_animation_name(&mut self, other: &Self) {
self.copy_animation_name_from(other)
}
${impl_animation_count('name', 'Name')}
${impl_animation_time_value('delay', 'Delay')}
@ -2952,6 +3122,10 @@ fn static_assert() {
self.gecko.mPerspectiveOrigin[1].copy_from(&other.gecko.mPerspectiveOrigin[1]);
}
pub fn reset_perspective_origin(&mut self, other: &Self) {
self.copy_perspective_origin_from(other)
}
pub fn clone_perspective_origin(&self) -> longhands::perspective_origin::computed_value::T {
use properties::longhands::perspective_origin::computed_value::T;
use values::computed::LengthOrPercentage;
@ -2975,6 +3149,10 @@ fn static_assert() {
self.gecko.mTransformOrigin[2].copy_from(&other.gecko.mTransformOrigin[2]);
}
pub fn reset_transform_origin(&mut self, other: &Self) {
self.copy_transform_origin_from(other)
}
pub fn clone_transform_origin(&self) -> longhands::transform_origin::computed_value::T {
use properties::longhands::transform_origin::computed_value::T;
use values::computed::LengthOrPercentage;
@ -3074,6 +3252,10 @@ fn static_assert() {
}
}
pub fn reset_will_change(&mut self, other: &Self) {
self.copy_will_change_from(other)
}
pub fn clone_will_change(&self) -> longhands::will_change::computed_value::T {
use properties::longhands::will_change::computed_value::T;
use gecko_bindings::structs::nsIAtom;
@ -3207,6 +3389,10 @@ fn static_assert() {
}
self.gecko.${layers_field_name}.${field_name}Count = count;
}
pub fn reset_${shorthand}_${name}(&mut self, other: &Self) {
self.copy_${shorthand}_${name}_from(other)
}
</%def>
<%def name="impl_simple_image_array_property(name, shorthand, layer_field_name, field_name, struct_name)">
@ -3357,6 +3543,10 @@ fn static_assert() {
self.gecko.${image_layers_field}.mPosition${orientation.upper()}Count = count;
}
pub fn reset_${shorthand}_position_${orientation}(&mut self, other: &Self) {
self.copy_${shorthand}_position_${orientation}_from(other)
}
pub fn clone_${shorthand}_position_${orientation}(&self)
-> longhands::${shorthand}_position_${orientation}::computed_value::T {
longhands::${shorthand}_position_${orientation}::computed_value::T(
@ -3468,7 +3658,6 @@ fn static_assert() {
)
}
pub fn copy_${shorthand}_image_from(&mut self, other: &Self) {
use gecko_bindings::structs::nsStyleImageLayers_LayerType as LayerType;
unsafe {
@ -3488,6 +3677,10 @@ fn static_assert() {
}
}
pub fn reset_${shorthand}_image(&mut self, other: &Self) {
self.copy_${shorthand}_image_from(other)
}
#[allow(unused_variables)]
pub fn set_${shorthand}_image<I>(&mut self, images: I)
where I: IntoIterator<Item = longhands::${shorthand}_image::computed_value::single_value::T>,
@ -3603,6 +3796,10 @@ fn static_assert() {
unsafe { Gecko_CopyListStyleImageFrom(&mut self.gecko, &other.gecko); }
}
pub fn reset_list_style_image(&mut self, other: &Self) {
self.copy_list_style_image_from(other)
}
pub fn clone_list_style_image(&self) -> longhands::list_style_image::computed_value::T {
use values::specified::url::SpecifiedUrl;
use values::{Either, None_};
@ -3640,6 +3837,10 @@ fn static_assert() {
}
}
pub fn reset_list_style_type(&mut self, other: &Self) {
self.copy_list_style_type_from(other)
}
pub fn set_quotes(&mut self, other: longhands::quotes::computed_value::T) {
use gecko_bindings::bindings::Gecko_NewStyleQuoteValues;
use gecko_bindings::sugar::refptr::UniqueRefPtr;
@ -3660,6 +3861,10 @@ fn static_assert() {
unsafe { self.gecko.mQuotes.set(&other.gecko.mQuotes); }
}
pub fn reset_quotes(&mut self, other: &Self) {
self.copy_quotes_from(other)
}
pub fn clone_quotes(&self) -> longhands::quotes::computed_value::T {
unsafe {
let ref gecko_quote_values = *self.gecko.mQuotes.mRawPtr;
@ -3759,6 +3964,10 @@ fn static_assert() {
self.gecko.mBoxShadow.copy_from(&other.gecko.mBoxShadow);
}
pub fn reset_box_shadow(&mut self, other: &Self) {
self.copy_box_shadow_from(other)
}
pub fn clone_box_shadow(&self) -> longhands::box_shadow::computed_value::T {
let buf = self.gecko.mBoxShadow.iter().map(|v| v.to_box_shadow()).collect();
longhands::box_shadow::computed_value::T(buf)
@ -3819,6 +4028,10 @@ fn static_assert() {
self.gecko.mClipFlags = other.gecko.mClipFlags;
}
pub fn reset_clip(&mut self, other: &Self) {
self.copy_clip_from(other)
}
pub fn clone_clip(&self) -> longhands::clip::computed_value::T {
use gecko_bindings::structs::NS_STYLE_CLIP_AUTO;
use gecko_bindings::structs::NS_STYLE_CLIP_BOTTOM_AUTO;
@ -3948,6 +4161,10 @@ fn static_assert() {
}
}
pub fn reset_filter(&mut self, other: &Self) {
self.copy_filter_from(other)
}
pub fn clone_filter(&self) -> longhands::filter::computed_value::T {
use values::generics::effects::Filter;
use values::specified::url::SpecifiedUrl;
@ -4031,6 +4248,10 @@ fn static_assert() {
bindings::Gecko_CopyImageOrientationFrom(&mut self.gecko, &other.gecko);
}
}
pub fn reset_image_orientation(&mut self, other: &Self) {
self.copy_image_orientation_from(other)
}
</%self:impl_trait>
<%self:impl_trait style_struct_name="InheritedTable"
@ -4046,6 +4267,10 @@ fn static_assert() {
self.gecko.mBorderSpacingRow = other.gecko.mBorderSpacingRow;
}
pub fn reset_border_spacing(&mut self, other: &Self) {
self.copy_border_spacing_from(other)
}
pub fn clone_border_spacing(&self) -> longhands::border_spacing::computed_value::T {
longhands::border_spacing::computed_value::T {
horizontal: Au(self.gecko.mBorderSpacingCol),
@ -4080,6 +4305,10 @@ fn static_assert() {
self.gecko.mTextShadow.copy_from(&other.gecko.mTextShadow);
}
pub fn reset_text_shadow(&mut self, other: &Self) {
self.copy_text_shadow_from(other)
}
pub fn clone_text_shadow(&self) -> longhands::text_shadow::computed_value::T {
let buf = self.gecko.mTextShadow.iter().map(|v| v.to_simple_shadow()).collect();
longhands::text_shadow::computed_value::T(buf)
@ -4206,6 +4435,10 @@ fn static_assert() {
self.gecko.mTextEmphasisStyle = other.gecko.mTextEmphasisStyle;
}
pub fn reset_text_emphasis_style(&mut self, other: &Self) {
self.copy_text_emphasis_style_from(other)
}
pub fn clone_text_emphasis_style(&self) -> longhands::text_emphasis_style::computed_value::T {
use properties::longhands::text_emphasis_style::computed_value::{T, KeywordValue};
use properties::longhands::text_emphasis_style::ShapeKeyword;
@ -4281,6 +4514,7 @@ fn static_assert() {
clear_if_string(&mut self.gecko.mTextOverflow.mLeft);
clear_if_string(&mut self.gecko.mTextOverflow.mRight);
}
pub fn set_text_overflow(&mut self, v: longhands::text_overflow::computed_value::T) {
use gecko_bindings::structs::nsStyleTextOverflowSide;
use properties::longhands::text_overflow::Side;
@ -4318,6 +4552,10 @@ fn static_assert() {
self.gecko.mTextOverflow.mLogicalDirections = other.gecko.mTextOverflow.mLogicalDirections;
}
pub fn reset_text_overflow(&mut self, other: &Self) {
self.copy_text_overflow_from(other)
}
pub fn clone_text_overflow(&self) -> longhands::text_overflow::computed_value::T {
use gecko_bindings::structs::nsStyleTextOverflowSide;
use properties::longhands::text_overflow::Side;
@ -4361,6 +4599,10 @@ fn static_assert() {
self.gecko.mInitialLetterSink = other.gecko.mInitialLetterSink;
}
pub fn reset_initial_letter(&mut self, other: &Self) {
self.copy_initial_letter_from(other)
}
pub fn clone_initial_letter(&self) -> longhands::initial_letter::computed_value::T {
use values::generics::text::InitialLetter;
@ -4498,6 +4740,10 @@ fn static_assert() {
Gecko_CopyShapeSourceFrom(&mut self.gecko.${gecko_ffi_name}, &other.gecko.${gecko_ffi_name});
}
}
pub fn reset_${ident}(&mut self, other: &Self) {
self.copy_${ident}_from(other)
}
</%def>
<% skip_svg_longhands = """
@ -4565,6 +4811,10 @@ clip-path
}
}
pub fn reset_stroke_dasharray(&mut self, other: &Self) {
self.copy_stroke_dasharray_from(other)
}
pub fn clone_stroke_dasharray(&self) -> longhands::stroke_dasharray::computed_value::T {
use values::computed::LengthOrPercentage;
@ -4655,6 +4905,11 @@ clip-path
bindings::Gecko_nsStyleSVG_CopyContextProperties(&mut self.gecko, &other.gecko);
}
}
#[allow(non_snake_case)]
pub fn reset__moz_context_properties(&mut self, other: &Self) {
self.copy__moz_context_properties_from(other)
}
</%self:impl_trait>
<%self:impl_trait style_struct_name="Color"
@ -4758,6 +5013,10 @@ clip-path
}
}
pub fn reset_cursor(&mut self, other: &Self) {
self.copy_cursor_from(other)
}
pub fn clone_cursor(&self) -> longhands::cursor::computed_value::T {
use properties::longhands::cursor::computed_value::{Keyword, Image};
use style_traits::cursor::Cursor;
@ -4985,6 +5244,10 @@ clip-path
}
}
pub fn reset_content(&mut self, other: &Self) {
self.copy_content_from(other)
}
% for counter_property in ["Increment", "Reset"]:
pub fn set_counter_${counter_property.lower()}(&mut self, v: longhands::counter_increment::computed_value::T) {
unsafe {
@ -5003,6 +5266,10 @@ clip-path
}
}
pub fn reset_counter_${counter_property.lower()}(&mut self, other: &Self) {
self.copy_counter_${counter_property.lower()}_from(other)
}
pub fn clone_counter_${counter_property.lower()}(&self) -> longhands::counter_increment::computed_value::T {
use values::CustomIdent;
use gecko_string_cache::Atom;

View file

@ -917,6 +917,15 @@
</%def>
</%self:logical_setter_helper>
}
/// Copy the appropriate physical property from another struct for ${name}
/// given a writing mode.
pub fn reset_${to_rust_ident(name)}(&mut self,
other: &Self,
wm: WritingMode) {
self.copy_${to_rust_ident(name)}_from(other, wm)
}
% if need_clone:
/// Get the computed value for the appropriate physical property for
/// ${name} given a writing mode.

View file

@ -108,7 +108,7 @@ ${helpers.single_keyword("flex-wrap", "nowrap wrap wrap-reverse",
${helpers.predefined_type(name="justify-items",
type="JustifyItems",
initial_value="specified::JustifyItems::auto()",
initial_value="computed::JustifyItems::auto()",
spec="https://drafts.csswg.org/css-align/#propdef-justify-items",
animation_value_type="discrete")}

View file

@ -1709,6 +1709,13 @@ pub mod style_structs {
pub fn copy_${longhand.ident}_from(&mut self, other: &Self) {
self.${longhand.ident} = other.${longhand.ident}.clone();
}
/// Reset ${longhand.name} from the initial struct.
#[allow(non_snake_case)]
#[inline]
pub fn reset_${longhand.ident}(&mut self, other: &Self) {
self.copy_${longhand.ident}_from(other)
}
% if longhand.need_clone:
/// Get the computed value for ${longhand.name}.
#[allow(non_snake_case)]
@ -2606,13 +2613,13 @@ impl<'a> StyleBuilder<'a> {
/// Inherit `${property.ident}` from our parent style.
#[allow(non_snake_case)]
pub fn inherit_${property.ident}(&mut self) {
% if property.style_struct.inherited:
let inherited_struct =
% if property.style_struct.inherited:
self.inherited_style.get_${property.style_struct.name_lower}();
% else:
let inherited_struct =
self.inherited_style_ignoring_first_line.get_${property.style_struct.name_lower}();
% endif
self.${property.style_struct.ident}.mutate()
.copy_${property.ident}_from(
inherited_struct,
@ -2625,9 +2632,11 @@ impl<'a> StyleBuilder<'a> {
/// Reset `${property.ident}` to the initial value.
#[allow(non_snake_case)]
pub fn reset_${property.ident}(&mut self) {
let reset_struct = self.reset_style.get_${property.style_struct.name_lower}();
let reset_struct =
self.reset_style.get_${property.style_struct.name_lower}();
self.${property.style_struct.ident}.mutate()
.copy_${property.ident}_from(
.reset_${property.ident}(
reset_struct,
% if property.logical:
self.writing_mode,

View file

@ -454,6 +454,36 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
}
}
/// Resolves "justify-items: auto" based on the inherited style if needed to
/// comply with:
///
/// https://drafts.csswg.org/css-align/#valdef-justify-items-legacy
///
/// (Note that "auto" is being renamed to "legacy")
#[cfg(feature = "gecko")]
fn adjust_for_justify_items(&mut self) {
use values::specified::align;
let justify_items = self.style.get_position().clone_justify_items();
if justify_items.specified.0 != align::ALIGN_AUTO {
return;
}
let parent_justify_items =
self.style.get_parent_position().clone_justify_items();
if !parent_justify_items.computed.0.contains(align::ALIGN_LEGACY) {
return;
}
if parent_justify_items.computed == justify_items.computed {
return;
}
self.style
.mutate_position()
.set_computed_justify_items(parent_justify_items.computed);
}
/// Adjusts the style to account for various fixups that don't fit naturally
/// into the cascade.
///
@ -478,6 +508,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
self.adjust_for_table_text_align();
self.adjust_for_contain();
self.adjust_for_mathvariant();
self.adjust_for_justify_items();
}
#[cfg(feature = "servo")]
{

View file

@ -0,0 +1,75 @@
/* 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/. */
//! Values for CSS Box Alignment properties
//!
//! https://drafts.csswg.org/css-align/
use std::fmt;
use style_traits::ToCss;
use values::computed::{ComputedValueAsSpecified, Context, ToComputedValue};
use values::specified;
pub use super::specified::{AlignItems, AlignJustifyContent, AlignJustifySelf};
/// The computed value for the `justify-items` property.
///
/// Need to carry around both the specified and computed value to handle the
/// special legacy keyword. Sigh.
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct JustifyItems {
/// The specified value for the property. Can contain `auto`.
pub specified: specified::JustifyItems,
/// The computed value for the property. Cannot contain `auto`.
pub computed: specified::JustifyItems,
}
impl ToCss for JustifyItems {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
where W: fmt::Write,
{
self.computed.to_css(dest)
}
}
impl JustifyItems {
/// Returns the `auto` value.
pub fn auto() -> Self {
Self {
specified: specified::JustifyItems::auto(),
computed: specified::JustifyItems::normal(),
}
}
}
impl ToComputedValue for specified::JustifyItems {
type ComputedValue = JustifyItems;
/// https://drafts.csswg.org/css-align/#valdef-justify-items-legacy
fn to_computed_value(&self, _context: &Context) -> JustifyItems {
use values::specified::align;
let specified = *self;
let computed =
if self.0 != align::ALIGN_AUTO {
*self
} else {
// If the inherited value of `justify-items` includes the
// `legacy` keyword, `auto` computes to the inherited value,
// but we assume it computes to `normal`, and handle that
// special-case in StyleAdjuster.
Self::normal()
};
JustifyItems { specified, computed }
}
#[inline]
fn from_computed_value(computed: &JustifyItems) -> Self {
computed.specified
}
}
impl ComputedValueAsSpecified for AlignItems {}
impl ComputedValueAsSpecified for AlignJustifyContent {}
impl ComputedValueAsSpecified for AlignJustifySelf {}

View file

@ -25,6 +25,8 @@ use super::specified;
pub use app_units::Au;
pub use properties::animated_properties::TransitionProperty;
#[cfg(feature = "gecko")]
pub use self::align::{AlignItems, AlignJustifyContent, AlignJustifySelf, JustifyItems};
pub use self::background::BackgroundSize;
pub use self::border::{BorderImageSlice, BorderImageWidth, BorderImageSideWidth};
pub use self::border::{BorderRadius, BorderCornerRadius};
@ -36,8 +38,6 @@ pub use self::image::{Gradient, GradientItem, Image, ImageLayer, LineDirection,
pub use self::gecko::ScrollSnapPoint;
pub use self::rect::LengthOrNumberRect;
pub use super::{Auto, Either, None_};
#[cfg(feature = "gecko")]
pub use super::specified::{AlignItems, AlignJustifyContent, AlignJustifySelf, JustifyItems};
pub use super::specified::{BorderStyle, UrlOrNone};
pub use super::generics::grid::GridLine;
pub use super::specified::url::SpecifiedUrl;
@ -47,6 +47,8 @@ pub use self::position::Position;
pub use self::text::{InitialLetter, LetterSpacing, LineHeight, WordSpacing};
pub use self::transform::{TimingFunction, TransformOrigin};
#[cfg(feature = "gecko")]
pub mod align;
pub mod background;
pub mod basic_shape;
pub mod border;
@ -396,36 +398,6 @@ impl ToCss for Time {
}
}
#[cfg(feature = "gecko")]
impl ToComputedValue for specified::JustifyItems {
type ComputedValue = JustifyItems;
// https://drafts.csswg.org/css-align/#valdef-justify-items-auto
fn to_computed_value(&self, context: &Context) -> JustifyItems {
use values::specified::align;
// If the inherited value of `justify-items` includes the `legacy` keyword, `auto` computes
// to the inherited value.
if self.0 == align::ALIGN_AUTO {
let inherited = context.builder.get_parent_position().clone_justify_items();
if inherited.0.contains(align::ALIGN_LEGACY) {
return inherited
}
}
return *self
}
#[inline]
fn from_computed_value(computed: &JustifyItems) -> Self {
*computed
}
}
#[cfg(feature = "gecko")]
impl ComputedValueAsSpecified for specified::AlignItems {}
#[cfg(feature = "gecko")]
impl ComputedValueAsSpecified for specified::AlignJustifyContent {}
#[cfg(feature = "gecko")]
impl ComputedValueAsSpecified for specified::AlignJustifySelf {}
impl ComputedValueAsSpecified for specified::BorderStyle {}
/// A `<number>` value.

View file

@ -292,6 +292,12 @@ impl JustifyItems {
JustifyItems(ALIGN_AUTO)
}
/// The value 'normal'
#[inline]
pub fn normal() -> Self {
JustifyItems(ALIGN_NORMAL)
}
/// Whether this value has extra flags.
#[inline]
pub fn has_extra_flags(self) -> bool {