Changeset 142444 in webkit


Ignore:
Timestamp:
Feb 11, 2013 3:00:54 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Implement CSSValue::equals(const CSSValue&) to optimise CSSValue comparison
https://bugs.webkit.org/show_bug.cgi?id=102901

Patch by Alexander Shalamov <alexander.shalamov@intel.com> on 2013-02-11
Reviewed by Antti Koivisto.

Source/WebCore:

Added comparison method to CSSValue and its children, so that the
css values could be compared efficiently. Before this patch, CSSValue
objects were compared using strings that were generated by the cssText() method.

Test: cssom/cssvalue-comparison.html

  • css/CSSAspectRatioValue.cpp:

(WebCore::CSSAspectRatioValue::equals):
(WebCore):

  • css/CSSAspectRatioValue.h:

(CSSAspectRatioValue):

  • css/CSSBasicShapes.cpp:

(WebCore::CSSBasicShapeRectangle::equals):
(WebCore):
(WebCore::CSSBasicShapeCircle::equals):
(WebCore::CSSBasicShapeEllipse::equals):
(WebCore::CSSBasicShapePolygon::equals):

  • css/CSSBasicShapes.h:

(CSSBasicShapeRectangle):
(CSSBasicShapeCircle):
(CSSBasicShapeEllipse):
(CSSBasicShapePolygon):

  • css/CSSBorderImageSliceValue.cpp:

(WebCore::CSSBorderImageSliceValue::equals):
(WebCore):

  • css/CSSBorderImageSliceValue.h:

(CSSBorderImageSliceValue):

  • css/CSSCalculationValue.cpp:

(WebCore::CSSCalcValue::equals):
(WebCore):
(WebCore::CSSCalcPrimitiveValue::equals):
(CSSCalcPrimitiveValue):
(WebCore::CSSCalcPrimitiveValue::type):
(WebCore::CSSCalcBinaryOperation::equals):
(CSSCalcBinaryOperation):
(WebCore::CSSCalcBinaryOperation::type):

  • css/CSSCalculationValue.h:

(WebCore::CSSCalcExpressionNode::equals):
(CSSCalcExpressionNode):
(CSSCalcValue):

  • css/CSSCanvasValue.cpp:

(WebCore::CSSCanvasValue::equals):
(WebCore):

  • css/CSSCanvasValue.h:

(CSSCanvasValue):

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
(WebCore::CSSComputedStyleDeclaration::cssPropertyMatches):
(WebCore::CSSComputedStyleDeclaration::getCSSPropertyValuesForSidesShorthand):

  • css/CSSCrossfadeValue.cpp:

(WebCore::CSSCrossfadeValue::equals):
(WebCore):

  • css/CSSCrossfadeValue.h:

(CSSCrossfadeValue):

  • css/CSSCursorImageValue.cpp:

(WebCore::CSSCursorImageValue::equals):
(WebCore):

  • css/CSSCursorImageValue.h:

(CSSCursorImageValue):

  • css/CSSFontFaceSrcValue.cpp:

(WebCore::CSSFontFaceSrcValue::equals):
(WebCore):

  • css/CSSFontFaceSrcValue.h:

(CSSFontFaceSrcValue):

  • css/CSSFunctionValue.cpp:

(WebCore::CSSFunctionValue::equals):
(WebCore):

  • css/CSSFunctionValue.h:

(CSSFunctionValue):

  • css/CSSGradientValue.cpp:

(WebCore::CSSLinearGradientValue::equals):
(WebCore):
(WebCore::CSSRadialGradientValue::equals):

  • css/CSSGradientValue.h:

(WebCore::CSSGradientColorStop::operator==):
(CSSLinearGradientValue):
(CSSRadialGradientValue):

  • css/CSSImageValue.cpp:

(WebCore::CSSImageValue::equals):
(WebCore):

  • css/CSSImageValue.h:

(CSSImageValue):

  • css/CSSInheritedValue.h:

(WebCore::CSSInheritedValue::equals):
(CSSInheritedValue):

  • css/CSSInitialValue.h:

(WebCore::CSSInitialValue::equals):
(CSSInitialValue):

  • css/CSSLineBoxContainValue.h:

(WebCore::CSSLineBoxContainValue::equals):

  • css/CSSPrimitiveValue.cpp:

(WebCore::CSSPrimitiveValue::equals):
(WebCore):

  • css/CSSPrimitiveValue.h:

(CSSPrimitiveValue):

  • css/CSSReflectValue.cpp:

(WebCore::CSSReflectValue::equals):
(WebCore):

  • css/CSSReflectValue.h:

(CSSReflectValue):

  • css/CSSTimingFunctionValue.cpp:

(WebCore::CSSCubicBezierTimingFunctionValue::equals):
(WebCore):
(WebCore::CSSStepsTimingFunctionValue::equals):

  • css/CSSTimingFunctionValue.h:

(WebCore::CSSLinearTimingFunctionValue::equals):
(CSSLinearTimingFunctionValue):
(CSSCubicBezierTimingFunctionValue):
(CSSStepsTimingFunctionValue):

  • css/CSSUnicodeRangeValue.cpp:

(WebCore::CSSUnicodeRangeValue::equals):
(WebCore):

  • css/CSSUnicodeRangeValue.h:

(CSSUnicodeRangeValue):

  • css/CSSValue.cpp:

(WebCore):
(WebCore::compareCSSValues):
(WebCore::CSSValue::equals):

  • css/CSSValue.h:

(CSSValue):
(WebCore):
(WebCore::compareCSSValueVector):
(WebCore::compareCSSValuePtr):

  • css/CSSValueList.cpp:

(WebCore::CSSValueList::removeAll):
(WebCore::CSSValueList::hasValue):
(WebCore::CSSValueList::equals):
(WebCore):

  • css/CSSValueList.h:

(CSSValueList):

  • css/CSSVariableValue.h:

(WebCore::CSSVariableValue::equals):
(CSSVariableValue):

  • css/Counter.h:

(Counter):
(WebCore::Counter::equals):

  • css/DashboardRegion.h:

(WebCore::DashboardRegion::equals):

  • css/FontFeatureValue.cpp:

(WebCore::FontFeatureValue::equals):
(WebCore):

  • css/FontFeatureValue.h:

(FontFeatureValue):

  • css/FontValue.cpp:

(WebCore::FontValue::equals):
(WebCore):

  • css/FontValue.h:

(FontValue):

  • css/MediaQueryExp.h:

(WebCore::MediaQueryExp::operator==):

  • css/Pair.h:

(WebCore::Pair::equals):
(Pair):

  • css/Rect.h:

(WebCore::RectBase::equals):
(RectBase):

  • css/ShadowValue.cpp:

(WebCore::ShadowValue::equals):
(WebCore):

  • css/ShadowValue.h:

(ShadowValue):

  • css/StylePropertySet.cpp:

(WebCore::StylePropertySet::get4Values):
(WebCore::StylePropertySet::propertyMatches):

  • css/WebKitCSSArrayFunctionValue.cpp:

(WebCore::WebKitCSSArrayFunctionValue::equals):
(WebCore):

  • css/WebKitCSSArrayFunctionValue.h:

(WebKitCSSArrayFunctionValue):

  • css/WebKitCSSFilterValue.cpp:

(WebCore::WebKitCSSFilterValue::equals):
(WebCore):

  • css/WebKitCSSFilterValue.h:

(WebKitCSSFilterValue):

  • css/WebKitCSSMixFunctionValue.cpp:

(WebCore::WebKitCSSMixFunctionValue::equals):
(WebCore):

  • css/WebKitCSSMixFunctionValue.h:

(WebKitCSSMixFunctionValue):

  • css/WebKitCSSSVGDocumentValue.cpp:

(WebCore::WebKitCSSSVGDocumentValue::equals):
(WebCore):

  • css/WebKitCSSSVGDocumentValue.h:

(WebKitCSSSVGDocumentValue):

  • css/WebKitCSSShaderValue.cpp:

(WebCore::WebKitCSSShaderValue::equals):
(WebCore):

  • css/WebKitCSSShaderValue.h:

(WebKitCSSShaderValue):

  • css/WebKitCSSTransformValue.h:

(WebCore::WebKitCSSTransformValue::equals):

  • editing/EditingStyle.cpp:

(WebCore::HTMLAttributeEquivalent::valueIsPresentInStyle):

  • svg/SVGColor.cpp:

(WebCore::SVGColor::equals):
(WebCore):

  • svg/SVGColor.h:

(SVGColor):

  • svg/SVGPaint.cpp:

(WebCore::SVGPaint::equals):
(WebCore):

  • svg/SVGPaint.h:

(SVGPaint):

LayoutTests:

New layout test to verify that CSSValue objects comparison works properly.

  • cssom/cssvalue-comparison-expected.txt: Added.
  • cssom/cssvalue-comparison.html: Added.
Location:
trunk
Files:
2 added
69 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r142442 r142444  
     12013-02-11  Alexander Shalamov  <alexander.shalamov@intel.com>
     2
     3        Implement CSSValue::equals(const CSSValue&) to optimise CSSValue comparison
     4        https://bugs.webkit.org/show_bug.cgi?id=102901
     5
     6        Reviewed by Antti Koivisto.
     7
     8        New layout test to verify that CSSValue objects comparison works properly.
     9
     10        * cssom/cssvalue-comparison-expected.txt: Added.
     11        * cssom/cssvalue-comparison.html: Added.
     12
    1132013-02-11  Kentaro Hara  <haraken@chromium.org>
    214
  • trunk/Source/WebCore/ChangeLog

    r142443 r142444  
     12013-02-11  Alexander Shalamov  <alexander.shalamov@intel.com>
     2
     3        Implement CSSValue::equals(const CSSValue&) to optimise CSSValue comparison
     4        https://bugs.webkit.org/show_bug.cgi?id=102901
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Added comparison method to CSSValue and its children, so that the
     9        css values could be compared efficiently. Before this patch, CSSValue
     10        objects were compared using strings that were generated by the cssText() method.
     11
     12        Test: cssom/cssvalue-comparison.html
     13
     14        * css/CSSAspectRatioValue.cpp:
     15        (WebCore::CSSAspectRatioValue::equals):
     16        (WebCore):
     17        * css/CSSAspectRatioValue.h:
     18        (CSSAspectRatioValue):
     19        * css/CSSBasicShapes.cpp:
     20        (WebCore::CSSBasicShapeRectangle::equals):
     21        (WebCore):
     22        (WebCore::CSSBasicShapeCircle::equals):
     23        (WebCore::CSSBasicShapeEllipse::equals):
     24        (WebCore::CSSBasicShapePolygon::equals):
     25        * css/CSSBasicShapes.h:
     26        (CSSBasicShapeRectangle):
     27        (CSSBasicShapeCircle):
     28        (CSSBasicShapeEllipse):
     29        (CSSBasicShapePolygon):
     30        * css/CSSBorderImageSliceValue.cpp:
     31        (WebCore::CSSBorderImageSliceValue::equals):
     32        (WebCore):
     33        * css/CSSBorderImageSliceValue.h:
     34        (CSSBorderImageSliceValue):
     35        * css/CSSCalculationValue.cpp:
     36        (WebCore::CSSCalcValue::equals):
     37        (WebCore):
     38        (WebCore::CSSCalcPrimitiveValue::equals):
     39        (CSSCalcPrimitiveValue):
     40        (WebCore::CSSCalcPrimitiveValue::type):
     41        (WebCore::CSSCalcBinaryOperation::equals):
     42        (CSSCalcBinaryOperation):
     43        (WebCore::CSSCalcBinaryOperation::type):
     44        * css/CSSCalculationValue.h:
     45        (WebCore::CSSCalcExpressionNode::equals):
     46        (CSSCalcExpressionNode):
     47        (CSSCalcValue):
     48        * css/CSSCanvasValue.cpp:
     49        (WebCore::CSSCanvasValue::equals):
     50        (WebCore):
     51        * css/CSSCanvasValue.h:
     52        (CSSCanvasValue):
     53        * css/CSSComputedStyleDeclaration.cpp:
     54        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
     55        (WebCore::CSSComputedStyleDeclaration::cssPropertyMatches):
     56        (WebCore::CSSComputedStyleDeclaration::getCSSPropertyValuesForSidesShorthand):
     57        * css/CSSCrossfadeValue.cpp:
     58        (WebCore::CSSCrossfadeValue::equals):
     59        (WebCore):
     60        * css/CSSCrossfadeValue.h:
     61        (CSSCrossfadeValue):
     62        * css/CSSCursorImageValue.cpp:
     63        (WebCore::CSSCursorImageValue::equals):
     64        (WebCore):
     65        * css/CSSCursorImageValue.h:
     66        (CSSCursorImageValue):
     67        * css/CSSFontFaceSrcValue.cpp:
     68        (WebCore::CSSFontFaceSrcValue::equals):
     69        (WebCore):
     70        * css/CSSFontFaceSrcValue.h:
     71        (CSSFontFaceSrcValue):
     72        * css/CSSFunctionValue.cpp:
     73        (WebCore::CSSFunctionValue::equals):
     74        (WebCore):
     75        * css/CSSFunctionValue.h:
     76        (CSSFunctionValue):
     77        * css/CSSGradientValue.cpp:
     78        (WebCore::CSSLinearGradientValue::equals):
     79        (WebCore):
     80        (WebCore::CSSRadialGradientValue::equals):
     81        * css/CSSGradientValue.h:
     82        (WebCore::CSSGradientColorStop::operator==):
     83        (CSSLinearGradientValue):
     84        (CSSRadialGradientValue):
     85        * css/CSSImageValue.cpp:
     86        (WebCore::CSSImageValue::equals):
     87        (WebCore):
     88        * css/CSSImageValue.h:
     89        (CSSImageValue):
     90        * css/CSSInheritedValue.h:
     91        (WebCore::CSSInheritedValue::equals):
     92        (CSSInheritedValue):
     93        * css/CSSInitialValue.h:
     94        (WebCore::CSSInitialValue::equals):
     95        (CSSInitialValue):
     96        * css/CSSLineBoxContainValue.h:
     97        (WebCore::CSSLineBoxContainValue::equals):
     98        * css/CSSPrimitiveValue.cpp:
     99        (WebCore::CSSPrimitiveValue::equals):
     100        (WebCore):
     101        * css/CSSPrimitiveValue.h:
     102        (CSSPrimitiveValue):
     103        * css/CSSReflectValue.cpp:
     104        (WebCore::CSSReflectValue::equals):
     105        (WebCore):
     106        * css/CSSReflectValue.h:
     107        (CSSReflectValue):
     108        * css/CSSTimingFunctionValue.cpp:
     109        (WebCore::CSSCubicBezierTimingFunctionValue::equals):
     110        (WebCore):
     111        (WebCore::CSSStepsTimingFunctionValue::equals):
     112        * css/CSSTimingFunctionValue.h:
     113        (WebCore::CSSLinearTimingFunctionValue::equals):
     114        (CSSLinearTimingFunctionValue):
     115        (CSSCubicBezierTimingFunctionValue):
     116        (CSSStepsTimingFunctionValue):
     117        * css/CSSUnicodeRangeValue.cpp:
     118        (WebCore::CSSUnicodeRangeValue::equals):
     119        (WebCore):
     120        * css/CSSUnicodeRangeValue.h:
     121        (CSSUnicodeRangeValue):
     122        * css/CSSValue.cpp:
     123        (WebCore):
     124        (WebCore::compareCSSValues):
     125        (WebCore::CSSValue::equals):
     126        * css/CSSValue.h:
     127        (CSSValue):
     128        (WebCore):
     129        (WebCore::compareCSSValueVector):
     130        (WebCore::compareCSSValuePtr):
     131        * css/CSSValueList.cpp:
     132        (WebCore::CSSValueList::removeAll):
     133        (WebCore::CSSValueList::hasValue):
     134        (WebCore::CSSValueList::equals):
     135        (WebCore):
     136        * css/CSSValueList.h:
     137        (CSSValueList):
     138        * css/CSSVariableValue.h:
     139        (WebCore::CSSVariableValue::equals):
     140        (CSSVariableValue):
     141        * css/Counter.h:
     142        (Counter):
     143        (WebCore::Counter::equals):
     144        * css/DashboardRegion.h:
     145        (WebCore::DashboardRegion::equals):
     146        * css/FontFeatureValue.cpp:
     147        (WebCore::FontFeatureValue::equals):
     148        (WebCore):
     149        * css/FontFeatureValue.h:
     150        (FontFeatureValue):
     151        * css/FontValue.cpp:
     152        (WebCore::FontValue::equals):
     153        (WebCore):
     154        * css/FontValue.h:
     155        (FontValue):
     156        * css/MediaQueryExp.h:
     157        (WebCore::MediaQueryExp::operator==):
     158        * css/Pair.h:
     159        (WebCore::Pair::equals):
     160        (Pair):
     161        * css/Rect.h:
     162        (WebCore::RectBase::equals):
     163        (RectBase):
     164        * css/ShadowValue.cpp:
     165        (WebCore::ShadowValue::equals):
     166        (WebCore):
     167        * css/ShadowValue.h:
     168        (ShadowValue):
     169        * css/StylePropertySet.cpp:
     170        (WebCore::StylePropertySet::get4Values):
     171        (WebCore::StylePropertySet::propertyMatches):
     172        * css/WebKitCSSArrayFunctionValue.cpp:
     173        (WebCore::WebKitCSSArrayFunctionValue::equals):
     174        (WebCore):
     175        * css/WebKitCSSArrayFunctionValue.h:
     176        (WebKitCSSArrayFunctionValue):
     177        * css/WebKitCSSFilterValue.cpp:
     178        (WebCore::WebKitCSSFilterValue::equals):
     179        (WebCore):
     180        * css/WebKitCSSFilterValue.h:
     181        (WebKitCSSFilterValue):
     182        * css/WebKitCSSMixFunctionValue.cpp:
     183        (WebCore::WebKitCSSMixFunctionValue::equals):
     184        (WebCore):
     185        * css/WebKitCSSMixFunctionValue.h:
     186        (WebKitCSSMixFunctionValue):
     187        * css/WebKitCSSSVGDocumentValue.cpp:
     188        (WebCore::WebKitCSSSVGDocumentValue::equals):
     189        (WebCore):
     190        * css/WebKitCSSSVGDocumentValue.h:
     191        (WebKitCSSSVGDocumentValue):
     192        * css/WebKitCSSShaderValue.cpp:
     193        (WebCore::WebKitCSSShaderValue::equals):
     194        (WebCore):
     195        * css/WebKitCSSShaderValue.h:
     196        (WebKitCSSShaderValue):
     197        * css/WebKitCSSTransformValue.h:
     198        (WebCore::WebKitCSSTransformValue::equals):
     199        * editing/EditingStyle.cpp:
     200        (WebCore::HTMLAttributeEquivalent::valueIsPresentInStyle):
     201        * svg/SVGColor.cpp:
     202        (WebCore::SVGColor::equals):
     203        (WebCore):
     204        * svg/SVGColor.h:
     205        (SVGColor):
     206        * svg/SVGPaint.cpp:
     207        (WebCore::SVGPaint::equals):
     208        (WebCore):
     209        * svg/SVGPaint.h:
     210        (SVGPaint):
     211
    12122013-02-11  Pan Deng  <pan.deng@intel.com>
    2213
  • trunk/Source/WebCore/css/CSSAspectRatioValue.cpp

    r128204 r142444  
    4040}
    4141
     42bool CSSAspectRatioValue::equals(const CSSAspectRatioValue& other) const
     43{
     44    return m_numeratorValue == other.m_numeratorValue && m_denominatorValue == other.m_denominatorValue;
     45}
     46
    4247void CSSAspectRatioValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    4348{
  • trunk/Source/WebCore/css/CSSAspectRatioValue.h

    r124768 r142444  
    4747    float denominatorValue() const { return m_denominatorValue; }
    4848
     49    bool equals(const CSSAspectRatioValue&) const;
     50
    4951    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
    5052
  • trunk/Source/WebCore/css/CSSBasicShapes.cpp

    r129831 r142444  
    3131
    3232#include "CSSBasicShapes.h"
     33#include "CSSPrimitiveValueMappings.h"
    3334
    3435#include <wtf/text/StringBuilder.h>
     
    7576}
    7677
     78bool CSSBasicShapeRectangle::equals(const CSSBasicShape& shape) const
     79{
     80    if (shape.type() != CSS_BASIC_SHAPE_RECTANGLE)
     81        return false;
     82
     83    const CSSBasicShapeRectangle& other = static_cast<const CSSBasicShapeRectangle&>(shape);
     84    return compareCSSValuePtr(m_x, other.m_x)
     85        && compareCSSValuePtr(m_y, other.m_y)
     86        && compareCSSValuePtr(m_width, other.m_width)
     87        && compareCSSValuePtr(m_height, other.m_height)
     88        && compareCSSValuePtr(m_radiusX, other.m_radiusX)
     89        && compareCSSValuePtr(m_radiusY, other.m_radiusY);
     90}
     91
    7792#if ENABLE(CSS_VARIABLES)
    7893String CSSBasicShapeRectangle::serializeResolvingVariables(const HashMap<AtomicString, String>& variables) const
     
    107122}
    108123
     124bool CSSBasicShapeCircle::equals(const CSSBasicShape& shape) const
     125{
     126    if (shape.type() != CSS_BASIC_SHAPE_CIRCLE)
     127        return false;
     128
     129    const CSSBasicShapeCircle& other = static_cast<const CSSBasicShapeCircle&>(shape);
     130    return compareCSSValuePtr(m_centerX, other.m_centerX)
     131        && compareCSSValuePtr(m_centerY, other.m_centerY)
     132        && compareCSSValuePtr(m_radius, other.m_radius);
     133}
     134
    109135#if ENABLE(CSS_VARIABLES)
    110136String CSSBasicShapeCircle::serializeResolvingVariables(const HashMap<AtomicString, String>& variables) const
     
    131157{
    132158    return buildEllipseString(m_centerX->cssText(), m_centerY->cssText(), m_radiusX->cssText(), m_radiusY->cssText());
     159}
     160
     161bool CSSBasicShapeEllipse::equals(const CSSBasicShape& shape) const
     162{
     163    if (shape.type() != CSS_BASIC_SHAPE_ELLIPSE)
     164        return false;
     165
     166    const CSSBasicShapeEllipse& other = static_cast<const CSSBasicShapeEllipse&>(shape);
     167    return compareCSSValuePtr(m_centerX, other.m_centerX)
     168        && compareCSSValuePtr(m_centerY, other.m_centerY)
     169        && compareCSSValuePtr(m_radiusX, other.m_radiusX)
     170        && compareCSSValuePtr(m_radiusY, other.m_radiusY);
    133171}
    134172
     
    200238}
    201239
     240bool CSSBasicShapePolygon::equals(const CSSBasicShape& shape) const
     241{
     242    if (shape.type() != CSS_BASIC_SHAPE_POLYGON)
     243        return false;
     244
     245    const CSSBasicShapePolygon& rhs = static_cast<const CSSBasicShapePolygon&>(shape);
     246    return compareCSSValueVector<CSSPrimitiveValue>(m_values, rhs.m_values);
     247}
     248
    202249#if ENABLE(CSS_VARIABLES)
    203250String CSSBasicShapePolygon::serializeResolvingVariables(const HashMap<AtomicString, String>& variables) const
  • trunk/Source/WebCore/css/CSSBasicShapes.h

    r129579 r142444  
    5050    virtual Type type() const = 0;
    5151    virtual String cssText() const = 0;
     52    virtual bool equals(const CSSBasicShape&) const = 0;
    5253
    5354#if ENABLE(CSS_VARIABLES)
     
    8384    virtual Type type() const { return CSS_BASIC_SHAPE_RECTANGLE; }
    8485    virtual String cssText() const;
     86    virtual bool equals(const CSSBasicShape&) const;
    8587
    8688#if ENABLE(CSS_VARIABLES)
     
    114116    virtual Type type() const { return CSS_BASIC_SHAPE_CIRCLE; }
    115117    virtual String cssText() const;
     118    virtual bool equals(const CSSBasicShape&) const;
    116119
    117120#if ENABLE(CSS_VARIABLES)
     
    144147    virtual Type type() const { return CSS_BASIC_SHAPE_ELLIPSE; }
    145148    virtual String cssText() const;
     149    virtual bool equals(const CSSBasicShape&) const;
    146150
    147151#if ENABLE(CSS_VARIABLES)
     
    178182    virtual Type type() const { return CSS_BASIC_SHAPE_POLYGON; }
    179183    virtual String cssText() const;
    180 
     184    virtual bool equals(const CSSBasicShape&) const;
    181185#if ENABLE(CSS_VARIABLES)
    182186    virtual String serializeResolvingVariables(const HashMap<AtomicString, String>&) const;
  • trunk/Source/WebCore/css/CSSBorderImageSliceValue.cpp

    r141570 r142444  
    5151}
    5252
     53bool CSSBorderImageSliceValue::equals(const CSSBorderImageSliceValue& other) const
     54{
     55    return m_fill == other.m_fill && compareCSSValuePtr(m_slices, other.m_slices);
     56}
     57
    5358void CSSBorderImageSliceValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    5459{
  • trunk/Source/WebCore/css/CSSBorderImageSliceValue.h

    r124768 r142444  
    4646    Quad* slices() { return m_slices ? m_slices->getQuadValue() : 0; }
    4747
     48    bool equals(const CSSBorderImageSliceValue&) const;
     49
    4850    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
    4951
  • trunk/Source/WebCore/css/CSSCalculationValue.cpp

    r142434 r142444  
    9696}
    9797
     98bool CSSCalcValue::equals(const CSSCalcValue& other) const
     99{
     100    return compareCSSValuePtr(m_expression, other.m_expression);
     101}
     102
    98103#if ENABLE(CSS_VARIABLES)
    99104String CSSCalcValue::customSerializeResolvingVariables(const HashMap<AtomicString, String>& variables) const
     
    224229    }
    225230
     231    virtual bool equals(const CSSCalcExpressionNode& other) const
     232    {
     233        if (type() != other.type())
     234            return false;
     235
     236        return compareCSSValuePtr(m_value, static_cast<const CSSCalcPrimitiveValue&>(other).m_value);
     237    }
     238
    226239    virtual void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const OVERRIDE
    227240    {
     
    229242        info.addMember(m_value, "value");
    230243    }
     244
     245    virtual Type type() const { return CssCalcPrimitiveValue; }
    231246   
    232247private:
     
    360375#endif
    361376
     377    virtual bool equals(const CSSCalcExpressionNode& exp) const
     378    {
     379        if (type() != exp.type())
     380            return false;
     381
     382        const CSSCalcBinaryOperation& other = static_cast<const CSSCalcBinaryOperation&>(exp);
     383        return compareCSSValuePtr(m_leftSide, other.m_leftSide)
     384            && compareCSSValuePtr(m_rightSide, other.m_rightSide)
     385            && m_operator == other.m_operator;
     386    }
     387
     388    virtual Type type() const { return CssCalcBinaryOperation; }
     389
    362390private:
    363391    CSSCalcBinaryOperation(PassRefPtr<CSSCalcExpressionNode> leftSide, PassRefPtr<CSSCalcExpressionNode> rightSide, CalcOperator op, CalculationCategory category)
  • trunk/Source/WebCore/css/CSSCalculationValue.h

    r131826 r142444  
    6161class CSSCalcExpressionNode : public RefCounted<CSSCalcExpressionNode> {
    6262public:
    63    
     63    enum Type {
     64        CssCalcPrimitiveValue = 1,
     65        CssCalcBinaryOperation
     66    };
     67
    6468    virtual ~CSSCalcExpressionNode() = 0;
    6569    virtual bool isZero() const = 0;
     
    7276    virtual bool hasVariableReference() const = 0;
    7377#endif
     78    virtual bool equals(const CSSCalcExpressionNode& other) const { return m_category == other.m_category && m_isInteger == other.m_isInteger; }
     79    virtual void reportMemoryUsage(MemoryObjectInfo*) const = 0;
     80    virtual Type type() const = 0;
    7481
    75     virtual void reportMemoryUsage(MemoryObjectInfo*) const = 0;
    76    
    7782    CalculationCategory category() const { return m_category; }   
    7883    bool isInteger() const { return m_isInteger; }
     
    105110       
    106111    String customCssText() const;
     112    bool equals(const CSSCalcValue&) const;
    107113#if ENABLE(CSS_VARIABLES)
    108114    String customSerializeResolvingVariables(const HashMap<AtomicString, String>&) const;
  • trunk/Source/WebCore/css/CSSCanvasValue.cpp

    r141570 r142444  
    9797}
    9898
     99bool CSSCanvasValue::equals(const CSSCanvasValue& other) const
     100{
     101    return m_name == other.m_name;
     102}
     103
    99104void CSSCanvasValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    100105{
  • trunk/Source/WebCore/css/CSSCanvasValue.h

    r124768 r142444  
    4747    bool isPending() const { return false; }
    4848    void loadSubimages(CachedResourceLoader*) { }
     49
     50    bool equals(const CSSCanvasValue&) const;
    4951
    5052    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r142215 r142444  
    26492649                                        CSSPropertyBorderLeft };
    26502650            for (size_t i = 0; i < WTF_ARRAY_LENGTH(properties); ++i) {
    2651                 if (value->cssText() !=  getPropertyCSSValue(properties[i], DoNotUpdateLayout)->cssText())
     2651                if (!compareCSSValuePtr<CSSValue>(value, getPropertyCSSValue(properties[i], DoNotUpdateLayout)))
    26522652                    return 0;
    26532653            }
     
    28732873    }
    28742874    RefPtr<CSSValue> value = getPropertyCSSValue(property.id());
    2875     return value && value->cssText() == property.value()->cssText();
     2875    return value && property.value() && value->equals(*property.value());
    28762876}
    28772877
     
    29092909        return 0;
    29102910
    2911     bool showLeft = rightValue->cssText() != leftValue->cssText();
    2912     bool showBottom = (topValue->cssText() != bottomValue->cssText()) || showLeft;
    2913     bool showRight = (topValue->cssText() != rightValue->cssText()) || showBottom;
     2911    bool showLeft = !compareCSSValuePtr(rightValue, leftValue);
     2912    bool showBottom = !compareCSSValuePtr(topValue, bottomValue) || showLeft;
     2913    bool showRight = !compareCSSValuePtr(topValue, rightValue) || showBottom;
    29142914
    29152915    list->append(topValue);
  • trunk/Source/WebCore/css/CSSCrossfadeValue.cpp

    r141637 r142444  
    230230}
    231231
     232bool CSSCrossfadeValue::equals(const CSSCrossfadeValue& other) const
     233{
     234    return compareCSSValuePtr(m_fromValue, other.m_fromValue)
     235        && compareCSSValuePtr(m_toValue, other.m_toValue)
     236        && compareCSSValuePtr(m_percentageValue, other.m_percentageValue);
     237}
     238
    232239} // namespace WebCore
  • trunk/Source/WebCore/css/CSSCrossfadeValue.h

    r141637 r142444  
    6767    bool hasFailedOrCanceledSubresources() const;
    6868
     69    bool equals(const CSSCrossfadeValue&) const;
     70
    6971    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
    7072
  • trunk/Source/WebCore/css/CSSCursorImageValue.cpp

    r141570 r142444  
    218218#endif
    219219
     220bool CSSCursorImageValue::equals(const CSSCursorImageValue& other) const
     221{
     222    return m_hasHotSpot ? other.m_hasHotSpot && m_hotSpot == other.m_hotSpot : !other.m_hasHotSpot
     223        && compareCSSValuePtr(m_imageValue, other.m_imageValue);
     224}
     225
    220226void CSSCursorImageValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    221227{
  • trunk/Source/WebCore/css/CSSCursorImageValue.h

    r136919 r142444  
    6060#endif
    6161
     62    bool equals(const CSSCursorImageValue&) const;
     63
    6264    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
    6365
  • trunk/Source/WebCore/css/CSSFontFaceSrcValue.cpp

    r141570 r142444  
    105105}
    106106
     107bool CSSFontFaceSrcValue::equals(const CSSFontFaceSrcValue& other) const
     108{
     109    return m_isLocal == other.m_isLocal && m_format == other.m_format && m_resource == other.m_resource;
     110}
     111
    107112void CSSFontFaceSrcValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    108113{
  • trunk/Source/WebCore/css/CSSFontFaceSrcValue.h

    r127757 r142444  
    7272    CachedFont* cachedFont(Document*);
    7373
     74    bool equals(const CSSFontFaceSrcValue&) const;
     75
    7476    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
    7577
  • trunk/Source/WebCore/css/CSSFunctionValue.cpp

    r141570 r142444  
    6060}
    6161
     62bool CSSFunctionValue::equals(const CSSFunctionValue& other) const
     63{
     64    return m_name == other.m_name && compareCSSValuePtr(m_args, other.m_args);
     65}
     66
    6267void CSSFunctionValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    6368{
  • trunk/Source/WebCore/css/CSSFunctionValue.h

    r136588 r142444  
    4848    String customCssText() const;
    4949
     50    bool equals(const CSSFunctionValue&) const;
     51
    5052    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
    5153
  • trunk/Source/WebCore/css/CSSGradientValue.cpp

    r141637 r142444  
    724724}
    725725
     726bool CSSLinearGradientValue::equals(const CSSLinearGradientValue& other) const
     727{
     728    if (m_gradientType == CSSDeprecatedLinearGradient)
     729        return other.m_gradientType == m_gradientType
     730            && compareCSSValuePtr(m_firstX, other.m_firstX)
     731            && compareCSSValuePtr(m_firstY, other.m_firstY)
     732            && compareCSSValuePtr(m_secondX, other.m_secondX)
     733            && compareCSSValuePtr(m_secondY, other.m_secondY)
     734            && m_stops == other.m_stops;
     735
     736    if (m_repeating != other.m_repeating)
     737        return false;
     738
     739    if (m_angle)
     740        return compareCSSValuePtr(m_angle, other.m_angle) && m_stops == other.m_stops;
     741
     742    if (other.m_angle)
     743        return false;
     744
     745    bool equalXorY = false;
     746    if (m_firstX && m_firstY)
     747        equalXorY = compareCSSValuePtr(m_firstX, other.m_firstX) && compareCSSValuePtr(m_firstY, other.m_firstY);
     748    else if (m_firstX)
     749        equalXorY =compareCSSValuePtr(m_firstX, other.m_firstX) && !other.m_firstY;
     750    else if (m_firstY)
     751        equalXorY = compareCSSValuePtr(m_firstY, other.m_firstY) && !other.m_firstX;
     752    else
     753        equalXorY = !other.m_firstX || !other.m_firstY;
     754
     755    return equalXorY && m_stops == other.m_stops;
     756}
     757
    726758void CSSLinearGradientValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    727759{
     
    11131145}
    11141146
     1147bool CSSRadialGradientValue::equals(const CSSRadialGradientValue& other) const
     1148{
     1149    if (m_gradientType == CSSDeprecatedRadialGradient)
     1150        return other.m_gradientType == m_gradientType
     1151            && compareCSSValuePtr(m_firstX, other.m_firstX)
     1152            && compareCSSValuePtr(m_firstY, other.m_firstY)
     1153            && compareCSSValuePtr(m_secondX, other.m_secondX)
     1154            && compareCSSValuePtr(m_secondY, other.m_secondY)
     1155            && compareCSSValuePtr(m_firstRadius, other.m_firstRadius)
     1156            && compareCSSValuePtr(m_secondRadius, other.m_secondRadius)
     1157            && m_stops == other.m_stops;
     1158
     1159    if (m_repeating != other.m_repeating)
     1160        return false;
     1161
     1162    bool equalXorY = false;
     1163    if (m_firstX && m_firstY)
     1164        equalXorY = compareCSSValuePtr(m_firstX, other.m_firstX) && compareCSSValuePtr(m_firstY, other.m_firstY);
     1165    else if (m_firstX)
     1166        equalXorY = compareCSSValuePtr(m_firstX, other.m_firstX) && !other.m_firstY;
     1167    else if (m_firstY)
     1168        equalXorY = compareCSSValuePtr(m_firstY, other.m_firstY) && !other.m_firstX;
     1169    else
     1170        equalXorY == !other.m_firstX || !other.m_firstY;
     1171
     1172    if (!equalXorY)
     1173        return false;
     1174
     1175    bool equalShape = true;
     1176    bool equalSizingBehavior = true;
     1177    bool equalHorizontalAndVerticalSize = true;
     1178
     1179    if (m_shape)
     1180        equalShape = compareCSSValuePtr(m_shape, other.m_shape);
     1181    else if (m_sizingBehavior)
     1182        equalSizingBehavior = compareCSSValuePtr(m_sizingBehavior, other.m_sizingBehavior);
     1183    else if (m_endHorizontalSize && m_endVerticalSize)
     1184        equalHorizontalAndVerticalSize = compareCSSValuePtr(m_endHorizontalSize, other.m_endHorizontalSize) && compareCSSValuePtr(m_endVerticalSize, other.m_endVerticalSize);
     1185    else {
     1186        equalShape = !other.m_shape;
     1187        equalSizingBehavior = !other.m_sizingBehavior;
     1188        equalHorizontalAndVerticalSize = !other.m_endHorizontalSize && !other.m_endVerticalSize;
     1189    }
     1190    return equalShape && equalSizingBehavior && equalHorizontalAndVerticalSize && m_stops == other.m_stops;
     1191}
     1192
    11151193void CSSRadialGradientValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    11161194{
  • trunk/Source/WebCore/css/CSSGradientValue.h

    r141637 r142444  
    5454    bool m_colorIsDerivedFromElement;
    5555    void reportMemoryUsage(MemoryObjectInfo*) const;
     56    bool operator==(const CSSGradientColorStop& other) const
     57    {
     58        return compareCSSValuePtr(m_color, other.m_color)
     59            && compareCSSValuePtr(m_position, other.m_position);
     60    }
    5661};
    5762
     
    153158    }
    154159
     160    bool equals(const CSSLinearGradientValue&) const;
     161
    155162    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
    156163
     
    195202    // Create the gradient for a given size.
    196203    PassRefPtr<Gradient> createGradient(RenderObject*, const IntSize&);
     204
     205    bool equals(const CSSRadialGradientValue&) const;
    197206
    198207    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
  • trunk/Source/WebCore/css/CSSImageValue.cpp

    r141637 r142444  
    9494}
    9595
     96bool CSSImageValue::equals(const CSSImageValue& other) const
     97{
     98    return m_url == other.m_url;
     99}
     100
    96101String CSSImageValue::customCssText() const
    97102{
  • trunk/Source/WebCore/css/CSSImageValue.h

    r141637 r142444  
    5151    bool hasFailedOrCanceledSubresources() const;
    5252
     53    bool equals(const CSSImageValue&) const;
     54
    5355    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
    5456
  • trunk/Source/WebCore/css/CSSInheritedValue.h

    r124768 r142444  
    3636    String customCssText() const;
    3737
     38    bool equals(const CSSInheritedValue&) const { return true; }
     39
    3840    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
    3941
  • trunk/Source/WebCore/css/CSSInitialValue.h

    r124768 r142444  
    4242    bool isImplicit() const { return m_isImplicit; }
    4343
     44    bool equals(const CSSInitialValue&) const { return true; }
     45
    4446    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
    4547
  • trunk/Source/WebCore/css/CSSLineBoxContainValue.h

    r124768 r142444  
    4848
    4949    String customCssText() const;
    50 
     50    bool equals(const CSSLineBoxContainValue& other) const { return m_value == other.m_value; }
    5151    LineBoxContain value() const { return m_value; }
    5252
  • trunk/Source/WebCore/css/CSSPrimitiveValue.cpp

    r142021 r142444  
    12751275}
    12761276
     1277bool CSSPrimitiveValue::equals(const CSSPrimitiveValue& other) const
     1278{
     1279    if (m_primitiveUnitType != other.m_primitiveUnitType)
     1280        return false;
     1281
     1282    switch (m_primitiveUnitType) {
     1283    case CSS_UNKNOWN:
     1284        return false;
     1285    case CSS_NUMBER:
     1286    case CSS_PARSER_INTEGER:
     1287    case CSS_PERCENTAGE:
     1288    case CSS_EMS:
     1289    case CSS_EXS:
     1290    case CSS_REMS:
     1291    case CSS_PX:
     1292    case CSS_CM:
     1293#if ENABLE(CSS_IMAGE_RESOLUTION) || ENABLE(RESOLUTION_MEDIA_QUERY)
     1294    case CSS_DPPX:
     1295    case CSS_DPI:
     1296    case CSS_DPCM:
     1297#endif
     1298    case CSS_MM:
     1299    case CSS_IN:
     1300    case CSS_PT:
     1301    case CSS_PC:
     1302    case CSS_DEG:
     1303    case CSS_RAD:
     1304    case CSS_GRAD:
     1305    case CSS_MS:
     1306    case CSS_S:
     1307    case CSS_HZ:
     1308    case CSS_KHZ:
     1309    case CSS_TURN:
     1310    case CSS_VW:
     1311    case CSS_VH:
     1312    case CSS_VMIN:
     1313    case CSS_DIMENSION:
     1314        return m_value.num == other.m_value.num;
     1315    case CSS_IDENT:
     1316        return valueOrPropertyName(m_value.ident) == valueOrPropertyName(other.m_value.ident);
     1317    case CSS_STRING:
     1318    case CSS_URI:
     1319    case CSS_ATTR:
     1320    case CSS_COUNTER_NAME:
     1321    case CSS_PARSER_IDENTIFIER:
     1322    case CSS_PARSER_HEXCOLOR:
     1323#if ENABLE(CSS_VARIABLES)
     1324    case CSS_VARIABLE_NAME:
     1325#endif
     1326        return equal(m_value.string, other.m_value.string);
     1327    case CSS_COUNTER:
     1328        return m_value.counter && other.m_value.counter && m_value.counter->equals(*other.m_value.counter);
     1329    case CSS_RECT:
     1330        return m_value.rect && other.m_value.rect && m_value.rect->equals(*other.m_value.rect);
     1331    case CSS_QUAD:
     1332        return m_value.quad && other.m_value.quad && m_value.quad->equals(*other.m_value.quad);
     1333    case CSS_RGBCOLOR:
     1334        return m_value.rgbcolor == other.m_value.rgbcolor;
     1335    case CSS_PAIR:
     1336        return m_value.pair && other.m_value.pair && m_value.pair->equals(*other.m_value.pair);
     1337#if ENABLE(DASHBOARD_SUPPORT)
     1338    case CSS_DASHBOARD_REGION: {
     1339        DashboardRegion* region = getDashboardRegionValue();
     1340        DashboardRegion* otherRegion = other.getDashboardRegionValue();
     1341        return region ? otherRegion && region->equals(*otherRegion) : !otherRegion;
     1342    }
     1343#endif
     1344    case CSS_PARSER_OPERATOR:
     1345        return m_value.ident == other.m_value.ident;
     1346    case CSS_CALC:
     1347        return m_value.calc && other.m_value.calc && m_value.calc->equals(*other.m_value.calc);
     1348    case CSS_SHAPE:
     1349        return m_value.shape && other.m_value.shape && m_value.shape->equals(*other.m_value.shape);
     1350    }
     1351    return false;
     1352}
     1353
    12771354void CSSPrimitiveValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    12781355{
  • trunk/Source/WebCore/css/CSSPrimitiveValue.h

    r142021 r142444  
    317317    void setCSSOMSafe() { m_isCSSOMSafe = true; }
    318318
     319    bool equals(const CSSPrimitiveValue&) const;
     320
    319321    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
    320322
  • trunk/Source/WebCore/css/CSSReflectValue.cpp

    r141570 r142444  
    5757}
    5858
     59bool CSSReflectValue::equals(const CSSReflectValue& other) const
     60{
     61    return m_direction == other.m_direction
     62        && compareCSSValuePtr(m_offset, other.m_offset)
     63        && compareCSSValuePtr(m_mask, other.m_mask);
     64}
     65
    5966void CSSReflectValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    6067{
  • trunk/Source/WebCore/css/CSSReflectValue.h

    r140642 r142444  
    5555    void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetContents*) const;
    5656
     57    bool equals(const CSSReflectValue&) const;
     58
    5759    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
    5860
  • trunk/Source/WebCore/css/CSSTimingFunctionValue.cpp

    r127869 r142444  
    5151}
    5252
     53bool CSSCubicBezierTimingFunctionValue::equals(const CSSCubicBezierTimingFunctionValue& other) const
     54{
     55    return m_x1 == other.m_x1 && m_x2 == other.m_x2 && m_y1 == other.m_y1 && m_y2 == other.m_y2;
     56}
     57
     58
    5359void CSSCubicBezierTimingFunctionValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    5460{
     
    6167}
    6268
     69bool CSSStepsTimingFunctionValue::equals(const CSSStepsTimingFunctionValue& other) const
     70{
     71    return m_steps == other.m_steps && m_stepAtStart == other.m_stepAtStart;
     72}
     73
     74
    6375void CSSStepsTimingFunctionValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    6476{
  • trunk/Source/WebCore/css/CSSTimingFunctionValue.h

    r124768 r142444  
    4141    String customCssText() const;
    4242
     43    bool equals(const CSSLinearTimingFunctionValue&) const { return true; }
     44
    4345    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
    4446
     
    6365    double x2() const { return m_x2; }
    6466    double y2() const { return m_y2; }
     67
     68    bool equals(const CSSCubicBezierTimingFunctionValue&) const;
    6569
    6670    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
     
    9498    String customCssText() const;
    9599
     100    bool equals(const CSSStepsTimingFunctionValue&) const;
     101
    96102    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
    97103
  • trunk/Source/WebCore/css/CSSUnicodeRangeValue.cpp

    r127869 r142444  
    3939}
    4040
     41bool CSSUnicodeRangeValue::equals(const CSSUnicodeRangeValue& other) const
     42{
     43    return m_from == other.m_from && m_to == other.m_to;
     44}
     45
    4146void CSSUnicodeRangeValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    4247{
  • trunk/Source/WebCore/css/CSSUnicodeRangeValue.h

    r124768 r142444  
    4545    String customCssText() const;
    4646
     47    bool equals(const CSSUnicodeRangeValue&) const;
     48
    4749    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
    4850
  • trunk/Source/WebCore/css/CSSValue.cpp

    r141570 r142444  
    7474
    7575COMPILE_ASSERT(sizeof(CSSValue) == sizeof(SameSizeAsCSSValue), CSS_value_should_stay_small);
    76    
     76
    7777class TextCloneCSSValue : public CSSValue {
    7878public:
     
    275275    }
    276276    ASSERT_NOT_REACHED();
     277}
     278
     279template<class ChildClassType>
     280inline static bool compareCSSValues(const CSSValue& first, const CSSValue& second)
     281{
     282    return static_cast<const ChildClassType&>(first).equals(static_cast<const ChildClassType&>(second));
     283}
     284
     285bool CSSValue::equals(const CSSValue& other) const
     286{
     287    if (m_isTextClone) {
     288        ASSERT(isCSSOMSafe());
     289        return static_cast<const TextCloneCSSValue*>(this)->cssText() == other.cssText();
     290    }
     291
     292    if (m_classType == other.m_classType) {
     293        switch (m_classType) {
     294        case AspectRatioClass:
     295            return compareCSSValues<CSSAspectRatioValue>(*this, other);
     296        case BorderImageSliceClass:
     297            return compareCSSValues<CSSBorderImageSliceValue>(*this, other);
     298        case CanvasClass:
     299            return compareCSSValues<CSSCanvasValue>(*this, other);
     300        case CursorImageClass:
     301            return compareCSSValues<CSSCursorImageValue>(*this, other);
     302        case FontClass:
     303            return compareCSSValues<FontValue>(*this, other);
     304        case FontFaceSrcClass:
     305            return compareCSSValues<CSSFontFaceSrcValue>(*this, other);
     306        case FontFeatureClass:
     307            return compareCSSValues<FontFeatureValue>(*this, other);
     308        case FunctionClass:
     309            return compareCSSValues<CSSFunctionValue>(*this, other);
     310        case LinearGradientClass:
     311            return compareCSSValues<CSSLinearGradientValue>(*this, other);
     312        case RadialGradientClass:
     313            return compareCSSValues<CSSRadialGradientValue>(*this, other);
     314        case CrossfadeClass:
     315            return compareCSSValues<CSSCrossfadeValue>(*this, other);
     316        case ImageClass:
     317            return compareCSSValues<CSSImageValue>(*this, other);
     318        case InheritedClass:
     319            return compareCSSValues<CSSInheritedValue>(*this, other);
     320        case InitialClass:
     321            return compareCSSValues<CSSInitialValue>(*this, other);
     322        case PrimitiveClass:
     323            return compareCSSValues<CSSPrimitiveValue>(*this, other);
     324        case ReflectClass:
     325            return compareCSSValues<CSSReflectValue>(*this, other);
     326        case ShadowClass:
     327            return compareCSSValues<ShadowValue>(*this, other);
     328        case LinearTimingFunctionClass:
     329            return compareCSSValues<CSSLinearTimingFunctionValue>(*this, other);
     330        case CubicBezierTimingFunctionClass:
     331            return compareCSSValues<CSSCubicBezierTimingFunctionValue>(*this, other);
     332        case StepsTimingFunctionClass:
     333            return compareCSSValues<CSSStepsTimingFunctionValue>(*this, other);
     334        case UnicodeRangeClass:
     335            return compareCSSValues<CSSUnicodeRangeValue>(*this, other);
     336        case ValueListClass:
     337            return compareCSSValues<CSSValueList>(*this, other);
     338        case WebKitCSSTransformClass:
     339            return compareCSSValues<WebKitCSSTransformValue>(*this, other);
     340        case LineBoxContainClass:
     341            return compareCSSValues<CSSLineBoxContainValue>(*this, other);
     342        case CalculationClass:
     343            return compareCSSValues<CSSCalcValue>(*this, other);
     344#if ENABLE(CSS_IMAGE_SET)
     345        case ImageSetClass:
     346            return compareCSSValues<CSSImageSetValue>(*this, other);
     347#endif
     348#if ENABLE(CSS_FILTERS)
     349        case WebKitCSSFilterClass:
     350            return compareCSSValues<WebKitCSSFilterValue>(*this, other);
     351#if ENABLE(CSS_SHADERS)
     352        case WebKitCSSArrayFunctionValueClass:
     353            return compareCSSValues<WebKitCSSArrayFunctionValue>(*this, other);
     354        case WebKitCSSMixFunctionValueClass:
     355            return compareCSSValues<WebKitCSSMixFunctionValue>(*this, other);
     356        case WebKitCSSShaderClass:
     357            return compareCSSValues<WebKitCSSShaderValue>(*this, other);
     358#endif
     359#endif
     360#if ENABLE(CSS_VARIABLES)
     361        case VariableClass:
     362            return compareCSSValues<CSSVariableValue>(*this, other);
     363#endif
     364#if ENABLE(SVG)
     365        case SVGColorClass:
     366            return compareCSSValues<SVGColor>(*this, other);
     367        case SVGPaintClass:
     368            return compareCSSValues<SVGPaint>(*this, other);
     369        case WebKitCSSSVGDocumentClass:
     370            return compareCSSValues<WebKitCSSSVGDocumentValue>(*this, other);
     371        }
     372#endif
     373        ASSERT_NOT_REACHED();
     374    } else if (m_classType == ValueListClass && other.m_classType != ValueListClass)
     375        return static_cast<const CSSValueList*>(this)->equals(other);
     376    else if (m_classType != ValueListClass && other.m_classType == ValueListClass)
     377        return static_cast<const CSSValueList&>(other).equals(*this);
     378    return false;
    277379}
    278380
  • trunk/Source/WebCore/css/CSSValue.h

    r136919 r142444  
    127127    void reportMemoryUsage(MemoryObjectInfo*) const;
    128128
     129    bool equals(const CSSValue&) const;
     130
    129131protected:
    130132
     
    237239};
    238240
     241template<typename CSSValueType>
     242inline bool compareCSSValueVector(const Vector<RefPtr<CSSValueType> >& firstVector, const Vector<RefPtr<CSSValueType> >& secondVector)
     243{
     244    size_t size = firstVector.size();
     245    if (size != secondVector.size())
     246        return false;
     247
     248    for (size_t i = 0; i < size; i++) {
     249        const RefPtr<CSSValueType>& firstPtr = firstVector[i];
     250        const RefPtr<CSSValueType>& secondPtr = secondVector[i];
     251        if (firstPtr == secondPtr || (firstPtr && secondPtr && firstPtr->equals(*secondPtr)))
     252            continue;
     253        return false;
     254    }
     255    return true;
     256}
     257
     258template<typename CSSValueType>
     259inline bool compareCSSValuePtr(const RefPtr<CSSValueType>& first, const RefPtr<CSSValueType>& second)
     260{
     261    return first ? second && first->equals(*second) : !second;
     262}
     263
    239264} // namespace WebCore
    240265
  • trunk/Source/WebCore/css/CSSValueList.cpp

    r141570 r142444  
    5656{
    5757    bool found = false;
    58     // FIXME: we should be implementing operator== to CSSValue and its derived classes
    59     // to make comparison more flexible and fast.
    6058    for (size_t index = 0; index < m_values.size(); index++) {
    61         if (m_values.at(index)->cssText() == val->cssText()) {
     59        RefPtr<CSSValue>& value = m_values.at(index);
     60        if (value && val && value->equals(*val)) {
    6261            m_values.remove(index);
    6362            found = true;
     
    7069bool CSSValueList::hasValue(CSSValue* val) const
    7170{
    72     // FIXME: we should be implementing operator== to CSSValue and its derived classes
    73     // to make comparison more flexible and fast.
    7471    for (size_t index = 0; index < m_values.size(); index++) {
    75         if (m_values.at(index)->cssText() == val->cssText())
     72        const RefPtr<CSSValue>& value = m_values.at(index);
     73        if (value && val && value->equals(*val))
    7674            return true;
    7775    }
     
    128126}
    129127
     128bool CSSValueList::equals(const CSSValueList& other) const
     129{
     130    return m_valueListSeparator == other.m_valueListSeparator && compareCSSValueVector<CSSValue>(m_values, other.m_values);
     131}
     132
     133bool CSSValueList::equals(const CSSValue& other) const
     134{
     135    if (m_values.size() != 1)
     136        return false;
     137
     138    const RefPtr<CSSValue>& value = m_values[0];
     139    return value && value->equals(other);
     140}
     141
    130142#if ENABLE(CSS_VARIABLES)
    131143String CSSValueList::customSerializeResolvingVariables(const HashMap<AtomicString, String>& variables) const
  • trunk/Source/WebCore/css/CSSValueList.h

    r141816 r142444  
    6161
    6262    String customCssText() const;
     63    bool equals(const CSSValueList&) const;
     64    bool equals(const CSSValue&) const;
    6365#if ENABLE(CSS_VARIABLES)
    6466    String customSerializeResolvingVariables(const HashMap<AtomicString, String>&) const;
  • trunk/Source/WebCore/css/CSSVariableValue.h

    r141570 r142444  
    4949    const String& value() const { return m_value; }
    5050
     51    bool equals(const CSSVariableValue& other) const { return m_name == other.m_name && m_value == other.m_value; }
     52
    5153    void reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    5254    {
  • trunk/Source/WebCore/css/Counter.h

    r127757 r142444  
    4343    void setListStyle(PassRefPtr<CSSPrimitiveValue> listStyle) { m_listStyle = listStyle; }
    4444    void setSeparator(PassRefPtr<CSSPrimitiveValue> separator) { m_separator = separator; }
     45
     46    bool equals(const Counter& other) const
     47    {
     48        return identifier() == other.identifier()
     49            && listStyle() == other.listStyle()
     50            && separator() == other.separator();
     51    }
    4552   
    4653    PassRefPtr<Counter> cloneForCSSOM() const
  • trunk/Source/WebCore/css/DashboardRegion.h

    r130829 r142444  
    3131public:
    3232    static PassRefPtr<DashboardRegion> create() { return adoptRef(new DashboardRegion); }
     33    bool equals(const DashboardRegion& other) const
     34    {
     35        return m_label == other.m_label && m_geometryType == other.m_geometryType
     36            && m_isCircle == other.m_isCircle && m_isRectangle == other.m_isRectangle
     37            && m_next ? other.m_next && m_next->equals(*other.m_next) : !other.m_next;
     38    }
    3339
    3440    RefPtr<DashboardRegion> m_next;
  • trunk/Source/WebCore/css/FontFeatureValue.cpp

    r141570 r142444  
    5151}
    5252
     53bool FontFeatureValue::equals(const FontFeatureValue& other) const
     54{
     55    return m_tag == other.m_tag && m_value == other.m_value;
     56}
     57
    5358void FontFeatureValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    5459{
  • trunk/Source/WebCore/css/FontFeatureValue.h

    r127757 r142444  
    4343    String customCssText() const;
    4444
     45    bool equals(const FontFeatureValue&) const;
     46
    4547    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
    4648
  • trunk/Source/WebCore/css/FontValue.cpp

    r141570 r142444  
    6666}
    6767
     68bool FontValue::equals(const FontValue& other) const
     69{
     70    return compareCSSValuePtr(style, other.style)
     71        && compareCSSValuePtr(variant, other.variant)
     72        && compareCSSValuePtr(weight, other.weight)
     73        && compareCSSValuePtr(size, other.size)
     74        && compareCSSValuePtr(lineHeight, other.lineHeight)
     75        && compareCSSValuePtr(family, other.family);
     76}
     77
    6878void FontValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    6979{
  • trunk/Source/WebCore/css/FontValue.h

    r124768 r142444  
    4040    String customCssText() const;
    4141
     42    bool equals(const FontValue&) const;
     43
    4244    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
    4345
  • trunk/Source/WebCore/css/MediaQueryExp.h

    r128418 r142444  
    5353        return (other.m_mediaFeature == m_mediaFeature)
    5454            && ((!other.m_value && !m_value)
    55                 || (other.m_value && m_value && other.m_value->cssText() == m_value->cssText()));
     55                || (other.m_value && m_value && other.m_value->equals(*m_value)));
    5656    }
    5757
  • trunk/Source/WebCore/css/Pair.h

    r129579 r142444  
    5757    }
    5858
     59    bool equals(const Pair& other) const { return compareCSSValuePtr(m_first, other.m_first) && compareCSSValuePtr(m_second, other.m_second); }
     60
    5961#if ENABLE(CSS_VARIABLES)
    6062    String serializeResolvingVariables(const HashMap<AtomicString, String>& variables) const
  • trunk/Source/WebCore/css/Rect.h

    r129831 r142444  
    3939    void setBottom(PassRefPtr<CSSPrimitiveValue> bottom) { m_bottom = bottom; }
    4040    void setLeft(PassRefPtr<CSSPrimitiveValue> left) { m_left = left; }
     41
     42    bool equals(const RectBase& other) const
     43    {
     44        return compareCSSValuePtr(m_top, other.m_top)
     45            && compareCSSValuePtr(m_right, other.m_right)
     46            && compareCSSValuePtr(m_left, other.m_left)
     47            && compareCSSValuePtr(m_bottom, other.m_bottom);
     48    }
    4149
    4250#if ENABLE(CSS_VARIABLES)
  • trunk/Source/WebCore/css/ShadowValue.cpp

    r141570 r142444  
    8080}
    8181
     82bool ShadowValue::equals(const ShadowValue& other) const
     83{
     84    return compareCSSValuePtr(color, other.color)
     85        && compareCSSValuePtr(x, other.x)
     86        && compareCSSValuePtr(y, other.y)
     87        && compareCSSValuePtr(blur, other.blur)
     88        && compareCSSValuePtr(spread, other.spread)
     89        && compareCSSValuePtr(style, other.style);
     90}
     91
    8292void ShadowValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    8393{
  • trunk/Source/WebCore/css/ShadowValue.h

    r124768 r142444  
    4545    String customCssText() const;
    4646
     47    bool equals(const ShadowValue&) const;
     48
    4749    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
    4850
  • trunk/Source/WebCore/css/StylePropertySet.cpp

    r141570 r142444  
    323323        return String();
    324324
    325     bool showLeft = right.value()->cssText() != left.value()->cssText();
    326     bool showBottom = (top.value()->cssText() != bottom.value()->cssText()) || showLeft;
    327     bool showRight = (top.value()->cssText() != right.value()->cssText()) || showBottom;
     325    bool showLeft = !right.value()->equals(*left.value());
     326    bool showBottom = !top.value()->equals(*bottom.value()) || showLeft;
     327    bool showRight = !top.value()->equals(*right.value()) || showBottom;
    328328
    329329    StringBuilder result;
     
    11151115    if (foundPropertyIndex == -1)
    11161116        return false;
    1117     return propertyAt(foundPropertyIndex).value()->cssText() == property.value()->cssText();
     1117    return propertyAt(foundPropertyIndex).value()->equals(*property.value());
    11181118}
    11191119   
  • trunk/Source/WebCore/css/WebKitCSSArrayFunctionValue.cpp

    r127869 r142444  
    5757}
    5858
     59bool WebKitCSSArrayFunctionValue::equals(const WebKitCSSArrayFunctionValue& other) const
     60{
     61    return CSSValueList::equals(other);
     62}
     63
    5964void WebKitCSSArrayFunctionValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    6065{
  • trunk/Source/WebCore/css/WebKitCSSArrayFunctionValue.h

    r127682 r142444  
    4949    PassRefPtr<WebKitCSSArrayFunctionValue> cloneForCSSOM() const;
    5050
     51    bool equals(const WebKitCSSArrayFunctionValue&) const;
     52
    5153    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
    5254
  • trunk/Source/WebCore/css/WebKitCSSFilterValue.cpp

    r127869 r142444  
    112112}
    113113
     114bool WebKitCSSFilterValue::equals(const WebKitCSSFilterValue& other) const
     115{
     116    return m_type == other.m_type && CSSValueList::equals(other);
     117}
     118
    114119void WebKitCSSFilterValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    115120{
  • trunk/Source/WebCore/css/WebKitCSSFilterValue.h

    r124768 r142444  
    6969    PassRefPtr<WebKitCSSFilterValue> cloneForCSSOM() const;
    7070
     71    bool equals(const WebKitCSSFilterValue&) const;
     72
    7173    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
    7274
  • trunk/Source/WebCore/css/WebKitCSSMixFunctionValue.cpp

    r127869 r142444  
    5757}
    5858
     59bool WebKitCSSMixFunctionValue::equals(const WebKitCSSMixFunctionValue& other) const
     60{
     61    return CSSValueList::equals(other);
     62}
     63
    5964void WebKitCSSMixFunctionValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    6065{
  • trunk/Source/WebCore/css/WebKitCSSMixFunctionValue.h

    r128418 r142444  
    4949    PassRefPtr<WebKitCSSMixFunctionValue> cloneForCSSOM() const;
    5050
     51    bool equals(const WebKitCSSMixFunctionValue&) const;
     52
    5153    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
    5254
  • trunk/Source/WebCore/css/WebKitCSSSVGDocumentValue.cpp

    r141570 r142444  
    6868}
    6969
     70bool WebKitCSSSVGDocumentValue::equals(const WebKitCSSSVGDocumentValue& other) const
     71{
     72    return m_url == other.m_url;
     73}
     74
    7075void WebKitCSSSVGDocumentValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    7176{
  • trunk/Source/WebCore/css/WebKitCSSSVGDocumentValue.h

    r124768 r142444  
    4545    const String& url() const { return m_url; }
    4646    bool loadRequested() const { return m_loadRequested; }
     47    bool equals(const WebKitCSSSVGDocumentValue&) const;
    4748
    4849    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
  • trunk/Source/WebCore/css/WebKitCSSShaderValue.cpp

    r141570 r142444  
    8484}
    8585
     86bool WebKitCSSShaderValue::equals(const WebKitCSSShaderValue& other) const
     87{
     88    return m_url == other.m_url;
     89}
     90
    8691void WebKitCSSShaderValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    8792{
  • trunk/Source/WebCore/css/WebKitCSSShaderValue.h

    r124768 r142444  
    5151    String customCssText() const;
    5252
     53    bool equals(const WebKitCSSShaderValue&) const;
     54
    5355    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
    5456
  • trunk/Source/WebCore/css/WebKitCSSTransformValue.h

    r124768 r142444  
    6767
    6868    String customCssText() const;
     69    bool equals(const WebKitCSSTransformValue& other) const { return m_type == other.m_type && CSSValueList::equals(other); }
    6970#if ENABLE(CSS_VARIABLES)
    7071    String customSerializeResolvingVariables(const HashMap<AtomicString, String>&) const;
  • trunk/Source/WebCore/editing/EditingStyle.cpp

    r142375 r142444  
    246246    RefPtr<CSSValue> styleValue = style->getPropertyCSSValue(m_propertyID);
    247247   
    248     // FIXME: This is very inefficient way of comparing values
    249     // but we can't string compare attribute value and CSS property value.
    250     return value && styleValue && value->cssText() == styleValue->cssText();
     248    return compareCSSValuePtr(value, styleValue);
    251249}
    252250
  • trunk/Source/WebCore/svg/SVGColor.cpp

    r127869 r142444  
    106106}
    107107
     108bool SVGColor::equals(const SVGColor& other) const
     109{
     110    return m_colorType == other.m_colorType && m_color == other.m_color;
     111}
     112
    108113void SVGColor::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    109114{
  • trunk/Source/WebCore/svg/SVGColor.h

    r124768 r142444  
    7676    PassRefPtr<SVGColor> cloneForCSSOM() const;
    7777
     78    bool equals(const SVGColor&) const;
     79
    7880    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
    7981
  • trunk/Source/WebCore/svg/SVGPaint.cpp

    r141570 r142444  
    113113}
    114114
     115bool SVGPaint::equals(const SVGPaint& other) const
     116{
     117    return m_paintType == other.m_paintType && m_uri == other.m_uri && SVGColor::equals(other);
     118}
     119
    115120void SVGPaint::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    116121{
  • trunk/Source/WebCore/svg/SVGPaint.h

    r124768 r142444  
    9696    PassRefPtr<SVGPaint> cloneForCSSOM() const;
    9797
     98    bool equals(const SVGPaint&) const;
     99
    98100    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
    99101
Note: See TracChangeset for help on using the changeset viewer.