Changeset 50907 in webkit


Ignore:
Timestamp:
Nov 12, 2009, 2:41:15 PM (16 years ago)
Author:
Adam Roben
Message:

Replace worldIDs with world objects

Part of <http://webkit.org/b/31414> Implement new SPI for dealing with
user scripts/stylesheets and isolated worlds

Reviewed by Sam Weinig.

WebCore:

Covered by existing tests.

  • WebCore.base.exp: Update exported symbols to match what now exists

and is needed by WebKit.

  • bindings/js/ScheduledAction.cpp:

(WebCore::ScheduledAction::execute): Updated for function rename.

  • bindings/js/ScriptController.cpp: Removed code that dealt with

worldIDs.
(WebCore::ScriptController::createWorld): Added. Returns a new world
suitable for use on the main thread.
(WebCore::ScriptController::executeScriptInWorld): Renamed from
executeScriptInIsolatedWorld, since this works just fine with a
"normal" world.

  • bindings/js/ScriptController.h: Added createWorld, removed functions

that took worldIDs, renamed executeScriptInIsolatedWorld to
executeScriptInWorld.

  • page/Frame.cpp:

(WebCore::Frame::injectUserScripts):
(WebCore::Frame::injectUserScriptsForWorld):
Updated for changes to UserScriptMap and ScriptController.

  • page/Frame.h: Changed injectUserScriptsForWorld to take a

DOMWrapperWorld* instead of a worldID.

  • page/PageGroup.cpp:

(WebCore::PageGroup::addUserScriptToWorld):
(WebCore::PageGroup::addUserStyleSheetToWorld):
(WebCore::PageGroup::removeUserScriptFromWorld):
(WebCore::PageGroup::removeUserStyleSheetFromWorld):
(WebCore::PageGroup::removeUserScriptsFromWorld):
(WebCore::PageGroup::removeUserStyleSheetsFromWorld):

  • page/PageGroup.h:

Changed these functions to take a DOMWrapperWorld* instead of a
worldID. Also updated for changes to UserScript and UserStyleSheet.

  • page/UserScript.h:
  • page/UserStyleSheet.h: Changed not to hold a worldID, since it was

never used.

  • page/UserScriptTypes.h:
  • page/UserStyleSheetTypes.h: Changed UserScriptMap and

UserStyleSheetMap to use a RefPtr<DOMWrapperWorld> instead of a
worldID as their key type.

WebKit:

  • WebKit.xcodeproj/project.pbxproj: Added WebScriptWorld to the project.

WebKit/mac:

WebScriptWorld is the new object that represents a world. The only
place worldID is still used is in -[WebFrame
_stringByEvaluatingJavaScriptInIsolatedWorld:WithGlobalObject:FromString:],
but that will change soon.

  • WebKit.exp: Export WebScriptWorld.
  • WebView/WebFrame.mm:

(-[WebFrame _stringByEvaluatingJavaScriptInIsolatedWorld:WithGlobalObject:FromString:]):
Moved the bizarre world caching/creation logic that DRT depends on
here from the findWorld function in ScriptController.cpp. Updated to
use ScriptController::executeScriptInWorld instead of
ScriptController::executeScriptInIsolatedWorld.
(-[WebFrame _contextForWorld:]): Renamed from contextForWorldID:. Now
takes a WebScriptWorld.

  • WebView/WebFramePrivate.h: Replaced contextForWorldID: with

_contextForWorld:.

  • WebView/WebScriptWorld.h: Added.
  • WebView/WebScriptWorld.mm: Added.

(-[WebScriptWorld initWithWorld:]): Store the passed-in world in our
_private member.
(-[WebScriptWorld init]): Create a new DOMWrapperWorld and pass it to
-initWithWorld:.
(-[WebScriptWorld dealloc]): Release _private.
(+[WebScriptWorld standardWorld]): Returns a shared instance that
represents WebCore's mainThreadNormalWorld().
(+[WebScriptWorld world]): Returns a new instance.
(core): Returns the DOMWrapperWorld for this WebScriptWorld.

  • WebView/WebScriptWorldInternal.h: Added.
  • WebView/WebView.mm:

(+[WebView _addUserScriptToGroup:world:source:url:whitelist:blacklist:injectionTime:]):
(+[WebView _addUserStyleSheetToGroup:world:source:url:whitelist:blacklist:]):
(+[WebView _removeUserScriptFromGroup:world:url:]):
(+[WebView _removeUserStyleSheetFromGroup:world:url:]):
(+[WebView _removeUserScriptsFromGroup:world:]):
(+[WebView _removeUserStyleSheetsFromGroup:world:]):

  • WebView/WebViewPrivate.h:

Changed these functions to take a WebScriptWorld instead of a worldID.

WebKit/win:

WebScriptWorld is the new object that represents a world. The only
place worldID is still used is in
IWebFramePrivate::stringByEvaluatingJavaScriptInIsolatedWorld, but
that will change soon.

  • ForEachCoClass.h: Added WebScriptWorld.
  • Interfaces/IWebFramePrivate.idl: Replaced contextForWorldID with

contextForWorld.

  • Interfaces/IWebScriptWorld.idl: Added.
  • Interfaces/IWebViewPrivate.idl: Changed the user script/stylesheet

functions to take an IWebScriptWorld instead of a worldID.

  • Interfaces/WebKit.idl: Added WebScriptWorld.
  • WebFrame.cpp:

(WebFrame::contextForWorld): Renamed from contextForWorldID. Now takes
an IWebScriptWorld.
(WebFrame::stringByEvaluatingJavaScriptInIsolatedWorld): Moved the
bizarre world caching/creation logic that DRT depends on here from the
findWorld function in ScriptController.cpp. Updated to use
ScriptController::executeScriptInWorld instead of
ScriptController::executeScriptInIsolatedWorld.

  • WebFrame.h: Replaced contextForWorldID with contextForWorld.
  • WebScriptWorld.cpp: Added.

(WebScriptWorld::WebScriptWorld):
(WebScriptWorld::~WebScriptWorld):
(WebScriptWorld::createInstance):
(WebScriptWorld::AddRef):
(WebScriptWorld::Release):
(WebScriptWorld::QueryInterface):
Standard COM class implementations.

(WebScriptWorld::standardWorld): Returns a shared instance that represents
WebCore's mainThreadNormalWorld().

  • WebScriptWorld.h: Added.

(WebScriptWorld::world): Simple getter.

  • WebKit.vcproj/Interfaces.vcproj: Added IWebScriptWorld.idl.
  • WebKit.vcproj/WebKit.vcproj: Added WebScriptWorld.
  • WebKitClassFactory.cpp: Added WebScriptWorld.
  • WebView.cpp:

(WebView::addUserScriptToGroup):
(WebView::addUserStyleSheetToGroup):
(WebView::removeUserScriptFromGroup):
(WebView::removeUserStyleSheetFromGroup):
(WebView::removeUserScriptsFromGroup):
(WebView::removeUserStyleSheetsFromGroup):

  • WebView.h:

Changed these functions to take an IWebScriptWorld instead of a worldID.

WebKitTools:

  • DumpRenderTree/mac/LayoutTestControllerMac.mm:

(LayoutTestController::addUserScript):
(LayoutTestController::addUserStyleSheet):

  • DumpRenderTree/win/LayoutTestControllerWin.cpp:

(LayoutTestController::addUserScript):
(LayoutTestController::addUserStyleSheet):
Changed these functions to create a new WebJSWorld each time they're
called and to pass that world to WebKit.

Location:
trunk
Files:
6 added
36 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r50905 r50907  
     12009-11-12  Adam Roben  <aroben@apple.com>
     2
     3        Replace worldIDs with world objects
     4
     5        Part of <http://webkit.org/b/31414> Implement new SPI for dealing with
     6        user scripts/stylesheets and isolated worlds
     7
     8        Reviewed by Sam Weinig.
     9
     10        Covered by existing tests.
     11
     12        * WebCore.base.exp: Update exported symbols to match what now exists
     13        and is needed by WebKit.
     14
     15        * bindings/js/ScheduledAction.cpp:
     16        (WebCore::ScheduledAction::execute): Updated for function rename.
     17
     18        * bindings/js/ScriptController.cpp: Removed code that dealt with
     19        worldIDs.
     20        (WebCore::ScriptController::createWorld): Added. Returns a new world
     21        suitable for use on the main thread.
     22        (WebCore::ScriptController::executeScriptInWorld): Renamed from
     23        executeScriptInIsolatedWorld, since this works just fine with a
     24        "normal" world.
     25
     26        * bindings/js/ScriptController.h: Added createWorld, removed functions
     27        that took worldIDs, renamed executeScriptInIsolatedWorld to
     28        executeScriptInWorld.
     29
     30        * page/Frame.cpp:
     31        (WebCore::Frame::injectUserScripts):
     32        (WebCore::Frame::injectUserScriptsForWorld):
     33        Updated for changes to UserScriptMap and ScriptController.
     34
     35        * page/Frame.h: Changed injectUserScriptsForWorld to take a
     36        DOMWrapperWorld* instead of a worldID.
     37
     38        * page/PageGroup.cpp:
     39        (WebCore::PageGroup::addUserScriptToWorld):
     40        (WebCore::PageGroup::addUserStyleSheetToWorld):
     41        (WebCore::PageGroup::removeUserScriptFromWorld):
     42        (WebCore::PageGroup::removeUserStyleSheetFromWorld):
     43        (WebCore::PageGroup::removeUserScriptsFromWorld):
     44        (WebCore::PageGroup::removeUserStyleSheetsFromWorld):
     45        * page/PageGroup.h:
     46        Changed these functions to take a DOMWrapperWorld* instead of a
     47        worldID. Also updated for changes to UserScript and UserStyleSheet.
     48
     49        * page/UserScript.h:
     50        * page/UserStyleSheet.h: Changed not to hold a worldID, since it was
     51        never used.
     52
     53        * page/UserScriptTypes.h:
     54        * page/UserStyleSheetTypes.h: Changed UserScriptMap and
     55        UserStyleSheetMap to use a RefPtr<DOMWrapperWorld> instead of a
     56        worldID as their key type.
     57
     58
    1592009-11-12  Brian Weinstein  <bweinstein@apple.com>
    260
  • trunk/WebCore/WebCore.base.exp

    r50792 r50907  
    327327__ZN7WebCore15BackForwardListC1EPNS_4PageE
    328328__ZN7WebCore15BackForwardListD1Ev
     329__ZN7WebCore15DOMWrapperWorldD1Ev
    329330__ZN7WebCore15DatabaseTracker12deleteOriginEPNS_14SecurityOriginE
    330331__ZN7WebCore15DatabaseTracker14deleteDatabaseEPNS_14SecurityOriginERKNS_6StringE
     
    339340__ZN7WebCore15DatabaseTracker8setQuotaEPNS_14SecurityOriginEy
    340341__ZN7WebCore15DatabaseTracker9setClientEPNS_21DatabaseTrackerClientE
    341 __ZN7WebCore15DOMWrapperWorldD1Ev
    342342__ZN7WebCore15FocusController10setFocusedEb
    343343__ZN7WebCore15FocusController15setFocusedFrameEN3WTF10PassRefPtrINS_5FrameEEE
     
    374374__ZN7WebCore16NavigationActionC1Ev
    375375__ZN7WebCore16ScriptController10initScriptEPNS_15DOMWrapperWorldE
    376 __ZN7WebCore16ScriptController12globalObjectEj
     376__ZN7WebCore16ScriptController11createWorldEv
    377377__ZN7WebCore16ScriptController13executeScriptERKNS_6StringEb
    378378__ZN7WebCore16ScriptController18windowScriptObjectEv
    379 __ZN7WebCore16ScriptController28executeScriptInIsolatedWorldEjRKNS_6StringEb
     379__ZN7WebCore16ScriptController20executeScriptInWorldEPNS_15DOMWrapperWorldERKNS_6StringEb
    380380__ZN7WebCore16VisibleSelectionC1EPKNS_5RangeENS_9EAffinityE
    381381__ZN7WebCore16VisibleSelectionC1ERKNS_15VisiblePositionES3_
     
    734734__ZN7WebCore9PageGroup14addVisitedLinkEPKtm
    735735__ZN7WebCore9PageGroup17closeLocalStorageEv
    736 __ZN7WebCore9PageGroup20addUserScriptToWorldEjRKNS_6StringERKNS_4KURLEN3WTF10PassOwnPtrINS7_6VectorIS1_Lm0EEEEESB_NS_23UserScriptInjectionTimeE
     736__ZN7WebCore9PageGroup20addUserScriptToWorldEPNS_15DOMWrapperWorldERKNS_6StringERKNS_4KURLEN3WTF10PassOwnPtrINS9_6VectorIS3_Lm0EEEEESD_NS_23UserScriptInjectionTimeE
    737737__ZN7WebCore9PageGroup20removeAllUserContentEv
    738738__ZN7WebCore9PageGroup21removeAllVisitedLinksEv
    739 __ZN7WebCore9PageGroup24addUserStyleSheetToWorldEjRKNS_6StringERKNS_4KURLEN3WTF10PassOwnPtrINS7_6VectorIS1_Lm0EEEEESB_
    740 __ZN7WebCore9PageGroup25removeUserScriptFromWorldEjRKNS_4KURLE
    741 __ZN7WebCore9PageGroup26removeUserScriptsFromWorldEj
     739__ZN7WebCore9PageGroup24addUserStyleSheetToWorldEPNS_15DOMWrapperWorldERKNS_6StringERKNS_4KURLEN3WTF10PassOwnPtrINS9_6VectorIS3_Lm0EEEEESD_
     740__ZN7WebCore9PageGroup25removeUserScriptFromWorldEPNS_15DOMWrapperWorldERKNS_4KURLE
     741__ZN7WebCore9PageGroup26removeUserScriptsFromWorldEPNS_15DOMWrapperWorldE
    742742__ZN7WebCore9PageGroup26setShouldTrackVisitedLinksEb
    743 __ZN7WebCore9PageGroup29removeUserStyleSheetFromWorldEjRKNS_4KURLE
    744 __ZN7WebCore9PageGroup30removeUserStyleSheetsFromWorldEj
     743__ZN7WebCore9PageGroup29removeUserStyleSheetFromWorldEPNS_15DOMWrapperWorldERKNS_4KURLE
     744__ZN7WebCore9PageGroup30removeUserStyleSheetsFromWorldEPNS_15DOMWrapperWorldE
    745745__ZN7WebCore9PageGroup9pageGroupERKNS_6StringE
    746746__ZN7WebCore9TimerBase4stopEv
  • trunk/WebCore/bindings/js/ScheduledAction.cpp

    r49963 r50907  
    127127        Document::updateStyleForAllDocuments();
    128128    } else
    129         frame->script()->executeScriptInIsolatedWorld(m_isolatedWorld.get(), m_code);
     129        frame->script()->executeScriptInWorld(m_isolatedWorld.get(), m_code);
    130130
    131131    frame->script()->setProcessingTimerCallback(false);
  • trunk/WebCore/bindings/js/ScriptController.cpp

    r50792 r50907  
    166166};
    167167
    168 static PassRefPtr<IsolatedWorld> findWorld(unsigned worldID)
    169 {
    170     if (!worldID)
    171         return IsolatedWorld::create(JSDOMWindow::commonJSGlobalData());
    172 
    173     typedef HashMap<unsigned, RefPtr<IsolatedWorld> > WorldMap;
    174     DEFINE_STATIC_LOCAL(WorldMap, isolatedWorlds, ());
    175 
    176     WorldMap::iterator iter = isolatedWorlds.find(worldID);
    177     if (iter != isolatedWorlds.end())
    178         return iter->second;
    179 
    180     RefPtr<IsolatedWorld> newWorld = IsolatedWorld::create(JSDOMWindow::commonJSGlobalData());
    181     isolatedWorlds.add(worldID, newWorld);
    182     return newWorld;
    183 }
    184 
    185 JSDOMWindow* ScriptController::globalObject(unsigned worldID)
    186 {
    187     RefPtr<DOMWrapperWorld> world = findWorld(worldID);
    188     return windowShell(world.get())->window();
    189 }
    190 
    191 ScriptValue ScriptController::evaluateInIsolatedWorld(unsigned worldID, const ScriptSourceCode& sourceCode)
    192 {
    193     RefPtr<DOMWrapperWorld> world = findWorld(worldID);
    194     return evaluateInWorld(sourceCode, world.get());
    195 }
    196 
    197 void ScriptController::evaluateInIsolatedWorld(unsigned worldID, const Vector<ScriptSourceCode>& sourceCode)
    198 {
    199     RefPtr<DOMWrapperWorld> world = findWorld(worldID);
    200 
    201     unsigned size = sourceCode.size();
    202     for (unsigned i = 0; i < size; ++i)
    203         evaluateInWorld(sourceCode[i], world.get());
     168PassRefPtr<DOMWrapperWorld> ScriptController::createWorld()
     169{
     170    return IsolatedWorld::create(JSDOMWindow::commonJSGlobalData());
    204171}
    205172
     
    477444}
    478445
    479 ScriptValue ScriptController::executeScriptInIsolatedWorld(unsigned worldID, const String& script, bool forceUserGesture)
     446ScriptValue ScriptController::executeScriptInWorld(DOMWrapperWorld* world, const String& script, bool forceUserGesture)
    480447{
    481448    ScriptSourceCode sourceCode(script, forceUserGesture ? KURL() : m_frame->loader()->url());
     
    487454    m_inExecuteScript = true;
    488455
    489     ScriptValue result = evaluateInIsolatedWorld(worldID, sourceCode);
     456    ScriptValue result = evaluateInWorld(sourceCode, world);
    490457
    491458    if (!wasInExecuteScript) {
     
    497464}
    498465
    499 ScriptValue ScriptController::executeScriptInIsolatedWorld(DOMWrapperWorld* world, const String& script, bool forceUserGesture)
    500 {
    501     ScriptSourceCode sourceCode(script, forceUserGesture ? KURL() : m_frame->loader()->url());
    502 
    503     if (!isEnabled() || isPaused())
    504         return ScriptValue();
    505 
    506     bool wasInExecuteScript = m_inExecuteScript;
    507     m_inExecuteScript = true;
    508 
    509     ScriptValue result = evaluateInWorld(sourceCode, world);
    510 
    511     if (!wasInExecuteScript) {
    512         m_inExecuteScript = false;
    513         Document::updateStyleForAllDocuments();
    514     }
    515 
    516     return result;
    517 }
    518 
    519466} // namespace WebCore
  • trunk/WebCore/bindings/js/ScriptController.h

    r50792 r50907  
    7171    ~ScriptController();
    7272
     73    static PassRefPtr<DOMWrapperWorld> createWorld();
     74
    7375    JSDOMWindowShell* windowShell(DOMWrapperWorld* world)
    7476    {
     
    8587        return windowShell(world)->window();
    8688    }
    87     JSDOMWindow* globalObject(unsigned worldID);
    8889
    8990    ScriptValue executeScript(const ScriptSourceCode&);
    9091    ScriptValue executeScript(const String& script, bool forceUserGesture = false);
    91     ScriptValue executeScriptInIsolatedWorld(unsigned worldID, const String& script, bool forceUserGesture = false);
    92     ScriptValue executeScriptInIsolatedWorld(DOMWrapperWorld* world, const String& script, bool forceUserGesture = false);
     92    ScriptValue executeScriptInWorld(DOMWrapperWorld* world, const String& script, bool forceUserGesture = false);
    9393
    9494    // Returns true if argument is a JavaScript URL.
     
    101101    ScriptValue evaluate(const ScriptSourceCode&);
    102102    ScriptValue evaluateInWorld(const ScriptSourceCode&, DOMWrapperWorld*);
    103     ScriptValue evaluateInIsolatedWorld(unsigned /*worldID*/, const ScriptSourceCode&);
    104     void evaluateInIsolatedWorld(unsigned /*worldID*/, const Vector<ScriptSourceCode>&);
    105103
    106104    void setEventHandlerLineNumber(int lineno) { m_handlerLineNumber = lineno; }
  • trunk/WebCore/page/Frame.cpp

    r50672 r50907  
    875875    UserScriptMap::const_iterator end = userScripts->end();
    876876    for (UserScriptMap::const_iterator it = userScripts->begin(); it != end; ++it)
    877         injectUserScriptsForWorld(it->first, *it->second, injectionTime);
    878 }
    879 
    880 void Frame::injectUserScriptsForWorld(unsigned worldID, const UserScriptVector& userScripts, UserScriptInjectionTime injectionTime)
     877        injectUserScriptsForWorld(it->first.get(), *it->second, injectionTime);
     878}
     879
     880void Frame::injectUserScriptsForWorld(DOMWrapperWorld* world, const UserScriptVector& userScripts, UserScriptInjectionTime injectionTime)
    881881{
    882882    if (userScripts.isEmpty())
     
    892892        UserScript* script = userScripts[i].get();
    893893        if (script->injectionTime() == injectionTime && UserContentURLPattern::matchesPatterns(doc->url(), script->whitelist(), script->blacklist()))
    894             sourceCode.append(ScriptSourceCode(script->source(), script->url()));
    895     }
    896     script()->evaluateInIsolatedWorld(worldID, sourceCode);
     894            m_script.evaluateInWorld(ScriptSourceCode(script->source(), script->url()), world);
     895    }
    897896}
    898897
  • trunk/WebCore/page/Frame.h

    r48958 r50907  
    132132
    133133    private:
    134         void injectUserScriptsForWorld(unsigned worldID, const UserScriptVector&, UserScriptInjectionTime);
     134        void injectUserScriptsForWorld(DOMWrapperWorld*, const UserScriptVector&, UserScriptInjectionTime);
    135135
    136136    private:
  • trunk/WebCore/page/PageGroup.cpp

    r49541 r50907  
    201201#endif
    202202
    203 void PageGroup::addUserScriptToWorld(unsigned worldID, const String& source, const KURL& url,  PassOwnPtr<Vector<String> > whitelist,
     203void PageGroup::addUserScriptToWorld(DOMWrapperWorld* world, const String& source, const KURL& url,  PassOwnPtr<Vector<String> > whitelist,
    204204                                     PassOwnPtr<Vector<String> > blacklist, UserScriptInjectionTime injectionTime)
    205205{
    206     if (worldID == UINT_MAX)
    207         return;
    208     OwnPtr<UserScript> userScript(new UserScript(source, url, whitelist, blacklist, worldID, injectionTime));
     206    ASSERT_ARG(world, world);
     207
     208    OwnPtr<UserScript> userScript(new UserScript(source, url, whitelist, blacklist, injectionTime));
    209209    if (!m_userScripts)
    210210        m_userScripts.set(new UserScriptMap);
    211     UserScriptVector*& scriptsInWorld = m_userScripts->add(worldID, 0).first->second;
     211    UserScriptVector*& scriptsInWorld = m_userScripts->add(world, 0).first->second;
    212212    if (!scriptsInWorld)
    213213        scriptsInWorld = new UserScriptVector;
     
    215215}
    216216
    217 void PageGroup::addUserStyleSheetToWorld(unsigned worldID, const String& source, const KURL& url, PassOwnPtr<Vector<String> > whitelist,
     217void PageGroup::addUserStyleSheetToWorld(DOMWrapperWorld* world, const String& source, const KURL& url, PassOwnPtr<Vector<String> > whitelist,
    218218                                         PassOwnPtr<Vector<String> > blacklist)
    219219{
    220     if (worldID == UINT_MAX)
    221         return;
    222     OwnPtr<UserStyleSheet> userStyleSheet(new UserStyleSheet(source, url, whitelist, blacklist, worldID));
     220    ASSERT_ARG(world, world);
     221
     222    OwnPtr<UserStyleSheet> userStyleSheet(new UserStyleSheet(source, url, whitelist, blacklist));
    223223    if (!m_userStyleSheets)
    224224        m_userStyleSheets.set(new UserStyleSheetMap);
    225     UserStyleSheetVector*& styleSheetsInWorld = m_userStyleSheets->add(worldID, 0).first->second;
     225    UserStyleSheetVector*& styleSheetsInWorld = m_userStyleSheets->add(world, 0).first->second;
    226226    if (!styleSheetsInWorld)
    227227        styleSheetsInWorld = new UserStyleSheetVector;
     
    236236}
    237237
    238 void PageGroup::removeUserScriptFromWorld(unsigned worldID, const KURL& url)
    239 {
     238void PageGroup::removeUserScriptFromWorld(DOMWrapperWorld* world, const KURL& url)
     239{
     240    ASSERT_ARG(world, world);
     241
    240242    if (!m_userScripts)
    241243        return;
    242244
    243     UserScriptMap::iterator it = m_userScripts->find(worldID);
     245    UserScriptMap::iterator it = m_userScripts->find(world);
    244246    if (it == m_userScripts->end())
    245247        return;
     
    258260}
    259261
    260 void PageGroup::removeUserStyleSheetFromWorld(unsigned worldID, const KURL& url)
    261 {
     262void PageGroup::removeUserStyleSheetFromWorld(DOMWrapperWorld* world, const KURL& url)
     263{
     264    ASSERT_ARG(world, world);
     265
    262266    if (!m_userStyleSheets)
    263267        return;
    264268
    265     UserStyleSheetMap::iterator it = m_userStyleSheets->find(worldID);
     269    UserStyleSheetMap::iterator it = m_userStyleSheets->find(world);
    266270    bool sheetsChanged = false;
    267271    if (it == m_userStyleSheets->end())
     
    292296}
    293297
    294 void PageGroup::removeUserScriptsFromWorld(unsigned worldID)
    295 {
     298void PageGroup::removeUserScriptsFromWorld(DOMWrapperWorld* world)
     299{
     300    ASSERT_ARG(world, world);
     301
    296302    if (!m_userScripts)
    297303        return;
    298304
    299     UserScriptMap::iterator it = m_userScripts->find(worldID);
     305    UserScriptMap::iterator it = m_userScripts->find(world);
    300306    if (it == m_userScripts->end())
    301307        return;
     
    305311}
    306312
    307 void PageGroup::removeUserStyleSheetsFromWorld(unsigned worldID)
    308 {
     313void PageGroup::removeUserStyleSheetsFromWorld(DOMWrapperWorld* world)
     314{
     315    ASSERT_ARG(world, world);
     316
    309317    if (!m_userStyleSheets)
    310318        return;
    311319   
    312     UserStyleSheetMap::iterator it = m_userStyleSheets->find(worldID);
     320    UserStyleSheetMap::iterator it = m_userStyleSheets->find(world);
    313321    if (it == m_userStyleSheets->end())
    314322        return;
  • trunk/WebCore/page/PageGroup.h

    r49541 r50907  
    7171#endif
    7272
    73         void addUserScriptToWorld(unsigned worldID, const String& source, const KURL&,
     73        void addUserScriptToWorld(DOMWrapperWorld*, const String& source, const KURL&,
    7474                                  PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist,
    7575                                  UserScriptInjectionTime);
    76         void addUserStyleSheetToWorld(unsigned worldID, const String& source, const KURL&,
     76        void addUserStyleSheetToWorld(DOMWrapperWorld*, const String& source, const KURL&,
    7777                               PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist);
    7878       
    79         void removeUserScriptFromWorld(unsigned, const KURL&);
    80         void removeUserStyleSheetFromWorld(unsigned, const KURL&);
     79        void removeUserScriptFromWorld(DOMWrapperWorld*, const KURL&);
     80        void removeUserStyleSheetFromWorld(DOMWrapperWorld*, const KURL&);
    8181       
    82         void removeUserScriptsFromWorld(unsigned);
    83         void removeUserStyleSheetsFromWorld(unsigned);
     82        void removeUserScriptsFromWorld(DOMWrapperWorld*);
     83        void removeUserStyleSheetsFromWorld(DOMWrapperWorld*);
    8484   
    8585        void removeAllUserContent();
  • trunk/WebCore/page/UserScript.h

    r50810 r50907  
    3939    UserScript(const String& source, const KURL& url,
    4040               PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist,
    41                unsigned worldID, UserScriptInjectionTime injectionTime)
     41               UserScriptInjectionTime injectionTime)
    4242        : m_source(source)
    4343        , m_url(url)
    4444        , m_whitelist(whitelist)
    4545        , m_blacklist(blacklist)
    46         , m_worldID(worldID)
    4746        , m_injectionTime(injectionTime)
    4847    {
     
    5352    const Vector<String>* whitelist() const { return m_whitelist.get(); }
    5453    const Vector<String>* blacklist() const { return m_blacklist.get(); }
    55     unsigned worldID() const { return m_worldID; }
    5654    UserScriptInjectionTime injectionTime() const { return m_injectionTime; }
    5755   
     
    6159    OwnPtr<Vector<String> > m_whitelist;
    6260    OwnPtr<Vector<String> > m_blacklist;
    63     unsigned m_worldID;
    6461    UserScriptInjectionTime m_injectionTime;
    6562};
  • trunk/WebCore/page/UserScriptTypes.h

    r48225 r50907  
    3434enum UserScriptInjectionTime { InjectAtDocumentStart, InjectAtDocumentEnd };
    3535
     36class DOMWrapperWorld;
    3637class UserScript;
    3738
    3839typedef Vector<OwnPtr<UserScript> > UserScriptVector;
    39 typedef HashMap<unsigned, UserScriptVector*> UserScriptMap;
     40typedef HashMap<RefPtr<DOMWrapperWorld>, UserScriptVector*> UserScriptMap;
    4041
    4142} // namespace WebCore
  • trunk/WebCore/page/UserStyleSheet.h

    r50810 r50907  
    3838public:
    3939    UserStyleSheet(const String& source, const KURL& url,
    40                    PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist,
    41                    unsigned worldID)
     40                   PassOwnPtr<Vector<String> > whitelist, PassOwnPtr<Vector<String> > blacklist)
    4241        : m_source(source)
    4342        , m_url(url)
    4443        , m_whitelist(whitelist)
    4544        , m_blacklist(blacklist)
    46         , m_worldID(worldID)
    4745    {
    4846    }
     
    5250    const Vector<String>* whitelist() const { return m_whitelist.get(); }
    5351    const Vector<String>* blacklist() const { return m_blacklist.get(); }
    54     unsigned worldID() const { return m_worldID; }
    5552
    5653private:
     
    5956    OwnPtr<Vector<String> > m_whitelist;
    6057    OwnPtr<Vector<String> > m_blacklist;
    61     unsigned m_worldID;
    6258};
    6359
  • trunk/WebCore/page/UserStyleSheetTypes.h

    r48225 r50907  
    3232namespace WebCore {
    3333
     34class DOMWrapperWorld;
    3435class UserStyleSheet;
    3536
    3637typedef Vector<OwnPtr<UserStyleSheet> > UserStyleSheetVector;
    37 typedef HashMap<unsigned, UserStyleSheetVector*> UserStyleSheetMap;
     38typedef HashMap<RefPtr<DOMWrapperWorld>, UserStyleSheetVector*> UserStyleSheetMap;
    3839
    3940} // namespace WebCore
  • trunk/WebKit/ChangeLog

    r50883 r50907  
     12009-11-12  Adam Roben  <aroben@apple.com>
     2
     3        Replace worldIDs with world objects
     4
     5        Part of <http://webkit.org/b/31414> Implement new SPI for dealing with
     6        user scripts/stylesheets and isolated worlds
     7
     8        Reviewed by Sam Weinig.
     9
     10        * WebKit.xcodeproj/project.pbxproj: Added WebScriptWorld to the project.
     11
    1122009-11-12  Chris Fleizach  <cfleizach@apple.com>
    213
  • trunk/WebKit/WebKit.xcodeproj/project.pbxproj

    r50106 r50907  
    334334                C0167BF80D7F5DD00028696E /* WebScriptDebugger.h in Headers */ = {isa = PBXBuildFile; fileRef = C0167BF60D7F5DD00028696E /* WebScriptDebugger.h */; };
    335335                C0167BF90D7F5DD00028696E /* WebScriptDebugger.mm in Sources */ = {isa = PBXBuildFile; fileRef = C0167BF70D7F5DD00028696E /* WebScriptDebugger.mm */; };
     336                C0B1F7E810AC8E3100C925D9 /* WebScriptWorld.h in Headers */ = {isa = PBXBuildFile; fileRef = C0B1F7E510AC8E3100C925D9 /* WebScriptWorld.h */; settings = {ATTRIBUTES = (Private, ); }; };
     337                C0B1F7E910AC8E3100C925D9 /* WebScriptWorld.mm in Sources */ = {isa = PBXBuildFile; fileRef = C0B1F7E610AC8E3100C925D9 /* WebScriptWorld.mm */; };
     338                C0B1F7EA10AC8E3100C925D9 /* WebScriptWorldInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = C0B1F7E710AC8E3100C925D9 /* WebScriptWorldInternal.h */; };
    336339                DD7CDEE70A23BA9E00069928 /* WebTypesInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = DD7CDEE60A23BA9E00069928 /* WebTypesInternal.h */; };
    337340                DD89682009AA87240097E7F0 /* WebElementDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = DD89681E09AA87240097E7F0 /* WebElementDictionary.h */; };
     
    622625                C0167BF60D7F5DD00028696E /* WebScriptDebugger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebScriptDebugger.h; sourceTree = "<group>"; };
    623626                C0167BF70D7F5DD00028696E /* WebScriptDebugger.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebScriptDebugger.mm; sourceTree = "<group>"; };
     627                C0B1F7E510AC8E3100C925D9 /* WebScriptWorld.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebScriptWorld.h; sourceTree = "<group>"; };
     628                C0B1F7E610AC8E3100C925D9 /* WebScriptWorld.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebScriptWorld.mm; sourceTree = "<group>"; };
     629                C0B1F7E710AC8E3100C925D9 /* WebScriptWorldInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebScriptWorldInternal.h; sourceTree = "<group>"; };
    624630                DD7CDEE60A23BA9E00069928 /* WebTypesInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebTypesInternal.h; sourceTree = "<group>"; };
    625631                DD89681E09AA87240097E7F0 /* WebElementDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebElementDictionary.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
     
    11311137                                C0167BF60D7F5DD00028696E /* WebScriptDebugger.h */,
    11321138                                C0167BF70D7F5DD00028696E /* WebScriptDebugger.mm */,
     1139                                C0B1F7E510AC8E3100C925D9 /* WebScriptWorld.h */,
     1140                                C0B1F7E610AC8E3100C925D9 /* WebScriptWorld.mm */,
     1141                                C0B1F7E710AC8E3100C925D9 /* WebScriptWorldInternal.h */,
    11331142                                936A2DE90FD2D08400D312DB /* WebTextCompletionController.h */,
    11341143                                936A2DE70FD2D08000D312DB /* WebTextCompletionController.mm */,
     
    15141523                                0FD3B0F81076C3F700039B96 /* WebWindowAnimation.h in Headers */,
    15151524                                0A2D87FD107AF52B00CDDEE3 /* WebPluginHalterClient.h in Headers */,
     1525                                C0B1F7E810AC8E3100C925D9 /* WebScriptWorld.h in Headers */,
     1526                                C0B1F7EA10AC8E3100C925D9 /* WebScriptWorldInternal.h in Headers */,
    15161527                        );
    15171528                        runOnlyForDeploymentPostprocessing = 0;
     
    18541865                                0A2D87FE107AF52B00CDDEE3 /* WebPluginHalterClient.mm in Sources */,
    18551866                                BC97E7E210963D260010D361 /* WebViewEventHandling.mm in Sources */,
     1867                                C0B1F7E910AC8E3100C925D9 /* WebScriptWorld.mm in Sources */,
    18561868                        );
    18571869                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebKit/mac/ChangeLog

    r50883 r50907  
     12009-11-12  Adam Roben  <aroben@apple.com>
     2
     3        Replace worldIDs with world objects
     4
     5        WebScriptWorld is the new object that represents a world.  The only
     6        place worldID is still used is in -[WebFrame
     7        _stringByEvaluatingJavaScriptInIsolatedWorld:WithGlobalObject:FromString:],
     8        but that will change soon.
     9
     10        Part of <http://webkit.org/b/31414> Implement new SPI for dealing with
     11        user scripts/stylesheets and isolated worlds
     12
     13        Reviewed by Sam Weinig.
     14
     15        * WebKit.exp: Export WebScriptWorld.
     16
     17        * WebView/WebFrame.mm:
     18        (-[WebFrame _stringByEvaluatingJavaScriptInIsolatedWorld:WithGlobalObject:FromString:]):
     19        Moved the bizarre world caching/creation logic that DRT depends on
     20        here from the findWorld function in ScriptController.cpp. Updated to
     21        use ScriptController::executeScriptInWorld instead of
     22        ScriptController::executeScriptInIsolatedWorld.
     23        (-[WebFrame _contextForWorld:]): Renamed from contextForWorldID:. Now
     24        takes a WebScriptWorld.
     25
     26        * WebView/WebFramePrivate.h: Replaced contextForWorldID: with
     27        _contextForWorld:.
     28
     29        * WebView/WebScriptWorld.h: Added.
     30        * WebView/WebScriptWorld.mm: Added.
     31        (-[WebScriptWorld initWithWorld:]): Store the passed-in world in our
     32        _private member.
     33        (-[WebScriptWorld init]): Create a new DOMWrapperWorld and pass it to
     34        -initWithWorld:.
     35        (-[WebScriptWorld dealloc]): Release _private.
     36        (+[WebScriptWorld standardWorld]): Returns a shared instance that
     37        represents WebCore's mainThreadNormalWorld().
     38        (+[WebScriptWorld world]): Returns a new instance.
     39        (core): Returns the DOMWrapperWorld for this WebScriptWorld.
     40
     41        * WebView/WebScriptWorldInternal.h: Added.
     42
     43        * WebView/WebView.mm:
     44        (+[WebView _addUserScriptToGroup:world:source:url:whitelist:blacklist:injectionTime:]):
     45        (+[WebView _addUserStyleSheetToGroup:world:source:url:whitelist:blacklist:]):
     46        (+[WebView _removeUserScriptFromGroup:world:url:]):
     47        (+[WebView _removeUserStyleSheetFromGroup:world:url:]):
     48        (+[WebView _removeUserScriptsFromGroup:world:]):
     49        (+[WebView _removeUserStyleSheetsFromGroup:world:]):
     50        * WebView/WebViewPrivate.h:
     51        Changed these functions to take a WebScriptWorld instead of a worldID.
     52
    1532009-11-12  Chris Fleizach  <cfleizach@apple.com>
    254
  • trunk/WebKit/mac/WebKit.exp

    r48144 r50907  
    2929.objc_class_name_WebResource
    3030.objc_class_name_WebScriptCallFrame
     31.objc_class_name_WebScriptWorld
    3132.objc_class_name_WebSecurityOrigin
    3233.objc_class_name_WebStringTruncator
  • trunk/WebKit/mac/WebView/WebFrame.mm

    r50786 r50907  
    5050#import "WebNSURLExtras.h"
    5151#import "WebScriptDebugger.h"
     52#import "WebScriptWorldInternal.h"
    5253#import "WebViewInternal.h"
    5354#import <JavaScriptCore/APICast.h>
     
    12041205    Frame* frame = anyWorldGlobalObject->impl()->frame();
    12051206    ASSERT(frame->document());
    1206     JSValue result = frame->script()->executeScriptInIsolatedWorld(worldID, string, true).jsValue();
     1207
     1208    // Get the world to execute in based on the worldID. DRT expects that a
     1209    // worldID of 0 always corresponds to a newly-created world, while any
     1210    // other worldID corresponds to a world that is created once and then
     1211    // cached forever.
     1212    RefPtr<DOMWrapperWorld> world;
     1213    if (!worldID)
     1214        world = ScriptController::createWorld();
     1215    else {
     1216        static HashMap<unsigned, RefPtr<DOMWrapperWorld> >& worlds = *new HashMap<unsigned, RefPtr<DOMWrapperWorld> >;
     1217        RefPtr<DOMWrapperWorld>& worldSlot = worlds.add(worldID, 0).first->second;
     1218        if (!worldSlot)
     1219            worldSlot = ScriptController::createWorld();
     1220        world = worldSlot;
     1221    }
     1222    JSValue result = frame->script()->executeScriptInWorld(world.get(), string, true).jsValue();
    12071223
    12081224    if (!frame) // In case the script removed our frame from the page.
     
    12191235}
    12201236
    1221 - (JSGlobalContextRef)contextForWorldID:(unsigned)worldID;
     1237- (JSGlobalContextRef)_globalContextForScriptWorld:(WebScriptWorld *)world
    12221238{
    12231239    Frame* coreFrame = _private->coreFrame;
    12241240    if (!coreFrame)
    12251241        return 0;
    1226     return toGlobalRef(coreFrame->script()->globalObject(worldID)->globalExec());
     1242    DOMWrapperWorld* coreWorld = core(world);
     1243    if (!coreWorld)
     1244        return 0;
     1245    return toGlobalRef(coreFrame->script()->globalObject(coreWorld)->globalExec());
    12271246}
    12281247
  • trunk/WebKit/mac/WebView/WebFramePrivate.h

    r50012 r50907  
    4040@class WebIconFetcher;
    4141@class WebScriptObject;
     42@class WebScriptWorld;
    4243
    4344// Keys for accessing the values in the page cache dictionary.
     
    9899
    99100- (NSString *)_stringByEvaluatingJavaScriptInIsolatedWorld:(unsigned)worldID WithGlobalObject:(JSObjectRef)globalObject FromString:(NSString *)string;
    100 - (JSGlobalContextRef)contextForWorldID:(unsigned)worldID;
     101- (JSGlobalContextRef)_globalContextForScriptWorld:(WebScriptWorld *)world;
    101102
    102103// Pause a given CSS animation or transition on the target node at a specific time.
  • trunk/WebKit/mac/WebView/WebView.mm

    r50242 r50907  
    9191#import "WebPreferencesPrivate.h"
    9292#import "WebScriptDebugDelegate.h"
     93#import "WebScriptWorldInternal.h"
    9394#import "WebSystemInterface.h"
    9495#import "WebTextCompletionController.h"
     
    21762177}
    21772178
    2178 + (void)_addUserScriptToGroup:(NSString *)groupName worldID:(unsigned)worldID source:(NSString *)source url:(NSURL *)url
     2179+ (void)_addUserScriptToGroup:(NSString *)groupName world:(WebScriptWorld *)world source:(NSString *)source url:(NSURL *)url
    21792180                    whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist injectionTime:(WebUserScriptInjectionTime)injectionTime
    21802181{
    21812182    String group(groupName);
    2182     if (group.isEmpty() || worldID == UINT_MAX)
     2183    if (group.isEmpty())
    21832184        return;
    21842185   
     
    21872188        return;
    21882189   
    2189     pageGroup->addUserScriptToWorld(worldID, source, url, toStringVector(whitelist), toStringVector(blacklist),
     2190    pageGroup->addUserScriptToWorld(core(world), source, url, toStringVector(whitelist), toStringVector(blacklist),
    21902191                                    injectionTime == WebInjectAtDocumentStart ? InjectAtDocumentStart : InjectAtDocumentEnd);
    21912192}
    21922193
    2193 + (void)_addUserStyleSheetToGroup:(NSString *)groupName worldID:(unsigned)worldID source:(NSString *)source url:(NSURL *)url
     2194+ (void)_addUserStyleSheetToGroup:(NSString *)groupName world:(WebScriptWorld *)world source:(NSString *)source url:(NSURL *)url
    21942195                        whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist
    21952196{
    21962197    String group(groupName);
    2197     if (group.isEmpty() || worldID == UINT_MAX)
     2198    if (group.isEmpty())
    21982199        return;
    21992200   
     
    22022203        return;
    22032204
    2204     pageGroup->addUserStyleSheetToWorld(worldID, source, url, toStringVector(whitelist), toStringVector(blacklist));
    2205 }
    2206 
    2207 + (void)_removeUserScriptFromGroup:(NSString *)groupName worldID:(unsigned)worldID url:(NSURL *)url
     2205    pageGroup->addUserStyleSheetToWorld(core(world), source, url, toStringVector(whitelist), toStringVector(blacklist));
     2206}
     2207
     2208+ (void)_removeUserScriptFromGroup:(NSString *)groupName world:(WebScriptWorld *)world url:(NSURL *)url
    22082209{
    22092210    String group(groupName);
     
    22152216        return;
    22162217
    2217     pageGroup->removeUserScriptFromWorld(worldID, url);
    2218 }
    2219 
    2220 + (void)_removeUserStyleSheetFromGroup:(NSString *)groupName worldID:(unsigned)worldID url:(NSURL *)url
     2218    pageGroup->removeUserScriptFromWorld(core(world), url);
     2219}
     2220
     2221+ (void)_removeUserStyleSheetFromGroup:(NSString *)groupName world:(WebScriptWorld *)world url:(NSURL *)url
    22212222{
    22222223    String group(groupName);
     
    22282229        return;
    22292230
    2230     pageGroup->removeUserStyleSheetFromWorld(worldID, url);
    2231 }
    2232 
    2233 + (void)_removeUserScriptsFromGroup:(NSString *)groupName worldID:(unsigned)worldID
     2231    pageGroup->removeUserStyleSheetFromWorld(core(world), url);
     2232}
     2233
     2234+ (void)_removeUserScriptsFromGroup:(NSString *)groupName world:(WebScriptWorld *)world
    22342235{
    22352236    String group(groupName);
     
    22412242        return;
    22422243
    2243     pageGroup->removeUserScriptsFromWorld(worldID);
    2244 }
    2245 
    2246 + (void)_removeUserStyleSheetsFromGroup:(NSString *)groupName worldID:(unsigned)worldID
     2244    pageGroup->removeUserScriptsFromWorld(core(world));
     2245}
     2246
     2247+ (void)_removeUserStyleSheetsFromGroup:(NSString *)groupName world:(WebScriptWorld *)world
    22472248{
    22482249    String group(groupName);
     
    22542255        return;
    22552256
    2256     pageGroup->removeUserStyleSheetsFromWorld(worldID);
     2257    pageGroup->removeUserStyleSheetsFromWorld(core(world));
    22572258}
    22582259
  • trunk/WebKit/mac/WebView/WebViewPrivate.h

    r49733 r50907  
    4646@class WebInspector;
    4747@class WebPreferences;
     48@class WebScriptWorld;
    4849@class WebTextIterator;
    4950
     
    480481+ (void)_resetOriginAccessWhiteLists;
    481482
    482 + (void)_addUserScriptToGroup:(NSString *)groupName worldID:(unsigned)worldID source:(NSString *)source url:(NSURL *)url whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist injectionTime:(WebUserScriptInjectionTime)injectionTime;
    483 + (void)_addUserStyleSheetToGroup:(NSString *)groupName worldID:(unsigned)worldID source:(NSString *)source url:(NSURL *)url whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist;
    484 + (void)_removeUserScriptFromGroup:(NSString *)groupName worldID:(unsigned)worldID url:(NSURL *)url;
    485 + (void)_removeUserStyleSheetFromGroup:(NSString *)groupName worldID:(unsigned)worldID url:(NSURL *)url;
    486 + (void)_removeUserScriptsFromGroup:(NSString *)groupName worldID:(unsigned)worldID;
    487 + (void)_removeUserStyleSheetsFromGroup:(NSString *)groupName worldID:(unsigned)worldID;
     483+ (void)_addUserScriptToGroup:(NSString *)groupName world:(WebScriptWorld *)world source:(NSString *)source url:(NSURL *)url whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist injectionTime:(WebUserScriptInjectionTime)injectionTime;
     484+ (void)_addUserStyleSheetToGroup:(NSString *)groupName world:(WebScriptWorld *)world source:(NSString *)source url:(NSURL *)url whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist;
     485+ (void)_removeUserScriptFromGroup:(NSString *)groupName world:(WebScriptWorld *)world url:(NSURL *)url;
     486+ (void)_removeUserStyleSheetFromGroup:(NSString *)groupName world:(WebScriptWorld *)world url:(NSURL *)url;
     487+ (void)_removeUserScriptsFromGroup:(NSString *)groupName world:(WebScriptWorld *)world;
     488+ (void)_removeUserStyleSheetsFromGroup:(NSString *)groupName world:(WebScriptWorld *)world;
    488489+ (void)_removeAllUserContentFromGroup:(NSString *)groupName;
    489490
  • trunk/WebKit/win/ChangeLog

    r50906 r50907  
     12009-11-12  Adam Roben  <aroben@apple.com>
     2
     3        Replace worldIDs with world objects
     4
     5        WebScriptWorld is the new object that represents a world.  The only
     6        place worldID is still used is in
     7        IWebFramePrivate::stringByEvaluatingJavaScriptInIsolatedWorld, but
     8        that will change soon.
     9
     10        Part of <http://webkit.org/b/31414> Implement new SPI for dealing with
     11        user scripts/stylesheets and isolated worlds
     12
     13        Reviewed by Sam Weinig.
     14
     15        * ForEachCoClass.h: Added WebScriptWorld.
     16
     17        * Interfaces/IWebFramePrivate.idl: Replaced contextForWorldID with
     18        contextForWorld.
     19
     20        * Interfaces/IWebScriptWorld.idl: Added.
     21
     22        * Interfaces/IWebViewPrivate.idl: Changed the user script/stylesheet
     23        functions to take an IWebScriptWorld instead of a worldID.
     24
     25        * Interfaces/WebKit.idl: Added WebScriptWorld.
     26
     27        * WebFrame.cpp:
     28        (WebFrame::contextForWorld): Renamed from contextForWorldID. Now takes
     29        an IWebScriptWorld.
     30        (WebFrame::stringByEvaluatingJavaScriptInIsolatedWorld): Moved the
     31        bizarre world caching/creation logic that DRT depends on here from the
     32        findWorld function in ScriptController.cpp. Updated to use
     33        ScriptController::executeScriptInWorld instead of
     34        ScriptController::executeScriptInIsolatedWorld.
     35
     36        * WebFrame.h: Replaced contextForWorldID with contextForWorld.
     37
     38        * WebScriptWorld.cpp: Added.
     39        (WebScriptWorld::WebScriptWorld):
     40        (WebScriptWorld::~WebScriptWorld):
     41        (WebScriptWorld::createInstance):
     42        (WebScriptWorld::AddRef):
     43        (WebScriptWorld::Release):
     44        (WebScriptWorld::QueryInterface):
     45        Standard COM class implementations.
     46
     47        (WebScriptWorld::standardWorld): Returns a shared instance that represents
     48        WebCore's mainThreadNormalWorld().
     49
     50        * WebScriptWorld.h: Added.
     51        (WebScriptWorld::world): Simple getter.
     52
     53        * WebKit.vcproj/Interfaces.vcproj: Added IWebScriptWorld.idl.
     54
     55        * WebKit.vcproj/WebKit.vcproj: Added WebScriptWorld.
     56
     57        * WebKitClassFactory.cpp: Added WebScriptWorld.
     58
     59        * WebView.cpp:
     60        (WebView::addUserScriptToGroup):
     61        (WebView::addUserStyleSheetToGroup):
     62        (WebView::removeUserScriptFromGroup):
     63        (WebView::removeUserStyleSheetFromGroup):
     64        (WebView::removeUserScriptsFromGroup):
     65        (WebView::removeUserStyleSheetsFromGroup):
     66        * WebView.h:
     67        Changed these functions to take an IWebScriptWorld instead of a worldID.
     68
    1692009-11-12  Adam Roben  <aroben@apple.com>
    270
  • trunk/WebKit/win/ForEachCoClass.h

    r47429 r50907  
    6464    macro(WebCookieManager) \
    6565    macro(WebWorkersPrivate) \
     66    macro(WebScriptWorld) \
    6667    // end of macro
    6768
  • trunk/WebKit/win/Interfaces/IWebFramePrivate.idl

    r50316 r50907  
    3333interface IWebIconFetcher;
    3434interface IWebIconFetcherDelegate;
     35interface IWebScriptWorld;
    3536
    3637typedef enum {
     
    9798    HRESULT stringByEvaluatingJavaScriptInIsolatedWorld([in] unsigned worldID, [in] OLE_HANDLE jsGlobalObject, [in] BSTR script, [out, retval] BSTR* result);
    9899
    99     [local] JSGlobalContextRef contextForWorldID([in] unsigned worldID);
     100    [local] JSGlobalContextRef globalContextForScriptWorld([in] IWebScriptWorld*);
    100101
    101102    HRESULT counterValueForElementById([in] BSTR id, [out, retval] BSTR* result);
  • trunk/WebKit/win/Interfaces/IWebViewPrivate.idl

    r49732 r50907  
    185185    HRESULT MIMETypeForExtension([in] BSTR extension, [out, retval] BSTR* mimeType);
    186186
    187     // For the following functions, 0 < worldID < UINT_MAX.
    188     HRESULT addUserScriptToGroup([in] BSTR groupName, [in] unsigned worldID, [in] BSTR source, [in] BSTR url,
     187    HRESULT addUserScriptToGroup([in] BSTR groupName, [in] IWebScriptWorld*, [in] BSTR source, [in] BSTR url,
    189188                                 [in] unsigned whitelistCount, [in, size_is(whitelistCount)] BSTR* whitelist,
    190189                                 [in] unsigned blacklistCount, [in, size_is(blacklistCount)] BSTR* blacklist,
    191190                                 [in] WebUserScriptInjectionTime injectionTime);
    192     HRESULT addUserStyleSheetToGroup([in] BSTR groupName, [in] unsigned worldID, [in] BSTR source, [in] BSTR url,
     191    HRESULT addUserStyleSheetToGroup([in] BSTR groupName, [in] IWebScriptWorld*, [in] BSTR source, [in] BSTR url,
    193192                                     [in] unsigned whitelistCount, [in, size_is(whitelistCount)] BSTR* whitelist,
    194193                                     [in] unsigned blacklistCount, [in, size_is(blacklistCount)] BSTR* blacklist);
    195     HRESULT removeUserScriptFromGroup([in] BSTR groupName, [in] unsigned worldID, [in] BSTR url);
    196     HRESULT removeUserStyleSheetFromGroup([in] BSTR groupName, [in] unsigned worldID, [in] BSTR url);
    197     HRESULT removeUserScriptsFromGroup([in] BSTR groupName, [in] unsigned worldID);
    198     HRESULT removeUserStyleSheetsFromGroup([in] BSTR groupName, [in] unsigned worldID);
     194    HRESULT removeUserScriptFromGroup([in] BSTR groupName, [in] IWebScriptWorld*, [in] BSTR url);
     195    HRESULT removeUserStyleSheetFromGroup([in] BSTR groupName, [in] IWebScriptWorld*, [in] BSTR url);
     196    HRESULT removeUserScriptsFromGroup([in] BSTR groupName, [in] IWebScriptWorld*);
     197    HRESULT removeUserStyleSheetsFromGroup([in] BSTR groupName, [in] IWebScriptWorld*);
    199198    HRESULT removeAllUserContentFromGroup([in] BSTR groupName);
    200199
  • trunk/WebKit/win/Interfaces/WebKit.idl

    r50484 r50907  
    114114#include "IWebResourceLoadDelegate.idl"
    115115#include "IWebResourceLoadDelegatePrivate.idl"
     116#include "IWebScriptWorld.idl"
    116117#include "IWebScrollBarDelegatePrivate.idl"
    117118#include "IWebScrollBarPrivate.idl"
     
    272273        [default] interface IWebWorkersPrivate;
    273274    }
     275
     276    [uuid(D3C301EE-D59A-49c0-A43A-9EA01CDB1590)]
     277    coclass WebScriptWorld {
     278        [default] interface IWebScriptWorld;
     279    }
    274280}
  • trunk/WebKit/win/WebFrame.cpp

    r50567 r50907  
    3030
    3131#include "CFDictionaryPropertyBag.h"
     32#include "COMPropertyBag.h"
    3233#include "COMPtr.h"
    33 #include "COMPropertyBag.h"
     34#include "DOMCoreClasses.h"
    3435#include "DefaultPolicyDelegate.h"
    35 #include "DOMCoreClasses.h"
    3636#include "HTMLFrameOwnerElement.h"
    3737#include "MarshallingHelpers.h"
    3838#include "WebActionPropertyBag.h"
    3939#include "WebChromeClient.h"
     40#include "WebDataSource.h"
    4041#include "WebDocumentLoader.h"
    4142#include "WebDownload.h"
     43#include "WebEditorClient.h"
    4244#include "WebError.h"
    43 #include "WebMutableURLRequest.h"
    44 #include "WebEditorClient.h"
    4545#include "WebFramePolicyListener.h"
    4646#include "WebHistory.h"
     47#include "WebHistoryItem.h"
    4748#include "WebIconFetcher.h"
    4849#include "WebKit.h"
    4950#include "WebKitStatisticsPrivate.h"
     51#include "WebMutableURLRequest.h"
    5052#include "WebNotificationCenter.h"
     53#include "WebScriptWorld.h"
     54#include "WebURLResponse.h"
    5155#include "WebView.h"
    52 #include "WebDataSource.h"
    53 #include "WebHistoryItem.h"
    54 #include "WebURLResponse.h"
    5556#pragma warning( push, 0 )
    5657#include <WebCore/BString.h>
     
    491492}
    492493
    493 JSGlobalContextRef STDMETHODCALLTYPE WebFrame::contextForWorldID(
    494     /* [in] */ unsigned worldID)
     494JSGlobalContextRef WebFrame::globalContextForScriptWorld(IWebScriptWorld* iWorld)
    495495{
    496496    Frame* coreFrame = core(this);
     
    498498        return 0;
    499499
    500     return toGlobalRef(coreFrame->script()->globalObject(worldID)->globalExec());
     500    COMPtr<WebScriptWorld> world(Query, iWorld);
     501    if (!world)
     502        return 0;
     503
     504    return toGlobalRef(coreFrame->script()->globalObject(world->world())->globalExec());
    501505}
    502506
     
    21952199    Frame* frame = anyWorldGlobalObject->impl()->frame();
    21962200    ASSERT(frame->document());
    2197     JSValue result = frame->script()->executeScriptInIsolatedWorld(worldID, string, true).jsValue();
     2201
     2202    // Get the world to execute in based on the worldID. DRT expects that a
     2203    // worldID of 0 always corresponds to a newly-created world, while any
     2204    // other worldID corresponds to a world that is created once and then
     2205    // cached forever.
     2206    RefPtr<DOMWrapperWorld> world;
     2207    if (!worldID)
     2208        world = ScriptController::createWorld();
     2209    else {
     2210        static HashMap<unsigned, RefPtr<DOMWrapperWorld> >& worlds = *new HashMap<unsigned, RefPtr<DOMWrapperWorld> >;
     2211        RefPtr<DOMWrapperWorld>& worldSlot = worlds.add(worldID, 0).first->second;
     2212        if (!worldSlot)
     2213            worldSlot = ScriptController::createWorld();
     2214        world = worldSlot;
     2215    }
     2216    JSValue result = frame->script()->executeScriptInWorld(world.get(), string, true).jsValue();
    21982217
    21992218    if (!frame) // In case the script removed our frame from the page.
  • trunk/WebKit/win/WebFrame.h

    r50233 r50907  
    255255        /* [retval][out] */ BSTR* evaluationResult);
    256256
    257     virtual /* [local] */ JSGlobalContextRef STDMETHODCALLTYPE contextForWorldID(
    258         /* [in] */ unsigned worldID);
     257    virtual JSGlobalContextRef STDMETHODCALLTYPE globalContextForScriptWorld(IWebScriptWorld*);
    259258
    260259    // IWebDocumentText
  • trunk/WebKit/win/WebKit.vcproj/Interfaces.vcproj

    r49566 r50907  
    13251325                </File>
    13261326                <File
     1327                        RelativePath="..\Interfaces\IWebScriptWorld.idl"
     1328                        >
     1329                        <FileConfiguration
     1330                                Name="Debug|Win32"
     1331                                ExcludedFromBuild="true"
     1332                                >
     1333                                <Tool
     1334                                        Name="VCMIDLTool"
     1335                                />
     1336                        </FileConfiguration>
     1337                        <FileConfiguration
     1338                                Name="Release|Win32"
     1339                                ExcludedFromBuild="true"
     1340                                >
     1341                                <Tool
     1342                                        Name="VCMIDLTool"
     1343                                />
     1344                        </FileConfiguration>
     1345                </File>
     1346                <File
    13271347                        RelativePath="..\Interfaces\IWebScrollBarDelegatePrivate.idl"
    13281348                        >
  • trunk/WebKit/win/WebKit.vcproj/WebKit.vcproj

    r50322 r50907  
    723723                        </File>
    724724                        <File
     725                                RelativePath="..\WebScriptWorld.h"
     726                                >
     727                        </File>
     728                        <File
    725729                                RelativePath="..\WebKitStatistics.h"
    726730                                >
     
    10881092                        <File
    10891093                                RelativePath="..\WebKitLogging.cpp"
     1094                                >
     1095                        </File>
     1096                        <File
     1097                                RelativePath="..\WebScriptWorld.cpp"
    10901098                                >
    10911099                        </File>
  • trunk/WebKit/win/WebKitClassFactory.cpp

    r50567 r50907  
    2828#include "WebKitClassFactory.h"
    2929
     30#include "CFDictionaryPropertyBag.h"
    3031#include "ForEachCoClass.h"
    31 #include "CFDictionaryPropertyBag.h"
    3232#include "WebArchive.h"
    3333#include "WebCache.h"
     
    4343#include "WebJavaScriptCollector.h"
    4444#include "WebKit.h"
    45 #include "WebScrollBar.h"
    4645#include "WebKitStatistics.h"
    4746#include "WebMutableURLRequest.h"
    4847#include "WebNotificationCenter.h"
    4948#include "WebPreferences.h"
     49#include "WebScriptWorld.h"
     50#include "WebScrollBar.h"
    5051#include "WebTextRenderer.h"
    5152#include "WebURLCredential.h"
  • trunk/WebKit/win/WebView.cpp

    r50906 r50907  
    3232#include "MarshallingHelpers.h"
    3333#include "SoftLinking.h"
    34 #include "WebDatabaseManager.h"
    35 #include "WebDocumentLoader.h"
    36 #include "WebDownload.h"
    37 #include "WebEditorClient.h"
    38 #include "WebElementPropertyBag.h"
    39 #include "WebFrame.h"
    4034#include "WebBackForwardList.h"
    4135#include "WebChromeClient.h"
    4236#include "WebContextMenuClient.h"
    4337#include "WebCoreTextRenderer.h"
     38#include "WebDatabaseManager.h"
     39#include "WebDocumentLoader.h"
     40#include "WebDownload.h"
    4441#include "WebDragClient.h"
     42#include "WebEditorClient.h"
     43#include "WebElementPropertyBag.h"
     44#include "WebFrame.h"
    4545#include "WebIconDatabase.h"
    4646#include "WebInspector.h"
     
    5353#include "WebPluginHalterClient.h"
    5454#include "WebPreferences.h"
     55#include "WebScriptWorld.h"
    5556#include "WindowsTouch.h"
    5657#pragma warning( push, 0 )
     
    54915492}
    54925493
    5493 HRESULT WebView::addUserScriptToGroup(BSTR groupName, unsigned worldID, BSTR source, BSTR url,
     5494HRESULT WebView::addUserScriptToGroup(BSTR groupName, IWebScriptWorld* iWorld, BSTR source, BSTR url,
    54945495                                      unsigned whitelistCount, BSTR* whitelist,
    54955496                                      unsigned blacklistCount, BSTR* blacklist,
    54965497                                      WebUserScriptInjectionTime injectionTime)
    54975498{
     5499    COMPtr<WebScriptWorld> world(Query, iWorld);
     5500    if (!world)
     5501        return E_POINTER;
     5502
    54985503    String group = toString(groupName);
    5499     if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max())
     5504    if (group.isEmpty())
    55005505        return E_INVALIDARG;
    55015506
     
    55055510        return E_FAIL;
    55065511
    5507     pageGroup->addUserScriptToWorld(worldID, toString(source), toKURL(url),
     5512    pageGroup->addUserScriptToWorld(world->world(), toString(source), toKURL(url),
    55085513                                    toStringVector(whitelistCount, whitelist), toStringVector(blacklistCount, blacklist),
    55095514                                    injectionTime == WebInjectAtDocumentStart ? InjectAtDocumentStart : InjectAtDocumentEnd);
     
    55125517}
    55135518
    5514 HRESULT WebView::addUserStyleSheetToGroup(BSTR groupName, unsigned worldID, BSTR source, BSTR url,
     5519HRESULT WebView::addUserStyleSheetToGroup(BSTR groupName, IWebScriptWorld* iWorld, BSTR source, BSTR url,
    55155520                                          unsigned whitelistCount, BSTR* whitelist,
    55165521                                          unsigned blacklistCount, BSTR* blacklist)
    55175522{
     5523    COMPtr<WebScriptWorld> world(Query, iWorld);
     5524    if (!world)
     5525        return E_POINTER;
     5526
    55185527    String group = toString(groupName);
    5519     if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max())
     5528    if (group.isEmpty())
    55205529        return E_INVALIDARG;
    55215530
     
    55255534        return E_FAIL;
    55265535
    5527     pageGroup->addUserStyleSheetToWorld(worldID, toString(source), toKURL(url),
     5536    pageGroup->addUserStyleSheetToWorld(world->world(), toString(source), toKURL(url),
    55285537                                        toStringVector(whitelistCount, whitelist), toStringVector(blacklistCount, blacklist));
    55295538
     
    55315540}
    55325541
    5533 HRESULT WebView::removeUserScriptFromGroup(BSTR groupName, unsigned worldID, BSTR url)
    5534 {
     5542HRESULT WebView::removeUserScriptFromGroup(BSTR groupName, IWebScriptWorld* iWorld, BSTR url)
     5543{
     5544    COMPtr<WebScriptWorld> world(Query, iWorld);
     5545    if (!world)
     5546        return E_POINTER;
     5547
    55355548    String group = toString(groupName);
    5536     if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max())
     5549    if (group.isEmpty())
    55375550        return E_INVALIDARG;
    55385551
     
    55425555        return E_FAIL;
    55435556
    5544     pageGroup->removeUserScriptFromWorld(worldID, toKURL(url));
    5545 
    5546     return S_OK;
    5547 }
    5548 
    5549 HRESULT WebView::removeUserStyleSheetFromGroup(BSTR groupName, unsigned worldID, BSTR url)
    5550 {
     5557    pageGroup->removeUserScriptFromWorld(world->world(), toKURL(url));
     5558
     5559    return S_OK;
     5560}
     5561
     5562HRESULT WebView::removeUserStyleSheetFromGroup(BSTR groupName, IWebScriptWorld* iWorld, BSTR url)
     5563{
     5564    COMPtr<WebScriptWorld> world(Query, iWorld);
     5565    if (!world)
     5566        return E_POINTER;
     5567
    55515568    String group = toString(groupName);
    5552     if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max())
     5569    if (group.isEmpty())
    55535570        return E_INVALIDARG;
    55545571
     
    55585575        return E_FAIL;
    55595576
    5560     pageGroup->removeUserStyleSheetFromWorld(worldID, toKURL(url));
    5561 
    5562     return S_OK;
    5563 }
    5564 
    5565 HRESULT WebView::removeUserScriptsFromGroup(BSTR groupName, unsigned worldID)
    5566 {
     5577    pageGroup->removeUserStyleSheetFromWorld(world->world(), toKURL(url));
     5578
     5579    return S_OK;
     5580}
     5581
     5582HRESULT WebView::removeUserScriptsFromGroup(BSTR groupName, IWebScriptWorld* iWorld)
     5583{
     5584    COMPtr<WebScriptWorld> world(Query, iWorld);
     5585    if (!world)
     5586        return E_POINTER;
     5587
    55675588    String group = toString(groupName);
    5568     if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max())
     5589    if (group.isEmpty())
    55695590        return E_INVALIDARG;
    55705591
     
    55745595        return E_FAIL;
    55755596
    5576     pageGroup->removeUserScriptsFromWorld(worldID);
    5577     return S_OK;
    5578 }
    5579 
    5580 HRESULT WebView::removeUserStyleSheetsFromGroup(BSTR groupName, unsigned worldID)
    5581 {
     5597    pageGroup->removeUserScriptsFromWorld(world->world());
     5598    return S_OK;
     5599}
     5600
     5601HRESULT WebView::removeUserStyleSheetsFromGroup(BSTR groupName, IWebScriptWorld* iWorld)
     5602{
     5603    COMPtr<WebScriptWorld> world(Query, iWorld);
     5604    if (!world)
     5605        return E_POINTER;
     5606
    55825607    String group = toString(groupName);
    5583     if (group.isEmpty() || !worldID || worldID == numeric_limits<unsigned>::max())
     5608    if (group.isEmpty())
    55845609        return E_INVALIDARG;
    55855610
     
    55895614        return E_FAIL;
    55905615
    5591     pageGroup->removeUserStyleSheetsFromWorld(worldID);
     5616    pageGroup->removeUserStyleSheetsFromWorld(world->world());
    55925617    return S_OK;
    55935618}
  • trunk/WebKit/win/WebView.h

    r49732 r50907  
    741741        /* [in] */ BOOL canStartPlugins);
    742742
    743     virtual HRESULT STDMETHODCALLTYPE addUserScriptToGroup(BSTR groupName, unsigned worldID, BSTR source, BSTR url,
     743    virtual HRESULT STDMETHODCALLTYPE addUserScriptToGroup(BSTR groupName, IWebScriptWorld*, BSTR source, BSTR url,
    744744                                                           unsigned whitelistCount, BSTR* whitelist,
    745745                                                           unsigned blacklistCount, BSTR* blacklist,
    746746                                                           WebUserScriptInjectionTime);
    747     virtual HRESULT STDMETHODCALLTYPE addUserStyleSheetToGroup(BSTR groupName, unsigned worldID, BSTR source, BSTR url,
     747    virtual HRESULT STDMETHODCALLTYPE addUserStyleSheetToGroup(BSTR groupName, IWebScriptWorld*, BSTR source, BSTR url,
    748748                                                               unsigned whitelistCount, BSTR* whitelist,
    749749                                                               unsigned blacklistCount, BSTR* blacklist);
    750     virtual HRESULT STDMETHODCALLTYPE removeUserScriptFromGroup(BSTR groupName, unsigned worldID, BSTR url);
    751     virtual HRESULT STDMETHODCALLTYPE removeUserStyleSheetFromGroup(BSTR groupName, unsigned worldID, BSTR url);
    752     virtual HRESULT STDMETHODCALLTYPE removeUserScriptsFromGroup(BSTR groupName, unsigned worldID);
    753     virtual HRESULT STDMETHODCALLTYPE removeUserStyleSheetsFromGroup(BSTR groupName, unsigned worldID);
     750    virtual HRESULT STDMETHODCALLTYPE removeUserScriptFromGroup(BSTR groupName, IWebScriptWorld*, BSTR url);
     751    virtual HRESULT STDMETHODCALLTYPE removeUserStyleSheetFromGroup(BSTR groupName, IWebScriptWorld*, BSTR url);
     752    virtual HRESULT STDMETHODCALLTYPE removeUserScriptsFromGroup(BSTR groupName, IWebScriptWorld*);
     753    virtual HRESULT STDMETHODCALLTYPE removeUserStyleSheetsFromGroup(BSTR groupName, IWebScriptWorld*);
    754754    virtual HRESULT STDMETHODCALLTYPE removeAllUserContentFromGroup(BSTR groupName);
    755755
  • trunk/WebKitTools/ChangeLog

    r50865 r50907  
     12009-11-12  Adam Roben  <aroben@apple.com>
     2
     3        Replace worldIDs with world objects
     4
     5        Part of <http://webkit.org/b/31414> Implement new SPI for dealing with
     6        user scripts/stylesheets and isolated worlds
     7
     8        Reviewed by Sam Weinig.
     9
     10        * DumpRenderTree/mac/LayoutTestControllerMac.mm:
     11        (LayoutTestController::addUserScript):
     12        (LayoutTestController::addUserStyleSheet):
     13        * DumpRenderTree/win/LayoutTestControllerWin.cpp:
     14        (LayoutTestController::addUserScript):
     15        (LayoutTestController::addUserStyleSheet):
     16        Changed these functions to create a new WebJSWorld each time they're
     17        called and to pass that world to WebKit.
     18
    1192009-11-11  Chris Fleizach  <cfleizach@apple.com>
    220
  • trunk/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm

    r50233 r50907  
    4444#import <WebKit/WebBackForwardList.h>
    4545#import <WebKit/WebCoreStatistics.h>
     46#import <WebKit/WebDataSource.h>
    4647#import <WebKit/WebDatabaseManagerPrivate.h>
    47 #import <WebKit/WebDataSource.h>
    4848#import <WebKit/WebFrame.h>
    4949#import <WebKit/WebFrameViewPrivate.h>
    50 #import <WebKit/WebIconDatabasePrivate.h>
     50#import <WebKit/WebGeolocationMockPrivate.h>
    5151#import <WebKit/WebHTMLRepresentation.h>
    5252#import <WebKit/WebHTMLViewPrivate.h>
    5353#import <WebKit/WebHistory.h>
    5454#import <WebKit/WebHistoryPrivate.h>
     55#import <WebKit/WebIconDatabasePrivate.h>
    5556#import <WebKit/WebInspectorPrivate.h>
    56 #import <WebKit/WebGeolocationMockPrivate.h>
    5757#import <WebKit/WebNSURLExtras.h>
    5858#import <WebKit/WebPreferences.h>
    5959#import <WebKit/WebPreferencesPrivate.h>
     60#import <WebKit/WebScriptWorld.h>
    6061#import <WebKit/WebSecurityOriginPrivate.h>
    6162#import <WebKit/WebTypesInternal.h>
     
    502503    RetainPtr<CFStringRef> sourceCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, source));
    503504    NSString *sourceNS = (NSString *)sourceCF.get();
    504     [WebView _addUserScriptToGroup:@"org.webkit.DumpRenderTree" worldID:1 source:sourceNS url:nil whitelist:nil blacklist:nil injectionTime:(runAtStart ? WebInjectAtDocumentStart : WebInjectAtDocumentEnd)];
     505    [WebView _addUserScriptToGroup:@"org.webkit.DumpRenderTree" world:[WebScriptWorld world] source:sourceNS url:nil whitelist:nil blacklist:nil injectionTime:(runAtStart ? WebInjectAtDocumentStart : WebInjectAtDocumentEnd)];
    505506}
    506507
     
    509510    RetainPtr<CFStringRef> sourceCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, source));
    510511    NSString *sourceNS = (NSString *)sourceCF.get();
    511     [WebView _addUserStyleSheetToGroup:@"org.webkit.DumpRenderTree" worldID:1 source:sourceNS url:nil whitelist:nil blacklist:nil];
     512    [WebView _addUserStyleSheetToGroup:@"org.webkit.DumpRenderTree" world:[WebScriptWorld world] source:sourceNS url:nil whitelist:nil blacklist:nil];
    512513}
    513514
  • trunk/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp

    r50233 r50907  
    660660{
    661661    m_waitToDump = waitUntilDone;
    662     if (m_waitToDump && !waitToDumpWatchdog)
     662    if (false && m_waitToDump && !waitToDumpWatchdog)
    663663        waitToDumpWatchdog = SetTimer(0, 0, waitToDumpWatchdogInterval * 1000, waitUntilDoneWatchdogFired);
    664664}
     
    862862        return;
    863863
    864     webView->addUserScriptToGroup(_bstr_t(L"org.webkit.DumpRenderTree").GetBSTR(), 1, bstrT(source).GetBSTR(), 0, 0, 0, 0, 0, runAtStart ? WebInjectAtDocumentStart : WebInjectAtDocumentEnd);
     864    COMPtr<IWebScriptWorld> world;
     865    if (FAILED(WebKitCreateInstance(__uuidof(WebScriptWorld), 0, __uuidof(world), reinterpret_cast<void**>(&world))))
     866        return;
     867
     868    webView->addUserScriptToGroup(_bstr_t(L"org.webkit.DumpRenderTree").GetBSTR(), world.get(), bstrT(source).GetBSTR(), 0, 0, 0, 0, 0, runAtStart ? WebInjectAtDocumentStart : WebInjectAtDocumentEnd);
    865869}
    866870
     
    872876        return;
    873877
    874     webView->addUserStyleSheetToGroup(_bstr_t(L"org.webkit.DumpRenderTree").GetBSTR(), 1, bstrT(source).GetBSTR(), 0, 0, 0, 0, 0);
     878    COMPtr<IWebScriptWorld> world;
     879    if (FAILED(WebKitCreateInstance(__uuidof(WebScriptWorld), 0, __uuidof(world), reinterpret_cast<void**>(&world))))
     880        return;
     881
     882    webView->addUserStyleSheetToGroup(_bstr_t(L"org.webkit.DumpRenderTree").GetBSTR(), world.get(), bstrT(source).GetBSTR(), 0, 0, 0, 0, 0);
    875883}
    876884
Note: See TracChangeset for help on using the changeset viewer.