Changeset 85027 in webkit


Ignore:
Timestamp:
Apr 27, 2011 12:04:28 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-04-27 James Robinson <jamesr@chromium.org>

Reviewed by Eric Seidel.

Fix OwnPtr strict errors in RenderStyle and make StyleRareInheritedData::textShadow an OwnPtr
https://bugs.webkit.org/show_bug.cgi?id=59377

This cleans up some strict OwnPtr<> violations around text and box shadow data. ShadowData's linked list data
structure now uses OwnPtr<>s to manage memory - each entry in the list has ownership of the next ShadowData.

  • css/CSSStyleSelector.cpp: (WebCore::CSSStyleSelector::applyProperty):
  • page/animation/AnimationBase.cpp: (WebCore::blendFunc): (WebCore::PropertyWrapperShadow::PropertyWrapperShadow): (WebCore::PropertyWrapperShadow::blend):
  • rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::setTextShadow): (WebCore::RenderStyle::setBoxShadow):
  • rendering/style/RenderStyle.h: (WebCore::InheritedFlags::textShadow):
  • rendering/style/ShadowData.cpp: (WebCore::ShadowData::ShadowData):
  • rendering/style/ShadowData.h: (WebCore::ShadowData::ShadowData): (WebCore::ShadowData::next): (WebCore::ShadowData::setNext):
  • rendering/style/StyleRareInheritedData.cpp: (WebCore::StyleRareInheritedData::StyleRareInheritedData): (WebCore::StyleRareInheritedData::~StyleRareInheritedData):
  • rendering/style/StyleRareInheritedData.h:
  • rendering/style/StyleRareNonInheritedData.cpp: (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
Location:
trunk/Source/WebCore
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r85020 r85027  
     12011-04-27  James Robinson  <jamesr@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Fix OwnPtr strict errors in RenderStyle and make StyleRareInheritedData::textShadow an OwnPtr
     6        https://bugs.webkit.org/show_bug.cgi?id=59377
     7
     8        This cleans up some strict OwnPtr<> violations around text and box shadow data.  ShadowData's linked list data
     9        structure now uses OwnPtr<>s to manage memory - each entry in the list has ownership of the next ShadowData.
     10
     11        * css/CSSStyleSelector.cpp:
     12        (WebCore::CSSStyleSelector::applyProperty):
     13        * page/animation/AnimationBase.cpp:
     14        (WebCore::blendFunc):
     15        (WebCore::PropertyWrapperShadow::PropertyWrapperShadow):
     16        (WebCore::PropertyWrapperShadow::blend):
     17        * rendering/style/RenderStyle.cpp:
     18        (WebCore::RenderStyle::setTextShadow):
     19        (WebCore::RenderStyle::setBoxShadow):
     20        * rendering/style/RenderStyle.h:
     21        (WebCore::InheritedFlags::textShadow):
     22        * rendering/style/ShadowData.cpp:
     23        (WebCore::ShadowData::ShadowData):
     24        * rendering/style/ShadowData.h:
     25        (WebCore::ShadowData::ShadowData):
     26        (WebCore::ShadowData::next):
     27        (WebCore::ShadowData::setNext):
     28        * rendering/style/StyleRareInheritedData.cpp:
     29        (WebCore::StyleRareInheritedData::StyleRareInheritedData):
     30        (WebCore::StyleRareInheritedData::~StyleRareInheritedData):
     31        * rendering/style/StyleRareInheritedData.h:
     32        * rendering/style/StyleRareNonInheritedData.cpp:
     33        (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
     34
    1352011-04-26  David Levin  <levin@chromium.org>
    236
  • trunk/Source/WebCore/css/CSSStyleSelector.cpp

    r84991 r85027  
    51295129        if (isInherit) {
    51305130            if (id == CSSPropertyTextShadow)
    5131                 return m_style->setTextShadow(m_parentStyle->textShadow() ? new ShadowData(*m_parentStyle->textShadow()) : 0);
    5132             return m_style->setBoxShadow(m_parentStyle->boxShadow() ? new ShadowData(*m_parentStyle->boxShadow()) : 0);
     5131                return m_style->setTextShadow(m_parentStyle->textShadow() ? adoptPtr(new ShadowData(*m_parentStyle->textShadow())) : PassOwnPtr<ShadowData>());
     5132            return m_style->setBoxShadow(m_parentStyle->boxShadow() ? adoptPtr(new ShadowData(*m_parentStyle->boxShadow())) : PassOwnPtr<ShadowData>());
    51335133        }
    51345134        if (isInitial || primitiveValue) // initial | none
    5135             return id == CSSPropertyTextShadow ? m_style->setTextShadow(0) : m_style->setBoxShadow(0);
     5135            return id == CSSPropertyTextShadow ? m_style->setTextShadow(PassOwnPtr<ShadowData>()) : m_style->setBoxShadow(PassOwnPtr<ShadowData>());
    51365136
    51375137        if (!value->isValueList())
     
    51535153            if (item->color)
    51545154                color = getColorFromPrimitiveValue(item->color.get());
    5155             ShadowData* shadowData = new ShadowData(x, y, blur, spread, shadowStyle, id == CSSPropertyWebkitBoxShadow, color.isValid() ? color : Color::transparent);
     5155            OwnPtr<ShadowData> shadowData = adoptPtr(new ShadowData(x, y, blur, spread, shadowStyle, id == CSSPropertyWebkitBoxShadow, color.isValid() ? color : Color::transparent));
    51565156            if (id == CSSPropertyTextShadow)
    5157                 m_style->setTextShadow(shadowData, i != 0);
     5157                m_style->setTextShadow(shadowData.release(), i /* add to the list if this is not the firsty entry */);
    51585158            else
    5159                 m_style->setBoxShadow(shadowData, i != 0);
     5159                m_style->setBoxShadow(shadowData.release(), i /* add to the list if this is not the firsty entry */);
    51605160        }
    51615161        return;
  • trunk/Source/WebCore/page/animation/AnimationBase.cpp

    r84901 r85027  
    140140}
    141141
    142 static inline ShadowData* blendFunc(const AnimationBase* anim, const ShadowData* from, const ShadowData* to, double progress)
     142static inline PassOwnPtr<ShadowData> blendFunc(const AnimationBase* anim, const ShadowData* from, const ShadowData* to, double progress)
    143143
    144144    ASSERT(from && to);
    145145    if (from->style() != to->style())
    146         return new ShadowData(*to);
    147 
    148     return new ShadowData(blendFunc(anim, from->x(), to->x(), progress),
    149                           blendFunc(anim, from->y(), to->y(), progress),
    150                           blendFunc(anim, from->blur(), to->blur(), progress),
    151                           blendFunc(anim, from->spread(), to->spread(), progress),
    152                           blendFunc(anim, from->style(), to->style(), progress),
    153                           from->isWebkitBoxShadow(),
    154                           blendFunc(anim, from->color(), to->color(), progress));
     146        return adoptPtr(new ShadowData(*to));
     147
     148    return adoptPtr(new ShadowData(blendFunc(anim, from->x(), to->x(), progress),
     149                                   blendFunc(anim, from->y(), to->y(), progress),
     150                                   blendFunc(anim, from->blur(), to->blur(), progress),
     151                                   blendFunc(anim, from->spread(), to->spread(), progress),
     152                                   blendFunc(anim, from->style(), to->style(), progress),
     153                                   from->isWebkitBoxShadow(),
     154                                   blendFunc(anim, from->color(), to->color(), progress)));
    155155}
    156156
     
    330330class PropertyWrapperShadow : public PropertyWrapperBase {
    331331public:
    332     PropertyWrapperShadow(int prop, const ShadowData* (RenderStyle::*getter)() const, void (RenderStyle::*setter)(ShadowData*, bool))
     332    PropertyWrapperShadow(int prop, const ShadowData* (RenderStyle::*getter)() const, void (RenderStyle::*setter)(PassOwnPtr<ShadowData>, bool))
    333333        : PropertyWrapperBase(prop)
    334334        , m_getter(getter)
     
    366366        ShadowData defaultInsetShadowData(0, 0, 0, 0, Inset, property() == CSSPropertyWebkitBoxShadow, Color::transparent);
    367367
    368         ShadowData* newShadowData = 0;
     368        OwnPtr<ShadowData> newShadowData;
    369369        ShadowData* lastShadow = 0;
    370370       
     
    373373            const ShadowData* dstShadow = shadowB ? shadowB : (shadowA->style() == Inset ? &defaultInsetShadowData : &defaultShadowData);
    374374
    375             ShadowData* blendedShadow = blendFunc(anim, srcShadow, dstShadow, progress);
     375            OwnPtr<ShadowData> blendedShadow = blendFunc(anim, srcShadow, dstShadow, progress);
     376            ShadowData* blendedShadowPtr = blendedShadow.get();
     377
    376378            if (!lastShadow)
    377                 newShadowData = blendedShadow;
     379                newShadowData = blendedShadow.release();
    378380            else
    379                 lastShadow->setNext(blendedShadow);
    380 
    381             lastShadow = blendedShadow;
     381                lastShadow->setNext(blendedShadow.release());
     382           
     383            lastShadow = blendedShadowPtr;
    382384
    383385            shadowA = shadowA ? shadowA->next() : 0;
     
    385387        }
    386388       
    387         (dst->*m_setter)(newShadowData, false);
     389        (dst->*m_setter)(newShadowData.release(), false);
    388390    }
    389391
    390392private:
    391393    const ShadowData* (RenderStyle::*m_getter)() const;
    392     void (RenderStyle::*m_setter)(ShadowData*, bool);
     394    void (RenderStyle::*m_setter)(PassOwnPtr<ShadowData>, bool);
    393395};
    394396
  • trunk/Source/WebCore/rendering/style/RenderStyle.cpp

    r84901 r85027  
    729729}
    730730
    731 void RenderStyle::setTextShadow(ShadowData* val, bool add)
    732 {
    733     ASSERT(!val || (!val->spread() && val->style() == Normal));
     731void RenderStyle::setTextShadow(PassOwnPtr<ShadowData> shadowData, bool add)
     732{
     733    ASSERT(!shadowData || (!shadowData->spread() && shadowData->style() == Normal));
    734734
    735735    StyleRareInheritedData* rareData = rareInheritedData.access();
    736736    if (!add) {
    737         delete rareData->textShadow;
    738         rareData->textShadow = val;
     737        rareData->textShadow = shadowData;
    739738        return;
    740739    }
    741740
    742     val->setNext(rareData->textShadow);
    743     rareData->textShadow = val;
    744 }
    745 
    746 void RenderStyle::setBoxShadow(ShadowData* shadowData, bool add)
     741    shadowData->setNext(rareData->textShadow.release());
     742    rareData->textShadow = shadowData;
     743}
     744
     745void RenderStyle::setBoxShadow(PassOwnPtr<ShadowData> shadowData, bool add)
    747746{
    748747    StyleRareNonInheritedData* rareData = rareNonInheritedData.access();
    749748    if (!add) {
    750         rareData->m_boxShadow.set(shadowData);
     749        rareData->m_boxShadow = shadowData;
    751750        return;
    752751    }
    753752
    754     shadowData->setNext(rareData->m_boxShadow.leakPtr());
    755     rareData->m_boxShadow.set(shadowData);
     753    shadowData->setNext(rareData->m_boxShadow.release());
     754    rareData->m_boxShadow = shadowData;
    756755}
    757756
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r84901 r85027  
    651651    }
    652652
    653     const ShadowData* textShadow() const { return rareInheritedData->textShadow; }
     653    const ShadowData* textShadow() const { return rareInheritedData->textShadow.get(); }
    654654    void getTextShadowExtent(int& top, int& right, int& bottom, int& left) const { getShadowExtent(textShadow(), top, right, bottom, left); }
    655655    void getTextShadowHorizontalExtent(int& left, int& right) const { getShadowHorizontalExtent(textShadow(), left, right); }
     
    10201020    // CSS3 Setters
    10211021    void setOutlineOffset(int v) { SET_VAR(m_background, m_outline.m_offset, v) }
    1022     void setTextShadow(ShadowData* val, bool add=false);
     1022    void setTextShadow(PassOwnPtr<ShadowData>, bool add = false);
    10231023    void setTextStrokeColor(const Color& c) { SET_VAR(rareInheritedData, textStrokeColor, c) }
    10241024    void setTextStrokeWidth(float w) { SET_VAR(rareInheritedData, textStrokeWidth, w) }
     
    10351035    void setBoxOrient(EBoxOrient o) { SET_VAR(rareNonInheritedData.access()->flexibleBox, orient, o); }
    10361036    void setBoxPack(EBoxAlignment p) { SET_VAR(rareNonInheritedData.access()->flexibleBox, pack, p); }
    1037     void setBoxShadow(ShadowData* val, bool add=false);
     1037    void setBoxShadow(PassOwnPtr<ShadowData>, bool add = false);
    10381038    void setBoxReflect(PassRefPtr<StyleReflection> reflect) { if (rareNonInheritedData->m_boxReflect != reflect) rareNonInheritedData.access()->m_boxReflect = reflect; }
    10391039    void setBoxSizing(EBoxSizing s) { SET_VAR(m_box, m_boxSizing, s); }
  • trunk/Source/WebCore/rendering/style/ShadowData.cpp

    r74538 r85027  
    3838    , m_style(o.m_style)
    3939    , m_isWebkitBoxShadow(o.m_isWebkitBoxShadow)
     40    , m_next(o.m_next ? adoptPtr(new ShadowData(*o.m_next)) : PassOwnPtr<ShadowData>())
    4041{
    41     m_next = o.m_next ? new ShadowData(*o.m_next) : 0;
    4242}
    4343
  • trunk/Source/WebCore/rendering/style/ShadowData.h

    r76248 r85027  
    2727
    2828#include "Color.h"
     29#include <wtf/OwnPtr.h>
     30#include <wtf/PassOwnPtr.h>
    2931
    3032namespace WebCore {
     
    3537enum ShadowStyle { Normal, Inset };
    3638
    37 // This struct holds information about shadows for the text-shadow and box-shadow properties.
     39// This class holds information about shadows for the text-shadow and box-shadow properties.
    3840
    3941class ShadowData {
     
    4749        , m_style(Normal)
    4850        , m_isWebkitBoxShadow(false)
    49         , m_next(0)
    5051    {
    5152    }
     
    5960        , m_style(style)
    6061        , m_isWebkitBoxShadow(isWebkitBoxShadow)
    61         , m_next(0)
    6262    {
    6363    }
    6464
    6565    ShadowData(const ShadowData& o);
    66     ~ShadowData() { delete m_next; }
    6766
    6867    bool operator==(const ShadowData& o) const;
     
    8079    bool isWebkitBoxShadow() const { return m_isWebkitBoxShadow; }
    8180
    82     const ShadowData* next() const { return m_next; }
    83     void setNext(ShadowData* shadow) { m_next = shadow; }
     81    const ShadowData* next() const { return m_next.get(); }
     82    void setNext(PassOwnPtr<ShadowData> shadow) { m_next = shadow; }
    8483
    8584    void adjustRectForShadow(IntRect&, int additionalOutlineSize = 0) const;
     
    9493    ShadowStyle m_style;
    9594    bool m_isWebkitBoxShadow;
    96     ShadowData* m_next;
     95    OwnPtr<ShadowData> m_next;
    9796};
    9897
  • trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp

    r84901 r85027  
    3333StyleRareInheritedData::StyleRareInheritedData()
    3434    : textStrokeWidth(RenderStyle::initialTextStrokeWidth())
    35     , textShadow(0)
    3635    , indent(RenderStyle::initialTextIndent())
    3736    , m_effectiveZoom(RenderStyle::initialZoom())
     
    6564    , textFillColor(o.textFillColor)
    6665    , textEmphasisColor(o.textEmphasisColor)
    67     , textShadow(o.textShadow ? new ShadowData(*o.textShadow) : 0)
     66    , textShadow(o.textShadow ? adoptPtr(new ShadowData(*o.textShadow)) : PassOwnPtr<ShadowData>())
    6867    , highlight(o.highlight)
    6968    , cursorData(o.cursorData)
     
    9897StyleRareInheritedData::~StyleRareInheritedData()
    9998{
    100     delete textShadow;
    10199}
    102100
  • trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h

    r84901 r85027  
    5959    Color textEmphasisColor;
    6060
    61     ShadowData* textShadow; // Our text shadow information for shadowed text drawing.
     61    OwnPtr<ShadowData> textShadow; // Our text shadow information for shadowed text drawing.
    6262    AtomicString highlight; // Apple-specific extension for custom highlight rendering.
    6363   
  • trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp

    r84901 r85027  
    3535    : lineClamp(RenderStyle::initialLineClamp())
    3636    , opacity(RenderStyle::initialOpacity())
    37     , m_content(0)
    38     , m_counterDirectives(0)
    3937    , userDrag(RenderStyle::initialUserDrag())
    4038    , textOverflow(RenderStyle::initialTextOverflow())
     
    5048    , m_runningAcceleratedAnimation(false)
    5149#endif
    52     , m_boxShadow(0)
    53     , m_animations(0)
    54     , m_transitions(0)
    5550    , m_mask(FillLayer(MaskFillLayer))
    5651    , m_transformStyle3D(RenderStyle::initialTransformStyle3D())
     
    7267    , m_multiCol(o.m_multiCol)
    7368    , m_transform(o.m_transform)
    74     , m_content(0)
    75     , m_counterDirectives(0)
    7669    , userDrag(o.userDrag)
    7770    , textOverflow(o.textOverflow)
     
    8780    , m_runningAcceleratedAnimation(o.m_runningAcceleratedAnimation)
    8881#endif
    89     , m_boxShadow(o.m_boxShadow ? new ShadowData(*o.m_boxShadow) : 0)
     82    , m_boxShadow(o.m_boxShadow ? adoptPtr(new ShadowData(*o.m_boxShadow)) : PassOwnPtr<ShadowData>())
    9083    , m_boxReflect(o.m_boxReflect)
    91     , m_animations(o.m_animations ? new AnimationList(*o.m_animations) : 0)
    92     , m_transitions(o.m_transitions ? new AnimationList(*o.m_transitions) : 0)
     84    , m_animations(o.m_animations ? adoptPtr(new AnimationList(*o.m_animations)) : PassOwnPtr<AnimationList>())
     85    , m_transitions(o.m_transitions ? adoptPtr(new AnimationList(*o.m_transitions)) : PassOwnPtr<AnimationList>())
    9386    , m_mask(o.m_mask)
    9487    , m_maskBoxImage(o.m_maskBoxImage)
Note: See TracChangeset for help on using the changeset viewer.