Bug 1348173 - stylo: combined gecko side patch for -moz-border-*-colors support. draft
authorJeremy Chen <jeremychen@mozilla.com>
Tue, 25 Apr 2017 14:50:44 +0800
changeset 567523 c81a77983d54f50ba92c121183e4a3a836b29800
parent 567507 85932a5027c024900bb0e58cdbc52ecf9a32e1f5
child 567524 dbf3106d13260901f201d7f078e02b98fb8baebc
push id55606
push userjichen@mozilla.com
push dateTue, 25 Apr 2017 06:51:13 +0000
bugs1348173
milestone55.0a1
Bug 1348173 - stylo: combined gecko side patch for -moz-border-*-colors support. MozReview-Commit-ID: 53gWkWKJNmV
layout/reftests/forms/progress/reftest-stylo.list
layout/style/ServoBindings.cpp
layout/style/ServoBindings.h
layout/style/nsStyleStruct.cpp
layout/style/nsStyleStruct.h
layout/style/test/stylo-failures.md
widget/reftests/reftest-stylo.list
--- a/layout/reftests/forms/progress/reftest-stylo.list
+++ b/layout/reftests/forms/progress/reftest-stylo.list
@@ -1,34 +1,34 @@
 # DO NOT EDIT! This is a auto-generated temporary list for Stylo testing
-fails == values.html values.html
-fails == values-rtl.html values-rtl.html
-fails == margin-padding.html margin-padding.html
-fails == margin-padding-rtl.html margin-padding-rtl.html
+== values.html values.html
+== values-rtl.html values-rtl.html
+== margin-padding.html margin-padding.html
+== margin-padding-rtl.html margin-padding-rtl.html
 fails == bar-pseudo-element.html bar-pseudo-element.html
-fails == bar-pseudo-element-rtl.html bar-pseudo-element-rtl.html
-fails == indeterminate-style-width.html indeterminate-style-width.html
+== bar-pseudo-element-rtl.html bar-pseudo-element-rtl.html
+== indeterminate-style-width.html indeterminate-style-width.html
 
 # vertical tests
-fails == values-vertical.html values-vertical.html
-fails == values-vertical-rtl.html values-vertical-rtl.html
-fails == margin-padding-vertical.html margin-padding-vertical.html
-fails == margin-padding-vertical-rtl.html margin-padding-vertical-rtl.html
-fails == bar-pseudo-element-vertical.html bar-pseudo-element-vertical.html
-fails == bar-pseudo-element-vertical-rtl.html bar-pseudo-element-vertical-rtl.html
-fails == indeterminate-style-height.html indeterminate-style-height.html
+== values-vertical.html values-vertical.html
+== values-vertical-rtl.html values-vertical-rtl.html
+== margin-padding-vertical.html margin-padding-vertical.html
+== margin-padding-vertical-rtl.html margin-padding-vertical-rtl.html
+== bar-pseudo-element-vertical.html bar-pseudo-element-vertical.html
+== bar-pseudo-element-vertical-rtl.html bar-pseudo-element-vertical-rtl.html
+== indeterminate-style-height.html indeterminate-style-height.html
 
 # The following test is disabled but kept in the repository because the
 # transformations will not behave exactly the same for <progress> and two divs.
 # However, it would be possible to manually check those.
-fails == transformations.html transformations.html
+== transformations.html transformations.html
 
 # Tests for bugs:
-fails == block-invalidate.html block-invalidate.html
-fails == in-cells.html in-cells.html
+== block-invalidate.html block-invalidate.html
+== in-cells.html in-cells.html
 == max-height.html max-height.html
 
 # Tests for block and inline orientation in combination with writing-mode
 fails == progress-orient-horizontal.html progress-orient-horizontal.html
 fails-if(!cocoaWidget||OSX==1010) == progress-orient-vertical.html progress-orient-vertical.html
 fails == progress-orient-block.html progress-orient-block.html
 fails == progress-orient-inline.html progress-orient-inline.html
 fails == progress-vlr.html progress-vlr.html
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -954,16 +954,43 @@ Gecko_AtomEqualsUTF8IgnoreCase(nsIAtom* 
   // XXXbholley: We should be able to do this without converting, I just can't
   // find the right thing to call.
   nsDependentAtomString atomStr(aAtom);
   NS_ConvertUTF8toUTF16 inStr(nsDependentCSubstring(aString, aLength));
   return nsContentUtils::EqualsIgnoreASCIICase(atomStr, inStr);
 }
 
 void
+Gecko_EnsureMozBorderColors(nsStyleBorder* aBorder)
+{
+  aBorder->EnsureBorderColors();
+}
+
+void Gecko_ClearMozBorderColors(nsStyleBorder* aBorder, mozilla::Side aSide)
+{
+  aBorder->ClearBorderColors(aSide);
+}
+
+void
+Gecko_AppendMozBorderColors(nsStyleBorder* aBorder, mozilla::Side aSide,
+                            nscolor aColor)
+{
+  aBorder->AppendBorderColor(aSide, aColor);
+}
+
+void
+Gecko_CopyMozBorderColors(nsStyleBorder* aDest, const nsStyleBorder* aSrc,
+                          mozilla::Side aSide)
+{
+  if (aSrc->mBorderColors) {
+    aDest->CopyBorderColorsFrom(aSrc->mBorderColors[aSide], aSide);
+  }
+}
+
+void
 Gecko_FontFamilyList_Clear(FontFamilyList* aList) {
   aList->Clear();
 }
 
 void
 Gecko_FontFamilyList_AppendNamed(FontFamilyList* aList, nsIAtom* aName, bool aQuoted)
 {
   FontFamilyName family;
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -31,16 +31,17 @@ class nsIAtom;
 class nsIPrincipal;
 class nsIURI;
 struct nsFont;
 namespace mozilla {
   class ServoStyleSheet;
   class FontFamilyList;
   enum FontFamilyType : uint32_t;
   struct Keyframe;
+  enum Side;
   namespace css {
     struct URLValue;
   };
   enum class UpdateAnimationsTasks : uint8_t;
   struct LangGroupFontPrefs;
 }
 using mozilla::FontFamilyList;
 using mozilla::FontFamilyType;
@@ -234,16 +235,24 @@ RawServoAnimationValueBorrowedOrNull Gec
 nsIAtom* Gecko_Atomize(const char* aString, uint32_t aLength);
 nsIAtom* Gecko_Atomize16(const nsAString* aString);
 void Gecko_AddRefAtom(nsIAtom* aAtom);
 void Gecko_ReleaseAtom(nsIAtom* aAtom);
 const uint16_t* Gecko_GetAtomAsUTF16(nsIAtom* aAtom, uint32_t* aLength);
 bool Gecko_AtomEqualsUTF8(nsIAtom* aAtom, const char* aString, uint32_t aLength);
 bool Gecko_AtomEqualsUTF8IgnoreCase(nsIAtom* aAtom, const char* aString, uint32_t aLength);
 
+// Border style
+void Gecko_EnsureMozBorderColors(nsStyleBorder* aBorder);
+void Gecko_ClearMozBorderColors(nsStyleBorder* aBorder, mozilla::Side aSide);
+void Gecko_AppendMozBorderColors(nsStyleBorder* aBorder, mozilla::Side aSide,
+                                 nscolor aColor);
+void Gecko_CopyMozBorderColors(nsStyleBorder* aDest, const nsStyleBorder* aSrc,
+                               mozilla::Side aSide);
+
 // Font style
 void Gecko_FontFamilyList_Clear(FontFamilyList* aList);
 void Gecko_FontFamilyList_AppendNamed(FontFamilyList* aList, nsIAtom* aName, bool aQuoted);
 void Gecko_FontFamilyList_AppendGeneric(FontFamilyList* list, FontFamilyType familyType);
 void Gecko_CopyFontFamilyFrom(nsFont* dst, const nsFont* src);
 // will not run destructors on dst, give it uninitialized memory
 // font_id is LookAndFeel::FontID
 void Gecko_nsFont_InitSystem(nsFont* dst, int32_t font_id,
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -361,23 +361,18 @@ nsStyleBorder::nsStyleBorder(const nsSty
   , mFloatEdge(aSrc.mFloatEdge)
   , mBoxDecorationBreak(aSrc.mBoxDecorationBreak)
   , mComputedBorder(aSrc.mComputedBorder)
   , mBorder(aSrc.mBorder)
   , mTwipsPerPixel(aSrc.mTwipsPerPixel)
 {
   MOZ_COUNT_CTOR(nsStyleBorder);
   if (aSrc.mBorderColors) {
-    EnsureBorderColors();
-    for (int32_t i = 0; i < 4; i++) {
-      if (aSrc.mBorderColors[i]) {
-        mBorderColors[i] = aSrc.mBorderColors[i]->Clone();
-      } else {
-        mBorderColors[i] = nullptr;
-      }
+    NS_FOR_CSS_SIDES(side) {
+      CopyBorderColorsFrom(aSrc.mBorderColors[side], side);
     }
   }
 
   NS_FOR_CSS_SIDES(side) {
     mBorderStyle[side] = aSrc.mBorderStyle[side];
     mBorderColor[side] = aSrc.mBorderColor[side];
   }
 }
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -1157,16 +1157,24 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
 
   void ClearBorderColors(mozilla::Side aSide) {
     if (mBorderColors && mBorderColors[aSide]) {
       delete mBorderColors[aSide];
       mBorderColors[aSide] = nullptr;
     }
   }
 
+  void CopyBorderColorsFrom(const nsBorderColors* aSrcBorderColors, mozilla::Side aSide) {
+    if (aSrcBorderColors) {
+      EnsureBorderColors();
+      ClearBorderColors(aSide);
+      mBorderColors[aSide] = aSrcBorderColors->Clone();
+    }
+  }
+
   // Return whether aStyle is a visible style.  Invisible styles cause
   // the relevant computed border width to be 0.
   // Note that this does *not* consider the effects of 'border-image':
   // if border-style is none, but there is a loaded border image,
   // HasVisibleStyle will be false even though there *is* a border.
   bool HasVisibleStyle(mozilla::Side aSide) const
   {
     return IsVisibleBorderStyle(mBorderStyle[aSide]);
--- a/layout/style/test/stylo-failures.md
+++ b/layout/style/test/stylo-failures.md
@@ -129,24 +129,16 @@ to mochitest command.
   * test_initial_storage.html `grid` [*]
   * test_property_syntax_errors.html `grid`: actually there are issues with this [*]
   * test_value_storage.html `'grid` [*]
 * url value from decl setter bug 1330503
   * test_compute_data_with_start_struct.html `border-image-source` [2]
   * test_inherit_computation.html `border-image` [2]
   * test_initial_computation.html `border-image` [4]
 * Unimplemented prefixed properties:
-  * -moz-border-*-colors bug 1348173
-    * test_compute_data_with_start_struct.html `-colors` [8]
-    * test_inherit_computation.html `-colors` [8]
-    * test_inherit_storage.html `-colors` [12]
-    * test_initial_computation.html `-colors` [16]
-    * test_initial_storage.html `-colors` [24]
-    * test_value_storage.html `-colors` [96]
-    * test_shorthand_property_getters.html `-colors` [1]
   * -moz-force-broken-image-icon servo/servo#16001
     * test_compute_data_with_start_struct.html `-moz-force-broken-image-icon` [2]
     * test_inherit_computation.html `-moz-force-broken-image-icon` [2]
     * test_inherit_storage.html `-moz-force-broken-image-icon` [2]
     * test_initial_computation.html `-moz-force-broken-image-icon` [4]
     * test_initial_storage.html `-moz-force-broken-image-icon` [4]
     * test_value_storage.html `-moz-force-broken-image-icon` [4]
   * -moz-transform: need different parsing rules servo/servo#16003
--- a/widget/reftests/reftest-stylo.list
+++ b/widget/reftests/reftest-stylo.list
@@ -1,7 +1,7 @@
 # DO NOT EDIT! This is a auto-generated temporary list for Stylo testing
 skip-if(!cocoaWidget) == 507947.html 507947.html
-fails == progressbar-fallback-default-style.html progressbar-fallback-default-style.html
+== progressbar-fallback-default-style.html progressbar-fallback-default-style.html
 == meter-native-style.html meter-native-style.html
 fails == meter-vertical-native-style.html meter-vertical-native-style.html
 fails == meter-fallback-default-style.html meter-fallback-default-style.html
 load 664925.xhtml