Bug 1542178 - Fix ToResolvedValue implementation for caret-color, and serialize some color properties with Servo. r=heycam
authorEmilio Cobos Álvarez <emilio@crisal.io>
Wed, 10 Apr 2019 12:10:49 +0000
changeset 530662 5ce09292f6bfd580d4a641ed8c00651dc0c7691e
parent 530661 11dcdb94e2faab73048c25a0802105d8e97d0f14
child 530663 3a101d5a14bb38c6f0234b6c393cb5d8065c4f9b
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1542178
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1542178 - Fix ToResolvedValue implementation for caret-color, and serialize some color properties with Servo. r=heycam Differential Revision: https://phabricator.services.mozilla.com/D26785
layout/style/ServoCSSPropList.mako.py
layout/style/nsComputedDOMStyle.cpp
layout/style/nsComputedDOMStyle.h
servo/components/style/values/generics/color.rs
servo/components/style/values/resolved/color.rs
servo/components/style/values/resolved/mod.rs
--- a/layout/style/ServoCSSPropList.mako.py
+++ b/layout/style/ServoCSSPropList.mako.py
@@ -64,20 +64,16 @@ def method(prop):
 LONGHANDS_NOT_SERIALIZED_WITH_SERVO = [
     "animation-delay",
     "animation-duration",
     "animation-iteration-count",
     "animation-name",
     "border-image-width",
     "border-spacing",
     "border-image-width",
-    "border-spacing",
-    "box-shadow",
-    "caret-color",
-    "color",
     "column-count",
     "column-gap",
     "column-rule-width",
     "display",
     "fill",
     "filter",
     "flex-basis",
     "flex-grow",
@@ -104,24 +100,22 @@ LONGHANDS_NOT_SERIALIZED_WITH_SERVO = [
     "min-width",
     "-moz-binding",
     "-moz-box-flex",
     "-moz-force-broken-image-icon",
     "-moz-osx-font-smoothing",
     "outline-width",
     "paint-order",
     "row-gap",
-    "scrollbar-color",
     "scroll-snap-points-x",
     "scroll-snap-points-y",
     "stroke",
     "text-emphasis-position",
     "text-emphasis-style",
     "text-overflow",
-    "text-shadow",
     "transition-delay",
     "transition-duration",
     "transition-property",
     "vertical-align",
     "-webkit-text-stroke-width",
     "will-change",
 ]
 
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -1040,22 +1040,16 @@ void nsComputedDOMStyle::SetToRGBAColor(
   aValue->SetString(string);
 }
 
 void nsComputedDOMStyle::SetValueFromComplexColor(
     nsROCSSPrimitiveValue* aValue, const mozilla::StyleColor& aColor) {
   SetToRGBAColor(aValue, aColor.CalcColor(*mComputedStyle));
 }
 
-already_AddRefed<CSSValue> nsComputedDOMStyle::DoGetColor() {
-  RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
-  SetToRGBAColor(val, StyleColor()->mColor.ToColor());
-  return val.forget();
-}
-
 already_AddRefed<CSSValue> nsComputedDOMStyle::DoGetColumnCount() {
   RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
 
   const nsStyleColumn* column = StyleColumn();
 
   if (column->mColumnCount == nsStyleColumn::kColumnCountAuto) {
     val->SetIdent(eCSSKeyword_auto);
   } else {
@@ -1842,36 +1836,16 @@ already_AddRefed<CSSValue> nsComputedDOM
 already_AddRefed<CSSValue> nsComputedDOMStyle::DoGetScrollSnapPointsX() {
   return GetScrollSnapPoints(StyleDisplay()->mScrollSnapPointsX);
 }
 
 already_AddRefed<CSSValue> nsComputedDOMStyle::DoGetScrollSnapPointsY() {
   return GetScrollSnapPoints(StyleDisplay()->mScrollSnapPointsY);
 }
 
-already_AddRefed<CSSValue> nsComputedDOMStyle::DoGetScrollbarColor() {
-  const nsStyleUI* ui = StyleUI();
-  if (ui->mScrollbarColor.IsAuto()) {
-    RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
-    val->SetIdent(eCSSKeyword_auto);
-    return val.forget();
-  }
-
-  RefPtr<nsDOMCSSValueList> list = GetROCSSValueList(false);
-  auto put = [this, &list](const mozilla::StyleColor& color) {
-    RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
-    SetValueFromComplexColor(val, color);
-    list->AppendCSSValue(val.forget());
-  };
-  auto& colors = ui->mScrollbarColor.AsColors();
-  put(colors.thumb);
-  put(colors.track);
-  return list.forget();
-}
-
 already_AddRefed<CSSValue> nsComputedDOMStyle::DoGetOutlineWidth() {
   RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
   val->SetAppUnits(StyleOutline()->GetOutlineWidth());
   return val.forget();
 }
 
 already_AddRefed<CSSValue> nsComputedDOMStyle::GetCSSShadowArray(
     nsCSSShadowArray* aArray, bool aIsBoxShadow) {
@@ -1927,20 +1901,16 @@ already_AddRefed<CSSValue> nsComputedDOM
       itemList->AppendCSSValue(val.forget());
     }
     valueList->AppendCSSValue(itemList.forget());
   }
 
   return valueList.forget();
 }
 
-already_AddRefed<CSSValue> nsComputedDOMStyle::DoGetBoxShadow() {
-  return GetCSSShadowArray(StyleEffects()->mBoxShadow, true);
-}
-
 already_AddRefed<CSSValue> nsComputedDOMStyle::DoGetInitialLetter() {
   const nsStyleTextReset* textReset = StyleTextReset();
   RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
   if (textReset->mInitialLetterSink == 0) {
     val->SetIdent(eCSSKeyword_normal);
     return val.forget();
   } else {
     RefPtr<nsDOMCSSValueList> valueList = GetROCSSValueList(false);
@@ -2121,39 +2091,22 @@ already_AddRefed<CSSValue> nsComputedDOM
   }
 
   RefPtr<nsDOMCSSValueList> valueList = GetROCSSValueList(false);
   valueList->AppendCSSValue(first.forget());
   valueList->AppendCSSValue(second.forget());
   return valueList.forget();
 }
 
-already_AddRefed<CSSValue> nsComputedDOMStyle::DoGetTextShadow() {
-  return GetCSSShadowArray(StyleText()->mTextShadow, false);
-}
-
 already_AddRefed<CSSValue> nsComputedDOMStyle::DoGetWebkitTextStrokeWidth() {
   RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
   val->SetAppUnits(StyleText()->mWebkitTextStrokeWidth);
   return val.forget();
 }
 
-static_assert(NS_STYLE_UNICODE_BIDI_NORMAL == 0,
-              "unicode-bidi style constants not as expected");
-
-already_AddRefed<CSSValue> nsComputedDOMStyle::DoGetCaretColor() {
-  RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
-  if (StyleUI()->mCaretColor.IsAuto()) {
-    SetToRGBAColor(val, StyleColor()->mColor.ToColor());
-  } else {
-    SetValueFromComplexColor(val, StyleUI()->mCaretColor.AsColor());
-  }
-  return val.forget();
-}
-
 already_AddRefed<CSSValue> nsComputedDOMStyle::DoGetBoxFlex() {
   RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
   val->SetNumber(StyleXUL()->mBoxFlex);
   return val.forget();
 }
 
 /* Border image properties */
 
--- a/layout/style/nsComputedDOMStyle.h
+++ b/layout/style/nsComputedDOMStyle.h
@@ -242,17 +242,16 @@ class nsComputedDOMStyle final : public 
   already_AddRefed<CSSValue> DoGetMinHeight();
   already_AddRefed<CSSValue> DoGetMinWidth();
   already_AddRefed<CSSValue> DoGetLeft();
   already_AddRefed<CSSValue> DoGetTop();
   already_AddRefed<CSSValue> DoGetRight();
   already_AddRefed<CSSValue> DoGetBottom();
 
   /* Color */
-  already_AddRefed<CSSValue> DoGetColor();
 
   /* Font properties */
   already_AddRefed<CSSValue> DoGetOsxFontSmoothing();
 
   /* Grid properties */
   already_AddRefed<CSSValue> DoGetGridAutoFlow();
   already_AddRefed<CSSValue> DoGetGridAutoColumns();
   already_AddRefed<CSSValue> DoGetGridAutoRows();
@@ -286,17 +285,16 @@ class nsComputedDOMStyle final : public 
   already_AddRefed<CSSValue> DoGetBorderBottomWidth();
   already_AddRefed<CSSValue> DoGetBorderLeftWidth();
   already_AddRefed<CSSValue> DoGetBorderRightWidth();
 
   /* Border Image */
   already_AddRefed<CSSValue> DoGetBorderImageWidth();
 
   /* Box Shadow */
-  already_AddRefed<CSSValue> DoGetBoxShadow();
 
   /* Margin Properties */
   already_AddRefed<CSSValue> DoGetMarginTopWidth();
   already_AddRefed<CSSValue> DoGetMarginBottomWidth();
   already_AddRefed<CSSValue> DoGetMarginLeftWidth();
   already_AddRefed<CSSValue> DoGetMarginRightWidth();
 
   /* Outline Properties */
@@ -306,32 +304,29 @@ class nsComputedDOMStyle final : public 
   already_AddRefed<CSSValue> DoGetInitialLetter();
   already_AddRefed<CSSValue> DoGetLineHeight();
   already_AddRefed<CSSValue> DoGetTextDecoration();
   already_AddRefed<CSSValue> DoGetTextDecorationColor();
   already_AddRefed<CSSValue> DoGetTextDecorationStyle();
   already_AddRefed<CSSValue> DoGetTextEmphasisPosition();
   already_AddRefed<CSSValue> DoGetTextEmphasisStyle();
   already_AddRefed<CSSValue> DoGetTextOverflow();
-  already_AddRefed<CSSValue> DoGetTextShadow();
   already_AddRefed<CSSValue> DoGetWebkitTextStrokeWidth();
 
   /* Display properties */
   already_AddRefed<CSSValue> DoGetBinding();
   already_AddRefed<CSSValue> DoGetDisplay();
   already_AddRefed<CSSValue> DoGetWillChange();
   already_AddRefed<CSSValue> DoGetTransform();
   already_AddRefed<CSSValue> DoGetTransformOrigin();
   already_AddRefed<CSSValue> DoGetPerspectiveOrigin();
   already_AddRefed<CSSValue> DoGetScrollSnapPointsX();
   already_AddRefed<CSSValue> DoGetScrollSnapPointsY();
-  already_AddRefed<CSSValue> DoGetScrollbarColor();
 
   /* User interface properties */
-  already_AddRefed<CSSValue> DoGetCaretColor();
   already_AddRefed<CSSValue> DoGetForceBrokenImageIcon();
 
   /* Column properties */
   already_AddRefed<CSSValue> DoGetColumnCount();
   already_AddRefed<CSSValue> DoGetColumnRuleWidth();
 
   /* CSS Transitions */
   already_AddRefed<CSSValue> DoGetTransitionProperty();
--- a/servo/components/style/values/generics/color.rs
+++ b/servo/components/style/values/generics/color.rs
@@ -94,17 +94,16 @@ impl<RGBA> From<RGBA> for Color<RGBA> {
     MallocSizeOf,
     PartialEq,
     Parse,
     SpecifiedValueInfo,
     ToAnimatedValue,
     ToAnimatedZero,
     ToComputedValue,
     ToCss,
-    ToResolvedValue,
     ToShmem,
 )]
 #[repr(C, u8)]
 pub enum GenericColorOrAuto<C> {
     /// A `<color>`.
     Color(C),
     /// `auto`
     Auto,
new file mode 100644
--- /dev/null
+++ b/servo/components/style/values/resolved/color.rs
@@ -0,0 +1,45 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+
+//! Resolved color values.
+
+use super::{Context, ToResolvedValue};
+
+use crate::values::computed;
+use crate::values::generics::color as generics;
+
+impl ToResolvedValue for computed::Color {
+    // A resolved color value is an rgba color, with currentcolor resolved.
+    type ResolvedValue = cssparser::RGBA;
+
+    #[inline]
+    fn to_resolved_value(self, context: &Context) -> Self::ResolvedValue {
+        context.style.resolve_color(self)
+    }
+
+    #[inline]
+    fn from_resolved_value(resolved: Self::ResolvedValue) -> Self {
+        generics::Color::Numeric(resolved)
+    }
+}
+
+impl ToResolvedValue for computed::ColorOrAuto {
+    // A resolved caret-color value is an rgba color, with auto resolving to
+    // currentcolor.
+    type ResolvedValue = cssparser::RGBA;
+
+    #[inline]
+    fn to_resolved_value(self, context: &Context) -> Self::ResolvedValue {
+        let color = match self {
+            generics::ColorOrAuto::Color(color) => color,
+            generics::ColorOrAuto::Auto => generics::Color::CurrentColor,
+        };
+        color.to_resolved_value(context)
+    }
+
+    #[inline]
+    fn from_resolved_value(resolved: Self::ResolvedValue) -> Self {
+        generics::ColorOrAuto::Color(computed::Color::from_resolved_value(resolved))
+    }
+}
--- a/servo/components/style/values/resolved/mod.rs
+++ b/servo/components/style/values/resolved/mod.rs
@@ -3,16 +3,19 @@
  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
 
 //! Resolved values. These are almost always computed values, but in some cases
 //! there are used values.
 
 use cssparser;
 use smallvec::SmallVec;
 use crate::properties::ComputedValues;
+
+mod color;
+
 use crate::values::computed;
 
 /// Information needed to resolve a given value.
 pub struct Context<'a> {
     /// The style we're resolving for. This is useful to resolve currentColor.
     pub style: &'a ComputedValues,
     // TODO(emilio): Add layout box information, and maybe property-specific
     // information?
@@ -182,27 +185,8 @@ where
         Vec::from(self).to_resolved_value(context).into_boxed_slice()
     }
 
     #[inline]
     fn from_resolved_value(resolved: Self::ResolvedValue) -> Self {
         Vec::from_resolved_value(Vec::from(resolved)).into_boxed_slice()
     }
 }
-
-
-/// A resolved color value is an rgba color, with currentcolor resolved.
-pub type Color = cssparser::RGBA;
-
-impl ToResolvedValue for computed::Color {
-    type ResolvedValue = Color;
-
-    #[inline]
-    fn to_resolved_value(self, context: &Context) -> Self::ResolvedValue {
-        context.style.resolve_color(self)
-    }
-
-    #[inline]
-    fn from_resolved_value(resolved: Self::ResolvedValue) -> Self {
-        use crate::values::generics::color::Color as GenericColor;
-        GenericColor::Numeric(resolved)
-    }
-}