Changeset 161115 in webkit
- Timestamp:
- Dec 28, 2013, 5:36:19 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r161113 r161115 1 2013-12-28 Andreas Kling <akling@apple.com> 2 3 Add an owning smart pointer for RenderObjects and start using it. 4 <https://webkit.org/b/126251> 5 6 This patch adds a RenderPtr pointer, essentially an OwnPtr for 7 RenderObjects. The difference is that RenderPtr destroys the object 8 by calling destroy() on it. 9 10 This is necessary to implement the willBeDestroyed() mechanism in 11 RenderObject that notifies renderers just before they are about to 12 be deleted, while they can still do tree traversal, etc. 13 14 I also added a make_unique-alike helper so you can write: 15 16 auto renderer = createRenderObject<RenderImage>(...); 17 18 Put it all to use by making ContentData::createRenderer() return 19 RenderPtr<RenderObject> instead of raw RenderObject*. 20 21 Reviewed by Antti Koivisto. 22 1 23 2013-12-28 Benjamin Poulain <benjamin@webkit.org> 2 24 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r161106 r161115 10981 10981 ADDF1AD41257CD9A0003A759 /* RenderSVGPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGPath.cpp; sourceTree = "<group>"; }; 10982 10982 ADDF1AD51257CD9A0003A759 /* RenderSVGPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGPath.h; sourceTree = "<group>"; }; 10983 ADE16736181050C300463A2E /* RenderPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderPtr.h; sourceTree = "<group>"; }; 10983 10984 B10B697D140C174000BC1C26 /* WebVTTToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebVTTToken.h; sourceTree = "<group>"; }; 10984 10985 B10B697E140C174000BC1C26 /* WebVTTTokenizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebVTTTokenizer.cpp; sourceTree = "<group>"; }; … … 21325 21326 A43BF59A1149292800C643CA /* RenderProgress.cpp */, 21326 21327 A43BF59B1149292800C643CA /* RenderProgress.h */, 21328 ADE16736181050C300463A2E /* RenderPtr.h */, 21327 21329 5A574F22131DB93900471B88 /* RenderQuote.cpp */, 21328 21330 5A574F23131DB93900471B88 /* RenderQuote.h */, -
trunk/Source/WebCore/dom/PseudoElement.cpp
r159989 r161115 84 84 return; 85 85 86 RenderStyle& style = renderer->style();86 const RenderStyle& style = renderer->style(); 87 87 ASSERT(style.contentData()); 88 88 89 89 for (const ContentData* content = style.contentData(); content; content = content->next()) { 90 Render Object*child = content->createRenderer(document(), style);90 RenderPtr<RenderObject> child = content->createRenderer(document(), style); 91 91 if (renderer->isChildAllowed(*child, style)) { 92 renderer->addChild(child);93 if (child->isQuote())94 toRenderQuote(child)->attachQuote();95 } else96 child->destroy();92 auto* childPtr = child.get(); 93 renderer->addChild(child.leakPtr()); 94 if (childPtr->isQuote()) 95 toRenderQuote(childPtr)->attachQuote(); 96 } 97 97 } 98 98 } -
trunk/Source/WebCore/rendering/style/ContentData.cpp
r159989 r161115 48 48 } 49 49 50 Render Object* ImageContentData::createRenderer(Document& document,RenderStyle& pseudoStyle) const50 RenderPtr<RenderObject> ImageContentData::createRenderer(Document& document, const RenderStyle& pseudoStyle) const 51 51 { 52 RenderImage* image = new RenderImage(document, RenderImage::createStyleInheritingFromPseudoStyle(pseudoStyle));52 auto image = createRenderObject<RenderImage>(document, RenderImage::createStyleInheritingFromPseudoStyle(pseudoStyle)); 53 53 image->initializeStyle(); 54 54 image->setAltText(altText()); … … 57 57 else 58 58 image->setImageResource(RenderImageResource::create()); 59 return image;59 return std::move(image); 60 60 } 61 61 62 Render Object* TextContentData::createRenderer(Document& document,RenderStyle&) const62 RenderPtr<RenderObject> TextContentData::createRenderer(Document& document, const RenderStyle&) const 63 63 { 64 RenderTextFragment* fragment = new RenderTextFragment(document, m_text);64 auto fragment = createRenderObject<RenderTextFragment>(document, m_text); 65 65 fragment->setAltText(altText()); 66 return fragment;66 return std::move(fragment); 67 67 } 68 68 69 Render Object* CounterContentData::createRenderer(Document& document,RenderStyle&) const69 RenderPtr<RenderObject> CounterContentData::createRenderer(Document& document, const RenderStyle&) const 70 70 { 71 return new RenderCounter(document, *m_counter);71 return createRenderObject<RenderCounter>(document, *m_counter); 72 72 } 73 73 74 Render Object* QuoteContentData::createRenderer(Document& document,RenderStyle&) const74 RenderPtr<RenderObject> QuoteContentData::createRenderer(Document& document, const RenderStyle&) const 75 75 { 76 return new RenderQuote(document, m_quote);76 return createRenderObject<RenderQuote>(document, m_quote); 77 77 } 78 78 -
trunk/Source/WebCore/rendering/style/ContentData.h
r159591 r161115 28 28 #include "CounterContent.h" 29 29 #include "StyleImage.h" 30 #include "RenderPtr.h" 30 31 #include <wtf/OwnPtr.h> 31 32 … … 46 47 virtual bool isText() const { return false; } 47 48 48 virtual Render Object* createRenderer(Document&,RenderStyle&) const = 0;49 virtual RenderPtr<RenderObject> createRenderer(Document&, const RenderStyle&) const = 0; 49 50 50 51 std::unique_ptr<ContentData> clone() const; … … 77 78 78 79 virtual bool isImage() const OVERRIDE { return true; } 79 virtual Render Object* createRenderer(Document&,RenderStyle&) const OVERRIDE;80 virtual RenderPtr<RenderObject> createRenderer(Document&, const RenderStyle&) const OVERRIDE; 80 81 81 82 virtual bool equals(const ContentData& data) const OVERRIDE … … 108 109 109 110 virtual bool isText() const OVERRIDE { return true; } 110 virtual Render Object* createRenderer(Document&,RenderStyle&) const OVERRIDE;111 virtual RenderPtr<RenderObject> createRenderer(Document&, const RenderStyle&) const OVERRIDE; 111 112 112 113 virtual bool equals(const ContentData& data) const OVERRIDE … … 134 135 135 136 virtual bool isCounter() const OVERRIDE { return true; } 136 virtual Render Object* createRenderer(Document&,RenderStyle&) const OVERRIDE;137 virtual RenderPtr<RenderObject> createRenderer(Document&, const RenderStyle&) const OVERRIDE; 137 138 138 139 private: … … 164 165 165 166 virtual bool isQuote() const OVERRIDE { return true; } 166 virtual Render Object* createRenderer(Document&,RenderStyle&) const OVERRIDE;167 virtual RenderPtr<RenderObject> createRenderer(Document&, const RenderStyle&) const OVERRIDE; 167 168 168 169 virtual bool equals(const ContentData& data) const OVERRIDE
Note:
See TracChangeset
for help on using the changeset viewer.