Bug 1278463: Better-distinguish between "stroke-dasharray" keyword values vs. list values, in StyleAnimationValue.cpp. r=birtles
authorDaniel Holbert <dholbert@cs.stanford.edu>
Tue, 28 Jun 2016 12:41:33 -0700
changeset 382187 4f40699e76a94c93a3fe0e69ed5b9d6274a06efc
parent 382186 9992f61e73146513ff255d7bfc7b2aecc5ac25e1
child 382188 0f7edd43d27ecc27622c08c03d1229cdef729339
push id21645
push userbmo:gasolin@mozilla.com
push dateWed, 29 Jun 2016 04:02:20 +0000
reviewersbirtles
bugs1278463
milestone50.0a1
Bug 1278463: Better-distinguish between "stroke-dasharray" keyword values vs. list values, in StyleAnimationValue.cpp. r=birtles MozReview-Commit-ID: 9U4v322RIw7
layout/style/StyleAnimationValue.cpp
layout/style/crashtests/1278463-1.html
layout/style/crashtests/crashtests.list
--- a/layout/style/StyleAnimationValue.cpp
+++ b/layout/style/StyleAnimationValue.cpp
@@ -2503,25 +2503,16 @@ StyleAnimationValue::AddWeighted(nsCSSPr
       uint32_t len1 = 0, len2 = 0;
       for (const nsCSSValueList *v = list1; v; v = v->mNext) {
         ++len1;
       }
       for (const nsCSSValueList *v = list2; v; v = v->mNext) {
         ++len2;
       }
       MOZ_ASSERT(len1 > 0 && len2 > 0, "unexpected length");
-      if (list1->mValue.GetUnit() == eCSSUnit_None ||
-          list2->mValue.GetUnit() == eCSSUnit_None) {
-        // One of our values is "none".  Can't do addition with that.
-        MOZ_ASSERT(
-          (list1->mValue.GetUnit() != eCSSUnit_None || len1 == 1) &&
-          (list2->mValue.GetUnit() != eCSSUnit_None || len2 == 1),
-          "multi-value valuelist with 'none' as first element");
-        return false;
-      }
 
       nsAutoPtr<nsCSSValueList> result;
       nsCSSValueList **resultTail = getter_Transfers(result);
       for (uint32_t i = 0, i_end = EuclidLCM<uint32_t>(len1, len2); i != i_end; ++i) {
         const nsCSSValue &v1 = list1->mValue;
         const nsCSSValue &v2 = list2->mValue;
         MOZ_ASSERT(v1.GetUnit() == eCSSUnit_Number ||
                    v1.GetUnit() == eCSSUnit_Percent, "unexpected");
@@ -3769,18 +3760,18 @@ StyleAnimationValue::ExtractComputedValu
           }
           aComputedValue.SetAndAdoptCSSValuePairValue(pair.forget(),
                                                       eUnit_CSSValuePair);
           break;
         }
 
         case eCSSProperty_stroke_dasharray: {
           const nsStyleSVG *svg = static_cast<const nsStyleSVG*>(styleStruct);
-          nsAutoPtr<nsCSSValueList> result;
           if (!svg->mStrokeDasharray.IsEmpty()) {
+            nsAutoPtr<nsCSSValueList> result;
             nsCSSValueList **resultTail = getter_Transfers(result);
             for (uint32_t i = 0, i_end = svg->mStrokeDasharray.Length();
                  i != i_end; ++i) {
               nsCSSValueList *item = new nsCSSValueList;
               *resultTail = item;
               resultTail = &item->mNext;
 
               const nsStyleCoord &coord = svg->mStrokeDasharray[i];
@@ -3801,22 +3792,27 @@ StyleAnimationValue::ExtractComputedValu
                 case eStyleUnit_Percent:
                   value.SetPercentValue(coord.GetPercentValue());
                   break;
                 default:
                   MOZ_ASSERT(false, "unexpected unit");
                   return false;
               }
             }
+            aComputedValue.SetAndAdoptCSSValueListValue(result.forget(),
+                                                        eUnit_Dasharray);
+          } else if (svg->StrokeDasharrayFromObject()) {
+            // An empty dasharray with StrokeDasharrayFromObject() == true
+            // corresponds to the "context-value" keyword.
+            aComputedValue.SetIntValue(NS_STYLE_STROKE_PROP_CONTEXT_VALUE,
+                                       eUnit_Enumerated);
           } else {
-            result = new nsCSSValueList;
-            result->mValue.SetNoneValue();
+            // Otherwise, an empty dasharray corresponds to the "none" keyword.
+            aComputedValue.SetNoneValue();
           }
-          aComputedValue.SetAndAdoptCSSValueListValue(result.forget(),
-                                                      eUnit_Dasharray);
           break;
         }
 
         case eCSSProperty_font_stretch: {
           int16_t stretch =
             static_cast<const nsStyleFont*>(styleStruct)->mFont.stretch;
           static_assert(NS_STYLE_FONT_STRETCH_ULTRA_CONDENSED == -4 &&
                         NS_STYLE_FONT_STRETCH_ULTRA_EXPANDED == 4,
new file mode 100644
--- /dev/null
+++ b/layout/style/crashtests/1278463-1.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+
+ @keyframes c {
+     50% {
+         stroke-dasharray: context-value;
+     }
+ }
+
+ div {
+     animation-name: c;
+ }
+
+</style>
+</head>
+<body>
+<div></div>
+</body>
+</html>
--- a/layout/style/crashtests/crashtests.list
+++ b/layout/style/crashtests/crashtests.list
@@ -143,9 +143,10 @@ load 1264396-1.html
 # layout.css.prefixes.webkit pref
 pref(layout.css.prefixes.webkit,false) load 1265611-1.html
 load border-image-visited-link.html
 load font-face-truncated-src.html 
 load large_border_image_width.html
 load long-url-list-stack-overflow.html
 pref(layout.css.background-clip-text.enabled,true) load 1264949.html
 pref(layout.css.background-clip-text.enabled,true) load 1270795.html
-pref(layout.css.background-clip-text.enabled,true) load 1275026.html
\ No newline at end of file
+pref(layout.css.background-clip-text.enabled,true) load 1275026.html
+load 1278463-1.html