diff --git a/dom/base/use_counter_metrics.yaml b/dom/base/use_counter_metrics.yaml index 8509627fad6e..4f9b4eadb6c6 100644 --- a/dom/base/use_counter_metrics.yaml +++ b/dom/base/use_counter_metrics.yaml @@ -131,7 +131,7 @@ use.counter.error: send_in_pings: - use-counters -# Total of 2307 use counter metrics (excludes denominators). +# Total of 2309 use counter metrics (excludes denominators). # Total of 358 'page' use counters. use.counter.page: svgsvgelement_getelementbyid: @@ -15735,7 +15735,7 @@ use.counter.deprecated_ops.doc: send_in_pings: - use-counters -# Total of 695 'CSS (page)' use counters. +# Total of 696 'CSS (page)' use counters. use.counter.css.page: css_align_content: type: counter @@ -17692,10 +17692,10 @@ use.counter.css.page: send_in_pings: - use-counters - css_text_wrap: + css_text_wrap_mode: type: counter description: > - Whether a page used the CSS property text-wrap. + Whether a page used the CSS property text-wrap-mode. Compare against `use.counter.top_level_content_documents_destroyed` to calculate the rate. bugs: @@ -17709,10 +17709,10 @@ use.counter.css.page: send_in_pings: - use-counters - css_text_wrap_mode: + css_text_wrap_style: type: counter description: > - Whether a page used the CSS property text-wrap-mode. + Whether a page used the CSS property text-wrap-style. Compare against `use.counter.top_level_content_documents_destroyed` to calculate the rate. bugs: @@ -23268,6 +23268,23 @@ use.counter.css.page: send_in_pings: - use-counters + css_text_wrap: + type: counter + description: > + Whether a page used the CSS property text-wrap. + Compare against `use.counter.top_level_content_documents_destroyed` + to calculate the rate. + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1852098 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1852098 + notification_emails: + - dom-core@mozilla.com + - emilio@mozilla.com + expires: never + send_in_pings: + - use-counters + css_white_space: type: counter description: > @@ -27552,7 +27569,7 @@ use.counter.css.page: send_in_pings: - use-counters -# Total of 695 'CSS (document)' use counters. +# Total of 696 'CSS (document)' use counters. use.counter.css.doc: css_align_content: type: counter @@ -29509,10 +29526,10 @@ use.counter.css.doc: send_in_pings: - use-counters - css_text_wrap: + css_text_wrap_mode: type: counter description: > - Whether a document used the CSS property text-wrap. + Whether a document used the CSS property text-wrap-mode. Compare against `use.counter.content_documents_destroyed` to calculate the rate. bugs: @@ -29526,10 +29543,10 @@ use.counter.css.doc: send_in_pings: - use-counters - css_text_wrap_mode: + css_text_wrap_style: type: counter description: > - Whether a document used the CSS property text-wrap-mode. + Whether a document used the CSS property text-wrap-style. Compare against `use.counter.content_documents_destroyed` to calculate the rate. bugs: @@ -35085,6 +35102,23 @@ use.counter.css.doc: send_in_pings: - use-counters + css_text_wrap: + type: counter + description: > + Whether a document used the CSS property text-wrap. + Compare against `use.counter.content_documents_destroyed` + to calculate the rate. + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1852098 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1852098 + notification_emails: + - dom-core@mozilla.com + - emilio@mozilla.com + expires: never + send_in_pings: + - use-counters + css_white_space: type: counter description: > diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index 7c13b3fc5aca..3e68bb96d46d 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -1470,8 +1470,9 @@ void nsBlockFrame::Reflow(nsPresContext* aPresContext, ReflowOutput& aMetrics, } // Whether to apply text-wrap: balance behavior. - bool tryBalance = StyleText()->mTextWrap == StyleTextWrap::Balance && - !GetPrevContinuation(); + bool tryBalance = + StyleText()->mTextWrapStyle == StyleTextWrapStyle::Balance && + !GetPrevContinuation(); // Struct used to hold the "target" number of lines or clamp position to // maintain when doing text-wrap: balance. diff --git a/layout/style/ServoBindings.toml b/layout/style/ServoBindings.toml index 23eabb98d8e3..9e16c418b89f 100644 --- a/layout/style/ServoBindings.toml +++ b/layout/style/ServoBindings.toml @@ -177,7 +177,7 @@ rusty-enums = [ "mozilla::StyleBlend", "mozilla::StyleMaskComposite", "mozilla::StyleWritingModeProperty", - "mozilla::StyleTextWrap", + "mozilla::StyleTextWrapStyle", "StyleFontVariantEmoji", ] allowlist-vars = [ diff --git a/layout/style/nsStyleConsts.h b/layout/style/nsStyleConsts.h index 9888d6e73596..99433c902730 100644 --- a/layout/style/nsStyleConsts.h +++ b/layout/style/nsStyleConsts.h @@ -409,7 +409,7 @@ enum class StyleTextWrapMode : uint8_t { // (see https://bugzilla.mozilla.org/show_bug.cgi?id=1758391) and // white-space (https://bugzilla.mozilla.org/show_bug.cgi?id=1852478) // into shorthands. -enum class StyleTextWrap : uint8_t { +enum class StyleTextWrapStyle : uint8_t { Auto = 0, Stable, Balance, diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index 35fc075623e6..123a1b3304cc 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -2855,7 +2855,7 @@ nsStyleText::nsStyleText(const nsStyleText& aSource) mTextEmphasisStyle(aSource.mTextEmphasisStyle), mHyphenateCharacter(aSource.mHyphenateCharacter), mWebkitTextSecurity(aSource.mWebkitTextSecurity), - mTextWrap(aSource.mTextWrap) { + mTextWrapStyle(aSource.mTextWrapStyle) { MOZ_COUNT_CTOR(nsStyleText); } @@ -2890,7 +2890,7 @@ nsChangeHint nsStyleText::CalcDifference(const nsStyleText& aNewData) const { (mTabSize != aNewData.mTabSize) || (mHyphenateCharacter != aNewData.mHyphenateCharacter) || (mWebkitTextSecurity != aNewData.mWebkitTextSecurity) || - (mTextWrap != aNewData.mTextWrap)) { + (mTextWrapStyle != aNewData.mTextWrapStyle)) { return NS_STYLE_HINT_REFLOW; } diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index 1861c3aaa56c..c2354290ab86 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -887,7 +887,8 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleText { mozilla::StyleTextSecurity mWebkitTextSecurity = mozilla::StyleTextSecurity::None; - mozilla::StyleTextWrap mTextWrap = mozilla::StyleTextWrap::Auto; + mozilla::StyleTextWrapStyle mTextWrapStyle = + mozilla::StyleTextWrapStyle::Auto; char16_t TextSecurityMaskChar() const { switch (mWebkitTextSecurity) { diff --git a/servo/components/style/properties/data.py b/servo/components/style/properties/data.py index ec29a200f2bc..ea8363d323dc 100644 --- a/servo/components/style/properties/data.py +++ b/servo/components/style/properties/data.py @@ -882,6 +882,7 @@ def _remove_common_first_line_and_first_letter_properties(props, engine): props.remove("text-justify") props.remove("white-space-collapse") props.remove("text-wrap-mode") + props.remove("text-wrap-style") props.remove("word-break") props.remove("text-indent") @@ -983,10 +984,11 @@ class PropertyRestrictions: def placeholder(data): props = PropertyRestrictions.first_line(data) props.add("opacity") - props.add("text-wrap") props.add("text-overflow") props.add("text-align") props.add("text-justify") + for p in PropertyRestrictions.shorthand(data, "text-wrap"): + props.add(p) for p in PropertyRestrictions.shorthand(data, "white-space"): props.add(p) return props @@ -996,7 +998,6 @@ class PropertyRestrictions: def marker(data): return set( [ - "text-wrap", "color", "text-combine-upright", "text-transform", @@ -1006,6 +1007,7 @@ class PropertyRestrictions: "line-height", "-moz-osx-font-smoothing", ] + + PropertyRestrictions.shorthand(data, "text-wrap") + PropertyRestrictions.shorthand(data, "white-space") + PropertyRestrictions.spec(data, "css-fonts") + PropertyRestrictions.spec(data, "css-animations") @@ -1021,7 +1023,6 @@ class PropertyRestrictions: "opacity", "visibility", "text-shadow", - "text-wrap", "text-combine-upright", "ruby-position", # XXX Should these really apply to cue? @@ -1032,6 +1033,7 @@ class PropertyRestrictions: "background-blend-mode", ] + PropertyRestrictions.shorthand(data, "text-decoration") + + PropertyRestrictions.shorthand(data, "text-wrap") + PropertyRestrictions.shorthand(data, "white-space") + PropertyRestrictions.shorthand(data, "background") + PropertyRestrictions.shorthand(data, "outline") diff --git a/servo/components/style/properties/longhands/inherited_text.mako.rs b/servo/components/style/properties/longhands/inherited_text.mako.rs index 284183f98056..fb7fdd2d03a7 100644 --- a/servo/components/style/properties/longhands/inherited_text.mako.rs +++ b/servo/components/style/properties/longhands/inherited_text.mako.rs @@ -160,16 +160,6 @@ ${helpers.single_keyword( affects="layout", )} -${helpers.single_keyword( - name="text-wrap-mode", - values="wrap nowrap", - engines="gecko", - gecko_enum_prefix="StyleTextWrapMode", - animation_value_type="discrete", - spec="https://drafts.csswg.org/css-text-4/#propdef-text-wrap-mode", - affects="layout", -)} - ${helpers.predefined_type( "text-shadow", "SimpleShadow", @@ -402,13 +392,23 @@ ${helpers.single_keyword( )} ${helpers.single_keyword( - "text-wrap", + "text-wrap-mode", + "wrap nowrap", + engines="gecko", + gecko_enum_prefix="StyleTextWrapMode", + animation_value_type="discrete", + spec="https://drafts.csswg.org/css-text-4/#propdef-text-wrap-mode", + affects="layout", +)} + +${helpers.single_keyword( + "text-wrap-style", "auto stable balance", engines="gecko", gecko_pref="layout.css.text-wrap-balance.enabled", has_effect_on_gecko_scrollbars=False, - gecko_enum_prefix="StyleTextWrap", + gecko_enum_prefix="StyleTextWrapStyle", animation_value_type="discrete", - spec="https://drafts.csswg.org/css-text-4/#text-wrap", + spec="https://drafts.csswg.org/css-text-4/#text-wrap-style", affects="layout", )} diff --git a/servo/components/style/properties/shorthands/inherited_text.mako.rs b/servo/components/style/properties/shorthands/inherited_text.mako.rs index 5711e9b09e58..d470553e4258 100644 --- a/servo/components/style/properties/shorthands/inherited_text.mako.rs +++ b/servo/components/style/properties/shorthands/inherited_text.mako.rs @@ -46,6 +46,65 @@ } +<%helpers:shorthand + name="text-wrap" + engines="gecko" + sub_properties="text-wrap-mode text-wrap-style" + spec="https://www.w3.org/TR/css-text-4/#text-wrap" +> + use crate::properties::longhands::{text_wrap_mode, text_wrap_style}; + + pub fn parse_value<'i, 't>( + context: &ParserContext, + input: &mut Parser<'i, 't>, + ) -> Result> { + let mut mode = None; + let mut style = None; + + loop { + if mode.is_none() { + if let Ok(value) = input.try_parse(|input| text_wrap_mode::parse(context, input)) { + mode = Some(value); + continue + } + } + if style.is_none() { + if let Ok(value) = input.try_parse(|input| text_wrap_style::parse(context, input)) { + style = Some(value); + continue + } + } + break + } + if mode.is_some() || style.is_some() { + Ok(expanded! { + text_wrap_mode: unwrap_or_initial!(text_wrap_mode, mode), + text_wrap_style: unwrap_or_initial!(text_wrap_style, style), + }) + } else { + Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)) + } + } + + impl<'a> ToCss for LonghandsToSerialize<'a> { + fn to_css(&self, dest: &mut CssWriter) -> fmt::Result where W: fmt::Write { + use text_wrap_mode::computed_value::T as Mode; + use text_wrap_style::computed_value::T as Style; + + if matches!(self.text_wrap_style, None | Some(&Style::Auto)) { + return self.text_wrap_mode.to_css(dest); + } + + if *self.text_wrap_mode != Mode::Wrap { + self.text_wrap_mode.to_css(dest)?; + dest.write_char(' ')?; + } + + self.text_wrap_style.to_css(dest) + } + } + + <%helpers:shorthand name="white-space" engines="gecko"