Title: [219744] trunk/Source/WebCore
Revision
219744
Author
[email protected]
Date
2017-07-21 14:20:25 -0700 (Fri, 21 Jul 2017)

Log Message

[WebIDL] Remove the need for the side map of DeprecatedCSSOMValue roots
https://bugs.webkit.org/show_bug.cgi?id=174713

Patch by Sam Weinig <[email protected]> on 2017-07-21
Reviewed by Andreas Kling.

We used to not want to bloat the size of CSSValues with a pointer to the
owner CSSStyleDeclaration, so, for GC purposes we need kept a mapping of
them on DOMWrapperWorld that only got set if a wrapper was made. Now that
we have DeprecatedCSSOMValue, a wrapper for CSSValue that only gets created
for the bindings, we no longer need the side table, and simply have the
DeprecatedCSSOMValue maintain a reference to the CSSStyleDeclaration.

* bindings/js/DOMWrapperWorld.h:
(WebCore::DOMWrapperWorld::wrappers):
Remove m_deprecatedCSSOMValueRoots and make m_wrappers private with a getter.

* bindings/js/JSCSSStyleDeclarationCustom.cpp:
(WebCore::JSCSSStyleDeclaration::getPropertyCSSValue): Deleted.
Remove custom implementation of getPropertyCSSValue, now that it no longer
needs to update m_deprecatedCSSOMValueRoots.

* bindings/js/JSDOMWindowBase.cpp:
(WebCore::JSDOMWindowBase::fireFrameClearedWatchpointsForWindow):
* bindings/js/JSDOMWrapperCache.h:
(WebCore::getCachedWrapper):
(WebCore::cacheWrapper):
(WebCore::uncacheWrapper):
* bindings/js/JSNodeCustom.cpp:
(WebCore::getOutOfLineCachedWrapper):
Use wrappers getter rather than direct member variable.

* bindings/js/JSDeprecatedCSSOMValueCustom.cpp:
(WebCore::JSDeprecatedCSSOMValueOwner::isReachableFromOpaqueRoots):
Rather than checking the side table for roots, now get the root
via the reference CSSStyleDeclaration.

(WebCore::JSDeprecatedCSSOMValueOwner::finalize): Deleted.
Remove custom finalize now that we don't have to remove ourself
from m_deprecatedCSSOMValueRoots.

* css/CSSStyleDeclaration.idl:
Remove [Custom] from getPropertyCSSValue.

* css/DeprecatedCSSOMValue.idl:
Remove [JSCustomFinalize].

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
* css/CSSImageValue.cpp:
(WebCore::CSSImageValue::createDeprecatedCSSOMWrapper):
* css/CSSImageValue.h:
* css/CSSPrimitiveValue.cpp:
(WebCore::CSSPrimitiveValue::createDeprecatedCSSOMPrimitiveWrapper):
* css/CSSPrimitiveValue.h:
* css/CSSStyleDeclaration.h:
* css/CSSValue.cpp:
(WebCore::CSSValue::createDeprecatedCSSOMWrapper):
* css/CSSValue.h:
* css/DeprecatedCSSOMCounter.h:
* css/DeprecatedCSSOMPrimitiveValue.cpp:
(WebCore::DeprecatedCSSOMPrimitiveValue::getCounterValue):
(WebCore::DeprecatedCSSOMPrimitiveValue::getRectValue):
(WebCore::DeprecatedCSSOMPrimitiveValue::getRGBColorValue):
* css/DeprecatedCSSOMPrimitiveValue.h:
(WebCore::DeprecatedCSSOMPrimitiveValue::create):
(WebCore::DeprecatedCSSOMPrimitiveValue::DeprecatedCSSOMPrimitiveValue):
* css/DeprecatedCSSOMRGBColor.h:
* css/DeprecatedCSSOMRect.h:
* css/DeprecatedCSSOMValue.h:
(WebCore::DeprecatedCSSOMValue::owner):
(WebCore::DeprecatedCSSOMValue::DeprecatedCSSOMValue):
(WebCore::DeprecatedCSSOMComplexValue::create):
(WebCore::DeprecatedCSSOMComplexValue::DeprecatedCSSOMComplexValue):
* css/DeprecatedCSSOMValueList.h:
(WebCore::DeprecatedCSSOMValueList::create):
(WebCore::DeprecatedCSSOMValueList::DeprecatedCSSOMValueList):
* css/PropertySetCSSStyleDeclaration.cpp:
(WebCore::PropertySetCSSStyleDeclaration::wrapForDeprecatedCSSOM):
* css/PropertySetCSSStyleDeclaration.h:
* svg/SVGElement.cpp:
(WebCore::SVGElement::getPresentationAttribute):
Pass owning CSSStyleDeclaration to DeprecatedCSSOMValue and derived classes.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (219743 => 219744)


--- trunk/Source/WebCore/ChangeLog	2017-07-21 21:16:29 UTC (rev 219743)
+++ trunk/Source/WebCore/ChangeLog	2017-07-21 21:20:25 UTC (rev 219744)
@@ -1,3 +1,88 @@
+2017-07-21  Sam Weinig  <[email protected]>
+
+        [WebIDL] Remove the need for the side map of DeprecatedCSSOMValue roots
+        https://bugs.webkit.org/show_bug.cgi?id=174713
+
+        Reviewed by Andreas Kling.
+
+        We used to not want to bloat the size of CSSValues with a pointer to the
+        owner CSSStyleDeclaration, so, for GC purposes we need kept a mapping of
+        them on DOMWrapperWorld that only got set if a wrapper was made. Now that
+        we have DeprecatedCSSOMValue, a wrapper for CSSValue that only gets created
+        for the bindings, we no longer need the side table, and simply have the
+        DeprecatedCSSOMValue maintain a reference to the CSSStyleDeclaration.
+
+        * bindings/js/DOMWrapperWorld.h:
+        (WebCore::DOMWrapperWorld::wrappers):
+        Remove m_deprecatedCSSOMValueRoots and make m_wrappers private with a getter.
+
+        * bindings/js/JSCSSStyleDeclarationCustom.cpp:
+        (WebCore::JSCSSStyleDeclaration::getPropertyCSSValue): Deleted.
+        Remove custom implementation of getPropertyCSSValue, now that it no longer
+        needs to update m_deprecatedCSSOMValueRoots.
+
+        * bindings/js/JSDOMWindowBase.cpp:
+        (WebCore::JSDOMWindowBase::fireFrameClearedWatchpointsForWindow):
+        * bindings/js/JSDOMWrapperCache.h:
+        (WebCore::getCachedWrapper):
+        (WebCore::cacheWrapper):
+        (WebCore::uncacheWrapper):
+        * bindings/js/JSNodeCustom.cpp:
+        (WebCore::getOutOfLineCachedWrapper):
+        Use wrappers getter rather than direct member variable.
+
+        * bindings/js/JSDeprecatedCSSOMValueCustom.cpp:
+        (WebCore::JSDeprecatedCSSOMValueOwner::isReachableFromOpaqueRoots):
+        Rather than checking the side table for roots, now get the root
+        via the reference CSSStyleDeclaration.
+
+        (WebCore::JSDeprecatedCSSOMValueOwner::finalize): Deleted.
+        Remove custom finalize now that we don't have to remove ourself
+        from m_deprecatedCSSOMValueRoots.
+
+        * css/CSSStyleDeclaration.idl:
+        Remove [Custom] from getPropertyCSSValue.
+
+        * css/DeprecatedCSSOMValue.idl:
+        Remove [JSCustomFinalize].
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
+        * css/CSSImageValue.cpp:
+        (WebCore::CSSImageValue::createDeprecatedCSSOMWrapper):
+        * css/CSSImageValue.h:
+        * css/CSSPrimitiveValue.cpp:
+        (WebCore::CSSPrimitiveValue::createDeprecatedCSSOMPrimitiveWrapper):
+        * css/CSSPrimitiveValue.h:
+        * css/CSSStyleDeclaration.h:
+        * css/CSSValue.cpp:
+        (WebCore::CSSValue::createDeprecatedCSSOMWrapper):
+        * css/CSSValue.h:
+        * css/DeprecatedCSSOMCounter.h:
+        * css/DeprecatedCSSOMPrimitiveValue.cpp:
+        (WebCore::DeprecatedCSSOMPrimitiveValue::getCounterValue):
+        (WebCore::DeprecatedCSSOMPrimitiveValue::getRectValue):
+        (WebCore::DeprecatedCSSOMPrimitiveValue::getRGBColorValue):
+        * css/DeprecatedCSSOMPrimitiveValue.h:
+        (WebCore::DeprecatedCSSOMPrimitiveValue::create):
+        (WebCore::DeprecatedCSSOMPrimitiveValue::DeprecatedCSSOMPrimitiveValue):
+        * css/DeprecatedCSSOMRGBColor.h:
+        * css/DeprecatedCSSOMRect.h:
+        * css/DeprecatedCSSOMValue.h:
+        (WebCore::DeprecatedCSSOMValue::owner):
+        (WebCore::DeprecatedCSSOMValue::DeprecatedCSSOMValue):
+        (WebCore::DeprecatedCSSOMComplexValue::create):
+        (WebCore::DeprecatedCSSOMComplexValue::DeprecatedCSSOMComplexValue):
+        * css/DeprecatedCSSOMValueList.h:
+        (WebCore::DeprecatedCSSOMValueList::create):
+        (WebCore::DeprecatedCSSOMValueList::DeprecatedCSSOMValueList):
+        * css/PropertySetCSSStyleDeclaration.cpp:
+        (WebCore::PropertySetCSSStyleDeclaration::wrapForDeprecatedCSSOM):
+        * css/PropertySetCSSStyleDeclaration.h:
+        * svg/SVGElement.cpp:
+        (WebCore::SVGElement::getPresentationAttribute):
+        Pass owning CSSStyleDeclaration to DeprecatedCSSOMValue and derived classes.
+
 2017-07-21  Andreas Kling  <[email protected]>
 
         Use more references in event dispatch code

Modified: trunk/Source/WebCore/bindings/js/DOMWrapperWorld.h (219743 => 219744)


--- trunk/Source/WebCore/bindings/js/DOMWrapperWorld.h	2017-07-21 21:16:29 UTC (rev 219743)
+++ trunk/Source/WebCore/bindings/js/DOMWrapperWorld.h	2017-07-21 21:20:25 UTC (rev 219744)
@@ -26,7 +26,6 @@
 
 namespace WebCore {
 
-class DeprecatedCSSOMValue;
 class ScriptController;
 
 typedef HashMap<void*, JSC::Weak<JSC::JSObject>> DOMObjectWrapperMap;
@@ -48,9 +47,7 @@
     void setShadowRootIsAlwaysOpen() { m_shadowRootIsAlwaysOpen = true; }
     bool shadowRootIsAlwaysOpen() const { return m_shadowRootIsAlwaysOpen; }
 
-    // FIXME: can we make this private?
-    DOMObjectWrapperMap m_wrappers;
-    HashMap<DeprecatedCSSOMValue*, void*> m_deprecatedCSSOMValueRoots;
+    DOMObjectWrapperMap& wrappers() { return m_wrappers; }
 
     bool isNormal() const { return m_isNormal; }
 
@@ -62,6 +59,8 @@
 private:
     JSC::VM& m_vm;
     HashSet<ScriptController*> m_scriptControllersWithWindowProxies;
+    DOMObjectWrapperMap m_wrappers;
+
     bool m_isNormal;
     bool m_shadowRootIsAlwaysOpen { false };
 };

Modified: trunk/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp (219743 => 219744)


--- trunk/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp	2017-07-21 21:16:29 UTC (rev 219743)
+++ trunk/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp	2017-07-21 21:20:25 UTC (rev 219744)
@@ -56,23 +56,4 @@
     visitor.addOpaqueRoot(root(&wrapped()));
 }
 
-JSValue JSCSSStyleDeclaration::getPropertyCSSValue(ExecState& state)
-{
-    VM& vm = state.vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    if (UNLIKELY(state.argumentCount() < 1))
-        return throwException(&state, scope, createNotEnoughArgumentsError(&state));
-
-    auto propertyName = convert<IDLDOMString>(state, state.uncheckedArgument(0));
-    RETURN_IF_EXCEPTION(scope, { });
-
-    auto value = wrapped().getPropertyCSSValue(propertyName);
-    if (!value)
-        return jsNull();
-
-    globalObject()->world().m_deprecatedCSSOMValueRoots.add(value.get(), root(&wrapped())); // Balanced by JSDeprecatedCSSOMValueOwner::finalize().
-    return toJS<IDLInterface<DeprecatedCSSOMValue>>(state, *globalObject(), *value);
-}
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp (219743 => 219744)


--- trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp	2017-07-21 21:16:29 UTC (rev 219743)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp	2017-07-21 21:20:25 UTC (rev 219744)
@@ -350,7 +350,7 @@
     Vector<Ref<DOMWrapperWorld>> wrapperWorlds;
     clientData->getAllWorlds(wrapperWorlds);
     for (unsigned i = 0; i < wrapperWorlds.size(); ++i) {
-        DOMObjectWrapperMap& wrappers = wrapperWorlds[i]->m_wrappers;
+        auto& wrappers = wrapperWorlds[i]->wrappers();
         auto result = wrappers.find(window);
         if (result == wrappers.end())
             continue;

Modified: trunk/Source/WebCore/bindings/js/JSDOMWrapperCache.h (219743 => 219744)


--- trunk/Source/WebCore/bindings/js/JSDOMWrapperCache.h	2017-07-21 21:16:29 UTC (rev 219743)
+++ trunk/Source/WebCore/bindings/js/JSDOMWrapperCache.h	2017-07-21 21:20:25 UTC (rev 219744)
@@ -161,7 +161,7 @@
 {
     if (auto* wrapper = getInlineCachedWrapper(world, &domObject))
         return wrapper;
-    return world.m_wrappers.get(wrapperKey(&domObject));
+    return world.wrappers().get(wrapperKey(&domObject));
 }
 
 template<typename DOMClass, typename WrapperClass> inline void cacheWrapper(DOMWrapperWorld& world, DOMClass* domObject, WrapperClass* wrapper)
@@ -169,7 +169,7 @@
     JSC::WeakHandleOwner* owner = wrapperOwner(world, domObject);
     if (setInlineCachedWrapper(world, domObject, wrapper, owner))
         return;
-    weakAdd(world.m_wrappers, wrapperKey(domObject), JSC::Weak<JSC::JSObject>(wrapper, owner, &world));
+    weakAdd(world.wrappers(), wrapperKey(domObject), JSC::Weak<JSC::JSObject>(wrapper, owner, &world));
 }
 
 template<typename DOMClass, typename WrapperClass> inline void uncacheWrapper(DOMWrapperWorld& world, DOMClass* domObject, WrapperClass* wrapper)
@@ -176,7 +176,7 @@
 {
     if (clearInlineCachedWrapper(world, domObject, wrapper))
         return;
-    weakRemove(world.m_wrappers, wrapperKey(domObject), wrapper);
+    weakRemove(world.wrappers(), wrapperKey(domObject), wrapper);
 }
 
 template<typename DOMClass, typename T> inline auto createWrapper(JSDOMGlobalObject* globalObject, Ref<T>&& domObject) -> typename std::enable_if<std::is_same<DOMClass, T>::value, typename JSDOMWrapperConverterTraits<DOMClass>::WrapperClass*>::type

Modified: trunk/Source/WebCore/bindings/js/JSDeprecatedCSSOMValueCustom.cpp (219743 => 219744)


--- trunk/Source/WebCore/bindings/js/JSDeprecatedCSSOMValueCustom.cpp	2017-07-21 21:16:29 UTC (rev 219743)
+++ trunk/Source/WebCore/bindings/js/JSDeprecatedCSSOMValueCustom.cpp	2017-07-21 21:20:25 UTC (rev 219744)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "JSDeprecatedCSSOMValue.h"
 
+#include "JSCSSStyleDeclarationCustom.h"
 #include "JSDeprecatedCSSOMPrimitiveValue.h"
 #include "JSDeprecatedCSSOMValueList.h"
 #include "JSNode.h"
@@ -34,26 +35,14 @@
 
 namespace WebCore {
 
-bool JSDeprecatedCSSOMValueOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void* context, SlotVisitor& visitor)
+bool JSDeprecatedCSSOMValueOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
 {
     JSDeprecatedCSSOMValue* jsCSSValue = jsCast<JSDeprecatedCSSOMValue*>(handle.slot()->asCell());
     if (!jsCSSValue->hasCustomProperties())
         return false;
-    DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
-    void* root = world->m_deprecatedCSSOMValueRoots.get(&jsCSSValue->wrapped());
-    if (!root)
-        return false;
-    return visitor.containsOpaqueRoot(root);
+    return visitor.containsOpaqueRoot(root(&jsCSSValue->wrapped().owner()));
 }
 
-void JSDeprecatedCSSOMValueOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
-{
-    JSDeprecatedCSSOMValue* jsCSSValue = static_cast<JSDeprecatedCSSOMValue*>(handle.slot()->asCell());
-    DOMWrapperWorld& world = *static_cast<DOMWrapperWorld*>(context);
-    world.m_deprecatedCSSOMValueRoots.remove(&jsCSSValue->wrapped());
-    uncacheWrapper(world, &jsCSSValue->wrapped(), jsCSSValue);
-}
-
 JSValue toJSNewlyCreated(ExecState*, JSDOMGlobalObject* globalObject, Ref<DeprecatedCSSOMValue>&& value)
 {
     if (value->isValueList())

Modified: trunk/Source/WebCore/bindings/js/JSNodeCustom.cpp (219743 => 219744)


--- trunk/Source/WebCore/bindings/js/JSNodeCustom.cpp	2017-07-21 21:16:29 UTC (rev 219743)
+++ trunk/Source/WebCore/bindings/js/JSNodeCustom.cpp	2017-07-21 21:20:25 UTC (rev 219744)
@@ -183,7 +183,7 @@
 JSC::JSObject* getOutOfLineCachedWrapper(JSDOMGlobalObject* globalObject, Node& node)
 {
     ASSERT(!globalObject->world().isNormal());
-    return globalObject->world().m_wrappers.get(&node);
+    return globalObject->world().wrappers().get(&node);
 }
 
 void willCreatePossiblyOrphanedTreeByRemovalSlowCase(Node* root)

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (219743 => 219744)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2017-07-21 21:16:29 UTC (rev 219743)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2017-07-21 21:20:25 UTC (rev 219744)
@@ -4224,7 +4224,7 @@
         auto value = ComputedStyleExtractor(m_element.ptr(), m_allowVisitedStyle, m_pseudoElementSpecifier).customPropertyValue(propertyName);
         if (!value)
             return nullptr;
-        return value->createDeprecatedCSSOMWrapper();
+        return value->createDeprecatedCSSOMWrapper(*this);
     }
 
     CSSPropertyID propertyID = cssPropertyID(propertyName);
@@ -4233,7 +4233,7 @@
     auto value = getPropertyCSSValue(propertyID);
     if (!value)
         return nullptr;
-    return value->createDeprecatedCSSOMWrapper();
+    return value->createDeprecatedCSSOMWrapper(*this);
 }
 
 String CSSComputedStyleDeclaration::getPropertyValue(const String &propertyName)

Modified: trunk/Source/WebCore/css/CSSImageValue.cpp (219743 => 219744)


--- trunk/Source/WebCore/css/CSSImageValue.cpp	2017-07-21 21:16:29 UTC (rev 219743)
+++ trunk/Source/WebCore/css/CSSImageValue.cpp	2017-07-21 21:20:25 UTC (rev 219744)
@@ -96,10 +96,10 @@
     return serializeURL(m_url);
 }
 
-Ref<DeprecatedCSSOMValue> CSSImageValue::createDeprecatedCSSOMWrapper() const
+Ref<DeprecatedCSSOMValue> CSSImageValue::createDeprecatedCSSOMWrapper(CSSStyleDeclaration& styleDeclaration) const
 {
     // NOTE: We expose CSSImageValues as URI primitive values in CSSOM to maintain old behavior.
-    return DeprecatedCSSOMPrimitiveValue::create(CSSPrimitiveValue::create(m_url, CSSPrimitiveValue::CSS_URI));
+    return DeprecatedCSSOMPrimitiveValue::create(CSSPrimitiveValue::create(m_url, CSSPrimitiveValue::CSS_URI), styleDeclaration);
 }
 
 bool CSSImageValue::knownToBeOpaque(const RenderElement* renderer) const

Modified: trunk/Source/WebCore/css/CSSImageValue.h (219743 => 219744)


--- trunk/Source/WebCore/css/CSSImageValue.h	2017-07-21 21:16:29 UTC (rev 219743)
+++ trunk/Source/WebCore/css/CSSImageValue.h	2017-07-21 21:20:25 UTC (rev 219744)
@@ -30,6 +30,7 @@
 class CachedImage;
 class CachedResourceLoader;
 class DeprecatedCSSOMValue;
+class CSSStyleDeclaration;
 class RenderElement;
 struct ResourceLoaderOptions;
 
@@ -47,7 +48,7 @@
 
     String customCSSText() const;
 
-    Ref<DeprecatedCSSOMValue> createDeprecatedCSSOMWrapper() const;
+    Ref<DeprecatedCSSOMValue> createDeprecatedCSSOMWrapper(CSSStyleDeclaration&) const;
 
     bool traverseSubresources(const WTF::Function<bool (const CachedResource&)>& handler) const;
 

Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.cpp (219743 => 219744)


--- trunk/Source/WebCore/css/CSSPrimitiveValue.cpp	2017-07-21 21:16:29 UTC (rev 219743)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.cpp	2017-07-21 21:20:25 UTC (rev 219744)
@@ -1216,9 +1216,9 @@
     return false;
 }
 
-Ref<DeprecatedCSSOMPrimitiveValue> CSSPrimitiveValue::createDeprecatedCSSOMPrimitiveWrapper() const
+Ref<DeprecatedCSSOMPrimitiveValue> CSSPrimitiveValue::createDeprecatedCSSOMPrimitiveWrapper(CSSStyleDeclaration& styleDeclaration) const
 {
-    return DeprecatedCSSOMPrimitiveValue::create(*this);
+    return DeprecatedCSSOMPrimitiveValue::create(*this, styleDeclaration);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.h (219743 => 219744)


--- trunk/Source/WebCore/css/CSSPrimitiveValue.h	2017-07-21 21:16:29 UTC (rev 219743)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.h	2017-07-21 21:20:25 UTC (rev 219744)
@@ -286,7 +286,7 @@
 
     static double computeNonCalcLengthDouble(const CSSToLengthConversionData&, UnitType, double value);
 
-    Ref<DeprecatedCSSOMPrimitiveValue> createDeprecatedCSSOMPrimitiveWrapper() const;
+    Ref<DeprecatedCSSOMPrimitiveValue> createDeprecatedCSSOMPrimitiveWrapper(CSSStyleDeclaration&) const;
 
 #if COMPILER(MSVC)
     // FIXME: This should be private, but for some reason MSVC then fails to invoke it from LazyNeverDestroyed::construct.

Modified: trunk/Source/WebCore/css/CSSStyleDeclaration.h (219743 => 219744)


--- trunk/Source/WebCore/css/CSSStyleDeclaration.h	2017-07-21 21:16:29 UTC (rev 219743)
+++ trunk/Source/WebCore/css/CSSStyleDeclaration.h	2017-07-21 21:20:25 UTC (rev 219744)
@@ -21,7 +21,6 @@
 #pragma once
 
 #include "CSSPropertyNames.h"
-#include "DeprecatedCSSOMValue.h"
 #include "ExceptionOr.h"
 #include "ScriptWrappable.h"
 #include <wtf/Forward.h>
@@ -34,6 +33,7 @@
 class CSSRule;
 class CSSStyleSheet;
 class CSSValue;
+class DeprecatedCSSOMValue;
 class MutableStyleProperties;
 class StyleProperties;
 class StyledElement;

Modified: trunk/Source/WebCore/css/CSSStyleDeclaration.idl (219743 => 219744)


--- trunk/Source/WebCore/css/CSSStyleDeclaration.idl	2017-07-21 21:16:29 UTC (rev 219743)
+++ trunk/Source/WebCore/css/CSSStyleDeclaration.idl	2017-07-21 21:20:25 UTC (rev 219744)
@@ -51,5 +51,5 @@
     [CEReactions, MayThrowException, CallNamedSetterOnlyForSupportedProperties] setter void (DOMString name, [TreatNullAs=EmptyString] DOMString value);
 
     // This method is deprecated, and we would like to drop support for it someday
-    [Custom] DeprecatedCSSOMValue? getPropertyCSSValue(DOMString propertyName);
+    DeprecatedCSSOMValue? getPropertyCSSValue(DOMString propertyName);
 };

Modified: trunk/Source/WebCore/css/CSSValue.cpp (219743 => 219744)


--- trunk/Source/WebCore/css/CSSValue.cpp	2017-07-21 21:16:29 UTC (rev 219743)
+++ trunk/Source/WebCore/css/CSSValue.cpp	2017-07-21 21:20:25 UTC (rev 219744)
@@ -452,15 +452,15 @@
     ASSERT_NOT_REACHED();
 }
 
-Ref<DeprecatedCSSOMValue> CSSValue::createDeprecatedCSSOMWrapper() const
+Ref<DeprecatedCSSOMValue> CSSValue::createDeprecatedCSSOMWrapper(CSSStyleDeclaration& styleDeclaration) const
 {
     if (isImageValue() || isCursorImageValue())
-        return downcast<CSSImageValue>(this)->createDeprecatedCSSOMWrapper();
+        return downcast<CSSImageValue>(this)->createDeprecatedCSSOMWrapper(styleDeclaration);
     if (isPrimitiveValue())
-        return DeprecatedCSSOMPrimitiveValue::create(downcast<CSSPrimitiveValue>(*this));
+        return DeprecatedCSSOMPrimitiveValue::create(downcast<CSSPrimitiveValue>(*this), styleDeclaration);
     if (isValueList())
-        return DeprecatedCSSOMValueList::create(downcast<CSSValueList>(*this));
-    return DeprecatedCSSOMComplexValue::create(*this);
+        return DeprecatedCSSOMValueList::create(downcast<CSSValueList>(*this), styleDeclaration);
+    return DeprecatedCSSOMComplexValue::create(*this, styleDeclaration);
 }
 
 bool CSSValue::treatAsInheritedValue(CSSPropertyID propertyID) const

Modified: trunk/Source/WebCore/css/CSSValue.h (219743 => 219744)


--- trunk/Source/WebCore/css/CSSValue.h	2017-07-21 21:16:29 UTC (rev 219743)
+++ trunk/Source/WebCore/css/CSSValue.h	2017-07-21 21:20:25 UTC (rev 219744)
@@ -30,6 +30,7 @@
 namespace WebCore {
 
 class CSSCustomPropertyValue;
+class CSSStyleDeclaration;
 class CachedResource;
 class DeprecatedCSSOMValue;
 class StyleSheetContents;
@@ -118,7 +119,7 @@
     
     bool hasVariableReferences() const { return isVariableReferenceValue() || isPendingSubstitutionValue(); }
 
-    Ref<DeprecatedCSSOMValue> createDeprecatedCSSOMWrapper() const;
+    Ref<DeprecatedCSSOMValue> createDeprecatedCSSOMWrapper(CSSStyleDeclaration&) const;
 
     bool traverseSubresources(const WTF::Function<bool (const CachedResource&)>& handler) const;
 

Modified: trunk/Source/WebCore/css/DeprecatedCSSOMCounter.h (219743 => 219744)


--- trunk/Source/WebCore/css/DeprecatedCSSOMCounter.h	2017-07-21 21:16:29 UTC (rev 219743)
+++ trunk/Source/WebCore/css/DeprecatedCSSOMCounter.h	2017-07-21 21:20:25 UTC (rev 219744)
@@ -33,7 +33,10 @@
 
 class DeprecatedCSSOMCounter final : public RefCounted<DeprecatedCSSOMCounter> {
 public:
-    static Ref<DeprecatedCSSOMCounter> create(const Counter& counter) { return adoptRef(*new DeprecatedCSSOMCounter(counter)); }
+    static Ref<DeprecatedCSSOMCounter> create(const Counter& counter, CSSStyleDeclaration& owner)
+    {
+        return adoptRef(*new DeprecatedCSSOMCounter(counter, owner));
+    }
 
     String identifier() const { return m_identifier->stringValue(); }
     String listStyle() const { return m_listStyle->stringValue(); }
@@ -40,10 +43,10 @@
     String separator() const { return m_separator->stringValue(); }
     
 private:
-    DeprecatedCSSOMCounter(const Counter& counter)
-        : m_identifier(counter.identifierValue().createDeprecatedCSSOMPrimitiveWrapper())
-        , m_listStyle(counter.listStyleValue().createDeprecatedCSSOMPrimitiveWrapper())
-        , m_separator(counter.separatorValue().createDeprecatedCSSOMPrimitiveWrapper())
+    DeprecatedCSSOMCounter(const Counter& counter, CSSStyleDeclaration& owner)
+        : m_identifier(counter.identifierValue().createDeprecatedCSSOMPrimitiveWrapper(owner))
+        , m_listStyle(counter.listStyleValue().createDeprecatedCSSOMPrimitiveWrapper(owner))
+        , m_separator(counter.separatorValue().createDeprecatedCSSOMPrimitiveWrapper(owner))
     {
     }
     

Modified: trunk/Source/WebCore/css/DeprecatedCSSOMPrimitiveValue.cpp (219743 => 219744)


--- trunk/Source/WebCore/css/DeprecatedCSSOMPrimitiveValue.cpp	2017-07-21 21:16:29 UTC (rev 219743)
+++ trunk/Source/WebCore/css/DeprecatedCSSOMPrimitiveValue.cpp	2017-07-21 21:20:25 UTC (rev 219744)
@@ -68,7 +68,7 @@
     ExceptionOr<Counter&> counter = m_value->getCounterValue();
     if (counter.hasException())
         return Exception { INVALID_ACCESS_ERR };
-    return DeprecatedCSSOMCounter::create(counter.releaseReturnValue());
+    return DeprecatedCSSOMCounter::create(counter.releaseReturnValue(), m_owner.get());
 }
     
 ExceptionOr<Ref<DeprecatedCSSOMRect>> DeprecatedCSSOMPrimitiveValue::getRectValue() const
@@ -76,7 +76,7 @@
     ExceptionOr<Rect&> rect = m_value->getRectValue();
     if (rect.hasException())
         return Exception { INVALID_ACCESS_ERR };
-    return DeprecatedCSSOMRect::create(rect.releaseReturnValue());
+    return DeprecatedCSSOMRect::create(rect.releaseReturnValue(), m_owner.get());
 }
 
 ExceptionOr<Ref<DeprecatedCSSOMRGBColor>> DeprecatedCSSOMPrimitiveValue::getRGBColorValue() const
@@ -84,7 +84,7 @@
     ExceptionOr<Ref<RGBColor>> color = m_value->getRGBColorValue();
     if (color.hasException())
         return Exception { INVALID_ACCESS_ERR };
-    return DeprecatedCSSOMRGBColor::create(color.releaseReturnValue());
+    return DeprecatedCSSOMRGBColor::create(color.releaseReturnValue(), m_owner.get());
 }
 
 }

Modified: trunk/Source/WebCore/css/DeprecatedCSSOMPrimitiveValue.h (219743 => 219744)


--- trunk/Source/WebCore/css/DeprecatedCSSOMPrimitiveValue.h	2017-07-21 21:16:29 UTC (rev 219743)
+++ trunk/Source/WebCore/css/DeprecatedCSSOMPrimitiveValue.h	2017-07-21 21:20:25 UTC (rev 219744)
@@ -70,9 +70,9 @@
         CSS_VMAX = 29
     };
 
-    static Ref<DeprecatedCSSOMPrimitiveValue> create(const CSSPrimitiveValue& value)
+    static Ref<DeprecatedCSSOMPrimitiveValue> create(const CSSPrimitiveValue& value, CSSStyleDeclaration& owner)
     {
-        return adoptRef(*new DeprecatedCSSOMPrimitiveValue(value));
+        return adoptRef(*new DeprecatedCSSOMPrimitiveValue(value, owner));
     }
 
     bool equals(const DeprecatedCSSOMPrimitiveValue& other) const { return m_value->equals(other.m_value); }
@@ -93,8 +93,8 @@
     String stringValue() const { return m_value->stringValue(); }
 
 protected:
-    DeprecatedCSSOMPrimitiveValue(const CSSPrimitiveValue& value)
-        : DeprecatedCSSOMValue(DeprecatedPrimitiveValueClass)
+    DeprecatedCSSOMPrimitiveValue(const CSSPrimitiveValue& value, CSSStyleDeclaration& owner)
+        : DeprecatedCSSOMValue(DeprecatedPrimitiveValueClass, owner)
         , m_value(const_cast<CSSPrimitiveValue&>(value))
     {
     }

Modified: trunk/Source/WebCore/css/DeprecatedCSSOMRGBColor.h (219743 => 219744)


--- trunk/Source/WebCore/css/DeprecatedCSSOMRGBColor.h	2017-07-21 21:16:29 UTC (rev 219743)
+++ trunk/Source/WebCore/css/DeprecatedCSSOMRGBColor.h	2017-07-21 21:20:25 UTC (rev 219744)
@@ -28,7 +28,10 @@
 
 class DeprecatedCSSOMRGBColor final : public RefCounted<DeprecatedCSSOMRGBColor> {
 public:
-    static Ref<DeprecatedCSSOMRGBColor> create(const RGBColor& color) { return adoptRef(*new DeprecatedCSSOMRGBColor(color)); }
+    static Ref<DeprecatedCSSOMRGBColor> create(const RGBColor& color, CSSStyleDeclaration& owner)
+    {
+        return adoptRef(*new DeprecatedCSSOMRGBColor(color, owner));
+    }
 
     DeprecatedCSSOMPrimitiveValue* red() { return m_red.get(); }
     DeprecatedCSSOMPrimitiveValue* green() { return m_green.get(); }
@@ -38,28 +41,28 @@
     Color color() const { return Color(m_rgbColor); }
 
 private:
-    DeprecatedCSSOMRGBColor(const RGBColor& color)
+    DeprecatedCSSOMRGBColor(const RGBColor& color, CSSStyleDeclaration& owner)
         : m_rgbColor(color.rgbColor())
     {
         // Red
         unsigned value = (m_rgbColor >> 16) & 0xFF;
         auto result = CSSPrimitiveValue::create(value, CSSPrimitiveValue::CSS_NUMBER);
-        m_red = result->createDeprecatedCSSOMPrimitiveWrapper();
+        m_red = result->createDeprecatedCSSOMPrimitiveWrapper(owner);
         
         // Green
         value = (m_rgbColor >> 8) & 0xFF;
         result = CSSPrimitiveValue::create(value, CSSPrimitiveValue::CSS_NUMBER);
-        m_green = result->createDeprecatedCSSOMPrimitiveWrapper();
+        m_green = result->createDeprecatedCSSOMPrimitiveWrapper(owner);
 
         // Blue
         value = m_rgbColor & 0xFF;
         result = CSSPrimitiveValue::create(value, CSSPrimitiveValue::CSS_NUMBER);
-        m_blue = result->createDeprecatedCSSOMPrimitiveWrapper();
+        m_blue = result->createDeprecatedCSSOMPrimitiveWrapper(owner);
         
         // Alpha
         float alphaValue = static_cast<float>((m_rgbColor >> 24) & 0xFF) / 0xFF;
         result = CSSPrimitiveValue::create(alphaValue, CSSPrimitiveValue::CSS_NUMBER);
-        m_alpha = result->createDeprecatedCSSOMPrimitiveWrapper();
+        m_alpha = result->createDeprecatedCSSOMPrimitiveWrapper(owner);
     }
     
     RGBA32 m_rgbColor;

Modified: trunk/Source/WebCore/css/DeprecatedCSSOMRect.h (219743 => 219744)


--- trunk/Source/WebCore/css/DeprecatedCSSOMRect.h	2017-07-21 21:16:29 UTC (rev 219743)
+++ trunk/Source/WebCore/css/DeprecatedCSSOMRect.h	2017-07-21 21:20:25 UTC (rev 219744)
@@ -33,7 +33,10 @@
 
 class DeprecatedCSSOMRect final : public RefCounted<DeprecatedCSSOMRect> {
 public:
-    static Ref<DeprecatedCSSOMRect> create(const Rect& rect) { return adoptRef(*new DeprecatedCSSOMRect(rect)); }
+    static Ref<DeprecatedCSSOMRect> create(const Rect& rect, CSSStyleDeclaration& owner)
+    {
+        return adoptRef(*new DeprecatedCSSOMRect(rect, owner));
+    }
 
     DeprecatedCSSOMPrimitiveValue* top() const { return m_top.get(); }
     DeprecatedCSSOMPrimitiveValue* right() const { return m_right.get(); }
@@ -41,16 +44,16 @@
     DeprecatedCSSOMPrimitiveValue* left() const { return m_left.get(); }
     
 private:
-    DeprecatedCSSOMRect(const Rect& rect)
+    DeprecatedCSSOMRect(const Rect& rect, CSSStyleDeclaration& owner)
     {
         if (rect.top())
-            m_top = rect.top()->createDeprecatedCSSOMPrimitiveWrapper();
+            m_top = rect.top()->createDeprecatedCSSOMPrimitiveWrapper(owner);
         if (rect.right())
-            m_right = rect.right()->createDeprecatedCSSOMPrimitiveWrapper();
+            m_right = rect.right()->createDeprecatedCSSOMPrimitiveWrapper(owner);
         if (rect.bottom())
-            m_bottom = rect.bottom()->createDeprecatedCSSOMPrimitiveWrapper();
+            m_bottom = rect.bottom()->createDeprecatedCSSOMPrimitiveWrapper(owner);
         if (rect.left())
-            m_left = rect.left()->createDeprecatedCSSOMPrimitiveWrapper();
+            m_left = rect.left()->createDeprecatedCSSOMPrimitiveWrapper(owner);
     }
     
     RefPtr<DeprecatedCSSOMPrimitiveValue> m_top;

Modified: trunk/Source/WebCore/css/DeprecatedCSSOMValue.h (219743 => 219744)


--- trunk/Source/WebCore/css/DeprecatedCSSOMValue.h	2017-07-21 21:16:29 UTC (rev 219743)
+++ trunk/Source/WebCore/css/DeprecatedCSSOMValue.h	2017-07-21 21:20:25 UTC (rev 219744)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include "CSSStyleDeclaration.h"
 #include "CSSValue.h"
 #include "ExceptionOr.h"
 #include <wtf/Ref.h>
@@ -63,7 +64,9 @@
     bool isComplexValue() const { return m_classType == DeprecatedComplexValueClass; }
     bool isPrimitiveValue() const { return m_classType == DeprecatedPrimitiveValueClass; }
     bool isValueList() const { return m_classType == DeprecatedValueListClass; }
-    
+
+    CSSStyleDeclaration& owner() const { return m_owner; }
+
 protected:
     static const size_t ClassTypeBits = 2;
     enum DeprecatedClassType {
@@ -74,8 +77,9 @@
 
     DeprecatedClassType classType() const { return static_cast<DeprecatedClassType>(m_classType); }
 
-    DeprecatedCSSOMValue(DeprecatedClassType classType)
+    DeprecatedCSSOMValue(DeprecatedClassType classType, CSSStyleDeclaration& owner)
         : m_classType(classType)
+        , m_owner(owner)
     {
     }
 
@@ -88,16 +92,16 @@
 
 protected:
     unsigned m_valueListSeparator : CSSValue::ValueListSeparatorBits;
-
-private:
     unsigned m_classType : ClassTypeBits; // ClassType
+    
+    Ref<CSSStyleDeclaration> m_owner;
 };
 
 class DeprecatedCSSOMComplexValue : public DeprecatedCSSOMValue {
 public:
-    static Ref<DeprecatedCSSOMComplexValue> create(const CSSValue& value)
+    static Ref<DeprecatedCSSOMComplexValue> create(const CSSValue& value, CSSStyleDeclaration& owner)
     {
-        return adoptRef(*new DeprecatedCSSOMComplexValue(value));
+        return adoptRef(*new DeprecatedCSSOMComplexValue(value, owner));
     }
 
     bool equals(const DeprecatedCSSOMComplexValue& other) const { return m_value->equals(other.m_value); }
@@ -106,8 +110,8 @@
     unsigned cssValueType() const { return m_value->cssValueType(); }
 
 protected:
-    DeprecatedCSSOMComplexValue(const CSSValue& value)
-        : DeprecatedCSSOMValue(DeprecatedComplexValueClass)
+    DeprecatedCSSOMComplexValue(const CSSValue& value, CSSStyleDeclaration& owner)
+        : DeprecatedCSSOMValue(DeprecatedComplexValueClass, owner)
         , m_value(const_cast<CSSValue&>(value))
     {
     }

Modified: trunk/Source/WebCore/css/DeprecatedCSSOMValue.idl (219743 => 219744)


--- trunk/Source/WebCore/css/DeprecatedCSSOMValue.idl	2017-07-21 21:16:29 UTC (rev 219743)
+++ trunk/Source/WebCore/css/DeprecatedCSSOMValue.idl	2017-07-21 21:20:25 UTC (rev 219744)
@@ -23,7 +23,6 @@
     CustomToJSObject,
     ExportToWrappedFunction,
     ImplementationLacksVTable,
-    JSCustomFinalize,
     InterfaceName=CSSValue
 ] interface DeprecatedCSSOMValue {
     // UnitTypes

Modified: trunk/Source/WebCore/css/DeprecatedCSSOMValueList.h (219743 => 219744)


--- trunk/Source/WebCore/css/DeprecatedCSSOMValueList.h	2017-07-21 21:16:29 UTC (rev 219743)
+++ trunk/Source/WebCore/css/DeprecatedCSSOMValueList.h	2017-07-21 21:20:25 UTC (rev 219744)
@@ -32,9 +32,9 @@
     
 class DeprecatedCSSOMValueList : public DeprecatedCSSOMValue {
 public:
-    static Ref<DeprecatedCSSOMValueList> create(const CSSValueList& value)
+    static Ref<DeprecatedCSSOMValueList> create(const CSSValueList& value, CSSStyleDeclaration& owner)
     {
-        return adoptRef(*new DeprecatedCSSOMValueList(value));
+        return adoptRef(*new DeprecatedCSSOMValueList(value, owner));
     }
     
     bool equals(const DeprecatedCSSOMValueList& other) const;
@@ -46,13 +46,13 @@
     const DeprecatedCSSOMValue* item(size_t index) const { return index < m_values.size() ? m_values[index].ptr() : nullptr; }
 
 protected:
-    DeprecatedCSSOMValueList(const CSSValueList& value)
-        : DeprecatedCSSOMValue(DeprecatedValueListClass)
+    DeprecatedCSSOMValueList(const CSSValueList& value, CSSStyleDeclaration& owner)
+        : DeprecatedCSSOMValue(DeprecatedValueListClass, owner)
     {
         m_valueListSeparator = value.separator();
         m_values.reserveInitialCapacity(value.length());
         for (unsigned i = 0, size = value.length(); i < size; ++i)
-            m_values.uncheckedAppend(value.itemWithoutBoundsCheck(i)->createDeprecatedCSSOMWrapper());
+            m_values.uncheckedAppend(value.itemWithoutBoundsCheck(i)->createDeprecatedCSSOMWrapper(owner));
     }
     
 private:

Modified: trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp (219743 => 219744)


--- trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp	2017-07-21 21:16:29 UTC (rev 219743)
+++ trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp	2017-07-21 21:20:25 UTC (rev 219744)
@@ -320,7 +320,7 @@
     
     RefPtr<DeprecatedCSSOMValue>& clonedValue = m_cssomValueWrappers->add(internalValue, RefPtr<DeprecatedCSSOMValue>()).iterator->value;
     if (!clonedValue)
-        clonedValue = internalValue->createDeprecatedCSSOMWrapper();
+        clonedValue = internalValue->createDeprecatedCSSOMWrapper(*this);
     return clonedValue.get();
 }
 

Modified: trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.h (219743 => 219744)


--- trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.h	2017-07-21 21:16:29 UTC (rev 219743)
+++ trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.h	2017-07-21 21:20:25 UTC (rev 219744)
@@ -27,6 +27,7 @@
 
 #include "CSSParserMode.h"
 #include "CSSStyleDeclaration.h"
+#include "DeprecatedCSSOMValue.h"
 #include <memory>
 #include <wtf/HashMap.h>
 #include <wtf/RefPtr.h>
@@ -36,7 +37,6 @@
 class CSSRule;
 class CSSProperty;
 class CSSValue;
-class DeprecatedCSSOMValue;
 class MutableStyleProperties;
 class StyleSheetContents;
 class StyledElement;

Modified: trunk/Source/WebCore/svg/SVGElement.cpp (219743 => 219744)


--- trunk/Source/WebCore/svg/SVGElement.cpp	2017-07-21 21:16:29 UTC (rev 219743)
+++ trunk/Source/WebCore/svg/SVGElement.cpp	2017-07-21 21:20:25 UTC (rev 219744)
@@ -1046,7 +1046,7 @@
     auto cssValue = style->getPropertyCSSValue(propertyID);
     if (!cssValue)
         return nullptr;
-    return cssValue->createDeprecatedCSSOMWrapper();
+    return cssValue->createDeprecatedCSSOMWrapper(style->ensureCSSStyleDeclaration());
 }
 
 bool SVGElement::instanceUpdatesBlocked() const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to