Changeset 173175 in webkit


Ignore:
Timestamp:
Sep 2, 2014 9:06:23 AM (10 years ago)
Author:
gyuyoung.kim@samsung.com
Message:

Introduce CSS_BASIC_TYPE_CASTS, and use it
https://bugs.webkit.org/show_bug.cgi?id=136403

Reviewed by Darin Adler.

toCSSBasicFoo() will help to detect wrong type casting. So this patch generates it, and use it
instead of static_cast<const CSSBasicFoo*>().

No new tests no behavior changes.

  • css/BasicShapeFunctions.cpp:

(WebCore::basicShapeForValue):

  • css/CSSBasicShapes.cpp:

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

  • css/CSSBasicShapes.h:
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r173173 r173175  
     12014-09-02  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
     2
     3        Introduce CSS_BASIC_TYPE_CASTS, and use it
     4        https://bugs.webkit.org/show_bug.cgi?id=136403
     5
     6        Reviewed by Darin Adler.
     7
     8        toCSSBasicFoo() will help to detect wrong type casting. So this patch generates it, and use it
     9        instead of static_cast<const CSSBasicFoo*>().
     10
     11        No new tests no behavior changes.
     12
     13        * css/BasicShapeFunctions.cpp:
     14        (WebCore::basicShapeForValue):
     15        * css/CSSBasicShapes.cpp:
     16        (WebCore::CSSBasicShapeCircle::equals):
     17        (WebCore::CSSBasicShapeEllipse::equals):
     18        (WebCore::CSSBasicShapePolygon::equals):
     19        (WebCore::CSSBasicShapeInset::equals):
     20        * css/CSSBasicShapes.h:
     21
    1222014-09-02  Youenn Fablet  <youenn.fablet@crf.canon.fr>
    223
  • trunk/Source/WebCore/css/BasicShapeFunctions.cpp

    r172536 r173175  
    206206    switch (basicShapeValue->type()) {
    207207    case CSSBasicShape::CSSBasicShapeCircleType: {
    208         const CSSBasicShapeCircle* circleValue = static_cast<const CSSBasicShapeCircle *>(basicShapeValue);
     208        const CSSBasicShapeCircle* circleValue = toCSSBasicShapeCircle(basicShapeValue);
    209209        RefPtr<BasicShapeCircle> circle = BasicShapeCircle::create();
    210210
     
    217217    }
    218218    case CSSBasicShape::CSSBasicShapeEllipseType: {
    219         const CSSBasicShapeEllipse* ellipseValue = static_cast<const CSSBasicShapeEllipse *>(basicShapeValue);
     219        const CSSBasicShapeEllipse* ellipseValue = toCSSBasicShapeEllipse(basicShapeValue);
    220220        RefPtr<BasicShapeEllipse> ellipse = BasicShapeEllipse::create();
    221221
     
    230230    }
    231231    case CSSBasicShape::CSSBasicShapePolygonType: {
    232         const CSSBasicShapePolygon* polygonValue = static_cast<const CSSBasicShapePolygon *>(basicShapeValue);
     232        const CSSBasicShapePolygon* polygonValue = toCSSBasicShapePolygon(basicShapeValue);
    233233        RefPtr<BasicShapePolygon> polygon = BasicShapePolygon::create();
    234234
     
    242242    }
    243243    case CSSBasicShape::CSSBasicShapeInsetType: {
    244         const CSSBasicShapeInset* rectValue = static_cast<const CSSBasicShapeInset* >(basicShapeValue);
     244        const CSSBasicShapeInset* rectValue = toCSSBasicShapeInset(basicShapeValue);
    245245        RefPtr<BasicShapeInset> rect = BasicShapeInset::create();
    246246
  • trunk/Source/WebCore/css/CSSBasicShapes.cpp

    r169406 r173175  
    129129        return false;
    130130
    131     const CSSBasicShapeCircle& other = static_cast<const CSSBasicShapeCircle&>(shape);
     131    const CSSBasicShapeCircle& other = toCSSBasicShapeCircle(shape);
    132132    return compareCSSValuePtr(m_centerX, other.m_centerX)
    133133        && compareCSSValuePtr(m_centerY, other.m_centerY)
     
    202202        return false;
    203203
    204     const CSSBasicShapeEllipse& other = static_cast<const CSSBasicShapeEllipse&>(shape);
     204    const CSSBasicShapeEllipse& other = toCSSBasicShapeEllipse(shape);
    205205    return compareCSSValuePtr(m_centerX, other.m_centerX)
    206206        && compareCSSValuePtr(m_centerY, other.m_centerY)
     
    273273        return false;
    274274
    275     const CSSBasicShapePolygon& rhs = static_cast<const CSSBasicShapePolygon&>(shape);
     275    const CSSBasicShapePolygon& rhs = toCSSBasicShapePolygon(shape);
    276276    return compareCSSValuePtr(m_referenceBox, rhs.m_referenceBox)
    277277        && compareCSSValueVector<CSSPrimitiveValue>(m_values, rhs.m_values);
     
    408408        return false;
    409409
    410     const CSSBasicShapeInset& other = static_cast<const CSSBasicShapeInset&>(shape);
     410    const CSSBasicShapeInset& other = toCSSBasicShapeInset(shape);
    411411    return compareCSSValuePtr(m_top, other.m_top)
    412412        && compareCSSValuePtr(m_right, other.m_right)
  • trunk/Source/WebCore/css/CSSBasicShapes.h

    r166909 r173175  
    6363};
    6464
     65#define CSS_BASIC_TYPE_CASTS(ToValueTypeName, predicate) \
     66    TYPE_CASTS_BASE(ToValueTypeName, CSSBasicShape, basicShape, basicShape->type() == predicate, basicShape.type() == predicate)
     67
    6568class CSSBasicShapeInset : public CSSBasicShape {
    6669public:
     
    128131};
    129132
     133CSS_BASIC_TYPE_CASTS(CSSBasicShapeInset, CSSBasicShapeInsetType)
     134
    130135class CSSBasicShapeCircle : public CSSBasicShape {
    131136public:
     
    151156    RefPtr<CSSPrimitiveValue> m_radius;
    152157};
     158
     159CSS_BASIC_TYPE_CASTS(CSSBasicShapeCircle, CSSBasicShapeCircleType)
    153160
    154161class CSSBasicShapeEllipse : public CSSBasicShape {
     
    179186};
    180187
     188CSS_BASIC_TYPE_CASTS(CSSBasicShapeEllipse, CSSBasicShapeEllipseType)
     189
    181190class CSSBasicShapePolygon : public CSSBasicShape {
    182191public:
     
    210219};
    211220
     221CSS_BASIC_TYPE_CASTS(CSSBasicShapePolygon, CSSBasicShapePolygonType)
     222
    212223} // namespace WebCore
    213224
Note: See TracChangeset for help on using the changeset viewer.