Changeset 52653 in webkit


Ignore:
Timestamp:
Dec 30, 2009 4:34:40 AM (14 years ago)
Author:
yurys@chromium.org
Message:

2009-12-30 Yury Semikhatsky <yurys@chromium.org>

Reviewed by Dimitri Glazkov.

[v8] Use current isolated world's context for ScriptCallStack.

https://bugs.webkit.org/show_bug.cgi?id=33016

  • bindings/v8/ScriptCallStack.cpp: (WebCore::ScriptCallStack::ScriptCallStack):
  • bindings/v8/ScriptCallStack.h: (WebCore::ScriptCallStack::state):
  • bindings/v8/ScriptController.cpp: (WebCore::ScriptController::mainWorldScriptState): (WebCore::ScriptController::currentScriptState): (WebCore::ScriptController::clearWindowShell):
  • bindings/v8/ScriptController.h:
  • bindings/v8/V8IsolatedWorld.cpp: (WebCore::V8IsolatedWorld::scriptState):
  • bindings/v8/V8IsolatedWorld.h:
Location:
trunk/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r52648 r52653  
     12009-12-30  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        [v8] Use current isolated world's context for ScriptCallStack.
     6
     7        https://bugs.webkit.org/show_bug.cgi?id=33016
     8
     9        * bindings/v8/ScriptCallStack.cpp:
     10        (WebCore::ScriptCallStack::ScriptCallStack):
     11        * bindings/v8/ScriptCallStack.h:
     12        (WebCore::ScriptCallStack::state):
     13        * bindings/v8/ScriptController.cpp:
     14        (WebCore::ScriptController::mainWorldScriptState):
     15        (WebCore::ScriptController::currentScriptState):
     16        (WebCore::ScriptController::clearWindowShell):
     17        * bindings/v8/ScriptController.h:
     18        * bindings/v8/V8IsolatedWorld.cpp:
     19        (WebCore::V8IsolatedWorld::scriptState):
     20        * bindings/v8/V8IsolatedWorld.h:
     21
    1222009-12-30  Laszlo Gombos  <laszlo.1.gombos@nokia.com>
    223
  • trunk/WebCore/bindings/v8/ScriptCallStack.cpp

    r50327 r52653  
    3232#include "ScriptCallStack.h"
    3333
     34#include "ScriptController.h"
     35
    3436#include <v8.h>
    3537
     
    5456ScriptCallStack::ScriptCallStack(const v8::Arguments& arguments, unsigned skipArgumentCount, String sourceName, int sourceLineNumber)
    5557    : m_lastCaller(String(), sourceName, sourceLineNumber, arguments, skipArgumentCount)
    56     , m_scriptState(new ScriptState(V8Proxy::retrieveFrameForCurrentContext()))
     58    , m_scriptState(ScriptController::currentScriptState())
    5759{
    5860}
  • trunk/WebCore/bindings/v8/ScriptCallStack.h

    r50327 r52653  
    3636#include "ScriptValue.h"
    3737#include <wtf/Noncopyable.h>
    38 #include <wtf/OwnPtr.h>
    3938
    4039namespace v8 {
     
    5352        unsigned size() const { return 1; }
    5453
    55         ScriptState* state() const { return m_scriptState.get(); }
     54        ScriptState* state() const { return m_scriptState; }
    5655
    5756    private:
     
    5958   
    6059        ScriptCallFrame m_lastCaller;
    61         OwnPtr<ScriptState> m_scriptState;
     60        ScriptState* m_scriptState;
    6261    };
    6362
  • trunk/WebCore/bindings/v8/ScriptController.cpp

    r52080 r52653  
    5252#include "V8Binding.h"
    5353#include "V8BindingState.h"
     54#include "V8IsolatedWorld.h"
    5455#include "V8NPObject.h"
    5556#include "V8Proxy.h"
     
    365366ScriptState* ScriptController::mainWorldScriptState()
    366367{
    367     if (!m_mainWorldScriptState)
     368    if (!m_mainWorldScriptState) {
     369        v8::HandleScope handleScope;
    368370        m_mainWorldScriptState.set(new ScriptState(m_frame, V8Proxy::mainWorldContext(m_frame)));
     371    }
    369372    return m_mainWorldScriptState.get();
     373}
     374
     375ScriptState* ScriptController::currentScriptState()
     376{
     377    if (V8IsolatedWorld* world = V8IsolatedWorld::getEntered())
     378        return world->scriptState();
     379    Frame* frame = V8Proxy::retrieveFrameForCurrentContext();
     380    ASSERT(frame);
     381    return frame->script()->mainWorldScriptState();
    370382}
    371383
     
    432444void ScriptController::clearWindowShell()
    433445{
     446    m_mainWorldScriptState.clear();
     447
    434448    // V8 binding expects ScriptController::clearWindowShell only be called
    435449    // when a frame is loading a new page. V8Proxy::clearForNavigation
  • trunk/WebCore/bindings/v8/ScriptController.h

    r52043 r52653  
    176176        ScriptState* mainWorldScriptState();
    177177
     178        // Returns ScriptState for current context.
     179        static ScriptState* currentScriptState();
     180
    178181    private:
    179182        Frame* m_frame;
  • trunk/WebCore/bindings/v8/V8IsolatedWorld.cpp

    r51416 r52653  
    9292}
    9393
     94ScriptState* V8IsolatedWorld::scriptState()
     95{
     96    if (!m_scriptState) {
     97        v8::HandleScope scope;
     98        v8::Handle<v8::Context> context = m_context.get()->get();
     99        m_scriptState.set(new ScriptState(V8Proxy::retrieveFrame(context), context));
     100    }
     101    return m_scriptState.get();
     102}
     103
    94104} // namespace WebCore
  • trunk/WebCore/bindings/v8/V8IsolatedWorld.h

    r51416 r52653  
    9696        DOMDataStore* getDOMDataStore() const { return m_domDataStore.getStore(); }
    9797
     98        ScriptState* scriptState();
     99
    98100    private:
    99101        static v8::Handle<v8::Object> getGlobalObject(v8::Handle<v8::Context> context)
     
    115117        DOMDataStoreHandle m_domDataStore;
    116118
     119        // FIXME: get rid of redundant m_context field. The context can be retrieved from the ScriptState.
     120        OwnPtr<ScriptState> m_scriptState;
     121
    117122        static int isolatedWorldCount;
    118123    };
Note: See TracChangeset for help on using the changeset viewer.