Changeset 85027 in webkit
- Timestamp:
- Apr 27, 2011 12:04:28 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r85020 r85027 1 2011-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 1 35 2011-04-26 David Levin <levin@chromium.org> 2 36 -
trunk/Source/WebCore/css/CSSStyleSelector.cpp
r84991 r85027 5129 5129 if (isInherit) { 5130 5130 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>()); 5133 5133 } 5134 5134 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>()); 5136 5136 5137 5137 if (!value->isValueList()) … … 5153 5153 if (item->color) 5154 5154 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)); 5156 5156 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 */); 5158 5158 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 */); 5160 5160 } 5161 5161 return; -
trunk/Source/WebCore/page/animation/AnimationBase.cpp
r84901 r85027 140 140 } 141 141 142 static inline ShadowData*blendFunc(const AnimationBase* anim, const ShadowData* from, const ShadowData* to, double progress)142 static inline PassOwnPtr<ShadowData> blendFunc(const AnimationBase* anim, const ShadowData* from, const ShadowData* to, double progress) 143 143 { 144 144 ASSERT(from && to); 145 145 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))); 155 155 } 156 156 … … 330 330 class PropertyWrapperShadow : public PropertyWrapperBase { 331 331 public: 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)) 333 333 : PropertyWrapperBase(prop) 334 334 , m_getter(getter) … … 366 366 ShadowData defaultInsetShadowData(0, 0, 0, 0, Inset, property() == CSSPropertyWebkitBoxShadow, Color::transparent); 367 367 368 ShadowData* newShadowData = 0;368 OwnPtr<ShadowData> newShadowData; 369 369 ShadowData* lastShadow = 0; 370 370 … … 373 373 const ShadowData* dstShadow = shadowB ? shadowB : (shadowA->style() == Inset ? &defaultInsetShadowData : &defaultShadowData); 374 374 375 ShadowData* blendedShadow = blendFunc(anim, srcShadow, dstShadow, progress); 375 OwnPtr<ShadowData> blendedShadow = blendFunc(anim, srcShadow, dstShadow, progress); 376 ShadowData* blendedShadowPtr = blendedShadow.get(); 377 376 378 if (!lastShadow) 377 newShadowData = blendedShadow ;379 newShadowData = blendedShadow.release(); 378 380 else 379 lastShadow->setNext(blendedShadow );380 381 lastShadow = blendedShadow ;381 lastShadow->setNext(blendedShadow.release()); 382 383 lastShadow = blendedShadowPtr; 382 384 383 385 shadowA = shadowA ? shadowA->next() : 0; … … 385 387 } 386 388 387 (dst->*m_setter)(newShadowData , false);389 (dst->*m_setter)(newShadowData.release(), false); 388 390 } 389 391 390 392 private: 391 393 const ShadowData* (RenderStyle::*m_getter)() const; 392 void (RenderStyle::*m_setter)( ShadowData*, bool);394 void (RenderStyle::*m_setter)(PassOwnPtr<ShadowData>, bool); 393 395 }; 394 396 -
trunk/Source/WebCore/rendering/style/RenderStyle.cpp
r84901 r85027 729 729 } 730 730 731 void RenderStyle::setTextShadow( ShadowData* val, bool add)732 { 733 ASSERT(! val || (!val->spread() && val->style() == Normal));731 void RenderStyle::setTextShadow(PassOwnPtr<ShadowData> shadowData, bool add) 732 { 733 ASSERT(!shadowData || (!shadowData->spread() && shadowData->style() == Normal)); 734 734 735 735 StyleRareInheritedData* rareData = rareInheritedData.access(); 736 736 if (!add) { 737 delete rareData->textShadow; 738 rareData->textShadow = val; 737 rareData->textShadow = shadowData; 739 738 return; 740 739 } 741 740 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 745 void RenderStyle::setBoxShadow(PassOwnPtr<ShadowData> shadowData, bool add) 747 746 { 748 747 StyleRareNonInheritedData* rareData = rareNonInheritedData.access(); 749 748 if (!add) { 750 rareData->m_boxShadow .set(shadowData);749 rareData->m_boxShadow = shadowData; 751 750 return; 752 751 } 753 752 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; 756 755 } 757 756 -
trunk/Source/WebCore/rendering/style/RenderStyle.h
r84901 r85027 651 651 } 652 652 653 const ShadowData* textShadow() const { return rareInheritedData->textShadow ; }653 const ShadowData* textShadow() const { return rareInheritedData->textShadow.get(); } 654 654 void getTextShadowExtent(int& top, int& right, int& bottom, int& left) const { getShadowExtent(textShadow(), top, right, bottom, left); } 655 655 void getTextShadowHorizontalExtent(int& left, int& right) const { getShadowHorizontalExtent(textShadow(), left, right); } … … 1020 1020 // CSS3 Setters 1021 1021 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); 1023 1023 void setTextStrokeColor(const Color& c) { SET_VAR(rareInheritedData, textStrokeColor, c) } 1024 1024 void setTextStrokeWidth(float w) { SET_VAR(rareInheritedData, textStrokeWidth, w) } … … 1035 1035 void setBoxOrient(EBoxOrient o) { SET_VAR(rareNonInheritedData.access()->flexibleBox, orient, o); } 1036 1036 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); 1038 1038 void setBoxReflect(PassRefPtr<StyleReflection> reflect) { if (rareNonInheritedData->m_boxReflect != reflect) rareNonInheritedData.access()->m_boxReflect = reflect; } 1039 1039 void setBoxSizing(EBoxSizing s) { SET_VAR(m_box, m_boxSizing, s); } -
trunk/Source/WebCore/rendering/style/ShadowData.cpp
r74538 r85027 38 38 , m_style(o.m_style) 39 39 , m_isWebkitBoxShadow(o.m_isWebkitBoxShadow) 40 , m_next(o.m_next ? adoptPtr(new ShadowData(*o.m_next)) : PassOwnPtr<ShadowData>()) 40 41 { 41 m_next = o.m_next ? new ShadowData(*o.m_next) : 0;42 42 } 43 43 -
trunk/Source/WebCore/rendering/style/ShadowData.h
r76248 r85027 27 27 28 28 #include "Color.h" 29 #include <wtf/OwnPtr.h> 30 #include <wtf/PassOwnPtr.h> 29 31 30 32 namespace WebCore { … … 35 37 enum ShadowStyle { Normal, Inset }; 36 38 37 // This structholds 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. 38 40 39 41 class ShadowData { … … 47 49 , m_style(Normal) 48 50 , m_isWebkitBoxShadow(false) 49 , m_next(0)50 51 { 51 52 } … … 59 60 , m_style(style) 60 61 , m_isWebkitBoxShadow(isWebkitBoxShadow) 61 , m_next(0)62 62 { 63 63 } 64 64 65 65 ShadowData(const ShadowData& o); 66 ~ShadowData() { delete m_next; }67 66 68 67 bool operator==(const ShadowData& o) const; … … 80 79 bool isWebkitBoxShadow() const { return m_isWebkitBoxShadow; } 81 80 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; } 84 83 85 84 void adjustRectForShadow(IntRect&, int additionalOutlineSize = 0) const; … … 94 93 ShadowStyle m_style; 95 94 bool m_isWebkitBoxShadow; 96 ShadowData*m_next;95 OwnPtr<ShadowData> m_next; 97 96 }; 98 97 -
trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp
r84901 r85027 33 33 StyleRareInheritedData::StyleRareInheritedData() 34 34 : textStrokeWidth(RenderStyle::initialTextStrokeWidth()) 35 , textShadow(0)36 35 , indent(RenderStyle::initialTextIndent()) 37 36 , m_effectiveZoom(RenderStyle::initialZoom()) … … 65 64 , textFillColor(o.textFillColor) 66 65 , textEmphasisColor(o.textEmphasisColor) 67 , textShadow(o.textShadow ? new ShadowData(*o.textShadow) : 0)66 , textShadow(o.textShadow ? adoptPtr(new ShadowData(*o.textShadow)) : PassOwnPtr<ShadowData>()) 68 67 , highlight(o.highlight) 69 68 , cursorData(o.cursorData) … … 98 97 StyleRareInheritedData::~StyleRareInheritedData() 99 98 { 100 delete textShadow;101 99 } 102 100 -
trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h
r84901 r85027 59 59 Color textEmphasisColor; 60 60 61 ShadowData*textShadow; // Our text shadow information for shadowed text drawing.61 OwnPtr<ShadowData> textShadow; // Our text shadow information for shadowed text drawing. 62 62 AtomicString highlight; // Apple-specific extension for custom highlight rendering. 63 63 -
trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp
r84901 r85027 35 35 : lineClamp(RenderStyle::initialLineClamp()) 36 36 , opacity(RenderStyle::initialOpacity()) 37 , m_content(0)38 , m_counterDirectives(0)39 37 , userDrag(RenderStyle::initialUserDrag()) 40 38 , textOverflow(RenderStyle::initialTextOverflow()) … … 50 48 , m_runningAcceleratedAnimation(false) 51 49 #endif 52 , m_boxShadow(0)53 , m_animations(0)54 , m_transitions(0)55 50 , m_mask(FillLayer(MaskFillLayer)) 56 51 , m_transformStyle3D(RenderStyle::initialTransformStyle3D()) … … 72 67 , m_multiCol(o.m_multiCol) 73 68 , m_transform(o.m_transform) 74 , m_content(0)75 , m_counterDirectives(0)76 69 , userDrag(o.userDrag) 77 70 , textOverflow(o.textOverflow) … … 87 80 , m_runningAcceleratedAnimation(o.m_runningAcceleratedAnimation) 88 81 #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>()) 90 83 , 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>()) 93 86 , m_mask(o.m_mask) 94 87 , m_maskBoxImage(o.m_maskBoxImage)
Note: See TracChangeset
for help on using the changeset viewer.