Title: [274393] trunk
Revision
274393
Author
[email protected]
Date
2021-03-13 18:47:53 -0800 (Sat, 13 Mar 2021)

Log Message

Unreviewed, reverting r274379.
https://bugs.webkit.org/show_bug.cgi?id=223154

Some LayoutTests are crashing

Reverted changeset:

"Cache cross-origin methods / accessors of Window and Location
per lexical global object"
https://bugs.webkit.org/show_bug.cgi?id=222739
https://trac.webkit.org/changeset/274379

Modified Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (274392 => 274393)


--- trunk/LayoutTests/ChangeLog	2021-03-13 21:55:51 UTC (rev 274392)
+++ trunk/LayoutTests/ChangeLog	2021-03-14 02:47:53 UTC (rev 274393)
@@ -1,3 +1,17 @@
+2021-03-13  Commit Queue  <[email protected]>
+
+        Unreviewed, reverting r274379.
+        https://bugs.webkit.org/show_bug.cgi?id=223154
+
+        Some LayoutTests are crashing
+
+        Reverted changeset:
+
+        "Cache cross-origin methods / accessors of Window and Location
+        per lexical global object"
+        https://bugs.webkit.org/show_bug.cgi?id=222739
+        https://trac.webkit.org/changeset/274379
+
 2021-03-13  Chris Gambrell  <[email protected]>
 
         [ macOS Wk2 ] http/tests/security/contentSecurityPolicy/report-only-connect-src-xmlhttprequest-redirect-to-blocked.php is constantly text failing

Modified: trunk/LayoutTests/http/tests/navigation/process-swap-window-open-expected.txt (274392 => 274393)


--- trunk/LayoutTests/http/tests/navigation/process-swap-window-open-expected.txt	2021-03-13 21:55:51 UTC (rev 274392)
+++ trunk/LayoutTests/http/tests/navigation/process-swap-window-open-expected.txt	2021-03-14 02:47:53 UTC (rev 274393)
@@ -28,11 +28,6 @@
 PASS w.focus is an instance of Function
 PASS w.blur is an instance of Function
 PASS w.postMessage is an instance of Function
-PASS w.close is w.close
-PASS w.focus is w.focus
-PASS w.blur is w.blur
-PASS w.postMessage is w.postMessage
-PASS w.postMessage.length is 1
 PASS w.postMessage('test', '*') did not throw exception.
 PASS w.focus() did not throw exception.
 PASS w.blur() did not throw exception.

Modified: trunk/LayoutTests/http/tests/navigation/process-swap-window-open.html (274392 => 274393)


--- trunk/LayoutTests/http/tests/navigation/process-swap-window-open.html	2021-03-13 21:55:51 UTC (rev 274392)
+++ trunk/LayoutTests/http/tests/navigation/process-swap-window-open.html	2021-03-14 02:47:53 UTC (rev 274393)
@@ -36,11 +36,6 @@
     shouldBeType("w.focus", "Function");
     shouldBeType("w.blur", "Function");
     shouldBeType("w.postMessage", "Function");
-    shouldBe("w.close", "w.close");
-    shouldBe("w.focus", "w.focus");
-    shouldBe("w.blur", "w.blur");
-    shouldBe("w.postMessage", "w.postMessage");
-    shouldBe("w.postMessage.length", "1");
     shouldNotThrow("w.postMessage('test', '*')");
     shouldNotThrow("w.focus()");
     shouldNotThrow("w.blur()");

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (274392 => 274393)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-03-13 21:55:51 UTC (rev 274392)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-03-14 02:47:53 UTC (rev 274393)
@@ -1,3 +1,17 @@
+2021-03-13  Commit Queue  <[email protected]>
+
+        Unreviewed, reverting r274379.
+        https://bugs.webkit.org/show_bug.cgi?id=223154
+
+        Some LayoutTests are crashing
+
+        Reverted changeset:
+
+        "Cache cross-origin methods / accessors of Window and Location
+        per lexical global object"
+        https://bugs.webkit.org/show_bug.cgi?id=222739
+        https://trac.webkit.org/changeset/274379
+
 2021-03-13  Antoine Quint  <[email protected]>
 
         Fix interpolation of clip CSS property

Deleted: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-function-caching-expected.txt (274392 => 274393)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-function-caching-expected.txt	2021-03-13 21:55:51 UTC (rev 274392)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-function-caching-expected.txt	2021-03-14 02:47:53 UTC (rev 274393)
@@ -1,6 +0,0 @@
-
-PASS Cross-origin Window methods are cached
-PASS Cross-origin Window accessors are cached
-PASS Cross-origin Location `replace` method is cached
-PASS Cross-origin Location `href` setter is cached
-

Deleted: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-function-caching.html (274392 => 274393)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-function-caching.html	2021-03-13 21:55:51 UTC (rev 274392)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-function-caching.html	2021-03-14 02:47:53 UTC (rev 274393)
@@ -1,49 +0,0 @@
-<!doctype html>
-<meta charset=utf-8>
-<title>Cross-origin methods and accessors are cached per Realm via[[CrossOriginPropertyDescriptorMap]]</title>
-<link rel="help" href=""
-<script src=""
-<script src=""
-<script src=""
-<script src=""
-<div id=log></div>
-<script>
-"use strict";
-
-promise_test(async t => {
-    const w = await makeCrossOriginWindow(t);
-    for (const {key} of crossOriginWindowMethods) {
-        assert_equals(w[key], w[key], `w.${key} via [[Get]]`);
-        const desc1 = Object.getOwnPropertyDescriptor(w, key);
-        const desc2 = Object.getOwnPropertyDescriptor(w, key);
-        assert_equals(desc1.value, desc2.value, `w.${key} via [[GetOwnProperty]]`);
-    }
-}, "Cross-origin Window methods are cached");
-
-promise_test(async t => {
-    const w = await makeCrossOriginWindow(t);
-    for (const {key} of crossOriginWindowAccessors) {
-        const desc1 = Object.getOwnPropertyDescriptor(w, key);
-        const desc2 = Object.getOwnPropertyDescriptor(w, key);
-        assert_equals(desc1.get, desc2.get, `w.${key} getter`);
-        if (key === "location") {
-            assert_equals(desc1.set, desc2.set, `w.${key} setter`);
-        }
-    }
-}, "Cross-origin Window accessors are cached");
-
-promise_test(async t => {
-    const w = await makeCrossOriginWindow(t);
-    assert_equals(w.location.replace, w.location.replace, "via [[Get]]");
-    const desc1 = Object.getOwnPropertyDescriptor(w.location, "replace");
-    const desc2 = Object.getOwnPropertyDescriptor(w.location, "replace");
-    assert_equals(desc1.value, desc2.value, "via [[GetOwnProperty]]");
-}, "Cross-origin Location `replace` method is cached");
-
-promise_test(async t => {
-    const w = await makeCrossOriginWindow(t);
-    const desc1 = Object.getOwnPropertyDescriptor(w.location, "href");
-    const desc2 = Object.getOwnPropertyDescriptor(w.location, "href");
-    assert_equals(desc1.set, desc2.set);
-}, "Cross-origin Location `href` setter is cached");
-</script>

Deleted: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-function-common.js (274392 => 274393)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-function-common.js	2021-03-13 21:55:51 UTC (rev 274392)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-function-common.js	2021-03-14 02:47:53 UTC (rev 274393)
@@ -1,34 +0,0 @@
-"use strict";
-
-const crossOriginWindowMethods = [
-    {key: "close", length: 0},
-    {key: "focus", length: 0},
-    {key: "blur", length: 0},
-    {key: "postMessage", length: 1},
-];
-
-const crossOriginWindowAccessors = [
-    "window",
-    "self",
-    "location",
-    "closed",
-    "frames",
-    "length",
-    "top",
-    "opener",
-    "parent",
-].map(key => ({key}));
-
-const makeCrossOriginWindow = t => {
-    const iframe = document.createElement("iframe");
-    const path = location.pathname.slice(0, location.pathname.lastIndexOf("/")) + "/frame.html";
-    iframe.src = "" + path;
-
-    return new Promise((resolve, reject) => {
-        iframe._onload_ = () => { resolve(iframe.contentWindow); };
-        iframe._onerror_ = reject;
-
-        document.body.append(iframe);
-        t.add_cleanup(() => { iframe.remove(); });
-    });
-};

Deleted: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-function-length-expected.txt (274392 => 274393)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-function-length-expected.txt	2021-03-13 21:55:51 UTC (rev 274392)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-function-length-expected.txt	2021-03-14 02:47:53 UTC (rev 274393)
@@ -1,6 +0,0 @@
-
-PASS Cross-origin Window methods have correct 'length'
-PASS Cross-origin Window accessors have correct 'length'
-PASS Cross-origin Location `replace` method has correct 'length'
-PASS Cross-origin Location `href` setter has correct 'length'
-

Deleted: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-function-length.html (274392 => 274393)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-function-length.html	2021-03-13 21:55:51 UTC (rev 274392)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-function-length.html	2021-03-14 02:47:53 UTC (rev 274393)
@@ -1,45 +0,0 @@
-<!doctype html>
-<meta charset=utf-8>
-<title>Cross-origin methods and accessors are created with correct 'length' property</title>
-<link rel="help" href=""
-<script src=""
-<script src=""
-<script src=""
-<script src=""
-<div id=log></div>
-<script>
-"use strict";
-
-promise_test(async t => {
-    const w = await makeCrossOriginWindow(t);
-    for (const {key, length} of crossOriginWindowMethods) {
-        assert_equals(w[key].length, length, `w.${key} via [[Get]]`);
-        const desc = Object.getOwnPropertyDescriptor(w, key);
-        assert_equals(desc.value.length, length, `w.${key} via [[GetOwnProperty]]`);
-    }
-}, "Cross-origin Window methods have correct 'length'");
-
-promise_test(async t => {
-    const w = await makeCrossOriginWindow(t);
-    for (const {key} of crossOriginWindowAccessors) {
-        const desc = Object.getOwnPropertyDescriptor(w, key);
-        assert_equals(desc.get.length, 0, `w.${key}`);
-        if (key === "location") {
-            assert_equals(desc.set.length, 1, `w.${key}`);
-        }
-    }
-}, "Cross-origin Window accessors have correct 'length'");
-
-promise_test(async t => {
-    const w = await makeCrossOriginWindow(t);
-    assert_equals(w.location.replace.length, 1);
-    const desc = Object.getOwnPropertyDescriptor(w.location, "replace");
-    assert_equals(desc.value.length, 1);
-}, "Cross-origin Location `replace` method has correct 'length'");
-
-promise_test(async t => {
-    const w = await makeCrossOriginWindow(t);
-    const desc = Object.getOwnPropertyDescriptor(w.location, "href");
-    assert_equals(desc.set.length, 1);
-}, "Cross-origin Location `href` setter has correct 'length'");
-</script>

Deleted: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-function-name-expected.txt (274392 => 274393)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-function-name-expected.txt	2021-03-13 21:55:51 UTC (rev 274392)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-function-name-expected.txt	2021-03-14 02:47:53 UTC (rev 274393)
@@ -1,6 +0,0 @@
-
-PASS Cross-origin Window methods have correct 'name'
-PASS Cross-origin Window accessors have correct 'name'
-PASS Cross-origin Location `replace` method has correct 'name'
-PASS Cross-origin Location `href` setter has correct 'name'
-

Deleted: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-function-name.html (274392 => 274393)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-function-name.html	2021-03-13 21:55:51 UTC (rev 274392)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-function-name.html	2021-03-14 02:47:53 UTC (rev 274393)
@@ -1,45 +0,0 @@
-<!doctype html>
-<meta charset=utf-8>
-<title>Cross-origin methods and accessors are created with correct 'name' property</title>
-<link rel="help" href=""
-<script src=""
-<script src=""
-<script src=""
-<script src=""
-<div id=log></div>
-<script>
-"use strict";
-
-promise_test(async t => {
-    const w = await makeCrossOriginWindow(t);
-    for (const {key} of crossOriginWindowMethods) {
-        assert_equals(w[key].name, key, `w.${key} via [[Get]]`);
-        const desc = Object.getOwnPropertyDescriptor(w, key);
-        assert_equals(desc.value.name, key, `w.${key} via [[GetOwnProperty]]`);
-    }
-}, "Cross-origin Window methods have correct 'name'");
-
-promise_test(async t => {
-    const w = await makeCrossOriginWindow(t);
-    for (const {key} of crossOriginWindowAccessors) {
-        const desc = Object.getOwnPropertyDescriptor(w, key);
-        assert_equals(desc.get.name, `get ${key}`);
-        if (key === "location") {
-            assert_equals(desc.set.name, `set ${key}`);
-        }
-    }
-}, "Cross-origin Window accessors have correct 'name'");
-
-promise_test(async t => {
-    const w = await makeCrossOriginWindow(t);
-    assert_equals(w.location.replace.name, "replace");
-    const desc = Object.getOwnPropertyDescriptor(w.location, "replace");
-    assert_equals(desc.value.name, "replace");
-}, "Cross-origin Location `replace` method has correct 'name'");
-
-promise_test(async t => {
-    const w = await makeCrossOriginWindow(t);
-    const desc = Object.getOwnPropertyDescriptor(w.location, "href");
-    assert_equals(desc.set.name, "set href");
-}, "Cross-origin Location `href` setter has correct 'name'");
-</script>

Modified: trunk/Source/_javascript_Core/ChangeLog (274392 => 274393)


--- trunk/Source/_javascript_Core/ChangeLog	2021-03-13 21:55:51 UTC (rev 274392)
+++ trunk/Source/_javascript_Core/ChangeLog	2021-03-14 02:47:53 UTC (rev 274393)
@@ -1,3 +1,17 @@
+2021-03-13  Commit Queue  <[email protected]>
+
+        Unreviewed, reverting r274379.
+        https://bugs.webkit.org/show_bug.cgi?id=223154
+
+        Some LayoutTests are crashing
+
+        Reverted changeset:
+
+        "Cache cross-origin methods / accessors of Window and Location
+        per lexical global object"
+        https://bugs.webkit.org/show_bug.cgi?id=222739
+        https://trac.webkit.org/changeset/274379
+
 2021-03-13  Alexey Shvayka  <[email protected]>
 
         Cache cross-origin methods / accessors of Window and Location per lexical global object

Modified: trunk/Source/_javascript_Core/runtime/JSCustomGetterFunction.cpp (274392 => 274393)


--- trunk/Source/_javascript_Core/runtime/JSCustomGetterFunction.cpp	2021-03-13 21:55:51 UTC (rev 274392)
+++ trunk/Source/_javascript_Core/runtime/JSCustomGetterFunction.cpp	2021-03-14 02:47:53 UTC (rev 274393)
@@ -40,7 +40,9 @@
 
     JSCustomGetterFunction* customGetterFunction = jsCast<JSCustomGetterFunction*>(callFrame->jsCallee());
     JSValue thisValue = callFrame->thisValue();
+
     GetValueFunc getter = customGetterFunction->getter();
+    ASSERT(getter);
 
     if (auto domAttribute = customGetterFunction->domAttribute()) {
         if (!thisValue.inherits(vm, domAttribute->classInfo))
@@ -60,7 +62,6 @@
 
 JSCustomGetterFunction* JSCustomGetterFunction::create(VM& vm, JSGlobalObject* globalObject, const PropertyName& propertyName, GetValueFunc getter, Optional<DOMAttributeAnnotation> domAttribute)
 {
-    ASSERT(getter);
     NativeExecutable* executable = vm.getHostFunction(customGetterFunctionCall, callHostFunctionAsConstructor, String(propertyName.publicName()));
     Structure* structure = globalObject->customGetterFunctionStructure();
     JSCustomGetterFunction* function = new (NotNull, allocateCell<JSCustomGetterFunction>(vm.heap)) JSCustomGetterFunction(vm, executable, globalObject, structure, propertyName, getter, domAttribute);

Modified: trunk/Source/_javascript_Core/runtime/JSCustomSetterFunction.cpp (274392 => 274393)


--- trunk/Source/_javascript_Core/runtime/JSCustomSetterFunction.cpp	2021-03-13 21:55:51 UTC (rev 274392)
+++ trunk/Source/_javascript_Core/runtime/JSCustomSetterFunction.cpp	2021-03-14 02:47:53 UTC (rev 274393)
@@ -36,6 +36,7 @@
 JSC_DEFINE_HOST_FUNCTION(customSetterFunctionCall, (JSGlobalObject* globalObject, CallFrame* callFrame))
 {
     PutValueFunc setter = jsCast<JSCustomSetterFunction*>(callFrame->jsCallee())->setter();
+    ASSERT(setter);
     setter(globalObject, JSValue::encode(callFrame->thisValue()), JSValue::encode(callFrame->argument(0)));
     return JSValue::encode(jsUndefined());
 }
@@ -48,7 +49,6 @@
 
 JSCustomSetterFunction* JSCustomSetterFunction::create(VM& vm, JSGlobalObject* globalObject, const PropertyName& propertyName, PutValueFunc setter)
 {
-    ASSERT(setter);
     NativeExecutable* executable = vm.getHostFunction(customSetterFunctionCall, callHostFunctionAsConstructor, String(propertyName.publicName()));
     Structure* structure = globalObject->customSetterFunctionStructure();
     JSCustomSetterFunction* function = new (NotNull, allocateCell<JSCustomSetterFunction>(vm.heap)) JSCustomSetterFunction(vm, executable, globalObject, structure, setter);

Modified: trunk/Source/_javascript_Core/runtime/JSObject.cpp (274392 => 274393)


--- trunk/Source/_javascript_Core/runtime/JSObject.cpp	2021-03-13 21:55:51 UTC (rev 274392)
+++ trunk/Source/_javascript_Core/runtime/JSObject.cpp	2021-03-14 02:47:53 UTC (rev 274393)
@@ -3521,18 +3521,24 @@
     return Butterfly::createOrGrowPropertyStorage(butterfly(), vm, this, structure(vm), oldSize, newSize);
 }
 
-static JSCustomGetterFunction* createCustomGetterFunction(JSGlobalObject* globalObject, PropertyName propertyName, GetValueFunc getValueFunc, Optional<DOMAttributeAnnotation> domAttribute)
+static JSCustomGetterFunction* getCustomGetterFunction(JSGlobalObject* globalObject, PropertyName propertyName, GetValueFunc getValueFunc, Optional<DOMAttributeAnnotation> domAttribute)
 {
-    return globalObject->customGetterFunctionMap().ensure(getValueFunc, [&] {
-        return JSCustomGetterFunction::create(globalObject->vm(), globalObject, propertyName, getValueFunc, domAttribute);
-    }).iterator->value.get();
+    JSCustomGetterFunction* customGetterFunction = globalObject->customGetterFunctionMap().get(getValueFunc);
+    if (!customGetterFunction) {
+        customGetterFunction = JSCustomGetterFunction::create(globalObject->vm(), globalObject, propertyName, getValueFunc, domAttribute);
+        globalObject->customGetterFunctionMap().set(getValueFunc, customGetterFunction);
+    }
+    return customGetterFunction;
 }
 
-static JSCustomSetterFunction* createCustomSetterFunction(JSGlobalObject* globalObject, PropertyName propertyName, PutValueFunc putValueFunc)
+static JSCustomSetterFunction* getCustomSetterFunction(JSGlobalObject* globalObject, PropertyName propertyName, PutValueFunc putValueFunc)
 {
-    return globalObject->customSetterFunctionMap().ensure(putValueFunc, [&] {
-        return JSCustomSetterFunction::create(globalObject->vm(), globalObject, propertyName, putValueFunc);
-    }).iterator->value.get();
+    JSCustomSetterFunction* customSetterFunction = globalObject->customSetterFunctionMap().get(putValueFunc);
+    if (!customSetterFunction) {
+        customSetterFunction = JSCustomSetterFunction::create(globalObject->vm(), globalObject, propertyName, putValueFunc);
+        globalObject->customSetterFunctionMap().set(putValueFunc, customSetterFunction);
+    }
+    return customSetterFunction;
 }
 
 bool JSObject::getOwnPropertyDescriptor(JSGlobalObject* globalObject, PropertyName propertyName, PropertyDescriptor& descriptor)
@@ -3553,9 +3559,9 @@
         descriptor.setAccessorDescriptor((slot.attributes() | PropertyAttribute::Accessor) & ~PropertyAttribute::CustomAccessor);
         JSGlobalObject* slotBaseGlobalObject = slot.slotBase()->globalObject(vm);
         if (slot.customGetter())
-            descriptor.setGetter(createCustomGetterFunction(slotBaseGlobalObject, propertyName, slot.customGetter(), slot.domAttribute()));
+            descriptor.setGetter(getCustomGetterFunction(slotBaseGlobalObject, propertyName, slot.customGetter(), slot.domAttribute()));
         if (slot.customSetter())
-            descriptor.setSetter(createCustomSetterFunction(slotBaseGlobalObject, propertyName, slot.customSetter()));
+            descriptor.setSetter(getCustomSetterFunction(slotBaseGlobalObject, propertyName, slot.customSetter()));
     } else {
         JSValue value = slot.getValue(globalObject, propertyName);
         RETURN_IF_EXCEPTION(scope, false);

Modified: trunk/Source/_javascript_Core/runtime/Lookup.h (274392 => 274393)


--- trunk/Source/_javascript_Core/runtime/Lookup.h	2021-03-13 21:55:51 UTC (rev 274392)
+++ trunk/Source/_javascript_Core/runtime/Lookup.h	2021-03-14 02:47:53 UTC (rev 274393)
@@ -414,4 +414,9 @@
     }
 }
 
+template<RawNativeFunction nativeFunction, int length> EncodedJSValue nonCachingStaticFunctionGetterImpl(JSGlobalObject* globalObject, PropertyName propertyName)
+{
+    return JSValue::encode(JSFunction::create(globalObject->vm(), globalObject, length, propertyName.publicName(), nativeFunction));
+}
+
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/runtime/WeakGCMap.h (274392 => 274393)


--- trunk/Source/_javascript_Core/runtime/WeakGCMap.h	2021-03-13 21:55:51 UTC (rev 274392)
+++ trunk/Source/_javascript_Core/runtime/WeakGCMap.h	2021-03-14 02:47:53 UTC (rev 274393)
@@ -64,12 +64,6 @@
         return m_map.set(key, WTFMove(value));
     }
 
-    template<typename Functor>
-    AddResult ensure(const KeyType& key, Functor&& functor)
-    {
-        return m_map.ensure(key, std::forward<Functor>(functor));
-    }
-
     bool remove(const KeyType& key)
     {
         return m_map.remove(key);

Modified: trunk/Source/WebCore/ChangeLog (274392 => 274393)


--- trunk/Source/WebCore/ChangeLog	2021-03-13 21:55:51 UTC (rev 274392)
+++ trunk/Source/WebCore/ChangeLog	2021-03-14 02:47:53 UTC (rev 274393)
@@ -1,3 +1,17 @@
+2021-03-13  Commit Queue  <[email protected]>
+
+        Unreviewed, reverting r274379.
+        https://bugs.webkit.org/show_bug.cgi?id=223154
+
+        Some LayoutTests are crashing
+
+        Reverted changeset:
+
+        "Cache cross-origin methods / accessors of Window and Location
+        per lexical global object"
+        https://bugs.webkit.org/show_bug.cgi?id=222739
+        https://trac.webkit.org/changeset/274379
+
 2021-03-13  Antoine Quint  <[email protected]>
 
         Fix interpolation of clip CSS property

Modified: trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp (274392 => 274393)


--- trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp	2021-03-13 21:55:51 UTC (rev 274392)
+++ trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp	2021-03-14 02:47:53 UTC (rev 274393)
@@ -54,13 +54,9 @@
 #include "WorkletGlobalScope.h"
 #include <_javascript_Core/BuiltinNames.h>
 #include <_javascript_Core/CodeBlock.h>
-#include <_javascript_Core/GetterSetter.h>
-#include <_javascript_Core/JSCustomGetterFunction.h>
-#include <_javascript_Core/JSCustomSetterFunction.h>
 #include <_javascript_Core/JSInternalPromise.h>
 #include <_javascript_Core/StructureInlines.h>
 #include <_javascript_Core/WasmStreamingCompiler.h>
-#include <_javascript_Core/WeakGCMapInlines.h>
 
 namespace WebCore {
 using namespace JSC;
@@ -79,8 +75,6 @@
     , m_world(WTFMove(world))
     , m_worldIsNormal(m_world->isNormal())
     , m_builtinInternalFunctions(vm)
-    , m_crossOriginFunctionMap(vm)
-    , m_crossOriginGetterSetterMap(vm)
 {
 }
 
@@ -304,26 +298,6 @@
         guarded->clear();
 }
 
-JSFunction* JSDOMGlobalObject::createCrossOriginFunction(JSGlobalObject* lexicalGlobalObject, PropertyName propertyName, NativeFunction nativeFunction, unsigned length)
-{
-    CrossOriginMapKey key = std::make_pair(lexicalGlobalObject, nativeFunction.rawPointer());
-    return m_crossOriginFunctionMap.ensure(key, [&] {
-        return JSFunction::create(lexicalGlobalObject->vm(), lexicalGlobalObject, length, propertyName.publicName(), nativeFunction);
-    }).iterator->value.get();
-}
-
-GetterSetter* JSDOMGlobalObject::createCrossOriginGetterSetter(JSGlobalObject* lexicalGlobalObject, PropertyName propertyName, GetValueFunc getter, PutValueFunc setter)
-{
-    ASSERT(getter || setter);
-    CrossOriginMapKey key = std::make_pair(lexicalGlobalObject, getter ? reinterpret_cast<void*>(getter) : reinterpret_cast<void*>(setter));
-    return m_crossOriginGetterSetterMap.ensure(key, [&] {
-        auto& vm = lexicalGlobalObject->vm();
-        return GetterSetter::create(vm, lexicalGlobalObject,
-            getter ? JSCustomGetterFunction::create(vm, lexicalGlobalObject, propertyName, getter) : nullptr,
-            setter ? JSCustomSetterFunction::create(vm, lexicalGlobalObject, propertyName, setter) : nullptr);
-    }).iterator->value.get();
-}
-
 #if ENABLE(WEBASSEMBLY)
 // https://webassembly.github.io/spec/web-api/index.html#compile-a-potential-webassembly-response
 static JSC::JSPromise* handleResponseOnStreamingAction(JSC::JSGlobalObject* globalObject, JSC::JSValue source, JSC::Wasm::CompilerMode compilerMode, JSC::JSObject* importObject)

Modified: trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.h (274392 => 274393)


--- trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.h	2021-03-13 21:55:51 UTC (rev 274392)
+++ trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.h	2021-03-14 02:47:53 UTC (rev 274393)
@@ -31,7 +31,6 @@
 #include <_javascript_Core/JSGlobalObject.h>
 #include <_javascript_Core/JSObjectInlines.h>
 #include <_javascript_Core/LockDuringMarking.h>
-#include <_javascript_Core/WeakGCMap.h>
 
 namespace WebCore {
 
@@ -84,9 +83,6 @@
 
     JSC::JSProxy& proxy() const { ASSERT(m_proxy); return *m_proxy.get(); }
 
-    JSC::JSFunction* createCrossOriginFunction(JSC::JSGlobalObject*, JSC::PropertyName, JSC::NativeFunction, unsigned length);
-    JSC::GetterSetter* createCrossOriginGetterSetter(JSC::JSGlobalObject*, JSC::PropertyName, JSC::GetValueFunc, JSC::PutValueFunc);
-
 public:
     ~JSDOMGlobalObject();
 
@@ -128,11 +124,7 @@
     void addBuiltinGlobals(JSC::VM&);
     friend void JSBuiltinInternalFunctions::initialize(JSDOMGlobalObject&);
 
-    using CrossOriginMapKey = std::pair<JSC::JSGlobalObject*, void*>;
-
     JSBuiltinInternalFunctions m_builtinInternalFunctions;
-    JSC::WeakGCMap<CrossOriginMapKey, JSC::JSFunction> m_crossOriginFunctionMap;
-    JSC::WeakGCMap<CrossOriginMapKey, JSC::GetterSetter> m_crossOriginGetterSetterMap;
 };
 
 template<class ConstructorClass>

Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp (274392 => 274393)


--- trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp	2021-03-13 21:55:51 UTC (rev 274392)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp	2021-03-14 02:47:53 UTC (rev 274393)
@@ -48,9 +48,12 @@
 #include "Settings.h"
 #include "WebCoreJSClientData.h"
 #include <_javascript_Core/BuiltinNames.h>
+#include <_javascript_Core/GetterSetter.h>
 #include <_javascript_Core/HeapAnalyzer.h>
 #include <_javascript_Core/InternalFunction.h>
 #include <_javascript_Core/JSCInlines.h>
+#include <_javascript_Core/JSCustomGetterFunction.h>
+#include <_javascript_Core/JSCustomSetterFunction.h>
 #include <_javascript_Core/JSFunction.h>
 #include <_javascript_Core/JSMicrotask.h>
 #include <_javascript_Core/Lookup.h>
@@ -64,10 +67,58 @@
 using namespace JSC;
 
 static JSC_DECLARE_HOST_FUNCTION(jsDOMWindowInstanceFunction_openDatabase);
+static JSC_DECLARE_CUSTOM_GETTER(jsRemoteDOMWindowInstanceFunction_blurNonCaching);
+static JSC_DECLARE_CUSTOM_GETTER(jsDOMWindowInstanceFunction_blurNonCaching);
+static JSC_DECLARE_CUSTOM_GETTER(jsRemoteDOMWindowInstanceFunction_closeNonCaching);
+static JSC_DECLARE_CUSTOM_GETTER(jsDOMWindowInstanceFunction_closeNonCaching);
+static JSC_DECLARE_CUSTOM_GETTER(jsRemoteDOMWindowInstanceFunction_focusNonCaching);
+static JSC_DECLARE_CUSTOM_GETTER(jsDOMWindowInstanceFunction_focusNonCaching);
+static JSC_DECLARE_CUSTOM_GETTER(jsRemoteDOMWindowInstanceFunction_postMessageNonCaching);
+static JSC_DECLARE_CUSTOM_GETTER(jsDOMWindowInstanceFunction_postMessageNonCaching);
 #if ENABLE(USER_MESSAGE_HANDLERS)
 static JSC_DECLARE_CUSTOM_GETTER(jsDOMWindow_webkit);
 #endif
 
+JSC_DEFINE_CUSTOM_GETTER(jsRemoteDOMWindowInstanceFunction_blurNonCaching, (JSGlobalObject* globalObject, EncodedJSValue, PropertyName propertyName))
+{
+    return nonCachingStaticFunctionGetterImpl<jsRemoteDOMWindowInstanceFunction_blur, 0>(globalObject, propertyName);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsDOMWindowInstanceFunction_blurNonCaching, (JSGlobalObject* globalObject, EncodedJSValue, PropertyName propertyName))
+{
+    return nonCachingStaticFunctionGetterImpl<jsDOMWindowInstanceFunction_blur, 0>(globalObject, propertyName);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsRemoteDOMWindowInstanceFunction_closeNonCaching, (JSGlobalObject* globalObject, EncodedJSValue, PropertyName propertyName))
+{
+    return nonCachingStaticFunctionGetterImpl<jsRemoteDOMWindowInstanceFunction_close, 0>(globalObject, propertyName);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsDOMWindowInstanceFunction_closeNonCaching, (JSGlobalObject* globalObject, EncodedJSValue, PropertyName propertyName))
+{
+    return nonCachingStaticFunctionGetterImpl<jsDOMWindowInstanceFunction_close, 0>(globalObject, propertyName);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsRemoteDOMWindowInstanceFunction_focusNonCaching, (JSGlobalObject* globalObject, EncodedJSValue, PropertyName propertyName))
+{
+    return nonCachingStaticFunctionGetterImpl<jsRemoteDOMWindowInstanceFunction_focus, 0>(globalObject, propertyName);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsDOMWindowInstanceFunction_focusNonCaching, (JSGlobalObject* globalObject, EncodedJSValue, PropertyName propertyName))
+{
+    return nonCachingStaticFunctionGetterImpl<jsDOMWindowInstanceFunction_focus, 0>(globalObject, propertyName);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsRemoteDOMWindowInstanceFunction_postMessageNonCaching, (JSGlobalObject* globalObject, EncodedJSValue, PropertyName propertyName))
+{
+    return nonCachingStaticFunctionGetterImpl<jsRemoteDOMWindowInstanceFunction_postMessage, 0>(globalObject, propertyName);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsDOMWindowInstanceFunction_postMessageNonCaching, (JSGlobalObject* globalObject, EncodedJSValue, PropertyName propertyName))
+{
+    return nonCachingStaticFunctionGetterImpl<jsDOMWindowInstanceFunction_postMessage, 2>(globalObject, propertyName);
+}
+
 template<typename Visitor>
 void JSDOMWindow::visitAdditionalChildren(Visitor& visitor)
 {
@@ -106,34 +157,45 @@
     // https://html.spec.whatwg.org/#crossorigingetownpropertyhelper-(-o,-p-)
 
     // These are the functions we allow access to cross-origin (DoNotCheckSecurity in IDL).
-    auto* classInfo = windowType == DOMWindowType::Remote ? JSRemoteDOMWindow::info() : JSDOMWindow::info();
-    if (propertyName == builtinNames.closePublicName()
-        || propertyName == builtinNames.focusPublicName()
-        || propertyName == builtinNames.blurPublicName()
-        || propertyName == builtinNames.postMessagePublicName()) {
-        auto* entry = classInfo->staticPropHashTable->entry(propertyName);
-        auto* jsFunction = thisObject->createCrossOriginFunction(&lexicalGlobalObject, propertyName, entry->function(), entry->functionLength());
-        slot.setValue(thisObject, PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum, jsFunction);
+    // Always provide the original function, on a fresh uncached function object.
+    if (propertyName == builtinNames.blurPublicName()) {
+        slot.setCustom(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum), windowType == DOMWindowType::Remote ? jsRemoteDOMWindowInstanceFunction_blurNonCaching : jsDOMWindowInstanceFunction_blurNonCaching);
         return true;
     }
+    if (propertyName == builtinNames.closePublicName()) {
+        slot.setCustom(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum), windowType == DOMWindowType::Remote ? jsRemoteDOMWindowInstanceFunction_closeNonCaching : jsDOMWindowInstanceFunction_closeNonCaching);
+        return true;
+    }
+    if (propertyName == builtinNames.focusPublicName()) {
+        slot.setCustom(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum), windowType == DOMWindowType::Remote ? jsRemoteDOMWindowInstanceFunction_focusNonCaching : jsDOMWindowInstanceFunction_focusNonCaching);
+        return true;
+    }
+    if (propertyName == builtinNames.postMessagePublicName()) {
+        slot.setCustom(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum), windowType == DOMWindowType::Remote ? jsRemoteDOMWindowInstanceFunction_postMessageNonCaching : jsDOMWindowInstanceFunction_postMessageNonCaching);
+        return true;
+    }
 
     // When accessing cross-origin known Window properties, we always use the original property getter,
     // even if the property was removed / redefined. As of early 2016, this matches Firefox and Chrome's
     // behavior.
-    if (propertyName == builtinNames.windowPublicName()
-        || propertyName == builtinNames.selfPublicName()
-        || propertyName == builtinNames.locationPublicName()
-        || propertyName == builtinNames.closedPublicName()
-        || propertyName == builtinNames.framesPublicName()
-        || propertyName == vm.propertyNames->length
-        || propertyName == builtinNames.topPublicName()
-        || propertyName == builtinNames.openerPublicName()
-        || propertyName == builtinNames.parentPublicName()) {
-        auto* entry = classInfo->staticPropHashTable->entry(propertyName);
-        auto* setter = propertyName == builtinNames.locationPublicName() ? entry->propertyPutter() : nullptr;
-        auto* getterSetter = thisObject->createCrossOriginGetterSetter(&lexicalGlobalObject, propertyName, entry->propertyGetter(), setter);
-        slot.setGetterSlot(thisObject, PropertyAttribute::Accessor | PropertyAttribute::DontEnum, getterSetter);
-        return true;
+    auto* classInfo = windowType == DOMWindowType::Remote ? JSRemoteDOMWindow::info() : JSDOMWindow::info();
+    if (auto* entry = classInfo->staticPropHashTable->entry(propertyName)) {
+        // Only allow access to these specific properties.
+        if (propertyName == builtinNames.locationPublicName()
+            || propertyName == builtinNames.closedPublicName()
+            || propertyName == vm.propertyNames->length
+            || propertyName == builtinNames.selfPublicName()
+            || propertyName == builtinNames.windowPublicName()
+            || propertyName == builtinNames.framesPublicName()
+            || propertyName == builtinNames.openerPublicName()
+            || propertyName == builtinNames.parentPublicName()
+            || propertyName == builtinNames.topPublicName()) {
+            auto* getter = JSCustomGetterFunction::create(vm, &lexicalGlobalObject, propertyName, entry->propertyGetter());
+            auto* setter = propertyName == builtinNames.locationPublicName() ? JSCustomSetterFunction::create(vm, &lexicalGlobalObject, propertyName, entry->propertyPutter()) : nullptr;
+            auto* getterSetter = GetterSetter::create(vm, &lexicalGlobalObject, getter, setter);
+            slot.setGetterSlot(thisObject, PropertyAttribute::Accessor | PropertyAttribute::DontEnum, getterSetter);
+            return true;
+        }
     }
 
     // Check for child frames by name before built-in properties to match Mozilla. This does
@@ -203,7 +265,7 @@
         // Detect when we're getting the property 'showModalDialog', this is disabled, and has its original value.
         bool isShowModalDialogAndShouldHide = propertyName == static_cast<JSVMClientData*>(lexicalGlobalObject->vm().clientData)->builtinNames().showModalDialogPublicName()
             && (!frame || !DOMWindow::canShowModalDialog(*frame))
-            && slot.isValue() && isHostFunction(slot.getValue(lexicalGlobalObject, propertyName), s_info.staticPropHashTable->entry(propertyName)->function());
+            && slot.isValue() && isHostFunction(slot.getValue(lexicalGlobalObject, propertyName), jsDOMWindowInstanceFunction_showModalDialog);
         // Unless we're in the showModalDialog special case, we're done.
         if (!isShowModalDialogAndShouldHide)
             return true;

Modified: trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp (274392 => 274393)


--- trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp	2021-03-13 21:55:51 UTC (rev 274392)
+++ trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp	2021-03-14 02:47:53 UTC (rev 274393)
@@ -29,6 +29,8 @@
 #include "JSDOMWindowCustom.h"
 #include "RuntimeApplicationChecks.h"
 #include "WebCoreJSClientData.h"
+#include <_javascript_Core/GetterSetter.h>
+#include <_javascript_Core/JSCustomSetterFunction.h>
 #include <_javascript_Core/JSFunction.h>
 #include <_javascript_Core/Lookup.h>
 
@@ -35,6 +37,13 @@
 namespace WebCore {
 using namespace JSC;
 
+static JSC_DECLARE_CUSTOM_GETTER(jsLocationInstanceFunction_replaceNonCaching);
+
+JSC_DEFINE_CUSTOM_GETTER(jsLocationInstanceFunction_replaceNonCaching, (JSGlobalObject* globalObject, EncodedJSValue, PropertyName propertyName))
+{
+    return nonCachingStaticFunctionGetterImpl<jsLocationInstanceFunction_replace, 1>(globalObject, propertyName);
+}
+
 static bool getOwnPropertySlotCommon(JSLocation& thisObject, JSGlobalObject& lexicalGlobalObject, PropertyName propertyName, PropertySlot& slot)
 {
     VM& vm = lexicalGlobalObject.vm();
@@ -55,9 +64,7 @@
 
     // We only allow access to Location.replace() cross origin.
     if (propertyName == vm.propertyNames->replace) {
-        auto* entry = JSLocation::info()->staticPropHashTable->entry(propertyName);
-        auto* jsFunction = thisObject.globalObject()->createCrossOriginFunction(&lexicalGlobalObject, propertyName, entry->function(), entry->functionLength());
-        slot.setValue(&thisObject, PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum, jsFunction);
+        slot.setCustom(&thisObject, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum), jsLocationInstanceFunction_replaceNonCaching);
         return true;
     }
 
@@ -65,7 +72,8 @@
     // a descriptor that has a setter but no getter.
     if (slot.internalMethodType() == PropertySlot::InternalMethodType::GetOwnProperty && propertyName == static_cast<JSVMClientData*>(vm.clientData)->builtinNames().hrefPublicName()) {
         auto* entry = JSLocation::info()->staticPropHashTable->entry(propertyName);
-        auto* getterSetter = thisObject.globalObject()->createCrossOriginGetterSetter(&lexicalGlobalObject, propertyName, nullptr, entry->propertyPutter());
+        auto* setter = JSCustomSetterFunction::create(vm, &lexicalGlobalObject, propertyName, entry->propertyPutter());
+        auto* getterSetter = GetterSetter::create(vm, &lexicalGlobalObject, nullptr, setter);
         slot.setGetterSlot(&thisObject, PropertyAttribute::Accessor | PropertyAttribute::DontEnum, getterSetter);
         return true;
     }

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (274392 => 274393)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2021-03-13 21:55:51 UTC (rev 274392)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2021-03-14 02:47:53 UTC (rev 274393)
@@ -3066,6 +3066,9 @@
     my $numCustomOperations = 0;
     my $numCustomAttributes = 0;
 
+    my $hasForwardDeclaringOperations = 0;
+    my $hasForwardDeclaringAttributes = 0;
+
     my $hasDOMJITAttributes = 0;
 
     # Attribute and function enums
@@ -3081,6 +3084,8 @@
                 push(@headerContent, "#endif\n") if $conditionalString;
             }
             $hasDOMJITAttributes = 1 if $attribute->extendedAttributes->{DOMJIT};
+
+            $hasForwardDeclaringAttributes = 1 if $attribute->extendedAttributes->{ForwardDeclareInHeader};
         }
     }
 
@@ -3139,6 +3144,7 @@
 
     foreach my $operation (@{$interface->operations}) {
         $numCustomOperations++ if HasCustomMethod($operation);
+        $hasForwardDeclaringOperations = 1 if $operation->extendedAttributes->{ForwardDeclareInHeader};
     }
 
     if ($numCustomOperations > 0) {
@@ -3264,6 +3270,52 @@
 
     GeneratePrototypeDeclaration(\@headerContent, $className, $interface) if HeaderNeedsPrototypeDeclaration($interface);
 
+    if ($hasForwardDeclaringOperations) {
+        my $inAppleCopyright = 0;
+        push(@headerContent,"// Functions\n\n");
+        foreach my $operation (@{$interface->operations}) {
+            next if $operation->{overloadIndex} && $operation->{overloadIndex} > 1;
+            next unless $operation->extendedAttributes->{ForwardDeclareInHeader};
+
+            if ($operation->extendedAttributes->{AppleCopyright}) {
+                if (!$inAppleCopyright) {
+                    push(@headerContent, $beginAppleCopyrightForHeaderFiles);
+                    $inAppleCopyright = 1;
+                }
+            } elsif ($inAppleCopyright) {
+                push(@headerContent, $endAppleCopyright);
+                $inAppleCopyright = 0;
+            }
+
+            my $conditionalAttribute = GetConditionalForOperationConsideringOverloads($operation);
+            my $conditionalString = $conditionalAttribute ? $codeGenerator->GenerateConditionalStringFromAttributeValue($conditionalAttribute) : undef;
+            push(@headerContent, "#if ${conditionalString}\n") if $conditionalString;
+            my $functionName = GetFunctionName($interface, $className, $operation);
+            push(@headerContent, "JSC_DECLARE_HOST_FUNCTION(${functionName});\n");
+            push(@headerContent, "#endif\n") if $conditionalString;
+        }
+
+        push(@headerContent, $endAppleCopyright) if $inAppleCopyright;
+        push(@headerContent,"\n");
+    }
+
+    if ($hasForwardDeclaringAttributes) {
+        push(@headerContent,"// Attributes\n\n");
+        foreach my $attribute (@{$interface->attributes}) {
+            next unless $attribute->extendedAttributes->{ForwardDeclareInHeader};
+
+            my $conditionalString = $codeGenerator->GenerateConditionalString($attribute);
+            push(@headerContent, "#if ${conditionalString}\n") if $conditionalString;
+            my $getter = GetAttributeGetterName($interface, $className, $attribute);
+            push(@headerContent, "JSC_DECLARE_CUSTOM_GETTER(${getter});\n");
+            if (!IsReadonly($attribute)) {
+                my $setter = GetAttributeSetterName($interface, $className, $attribute);
+                push(@headerContent, "JSC_DECLARE_CUSTOM_SETTER(${setter});\n");
+            }
+            push(@headerContent, "#endif\n") if $conditionalString;
+        }
+    }
+
     # CheckJSCast Snippet function.
     if ($interface->extendedAttributes->{DOMJIT}) {
         $headerIncludes{"<_javascript_Core/Snippet.h>"} = 1;
@@ -4255,6 +4307,7 @@
         push(@implContent,"// Functions\n\n");
         foreach my $operation (@{$interface->operations}) {
             next if $operation->{overloadIndex} && $operation->{overloadIndex} > 1;
+            next if $operation->extendedAttributes->{ForwardDeclareInHeader};
             next if IsJSBuiltin($interface, $operation);
             next if $operation->name eq "[Symbol.Iterator]";
 
@@ -4300,6 +4353,7 @@
         }
 
         foreach my $attribute (@{$interface->attributes}) {
+            next if $attribute->extendedAttributes->{ForwardDeclareInHeader};
             next if IsJSBuiltin($interface, $attribute);
 
             my $conditionalString = $codeGenerator->GenerateConditionalString($attribute);

Modified: trunk/Source/WebCore/bindings/scripts/IDLAttributes.json (274392 => 274393)


--- trunk/Source/WebCore/bindings/scripts/IDLAttributes.json	2021-03-13 21:55:51 UTC (rev 274392)
+++ trunk/Source/WebCore/bindings/scripts/IDLAttributes.json	2021-03-14 02:47:53 UTC (rev 274393)
@@ -223,6 +223,9 @@
                 "url": "https://heycam.github.io/webidl/#Exposed"
             }
         },
+        "ForwardDeclareInHeader": {
+            "contextsAllowed": ["attribute", "operation"]
+        },
         "GenerateIsReachable": {
             "contextsAllowed": ["interface"],
             "values": ["", "Impl", "ImplWebGLRenderingContext", "ImplCanvasBase", "ImplDocument", "ImplElementRoot", "ImplOwnerNodeRoot", "ImplScriptExecutionContext", "ReachableFromDOMWindow", "ReachableFromNavigator"]

Modified: trunk/Source/WebCore/page/DOMWindow.idl (274392 => 274393)


--- trunk/Source/WebCore/page/DOMWindow.idl	2021-03-13 21:55:51 UTC (rev 274392)
+++ trunk/Source/WebCore/page/DOMWindow.idl	2021-03-14 02:47:53 UTC (rev 274393)
@@ -62,11 +62,11 @@
     [Replaceable] readonly attribute BarProp statusbar;
     [Replaceable] readonly attribute BarProp toolbar;
     attribute DOMString status;
-    [DoNotCheckSecurity, CallWith=IncumbentDocument] undefined close();
-    [DoNotCheckSecurity] readonly attribute boolean closed;
+    [DoNotCheckSecurity, CallWith=IncumbentDocument, ForwardDeclareInHeader] undefined close();
+    [DoNotCheckSecurity, ForwardDeclareInHeader] readonly attribute boolean closed;
     undefined stop();
-    [DoNotCheckSecurity, CallWith=IncumbentWindow] undefined focus();
-    [DoNotCheckSecurity] undefined blur();
+    [DoNotCheckSecurity, CallWith=IncumbentWindow, ForwardDeclareInHeader] undefined focus();
+    [DoNotCheckSecurity, ForwardDeclareInHeader] undefined blur();
 
     // other browsing contexts
     [Replaceable, DoNotCheckSecurityOnGetter, CustomGetter] readonly attribute WindowProxy frames;
@@ -91,8 +91,8 @@
     DOMString? prompt(optional DOMString message = "", optional DOMString defaultValue = "");
     undefined print();
 
-    [CallWith=GlobalObject&IncumbentWindow, DoNotCheckSecurity, MayThrowException] undefined postMessage(any message, USVString targetOrigin, optional sequence<object> transfer = []);
-    [CallWith=GlobalObject&IncumbentWindow, DoNotCheckSecurity, MayThrowException] undefined postMessage(any message, optional WindowPostMessageOptions options);
+    [CallWith=GlobalObject&IncumbentWindow, DoNotCheckSecurity, ForwardDeclareInHeader, MayThrowException] undefined postMessage(any message, USVString targetOrigin, optional sequence<object> transfer = []);
+    [CallWith=GlobalObject&IncumbentWindow, DoNotCheckSecurity, ForwardDeclareInHeader, MayThrowException] undefined postMessage(any message, optional WindowPostMessageOptions options);
 
 
     // Obsolete: Still part of the HTML specification (https://html.spec.whatwg.org/#Window-partial).
@@ -119,7 +119,7 @@
     [NotEnumerable, Conditional=IOS_GESTURE_EVENTS] attribute EventHandler ongesturestart;
 
     // Non-standard: This has been dropped from the HTML specification and by other browsers.
-    [Custom] any showModalDialog(DOMString url, optional any dialogArgs, optional DOMString featureArgs);
+    [Custom, ForwardDeclareInHeader] any showModalDialog(DOMString url, optional any dialogArgs, optional DOMString featureArgs);
 
     // Non-standard: should probably deprecate this (https://bugs.webkit.org/show_bug.cgi?id=79653).
     // Blink already deprecated it (https://bugs.chromium.org/p/chromium/issues/detail?id=437569).

Modified: trunk/Source/WebCore/page/History.idl (274392 => 274393)


--- trunk/Source/WebCore/page/History.idl	2021-03-13 21:55:51 UTC (rev 274392)
+++ trunk/Source/WebCore/page/History.idl	2021-03-14 02:47:53 UTC (rev 274393)
@@ -33,9 +33,9 @@
     attribute ScrollRestoration scrollRestoration;
     [Custom] readonly attribute any state;
 
-    [CallWith=Document] undefined back();
-    [CallWith=Document] undefined forward();
-    [CallWith=Document] undefined go(optional long delta = 0);
+    [CallWith=Document, ForwardDeclareInHeader] undefined back();
+    [CallWith=Document, ForwardDeclareInHeader] undefined forward();
+    [CallWith=Document, ForwardDeclareInHeader] undefined go(optional long delta = 0);
 
     // FIXME: title should not be nullable as per the HTML specification.
     [MayThrowException] undefined pushState(SerializedScriptValue data, DOMString? title, optional USVString? url = ""

Modified: trunk/Source/WebCore/page/Location.idl (274392 => 274393)


--- trunk/Source/WebCore/page/Location.idl	2021-03-13 21:55:51 UTC (rev 274392)
+++ trunk/Source/WebCore/page/Location.idl	2021-03-14 02:47:53 UTC (rev 274393)
@@ -45,9 +45,9 @@
 ] interface Location {
     [SetterCallWith=ActiveWindow&FirstWindow, DoNotCheckSecurityOnSetter] stringifier attribute USVString href;
 
-    [CallWith=ActiveWindow&FirstWindow, MayThrowException] undefined assign(USVString url);
-    [DoNotCheckSecurity, CallWith=ActiveWindow&FirstWindow, MayThrowException] undefined replace(USVString url);
-    [CallWith=ActiveWindow] undefined reload();
+    [CallWith=ActiveWindow&FirstWindow, MayThrowException, ForwardDeclareInHeader] undefined assign(USVString url);
+    [DoNotCheckSecurity, CallWith=ActiveWindow&FirstWindow, MayThrowException, ForwardDeclareInHeader] undefined replace(USVString url);
+    [CallWith=ActiveWindow, ForwardDeclareInHeader] undefined reload();
 
     // URI decomposition attributes
     [SetterCallWith=ActiveWindow&FirstWindow] attribute USVString protocol;

Modified: trunk/Source/WebCore/page/RemoteDOMWindow.idl (274392 => 274393)


--- trunk/Source/WebCore/page/RemoteDOMWindow.idl	2021-03-13 21:55:51 UTC (rev 274392)
+++ trunk/Source/WebCore/page/RemoteDOMWindow.idl	2021-03-14 02:47:53 UTC (rev 274393)
@@ -46,14 +46,14 @@
     [LegacyUnforgeable, ImplementedAs=self] readonly attribute WindowProxy window;
     [Replaceable] readonly attribute WindowProxy self;
     [PutForwards=href, LegacyUnforgeable] readonly attribute Location? location; // FIXME: Should not be nullable.
-    [CallWith=IncumbentDocument] undefined close();
-    readonly attribute boolean closed;
-    [CallWith=IncumbentWindow] undefined focus();
-    undefined blur();
+    [CallWith=IncumbentDocument, ForwardDeclareInHeader] undefined close();
+    [ForwardDeclareInHeader] readonly attribute boolean closed;
+    [CallWith=IncumbentWindow, ForwardDeclareInHeader] undefined focus();
+    [ForwardDeclareInHeader] undefined blur();
     [Replaceable, ImplementedAs=self] readonly attribute WindowProxy frames;
     [Replaceable] readonly attribute unsigned long length;
     [LegacyUnforgeable] readonly attribute WindowProxy? top;
     readonly attribute WindowProxy? opener;
     [Replaceable] readonly attribute WindowProxy? parent;
-    [CallWith=GlobalObject&IncumbentWindow] undefined postMessage(any message, USVString targetOrigin, optional sequence<object> transfer = []);
+    [CallWith=GlobalObject&IncumbentWindow, ForwardDeclareInHeader] undefined postMessage(any message, USVString targetOrigin, optional sequence<object> transfer = []);
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to