diff --git a/components/style/cbindgen.toml b/components/style/cbindgen.toml index 82ed48ab290..205f5478316 100644 --- a/components/style/cbindgen.toml +++ b/components/style/cbindgen.toml @@ -95,6 +95,7 @@ include = [ "Perspective", "ZIndex", "TransformOrigin", + "WordBreak", ] item_types = ["enums", "structs", "typedefs"] diff --git a/components/style/properties/data.py b/components/style/properties/data.py index f3b4e43c225..9347d9b9428 100644 --- a/components/style/properties/data.py +++ b/components/style/properties/data.py @@ -347,6 +347,7 @@ class Longhand(object): "TouchAction", "TransformStyle", "UserSelect", + "WordBreak", "XSpan", "XTextZoom", "ZIndex", diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index ecad0b419d5..cca1bd540f9 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -1328,6 +1328,7 @@ impl Clone for ${style_struct.gecko_struct_name} { "TransformOrigin": impl_simple, "UserSelect": impl_simple, "url::UrlOrNone": impl_css_url, + "WordBreak": impl_simple, "ZIndex": impl_simple, } diff --git a/components/style/properties/longhands/inherited_text.mako.rs b/components/style/properties/longhands/inherited_text.mako.rs index 97d551120a4..f11a9a7b6b2 100644 --- a/components/style/properties/longhands/inherited_text.mako.rs +++ b/components/style/properties/longhands/inherited_text.mako.rs @@ -74,13 +74,13 @@ ${helpers.predefined_type( servo_restyle_damage="rebuild_and_reflow", )} -// TODO(pcwalton): Support `word-break: keep-all` once we have better CJK support. -${helpers.single_keyword( +${helpers.predefined_type( "word-break", - "normal break-all keep-all", - gecko_constant_prefix="NS_STYLE_WORDBREAK", + "WordBreak", + "computed::WordBreak::Normal", animation_value_type="discrete", spec="https://drafts.csswg.org/css-text/#propdef-word-break", + needs_context=False, servo_restyle_damage="rebuild_and_reflow", )} diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index 6fe36d684f2..70d1e243f02 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -78,7 +78,7 @@ pub use self::svg::{SVGLength, SVGOpacity, SVGPaint, SVGPaintKind}; pub use self::svg::{SVGPaintOrder, SVGStrokeDashArray, SVGWidth}; pub use self::table::XSpan; pub use self::text::{InitialLetter, LetterSpacing, LineHeight}; -pub use self::text::{OverflowWrap, TextOverflow, WordSpacing}; +pub use self::text::{OverflowWrap, TextOverflow, WordSpacing, WordBreak}; pub use self::text::{TextAlign, TextEmphasisPosition, TextEmphasisStyle}; pub use self::time::Time; pub use self::transform::{Rotate, Scale, Transform, TransformOperation}; diff --git a/components/style/values/computed/text.rs b/components/style/values/computed/text.rs index 2c9a9593ecc..e921967f46d 100644 --- a/components/style/values/computed/text.rs +++ b/components/style/values/computed/text.rs @@ -17,7 +17,7 @@ use crate::values::{CSSFloat, CSSInteger}; use std::fmt::{self, Write}; use style_traits::{CssWriter, ToCss}; -pub use crate::values::specified::OverflowWrap; +pub use crate::values::specified::{OverflowWrap, WordBreak}; pub use crate::values::specified::TextAlignKeyword as TextAlign; pub use crate::values::specified::TextEmphasisPosition; diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index 4956d53f177..fabc595c416 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -80,7 +80,7 @@ pub use self::svg::{SVGPaintOrder, SVGStrokeDashArray, SVGWidth}; pub use self::svg_path::SVGPathData; pub use self::table::XSpan; pub use self::text::{InitialLetter, LetterSpacing, LineHeight, TextAlign}; -pub use self::text::{OverflowWrap, TextEmphasisPosition, TextEmphasisStyle}; +pub use self::text::{OverflowWrap, TextEmphasisPosition, TextEmphasisStyle, WordBreak}; pub use self::text::{TextAlignKeyword, TextDecorationLine, TextOverflow, WordSpacing}; pub use self::time::Time; pub use self::transform::{Rotate, Scale, Transform}; diff --git a/components/style/values/specified/text.rs b/components/style/values/specified/text.rs index 1879dc4159a..33394857f68 100644 --- a/components/style/values/specified/text.rs +++ b/components/style/values/specified/text.rs @@ -813,6 +813,32 @@ impl From for u8 { } } +/// Values for the `word-break` property. +#[repr(u8)] +#[derive( + Clone, + Copy, + Debug, + Eq, + MallocSizeOf, + Parse, + PartialEq, + SpecifiedValueInfo, + ToComputedValue, + ToCss, +)] +#[allow(missing_docs)] +pub enum WordBreak { + Normal, + BreakAll, + KeepAll, + /// The break-word value, needed for compat. + /// + /// Specifying `word-break: break-word` makes `overflow-wrap` behave as + /// `anywhere`, and `word-break` behave like `normal`. + BreakWord, +} + /// Values for the `overflow-wrap` property. #[repr(u8)] #[derive(