diff --git a/components/style/lib.rs b/components/style/lib.rs index abc176799cd..59c9f69b022 100644 --- a/components/style/lib.rs +++ b/components/style/lib.rs @@ -116,13 +116,12 @@ pub mod selector_map; pub mod selector_parser; pub mod shared_lock; pub mod sharing; -pub mod style_resolver; -pub mod stylist; -#[cfg(feature = "servo")] #[allow(unsafe_code)] pub mod servo; pub mod str; pub mod style_adjuster; +pub mod style_resolver; pub mod stylesheet_set; pub mod stylesheets; +pub mod stylist; pub mod thread_state; pub mod timer; pub mod traversal; @@ -154,6 +153,9 @@ pub mod properties { include!(concat!(env!("OUT_DIR"), "/properties.rs")); } +// uses a macro from properties +#[cfg(feature = "servo")] #[allow(unsafe_code)] pub mod servo; + #[cfg(feature = "gecko")] #[allow(unsafe_code, missing_docs)] pub mod gecko_properties { diff --git a/components/style/properties/data.py b/components/style/properties/data.py index ac7f9e427f7..9974815d88c 100644 --- a/components/style/properties/data.py +++ b/components/style/properties/data.py @@ -152,7 +152,7 @@ class Longhand(object): allowed_in_keyframe_block=True, cast_type='u8', logical=False, alias=None, extra_prefixes=None, boxed=False, flags=None, allowed_in_page_rule=False, allow_quirks=False, ignored_when_colors_disabled=False, - vector=False, need_animatable=False): + vector=False, need_animatable=False, servo_restyle_damage="repaint"): self.name = name if not spec: raise TypeError("Spec should be specified for %s" % name) @@ -211,6 +211,9 @@ class Longhand(object): self.transitionable = False self.animation_type = None + # See compute_damage for the various values this can take + self.servo_restyle_damage = servo_restyle_damage + def experimental(self, product): if product == "gecko": return bool(self.gecko_pref) diff --git a/components/style/properties/longhand/border.mako.rs b/components/style/properties/longhand/border.mako.rs index 469c5783205..bf2e8e9210b 100644 --- a/components/style/properties/longhand/border.mako.rs +++ b/components/style/properties/longhand/border.mako.rs @@ -52,7 +52,8 @@ animation_value_type="NonNegativeLength", logical=is_logical, flags="APPLIES_TO_FIRST_LETTER", - allow_quirks=not is_logical)} + allow_quirks=not is_logical, + servo_restyle_damage = "reflow rebuild_and_reflow_inline")} % endfor ${helpers.gecko_keyword_conversion(Keyword('border-style', diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs index 999b7697ab9..944e92a9770 100644 --- a/components/style/properties/longhand/box.mako.rs +++ b/components/style/properties/longhand/box.mako.rs @@ -22,6 +22,7 @@ ${helpers.predefined_type( needs_context=False, flags="APPLIES_TO_PLACEHOLDER", spec="https://drafts.csswg.org/css-display/#propdef-display", + servo_restyle_damage="rebuild_and_reflow" )} // FIXME(emilio): Listing all the display values here is very unfortunate, we should teach C++ to use the @@ -52,7 +53,8 @@ ${helpers.single_keyword("-moz-top-layer", "none top", ${helpers.single_keyword("position", "static absolute relative fixed sticky", animation_value_type="discrete", flags="CREATES_STACKING_CONTEXT ABSPOS_CB", - spec="https://drafts.csswg.org/css-position/#position-property")} + spec="https://drafts.csswg.org/css-position/#position-property", + servo_restyle_damage="rebuild_and_reflow")} <%helpers:single_keyword name="float" @@ -66,6 +68,7 @@ ${helpers.single_keyword("position", "static absolute relative fixed sticky", gecko_ffi_name="mFloat" flags="APPLIES_TO_FIRST_LETTER" spec="https://drafts.csswg.org/css-box/#propdef-float" + servo_restyle_damage="rebuild_and_reflow" > impl ToComputedValue for SpecifiedValue { type ComputedValue = computed_value::T; @@ -120,6 +123,7 @@ ${helpers.single_keyword("position", "static absolute relative fixed sticky", gecko_enum_prefix="StyleClear" gecko_ffi_name="mBreakType" spec="https://drafts.csswg.org/css-box/#propdef-clear" + servo_restyle_damage="rebuild_and_reflow" > impl ToComputedValue for SpecifiedValue { type ComputedValue = computed_value::T; @@ -392,7 +396,8 @@ ${helpers.predefined_type("transform", "Transform", animation_value_type="ComputedValue", gecko_ffi_name="mSpecifiedTransform", flags="CREATES_STACKING_CONTEXT FIXPOS_CB", - spec="https://drafts.csswg.org/css-transforms/#propdef-transform")} + spec="https://drafts.csswg.org/css-transforms/#propdef-transform", + servo_restyle_damage = "reflow_out_of_flow")} ${helpers.predefined_type("rotate", "Rotate", "generics::transform::Rotate::None", @@ -505,7 +510,8 @@ ${helpers.predefined_type("perspective", spec="https://drafts.csswg.org/css-transforms/#perspective", extra_prefixes="moz webkit", flags="CREATES_STACKING_CONTEXT FIXPOS_CB", - animation_value_type="ComputedValue")} + animation_value_type="ComputedValue", + servo_restyle_damage = "reflow_out_of_flow")} ${helpers.predefined_type("perspective-origin", "position::Position", @@ -513,7 +519,8 @@ ${helpers.predefined_type("perspective-origin", boxed=True, extra_prefixes="moz webkit", spec="https://drafts.csswg.org/css-transforms-2/#perspective-origin-property", - animation_value_type="ComputedValue")} + animation_value_type="ComputedValue", + servo_restyle_damage = "reflow_out_of_flow")} ${helpers.single_keyword("backface-visibility", "visible hidden", @@ -539,6 +546,7 @@ ${helpers.predefined_type( extra_prefixes="moz webkit", flags="CREATES_STACKING_CONTEXT FIXPOS_CB", animation_value_type="discrete", + servo_restyle_damage = "reflow_out_of_flow", )} ${helpers.predefined_type("transform-origin", @@ -548,7 +556,8 @@ ${helpers.predefined_type("transform-origin", extra_prefixes="moz webkit", gecko_ffi_name="mTransformOrigin", boxed=True, - spec="https://drafts.csswg.org/css-transforms/#transform-origin-property")} + spec="https://drafts.csswg.org/css-transforms/#transform-origin-property", + servo_restyle_damage = "reflow_out_of_flow")} ${helpers.predefined_type("contain", "Contain", diff --git a/components/style/properties/longhand/column.mako.rs b/components/style/properties/longhand/column.mako.rs index 897b95d17c4..68fcb2edc83 100644 --- a/components/style/properties/longhand/column.mako.rs +++ b/components/style/properties/longhand/column.mako.rs @@ -13,7 +13,8 @@ ${helpers.predefined_type("column-width", extra_prefixes="moz", animation_value_type="NonNegativeLengthOrAuto", servo_pref="layout.column-width.enabled", - spec="https://drafts.csswg.org/css-multicol/#propdef-column-width")} + spec="https://drafts.csswg.org/css-multicol/#propdef-column-width", + servo_restyle_damage="rebuild_and_reflow")} ${helpers.predefined_type("column-count", @@ -23,7 +24,8 @@ ${helpers.predefined_type("column-count", servo_pref="layout.column-count.enabled", animation_value_type="PositiveIntegerOrAuto", extra_prefixes="moz", - spec="https://drafts.csswg.org/css-multicol/#propdef-column-count")} + spec="https://drafts.csswg.org/css-multicol/#propdef-column-count", + servo_restyle_damage="rebuild_and_reflow")} ${helpers.predefined_type("column-gap", "length::NonNegativeLengthOrNormal", @@ -31,7 +33,8 @@ ${helpers.predefined_type("column-gap", extra_prefixes="moz", servo_pref="layout.column-gap.enabled", animation_value_type="NonNegativeLengthOrNormal", - spec="https://drafts.csswg.org/css-multicol/#propdef-column-gap")} + spec="https://drafts.csswg.org/css-multicol/#propdef-column-gap", + servo_restyle_damage = "reflow")} ${helpers.single_keyword("column-fill", "balance auto", extra_prefixes="moz", products="gecko", animation_value_type="discrete", diff --git a/components/style/properties/longhand/counters.mako.rs b/components/style/properties/longhand/counters.mako.rs index 06c1e5b76d2..ececf58310f 100644 --- a/components/style/properties/longhand/counters.mako.rs +++ b/components/style/properties/longhand/counters.mako.rs @@ -11,7 +11,8 @@ ${helpers.predefined_type("content", "computed::Content::normal()", initial_specified_value="specified::Content::normal()", animation_value_type="discrete", - spec="https://drafts.csswg.org/css-content/#propdef-content")} + spec="https://drafts.csswg.org/css-content/#propdef-content", + servo_restyle_damage="rebuild_and_reflow")} ${helpers.predefined_type( "counter-increment", @@ -19,6 +20,7 @@ ${helpers.predefined_type( initial_value="Default::default()", animation_value_type="discrete", spec="https://drafts.csswg.org/css-lists/#propdef-counter-increment", + servo_restyle_damage="rebuild_and_reflow" )} ${helpers.predefined_type( @@ -27,4 +29,5 @@ ${helpers.predefined_type( initial_value="Default::default()", animation_value_type="discrete", spec="https://drafts.csswg.org/css-lists-3/#propdef-counter-reset", + servo_restyle_damage="rebuild_and_reflow" )} diff --git a/components/style/properties/longhand/effects.mako.rs b/components/style/properties/longhand/effects.mako.rs index 98630f0ef6a..3292e1bf36c 100644 --- a/components/style/properties/longhand/effects.mako.rs +++ b/components/style/properties/longhand/effects.mako.rs @@ -12,7 +12,8 @@ ${helpers.predefined_type("opacity", "1.0", animation_value_type="ComputedValue", flags="CREATES_STACKING_CONTEXT APPLIES_TO_PLACEHOLDER", - spec="https://drafts.csswg.org/css-color/#opacity")} + spec="https://drafts.csswg.org/css-color/#opacity", + servo_restyle_damage = "reflow_out_of_flow")} ${helpers.predefined_type( "box-shadow", diff --git a/components/style/properties/longhand/font.mako.rs b/components/style/properties/longhand/font.mako.rs index 9533c09ed24..8da4af6a817 100644 --- a/components/style/properties/longhand/font.mako.rs +++ b/components/style/properties/longhand/font.mako.rs @@ -12,7 +12,8 @@ ${helpers.predefined_type("font-family", initial_value="computed::FontFamily::serif()", animation_value_type="discrete", flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", - spec="https://drafts.csswg.org/css-fonts/#propdef-font-family")} + spec="https://drafts.csswg.org/css-fonts/#propdef-font-family", + servo_restyle_damage="rebuild_and_reflow")} ${helpers.single_keyword_system("font-style", "normal italic oblique", @@ -20,7 +21,8 @@ ${helpers.single_keyword_system("font-style", gecko_ffi_name="mFont.style", spec="https://drafts.csswg.org/css-fonts/#propdef-font-style", flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", - animation_value_type="discrete")} + animation_value_type="discrete", + servo_restyle_damage="rebuild_and_reflow")} <% font_variant_caps_custom_consts= { "small-caps": "SMALLCAPS", @@ -37,7 +39,8 @@ ${helpers.single_keyword_system("font-variant-caps", spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-caps", custom_consts=font_variant_caps_custom_consts, flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", - animation_value_type="discrete")} + animation_value_type="discrete", + servo_restyle_damage="rebuild_and_reflow")} ${helpers.predefined_type("font-weight", "FontWeight", @@ -45,7 +48,8 @@ ${helpers.predefined_type("font-weight", initial_specified_value="specified::FontWeight::Normal", animation_value_type="ComputedValue", flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", - spec="https://drafts.csswg.org/css-fonts/#propdef-font-weight")} + spec="https://drafts.csswg.org/css-fonts/#propdef-font-weight", + servo_restyle_damage="rebuild_and_reflow")} ${helpers.predefined_type("font-size", "FontSize", @@ -54,7 +58,8 @@ ${helpers.predefined_type("font-size", animation_value_type="NonNegativeLength", allow_quirks=True, flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", - spec="https://drafts.csswg.org/css-fonts/#propdef-font-size")} + spec="https://drafts.csswg.org/css-fonts/#propdef-font-size", + servo_restyle_damage="rebuild_and_reflow")} ${helpers.predefined_type("font-size-adjust", "FontSizeAdjust", @@ -82,7 +87,8 @@ ${helpers.single_keyword_system("font-stretch", cast_type='i16', spec="https://drafts.csswg.org/css-fonts/#propdef-font-stretch", flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", - animation_value_type="ComputedValue")} + animation_value_type="ComputedValue", + servo_restyle_damage="rebuild_and_reflow")} ${helpers.single_keyword_system("font-kerning", "auto none normal", diff --git a/components/style/properties/longhand/inherited_box.mako.rs b/components/style/properties/longhand/inherited_box.mako.rs index dabbe14d859..23dfe7fef5c 100644 --- a/components/style/properties/longhand/inherited_box.mako.rs +++ b/components/style/properties/longhand/inherited_box.mako.rs @@ -24,11 +24,13 @@ ${helpers.single_keyword("writing-mode", tb=vertical-rl tb-rl=vertical-rl", servo_pref="layout.writing-mode.enabled", animation_value_type="discrete", - spec="https://drafts.csswg.org/css-writing-modes/#propdef-writing-mode")} + spec="https://drafts.csswg.org/css-writing-modes/#propdef-writing-mode", + servo_restyle_damage="rebuild_and_reflow")} ${helpers.single_keyword("direction", "ltr rtl", animation_value_type="discrete", spec="https://drafts.csswg.org/css-writing-modes/#propdef-direction", - needs_conversion=True)} + needs_conversion=True, + servo_restyle_damage="rebuild_and_reflow")} ${helpers.single_keyword("text-orientation", "mixed upright sideways", diff --git a/components/style/properties/longhand/inherited_table.mako.rs b/components/style/properties/longhand/inherited_table.mako.rs index 3a1fe70021d..4f55d9b1fa5 100644 --- a/components/style/properties/longhand/inherited_table.mako.rs +++ b/components/style/properties/longhand/inherited_table.mako.rs @@ -9,20 +9,24 @@ ${helpers.single_keyword("border-collapse", "separate collapse", gecko_constant_prefix="NS_STYLE_BORDER", animation_value_type="discrete", - spec="https://drafts.csswg.org/css-tables/#propdef-border-collapse")} + spec="https://drafts.csswg.org/css-tables/#propdef-border-collapse", + servo_restyle_damage = "reflow")} ${helpers.single_keyword("empty-cells", "show hide", gecko_constant_prefix="NS_STYLE_TABLE_EMPTY_CELLS", animation_value_type="discrete", - spec="https://drafts.csswg.org/css-tables/#propdef-empty-cells")} + spec="https://drafts.csswg.org/css-tables/#propdef-empty-cells", + servo_restyle_damage="rebuild_and_reflow")} ${helpers.single_keyword("caption-side", "top bottom", extra_gecko_values="right left top-outside bottom-outside", needs_conversion="True", animation_value_type="discrete", - spec="https://drafts.csswg.org/css-tables/#propdef-caption-side")} + spec="https://drafts.csswg.org/css-tables/#propdef-caption-side", + servo_restyle_damage="rebuild_and_reflow")} ${helpers.predefined_type("border-spacing", "BorderSpacing", "computed::BorderSpacing::zero()", animation_value_type="BorderSpacing", boxed=True, - spec="https://drafts.csswg.org/css-tables/#propdef-border-spacing")} + spec="https://drafts.csswg.org/css-tables/#propdef-border-spacing", + servo_restyle_damage = "reflow")} diff --git a/components/style/properties/longhand/inherited_text.mako.rs b/components/style/properties/longhand/inherited_text.mako.rs index d81c2a717cf..3594cab8463 100644 --- a/components/style/properties/longhand/inherited_text.mako.rs +++ b/components/style/properties/longhand/inherited_text.mako.rs @@ -11,7 +11,8 @@ ${helpers.predefined_type("line-height", "computed::LineHeight::normal()", animation_value_type="LineHeight", flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", - spec="https://drafts.csswg.org/css2/visudet.html#propdef-line-height")} + spec="https://drafts.csswg.org/css2/visudet.html#propdef-line-height", + servo_restyle_damage = "reflow")} // CSS Text Module Level 3 @@ -21,7 +22,8 @@ ${helpers.single_keyword("text-transform", extra_gecko_values="full-width", animation_value_type="discrete", flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", - spec="https://drafts.csswg.org/css-text/#propdef-text-transform")} + spec="https://drafts.csswg.org/css-text/#propdef-text-transform", + servo_restyle_damage="rebuild_and_reflow")} ${helpers.single_keyword("hyphens", "manual none auto", gecko_enum_prefix="StyleHyphens", @@ -41,7 +43,7 @@ ${helpers.predefined_type("text-indent", "computed::LengthOrPercentage::Length(computed::Length::new(0.))", animation_value_type="ComputedValue", spec="https://drafts.csswg.org/css-text/#propdef-text-indent", - allow_quirks=True)} + allow_quirks=True, servo_restyle_damage = "reflow")} // Also known as "word-wrap" (which is more popular because of IE), but this is the preferred // name per CSS-TEXT 6.2. @@ -50,14 +52,16 @@ ${helpers.single_keyword("overflow-wrap", gecko_constant_prefix="NS_STYLE_OVERFLOWWRAP", animation_value_type="discrete", spec="https://drafts.csswg.org/css-text/#propdef-overflow-wrap", - alias="word-wrap")} + alias="word-wrap", + servo_restyle_damage="rebuild_and_reflow")} // TODO(pcwalton): Support `word-break: keep-all` once we have better CJK support. ${helpers.single_keyword("word-break", "normal break-all keep-all", gecko_constant_prefix="NS_STYLE_WORDBREAK", animation_value_type="discrete", - spec="https://drafts.csswg.org/css-text/#propdef-word-break")} + spec="https://drafts.csswg.org/css-text/#propdef-word-break", + servo_restyle_damage="rebuild_and_reflow")} // TODO(pcwalton): Support `text-justify: distribute`. <%helpers:single_keyword @@ -70,6 +74,7 @@ ${helpers.single_keyword("word-break", gecko_pref="layout.css.text-justify.enabled" flags="APPLIES_TO_PLACEHOLDER", spec="https://drafts.csswg.org/css-text/#propdef-text-justify" + servo_restyle_damage="rebuild_and_reflow" > % if product == 'gecko': impl ToComputedValue for SpecifiedValue { @@ -113,21 +118,24 @@ ${helpers.predefined_type("text-align", "computed::TextAlign::start()", animation_value_type="discrete", flags="APPLIES_TO_PLACEHOLDER", - spec="https://drafts.csswg.org/css-text/#propdef-text-align")} + spec="https://drafts.csswg.org/css-text/#propdef-text-align", + servo_restyle_damage = "reflow")} ${helpers.predefined_type("letter-spacing", "LetterSpacing", "computed::LetterSpacing::normal()", animation_value_type="ComputedValue", flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", - spec="https://drafts.csswg.org/css-text/#propdef-letter-spacing")} + spec="https://drafts.csswg.org/css-text/#propdef-letter-spacing", + servo_restyle_damage="rebuild_and_reflow")} ${helpers.predefined_type("word-spacing", "WordSpacing", "computed::WordSpacing::normal()", animation_value_type="ComputedValue", flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", - spec="https://drafts.csswg.org/css-text/#propdef-word-spacing")} + spec="https://drafts.csswg.org/css-text/#propdef-word-spacing", + servo_restyle_damage="rebuild_and_reflow")} <%helpers:single_keyword name="white-space" @@ -139,6 +147,7 @@ ${helpers.predefined_type("word-spacing", // Only allowed for UA sheets, which set it !important. flags="APPLIES_TO_PLACEHOLDER" spec="https://drafts.csswg.org/css-text/#propdef-white-space" + servo_restyle_damage="rebuild_and_reflow" > % if product != "gecko": impl SpecifiedValue { @@ -544,7 +553,8 @@ ${helpers.single_keyword("text-combine-upright", "none all", ${helpers.single_keyword("text-rendering", "auto optimizespeed optimizelegibility geometricprecision", animation_value_type="discrete", - spec="https://www.w3.org/TR/SVG11/painting.html#TextRenderingProperty")} + spec="https://www.w3.org/TR/SVG11/painting.html#TextRenderingProperty", + servo_restyle_damage="rebuild_and_reflow")} // FIXME Firefox expects the initial value of this property to change depending // on the value of the layout.css.control-characters.visible pref. diff --git a/components/style/properties/longhand/list.mako.rs b/components/style/properties/longhand/list.mako.rs index 5819b2b8d02..87f57ba789c 100644 --- a/components/style/properties/longhand/list.mako.rs +++ b/components/style/properties/longhand/list.mako.rs @@ -28,7 +28,8 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu malayalam mongolian myanmar oriya persian telugu thai tibetan cjk-earthly-branch cjk-heavenly-stem lower-greek hiragana hiragana-iroha katakana katakana-iroha""", animation_value_type="discrete", - spec="https://drafts.csswg.org/css-lists/#propdef-list-style-type")} + spec="https://drafts.csswg.org/css-lists/#propdef-list-style-type", + servo_restyle_damage="rebuild_and_reflow")} % else: ${helpers.predefined_type("list-style-type", "ListStyleType", @@ -36,7 +37,8 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu initial_specified_value="specified::ListStyleType::disc()", animation_value_type="discrete", boxed=True, - spec="https://drafts.csswg.org/css-lists/#propdef-list-style-type")} + spec="https://drafts.csswg.org/css-lists/#propdef-list-style-type", + servo_restyle_damage="rebuild_and_reflow")} % endif ${helpers.predefined_type("list-style-image", @@ -51,7 +53,8 @@ ${helpers.predefined_type("quotes", "Quotes", "computed::Quotes::get_initial_value()", animation_value_type="discrete", - spec="https://drafts.csswg.org/css-content/#propdef-quotes")} + spec="https://drafts.csswg.org/css-content/#propdef-quotes", + servo_restyle_damage="rebuild_and_reflow")} ${helpers.predefined_type("-moz-image-region", "ClipRectOrAuto", diff --git a/components/style/properties/longhand/margin.mako.rs b/components/style/properties/longhand/margin.mako.rs index 948faeed06f..5c0d06f8206 100644 --- a/components/style/properties/longhand/margin.mako.rs +++ b/components/style/properties/longhand/margin.mako.rs @@ -18,5 +18,6 @@ allow_quirks=not side[1], animation_value_type="ComputedValue", logical = side[1], spec = spec, flags="APPLIES_TO_FIRST_LETTER", - allowed_in_page_rule=True)} + allowed_in_page_rule=True, + servo_restyle_damage = "reflow")} % endfor diff --git a/components/style/properties/longhand/padding.mako.rs b/components/style/properties/longhand/padding.mako.rs index 49d9b1bd722..be0f9553cd2 100644 --- a/components/style/properties/longhand/padding.mako.rs +++ b/components/style/properties/longhand/padding.mako.rs @@ -21,5 +21,6 @@ logical = side[1], spec = spec, flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_PLACEHOLDER", - allow_quirks=not side[1])} + allow_quirks=not side[1], + servo_restyle_damage = "reflow rebuild_and_reflow_inline")} % endfor diff --git a/components/style/properties/longhand/position.mako.rs b/components/style/properties/longhand/position.mako.rs index 6cb088a20f8..148cbc56bc4 100644 --- a/components/style/properties/longhand/position.mako.rs +++ b/components/style/properties/longhand/position.mako.rs @@ -14,7 +14,7 @@ "computed::LengthOrPercentageOrAuto::Auto", spec="https://www.w3.org/TR/CSS2/visuren.html#propdef-%s" % side, animation_value_type="ComputedValue", - allow_quirks=True)} + allow_quirks=True, servo_restyle_damage = "reflow_out_of_flow")} % endfor // offset-* logical properties, map to "top" / "left" / "bottom" / "right" % for side in LOGICAL_SIDES: @@ -55,25 +55,29 @@ ${helpers.predefined_type("z-index", "IntegerOrAuto", // Flex container properties ${helpers.single_keyword("flex-direction", "row row-reverse column column-reverse", spec="https://drafts.csswg.org/css-flexbox/#flex-direction-property", - extra_prefixes="webkit", animation_value_type="discrete")} + extra_prefixes="webkit", animation_value_type="discrete", + servo_restyle_damage = "reflow")} ${helpers.single_keyword("flex-wrap", "nowrap wrap wrap-reverse", spec="https://drafts.csswg.org/css-flexbox/#flex-wrap-property", - extra_prefixes="webkit", animation_value_type="discrete")} + extra_prefixes="webkit", animation_value_type="discrete", + servo_restyle_damage = "reflow")} % if product == "servo": // FIXME: Update Servo to support the same Syntax as Gecko. ${helpers.single_keyword("justify-content", "flex-start stretch flex-end center space-between space-around", extra_prefixes="webkit", spec="https://drafts.csswg.org/css-align/#propdef-justify-content", - animation_value_type="discrete")} + animation_value_type="discrete", + servo_restyle_damage = "reflow")} % else: ${helpers.predefined_type(name="justify-content", type="JustifyContent", initial_value="specified::JustifyContent(specified::ContentDistribution::normal())", spec="https://drafts.csswg.org/css-align/#propdef-justify-content", extra_prefixes="webkit", - animation_value_type="discrete")} + animation_value_type="discrete", + servo_restyle_damage = "reflow")} % endif % if product == "servo": @@ -81,27 +85,31 @@ ${helpers.single_keyword("flex-wrap", "nowrap wrap wrap-reverse", ${helpers.single_keyword("align-content", "stretch flex-start flex-end center space-between space-around", extra_prefixes="webkit", spec="https://drafts.csswg.org/css-align/#propdef-align-content", - animation_value_type="discrete")} + animation_value_type="discrete", + servo_restyle_damage = "reflow")} ${helpers.single_keyword("align-items", "stretch flex-start flex-end center baseline", extra_prefixes="webkit", spec="https://drafts.csswg.org/css-flexbox/#align-items-property", - animation_value_type="discrete")} + animation_value_type="discrete", + servo_restyle_damage = "reflow")} % else: ${helpers.predefined_type(name="align-content", type="AlignContent", initial_value="specified::AlignContent(specified::ContentDistribution::normal())", spec="https://drafts.csswg.org/css-align/#propdef-align-content", extra_prefixes="webkit", - animation_value_type="discrete")} + animation_value_type="discrete", + servo_restyle_damage = "reflow")} ${helpers.predefined_type(name="align-items", type="AlignItems", initial_value="specified::AlignItems::normal()", spec="https://drafts.csswg.org/css-align/#propdef-align-items", extra_prefixes="webkit", - animation_value_type="discrete")} + animation_value_type="discrete", + servo_restyle_damage = "reflow")} #[cfg(feature = "gecko")] impl_align_conversions!(::values::specified::align::AlignItems); @@ -121,13 +129,15 @@ ${helpers.predefined_type("flex-grow", "NonNegativeNumber", "From::from(0.0)", spec="https://drafts.csswg.org/css-flexbox/#flex-grow-property", extra_prefixes="webkit", - animation_value_type="NonNegativeNumber")} + animation_value_type="NonNegativeNumber", + servo_restyle_damage = "reflow")} ${helpers.predefined_type("flex-shrink", "NonNegativeNumber", "From::from(1.0)", spec="https://drafts.csswg.org/css-flexbox/#flex-shrink-property", extra_prefixes="webkit", - animation_value_type="NonNegativeNumber")} + animation_value_type="NonNegativeNumber", + servo_restyle_damage = "reflow")} // https://drafts.csswg.org/css-align/#align-self-property % if product == "servo": @@ -135,7 +145,8 @@ ${helpers.predefined_type("flex-shrink", "NonNegativeNumber", ${helpers.single_keyword("align-self", "auto stretch flex-start flex-end center baseline", extra_prefixes="webkit", spec="https://drafts.csswg.org/css-flexbox/#propdef-align-self", - animation_value_type="discrete")} + animation_value_type="discrete", + servo_restyle_damage = "reflow")} % else: ${helpers.predefined_type(name="align-self", type="AlignSelf", @@ -158,7 +169,8 @@ ${helpers.predefined_type("flex-shrink", "NonNegativeNumber", ${helpers.predefined_type("order", "Integer", "0", extra_prefixes="webkit", animation_value_type="ComputedValue", - spec="https://drafts.csswg.org/css-flexbox/#order-property")} + spec="https://drafts.csswg.org/css-flexbox/#order-property", + servo_restyle_damage = "reflow")} % if product == "gecko": // FIXME: Gecko doesn't support content value yet. @@ -173,7 +185,8 @@ ${helpers.predefined_type("order", "Integer", "0", extra_prefixes="webkit", animation_value_type="MozLength", allow_quirks=True, - spec="https://drafts.csswg.org/css-flexbox/#flex-basis-property" + spec="https://drafts.csswg.org/css-flexbox/#flex-basis-property", + servo_restyle_damage = "reflow" )} % else: // FIXME: This property should be animatable. @@ -182,7 +195,8 @@ ${helpers.predefined_type("order", "Integer", "0", "computed::FlexBasis::auto()", spec="https://drafts.csswg.org/css-flexbox/#flex-basis-property", extra_prefixes="webkit", - animation_value_type="none")} + animation_value_type="none", + servo_restyle_damage = "reflow")} % endif % for (size, logical) in ALL_SIZES: <% @@ -208,7 +222,8 @@ ${helpers.predefined_type("order", "Integer", "0", logical=logical, allow_quirks=not logical, spec=spec % size, - animation_value_type="MozLength" + animation_value_type="MozLength", + servo_restyle_damage = "reflow" )} // min-width, min-height, min-block-size, min-inline-size, ${helpers.predefined_type( @@ -219,7 +234,7 @@ ${helpers.predefined_type("order", "Integer", "0", logical=logical, allow_quirks=not logical, spec=spec % size, - animation_value_type="MozLength" + animation_value_type="MozLength", )} ${helpers.predefined_type( "max-%s" % size, @@ -239,7 +254,8 @@ ${helpers.predefined_type("order", "Integer", "0", "parse_non_negative", spec=spec % size, allow_quirks=not logical, - animation_value_type="ComputedValue", logical = logical)} + animation_value_type="ComputedValue", logical = logical, + servo_restyle_damage = "reflow")} ${helpers.predefined_type("min-%s" % size, "LengthOrPercentage", "computed::LengthOrPercentage::Length(computed::Length::new(0.))", diff --git a/components/style/properties/longhand/table.mako.rs b/components/style/properties/longhand/table.mako.rs index e93fb4254db..2af39e1d6e3 100644 --- a/components/style/properties/longhand/table.mako.rs +++ b/components/style/properties/longhand/table.mako.rs @@ -8,7 +8,8 @@ ${helpers.single_keyword("table-layout", "auto fixed", gecko_ffi_name="mLayoutStrategy", animation_value_type="discrete", - spec="https://drafts.csswg.org/css-tables/#propdef-table-layout")} + spec="https://drafts.csswg.org/css-tables/#propdef-table-layout", + servo_restyle_damage = "reflow")} ${helpers.predefined_type("-x-span", "XSpan", diff --git a/components/style/properties/longhand/text.mako.rs b/components/style/properties/longhand/text.mako.rs index 2c8bf1b52ff..613ed6c5f67 100644 --- a/components/style/properties/longhand/text.mako.rs +++ b/components/style/properties/longhand/text.mako.rs @@ -18,12 +18,14 @@ ${helpers.predefined_type("text-overflow", animation_value_type="discrete", boxed=True, flags="APPLIES_TO_PLACEHOLDER", - spec="https://drafts.csswg.org/css-ui/#propdef-text-overflow")} + spec="https://drafts.csswg.org/css-ui/#propdef-text-overflow", + servo_restyle_damage="rebuild_and_reflow")} ${helpers.single_keyword("unicode-bidi", "normal embed isolate bidi-override isolate-override plaintext", animation_value_type="discrete", - spec="https://drafts.csswg.org/css-writing-modes/#propdef-unicode-bidi")} + spec="https://drafts.csswg.org/css-writing-modes/#propdef-unicode-bidi", + servo_restyle_damage="rebuild_and_reflow")} ${helpers.predefined_type("text-decoration-line", "TextDecorationLine", @@ -31,7 +33,8 @@ ${helpers.predefined_type("text-decoration-line", initial_specified_value="specified::TextDecorationLine::none()", animation_value_type="discrete", flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", - spec="https://drafts.csswg.org/css-text-decor/#propdef-text-decoration-line")} + spec="https://drafts.csswg.org/css-text-decor/#propdef-text-decoration-line", + servo_restyle_damage="rebuild_and_reflow")} ${helpers.single_keyword("text-decoration-style", "solid double dotted dashed wavy -moz-none", diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index ee35b7bf4f4..73bfe8cf400 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -3870,3 +3870,28 @@ macro_rules! longhand_properties_idents { } } } + +% if product == "servo": +% for effect_name in ["repaint", "reflow_out_of_flow", "reflow", "rebuild_and_reflow_inline", "rebuild_and_reflow"]: + macro_rules! restyle_damage_${effect_name} { + ($old: ident, $new: ident, $damage: ident, [ $($effect:expr),* ]) => ({ + if + % for style_struct in data.active_style_structs(): + % for longhand in style_struct.longhands: + % if effect_name in longhand.servo_restyle_damage.split() and not longhand.logical: + $old.get_${style_struct.name_lower}().${longhand.ident} != + $new.get_${style_struct.name_lower}().${longhand.ident} || + % endif + % endfor + % endfor + + false { + $damage.insert($($effect)|*); + true + } else { + false + } + }) + } +% endfor +% endif diff --git a/components/style/servo/restyle_damage.rs b/components/style/servo/restyle_damage.rs index f3bb6ef3d63..9b8a16353bd 100644 --- a/components/style/servo/restyle_damage.rs +++ b/components/style/servo/restyle_damage.rs @@ -175,119 +175,32 @@ impl fmt::Display for ServoRestyleDamage { } } -// NB: We need the braces inside the RHS due to Rust #8012. This particular -// version of this macro might be safe anyway, but we want to avoid silent -// breakage on modifications. -macro_rules! add_if_not_equal( - ($old:ident, $new:ident, $damage:ident, - [ $($effect:path),* ], [ $($style_struct_getter:ident.$name:ident),* ]) => ({ - if $( ($old.$style_struct_getter().$name != $new.$style_struct_getter().$name) )||* { - $damage.insert($($effect)|*); - true - } else { - false - } - }) -); - fn compute_damage(old: &ComputedValues, new: &ComputedValues) -> ServoRestyleDamage { let mut damage = ServoRestyleDamage::empty(); // This should check every CSS property, as enumerated in the fields of // http://doc.servo.org/style/properties/struct.ComputedValues.html - // FIXME: Test somehow that every property is included. - - add_if_not_equal!(old, new, damage, - [ServoRestyleDamage::REPAINT, ServoRestyleDamage::REPOSITION, - ServoRestyleDamage::STORE_OVERFLOW, ServoRestyleDamage::BUBBLE_ISIZES, - ServoRestyleDamage::REFLOW_OUT_OF_FLOW, ServoRestyleDamage::REFLOW, - ServoRestyleDamage::RECONSTRUCT_FLOW], [ - get_box.clear, get_box.float, get_box.display, get_box.position, get_counters.content, - get_counters.counter_reset, get_counters.counter_increment, - get_list.quotes, get_list.list_style_type, - - // If these text or font properties change, we need to reconstruct the flow so that - // text shaping is re-run. - get_inheritedtext.letter_spacing, get_inheritedtext.text_rendering, - get_inheritedtext.text_transform, get_inheritedtext.word_spacing, - get_inheritedtext.overflow_wrap, get_inheritedtext.text_justify, - get_inheritedtext.white_space, get_inheritedtext.word_break, get_text.text_overflow, - get_font.font_family, get_font.font_style, get_font.font_variant_caps, get_font.font_weight, - get_font.font_size, get_font.font_stretch, - get_inheritedbox.direction, get_inheritedbox.writing_mode, - get_text.text_decoration_line, get_text.unicode_bidi, - get_inheritedtable.empty_cells, get_inheritedtable.caption_side, - get_column.column_width, get_column.column_count - ]) || (new.get_box().display == Display::Inline && - add_if_not_equal!(old, new, damage, - [ServoRestyleDamage::REPAINT, ServoRestyleDamage::REPOSITION, - ServoRestyleDamage::STORE_OVERFLOW, ServoRestyleDamage::BUBBLE_ISIZES, - ServoRestyleDamage::REFLOW_OUT_OF_FLOW, ServoRestyleDamage::REFLOW, - ServoRestyleDamage::RECONSTRUCT_FLOW], [ - // For inline boxes only, border/padding styles are used in flow construction (to decide - // whether to create fragments for empty flows). - get_border.border_top_width, get_border.border_right_width, - get_border.border_bottom_width, get_border.border_left_width, - get_padding.padding_top, get_padding.padding_right, - get_padding.padding_bottom, get_padding.padding_left - ])) || add_if_not_equal!(old, new, damage, - [ServoRestyleDamage::REPAINT, ServoRestyleDamage::REPOSITION, - ServoRestyleDamage::STORE_OVERFLOW, ServoRestyleDamage::BUBBLE_ISIZES, - ServoRestyleDamage::REFLOW_OUT_OF_FLOW, ServoRestyleDamage::REFLOW], - [get_border.border_top_width, get_border.border_right_width, - get_border.border_bottom_width, get_border.border_left_width, - get_margin.margin_top, get_margin.margin_right, - get_margin.margin_bottom, get_margin.margin_left, - get_padding.padding_top, get_padding.padding_right, - get_padding.padding_bottom, get_padding.padding_left, - get_position.width, get_position.height, - get_inheritedtext.line_height, - get_inheritedtext.text_align, get_inheritedtext.text_indent, - get_table.table_layout, - get_inheritedtable.border_collapse, - get_inheritedtable.border_spacing, - get_column.column_gap, - get_position.flex_direction, - get_position.flex_wrap, - get_position.justify_content, - get_position.align_items, - get_position.align_content, - get_position.order, - get_position.flex_basis, - get_position.flex_grow, - get_position.flex_shrink, - get_position.align_self - ]) || add_if_not_equal!(old, new, damage, - [ServoRestyleDamage::REPAINT, ServoRestyleDamage::REPOSITION, - ServoRestyleDamage::STORE_OVERFLOW, ServoRestyleDamage::REFLOW_OUT_OF_FLOW], - [get_position.top, get_position.left, - get_position.right, get_position.bottom, - get_effects.opacity, - get_box.transform, get_box.transform_style, get_box.transform_origin, - get_box.perspective, get_box.perspective_origin - ]) || add_if_not_equal!(old, new, damage, - [ServoRestyleDamage::REPAINT], [ - get_color.color, get_background.background_color, - get_background.background_image, get_background.background_position_x, - get_background.background_position_y, get_background.background_repeat, - get_background.background_attachment, get_background.background_clip, - get_background.background_origin, get_background.background_size, - get_border.border_top_color, get_border.border_right_color, - get_border.border_bottom_color, get_border.border_left_color, - get_border.border_top_style, get_border.border_right_style, - get_border.border_bottom_style, get_border.border_left_style, - get_border.border_top_left_radius, get_border.border_top_right_radius, - get_border.border_bottom_left_radius, get_border.border_bottom_right_radius, - get_position.z_index, get_box._servo_overflow_clip_box, - get_inheritedtext.text_decorations_in_effect, - get_pointing.cursor, get_pointing.pointer_events, - get_effects.box_shadow, get_effects.clip, get_inheritedtext.text_shadow, get_effects.filter, - get_effects.mix_blend_mode, get_inheritedbox.image_rendering, - - // Note: May require REFLOW et al. if `visibility: collapse` is implemented. - get_inheritedbox.visibility - ]); + restyle_damage_rebuild_and_reflow!(old, new, damage, + [ServoRestyleDamage::REPAINT, ServoRestyleDamage::REPOSITION, + ServoRestyleDamage::STORE_OVERFLOW, ServoRestyleDamage::BUBBLE_ISIZES, + ServoRestyleDamage::REFLOW_OUT_OF_FLOW, ServoRestyleDamage::REFLOW, + ServoRestyleDamage::RECONSTRUCT_FLOW]) || + (new.get_box().display == Display::Inline && + restyle_damage_rebuild_and_reflow_inline!(old, new, damage, + [ServoRestyleDamage::REPAINT, ServoRestyleDamage::REPOSITION, + ServoRestyleDamage::STORE_OVERFLOW, ServoRestyleDamage::BUBBLE_ISIZES, + ServoRestyleDamage::REFLOW_OUT_OF_FLOW, ServoRestyleDamage::REFLOW, + ServoRestyleDamage::RECONSTRUCT_FLOW])) || + restyle_damage_reflow!(old, new, damage, + [ServoRestyleDamage::REPAINT, ServoRestyleDamage::REPOSITION, + ServoRestyleDamage::STORE_OVERFLOW, ServoRestyleDamage::BUBBLE_ISIZES, + ServoRestyleDamage::REFLOW_OUT_OF_FLOW, ServoRestyleDamage::REFLOW]) || + restyle_damage_reflow_out_of_flow!(old, new, damage, + [ServoRestyleDamage::REPAINT, ServoRestyleDamage::REPOSITION, + ServoRestyleDamage::STORE_OVERFLOW, ServoRestyleDamage::REFLOW_OUT_OF_FLOW]) || + restyle_damage_repaint!(old, new, damage, + [ServoRestyleDamage::REPAINT]); // Paint worklets may depend on custom properties,