forked from mirrors/gecko-dev
Bug 1758391 - Rename text-wrap to text-wrap-style, and create the text-wrap shorthand. r=firefox-style-system-reviewers,emilio
This depends on having `text-wrap-mode`, introduced in bug 1852478 as part of
turning `white-space` into a shorthand.
Differential Revision: https://phabricator.services.mozilla.com/D198791
This commit is contained in:
parent
5741b2b190
commit
16f020d34a
9 changed files with 131 additions and 34 deletions
|
|
@ -131,7 +131,7 @@ use.counter.error:
|
||||||
send_in_pings:
|
send_in_pings:
|
||||||
- use-counters
|
- use-counters
|
||||||
|
|
||||||
# Total of 2307 use counter metrics (excludes denominators).
|
# Total of 2309 use counter metrics (excludes denominators).
|
||||||
# Total of 358 'page' use counters.
|
# Total of 358 'page' use counters.
|
||||||
use.counter.page:
|
use.counter.page:
|
||||||
svgsvgelement_getelementbyid:
|
svgsvgelement_getelementbyid:
|
||||||
|
|
@ -15735,7 +15735,7 @@ use.counter.deprecated_ops.doc:
|
||||||
send_in_pings:
|
send_in_pings:
|
||||||
- use-counters
|
- use-counters
|
||||||
|
|
||||||
# Total of 695 'CSS (page)' use counters.
|
# Total of 696 'CSS (page)' use counters.
|
||||||
use.counter.css.page:
|
use.counter.css.page:
|
||||||
css_align_content:
|
css_align_content:
|
||||||
type: counter
|
type: counter
|
||||||
|
|
@ -17692,10 +17692,10 @@ use.counter.css.page:
|
||||||
send_in_pings:
|
send_in_pings:
|
||||||
- use-counters
|
- use-counters
|
||||||
|
|
||||||
css_text_wrap:
|
css_text_wrap_mode:
|
||||||
type: counter
|
type: counter
|
||||||
description: >
|
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`
|
Compare against `use.counter.top_level_content_documents_destroyed`
|
||||||
to calculate the rate.
|
to calculate the rate.
|
||||||
bugs:
|
bugs:
|
||||||
|
|
@ -17709,10 +17709,10 @@ use.counter.css.page:
|
||||||
send_in_pings:
|
send_in_pings:
|
||||||
- use-counters
|
- use-counters
|
||||||
|
|
||||||
css_text_wrap_mode:
|
css_text_wrap_style:
|
||||||
type: counter
|
type: counter
|
||||||
description: >
|
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`
|
Compare against `use.counter.top_level_content_documents_destroyed`
|
||||||
to calculate the rate.
|
to calculate the rate.
|
||||||
bugs:
|
bugs:
|
||||||
|
|
@ -23268,6 +23268,23 @@ use.counter.css.page:
|
||||||
send_in_pings:
|
send_in_pings:
|
||||||
- use-counters
|
- 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:
|
css_white_space:
|
||||||
type: counter
|
type: counter
|
||||||
description: >
|
description: >
|
||||||
|
|
@ -27552,7 +27569,7 @@ use.counter.css.page:
|
||||||
send_in_pings:
|
send_in_pings:
|
||||||
- use-counters
|
- use-counters
|
||||||
|
|
||||||
# Total of 695 'CSS (document)' use counters.
|
# Total of 696 'CSS (document)' use counters.
|
||||||
use.counter.css.doc:
|
use.counter.css.doc:
|
||||||
css_align_content:
|
css_align_content:
|
||||||
type: counter
|
type: counter
|
||||||
|
|
@ -29509,10 +29526,10 @@ use.counter.css.doc:
|
||||||
send_in_pings:
|
send_in_pings:
|
||||||
- use-counters
|
- use-counters
|
||||||
|
|
||||||
css_text_wrap:
|
css_text_wrap_mode:
|
||||||
type: counter
|
type: counter
|
||||||
description: >
|
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`
|
Compare against `use.counter.content_documents_destroyed`
|
||||||
to calculate the rate.
|
to calculate the rate.
|
||||||
bugs:
|
bugs:
|
||||||
|
|
@ -29526,10 +29543,10 @@ use.counter.css.doc:
|
||||||
send_in_pings:
|
send_in_pings:
|
||||||
- use-counters
|
- use-counters
|
||||||
|
|
||||||
css_text_wrap_mode:
|
css_text_wrap_style:
|
||||||
type: counter
|
type: counter
|
||||||
description: >
|
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`
|
Compare against `use.counter.content_documents_destroyed`
|
||||||
to calculate the rate.
|
to calculate the rate.
|
||||||
bugs:
|
bugs:
|
||||||
|
|
@ -35085,6 +35102,23 @@ use.counter.css.doc:
|
||||||
send_in_pings:
|
send_in_pings:
|
||||||
- use-counters
|
- 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:
|
css_white_space:
|
||||||
type: counter
|
type: counter
|
||||||
description: >
|
description: >
|
||||||
|
|
|
||||||
|
|
@ -1470,7 +1470,8 @@ void nsBlockFrame::Reflow(nsPresContext* aPresContext, ReflowOutput& aMetrics,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Whether to apply text-wrap: balance behavior.
|
// Whether to apply text-wrap: balance behavior.
|
||||||
bool tryBalance = StyleText()->mTextWrap == StyleTextWrap::Balance &&
|
bool tryBalance =
|
||||||
|
StyleText()->mTextWrapStyle == StyleTextWrapStyle::Balance &&
|
||||||
!GetPrevContinuation();
|
!GetPrevContinuation();
|
||||||
|
|
||||||
// Struct used to hold the "target" number of lines or clamp position to
|
// Struct used to hold the "target" number of lines or clamp position to
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,7 @@ rusty-enums = [
|
||||||
"mozilla::StyleBlend",
|
"mozilla::StyleBlend",
|
||||||
"mozilla::StyleMaskComposite",
|
"mozilla::StyleMaskComposite",
|
||||||
"mozilla::StyleWritingModeProperty",
|
"mozilla::StyleWritingModeProperty",
|
||||||
"mozilla::StyleTextWrap",
|
"mozilla::StyleTextWrapStyle",
|
||||||
"StyleFontVariantEmoji",
|
"StyleFontVariantEmoji",
|
||||||
]
|
]
|
||||||
allowlist-vars = [
|
allowlist-vars = [
|
||||||
|
|
|
||||||
|
|
@ -409,7 +409,7 @@ enum class StyleTextWrapMode : uint8_t {
|
||||||
// (see https://bugzilla.mozilla.org/show_bug.cgi?id=1758391) and
|
// (see https://bugzilla.mozilla.org/show_bug.cgi?id=1758391) and
|
||||||
// white-space (https://bugzilla.mozilla.org/show_bug.cgi?id=1852478)
|
// white-space (https://bugzilla.mozilla.org/show_bug.cgi?id=1852478)
|
||||||
// into shorthands.
|
// into shorthands.
|
||||||
enum class StyleTextWrap : uint8_t {
|
enum class StyleTextWrapStyle : uint8_t {
|
||||||
Auto = 0,
|
Auto = 0,
|
||||||
Stable,
|
Stable,
|
||||||
Balance,
|
Balance,
|
||||||
|
|
|
||||||
|
|
@ -2855,7 +2855,7 @@ nsStyleText::nsStyleText(const nsStyleText& aSource)
|
||||||
mTextEmphasisStyle(aSource.mTextEmphasisStyle),
|
mTextEmphasisStyle(aSource.mTextEmphasisStyle),
|
||||||
mHyphenateCharacter(aSource.mHyphenateCharacter),
|
mHyphenateCharacter(aSource.mHyphenateCharacter),
|
||||||
mWebkitTextSecurity(aSource.mWebkitTextSecurity),
|
mWebkitTextSecurity(aSource.mWebkitTextSecurity),
|
||||||
mTextWrap(aSource.mTextWrap) {
|
mTextWrapStyle(aSource.mTextWrapStyle) {
|
||||||
MOZ_COUNT_CTOR(nsStyleText);
|
MOZ_COUNT_CTOR(nsStyleText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2890,7 +2890,7 @@ nsChangeHint nsStyleText::CalcDifference(const nsStyleText& aNewData) const {
|
||||||
(mTabSize != aNewData.mTabSize) ||
|
(mTabSize != aNewData.mTabSize) ||
|
||||||
(mHyphenateCharacter != aNewData.mHyphenateCharacter) ||
|
(mHyphenateCharacter != aNewData.mHyphenateCharacter) ||
|
||||||
(mWebkitTextSecurity != aNewData.mWebkitTextSecurity) ||
|
(mWebkitTextSecurity != aNewData.mWebkitTextSecurity) ||
|
||||||
(mTextWrap != aNewData.mTextWrap)) {
|
(mTextWrapStyle != aNewData.mTextWrapStyle)) {
|
||||||
return NS_STYLE_HINT_REFLOW;
|
return NS_STYLE_HINT_REFLOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -887,7 +887,8 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleText {
|
||||||
mozilla::StyleTextSecurity mWebkitTextSecurity =
|
mozilla::StyleTextSecurity mWebkitTextSecurity =
|
||||||
mozilla::StyleTextSecurity::None;
|
mozilla::StyleTextSecurity::None;
|
||||||
|
|
||||||
mozilla::StyleTextWrap mTextWrap = mozilla::StyleTextWrap::Auto;
|
mozilla::StyleTextWrapStyle mTextWrapStyle =
|
||||||
|
mozilla::StyleTextWrapStyle::Auto;
|
||||||
|
|
||||||
char16_t TextSecurityMaskChar() const {
|
char16_t TextSecurityMaskChar() const {
|
||||||
switch (mWebkitTextSecurity) {
|
switch (mWebkitTextSecurity) {
|
||||||
|
|
|
||||||
|
|
@ -882,6 +882,7 @@ def _remove_common_first_line_and_first_letter_properties(props, engine):
|
||||||
props.remove("text-justify")
|
props.remove("text-justify")
|
||||||
props.remove("white-space-collapse")
|
props.remove("white-space-collapse")
|
||||||
props.remove("text-wrap-mode")
|
props.remove("text-wrap-mode")
|
||||||
|
props.remove("text-wrap-style")
|
||||||
props.remove("word-break")
|
props.remove("word-break")
|
||||||
props.remove("text-indent")
|
props.remove("text-indent")
|
||||||
|
|
||||||
|
|
@ -983,10 +984,11 @@ class PropertyRestrictions:
|
||||||
def placeholder(data):
|
def placeholder(data):
|
||||||
props = PropertyRestrictions.first_line(data)
|
props = PropertyRestrictions.first_line(data)
|
||||||
props.add("opacity")
|
props.add("opacity")
|
||||||
props.add("text-wrap")
|
|
||||||
props.add("text-overflow")
|
props.add("text-overflow")
|
||||||
props.add("text-align")
|
props.add("text-align")
|
||||||
props.add("text-justify")
|
props.add("text-justify")
|
||||||
|
for p in PropertyRestrictions.shorthand(data, "text-wrap"):
|
||||||
|
props.add(p)
|
||||||
for p in PropertyRestrictions.shorthand(data, "white-space"):
|
for p in PropertyRestrictions.shorthand(data, "white-space"):
|
||||||
props.add(p)
|
props.add(p)
|
||||||
return props
|
return props
|
||||||
|
|
@ -996,7 +998,6 @@ class PropertyRestrictions:
|
||||||
def marker(data):
|
def marker(data):
|
||||||
return set(
|
return set(
|
||||||
[
|
[
|
||||||
"text-wrap",
|
|
||||||
"color",
|
"color",
|
||||||
"text-combine-upright",
|
"text-combine-upright",
|
||||||
"text-transform",
|
"text-transform",
|
||||||
|
|
@ -1006,6 +1007,7 @@ class PropertyRestrictions:
|
||||||
"line-height",
|
"line-height",
|
||||||
"-moz-osx-font-smoothing",
|
"-moz-osx-font-smoothing",
|
||||||
]
|
]
|
||||||
|
+ PropertyRestrictions.shorthand(data, "text-wrap")
|
||||||
+ PropertyRestrictions.shorthand(data, "white-space")
|
+ PropertyRestrictions.shorthand(data, "white-space")
|
||||||
+ PropertyRestrictions.spec(data, "css-fonts")
|
+ PropertyRestrictions.spec(data, "css-fonts")
|
||||||
+ PropertyRestrictions.spec(data, "css-animations")
|
+ PropertyRestrictions.spec(data, "css-animations")
|
||||||
|
|
@ -1021,7 +1023,6 @@ class PropertyRestrictions:
|
||||||
"opacity",
|
"opacity",
|
||||||
"visibility",
|
"visibility",
|
||||||
"text-shadow",
|
"text-shadow",
|
||||||
"text-wrap",
|
|
||||||
"text-combine-upright",
|
"text-combine-upright",
|
||||||
"ruby-position",
|
"ruby-position",
|
||||||
# XXX Should these really apply to cue?
|
# XXX Should these really apply to cue?
|
||||||
|
|
@ -1032,6 +1033,7 @@ class PropertyRestrictions:
|
||||||
"background-blend-mode",
|
"background-blend-mode",
|
||||||
]
|
]
|
||||||
+ PropertyRestrictions.shorthand(data, "text-decoration")
|
+ PropertyRestrictions.shorthand(data, "text-decoration")
|
||||||
|
+ PropertyRestrictions.shorthand(data, "text-wrap")
|
||||||
+ PropertyRestrictions.shorthand(data, "white-space")
|
+ PropertyRestrictions.shorthand(data, "white-space")
|
||||||
+ PropertyRestrictions.shorthand(data, "background")
|
+ PropertyRestrictions.shorthand(data, "background")
|
||||||
+ PropertyRestrictions.shorthand(data, "outline")
|
+ PropertyRestrictions.shorthand(data, "outline")
|
||||||
|
|
|
||||||
|
|
@ -160,16 +160,6 @@ ${helpers.single_keyword(
|
||||||
affects="layout",
|
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(
|
${helpers.predefined_type(
|
||||||
"text-shadow",
|
"text-shadow",
|
||||||
"SimpleShadow",
|
"SimpleShadow",
|
||||||
|
|
@ -402,13 +392,23 @@ ${helpers.single_keyword(
|
||||||
)}
|
)}
|
||||||
|
|
||||||
${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",
|
"auto stable balance",
|
||||||
engines="gecko",
|
engines="gecko",
|
||||||
gecko_pref="layout.css.text-wrap-balance.enabled",
|
gecko_pref="layout.css.text-wrap-balance.enabled",
|
||||||
has_effect_on_gecko_scrollbars=False,
|
has_effect_on_gecko_scrollbars=False,
|
||||||
gecko_enum_prefix="StyleTextWrap",
|
gecko_enum_prefix="StyleTextWrapStyle",
|
||||||
animation_value_type="discrete",
|
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",
|
affects="layout",
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,65 @@
|
||||||
}
|
}
|
||||||
</%helpers:shorthand>
|
</%helpers:shorthand>
|
||||||
|
|
||||||
|
<%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<Longhands, ParseError<'i>> {
|
||||||
|
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<W>(&self, dest: &mut CssWriter<W>) -> 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>
|
||||||
|
|
||||||
<%helpers:shorthand
|
<%helpers:shorthand
|
||||||
name="white-space"
|
name="white-space"
|
||||||
engines="gecko"
|
engines="gecko"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue