Changeset 249198 in webkit
- Timestamp:
- Aug 28, 2019, 8:15:51 AM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
-
ChangeLog (modified) (1 diff)
-
dom/ElementRareData.h (modified) (1 diff)
-
dom/Node.cpp (modified) (1 diff)
-
dom/Node.h (modified) (2 diffs)
-
dom/NodeRareData.cpp (modified) (1 diff)
-
dom/NodeRareData.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r249197 r249198 1 2019-08-28 Ryosuke Niwa <rniwa@webkit.org> 2 3 REGRESSION (r248807): Objects stored in ElementRareData are leaked 4 https://bugs.webkit.org/show_bug.cgi?id=200954 5 6 Reviewed by Antti Koivisto. 7 8 Use a custom deleter in std::unique_ptr to call the correct destructor instead of making 9 NodeRareData's destructor virtual. Added NodeRareData::isElementRareData to differentiate 10 ElementRareData and NodeRareData by borrowing 1 bit from the frame count. 11 12 No new tests since there should be no behavioral change. 13 14 * dom/ElementRareData.h: 15 (WebCore::ElementRareData::ElementRareData): 16 * dom/Node.cpp: 17 (WebCore::Node::materializeRareData): Call the constructors of unique_ptr directly since 18 make_unique does not take a custom deleter. We can't add the support to makeUnique either 19 without making it three arguments since we need to cast ElementRareData to NodeRareData 20 in addition to specifying a custom deleter (normal casting wouldn't work due to 21 the presence of a custom deleter). 22 (WebCore::Node::NodeRareDataDeleter::operator() const): Added. 23 * dom/Node.h: 24 (WebCore::Node::NodeRareDataDeleter): Added. 25 * dom/NodeRareData.cpp: 26 * dom/NodeRareData.h: 27 (WebCore::NodeRareData::NodeRareData): Makes newly added Type. 28 (WebCore::NodeRareData::isElementRareData): Added. 29 (WebCore::NodeRareData::~NodeRareData): Deleted. 30 1 31 2019-08-28 Claudio Saavedra <csaavedra@igalia.com> 2 32 -
trunk/Source/WebCore/dom/ElementRareData.h
r248807 r249198 191 191 192 192 inline ElementRareData::ElementRareData() 193 : m_tabIndex(0) 193 : NodeRareData(Type::Element) 194 , m_tabIndex(0) 194 195 , m_childIndex(0) 195 196 , m_tabIndexWasSetExplicitly(false) -
trunk/Source/WebCore/dom/Node.cpp
r248846 r249198 396 396 { 397 397 if (is<Element>(*this)) 398 m_rareData = makeUnique<ElementRareData>();398 m_rareData = std::unique_ptr<NodeRareData, NodeRareDataDeleter>(new ElementRareData); 399 399 else 400 m_rareData = makeUnique<NodeRareData>(); 400 m_rareData = std::unique_ptr<NodeRareData, NodeRareDataDeleter>(new NodeRareData); 401 } 402 403 inline void Node::NodeRareDataDeleter::operator()(NodeRareData* rareData) const 404 { 405 if (rareData->isElementRareData()) 406 delete static_cast<ElementRareData*>(rareData); 407 else 408 delete static_cast<NodeRareData*>(rareData); 401 409 } 402 410 -
trunk/Source/WebCore/dom/Node.h
r248807 r249198 665 665 void moveNodeToNewDocument(Document& oldDocument, Document& newDocument); 666 666 667 struct NodeRareDataDeleter { 668 void operator()(NodeRareData*) const; 669 }; 670 667 671 uint32_t m_refCountAndParentBit { s_refCountIncrement }; 668 672 mutable uint32_t m_nodeFlags; … … 673 677 Node* m_next { nullptr }; 674 678 CompactPointerTuple<RenderObject*, uint8_t> m_rendererWithStyleFlags; 675 std::unique_ptr<NodeRareData > m_rareData;679 std::unique_ptr<NodeRareData, NodeRareDataDeleter> m_rareData; 676 680 }; 677 681 -
trunk/Source/WebCore/dom/NodeRareData.cpp
r249076 r249198 37 37 38 38 struct SameSizeAsNodeRareData { 39 unsigned m_frameCount ;40 void* m_pointer[ 3];39 unsigned m_frameCountAndIsElementRareDataFlag; 40 void* m_pointer[2]; 41 41 }; 42 42 -
trunk/Source/WebCore/dom/NodeRareData.h
r249076 r249198 271 271 #endif 272 272 273 NodeRareData() 274 { } 275 276 virtual ~NodeRareData() 277 { } 273 enum class Type { Element, Node }; 274 275 NodeRareData(Type type = Type::Node) 276 : m_connectedFrameCount(0) 277 , m_isElementRareData(type == Type::Element) 278 { 279 } 280 281 bool isElementRareData() { return m_isElementRareData; } 278 282 279 283 void clearNodeLists() { m_nodeLists = nullptr; } … … 321 325 322 326 private: 323 unsigned m_connectedFrameCount { 0 }; // Must fit Page::maxNumberOfFrames. 327 unsigned m_connectedFrameCount : 31; // Must fit Page::maxNumberOfFrames. 328 unsigned m_isElementRareData : 1; 324 329 325 330 std::unique_ptr<NodeListsNodeData> m_nodeLists;
Note:
See TracChangeset
for help on using the changeset viewer.