haikuwebkit/LayoutTests/css-typedom/attribute-style-map-should-...

4 lines
94 B
Plaintext
Raw Permalink Normal View History

[CSS OM] StyledElementInlineStylePropertyMap creates a Ref cycle with its owner element https://bugs.webkit.org/show_bug.cgi?id=195987 Reviewed by Simon Fraser. Source/WebCore: StyledElementInlineStylePropertyMap was leaking every element for which it was created because due to a reference cycle. The StyledElementInlineStylePropertyMap holds onto its element using Ref and the element also stores StyledElementInlineStylePropertyMap in ElementRareData using RefPtr. Fixed the cycle by making the reference from StyledElementInlineStylePropertyMap weak. For now we use a raw pointer because we can't create a WeakPtr of an element yet. Test: css-typedom/attribute-style-map-should-not-leak-every-element.html * css/typedom/StylePropertyMap.h: (WebCore::StylePropertyMap): Added clearElement as a virtual function. * dom/Element.cpp: (WebCore::Element::~Element): Clear the element pointer in StyledElementInlineStylePropertyMap. * dom/StyledElement.cpp: (WebCore::StyledElementInlineStylePropertyMap::get): Added a null check for m_element. (WebCore::StyledElementInlineStylePropertyMap::StyledElementInlineStylePropertyMap): (WebCore::StyledElementInlineStylePropertyMap::clearElement): Added. (WebCore::StyledElementInlineStylePropertyMap): Use a raw pointer instead of Ref to StyledElement to avoid the leak. * platform/graphics/CustomPaintImage.cpp: (WebCore::HashMapStylePropertyMap::clearElement): Added. LayoutTests: Added a regression test. * css-typedom/attribute-style-map-should-not-leak-every-element-expected.txt: Added. * css-typedom/attribute-style-map-should-not-leak-every-element.html: Added. Canonical link: https://commits.webkit.org/210305@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243239 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-03-20 21:23:02 +00:00
This tests allocating 1000 elements and triggering GC. GC should collect some elements.
PASS