Title: [292343] branches/safari-613-branch/Source/WebCore
Revision
292343
Author
[email protected]
Date
2022-04-04 14:56:22 -0700 (Mon, 04 Apr 2022)

Log Message

Cherry-pick r291964. rdar://91259284

    Optimize toJS() for HTMLElements
    https://bugs.webkit.org/show_bug.cgi?id=238426

    Reviewed by Yusuke Suzuki.

    Optimize toJS() for HTMLElements. Previously, the more generic Element's toJS() would be called,
    which would have to do more checks.

    This is a 0.6% progression on Speedometer 2.0 on MacBook Air 10,1 (AS).

    bindings/js/JSHTMLElementCustom.cpp:
    (WebCore::toJS):
    (WebCore::toJSNewlyCreated):

    html/HTMLElement.idl:

Modified Paths

Diff

Modified: branches/safari-613-branch/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp (292342 => 292343)


--- branches/safari-613-branch/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp	2022-04-04 21:56:20 UTC (rev 292342)
+++ branches/safari-613-branch/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp	2022-04-04 21:56:22 UTC (rev 292343)
@@ -32,6 +32,7 @@
 #include "HTMLFormElement.h"
 #include "JSCustomElementInterface.h"
 #include "JSDOMConstructorBase.h"
+#include "JSHTMLElementWrapperFactory.h"
 #include "JSNodeCustom.h"
 #include "ScriptExecutionContext.h"
 #include <_javascript_Core/InternalFunction.h>
@@ -130,4 +131,23 @@
     return JSWithScope::create(vm, lexicalGlobalObject, scope, asObject(toJS(lexicalGlobalObject, globalObject(), element)));
 }
 
+JSValue toJS(JSGlobalObject*, JSDOMGlobalObject* globalObject, HTMLElement& element)
+{
+    if (auto* wrapper = getCachedWrapper(globalObject->world(), element))
+        return wrapper;
+    return createJSHTMLWrapper(globalObject, element);
+}
+
+JSValue toJSNewlyCreated(JSGlobalObject*, JSDOMGlobalObject* globalObject, Ref<HTMLElement>&& element)
+{
+    if (element->isDefinedCustomElement()) {
+        JSValue result = getCachedWrapper(globalObject->world(), element);
+        if (result)
+            return result;
+        ASSERT(!globalObject->vm().exceptionForInspection());
+    }
+    ASSERT(!getCachedWrapper(globalObject->world(), element));
+    return createJSHTMLWrapper(globalObject, WTFMove(element));
+}
+
 } // namespace WebCore

Modified: branches/safari-613-branch/Source/WebCore/html/HTMLElement.idl (292342 => 292343)


--- branches/safari-613-branch/Source/WebCore/html/HTMLElement.idl	2022-04-04 21:56:20 UTC (rev 292342)
+++ branches/safari-613-branch/Source/WebCore/html/HTMLElement.idl	2022-04-04 21:56:22 UTC (rev 292343)
@@ -20,6 +20,7 @@
 
 [
     CustomPushEventHandlerScope,
+    CustomToJSObject,
     ExportMacro=WEBCORE_EXPORT,
     Exposed=Window,
     GenerateForEachEventHandlerContentAttribute,
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to