Commit 17746a83 authored by thakis@chromium.org's avatar thakis@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.

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:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@157598 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a8572f7b
2013-10-17 Nico Weber <thakis@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_fong@apple.com>
Unreviewed gardening of Apple Windows port.
......
......@@ -66,6 +66,10 @@ PASS Two CSSValues "italic bold 12px/30px arial" and "italic bold 8px/16px helve
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.
......
......@@ -50,6 +50,8 @@ function run() {
{"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
......
2013-10-17 Nico Weber <thakis@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 <graouts@apple.com>
Web Inspector: allow front-end to trigger the system beep sound to signal an error
......
......@@ -726,17 +726,17 @@ bool CSSLinearGradientValue::equals(const CSSLinearGradientValue& other) const
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 @@ bool CSSRadialGradientValue::equals(const CSSRadialGradientValue& other) const
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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment