Title: [157598] trunk
Revision
157598
Author
tha...@chromium.org
Date
2013-10-17 14:14:46 -0700 (Thu, 17 Oct 2013)

Log Message

Fix three bugs in the equals() implementations for css gradients.
https://bugs.webkit.org/show_bug.cgi?id=122987

Reviewed by Andreas Kling.

1. Linear gradients were considered equal if the first gradient has no x and y
   position and the second has no x but does have y.
2. Same as 1, for radial gradients. (This doesn't happen in practice as
   CSSParser::parseRadialGradient rejects such input, so no test for this case.)
3. Radial gradients without x and y position weren't considered equal even if
   they were.

Source/WebCore:

* css/CSSGradientValue.cpp:
(WebCore::CSSLinearGradientValue::equals):
(WebCore::CSSRadialGradientValue::equals):

LayoutTests:

Merges https://codereview.chromium.org/26147006/

* cssom/cssvalue-comparison-expected.txt:
* cssom/cssvalue-comparison.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (157597 => 157598)


--- trunk/LayoutTests/ChangeLog	2013-10-17 21:07:59 UTC (rev 157597)
+++ trunk/LayoutTests/ChangeLog	2013-10-17 21:14:46 UTC (rev 157598)
@@ -1,3 +1,22 @@
+2013-10-17  Nico Weber  <tha...@chromium.org>
+
+        Fix three bugs in the equals() implementations for css gradients.
+        https://bugs.webkit.org/show_bug.cgi?id=122987
+
+        Reviewed by Andreas Kling.
+
+        1. Linear gradients were considered equal if the first gradient has no x and y
+           position and the second has no x but does have y.
+        2. Same as 1, for radial gradients. (This doesn't happen in practice as
+           CSSParser::parseRadialGradient rejects such input, so no test for this case.)
+        3. Radial gradients without x and y position weren't considered equal even if
+           they were.
+
+        Merges https://codereview.chromium.org/26147006/
+
+        * cssom/cssvalue-comparison-expected.txt:
+        * cssom/cssvalue-comparison.html:
+
 2013-10-17  Roger Fong  <roger_f...@apple.com>
 
         Unreviewed gardening of Apple Windows port.

Modified: trunk/LayoutTests/cssom/cssvalue-comparison-expected.txt (157597 => 157598)


--- trunk/LayoutTests/cssom/cssvalue-comparison-expected.txt	2013-10-17 21:07:59 UTC (rev 157597)
+++ trunk/LayoutTests/cssom/cssvalue-comparison-expected.txt	2013-10-17 21:14:46 UTC (rev 157598)
@@ -66,6 +66,10 @@
 PASS Two CSSValues "-webkit-gradient(linear, left top, left bottom, from(#ccc), to(#000))" for property "background" are equal. 
 PASS Two CSSValues "-webkit-gradient(radial, 45 45, 0, 52 50, 0, from(#A7D30C), to(rgba(1,159,98,0)), color-stop(90%, #019F62))" for property "background" are equal. 
 PASS Two CSSValues "-webkit-gradient(linear, left top, left bottom, from(#ccc), to(#000))" and "-webkit-gradient(radial, 45 45, 0, 52 50, 0, from(#A7D30C), to(rgba(1,159,98,0)), color-stop(90%, #019F62))" for property "background" are not equal. 
+PASS Two CSSValues "radial-gradient(circle, #ccc, #000)" for property "background" are equal. 
+PASS Two CSSValues "linear-gradient(#000, #234)" for property "background" are equal. 
+PASS Two CSSValues "linear-gradient(to top, #000, #234)" for property "background" are equal. 
+PASS Two CSSValues "linear-gradient(#000, #234)" and "linear-gradient(to top, #000, #234)" for property "background" are not equal. 
 PASS Two CSSValues "-webkit-cross-fade(url(dummy://example.png), url(dummy://example.png), 50%)" for property "background-image" are equal. 
 PASS Two CSSValues "-webkit-cross-fade(url(dummy://background.png), url(dummy://foreground.png), 80%)" for property "background-image" are equal. 
 PASS Two CSSValues "-webkit-cross-fade(url(dummy://example.png), url(dummy://example.png), 50%)" and "-webkit-cross-fade(url(dummy://background.png), url(dummy://foreground.png), 80%)" for property "background-image" are not equal. 

Modified: trunk/LayoutTests/cssom/cssvalue-comparison.html (157597 => 157598)


--- trunk/LayoutTests/cssom/cssvalue-comparison.html	2013-10-17 21:07:59 UTC (rev 157597)
+++ trunk/LayoutTests/cssom/cssvalue-comparison.html	2013-10-17 21:14:46 UTC (rev 157598)
@@ -50,6 +50,8 @@
                   {"cursor" : ["url(resources/greenbox.png) 0 0, pointer", "url(resources/cursor.png) 1 1, wait"]}, // cursor
                   {"font" : ["italic bold 12px/30px arial", "italic bold 8px/16px helvetica"]}, // font
                   {"background" : ["-webkit-gradient(linear, left top, left bottom, from(#ccc), to(#000))", "-webkit-gradient(radial, 45 45, 0, 52 50, 0, from(#A7D30C), to(rgba(1,159,98,0)), color-stop(90%, #019F62))"]}, // gradients
+                  {"background" : ["radial-gradient(circle, #ccc, #000)"]}, // gradients
+                  {"background" : ["linear-gradient(#000, #234)", "linear-gradient(to top, #000, #234)"]}, // gradients
                   {"background-image" : ["-webkit-cross-fade(url(dummy://example.png), url(dummy://example.png), 50%)", "-webkit-cross-fade(url(dummy://background.png), url(dummy://foreground.png), 80%)"]}, // crossfade
                   {"-webkit-box-reflect" : ["below 10px", "below 0px -webkit-gradient(linear, left top, left bottom, from(transparent), to(rgba(10, 55, 234, 1)))"]}, // reflect
                   {"-webkit-box-shadow" : ["0 -20px 10px red, 0 20px 10px blue", "0 20px 10px blue", "5px 5px 5px rgba(0, 0, 0, 0.3)"]}, // shadow

Modified: trunk/Source/WebCore/ChangeLog (157597 => 157598)


--- trunk/Source/WebCore/ChangeLog	2013-10-17 21:07:59 UTC (rev 157597)
+++ trunk/Source/WebCore/ChangeLog	2013-10-17 21:14:46 UTC (rev 157598)
@@ -1,3 +1,21 @@
+2013-10-17  Nico Weber  <tha...@chromium.org>
+
+        Fix three bugs in the equals() implementations for css gradients.
+        https://bugs.webkit.org/show_bug.cgi?id=122987
+
+        Reviewed by Andreas Kling.
+
+        1. Linear gradients were considered equal if the first gradient has no x and y
+           position and the second has no x but does have y.
+        2. Same as 1, for radial gradients. (This doesn't happen in practice as
+           CSSParser::parseRadialGradient rejects such input, so no test for this case.)
+        3. Radial gradients without x and y position weren't considered equal even if
+           they were.
+
+        * css/CSSGradientValue.cpp:
+        (WebCore::CSSLinearGradientValue::equals):
+        (WebCore::CSSRadialGradientValue::equals):
+
 2013-10-17  Antoine Quint  <grao...@apple.com>
 
         Web Inspector: allow front-end to trigger the system beep sound to signal an error

Modified: trunk/Source/WebCore/css/CSSGradientValue.cpp (157597 => 157598)


--- trunk/Source/WebCore/css/CSSGradientValue.cpp	2013-10-17 21:07:59 UTC (rev 157597)
+++ trunk/Source/WebCore/css/CSSGradientValue.cpp	2013-10-17 21:14:46 UTC (rev 157598)
@@ -726,17 +726,17 @@
     if (other.m_angle)
         return false;
 
-    bool equalXorY = false;
+    bool equalXandY = false;
     if (m_firstX && m_firstY)
-        equalXorY = compareCSSValuePtr(m_firstX, other.m_firstX) && compareCSSValuePtr(m_firstY, other.m_firstY);
+        equalXandY = compareCSSValuePtr(m_firstX, other.m_firstX) && compareCSSValuePtr(m_firstY, other.m_firstY);
     else if (m_firstX)
-        equalXorY =compareCSSValuePtr(m_firstX, other.m_firstX) && !other.m_firstY;
+        equalXandY = compareCSSValuePtr(m_firstX, other.m_firstX) && !other.m_firstY;
     else if (m_firstY)
-        equalXorY = compareCSSValuePtr(m_firstY, other.m_firstY) && !other.m_firstX;
+        equalXandY = compareCSSValuePtr(m_firstY, other.m_firstY) && !other.m_firstX;
     else
-        equalXorY = !other.m_firstX || !other.m_firstY;
+        equalXandY = !other.m_firstX && !other.m_firstY;
 
-    return equalXorY && m_stops == other.m_stops;
+    return equalXandY && m_stops == other.m_stops;
 }
 
 String CSSRadialGradientValue::customCSSText() const
@@ -1138,17 +1138,17 @@
     if (m_repeating != other.m_repeating)
         return false;
 
-    bool equalXorY = false;
+    bool equalXandY = false;
     if (m_firstX && m_firstY)
-        equalXorY = compareCSSValuePtr(m_firstX, other.m_firstX) && compareCSSValuePtr(m_firstY, other.m_firstY);
+        equalXandY = compareCSSValuePtr(m_firstX, other.m_firstX) && compareCSSValuePtr(m_firstY, other.m_firstY);
     else if (m_firstX)
-        equalXorY = compareCSSValuePtr(m_firstX, other.m_firstX) && !other.m_firstY;
+        equalXandY = compareCSSValuePtr(m_firstX, other.m_firstX) && !other.m_firstY;
     else if (m_firstY)
-        equalXorY = compareCSSValuePtr(m_firstY, other.m_firstY) && !other.m_firstX;
+        equalXandY = compareCSSValuePtr(m_firstY, other.m_firstY) && !other.m_firstX;
     else
-        equalXorY == !other.m_firstX || !other.m_firstY;
+        equalXandY = !other.m_firstX && !other.m_firstY;
 
-    if (!equalXorY)
+    if (!equalXandY)
         return false;
 
     bool equalShape = true;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to