aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2018-11-08 22:39:34 +0000
committerEmilio Cobos Álvarez <emilio@crisal.io>2018-11-10 21:10:19 +0100
commitfa764fc8e98835968925b4df3d8f9c9bf1d49ba9 (patch)
tree4e747cf897085ab881fcc67c4a96dee9cace7ee1
parent087ac72f73850ba9016429ee3201d293badd060e (diff)
downloadservo-fa764fc8e98835968925b4df3d8f9c9bf1d49ba9.tar.gz
servo-fa764fc8e98835968925b4df3d8f9c9bf1d49ba9.zip
style: Implement overflow-wrap: anywhere.
Per https://github.com/w3c/csswg-drafts/issues/2682 Differential Revision: https://phabricator.services.mozilla.com/D11328
-rw-r--r--components/style/cbindgen.toml1
-rw-r--r--components/style/properties/data.py1
-rw-r--r--components/style/properties/gecko.mako.rs1
-rw-r--r--components/style/properties/longhands/inherited_text.mako.rs11
-rw-r--r--components/style/values/computed/mod.rs2
-rw-r--r--components/style/values/computed/text.rs1
-rw-r--r--components/style/values/specified/mod.rs2
-rw-r--r--components/style/values/specified/text.rs24
8 files changed, 36 insertions, 7 deletions
diff --git a/components/style/cbindgen.toml b/components/style/cbindgen.toml
index 50252690054..06c1730622a 100644
--- a/components/style/cbindgen.toml
+++ b/components/style/cbindgen.toml
@@ -49,6 +49,7 @@ include = [
"FontDisplay",
"FontFaceSourceListComponent",
"FontLanguageOverride",
+ "OverflowWrap",
"TimingFunction",
"PathCommand",
"UnicodeRange",
diff --git a/components/style/properties/data.py b/components/style/properties/data.py
index 38fb9b71c6d..10f64484693 100644
--- a/components/style/properties/data.py
+++ b/components/style/properties/data.py
@@ -324,6 +324,7 @@ class Longhand(object):
"Opacity",
"OutlineStyle",
"OverflowClipBox",
+ "OverflowWrap",
"OverscrollBehavior",
"Percentage",
"Resize",
diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs
index b41e84a3be8..b845d382623 100644
--- a/components/style/properties/gecko.mako.rs
+++ b/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/components/style/properties/longhands/inherited_text.mako.rs b/components/style/properties/longhands/inherited_text.mako.rs
index 5b6cf609826..95c12885f60 100644
--- a/components/style/properties/longhands/inherited_text.mako.rs
+++ b/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/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs
index 5b43b964c6f..045c7489472 100644
--- a/components/style/values/computed/mod.rs
+++ b/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/components/style/values/computed/text.rs b/components/style/values/computed/text.rs
index 0f16f2d26fd..88e458cbd3e 100644
--- a/components/style/values/computed/text.rs
+++ b/components/style/values/computed/text.rs
@@ -21,6 +21,7 @@ use style_traits::{CssWriter, ToCss};
pub use crate::values::specified::TextAlignKeyword as TextAlign;
pub use crate::values::specified::TextEmphasisPosition;
+pub use crate::values::specified::OverflowWrap;
/// A computed value for the `initial-letter` property.
pub type InitialLetter = GenericInitialLetter<CSSFloat, CSSInteger>;
diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs
index 0fb510543f7..bb9bca07b0f 100644
--- a/components/style/values/specified/mod.rs
+++ b/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/components/style/values/specified/text.rs b/components/style/values/specified/text.rs
index 43106a1083f..fc1fcc5fd5b 100644
--- a/components/style/values/specified/text.rs
+++ b/components/style/values/specified/text.rs
@@ -661,6 +661,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
{
@@ -682,6 +684,7 @@ impl ToComputedValue for TextEmphasisStyle {
},
}
}
+
#[inline]
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
match *computed {
@@ -879,3 +882,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,
+}