Changeset 243239 in webkit
- Timestamp:
- Mar 20, 2019, 2:23:02 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 6 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/css-typedom/attribute-style-map-should-not-leak-every-element-expected.txt (added)
-
LayoutTests/css-typedom/attribute-style-map-should-not-leak-every-element.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/css/typedom/StylePropertyMap.h (modified) (1 diff)
-
Source/WebCore/dom/Element.cpp (modified) (1 diff)
-
Source/WebCore/dom/StyledElement.cpp (modified) (2 diffs)
-
Source/WebCore/platform/graphics/CustomPaintImage.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r243235 r243239 1 2019-03-19 Ryosuke Niwa <rniwa@webkit.org> 2 3 [CSS OM] StyledElementInlineStylePropertyMap creates a Ref cycle with its owner element 4 https://bugs.webkit.org/show_bug.cgi?id=195987 5 6 Reviewed by Simon Fraser. 7 8 Added a regression test. 9 10 * css-typedom/attribute-style-map-should-not-leak-every-element-expected.txt: Added. 11 * css-typedom/attribute-style-map-should-not-leak-every-element.html: Added. 12 1 13 2019-03-20 Antoine Quint <graouts@apple.com> 2 14 -
trunk/Source/WebCore/ChangeLog
r243233 r243239 1 2019-03-19 Ryosuke Niwa <rniwa@webkit.org> 2 3 [CSS OM] StyledElementInlineStylePropertyMap creates a Ref cycle with its owner element 4 https://bugs.webkit.org/show_bug.cgi?id=195987 5 6 Reviewed by Simon Fraser. 7 8 StyledElementInlineStylePropertyMap was leaking every element for which it was created because due to 9 a reference cycle. The StyledElementInlineStylePropertyMap holds onto its element using Ref and 10 the element also stores StyledElementInlineStylePropertyMap in ElementRareData using RefPtr. 11 12 Fixed the cycle by making the reference from StyledElementInlineStylePropertyMap weak. For now we use 13 a raw pointer because we can't create a WeakPtr of an element yet. 14 15 Test: css-typedom/attribute-style-map-should-not-leak-every-element.html 16 17 * css/typedom/StylePropertyMap.h: 18 (WebCore::StylePropertyMap): Added clearElement as a virtual function. 19 * dom/Element.cpp: 20 (WebCore::Element::~Element): Clear the element pointer in StyledElementInlineStylePropertyMap. 21 * dom/StyledElement.cpp: 22 (WebCore::StyledElementInlineStylePropertyMap::get): Added a null check for m_element. 23 (WebCore::StyledElementInlineStylePropertyMap::StyledElementInlineStylePropertyMap): 24 (WebCore::StyledElementInlineStylePropertyMap::clearElement): Added. 25 (WebCore::StyledElementInlineStylePropertyMap): Use a raw pointer instead of Ref to StyledElement 26 to avoid the leak. 27 * platform/graphics/CustomPaintImage.cpp: 28 (WebCore::HashMapStylePropertyMap::clearElement): Added. 29 1 30 2019-03-19 Ryosuke Niwa <rniwa@webkit.org> 2 31 -
trunk/Source/WebCore/css/typedom/StylePropertyMap.h
r239341 r243239 36 36 37 37 class StylePropertyMap : public StylePropertyMapReadOnly { 38 public: 39 virtual void clearElement() = 0; 38 40 }; 39 41 -
trunk/Source/WebCore/dom/Element.cpp
r243163 r243239 204 204 detachAllAttrNodesFromElement(); 205 205 206 #if ENABLE(CSS_TYPED_OM) 207 if (hasRareData()) { 208 if (auto* map = elementRareData()->attributeStyleMap()) 209 map->clearElement(); 210 } 211 #endif 212 206 213 if (hasPendingResources()) { 207 214 document().accessSVGExtensions().removeElementFromPendingResources(*this); -
trunk/Source/WebCore/dom/StyledElement.cpp
r239341 r243239 89 89 RefPtr<TypedOMCSSStyleValue> get(const String& property) const final 90 90 { 91 return extractInlineProperty(property, m_element.get()); 91 ASSERT(m_element); // Hitting this assertion would imply a GC bug. Element is collected while this property map is alive. 92 if (!m_element) 93 return nullptr; 94 return extractInlineProperty(property, *m_element); 92 95 } 93 96 94 97 explicit StyledElementInlineStylePropertyMap(StyledElement& element) 95 : m_element( makeRef(element))98 : m_element(&element) 96 99 { 97 100 } 101 102 void clearElement() override { m_element = nullptr; } 98 103 99 104 static RefPtr<TypedOMCSSStyleValue> extractInlineProperty(const String& name, StyledElement& element) … … 115 120 } 116 121 117 Ref<StyledElement> m_element;122 StyledElement* m_element { nullptr }; 118 123 }; 119 124 -
trunk/Source/WebCore/platform/graphics/CustomPaintImage.cpp
r239341 r243239 106 106 } 107 107 108 void clearElement() override { } 109 108 110 RefPtr<TypedOMCSSStyleValue> get(const String& property) const final { return makeRefPtr(m_map.get(property)); } 109 111
Note:
See TracChangeset
for help on using the changeset viewer.