Changeset 157598 in webkit


Ignore:
Timestamp:
Oct 17, 2013 2:14:46 PM (11 years ago)
Author:
thakis@chromium.org
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:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r157585 r157598  
     12013-10-17  Nico Weber  <thakis@chromium.org>
     2
     3        Fix three bugs in the equals() implementations for css gradients.
     4        https://bugs.webkit.org/show_bug.cgi?id=122987
     5
     6        Reviewed by Andreas Kling.
     7
     8        1. Linear gradients were considered equal if the first gradient has no x and y
     9           position and the second has no x but does have y.
     10        2. Same as 1, for radial gradients. (This doesn't happen in practice as
     11           CSSParser::parseRadialGradient rejects such input, so no test for this case.)
     12        3. Radial gradients without x and y position weren't considered equal even if
     13           they were.
     14
     15        Merges https://codereview.chromium.org/26147006/
     16
     17        * cssom/cssvalue-comparison-expected.txt:
     18        * cssom/cssvalue-comparison.html:
     19
    1202013-10-17  Roger Fong  <roger_fong@apple.com>
    221
  • trunk/LayoutTests/cssom/cssvalue-comparison-expected.txt

    r142444 r157598  
    6767PASS 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.
    6868PASS 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.
     69PASS Two CSSValues "radial-gradient(circle, #ccc, #000)" for property "background" are equal.
     70PASS Two CSSValues "linear-gradient(#000, #234)" for property "background" are equal.
     71PASS Two CSSValues "linear-gradient(to top, #000, #234)" for property "background" are equal.
     72PASS Two CSSValues "linear-gradient(#000, #234)" and "linear-gradient(to top, #000, #234)" for property "background" are not equal.
    6973PASS Two CSSValues "-webkit-cross-fade(url(dummy://example.png), url(dummy://example.png), 50%)" for property "background-image" are equal.
    7074PASS Two CSSValues "-webkit-cross-fade(url(dummy://background.png), url(dummy://foreground.png), 80%)" for property "background-image" are equal.
  • trunk/LayoutTests/cssom/cssvalue-comparison.html

    r142444 r157598  
    5151                  {"font" : ["italic bold 12px/30px arial", "italic bold 8px/16px helvetica"]}, // font
    5252                  {"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
     53                  {"background" : ["radial-gradient(circle, #ccc, #000)"]}, // gradients
     54                  {"background" : ["linear-gradient(#000, #234)", "linear-gradient(to top, #000, #234)"]}, // gradients
    5355                  {"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
    5456                  {"-webkit-box-reflect" : ["below 10px", "below 0px -webkit-gradient(linear, left top, left bottom, from(transparent), to(rgba(10, 55, 234, 1)))"]}, // reflect
  • trunk/Source/WebCore/ChangeLog

    r157597 r157598  
     12013-10-17  Nico Weber  <thakis@chromium.org>
     2
     3        Fix three bugs in the equals() implementations for css gradients.
     4        https://bugs.webkit.org/show_bug.cgi?id=122987
     5
     6        Reviewed by Andreas Kling.
     7
     8        1. Linear gradients were considered equal if the first gradient has no x and y
     9           position and the second has no x but does have y.
     10        2. Same as 1, for radial gradients. (This doesn't happen in practice as
     11           CSSParser::parseRadialGradient rejects such input, so no test for this case.)
     12        3. Radial gradients without x and y position weren't considered equal even if
     13           they were.
     14
     15        * css/CSSGradientValue.cpp:
     16        (WebCore::CSSLinearGradientValue::equals):
     17        (WebCore::CSSRadialGradientValue::equals):
     18
    1192013-10-17  Antoine Quint  <graouts@apple.com>
    220
  • trunk/Source/WebCore/css/CSSGradientValue.cpp

    r156964 r157598  
    727727        return false;
    728728
    729     bool equalXorY = false;
     729    bool equalXandY = false;
    730730    if (m_firstX && m_firstY)
    731         equalXorY = compareCSSValuePtr(m_firstX, other.m_firstX) && compareCSSValuePtr(m_firstY, other.m_firstY);
     731        equalXandY = compareCSSValuePtr(m_firstX, other.m_firstX) && compareCSSValuePtr(m_firstY, other.m_firstY);
    732732    else if (m_firstX)
    733         equalXorY =compareCSSValuePtr(m_firstX, other.m_firstX) && !other.m_firstY;
     733        equalXandY = compareCSSValuePtr(m_firstX, other.m_firstX) && !other.m_firstY;
    734734    else if (m_firstY)
    735         equalXorY = compareCSSValuePtr(m_firstY, other.m_firstY) && !other.m_firstX;
     735        equalXandY = compareCSSValuePtr(m_firstY, other.m_firstY) && !other.m_firstX;
    736736    else
    737         equalXorY = !other.m_firstX || !other.m_firstY;
    738 
    739     return equalXorY && m_stops == other.m_stops;
     737        equalXandY = !other.m_firstX && !other.m_firstY;
     738
     739    return equalXandY && m_stops == other.m_stops;
    740740}
    741741
     
    11391139        return false;
    11401140
    1141     bool equalXorY = false;
     1141    bool equalXandY = false;
    11421142    if (m_firstX && m_firstY)
    1143         equalXorY = compareCSSValuePtr(m_firstX, other.m_firstX) && compareCSSValuePtr(m_firstY, other.m_firstY);
     1143        equalXandY = compareCSSValuePtr(m_firstX, other.m_firstX) && compareCSSValuePtr(m_firstY, other.m_firstY);
    11441144    else if (m_firstX)
    1145         equalXorY = compareCSSValuePtr(m_firstX, other.m_firstX) && !other.m_firstY;
     1145        equalXandY = compareCSSValuePtr(m_firstX, other.m_firstX) && !other.m_firstY;
    11461146    else if (m_firstY)
    1147         equalXorY = compareCSSValuePtr(m_firstY, other.m_firstY) && !other.m_firstX;
     1147        equalXandY = compareCSSValuePtr(m_firstY, other.m_firstY) && !other.m_firstX;
    11481148    else
    1149         equalXorY == !other.m_firstX || !other.m_firstY;
    1150 
    1151     if (!equalXorY)
     1149        equalXandY = !other.m_firstX && !other.m_firstY;
     1150
     1151    if (!equalXandY)
    11521152        return false;
    11531153
Note: See TracChangeset for help on using the changeset viewer.