Changeset 230737 in webkit


Ignore:
Timestamp:
Apr 17, 2018 4:33:02 PM (6 years ago)
Author:
commit-queue@webkit.org
Message:

References from CSSStyleDeclaration to CSSValues should be weak
https://bugs.webkit.org/show_bug.cgi?id=180280
<rdar://problem/35804869>

Patch by Tadeu Zagallo <Tadeu Zagallo> on 2018-04-17
Reviewed by Geoffrey Garen.

No new tests - used the existing test to verify the leak

  • css/DeprecatedCSSOMValue.h:

(WebCore::DeprecatedCSSOMValue::weakPtrFactory):

  • css/PropertySetCSSStyleDeclaration.cpp:

(WebCore::PropertySetCSSStyleDeclaration::wrapForDeprecatedCSSOM):

  • css/PropertySetCSSStyleDeclaration.h:
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r230736 r230737  
     12018-04-17  Tadeu Zagallo  <tzagallo@apple.com>
     2
     3        References from CSSStyleDeclaration to CSSValues should be weak
     4        https://bugs.webkit.org/show_bug.cgi?id=180280
     5        <rdar://problem/35804869>
     6
     7        Reviewed by Geoffrey Garen.
     8
     9        No new tests - used the existing test to verify the leak
     10
     11        * css/DeprecatedCSSOMValue.h:
     12        (WebCore::DeprecatedCSSOMValue::weakPtrFactory):
     13        * css/PropertySetCSSStyleDeclaration.cpp:
     14        (WebCore::PropertySetCSSStyleDeclaration::wrapForDeprecatedCSSOM):
     15        * css/PropertySetCSSStyleDeclaration.h:
     16
    1172018-04-17  Jonathan Bedard  <jbedard@apple.com>
    218
  • trunk/Source/WebCore/css/DeprecatedCSSOMValue.h

    r226382 r230737  
    3232#include <wtf/RefCounted.h>
    3333#include <wtf/TypeCasts.h>
     34#include <wtf/WeakPtr.h>
    3435#include <wtf/text/WTFString.h>
    3536
     
    6566    CSSStyleDeclaration& owner() const { return m_owner; }
    6667
     68    WeakPtrFactory<DeprecatedCSSOMValue>& weakPtrFactory() { return m_weakPtrFactory; }
     69
    6770protected:
    6871    static const size_t ClassTypeBits = 2;
     
    9396   
    9497    Ref<CSSStyleDeclaration> m_owner;
     98    WeakPtrFactory<DeprecatedCSSOMValue> m_weakPtrFactory;
    9599};
    96100
  • trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp

    r219856 r230737  
    309309}
    310310
    311 DeprecatedCSSOMValue* PropertySetCSSStyleDeclaration::wrapForDeprecatedCSSOM(CSSValue* internalValue)
     311RefPtr<DeprecatedCSSOMValue> PropertySetCSSStyleDeclaration::wrapForDeprecatedCSSOM(CSSValue* internalValue)
    312312{
    313313    if (!internalValue)
     
    317317    // FIXME: It is likely that the identity is not important for web compatibility and this code should be removed.
    318318    if (!m_cssomValueWrappers)
    319         m_cssomValueWrappers = std::make_unique<HashMap<CSSValue*, RefPtr<DeprecatedCSSOMValue>>>();
     319        m_cssomValueWrappers = std::make_unique<HashMap<CSSValue*, WeakPtr<DeprecatedCSSOMValue>>>();
    320320   
    321     RefPtr<DeprecatedCSSOMValue>& clonedValue = m_cssomValueWrappers->add(internalValue, RefPtr<DeprecatedCSSOMValue>()).iterator->value;
    322     if (!clonedValue)
    323         clonedValue = internalValue->createDeprecatedCSSOMWrapper(*this);
    324     return clonedValue.get();
     321    auto& clonedValue = m_cssomValueWrappers->add(internalValue, WeakPtr<DeprecatedCSSOMValue>()).iterator->value;
     322    if (clonedValue)
     323        return clonedValue.get();
     324
     325    RefPtr<DeprecatedCSSOMValue> wrapper = internalValue->createDeprecatedCSSOMWrapper(*this);
     326    clonedValue = makeWeakPtr(wrapper.get());
     327    return wrapper;
    325328}
    326329
  • trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.h

    r219744 r230737  
    3232#include <wtf/HashMap.h>
    3333#include <wtf/RefPtr.h>
     34#include <wtf/WeakPtr.h>
    3435
    3536namespace WebCore {
     
    5859
    5960    MutableStyleProperties* m_propertySet;
    60     std::unique_ptr<HashMap<CSSValue*, RefPtr<DeprecatedCSSOMValue>>> m_cssomValueWrappers;
     61    std::unique_ptr<HashMap<CSSValue*, WeakPtr<DeprecatedCSSOMValue>>> m_cssomValueWrappers;
    6162
    6263private:
     
    8283    Ref<MutableStyleProperties> copyProperties() const final;
    8384
    84     DeprecatedCSSOMValue* wrapForDeprecatedCSSOM(CSSValue*);
     85    RefPtr<DeprecatedCSSOMValue> wrapForDeprecatedCSSOM(CSSValue*);
    8586   
    8687    virtual bool willMutate() WARN_UNUSED_RETURN { return true; }
Note: See TracChangeset for help on using the changeset viewer.