⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 268868 in webkit


Ignore:
Timestamp:
Oct 22, 2020, 9:23:07 AM (6 years ago)
Author:
Chris Dumez
Message:

Turn ScriptExecutionContext::vm() into a pure virtual function
https://bugs.webkit.org/show_bug.cgi?id=218057

Reviewed by Geoffrey Garen.

Turn ScriptExecutionContext::vm() into a pure virtual function instead of using a
non-virtual function that does type-checking inside.

  • dom/Document.cpp:

(WebCore::Document::vm):

  • dom/Document.h:
  • dom/EmptyScriptExecutionContext.h:
  • dom/ScriptExecutionContext.cpp:

(WebCore::ScriptExecutionContext::vm): Deleted.

  • dom/ScriptExecutionContext.h:
  • workers/WorkerOrWorkletGlobalScope.cpp:

(WebCore::WorkerOrWorkletGlobalScope::vm):

  • workers/WorkerOrWorkletGlobalScope.h:
Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r268866 r268868  
     12020-10-22  Chris Dumez  <cdumez@apple.com>
     2
     3        Turn ScriptExecutionContext::vm() into a pure virtual function
     4        https://bugs.webkit.org/show_bug.cgi?id=218057
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Turn ScriptExecutionContext::vm() into a pure virtual function instead of using a
     9        non-virtual function that does type-checking inside.
     10
     11        * dom/Document.cpp:
     12        (WebCore::Document::vm):
     13        * dom/Document.h:
     14        * dom/EmptyScriptExecutionContext.h:
     15        * dom/ScriptExecutionContext.cpp:
     16        (WebCore::ScriptExecutionContext::vm): Deleted.
     17        * dom/ScriptExecutionContext.h:
     18        * workers/WorkerOrWorkletGlobalScope.cpp:
     19        (WebCore::WorkerOrWorkletGlobalScope::vm):
     20        * workers/WorkerOrWorkletGlobalScope.h:
     21
    1222020-10-22  Aditya Keerthi  <akeerthi@apple.com>
    223
  • trunk/Source/WebCore/dom/Document.cpp

    r268774 r268868  
    86708670}
    86718671
     8672JSC::VM& Document::vm()
     8673{
     8674    return commonVM();
     8675}
     8676
    86728677} // namespace WebCore
    86738678
  • trunk/Source/WebCore/dom/Document.h

    r268860 r268868  
    15961596    bool contains(const Node* node) const { return node && contains(*node); }
    15971597
     1598    WEBCORE_EXPORT JSC::VM& vm() final;
     1599
    15981600protected:
    15991601    enum ConstructionFlags { Synthesized = 1, NonRenderedPlaceholder = 1 << 1 };
  • trunk/Source/WebCore/dom/EmptyScriptExecutionContext.h

    r264486 r268868  
    7676#endif
    7777
     78    JSC::VM& vm() final { return m_vm; }
     79
    7880    using RefCounted::ref;
    7981    using RefCounted::deref;
     
    8183private:
    8284    EmptyScriptExecutionContext(JSC::VM& vm)
    83         : m_origin(SecurityOrigin::createUnique())
     85        : m_vm(vm)
     86        , m_origin(SecurityOrigin::createUnique())
    8487        , m_eventLoop(EmptyEventLoop::create(vm))
    8588        , m_eventLoopTaskGroup(makeUnique<EventLoopTaskGroup>(m_eventLoop))
     
    113116    };
    114117
     118    Ref<JSC::VM> m_vm;
    115119    Ref<SecurityOrigin> m_origin;
    116120    URL m_url;
  • trunk/Source/WebCore/dom/ScriptExecutionContext.cpp

    r268801 r268868  
    478478}
    479479
    480 JSC::VM& ScriptExecutionContext::vm()
    481 {
    482     if (is<Document>(*this))
    483         return commonVM();
    484     if (is<WorkerOrWorkletGlobalScope>(*this))
    485         return downcast<WorkerOrWorkletGlobalScope>(*this).script()->vm();
    486 
    487     RELEASE_ASSERT_NOT_REACHED();
    488     return commonVM();
    489 }
    490 
    491480RejectedPromiseTracker& ScriptExecutionContext::ensureRejectedPromiseTrackerSlow()
    492481{
  • trunk/Source/WebCore/dom/ScriptExecutionContext.h

    r268700 r268868  
    212212    DOMTimer* findTimeout(int timeoutId) { return m_timeouts.get(timeoutId); }
    213213
    214     WEBCORE_EXPORT JSC::VM& vm();
     214    virtual JSC::VM& vm() = 0;
    215215
    216216    void adjustMinimumDOMTimerInterval(Seconds oldMinimumTimerInterval);
  • trunk/Source/WebCore/workers/WorkerOrWorkletGlobalScope.cpp

    r268822 r268868  
    6565}
    6666
     67JSC::VM& WorkerOrWorkletGlobalScope::vm()
     68{
     69    return script()->vm();
     70}
     71
    6772void WorkerOrWorkletGlobalScope::disableEval(const String& errorMessage)
    6873{
  • trunk/Source/WebCore/workers/WorkerOrWorkletGlobalScope.h

    r268822 r268868  
    4848    void clearScript();
    4949
     50    JSC::VM& vm() final;
     51
    5052    unsigned long createUniqueIdentifier() { return m_uniqueIdentifier++; }
    5153
Note: See TracChangeset for help on using the changeset viewer.