Changeset 52882 in webkit


Ignore:
Timestamp:
Jan 6, 2010 4:47:00 PM (14 years ago)
Author:
abarth@webkit.org
Message:

2010-01-06 Adam Barth <abarth@webkit.org>

No review, rolling out r52877.
http://trac.webkit.org/changeset/52877
https://bugs.webkit.org/show_bug.cgi?id=33243

I screwedd up landing this patch and only partially applied the patch I
was trying to land.

  • bindings/ScriptControllerBase.cpp:
  • bindings/js/ScriptController.cpp: (WebCore::ScriptController::executeScriptInWorld):
  • bindings/v8/ScriptController.cpp: (WebCore::ScriptController::ScriptController): (WebCore::ScriptController::~ScriptController): (WebCore::ScriptController::updateSecurityOrigin): (WebCore::ScriptController::evaluateInIsolatedWorld): (WebCore::ScriptController::haveInterpreter): (WebCore::ScriptController::mainWorldWindowShell): (WebCore::ScriptController::clearWindowShell): (WebCore::ScriptController::clearForClose): (WebCore::ScriptController::destroyWindowShell): (WebCore::ScriptController::updateDocument):
  • bindings/v8/ScriptController.h: (WebCore::ScriptController::proxy): (WebCore::ScriptController::windowShell): (WebCore::ScriptController::existingWindowShell): (WebCore::ScriptController::evaluateInWorld):
  • bindings/v8/V8DOMWindowShell.cpp: (WebCore::V8DOMWindowShell::create): (WebCore::V8DOMWindowShell::V8DOMWindowShell): (WebCore::V8DOMWindowShell::initContextIfNeeded):
Location:
trunk/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r52880 r52882  
     12010-01-06  Adam Barth  <abarth@webkit.org>
     2
     3        No review, rolling out r52877.
     4        http://trac.webkit.org/changeset/52877
     5        https://bugs.webkit.org/show_bug.cgi?id=33243
     6
     7        I screwedd up landing this patch and only partially applied the patch I
     8        was trying to land.
     9
     10        * bindings/ScriptControllerBase.cpp:
     11        * bindings/js/ScriptController.cpp:
     12        (WebCore::ScriptController::executeScriptInWorld):
     13        * bindings/v8/ScriptController.cpp:
     14        (WebCore::ScriptController::ScriptController):
     15        (WebCore::ScriptController::~ScriptController):
     16        (WebCore::ScriptController::updateSecurityOrigin):
     17        (WebCore::ScriptController::evaluateInIsolatedWorld):
     18        (WebCore::ScriptController::haveInterpreter):
     19        (WebCore::ScriptController::mainWorldWindowShell):
     20        (WebCore::ScriptController::clearWindowShell):
     21        (WebCore::ScriptController::clearForClose):
     22        (WebCore::ScriptController::destroyWindowShell):
     23        (WebCore::ScriptController::updateDocument):
     24        * bindings/v8/ScriptController.h:
     25        (WebCore::ScriptController::proxy):
     26        (WebCore::ScriptController::windowShell):
     27        (WebCore::ScriptController::existingWindowShell):
     28        (WebCore::ScriptController::evaluateInWorld):
     29        * bindings/v8/V8DOMWindowShell.cpp:
     30        (WebCore::V8DOMWindowShell::create):
     31        (WebCore::V8DOMWindowShell::V8DOMWindowShell):
     32        (WebCore::V8DOMWindowShell::initContextIfNeeded):
     33
    1342010-01-06  Eric Seidel  <eric@webkit.org>
    235
  • trunk/WebCore/bindings/ScriptControllerBase.cpp

    r52877 r52882  
    5454}
    5555
    56 ScriptValue ScriptController::executeScriptInWorld(DOMWrapperWorld* world, const String& script, bool forceUserGesture)
    57 {
    58     ScriptSourceCode sourceCode(script, forceUserGesture ? KURL() : m_frame->loader()->url());
    59 
    60     if (!isEnabled() || isPaused())
    61         return ScriptValue();
    62 
    63     bool wasInExecuteScript = m_inExecuteScript;
    64     m_inExecuteScript = true;
    65 
    66     ScriptValue result = evaluateInWorld(sourceCode, world);
    67 
    68     if (!wasInExecuteScript) {
    69         m_inExecuteScript = false;
    70         Document::updateStyleForAllDocuments();
    71     }
    72 
    73     return result;
    74 }
    7556
    7657bool ScriptController::executeIfJavaScriptURL(const KURL& url, bool userGesture, bool replaceDocument)
  • trunk/WebCore/bindings/js/ScriptController.cpp

    r52877 r52882  
    447447}
    448448
     449ScriptValue ScriptController::executeScriptInWorld(DOMWrapperWorld* world, const String& script, bool forceUserGesture)
     450{
     451    ScriptSourceCode sourceCode(script, forceUserGesture ? KURL() : m_frame->loader()->url());
     452
     453    if (!isEnabled() || isPaused())
     454        return ScriptValue();
     455
     456    bool wasInExecuteScript = m_inExecuteScript;
     457    m_inExecuteScript = true;
     458
     459    ScriptValue result = evaluateInWorld(sourceCode, world);
     460
     461    if (!wasInExecuteScript) {
     462        m_inExecuteScript = false;
     463        Document::updateStyleForAllDocuments();
     464    }
     465
     466    return result;
     467}
     468
    449469} // namespace WebCore
  • trunk/WebCore/bindings/v8/ScriptController.cpp

    r52877 r52882  
    6161namespace WebCore {
    6262
    63 PassRefPtr<DOMWrapperWorld> ScriptController::createWorld()
    64 {
    65     return IsolatedWorld::create();
    66 }
    67 
    68 V8DOMWindowShell* ScriptController::initScript(DOMWrapperWorld* world)
    69 {
    70     ASSERT(!m_windowShells.contains(world));
    71 
    72     RefPtr<V8DOMWindowShell> windowShell = V8DOMWindowShell::create(m_frame, world);
    73     m_windowShells.add(world, windowShell);
    74     windowShell->initContextIfNeeded();
    75     windowShell->updateDocument();
    76 
    77     m_frame->loader()->dispatchDidClearWindowObjectInWorld(world);
    78 
    79     return windowShell.get();
    80 }
    81 
    8263void ScriptController::initializeThreading()
    8364{
     
    126107    , m_paused(false)
    127108    , m_proxy(new V8Proxy(frame))
     109    , m_windowShell(V8DOMWindowShell::create(frame))
    128110#if ENABLE(NETSCAPE_PLUGIN_API)
    129111    , m_windowScriptNPObject(0)
     
    136118{
    137119    m_proxy->disconnectFrame();
    138 
    139     if (!m_windowShells.isEmpty()) {
    140         m_windowShells.clear();
    141         m_mainWorldWindowShell = 0;
    142         // JSC triggers a GC here, but we haven't historically.
    143     }
     120    m_windowShell.clear();
    144121}
    145122
     
    166143void ScriptController::updateSecurityOrigin()
    167144{
    168     for (ShellMap::iterator iter = m_windowShells.begin(); iter != m_windowShells.end(); ++iter)
    169         iter->second->updateSecurityOrigin();
     145    m_windowShell->updateSecurityOrigin();
    170146}
    171147
     
    233209{
    234210    // FIXME: This will need to get reorganized once we have a windowShell for the isolated world.
    235    
    236     // Force the mainWindowShell to exist.
    237     windowShell(mainThreadNormalWorld());
     211    m_windowShell->initContextIfNeeded();
    238212    m_proxy->evaluateInIsolatedWorld(worldID, sources, 0);
    239213}
     
    275249}
    276250
    277 ScriptValue ScriptController::evaluateInWorld(const ScriptSourceCode&, DOMWrapperWorld*)
    278 {
    279     // FIXME: Move isolated world execution to here!
    280     notImplemented();
    281     return ScriptValue();
    282 }
    283 
    284251void ScriptController::setEventHandlerLineNumber(int lineNumber)
    285252{
     
    325292{
    326293    v8::V8::LowMemoryNotification();
     294}
     295
     296bool ScriptController::haveInterpreter() const
     297{
     298    return m_windowShell->isContextInitialized();
    327299}
    328300
     
    468440}
    469441
    470 V8DOMWindowShell* ScriptController::mainWorldWindowShell()
    471 {
    472     if (!m_mainWorldWindowShell)
    473         m_mainWorldWindowShell = windowShell(mainThreadNormalWorld());
    474     return m_mainWorldWindowShell.get();
     442V8DOMWindowShell* ScriptController::mainWorldWindowShell() const
     443{
     444    m_windowShell->initContextIfNeeded();
     445    return m_windowShell.get();
    475446}
    476447
     
    483454    // when a frame is loading a new page. V8DOMWindowShell::clearForNavigation
    484455    // creates a new context for the new page.
    485     for (ShellMap::iterator iter = m_windowShells.begin(); iter != m_windowShells.end(); ++iter)
    486         iter->second->clearForNavigation();
     456    m_windowShell->clearForNavigation();
    487457}
    488458
    489459void ScriptController::clearForClose()
    490460{
    491     for (ShellMap::iterator iter = m_windowShells.begin(); iter != m_windowShells.end(); ++iter)
    492         iter->second->clearForClose();
     461    m_windowShell->clearForClose();
    493462}
    494463
    495464void ScriptController::destroyWindowShell()
    496465{
    497     m_windowShells.clear();
    498     m_mainWorldWindowShell = 0;
     466    m_windowShell->clearForClose();
     467    m_windowShell->destroyGlobal();
    499468}
    500469
     
    506475void ScriptController::updateDocument()
    507476{
    508     // This seems redudant, but JSC does it.
    509     if (!m_frame->document())
    510         return;
    511 
    512     for (ShellMap::iterator iter = m_windowShells.begin(); iter != m_windowShells.end(); ++iter)
    513         iter->second->updateDocument();
     477    m_windowShell->updateDocument();
    514478}
    515479
  • trunk/WebCore/bindings/v8/ScriptController.h

    r52877 r52882  
    5252class ScriptState;
    5353class String;
    54 class V8DOMWindow;
    5554class Widget;
    5655class XSSAuditor;
    5756
    5857class ScriptController {
    59     typedef WTF::HashMap< RefPtr<DOMWrapperWorld>, RefPtr<V8DOMWindowShell> > ShellMap;
    60 
    6158public:
    6259    ScriptController(Frame*);
    6360    ~ScriptController();
    6461
    65     static PassRefPtr<DOMWrapperWorld> createWorld();
    66 
    67     V8DOMWindowShell* windowShell(DOMWrapperWorld* world)
    68     {
    69         ShellMap::iterator iter = m_windowShells.find(world);
    70         return (iter != m_windowShells.end()) ? iter->second.get() : initScript(world);
    71     }
    72     V8DOMWindowShell* existingWindowShell(DOMWrapperWorld* world) const
    73     {
    74         ShellMap::const_iterator iter = m_windowShells.find(world);
    75         return (iter != m_windowShells.end()) ? iter->second.get() : 0;
    76     }
    77     V8DOMWindow* globalObject(DOMWrapperWorld* world)
    78     {
    79         notImplemented();
    80         return 0;
    81     }
    82 
    83     static void getAllWorlds(Vector<DOMWrapperWorld*>&);
    84 
    85     ScriptValue executeScript(const ScriptSourceCode&);
    86     ScriptValue executeScript(const String& script, bool forceUserGesture = false);
    87     ScriptValue executeScriptInWorld(DOMWrapperWorld* world, const String& script, bool forceUserGesture = false);
    88 
    89     // Returns true if argument is a JavaScript URL.
    90     bool executeIfJavaScriptURL(const KURL&, bool userGesture = false, bool replaceDocument = true);
    91 
    92     // This function must be called from the main thread. It is safe to call it repeatedly.
    93     static void initializeThreading();
    94 
    95     ScriptValue evaluate(const ScriptSourceCode&);
    96     ScriptValue evaluateInWorld(const ScriptSourceCode&, DOMWrapperWorld*);
    97 
    98     // ==== End identical match with JSC's ScriptController === //
    99 
    10062    // FIXME: V8Proxy should either be folded into ScriptController
    10163    // or this accessor should be made JSProxy*
    10264    V8Proxy* proxy() { return m_proxy.get(); }
    10365
    104     // FIXME: We should eventually remove all clients of this method. The
    105     // problem is that some of them are in very hot code paths.
    106     V8DOMWindowShell* mainWorldWindowShell();
     66    V8DOMWindowShell* mainWorldWindowShell() const;
     67
     68    ScriptValue executeScript(const ScriptSourceCode&);
     69    ScriptValue executeScript(const String& script, bool forceUserGesture = false);
     70
     71    // Returns true if argument is a JavaScript URL.
     72    bool executeIfJavaScriptURL(const KURL&, bool userGesture = false, bool replaceDocument = true);
     73
     74    // This function must be called from the main thread. It is safe to call it repeatedly.
     75    static void initializeThreading();
     76
     77    // Evaluate a script file in the environment of this proxy.
     78    // If succeeded, 'succ' is set to true and result is returned
     79    // as a string.
     80    ScriptValue evaluate(const ScriptSourceCode&);
    10781
    10882    void evaluateInIsolatedWorld(unsigned worldID, const Vector<ScriptSourceCode>&);
     
    12094    void evaluateInIsolatedWorld(unsigned worldID, const Vector<ScriptSourceCode>&, int extensionGroup);
    12195
     96    // Masquerade 'this' as the windowShell.
     97    // This is a bit of a hack, but provides reasonable compatibility
     98    // with what JSC does as well.
     99    ScriptController* windowShell(DOMWrapperWorld*) { return this; }
     100    ScriptController* existingWindowShell(DOMWrapperWorld*) { return this; }
     101
    122102    XSSAuditor* xssAuditor() { return m_XSSAuditor.get(); }
    123103
     
    131111
    132112    PassScriptInstance createScriptInstanceForWidget(Widget*);
     113
     114    // Check if the javascript engine has been initialized.
     115    bool haveInterpreter() const;
    133116
    134117    bool isEnabled() const;
     
    188171#endif
    189172
     173    // Dummy method to avoid a bunch of ifdef's in WebCore.
     174    void evaluateInWorld(const ScriptSourceCode&, DOMWrapperWorld*) { }
     175    static void getAllWorlds(Vector<DOMWrapperWorld*>& worlds);
     176
    190177    // Script state for the main world context.
    191178    ScriptState* mainWorldScriptState();
     
    195182
    196183private:
    197     V8DOMWindowShell* initScript(DOMWrapperWorld*);
    198 
    199     ShellMap m_windowShells;
    200184    Frame* m_frame;
    201 
    202     // This is a cache of the main world's windowShell.  We have this
    203     // because we need access to it during some wrapper operations that
    204     // are performance sensitive.  Those call sites are wrong, but I'm
    205     // waiting to remove them until the next patch.
    206     RefPtr<V8DOMWindowShell> m_mainWorldWindowShell;
    207 
    208185    const String* m_sourceURL;
    209186
     
    215192    // FIXME: V8Proxy should eventually be removed.
    216193    OwnPtr<V8Proxy> m_proxy;
     194
     195    // For the moment, we have one of these.  Soon we will have one per DOMWrapperWorld.
     196    RefPtr<V8DOMWindowShell> m_windowShell;
    217197
    218198    typedef HashMap<Widget*, NPObject*> PluginObjectMap;
  • trunk/WebCore/bindings/v8/V8DOMWindowShell.cpp

    r52877 r52882  
    3737#include "DocumentLoader.h"
    3838#include "DOMObjectsInclude.h"
    39 #include "DOMWrapperWorld.h"
    4039#include "Frame.h"
    4140#include "FrameLoaderClient.h"
     
    124123}
    125124
    126 PassRefPtr<V8DOMWindowShell> V8DOMWindowShell::create(Frame* frame, DOMWrapperWorld* world)
    127 {
    128     return adoptRef(new V8DOMWindowShell(frame, world));
    129 }
    130 
    131 V8DOMWindowShell::V8DOMWindowShell(Frame* frame, DOMWrapperWorld* world)
     125PassRefPtr<V8DOMWindowShell> V8DOMWindowShell::create(Frame* frame)
     126{
     127    return adoptRef(new V8DOMWindowShell(frame));
     128}
     129
     130V8DOMWindowShell::V8DOMWindowShell(Frame* frame)
    132131    : m_frame(frame)
    133     , m_world(world)
    134132{
    135133}
     
    314312    setSecurityToken();
    315313
    316     // FIXME: JSC doesn't seem to make this callback.
    317314    m_frame->loader()->client()->didCreateScriptContextForFrame();
     315
     316    // FIXME: This is wrong. We should actually do this for the proper world once
     317    // we do isolated worlds the WebCore way.
     318    m_frame->loader()->dispatchDidClearWindowObjectInWorld(0);
    318319}
    319320
Note: See TracChangeset for help on using the changeset viewer.