Bug 234548

Summary: ScriptState.h/cpp is a remnant of JavaScript engine abstraction that can be removed
Product: WebKit Reporter: Darin Adler <darin>
Component: WebCore JavaScriptAssignee: Darin Adler <darin>
Status: RESOLVED FIXED    
Severity: Normal CC: alecflett, annulen, ashvayka, beidson, cdumez, esprehn+autocc, ews-watchlist, gyuyoung.kim, hi, joepeck, jsbell, kangil.han, pangle, ryuan.choi, sergio, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch
ews-feeder: commit-queue-
Patch
ews-feeder: commit-queue-
Patch
ysuzuki: review+, ews-feeder: commit-queue-
Patch
ews-feeder: commit-queue-
Patch
ews-feeder: commit-queue-
Patch
ews-feeder: commit-queue-
Patch none

Darin Adler
Reported 2021-12-20 23:53:58 PST
ScriptState.h/cpp is a remnant of JavaScript engine abstraction that can be removed
Attachments
Patch (77.03 KB, patch)
2021-12-21 00:45 PST, Darin Adler
ews-feeder: commit-queue-
Patch (77.64 KB, patch)
2021-12-21 00:51 PST, Darin Adler
ews-feeder: commit-queue-
Patch (77.65 KB, patch)
2021-12-21 01:36 PST, Darin Adler
ysuzuki: review+
ews-feeder: commit-queue-
Patch (77.19 KB, patch)
2021-12-21 02:12 PST, Darin Adler
ews-feeder: commit-queue-
Patch (77.42 KB, patch)
2021-12-21 02:26 PST, Darin Adler
ews-feeder: commit-queue-
Patch (77.73 KB, patch)
2021-12-21 08:28 PST, Darin Adler
ews-feeder: commit-queue-
Patch (76.22 KB, patch)
2021-12-21 11:28 PST, Darin Adler
no flags
Darin Adler
Comment 1 2021-12-21 00:45:28 PST Comment hidden (obsolete)
Darin Adler
Comment 2 2021-12-21 00:51:08 PST Comment hidden (obsolete)
Darin Adler
Comment 3 2021-12-21 01:36:43 PST
Yusuke Suzuki
Comment 4 2021-12-21 01:51:57 PST
Comment on attachment 447697 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=447697&action=review r=me with comments. > Source/WebCore/ChangeLog:15 > + Also begin to just call global objects "global object", and not "script state". Nice. > Source/WebCore/inspector/InspectorFrontendHost.cpp:164 > + auto& globalObject = *m_frontendPage->mainFrame().script().globalObject(world); In the old code, m_frontendPage can be nullptr. > Source/WebCore/inspector/WebInjectedScriptManager.cpp:91 > + { > + Vector<long> idsToRemove; > + for (auto& entry : m_idToInjectedScript) { > + auto* globalObject = entry.value.globalObject(); > + if (executionContext(globalObject) == document) { > + m_scriptStateToId.remove(globalObject); > + idsToRemove.append(entry.key); > + } > + } > + for (auto& id : idsToRemove) > + m_idToInjectedScript.remove(id); > } How about using `HashMap::removeIf`? > Source/WebCore/inspector/WebInjectedScriptManager.cpp:103 > + // Now remove global objects that have no injected script. > + { > + Vector<JSC::JSGlobalObject*> globalObjectsToRemove; > + for (auto& entry : m_scriptStateToId) { > + auto* globalObject = entry.key; > + if (executionContext(globalObject) == document) > + globalObjectsToRemove.append(globalObject); > + } > + for (auto& globalObject : globalObjectsToRemove) > + m_scriptStateToId.remove(globalObject); > + } How about using `HashMap::removeIf`? > Source/WebCore/inspector/agents/InspectorApplicationCacheAgent.cpp:117 > + m_inspectedPage.forEachFrame([&] (Frame& frame) { Remove space between [&] and (Frame& frame). > Source/WebCore/inspector/agents/InspectorTimelineAgent.cpp:297 > void InspectorTimelineAgent::startFromConsole(JSC::JSGlobalObject* exec, const String& title) Let's rename exec to `globalObject` or `lexicalGlobalObject`. > Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp:136 > + m_inspectedPage.forEachFrame([&] (Frame& frame) { Remove space between [] part and () part in lambda.
Darin Adler
Comment 5 2021-12-21 02:12:21 PST Comment hidden (obsolete)
Darin Adler
Comment 6 2021-12-21 02:26:25 PST Comment hidden (obsolete)
Darin Adler
Comment 7 2021-12-21 08:28:50 PST Comment hidden (obsolete)
Darin Adler
Comment 8 2021-12-21 11:28:48 PST
Darin Adler
Comment 9 2021-12-21 13:56:43 PST
Radar WebKit Bug Importer
Comment 10 2021-12-21 13:57:18 PST
Note You need to log in before you can comment on or make changes to this bug.