Title: [268700] trunk/Source/WebCore
Revision
268700
Author
cdu...@apple.com
Date
2020-10-19 16:50:58 -0700 (Mon, 19 Oct 2020)

Log Message

Replace execStateFrom*() functions with globalObject() overloads
https://bugs.webkit.org/show_bug.cgi?id=217912

Reviewed by Darin Adler.

Introduce globalObject() overloads to replace existing execStateFrom*() functions.
This is a first step to promote code sharing. Ideally, code would not have to
differentiate workers from worklets as much as possible.

No new tests, no Web-facing behavior change.

* bindings/js/JSDOMGlobalObject.cpp:
(WebCore::JSDOMGlobalObject::scriptExecutionContext const):
* bindings/js/ScriptState.cpp:
(WebCore::execStateFromWorkerOrWorkletGlobalScope):
* bindings/js/ScriptState.h:
* bindings/js/WorkerScriptController.cpp:
(WebCore::WorkerScriptController::globalScopeWrapper):
* bindings/js/WorkerScriptController.h:
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::vm):
(WebCore::ScriptExecutionContext::execState):
* inspector/agents/worker/WorkerAuditAgent.cpp:
(WebCore::WorkerAuditAgent::injectedScriptForEval):
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
(WebCore::WorkerDebuggerAgent::injectedScriptForEval):
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
(WebCore::WorkerRuntimeAgent::injectedScriptForEval):
* workers/WorkerOrWorkletScriptController.h:
* worklets/WorkletScriptController.cpp:
(WebCore::WorkletScriptController::globalScopeWrapper):
* worklets/WorkletScriptController.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (268699 => 268700)


--- trunk/Source/WebCore/ChangeLog	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/ChangeLog	2020-10-19 23:50:58 UTC (rev 268700)
@@ -1,3 +1,38 @@
+2020-10-19  Chris Dumez  <cdu...@apple.com>
+
+        Replace execStateFrom*() functions with globalObject() overloads
+        https://bugs.webkit.org/show_bug.cgi?id=217912
+
+        Reviewed by Darin Adler.
+
+        Introduce globalObject() overloads to replace existing execStateFrom*() functions.
+        This is a first step to promote code sharing. Ideally, code would not have to
+        differentiate workers from worklets as much as possible.
+
+        No new tests, no Web-facing behavior change.
+
+        * bindings/js/JSDOMGlobalObject.cpp:
+        (WebCore::JSDOMGlobalObject::scriptExecutionContext const):
+        * bindings/js/ScriptState.cpp:
+        (WebCore::execStateFromWorkerOrWorkletGlobalScope):
+        * bindings/js/ScriptState.h:
+        * bindings/js/WorkerScriptController.cpp:
+        (WebCore::WorkerScriptController::globalScopeWrapper):
+        * bindings/js/WorkerScriptController.h:
+        * dom/ScriptExecutionContext.cpp:
+        (WebCore::ScriptExecutionContext::vm):
+        (WebCore::ScriptExecutionContext::execState):
+        * inspector/agents/worker/WorkerAuditAgent.cpp:
+        (WebCore::WorkerAuditAgent::injectedScriptForEval):
+        * inspector/agents/worker/WorkerDebuggerAgent.cpp:
+        (WebCore::WorkerDebuggerAgent::injectedScriptForEval):
+        * inspector/agents/worker/WorkerRuntimeAgent.cpp:
+        (WebCore::WorkerRuntimeAgent::injectedScriptForEval):
+        * workers/WorkerOrWorkletScriptController.h:
+        * worklets/WorkletScriptController.cpp:
+        (WebCore::WorkletScriptController::globalScopeWrapper):
+        * worklets/WorkletScriptController.h:
+
 2020-10-19  Timothy Horton  <timothy_hor...@apple.com>
 
         Adjust a comment about an antique way to override the UA on iOS

Modified: trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp (268699 => 268700)


--- trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp	2020-10-19 23:50:58 UTC (rev 268700)
@@ -67,7 +67,7 @@
         return Exception { TypeError, "Missing payment method data." };
 
     auto throwScope = DECLARE_THROW_SCOPE(context.vm());
-    auto applePayRequest = convertDictionary<ApplePayRequest>(*context.execState(), data);
+    auto applePayRequest = convertDictionary<ApplePayRequest>(*context.globalObject(), data);
     if (throwScope.exception())
         return Exception { ExistingExceptionError };
 
@@ -305,7 +305,7 @@
         if (serializedModifierData[i].isEmpty())
             continue;
 
-        auto& lexicalGlobalObject = *document().execState();
+        auto& lexicalGlobalObject = *document().globalObject();
         auto scope = DECLARE_THROW_SCOPE(lexicalGlobalObject.vm());
         JSC::JSValue data;
         {
@@ -403,7 +403,7 @@
 
     auto& context = *scriptExecutionContext();
     auto throwScope = DECLARE_THROW_SCOPE(context.vm());
-    auto applePayErrors = convert<IDLSequence<IDLInterface<ApplePayError>>>(*context.execState(), paymentMethodErrors);
+    auto applePayErrors = convert<IDLSequence<IDLInterface<ApplePayError>>>(*context.globalObject(), paymentMethodErrors);
     if (throwScope.exception())
         return Exception { ExistingExceptionError };
 
@@ -442,7 +442,7 @@
         return Exception { TypeError };
 
     String errorMessage;
-    auto merchantSession = PaymentMerchantSession::fromJS(*document().execState(), asObject(merchantSessionValue), errorMessage);
+    auto merchantSession = PaymentMerchantSession::fromJS(*document().globalObject(), asObject(merchantSessionValue), errorMessage);
     if (!merchantSession)
         return Exception { TypeError, WTFMove(errorMessage) };
 

Modified: trunk/Source/WebCore/Modules/cache/DOMCache.cpp (268699 => 268700)


--- trunk/Source/WebCore/Modules/cache/DOMCache.cpp	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/Modules/cache/DOMCache.cpp	2020-10-19 23:50:58 UTC (rev 268700)
@@ -366,7 +366,7 @@
 
     // FIXME: for efficiency, we should load blobs directly instead of going through the readableStream path.
     if (response->isBlobBody()) {
-        auto streamOrException = response->readableStream(*scriptExecutionContext()->execState());
+        auto streamOrException = response->readableStream(*scriptExecutionContext()->globalObject());
         if (UNLIKELY(streamOrException.hasException())) {
             promise.reject(streamOrException.releaseException());
             return;

Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp (268699 => 268700)


--- trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp	2020-10-19 23:50:58 UTC (rev 268700)
@@ -178,7 +178,7 @@
 
     // If loading, let's create a stream so that data is teed on both clones.
     if (isLoading() && !m_readableStreamSource) {
-        auto voidOrException = createReadableStream(*context.execState());
+        auto voidOrException = createReadableStream(*context.globalObject());
         if (UNLIKELY(voidOrException.hasException()))
             return voidOrException.releaseException();
     }

Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBSerializationContext.cpp (268699 => 268700)


--- trunk/Source/WebCore/Modules/indexeddb/server/IDBSerializationContext.cpp	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBSerializationContext.cpp	2020-10-19 23:50:58 UTC (rev 268700)
@@ -91,7 +91,7 @@
     return *m_vm;
 }
 
-JSC::JSGlobalObject& IDBSerializationContext::execState()
+JSC::JSGlobalObject& IDBSerializationContext::globalObject()
 {
     initializeVM();
     return *m_globalObject.get();

Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBSerializationContext.h (268699 => 268700)


--- trunk/Source/WebCore/Modules/indexeddb/server/IDBSerializationContext.h	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBSerializationContext.h	2020-10-19 23:50:58 UTC (rev 268700)
@@ -48,7 +48,7 @@
     ~IDBSerializationContext();
 
     JSC::VM& vm();
-    JSC::JSGlobalObject& execState();
+    JSC::JSGlobalObject& globalObject();
 
 private:
     IDBSerializationContext(PAL::SessionID);

Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp (268699 => 268700)


--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp	2020-10-19 23:50:58 UTC (rev 268700)
@@ -252,7 +252,7 @@
 
 IDBError MemoryObjectStore::addRecord(MemoryBackingStoreTransaction& transaction, const IDBKeyData& keyData, const IDBValue& value)
 {
-    auto indexKeys = generateIndexKeyMapForValue(m_serializationContext->execState(), m_info, keyData, value);
+    auto indexKeys = generateIndexKeyMapForValue(m_serializationContext->globalObject(), m_info, keyData, value);
     return addRecord(transaction, keyData, indexKeys, value);
 }
 
@@ -342,12 +342,12 @@
     JSLockHolder locker(m_serializationContext->vm());
 
     for (const auto& iterator : *m_keyValueStore) {
-        auto jsValue = deserializeIDBValueToJSValue(m_serializationContext->execState(), iterator.value);
+        auto jsValue = deserializeIDBValueToJSValue(m_serializationContext->globalObject(), iterator.value);
         if (jsValue.isUndefinedOrNull())
             return IDBError { };
 
         IndexKey indexKey;
-        generateIndexKeyForValue(m_serializationContext->execState(), index.info(), jsValue, indexKey, m_info.keyPath(), iterator.key);
+        generateIndexKeyForValue(m_serializationContext->globalObject(), index.info(), jsValue, indexKey, m_info.keyPath(), iterator.key);
 
         if (indexKey.isNull())
             continue;

Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp (268699 => 268700)


--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp	2020-10-19 23:50:58 UTC (rev 268700)
@@ -2086,12 +2086,12 @@
 {
     JSLockHolder locker(m_serializationContext->vm());
 
-    auto jsValue = deserializeIDBValueToJSValue(m_serializationContext->execState(), value);
+    auto jsValue = deserializeIDBValueToJSValue(m_serializationContext->globalObject(), value);
     if (jsValue.isUndefinedOrNull())
         return IDBError { };
 
     IndexKey indexKey;
-    generateIndexKeyForValue(m_serializationContext->execState(), info, jsValue, indexKey, objectStoreInfo.keyPath(), key);
+    generateIndexKeyForValue(m_serializationContext->globalObject(), info, jsValue, indexKey, objectStoreInfo.keyPath(), key);
 
     if (indexKey.isNull())
         return IDBError { };

Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp (268699 => 268700)


--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp	2020-10-19 23:50:58 UTC (rev 268700)
@@ -758,7 +758,7 @@
         usedKey = keyData;
 
     // Generate index keys up front for more accurate quota check.
-    auto indexKeys = generateIndexKeyMapForValue(m_backingStore->serializationContext().execState(), *objectStoreInfo, usedKey, value);
+    auto indexKeys = generateIndexKeyMapForValue(m_backingStore->serializationContext().globalObject(), *objectStoreInfo, usedKey, value);
 
     if (overwriteMode == IndexedDB::ObjectStoreOverwriteMode::NoOverwrite) {
         bool keyExists;

Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp (268699 => 268700)


--- trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp	2020-10-19 23:50:58 UTC (rev 268700)
@@ -308,7 +308,7 @@
 static ExceptionOr<JSC::JSValue> parse(ScriptExecutionContext& context, const String& string)
 {
     auto scope = DECLARE_THROW_SCOPE(context.vm());
-    JSC::JSValue data = "" string);
+    JSC::JSValue data = "" string);
     if (scope.exception())
         return Exception { ExistingExceptionError };
     return data;
@@ -337,8 +337,8 @@
 
         String serializedData;
         if (paymentMethod.data) {
-            auto scope = DECLARE_THROW_SCOPE(document.execState()->vm());
-            serializedData = JSONStringify(document.execState(), paymentMethod.data.get(), 0);
+            auto scope = DECLARE_THROW_SCOPE(document.globalObject()->vm());
+            serializedData = JSONStringify(document.globalObject(), paymentMethod.data.get(), 0);
             if (scope.exception())
                 return Exception { ExistingExceptionError };
             
@@ -357,7 +357,7 @@
     if (totalResult.hasException())
         return totalResult.releaseException();
 
-    auto detailsResult = checkAndCanonicalizeDetails(*document.execState(), details, options.requestShipping, ShouldValidatePaymentMethodIdentifier::No);
+    auto detailsResult = checkAndCanonicalizeDetails(*document.globalObject(), details, options.requestShipping, ShouldValidatePaymentMethodIdentifier::No);
     if (detailsResult.hasException())
         return detailsResult.releaseException();
 
@@ -647,7 +647,7 @@
 
     auto& context = *m_detailsPromise->scriptExecutionContext();
     auto throwScope = DECLARE_THROW_SCOPE(context.vm());
-    auto detailsUpdate = convertDictionary<PaymentDetailsUpdate>(*context.execState(), m_detailsPromise->result());
+    auto detailsUpdate = convertDictionary<PaymentDetailsUpdate>(*context.globalObject(), m_detailsPromise->result());
     if (throwScope.exception()) {
         abortWithException(Exception { ExistingExceptionError });
         return;
@@ -659,7 +659,7 @@
         return;
     }
 
-    auto detailsResult = checkAndCanonicalizeDetails(*context.execState(), detailsUpdate, m_options.requestShipping, ShouldValidatePaymentMethodIdentifier::Yes);
+    auto detailsResult = checkAndCanonicalizeDetails(*context.globalObject(), detailsUpdate, m_options.requestShipping, ShouldValidatePaymentMethodIdentifier::Yes);
     if (detailsResult.hasException()) {
         abortWithException(detailsResult.releaseException());
         return;

Modified: trunk/Source/WebCore/Modules/webxr/WebXRSystem.cpp (268699 => 268700)


--- trunk/Source/WebCore/Modules/webxr/WebXRSystem.cpp	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/Modules/webxr/WebXRSystem.cpp	2020-10-19 23:50:58 UTC (rev 268700)
@@ -388,7 +388,7 @@
         if (!device || !device->supports(mode))
             return;
 
-        auto* globalObject = protectedDocument->execState();
+        auto* globalObject = protectedDocument->globalObject();
         if (!globalObject)
             return;
 

Modified: trunk/Source/WebCore/bindings/js/JSCustomElementInterface.cpp (268699 => 268700)


--- trunk/Source/WebCore/bindings/js/JSCustomElementInterface.cpp	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/bindings/js/JSCustomElementInterface.cpp	2020-10-19 23:50:58 UTC (rev 268700)
@@ -99,7 +99,7 @@
         return nullptr;
 
     ASSERT(&document == scriptExecutionContext());
-    auto& lexicalGlobalObject = *document.execState();
+    auto& lexicalGlobalObject = *document.globalObject();
     auto element = constructCustomElementSynchronously(document, vm, lexicalGlobalObject, m_constructor.get(), localName);
     EXCEPTION_ASSERT(!!scope.exception() == !element);
     if (!element) {

Modified: trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp (268699 => 268700)


--- trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp	2020-10-19 23:50:58 UTC (rev 268700)
@@ -224,10 +224,8 @@
         return nullptr;
     if (inherits<JSWorkerGlobalScopeBase>(vm()))
         return jsCast<const JSWorkerGlobalScopeBase*>(this)->scriptExecutionContext();
-#if ENABLE(CSS_PAINTING_API)
     if (inherits<JSWorkletGlobalScopeBase>(vm()))
         return jsCast<const JSWorkletGlobalScopeBase*>(this)->scriptExecutionContext();
-#endif
 #if ENABLE(INDEXED_DATABASE)
     if (inherits<JSIDBSerializationGlobalObject>(vm()))
         return jsCast<const JSIDBSerializationGlobalObject*>(this)->scriptExecutionContext();

Modified: trunk/Source/WebCore/bindings/js/ScriptState.cpp (268699 => 268700)


--- trunk/Source/WebCore/bindings/js/ScriptState.cpp	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/bindings/js/ScriptState.cpp	2020-10-19 23:50:58 UTC (rev 268700)
@@ -39,7 +39,7 @@
 #include "Node.h"
 #include "Page.h"
 #include "ScriptController.h"
-#include "WorkerGlobalScope.h"
+#include "WorkerOrWorkletGlobalScope.h"
 #include "WorkerScriptController.h"
 #include "WorkletGlobalScope.h"
 #include "WorkletScriptController.h"
@@ -81,7 +81,7 @@
     return frame->windowProxy().jsWindowProxy(mainThreadNormalWorld())->window();
 }
 
-JSC::JSGlobalObject* execStateFromNode(DOMWrapperWorld& world, Node* node)
+JSC::JSGlobalObject* globalObject(DOMWrapperWorld& world, Node* node)
 {
     if (!node)
         return nullptr;
@@ -93,23 +93,16 @@
     return frame->script().globalObject(world);
 }
 
-JSC::JSGlobalObject* execStateFromPage(DOMWrapperWorld& world, Page* page)
+JSC::JSGlobalObject* globalObject(DOMWrapperWorld& world, Page* page)
 {
     return page ? page->mainFrame().script().globalObject(world) : nullptr;
 }
 
-JSC::JSGlobalObject* execStateFromWorkerGlobalScope(WorkerGlobalScope& workerGlobalScope)
+JSC::JSGlobalObject* globalObject(WorkerOrWorkletGlobalScope& workerOrWorkletGlobalScope)
 {
-    return workerGlobalScope.script()->workerGlobalScopeWrapper();
+    if (auto* scriptController = workerOrWorkletGlobalScope.script())
+        return scriptController->globalScopeWrapper();
+    return nullptr;
 }
 
-#if ENABLE(CSS_PAINTING_API)
-JSC::JSGlobalObject* execStateFromWorkletGlobalScope(WorkletGlobalScope& workletGlobalScope)
-{
-    if (!workletGlobalScope.script())
-        return nullptr;
-    return workletGlobalScope.script()->workletGlobalScopeWrapper();
 }
-#endif
-
-}

Modified: trunk/Source/WebCore/bindings/js/ScriptState.h (268699 => 268700)


--- trunk/Source/WebCore/bindings/js/ScriptState.h	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/bindings/js/ScriptState.h	2020-10-19 23:50:58 UTC (rev 268700)
@@ -44,10 +44,7 @@
 class Node;
 class Page;
 class ScriptExecutionContext;
-class WorkerGlobalScope;
-#if ENABLE(CSS_PAINTING_API)
-class WorkletGlobalScope;
-#endif
+class WorkerOrWorkletGlobalScope;
 
 DOMWindow* domWindowFromExecState(JSC::JSGlobalObject*);
 Frame* frameFromExecState(JSC::JSGlobalObject*);
@@ -55,11 +52,8 @@
 
 JSC::JSGlobalObject* mainWorldExecState(Frame*);
 
-JSC::JSGlobalObject* execStateFromNode(DOMWrapperWorld&, Node*);
-WEBCORE_EXPORT JSC::JSGlobalObject* execStateFromPage(DOMWrapperWorld&, Page*);
-JSC::JSGlobalObject* execStateFromWorkerGlobalScope(WorkerGlobalScope&);
-#if ENABLE(CSS_PAINTING_API)
-JSC::JSGlobalObject* execStateFromWorkletGlobalScope(WorkletGlobalScope&);
-#endif
+JSC::JSGlobalObject* globalObject(DOMWrapperWorld&, Node*);
+WEBCORE_EXPORT JSC::JSGlobalObject* globalObject(DOMWrapperWorld&, Page*);
+JSC::JSGlobalObject* globalObject(WorkerOrWorkletGlobalScope&);
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/js/WorkerScriptController.cpp (268699 => 268700)


--- trunk/Source/WebCore/bindings/js/WorkerScriptController.cpp	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/bindings/js/WorkerScriptController.cpp	2020-10-19 23:50:58 UTC (rev 268700)
@@ -279,4 +279,9 @@
     debugger->detach(m_workerGlobalScopeWrapper.get(), JSC::Debugger::TerminatingDebuggingSession);
 }
 
+JSC::JSGlobalObject* WorkerScriptController::globalScopeWrapper()
+{
+    return workerGlobalScopeWrapper();
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/js/WorkerScriptController.h (268699 => 268700)


--- trunk/Source/WebCore/bindings/js/WorkerScriptController.h	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/bindings/js/WorkerScriptController.h	2020-10-19 23:50:58 UTC (rev 268700)
@@ -57,6 +57,8 @@
         return m_workerGlobalScopeWrapper.get();
     }
 
+    JSC::JSGlobalObject* globalScopeWrapper() final;
+
     void evaluate(const ScriptSourceCode&, String* returnedExceptionMessage = nullptr);
     void evaluate(const ScriptSourceCode&, NakedPtr<JSC::Exception>& returnedException, String* returnedExceptionMessage = nullptr);
 

Modified: trunk/Source/WebCore/dom/ScriptExecutionContext.cpp (268699 => 268700)


--- trunk/Source/WebCore/dom/ScriptExecutionContext.cpp	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/dom/ScriptExecutionContext.cpp	2020-10-19 23:50:58 UTC (rev 268700)
@@ -483,10 +483,8 @@
         return commonVM();
     if (is<WorkerGlobalScope>(*this))
         return downcast<WorkerGlobalScope>(*this).script()->vm();
-#if ENABLE(CSS_PAINTING_API)
     if (is<WorkletGlobalScope>(*this))
         return downcast<WorkletGlobalScope>(*this).script()->vm();
-#endif
 
     RELEASE_ASSERT_NOT_REACHED();
     return commonVM();
@@ -524,20 +522,13 @@
     return false;
 }
 
-JSC::JSGlobalObject* ScriptExecutionContext::execState()
+JSC::JSGlobalObject* ScriptExecutionContext::globalObject()
 {
-    if (is<Document>(*this)) {
-        Document& document = downcast<Document>(*this);
-        auto* frame = document.frame();
-        return frame ? frame->script().globalObject(mainThreadNormalWorld()) : nullptr;
-    }
+    if (is<Document>(*this))
+        return WebCore::globalObject(mainThreadNormalWorld(), downcast<Document>(*this).page());
 
-    if (is<WorkerGlobalScope>(*this))
-        return execStateFromWorkerGlobalScope(downcast<WorkerGlobalScope>(*this));
-#if ENABLE(CSS_PAINTING_API)
-    if (is<WorkletGlobalScope>(*this))
-        return execStateFromWorkletGlobalScope(downcast<WorkletGlobalScope>(*this));
-#endif
+    if (is<WorkerOrWorkletGlobalScope>(*this))
+        return WebCore::globalObject(downcast<WorkerOrWorkletGlobalScope>(*this));
 
     ASSERT_NOT_REACHED();
     return nullptr;

Modified: trunk/Source/WebCore/dom/ScriptExecutionContext.h (268699 => 268700)


--- trunk/Source/WebCore/dom/ScriptExecutionContext.h	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/dom/ScriptExecutionContext.h	2020-10-19 23:50:58 UTC (rev 268700)
@@ -242,7 +242,7 @@
         return ensureRejectedPromiseTrackerSlow();
     }
 
-    WEBCORE_EXPORT JSC::JSGlobalObject* execState();
+    WEBCORE_EXPORT JSC::JSGlobalObject* globalObject();
 
     WEBCORE_EXPORT String domainForCachePartition() const;
     void setDomainForCachePartition(String&& domain) { m_domainForCachePartition = WTFMove(domain); }

Modified: trunk/Source/WebCore/fileapi/Blob.cpp (268699 => 268700)


--- trunk/Source/WebCore/fileapi/Blob.cpp	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/fileapi/Blob.cpp	2020-10-19 23:50:58 UTC (rev 268700)
@@ -277,7 +277,7 @@
         UniqueRef<FileReaderLoader> m_loader;
     };
 
-    return ReadableStream::create(*scriptExecutionContext.execState(), adoptRef(*new BlobStreamSource(scriptExecutionContext, *this)));
+    return ReadableStream::create(*scriptExecutionContext.globalObject(), adoptRef(*new BlobStreamSource(scriptExecutionContext, *this)));
 }
 
 #if ASSERT_ENABLED

Modified: trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp (268699 => 268700)


--- trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp	2020-10-19 23:50:58 UTC (rev 268700)
@@ -228,7 +228,7 @@
 
             document()->eventLoop().performMicrotaskCheckpoint();
 
-            CustomElementReactionStack reactionStack(document()->execState());
+            CustomElementReactionStack reactionStack(document()->globalObject());
             auto& elementInterface = constructionData->elementInterface.get();
             auto newElement = elementInterface.constructElementWithFallback(*document(), constructionData->name);
             m_treeBuilder->didCreateCustomOrFallbackElement(WTFMove(newElement), *constructionData);

Modified: trunk/Source/WebCore/inspector/InspectorFrontendHost.cpp (268699 => 268700)


--- trunk/Source/WebCore/inspector/InspectorFrontendHost.cpp	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/inspector/InspectorFrontendHost.cpp	2020-10-19 23:50:58 UTC (rev 268700)
@@ -156,7 +156,7 @@
 
 void InspectorFrontendHost::addSelfToGlobalObjectInWorld(DOMWrapperWorld& world)
 {
-    auto& lexicalGlobalObject = *execStateFromPage(world, m_frontendPage);
+    auto& lexicalGlobalObject = *globalObject(world, m_frontendPage);
     auto& vm = lexicalGlobalObject.vm();
     JSC::JSLockHolder lock(vm);
     auto scope = DECLARE_CATCH_SCOPE(vm);
@@ -500,7 +500,7 @@
 #if ENABLE(CONTEXT_MENUS)
     ASSERT(m_frontendPage);
 
-    auto& lexicalGlobalObject = *execStateFromPage(debuggerWorld(), m_frontendPage);
+    auto& lexicalGlobalObject = *globalObject(debuggerWorld(), m_frontendPage);
     auto& vm = lexicalGlobalObject.vm();
     auto value = lexicalGlobalObject.get(&lexicalGlobalObject, JSC::Identifier::fromString(vm, "InspectorFrontendAPI"));
     ASSERT(value);

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (268699 => 268700)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2020-10-19 23:50:58 UTC (rev 268700)
@@ -321,7 +321,7 @@
 void InspectorInstrumentation::didInstallTimerImpl(InstrumentingAgents& instrumentingAgents, int timerId, Seconds timeout, bool singleShot, ScriptExecutionContext& context)
 {
     if (auto* webDebuggerAgent = instrumentingAgents.enabledWebDebuggerAgent())
-        webDebuggerAgent->didScheduleAsyncCall(context.execState(), InspectorDebuggerAgent::AsyncCallType::DOMTimer, timerId, singleShot);
+        webDebuggerAgent->didScheduleAsyncCall(context.globalObject(), InspectorDebuggerAgent::AsyncCallType::DOMTimer, timerId, singleShot);
 
     if (auto* timelineAgent = instrumentingAgents.trackingTimelineAgent())
         timelineAgent->didInstallTimer(timerId, timeout, singleShot, frameForScriptExecutionContext(context));

Modified: trunk/Source/WebCore/inspector/agents/InspectorAnimationAgent.cpp (268699 => 268700)


--- trunk/Source/WebCore/inspector/agents/InspectorAnimationAgent.cpp	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/inspector/agents/InspectorAnimationAgent.cpp	2020-10-19 23:50:58 UTC (rev 268700)
@@ -313,7 +313,7 @@
     if (!animation)
         return makeUnexpected(errorString);
 
-    auto* state = animation->scriptExecutionContext()->execState();
+    auto* state = animation->scriptExecutionContext()->globalObject();
     auto injectedScript = m_injectedScriptManager.injectedScriptFor(state);
     ASSERT(!injectedScript.hasNoValue());
 

Modified: trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp (268699 => 268700)


--- trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp	2020-10-19 23:50:58 UTC (rev 268700)
@@ -248,7 +248,7 @@
     if (!inspectorCanvas)
         return makeUnexpected(errorString);
 
-    auto* state = inspectorCanvas->scriptExecutionContext()->execState();
+    auto* state = inspectorCanvas->scriptExecutionContext()->globalObject();
     auto injectedScript = m_injectedScriptManager.injectedScriptFor(state);
     ASSERT(!injectedScript.hasNoValue());
 

Modified: trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp (268699 => 268700)


--- trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp	2020-10-19 23:50:58 UTC (rev 268700)
@@ -1847,17 +1847,17 @@
             document = &downcast<Node>(eventTarget).document();
 
         JSC::JSObject* handlerObject = nullptr;
-        JSC::JSGlobalObject* exec = nullptr;
+        JSC::JSGlobalObject* globalObject = nullptr;
 
         JSC::JSLockHolder lock(scriptListener.isolatedWorld().vm());
 
         if (document) {
             handlerObject = scriptListener.ensureJSFunction(*document);
-            exec = execStateFromNode(scriptListener.isolatedWorld(), document);
+            globalObject = WebCore::globalObject(scriptListener.isolatedWorld(), document);
         }
 
-        if (handlerObject && exec) {
-            JSC::VM& vm = exec->vm();
+        if (handlerObject && globalObject) {
+            JSC::VM& vm = globalObject->vm();
             JSC::JSFunction* handlerFunction = JSC::jsDynamicCast<JSC::JSFunction*>(vm, handlerObject);
 
             if (!handlerFunction) {
@@ -1864,7 +1864,7 @@
                 auto scope = DECLARE_CATCH_SCOPE(vm);
 
                 // If the handler is not actually a function, see if it implements the EventListener interface and use that.
-                auto handleEventValue = handlerObject->get(exec, JSC::Identifier::fromString(vm, "handleEvent"));
+                auto handleEventValue = handlerObject->get(globalObject, JSC::Identifier::fromString(vm, "handleEvent"));
 
                 if (UNLIKELY(scope.exception()))
                     scope.clearException();

Modified: trunk/Source/WebCore/inspector/agents/InspectorDOMDebuggerAgent.cpp (268699 => 268700)


--- trunk/Source/WebCore/inspector/agents/InspectorDOMDebuggerAgent.cpp	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/inspector/agents/InspectorDOMDebuggerAgent.cpp	2020-10-19 23:50:58 UTC (rev 268700)
@@ -220,7 +220,7 @@
 
 void InspectorDOMDebuggerAgent::willHandleEvent(Event& event, const RegisteredEventListener& registeredEventListener)
 {
-    auto state = event.target()->scriptExecutionContext()->execState();
+    auto state = event.target()->scriptExecutionContext()->globalObject();
     auto injectedScript = m_injectedScriptManager.injectedScriptFor(state);
     if (injectedScript.hasNoValue())
         return;
@@ -261,7 +261,7 @@
 
 void InspectorDOMDebuggerAgent::didHandleEvent(Event& event, const RegisteredEventListener& registeredEventListener)
 {
-    auto state = event.target()->scriptExecutionContext()->execState();
+    auto state = event.target()->scriptExecutionContext()->globalObject();
     auto injectedScript = m_injectedScriptManager.injectedScriptFor(state);
     if (injectedScript.hasNoValue())
         return;

Modified: trunk/Source/WebCore/inspector/agents/InspectorIndexedDBAgent.cpp (268699 => 268700)


--- trunk/Source/WebCore/inspector/agents/InspectorIndexedDBAgent.cpp	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/inspector/agents/InspectorIndexedDBAgent.cpp	2020-10-19 23:50:58 UTC (rev 268700)
@@ -388,7 +388,7 @@
             return;
         }
 
-        auto* lexicalGlobalObject = context.execState();
+        auto* lexicalGlobalObject = context.globalObject();
 
         auto key = m_injectedScript.wrapObject(toJS(*lexicalGlobalObject, *lexicalGlobalObject, cursor->key()), String(), true);
         if (!key)
@@ -462,7 +462,7 @@
 
         TransactionActivator activator(idbTransaction.get());
         RefPtr<IDBRequest> idbRequest;
-        auto* exec = context() ? context()->execState() : nullptr;
+        auto* exec = context() ? context()->globalObject() : nullptr;
         if (!m_indexName.isEmpty()) {
             auto idbIndex = indexForObjectStore(idbObjectStore.get(), m_indexName);
             if (!idbIndex) {
@@ -705,7 +705,7 @@
 
         TransactionActivator activator(idbTransaction.get());
         RefPtr<IDBRequest> idbRequest;
-        if (auto* exec = context() ? context()->execState() : nullptr) {
+        if (auto* exec = context() ? context()->globalObject() : nullptr) {
             auto result = idbObjectStore->clear(*exec);
             ASSERT(!result.hasException());
             if (result.hasException()) {

Modified: trunk/Source/WebCore/inspector/agents/WebDebuggerAgent.cpp (268699 => 268700)


--- trunk/Source/WebCore/inspector/agents/WebDebuggerAgent.cpp	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/inspector/agents/WebDebuggerAgent.cpp	2020-10-19 23:50:58 UTC (rev 268700)
@@ -79,14 +79,14 @@
     if (m_registeredEventListeners.contains(registeredListener.get()))
         return;
 
-    JSC::JSGlobalObject* scriptState = target.scriptExecutionContext()->execState();
-    if (!scriptState)
+    auto* globalObject = target.scriptExecutionContext()->globalObject();
+    if (!globalObject)
         return;
 
     int identifier = m_nextEventListenerIdentifier++;
     m_registeredEventListeners.set(registeredListener.get(), identifier);
 
-    didScheduleAsyncCall(scriptState, InspectorDebuggerAgent::AsyncCallType::EventListener, identifier, registeredListener->isOnce());
+    didScheduleAsyncCall(globalObject, InspectorDebuggerAgent::AsyncCallType::EventListener, identifier, registeredListener->isOnce());
 }
 
 void WebDebuggerAgent::willRemoveEventListener(EventTarget& target, const AtomString& eventType, EventListener& listener, bool capture)

Modified: trunk/Source/WebCore/inspector/agents/page/PageDebuggerAgent.cpp (268699 => 268700)


--- trunk/Source/WebCore/inspector/agents/page/PageDebuggerAgent.cpp	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/inspector/agents/page/PageDebuggerAgent.cpp	2020-10-19 23:50:58 UTC (rev 268700)
@@ -171,11 +171,11 @@
     if (!breakpointsActive())
         return;
 
-    JSC::JSGlobalObject* scriptState = document.execState();
-    if (!scriptState)
+    auto* globalObject = document.globalObject();
+    if (!globalObject)
         return;
 
-    didScheduleAsyncCall(scriptState, InspectorDebuggerAgent::AsyncCallType::RequestAnimationFrame, callbackId, true);
+    didScheduleAsyncCall(globalObject, InspectorDebuggerAgent::AsyncCallType::RequestAnimationFrame, callbackId, true);
 }
 
 void PageDebuggerAgent::willFireAnimationFrame(int callbackId)

Modified: trunk/Source/WebCore/inspector/agents/worker/WorkerAuditAgent.cpp (268699 => 268700)


--- trunk/Source/WebCore/inspector/agents/worker/WorkerAuditAgent.cpp	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/inspector/agents/worker/WorkerAuditAgent.cpp	2020-10-19 23:50:58 UTC (rev 268700)
@@ -55,8 +55,7 @@
         return InjectedScript();
     }
 
-    JSC::JSGlobalObject* scriptState = execStateFromWorkerGlobalScope(m_workerGlobalScope);
-    return injectedScriptManager().injectedScriptFor(scriptState);
+    return injectedScriptManager().injectedScriptFor(globalObject(m_workerGlobalScope));
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/inspector/agents/worker/WorkerDebuggerAgent.cpp (268699 => 268700)


--- trunk/Source/WebCore/inspector/agents/worker/WorkerDebuggerAgent.cpp	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/inspector/agents/worker/WorkerDebuggerAgent.cpp	2020-10-19 23:50:58 UTC (rev 268700)
@@ -60,8 +60,7 @@
         return InjectedScript();
     }
 
-    JSC::JSGlobalObject* scriptState = execStateFromWorkerGlobalScope(m_workerGlobalScope);
-    return injectedScriptManager().injectedScriptFor(scriptState);
+    return injectedScriptManager().injectedScriptFor(globalObject(m_workerGlobalScope));
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/inspector/agents/worker/WorkerRuntimeAgent.cpp (268699 => 268700)


--- trunk/Source/WebCore/inspector/agents/worker/WorkerRuntimeAgent.cpp	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/inspector/agents/worker/WorkerRuntimeAgent.cpp	2020-10-19 23:50:58 UTC (rev 268700)
@@ -58,8 +58,7 @@
         return InjectedScript();
     }
 
-    JSC::JSGlobalObject* scriptState = execStateFromWorkerGlobalScope(m_workerGlobalScope);
-    return injectedScriptManager().injectedScriptFor(scriptState);
+    return injectedScriptManager().injectedScriptFor(globalObject(m_workerGlobalScope));
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/testing/WebXRTest.cpp (268699 => 268700)


--- trunk/Source/WebCore/testing/WebXRTest.cpp	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/testing/WebXRTest.cpp	2020-10-19 23:50:58 UTC (rev 268700)
@@ -56,7 +56,7 @@
 
         Vector<XRReferenceSpaceType> features;
         if (init.supportedFeatures) {
-            if (auto* globalObject = context.execState()) {
+            if (auto* globalObject = context.globalObject()) {
                 for (auto& feature : init.supportedFeatures.value()) {
                     if (auto referenceSpaceType = parseEnumeration<XRReferenceSpaceType>(*globalObject, feature))
                         features.append(referenceSpaceType.value());

Modified: trunk/Source/WebCore/testing/js/WebCoreTestSupport.cpp (268699 => 268700)


--- trunk/Source/WebCore/testing/js/WebCoreTestSupport.cpp	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/testing/js/WebCoreTestSupport.cpp	2020-10-19 23:50:58 UTC (rev 268700)
@@ -222,11 +222,11 @@
         if (!script)
             return;
 
-        auto& state = *globalScope.execState();
-        auto& vm = state.vm();
+        auto& globalObject = *globalScope.globalObject();
+        auto& vm = globalObject.vm();
         JSLockHolder locker(vm);
         auto* contextWrapper = script->workerGlobalScopeWrapper();
-        contextWrapper->putDirect(vm, Identifier::fromString(vm, Internals::internalsId), toJS(&state, contextWrapper, ServiceWorkerInternals::create(identifier)));
+        contextWrapper->putDirect(vm, Identifier::fromString(vm, Internals::internalsId), toJS(&globalObject, contextWrapper, ServiceWorkerInternals::create(identifier)));
     });
 #else
     UNUSED_PARAM(serviceWorkerIdentifier);

Modified: trunk/Source/WebCore/workers/WorkerOrWorkletScriptController.h (268699 => 268700)


--- trunk/Source/WebCore/workers/WorkerOrWorkletScriptController.h	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/workers/WorkerOrWorkletScriptController.h	2020-10-19 23:50:58 UTC (rev 268700)
@@ -40,6 +40,8 @@
     virtual void removeTimerSetNotification(JSC::JSRunLoopTimer::TimerNotificationCallback) = 0;
 
     virtual bool isTerminatingExecution() const = 0;
+
+    virtual JSC::JSGlobalObject* globalScopeWrapper() = 0;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/worklets/WorkletScriptController.cpp (268699 => 268700)


--- trunk/Source/WebCore/worklets/WorkletScriptController.cpp	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/worklets/WorkletScriptController.cpp	2020-10-19 23:50:58 UTC (rev 268700)
@@ -267,4 +267,9 @@
     return m_isTerminatingExecution;
 }
 
+JSC::JSGlobalObject* WorkletScriptController::globalScopeWrapper()
+{
+    return workletGlobalScopeWrapper();
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/worklets/WorkletScriptController.h (268699 => 268700)


--- trunk/Source/WebCore/worklets/WorkletScriptController.h	2020-10-19 23:49:39 UTC (rev 268699)
+++ trunk/Source/WebCore/worklets/WorkletScriptController.h	2020-10-19 23:50:58 UTC (rev 268700)
@@ -59,6 +59,8 @@
         return m_workletGlobalScopeWrapper.get();
     }
 
+    JSC::JSGlobalObject* globalScopeWrapper() final;
+
     void forbidExecution();
     bool isExecutionForbidden() const;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to