diff --git a/devtools/shared/css/generated/properties-db.js b/devtools/shared/css/generated/properties-db.js index eb7d43b03c89..04d5745bc028 100644 --- a/devtools/shared/css/generated/properties-db.js +++ b/devtools/shared/css/generated/properties-db.js @@ -7578,6 +7578,7 @@ exports.CSS_PROPERTIES = { ], "supports": [], "values": [ + "anywhere", "break-word", "inherit", "initial", @@ -9204,6 +9205,7 @@ exports.CSS_PROPERTIES = { ], "supports": [], "values": [ + "anywhere", "break-word", "inherit", "initial", diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index 966efb56c6c0..66d7d9190b38 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -8607,8 +8607,7 @@ nsTextFrame::AddInlineMinISizeForFlow(gfxContext *aRenderingContext, return; } - // If overflow-wrap is break-word, we can wrap everywhere. - if (StaticPrefs::layout_css_overflow_break_intrinsic_size() && + if (textStyle->mOverflowWrap == mozilla::StyleOverflowWrap::Anywhere && textStyle->WordCanWrap(this)) { aData->OptionallyBreak(); aData->mCurrentLine += diff --git a/layout/style/ServoBindings.toml b/layout/style/ServoBindings.toml index 88a804470e8e..4ed046ddeacb 100644 --- a/layout/style/ServoBindings.toml +++ b/layout/style/ServoBindings.toml @@ -395,6 +395,7 @@ cbindgen-types = [ { gecko = "StyleFontLanguageOverride", servo = "values::computed::font::FontLanguageOverride" }, { gecko = "StylePathCommand", servo = "values::specified::svg_path::PathCommand" }, { gecko = "StyleUnicodeRange", servo = "cssparser::UnicodeRange" }, + { gecko = "StyleOverflowWrap", servo = "values::computed::OverflowWrap" }, ] mapped-generic-types = [ diff --git a/layout/style/ServoCSSPropList.mako.py b/layout/style/ServoCSSPropList.mako.py index 22c67b631e10..48d52eef36e8 100644 --- a/layout/style/ServoCSSPropList.mako.py +++ b/layout/style/ServoCSSPropList.mako.py @@ -102,6 +102,7 @@ SERIALIZED_PREDEFINED_TYPES = [ "ListStyleType", "OffsetPath", "Opacity", + "OverflowWrap", "Quotes", "Resize", "Scale", diff --git a/layout/style/nsStyleConsts.h b/layout/style/nsStyleConsts.h index adf4fdabfd51..58c7688dadbe 100644 --- a/layout/style/nsStyleConsts.h +++ b/layout/style/nsStyleConsts.h @@ -788,10 +788,6 @@ enum class StyleWhiteSpace : uint8_t { #define NS_STYLE_WORDBREAK_BREAK_ALL 1 #define NS_STYLE_WORDBREAK_KEEP_ALL 2 -// See nsStyleText -#define NS_STYLE_OVERFLOWWRAP_NORMAL 0 -#define NS_STYLE_OVERFLOWWRAP_BREAK_WORD 1 - // ruby-align, see nsStyleText #define NS_STYLE_RUBY_ALIGN_START 0 #define NS_STYLE_RUBY_ALIGN_CENTER 1 diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index 17e3d87b2b57..0398f6894ae0 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -4249,7 +4249,7 @@ nsStyleText::nsStyleText(const nsPresContext* aContext) , mTextTransform(NS_STYLE_TEXT_TRANSFORM_NONE) , mWhiteSpace(StyleWhiteSpace::Normal) , mWordBreak(NS_STYLE_WORDBREAK_NORMAL) - , mOverflowWrap(NS_STYLE_OVERFLOWWRAP_NORMAL) + , mOverflowWrap(StyleOverflowWrap::Normal) , mHyphens(StyleHyphens::Manual) , mRubyAlign(NS_STYLE_RUBY_ALIGN_SPACE_AROUND) , mRubyPosition(NS_STYLE_RUBY_POSITION_OVER) diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index 9930ba6312c1..b1423b325121 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -1578,7 +1578,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleText uint8_t mTextTransform; // NS_STYLE_TEXT_TRANSFORM_* mozilla::StyleWhiteSpace mWhiteSpace; uint8_t mWordBreak; // NS_STYLE_WORDBREAK_* - uint8_t mOverflowWrap; // NS_STYLE_OVERFLOWWRAP_* + mozilla::StyleOverflowWrap mOverflowWrap; mozilla::StyleHyphens mHyphens; uint8_t mRubyAlign; // NS_STYLE_RUBY_ALIGN_* uint8_t mRubyPosition; // NS_STYLE_RUBY_POSITION_* @@ -1634,8 +1634,11 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleText } bool WordCanWrapStyle() const { - return WhiteSpaceCanWrapStyle() && - mOverflowWrap == NS_STYLE_OVERFLOWWRAP_BREAK_WORD; + if (!WhiteSpaceCanWrapStyle()) { + return false; + } + return mOverflowWrap == mozilla::StyleOverflowWrap::BreakWord || + mOverflowWrap == mozilla::StyleOverflowWrap::Anywhere; } bool HasTextEmphasis() const { diff --git a/modules/libpref/init/StaticPrefList.h b/modules/libpref/init/StaticPrefList.h index 9bfd9028add2..bd41c88dbe00 100644 --- a/modules/libpref/init/StaticPrefList.h +++ b/modules/libpref/init/StaticPrefList.h @@ -804,13 +804,6 @@ VARCACHE_PREF( bool, false ) -// Does overflow-break: break-word affect intrinsic size? -VARCACHE_PREF( - "layout.css.overflow-break.intrinsic-size", - layout_css_overflow_break_intrinsic_size, - bool, false -) - // Does arbitrary ::-webkit-* pseudo-element parsed? VARCACHE_PREF( "layout.css.unknown-webkit-pseudo-element", diff --git a/servo/components/style/cbindgen.toml b/servo/components/style/cbindgen.toml index 50252690054a..06c1730622a2 100644 --- a/servo/components/style/cbindgen.toml +++ b/servo/components/style/cbindgen.toml @@ -49,6 +49,7 @@ include = [ "FontDisplay", "FontFaceSourceListComponent", "FontLanguageOverride", + "OverflowWrap", "TimingFunction", "PathCommand", "UnicodeRange", diff --git a/servo/components/style/properties/data.py b/servo/components/style/properties/data.py index 5b07f9c326a5..a7372c481818 100644 --- a/servo/components/style/properties/data.py +++ b/servo/components/style/properties/data.py @@ -324,6 +324,7 @@ class Longhand(object): "Opacity", "OutlineStyle", "OverflowClipBox", + "OverflowWrap", "OverscrollBehavior", "Percentage", "Resize", diff --git a/servo/components/style/properties/gecko.mako.rs b/servo/components/style/properties/gecko.mako.rs index 7fe1cd4d5c78..b7c9179f2922 100644 --- a/servo/components/style/properties/gecko.mako.rs +++ b/servo/components/style/properties/gecko.mako.rs @@ -1419,6 +1419,7 @@ impl Clone for ${style_struct.gecko_struct_name} { "NonNegativeNumber": impl_simple, "Number": impl_simple, "Opacity": impl_simple, + "OverflowWrap": impl_simple, "Perspective": impl_style_coord, "Position": impl_position, "RGBAColor": impl_rgba_color, diff --git a/servo/components/style/properties/longhands/inherited_text.mako.rs b/servo/components/style/properties/longhands/inherited_text.mako.rs index 164f8a7dea14..431e73e99a20 100644 --- a/servo/components/style/properties/longhands/inherited_text.mako.rs +++ b/servo/components/style/properties/longhands/inherited_text.mako.rs @@ -61,15 +61,16 @@ ${helpers.predefined_type( 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. -${helpers.single_keyword( +// Also known as "word-wrap" (which is more popular because of IE), but this is +// the preferred name per CSS-TEXT 6.2. +${helpers.predefined_type( "overflow-wrap", - "normal break-word", - gecko_constant_prefix="NS_STYLE_OVERFLOWWRAP", + "OverflowWrap", + "computed::OverflowWrap::Normal", animation_value_type="discrete", spec="https://drafts.csswg.org/css-text/#propdef-overflow-wrap", alias="word-wrap", + needs_context=False, servo_restyle_damage="rebuild_and_reflow", )} diff --git a/servo/components/style/values/computed/mod.rs b/servo/components/style/values/computed/mod.rs index 0cf1dac56866..40a350dedc07 100644 --- a/servo/components/style/values/computed/mod.rs +++ b/servo/components/style/values/computed/mod.rs @@ -78,7 +78,7 @@ pub use self::svg::{SVGPaintOrder, SVGStrokeDashArray, SVGWidth}; pub use self::table::XSpan; pub use self::text::{InitialLetter, LetterSpacing, LineHeight, MozTabSize}; pub use self::text::{TextAlign, TextEmphasisPosition, TextEmphasisStyle}; -pub use self::text::{TextOverflow, WordSpacing}; +pub use self::text::{TextOverflow, WordSpacing, OverflowWrap}; pub use self::time::Time; pub use self::transform::{Rotate, Scale, Transform, TransformOperation}; pub use self::transform::{TransformOrigin, TransformStyle, Translate}; diff --git a/servo/components/style/values/computed/text.rs b/servo/components/style/values/computed/text.rs index f8443ec607ac..daddfedc910f 100644 --- a/servo/components/style/values/computed/text.rs +++ b/servo/components/style/values/computed/text.rs @@ -19,6 +19,7 @@ use values::{CSSFloat, CSSInteger}; pub use values::specified::TextAlignKeyword as TextAlign; pub use values::specified::TextEmphasisPosition; +pub use values::specified::OverflowWrap; /// A computed value for the `initial-letter` property. pub type InitialLetter = GenericInitialLetter; diff --git a/servo/components/style/values/specified/mod.rs b/servo/components/style/values/specified/mod.rs index 21fd4b86e944..0cbd957147ca 100644 --- a/servo/components/style/values/specified/mod.rs +++ b/servo/components/style/values/specified/mod.rs @@ -76,7 +76,7 @@ pub use self::svg_path::SVGPathData; pub use self::table::XSpan; pub use self::text::{InitialLetter, LetterSpacing, LineHeight, MozTabSize, TextAlign}; pub use self::text::{TextAlignKeyword, TextDecorationLine, TextOverflow, WordSpacing}; -pub use self::text::{TextEmphasisPosition, TextEmphasisStyle}; +pub use self::text::{TextEmphasisPosition, TextEmphasisStyle, OverflowWrap}; pub use self::time::Time; pub use self::transform::{Rotate, Scale, Transform}; pub use self::transform::{TransformOrigin, TransformStyle, Translate}; diff --git a/servo/components/style/values/specified/text.rs b/servo/components/style/values/specified/text.rs index 32405076054e..a62825147c9b 100644 --- a/servo/components/style/values/specified/text.rs +++ b/servo/components/style/values/specified/text.rs @@ -659,6 +659,8 @@ impl ToComputedValue for TextEmphasisStyle { fn to_computed_value(&self, context: &Context) -> Self::ComputedValue { match *self { TextEmphasisStyle::Keyword(ref keyword) => { + // FIXME(emilio): This should set the rule_cache_conditions + // properly. let default_shape = if context.style().get_inherited_box().clone_writing_mode() == SpecifiedWritingMode::HorizontalTb { @@ -680,6 +682,7 @@ impl ToComputedValue for TextEmphasisStyle { }, } } + #[inline] fn from_computed_value(computed: &Self::ComputedValue) -> Self { match *computed { @@ -877,3 +880,24 @@ impl Parse for MozTabSize { )?)) } } + +/// Values for the `overflow-wrap` property. +#[repr(u8)] +#[derive( + Clone, + Copy, + Debug, + Eq, + MallocSizeOf, + Parse, + PartialEq, + SpecifiedValueInfo, + ToComputedValue, + ToCss, +)] +#[allow(missing_docs)] +pub enum OverflowWrap { + Normal, + BreakWord, + Anywhere, +} diff --git a/testing/web-platform/meta/css/css-text/overflow-wrap/overflow-wrap-min-content-size-001.html.ini b/testing/web-platform/meta/css/css-text/overflow-wrap/overflow-wrap-min-content-size-001.html.ini deleted file mode 100644 index b8d2b741cda3..000000000000 --- a/testing/web-platform/meta/css/css-text/overflow-wrap/overflow-wrap-min-content-size-001.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[overflow-wrap-min-content-size-001.html] - prefs: [layout.css.overflow-break.intrinsic-size:true] diff --git a/testing/web-platform/meta/css/css-text/overflow-wrap/overflow-wrap-min-content-size-002.html.ini b/testing/web-platform/meta/css/css-text/overflow-wrap/overflow-wrap-min-content-size-002.html.ini deleted file mode 100644 index a7f74abcf099..000000000000 --- a/testing/web-platform/meta/css/css-text/overflow-wrap/overflow-wrap-min-content-size-002.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[overflow-wrap-min-content-size-002.html] - prefs: [layout.css.overflow-break.intrinsic-size:true] diff --git a/testing/web-platform/meta/css/css-text/overflow-wrap/overflow-wrap-min-content-size-003.html.ini b/testing/web-platform/meta/css/css-text/overflow-wrap/overflow-wrap-min-content-size-003.html.ini deleted file mode 100644 index d831f9ab237e..000000000000 --- a/testing/web-platform/meta/css/css-text/overflow-wrap/overflow-wrap-min-content-size-003.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[overflow-wrap-min-content-size-003.html] - prefs: [layout.css.overflow-break.intrinsic-size:true] diff --git a/testing/web-platform/tests/css/css-text/overflow-wrap/overflow-wrap-min-content-size-001.html b/testing/web-platform/tests/css/css-text/overflow-wrap/overflow-wrap-min-content-size-001.html index e4a7ef4a3852..608d4853a242 100644 --- a/testing/web-platform/tests/css/css-text/overflow-wrap/overflow-wrap-min-content-size-001.html +++ b/testing/web-platform/tests/css/css-text/overflow-wrap/overflow-wrap-min-content-size-001.html @@ -1,14 +1,14 @@ -CSS Text Test: overflow-wrap: break-word and intrinsic sizing +CSS Text Test: overflow-wrap: anywhere and intrinsic sizing - +