<https://webkit.org/b/119852> Frame::scriptController() should return a reference
authorpsolanki@apple.com <psolanki@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Aug 2013 17:55:32 +0000 (17:55 +0000)
committerpsolanki@apple.com <psolanki@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Aug 2013 17:55:32 +0000 (17:55 +0000)
Reviewed by Andreas Kling.

m_script is never NULL so we can just return a reference. Also remove some pointless null
checks as a result of doing this.

Source/WebCore:

* Modules/websockets/WebSocket.cpp:
(WebCore::WebSocket::connect):
* bindings/js/JSDOMWindowBase.cpp:
(WebCore::toJS):
(WebCore::toJSDOMWindow):
* bindings/js/JSDOMWindowShell.cpp:
(WebCore::toJS):
(WebCore::toJSDOMWindowShell):
* bindings/js/JSEventListener.cpp:
(WebCore::JSEventListener::handleEvent):
* bindings/js/JSLazyEventListener.cpp:
(WebCore::JSLazyEventListener::initializeJSFunction):
* bindings/js/PageScriptDebugServer.cpp:
(WebCore::PageScriptDebugServer::setJavaScriptPaused):
* bindings/js/ScheduledAction.cpp:
(WebCore::ScheduledAction::execute):
* bindings/js/ScriptCachedFrameData.cpp:
(WebCore::ScriptCachedFrameData::ScriptCachedFrameData):
(WebCore::ScriptCachedFrameData::restore):
* bindings/js/ScriptEventListener.cpp:
(WebCore::createAttributeEventListener):
(WebCore::eventListenerHandlerScriptState):
* bindings/js/ScriptState.cpp:
(WebCore::mainWorldScriptState):
(WebCore::scriptStateFromNode):
(WebCore::scriptStateFromPage):
* bindings/objc/DOM.mm:
(-[DOMNode JSC::Bindings::]):
* bindings/objc/DOMInternal.mm:
(-[WebScriptObject _initializeScriptDOMNodeImp]):
* dom/Document.cpp:
(WebCore::Document::disableEval):
(WebCore::Document::ensurePlugInsInjectedScript):
* dom/ScriptElement.cpp:
(WebCore::ScriptElement::prepareScript):
(WebCore::ScriptElement::executeScript):
* history/CachedFrame.cpp:
(WebCore::CachedFrameBase::restore):
* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::createRenderer):
* html/HTMLElement.cpp:
(WebCore::HTMLElement::rendererIsNeeded):
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::controls):
* html/HTMLPlugInElement.cpp:
(WebCore::HTMLPlugInElement::getInstance):
(WebCore::HTMLPlugInElement::getNPObject):
* html/HTMLPlugInImageElement.cpp:
(WebCore::HTMLPlugInImageElement::didAddUserAgentShadowRoot):
* html/parser/HTMLParserOptions.cpp:
(WebCore::HTMLParserOptions::HTMLParserOptions):
* inspector/InspectorAgent.cpp:
(WebCore::InspectorAgent::didClearWindowObjectInWorld):
* inspector/InspectorClient.cpp:
(WebCore::InspectorClient::doDispatchMessageOnFrontendPage):
* inspector/InspectorFrontendClientLocal.cpp:
(WebCore::InspectorFrontendClientLocal::evaluateAsBoolean):
(WebCore::InspectorFrontendClientLocal::evaluateOnLoad):
* inspector/InspectorOverlay.cpp:
(WebCore::InspectorOverlay::evaluateInOverlay):
* inspector/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::getScriptExecutionStatus):
(WebCore::InspectorPageAgent::didClearWindowObjectInWorld):
* inspector/PageRuntimeAgent.cpp:
(WebCore::PageRuntimeAgent::reportExecutionContextCreation):
* loader/DocumentWriter.cpp:
(WebCore::DocumentWriter::begin):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::urlSelected):
(WebCore::FrameLoader::submitForm):
(WebCore::FrameLoader::cancelAndClear):
(WebCore::FrameLoader::clear):
(WebCore::FrameLoader::prepareForCachedPageRestore):
(WebCore::FrameLoader::dispatchDidClearWindowObjectsInAllWorlds):
(WebCore::FrameLoader::dispatchDidClearWindowObjectInWorld):
* loader/SubframeLoader.cpp:
(WebCore::SubframeLoader::requestFrame):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::canRequest):
* page/EventSource.cpp:
(WebCore::EventSource::create):
* page/Frame.cpp:
(WebCore::Frame::willDetachPage):
* page/Frame.h:
(WebCore::Frame::script):
* page/Navigator.cpp:
(WebCore::shouldHideFourDot):
* page/Page.cpp:
(WebCore::Page::setDebugger):
* platform/graphics/wince/MediaPlayerProxy.cpp:
(WebCore::WebMediaPlayerProxy::pluginInstance):
(WebCore::WebMediaPlayerProxy::invokeMethod):
* plugins/PluginView.cpp:
(WebCore::PluginView::~PluginView):
(WebCore::PluginView::performRequest):
(WebCore::PluginView::load):
(WebCore::PluginView::bindingInstance):
(WebCore::PluginView::getValue):
* plugins/efl/PluginViewEfl.cpp:
(WebCore::PluginView::platformGetValue):
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::open):
* xml/XMLTreeViewer.cpp:
(WebCore::XMLTreeViewer::transformDocumentToTreeView):

Source/WebKit/blackberry:

* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::load):
(BlackBerry::WebKit::WebPagePrivate::executeJavaScript):
(BlackBerry::WebKit::WebPagePrivate::executeJavaScriptInIsolatedWorld):
(BlackBerry::WebKit::WebPage::executeJavaScriptFunction):
(BlackBerry::WebKit::WebPage::globalContext):
* WebCoreSupport/FrameLoaderClientBlackBerry.cpp:
(WebCore::FrameLoaderClientBlackBerry::dispatchDidClearWindowObjectInWorld):

Source/WebKit/efl:

* WebCoreSupport/DumpRenderTreeSupportEfl.cpp:
(DumpRenderTreeSupportEfl::evaluateScriptInIsolatedWorld):
(DumpRenderTreeSupportEfl::globalContextRefForFrame):
* WebCoreSupport/FrameLoaderClientEfl.cpp:
(WebCore::FrameLoaderClientEfl::dispatchDidClearWindowObjectInWorld):
* ewk/ewk_frame.cpp:
(ewk_frame_script_execute):
* ewk/ewk_view.cpp:
(ewk_view_js_object_add):

Source/WebKit/gtk:

* WebCoreSupport/FrameLoaderClientGtk.cpp:
(WebKit::FrameLoaderClient::dispatchDidClearWindowObjectInWorld):
* webkit/webkitwebframe.cpp:
(webkit_web_frame_get_global_context):
* webkit/webkitwebview.cpp:
(webkit_web_view_execute_script):

Source/WebKit/mac:

* Plugins/Hosted/NetscapePluginInstanceProxy.mm:
(WebKit::NetscapePluginInstanceProxy::cleanup):
(WebKit::NetscapePluginInstanceProxy::getWindowNPObject):
(WebKit::NetscapePluginInstanceProxy::getPluginElementNPObject):
(WebKit::NetscapePluginInstanceProxy::evaluate):
(WebKit::NetscapePluginInstanceProxy::invoke):
(WebKit::NetscapePluginInstanceProxy::invokeDefault):
(WebKit::NetscapePluginInstanceProxy::construct):
(WebKit::NetscapePluginInstanceProxy::getProperty):
(WebKit::NetscapePluginInstanceProxy::setProperty):
(WebKit::NetscapePluginInstanceProxy::removeProperty):
(WebKit::NetscapePluginInstanceProxy::hasProperty):
(WebKit::NetscapePluginInstanceProxy::hasMethod):
(WebKit::NetscapePluginInstanceProxy::enumerate):
(WebKit::NetscapePluginInstanceProxy::demarshalValueFromArray):
* Plugins/WebNetscapePluginView.mm:
(-[WebNetscapePluginView getVariable:value:]):
(-[WebNetscapePluginView _destroyPlugin]):
* Plugins/WebPluginController.mm:
* WebCoreSupport/WebFrameLoaderClient.mm:
* WebCoreSupport/WebInspectorClient.mm:
(WebInspectorFrontendClient::save):
(WebInspectorFrontendClient::append):
* WebView/WebFrame.mm:
(-[WebFrame _attachScriptDebugger]):
(-[WebFrame _stringByEvaluatingJavaScriptFromString:forceUserGesture:]):
(-[WebFrame _stringByEvaluatingJavaScriptFromString:withGlobalObject:inScriptWorld:]):
(-[WebFrame _globalContextForScriptWorld:]):
(-[WebFrame jsWrapperForNode:inScriptWorld:]):
(-[WebFrame windowObject]):
(-[WebFrame globalContext]):
(-[WebFrame javaScriptContext]):
* WebView/WebScriptDebugger.mm:
(WebScriptDebugger::initGlobalCallFrame):
(WebScriptDebugger::callEvent):
* WebView/WebView.mm:
(-[WebView windowScriptObject]):
(-[WebView aeDescByEvaluatingJavaScriptFromString:]):

Source/WebKit/qt:

* Api/qwebelement.cpp:
(setupScriptContext):
(QWebElement::evaluateJavaScript):
* WebCoreSupport/DumpRenderTreeSupportQt.cpp:
(DumpRenderTreeSupportQt::evaluateScriptInIsolatedWorld):
* WebCoreSupport/QWebFrameAdapter.cpp:
(QWebFrameAdapter::evaluateJavaScript):
(QWebFrameAdapter::addToJavaScriptWindowObject):

Source/WebKit/win:

* WebFrame.cpp:
(WebFrame::globalContext):
(WebFrame::globalContextForScriptWorld):
(WebFrame::dispatchDidClearWindowObjectInWorld):
(WebFrame::stringByEvaluatingJavaScriptInScriptWorld):
* WebView.cpp:
(WebView::stringByEvaluatingJavaScriptFromString):

Source/WebKit2:

* WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp:
(WebKit::NPRuntimeObjectMap::globalObject):
* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::performJavaScriptURLRequest):
(WebKit::PluginView::windowScriptNPObject):
(WebKit::PluginView::pluginElementNPObject):
* WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::jsContext):
(WebKit::WebFrame::jsContextForWorld):
(WebKit::WebFrame::jsWrapperForWorld):
* WebProcess/WebPage/WebInspector.cpp:
(WebKit::WebInspector::didSave):
(WebKit::WebInspector::didAppend):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::runJavaScriptInMainFrame):

Tools:

* DumpRenderTree/blackberry/DumpRenderTree.cpp:
(BlackBerry::WebKit::DumpRenderTree::resetToConsistentStateBeforeTesting):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@154192 268f45cc-cd09-0410-ab3c-d52691b4dbfc

78 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/websockets/WebSocket.cpp
Source/WebCore/bindings/js/JSDOMWindowBase.cpp
Source/WebCore/bindings/js/JSDOMWindowShell.cpp
Source/WebCore/bindings/js/JSEventListener.cpp
Source/WebCore/bindings/js/JSLazyEventListener.cpp
Source/WebCore/bindings/js/PageScriptDebugServer.cpp
Source/WebCore/bindings/js/ScheduledAction.cpp
Source/WebCore/bindings/js/ScriptCachedFrameData.cpp
Source/WebCore/bindings/js/ScriptEventListener.cpp
Source/WebCore/bindings/js/ScriptState.cpp
Source/WebCore/bindings/objc/DOM.mm
Source/WebCore/bindings/objc/DOMInternal.mm
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/ScriptElement.cpp
Source/WebCore/history/CachedFrame.cpp
Source/WebCore/html/HTMLCanvasElement.cpp
Source/WebCore/html/HTMLElement.cpp
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLPlugInElement.cpp
Source/WebCore/html/HTMLPlugInImageElement.cpp
Source/WebCore/html/parser/HTMLParserOptions.cpp
Source/WebCore/inspector/InspectorAgent.cpp
Source/WebCore/inspector/InspectorClient.cpp
Source/WebCore/inspector/InspectorFrontendClientLocal.cpp
Source/WebCore/inspector/InspectorOverlay.cpp
Source/WebCore/inspector/InspectorPageAgent.cpp
Source/WebCore/inspector/PageRuntimeAgent.cpp
Source/WebCore/loader/DocumentWriter.cpp
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/loader/SubframeLoader.cpp
Source/WebCore/loader/cache/CachedResourceLoader.cpp
Source/WebCore/page/EventSource.cpp
Source/WebCore/page/Frame.cpp
Source/WebCore/page/Frame.h
Source/WebCore/page/Navigator.cpp
Source/WebCore/page/Page.cpp
Source/WebCore/platform/graphics/wince/MediaPlayerProxy.cpp
Source/WebCore/plugins/PluginView.cpp
Source/WebCore/plugins/efl/PluginViewEfl.cpp
Source/WebCore/xml/XMLHttpRequest.cpp
Source/WebCore/xml/XMLTreeViewer.cpp
Source/WebKit/blackberry/Api/WebPage.cpp
Source/WebKit/blackberry/ChangeLog
Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp
Source/WebKit/efl/ChangeLog
Source/WebKit/efl/WebCoreSupport/DumpRenderTreeSupportEfl.cpp
Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.cpp
Source/WebKit/efl/ewk/ewk_frame.cpp
Source/WebKit/efl/ewk/ewk_view.cpp
Source/WebKit/gtk/ChangeLog
Source/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
Source/WebKit/gtk/webkit/webkitwebframe.cpp
Source/WebKit/gtk/webkit/webkitwebview.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm
Source/WebKit/mac/Plugins/WebNetscapePluginView.mm
Source/WebKit/mac/Plugins/WebPluginController.mm
Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
Source/WebKit/mac/WebCoreSupport/WebInspectorClient.mm
Source/WebKit/mac/WebView/WebFrame.mm
Source/WebKit/mac/WebView/WebScriptDebugger.mm
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit/qt/Api/qwebelement.cpp
Source/WebKit/qt/ChangeLog
Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp
Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.cpp
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebFrame.cpp
Source/WebKit/win/WebView.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp
Source/WebKit2/WebProcess/Plugins/PluginView.cpp
Source/WebKit2/WebProcess/WebPage/WebFrame.cpp
Source/WebKit2/WebProcess/WebPage/WebInspector.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Tools/ChangeLog
Tools/DumpRenderTree/blackberry/DumpRenderTree.cpp

index 019c7ea..355a4e8 100644 (file)
@@ -1,3 +1,117 @@
+2013-08-16  Pratik Solanki  <psolanki@apple.com>
+
+        <https://webkit.org/b/119852> Frame::scriptController() should return a reference
+
+        Reviewed by Andreas Kling.
+
+        m_script is never NULL so we can just return a reference. Also remove some pointless null
+        checks as a result of doing this.
+
+        * Modules/websockets/WebSocket.cpp:
+        (WebCore::WebSocket::connect):
+        * bindings/js/JSDOMWindowBase.cpp:
+        (WebCore::toJS):
+        (WebCore::toJSDOMWindow):
+        * bindings/js/JSDOMWindowShell.cpp:
+        (WebCore::toJS):
+        (WebCore::toJSDOMWindowShell):
+        * bindings/js/JSEventListener.cpp:
+        (WebCore::JSEventListener::handleEvent):
+        * bindings/js/JSLazyEventListener.cpp:
+        (WebCore::JSLazyEventListener::initializeJSFunction):
+        * bindings/js/PageScriptDebugServer.cpp:
+        (WebCore::PageScriptDebugServer::setJavaScriptPaused):
+        * bindings/js/ScheduledAction.cpp:
+        (WebCore::ScheduledAction::execute):
+        * bindings/js/ScriptCachedFrameData.cpp:
+        (WebCore::ScriptCachedFrameData::ScriptCachedFrameData):
+        (WebCore::ScriptCachedFrameData::restore):
+        * bindings/js/ScriptEventListener.cpp:
+        (WebCore::createAttributeEventListener):
+        (WebCore::eventListenerHandlerScriptState):
+        * bindings/js/ScriptState.cpp:
+        (WebCore::mainWorldScriptState):
+        (WebCore::scriptStateFromNode):
+        (WebCore::scriptStateFromPage):
+        * bindings/objc/DOM.mm:
+        (-[DOMNode JSC::Bindings::]):
+        * bindings/objc/DOMInternal.mm:
+        (-[WebScriptObject _initializeScriptDOMNodeImp]):
+        * dom/Document.cpp:
+        (WebCore::Document::disableEval):
+        (WebCore::Document::ensurePlugInsInjectedScript):
+        * dom/ScriptElement.cpp:
+        (WebCore::ScriptElement::prepareScript):
+        (WebCore::ScriptElement::executeScript):
+        * history/CachedFrame.cpp:
+        (WebCore::CachedFrameBase::restore):
+        * html/HTMLCanvasElement.cpp:
+        (WebCore::HTMLCanvasElement::createRenderer):
+        * html/HTMLElement.cpp:
+        (WebCore::HTMLElement::rendererIsNeeded):
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::controls):
+        * html/HTMLPlugInElement.cpp:
+        (WebCore::HTMLPlugInElement::getInstance):
+        (WebCore::HTMLPlugInElement::getNPObject):
+        * html/HTMLPlugInImageElement.cpp:
+        (WebCore::HTMLPlugInImageElement::didAddUserAgentShadowRoot):
+        * html/parser/HTMLParserOptions.cpp:
+        (WebCore::HTMLParserOptions::HTMLParserOptions):
+        * inspector/InspectorAgent.cpp:
+        (WebCore::InspectorAgent::didClearWindowObjectInWorld):
+        * inspector/InspectorClient.cpp:
+        (WebCore::InspectorClient::doDispatchMessageOnFrontendPage):
+        * inspector/InspectorFrontendClientLocal.cpp:
+        (WebCore::InspectorFrontendClientLocal::evaluateAsBoolean):
+        (WebCore::InspectorFrontendClientLocal::evaluateOnLoad):
+        * inspector/InspectorOverlay.cpp:
+        (WebCore::InspectorOverlay::evaluateInOverlay):
+        * inspector/InspectorPageAgent.cpp:
+        (WebCore::InspectorPageAgent::getScriptExecutionStatus):
+        (WebCore::InspectorPageAgent::didClearWindowObjectInWorld):
+        * inspector/PageRuntimeAgent.cpp:
+        (WebCore::PageRuntimeAgent::reportExecutionContextCreation):
+        * loader/DocumentWriter.cpp:
+        (WebCore::DocumentWriter::begin):
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::urlSelected):
+        (WebCore::FrameLoader::submitForm):
+        (WebCore::FrameLoader::cancelAndClear):
+        (WebCore::FrameLoader::clear):
+        (WebCore::FrameLoader::prepareForCachedPageRestore):
+        (WebCore::FrameLoader::dispatchDidClearWindowObjectsInAllWorlds):
+        (WebCore::FrameLoader::dispatchDidClearWindowObjectInWorld):
+        * loader/SubframeLoader.cpp:
+        (WebCore::SubframeLoader::requestFrame):
+        * loader/cache/CachedResourceLoader.cpp:
+        (WebCore::CachedResourceLoader::canRequest):
+        * page/EventSource.cpp:
+        (WebCore::EventSource::create):
+        * page/Frame.cpp:
+        (WebCore::Frame::willDetachPage):
+        * page/Frame.h:
+        (WebCore::Frame::script):
+        * page/Navigator.cpp:
+        (WebCore::shouldHideFourDot):
+        * page/Page.cpp:
+        (WebCore::Page::setDebugger):
+        * platform/graphics/wince/MediaPlayerProxy.cpp:
+        (WebCore::WebMediaPlayerProxy::pluginInstance):
+        (WebCore::WebMediaPlayerProxy::invokeMethod):
+        * plugins/PluginView.cpp:
+        (WebCore::PluginView::~PluginView):
+        (WebCore::PluginView::performRequest):
+        (WebCore::PluginView::load):
+        (WebCore::PluginView::bindingInstance):
+        (WebCore::PluginView::getValue):
+        * plugins/efl/PluginViewEfl.cpp:
+        (WebCore::PluginView::platformGetValue):
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::open):
+        * xml/XMLTreeViewer.cpp:
+        (WebCore::XMLTreeViewer::transformDocumentToTreeView):
+
 2013-08-16  Andreas Kling  <akling@apple.com>
 
         Attempt to fix the Qt/MountainLion build after r154142.
index 13a5ad8..ab863ea 100644 (file)
@@ -245,7 +245,7 @@ void WebSocket::connect(const String& url, const Vector<String>& protocols, Exce
     bool shouldBypassMainWorldContentSecurityPolicy = false;
     if (scriptExecutionContext()->isDocument()) {
         Document* document = toDocument(scriptExecutionContext());
-        shouldBypassMainWorldContentSecurityPolicy = document->frame()->script()->shouldBypassMainWorldContentSecurityPolicy();
+        shouldBypassMainWorldContentSecurityPolicy = document->frame()->script().shouldBypassMainWorldContentSecurityPolicy();
     }
     if (!shouldBypassMainWorldContentSecurityPolicy && !scriptExecutionContext()->contentSecurityPolicy()->allowConnectToSource(m_url)) {
         m_state = CLOSED;
index de273de..4ae94fa 100644 (file)
@@ -205,14 +205,14 @@ JSValue toJS(ExecState* exec, DOMWindow* domWindow)
     Frame* frame = domWindow->frame();
     if (!frame)
         return jsNull();
-    return frame->script()->windowShell(currentWorld(exec));
+    return frame->script().windowShell(currentWorld(exec));
 }
 
 JSDOMWindow* toJSDOMWindow(Frame* frame, DOMWrapperWorld* world)
 {
     if (!frame)
         return 0;
-    return frame->script()->windowShell(world)->window();
+    return frame->script().windowShell(world)->window();
 }
 
 JSDOMWindow* toJSDOMWindow(JSValue value)
index 35f5132..7f7da93 100644 (file)
@@ -105,14 +105,14 @@ JSValue toJS(ExecState* exec, Frame* frame)
 {
     if (!frame)
         return jsNull();
-    return frame->script()->windowShell(currentWorld(exec));
+    return frame->script().windowShell(currentWorld(exec));
 }
 
 JSDOMWindowShell* toJSDOMWindowShell(Frame* frame, DOMWrapperWorld* isolatedWorld)
 {
     if (!frame)
         return 0;
-    return frame->script()->windowShell(isolatedWorld);
+    return frame->script().windowShell(isolatedWorld);
 }
 
 } // namespace WebCore
index 6ba8727..80cf320 100644 (file)
@@ -94,8 +94,8 @@ void JSEventListener::handleEvent(ScriptExecutionContext* scriptExecutionContext
         if (!window->impl()->isCurrentlyDisplayedInFrame())
             return;
         // FIXME: Is this check needed for other contexts?
-        ScriptController* script = window->impl()->frame()->script();
-        if (!script->canExecuteScripts(AboutToExecuteScript) || script->isPaused())
+        ScriptController& script = window->impl()->frame()->script();
+        if (!script.canExecuteScripts(AboutToExecuteScript) || script.isPaused())
             return;
     }
 
index 8dd1885..77d97a9 100644 (file)
@@ -91,8 +91,8 @@ JSObject* JSLazyEventListener::initializeJSFunction(ScriptExecutionContext* exec
     if (!document->contentSecurityPolicy()->allowInlineEventHandlers(m_sourceURL, m_position.m_line))
         return 0;
 
-    ScriptController* script = document->frame()->script();
-    if (!script->canExecuteScripts(AboutToExecuteScript) || script->isPaused())
+    ScriptController& script = document->frame()->script();
+    if (!script.canExecuteScripts(AboutToExecuteScript) || script.isPaused())
         return 0;
 
     JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(executionContext, isolatedWorld());
index bbdde8b..bd954e4 100644 (file)
@@ -197,10 +197,10 @@ void PageScriptDebugServer::setJavaScriptPaused(Frame* frame, bool paused)
 {
     ASSERT_ARG(frame, frame);
 
-    if (!frame->script()->canExecuteScripts(NotAboutToExecuteScript))
+    if (!frame->script().canExecuteScripts(NotAboutToExecuteScript))
         return;
 
-    frame->script()->setPaused(paused);
+    frame->script().setPaused(paused);
 
     Document* document = frame->document();
     if (paused) {
index 4e38cd9..563f2d9 100644 (file)
@@ -125,13 +125,13 @@ void ScheduledAction::execute(Document* document)
         return;
 
     RefPtr<Frame> frame = window->impl()->frame();
-    if (!frame || !frame->script()->canExecuteScripts(AboutToExecuteScript))
+    if (!frame || !frame->script().canExecuteScripts(AboutToExecuteScript))
         return;
 
     if (m_function)
         executeFunctionInContext(window, window->shell(), document);
     else
-        frame->script()->executeScriptInWorld(m_isolatedWorld.get(), m_code);
+        frame->script().executeScriptInWorld(m_isolatedWorld.get(), m_code);
 }
 
 #if ENABLE(WORKERS)
index 07b1bba..5051ef5 100644 (file)
@@ -48,8 +48,8 @@ ScriptCachedFrameData::ScriptCachedFrameData(Frame* frame)
 {
     JSLockHolder lock(JSDOMWindowBase::commonVM());
 
-    ScriptController* scriptController = frame->script();
-    ScriptController::ShellMap& windowShells = scriptController->m_windowShells;
+    ScriptController& scriptController = frame->script();
+    ScriptController::ShellMap& windowShells = scriptController.m_windowShells;
 
     ScriptController::ShellMap::iterator windowShellsEnd = windowShells.end();
     for (ScriptController::ShellMap::iterator iter = windowShells.begin(); iter != windowShellsEnd; ++iter) {
@@ -57,7 +57,7 @@ ScriptCachedFrameData::ScriptCachedFrameData(Frame* frame)
         m_windows.add(iter->key.get(), Strong<JSDOMWindow>(window->vm(), window));
     }
 
-    scriptController->attachDebugger(0);
+    scriptController.attachDebugger(0);
 }
 
 ScriptCachedFrameData::~ScriptCachedFrameData()
@@ -69,8 +69,8 @@ void ScriptCachedFrameData::restore(Frame* frame)
 {
     JSLockHolder lock(JSDOMWindowBase::commonVM());
 
-    ScriptController* scriptController = frame->script();
-    ScriptController::ShellMap& windowShells = scriptController->m_windowShells;
+    ScriptController& scriptController = frame->script();
+    ScriptController::ShellMap& windowShells = scriptController.m_windowShells;
 
     ScriptController::ShellMap::iterator windowShellsEnd = windowShells.end();
     for (ScriptController::ShellMap::iterator iter = windowShells.begin(); iter != windowShellsEnd; ++iter) {
@@ -87,7 +87,7 @@ void ScriptCachedFrameData::restore(Frame* frame)
             windowShell->setWindow(domWindow);
 
             if (Page* page = frame->page()) {
-                scriptController->attachDebugger(windowShell, page->debugger());
+                scriptController.attachDebugger(windowShell, page->debugger());
                 windowShell->window()->setProfileGroup(page->group().identifier());
             }
         }
index c55814c..7e116d1 100644 (file)
@@ -64,11 +64,11 @@ PassRefPtr<JSLazyEventListener> createAttributeEventListener(Node* node, const Q
     
     // FIXME: We should be able to provide accurate source information for frameless documents, too (e.g. for importing nodes from XMLHttpRequest.responseXML).
     if (Frame* frame = node->document()->frame()) {
-        ScriptController* scriptController = frame->script();
-        if (!scriptController->canExecuteScripts(AboutToExecuteScript))
+        ScriptController& scriptController = frame->script();
+        if (!scriptController.canExecuteScripts(AboutToExecuteScript))
             return 0;
 
-        position = scriptController->eventHandlerPosition();
+        position = scriptController.eventHandlerPosition();
         sourceURL = node->document()->url().string();
     }
 
@@ -83,11 +83,11 @@ PassRefPtr<JSLazyEventListener> createAttributeEventListener(Frame* frame, const
     if (value.isNull())
         return 0;
 
-    ScriptController* scriptController = frame->script();
-    if (!scriptController->canExecuteScripts(AboutToExecuteScript))
+    ScriptController& scriptController = frame->script();
+    if (!scriptController.canExecuteScripts(AboutToExecuteScript))
         return 0;
 
-    TextPosition position = scriptController->eventHandlerPosition();
+    TextPosition position = scriptController.eventHandlerPosition();
     String sourceURL = frame->document()->url().string();
     JSObject* wrapper = toJSDOMWindow(frame, mainThreadNormalWorld());
     return JSLazyEventListener::create(name.localName().string(), eventParameterName(frame->document()->isSVGDocument()), value, 0, sourceURL, position, wrapper, mainThreadNormalWorld());
@@ -126,10 +126,10 @@ ScriptState* eventListenerHandlerScriptState(Frame* frame, EventListener* eventL
     ASSERT(jsListener);
     if (!jsListener)
         return 0;
-    if (!frame->script()->canExecuteScripts(NotAboutToExecuteScript))
+    if (!frame->script().canExecuteScripts(NotAboutToExecuteScript))
         return 0;
     DOMWrapperWorld* world = jsListener->isolatedWorld();
-    return frame->script()->globalObject(world)->globalExec();
+    return frame->script().globalObject(world)->globalExec();
 }
 
 bool eventListenerHandlerLocation(Document* document, EventListener* eventListener, String& sourceName, String& scriptId, int& lineNumber)
index 204c80e..e6a530c 100644 (file)
@@ -68,7 +68,7 @@ ScriptState* mainWorldScriptState(Frame* frame)
 {
     if (!frame)
         return 0;
-    JSDOMWindowShell* shell = frame->script()->windowShell(mainThreadNormalWorld());
+    JSDOMWindowShell* shell = frame->script().windowShell(mainThreadNormalWorld());
     return shell->window()->globalExec();
 }
 
@@ -82,14 +82,14 @@ ScriptState* scriptStateFromNode(DOMWrapperWorld* world, Node* node)
     Frame* frame = document->frame();
     if (!frame)
         return 0;
-    if (!frame->script()->canExecuteScripts(NotAboutToExecuteScript))
+    if (!frame->script().canExecuteScripts(NotAboutToExecuteScript))
         return 0;
-    return frame->script()->globalObject(world)->globalExec();
+    return frame->script().globalObject(world)->globalExec();
 }
 
 ScriptState* scriptStateFromPage(DOMWrapperWorld* world, Page* page)
 {
-    return page->mainFrame()->script()->globalObject(world)->globalExec();
+    return page->mainFrame()->script().globalObject(world)->globalExec();
 }
 
 #if ENABLE(WORKERS)
index 48217fc..e5a0ea8 100644 (file)
@@ -198,7 +198,7 @@ static NSArray *kit(const Vector<IntRect>& rects)
     WebCore::Frame* frame = core(self)->document()->frame();
     if (!frame)
         return 0;
-    return frame->script()->bindingRootObject();
+    return frame->script().bindingRootObject();
 }
 
 @end
index f55674d..df92a14 100644 (file)
@@ -119,13 +119,13 @@ void removeDOMWrapper(DOMObjectInternal* impl)
         return;
 
     // The global object which should own this node - FIXME: does this need to be isolated-world aware?
-    WebCore::JSDOMGlobalObject* globalObject = frame->script()->globalObject(WebCore::mainThreadNormalWorld());
+    WebCore::JSDOMGlobalObject* globalObject = frame->script().globalObject(WebCore::mainThreadNormalWorld());
     JSC::ExecState *exec = globalObject->globalExec();
 
     // Get (or create) a cached JS object for the DOM node.
     JSC::JSObject *scriptImp = asObject(WebCore::toJS(exec, globalObject, nodeImpl));
 
-    JSC::Bindings::RootObject* rootObject = frame->script()->bindingRootObject();
+    JSC::Bindings::RootObject* rootObject = frame->script().bindingRootObject();
 
     [self _setImp:scriptImp originRootObject:rootObject rootObject:rootObject];
 }
index 522007c..b14a7d6 100644 (file)
@@ -2683,7 +2683,7 @@ void Document::disableEval(const String& errorMessage)
     if (!frame())
         return;
 
-    frame()->script()->disableEval(errorMessage);
+    frame()->script().disableEval(errorMessage);
 }
 
 bool Document::canNavigate(Frame* targetFrame)
@@ -5983,7 +5983,7 @@ void Document::ensurePlugInsInjectedScript(DOMWrapperWorld* world)
     if (!jsString)
         jsString = plugInsJavaScript;
 
-    page()->mainFrame()->script()->evaluateInWorld(ScriptSourceCode(jsString), world);
+    page()->mainFrame()->script().evaluateInWorld(ScriptSourceCode(jsString), world);
 
     m_hasInjectedPlugInsScript = true;
 }
index 143ba5c..c192a2b 100644 (file)
@@ -209,7 +209,7 @@ bool ScriptElement::prepareScript(const TextPosition& scriptStartPosition, Legac
     if (!document->frame())
         return false;
 
-    if (!document->frame()->script()->canExecuteScripts(AboutToExecuteScript))
+    if (!document->frame()->script().canExecuteScripts(AboutToExecuteScript))
         return false;
 
     if (!isScriptForEventSupported())
@@ -313,7 +313,7 @@ void ScriptElement::executeScript(const ScriptSourceCode& sourceCode)
             // Create a script from the script element node, using the script
             // block's source and the script block's type.
             // Note: This is where the script is compiled and actually executed.
-            frame->script()->evaluate(sourceCode);
+            frame->script().evaluate(sourceCode);
         }
     }
 }
index fab3de3..75c2d9a 100644 (file)
@@ -116,7 +116,7 @@ void CachedFrameBase::restore()
 
     // It is necessary to update any platform script objects after restoring the
     // cached page.
-    frame.script()->updatePlatformScriptObjects();
+    frame.script().updatePlatformScriptObjects();
 
 #if USE(ACCELERATED_COMPOSITING)
     if (m_isComposited)
index 795a3ba..32267eb 100644 (file)
@@ -111,7 +111,7 @@ void HTMLCanvasElement::parseAttribute(const QualifiedName& name, const AtomicSt
 RenderObject* HTMLCanvasElement::createRenderer(RenderArena* arena, RenderStyle* style)
 {
     Frame* frame = document()->frame();
-    if (frame && frame->script()->canExecuteScripts(NotAboutToExecuteScript)) {
+    if (frame && frame->script().canExecuteScripts(NotAboutToExecuteScript)) {
         m_rendererIsCanvas = true;
         return new (arena) RenderHTMLCanvas(this);
     }
index 87363f6..94adc17 100644 (file)
@@ -753,7 +753,7 @@ bool HTMLElement::rendererIsNeeded(const NodeRenderingContext& context)
 {
     if (hasLocalName(noscriptTag)) {
         Frame* frame = document()->frame();
-        if (frame && frame->script()->canExecuteScripts(NotAboutToExecuteScript))
+        if (frame && frame->script().canExecuteScripts(NotAboutToExecuteScript))
             return false;
     } else if (hasLocalName(noembedTag)) {
         Frame* frame = document()->frame();
index b429f5d..890d14b 100644 (file)
@@ -2682,7 +2682,7 @@ bool HTMLMediaElement::controls() const
     Frame* frame = document()->frame();
 
     // always show controls when scripting is disabled
-    if (frame && !frame->script()->canExecuteScripts(NotAboutToExecuteScript))
+    if (frame && !frame->script().canExecuteScripts(NotAboutToExecuteScript))
         return true;
 
     // always show controls for video when fullscreen playback is required.
index dff2d39..b740125 100644 (file)
@@ -130,7 +130,7 @@ PassRefPtr<JSC::Bindings::Instance> HTMLPlugInElement::getInstance()
         return m_instance;
 
     if (Widget* widget = pluginWidget())
-        m_instance = frame->script()->createScriptInstanceForWidget(widget);
+        m_instance = frame->script().createScriptInstanceForWidget(widget);
 
     return m_instance;
 }
@@ -260,7 +260,7 @@ NPObject* HTMLPlugInElement::getNPObject()
 {
     ASSERT(document()->frame());
     if (!m_NPObject)
-        m_NPObject = document()->frame()->script()->createScriptObjectForPluginElement(this);
+        m_NPObject = document()->frame()->script().createScriptObjectForPluginElement(this);
     return m_NPObject;
 }
 
index dccb9f0..2a3d879 100644 (file)
@@ -374,8 +374,8 @@ void HTMLPlugInImageElement::didAddUserAgentShadowRoot(ShadowRoot* root)
     static DOMWrapperWorld* isolatedWorld = DOMWrapperWorld::create(JSDOMWindow::commonVM()).leakRef();
     document()->ensurePlugInsInjectedScript(isolatedWorld);
 
-    ScriptController* scriptController = page->mainFrame()->script();
-    JSDOMGlobalObject* globalObject = JSC::jsCast<JSDOMGlobalObject*>(scriptController->globalObject(isolatedWorld));
+    ScriptController& scriptController = page->mainFrame()->script();
+    JSDOMGlobalObject* globalObject = JSC::jsCast<JSDOMGlobalObject*>(scriptController.globalObject(isolatedWorld));
     JSC::ExecState* exec = globalObject->globalExec();
 
     JSC::JSLockHolder lock(exec);
index bd6814b..81b5c35 100644 (file)
@@ -37,7 +37,7 @@ namespace WebCore {
 HTMLParserOptions::HTMLParserOptions(Document* document)
 {
     Frame* frame = document ? document->frame() : 0;
-    scriptEnabled = frame && frame->script()->canExecuteScripts(NotAboutToExecuteScript);
+    scriptEnabled = frame && frame->script().canExecuteScripts(NotAboutToExecuteScript);
     pluginsEnabled = frame && frame->loader().subframeLoader()->allowPlugins(NotAboutToInstantiatePlugin);
 
     Settings* settings = document ? document->settings() : 0;
index 245a9da..172dc91 100644 (file)
@@ -95,7 +95,7 @@ void InspectorAgent::didClearWindowObjectInWorld(Frame* frame, DOMWrapperWorld*
     scriptSource.append("(");
     scriptSource.appendNumber(injectedScriptId);
     scriptSource.append(")");
-    frame->script()->executeScript(scriptSource.toString());
+    frame->script().executeScript(scriptSource.toString());
 }
 
 void InspectorAgent::setFrontend(InspectorFrontend* inspectorFrontend)
index cd625b3..405c0c0 100644 (file)
@@ -51,14 +51,10 @@ bool InspectorClient::doDispatchMessageOnFrontendPage(Page* frontendPage, const
     if (!frame)
         return false;
 
-    ScriptController* scriptController = frame->script();
-    if (!scriptController)
-        return false;
-
     String dispatchToFrontend = "InspectorFrontendAPI.dispatchMessageAsync(" + message + ");";
 
     // FIXME: This should execute the script in the appropriate world.
-    scriptController->evaluate(ScriptSourceCode(dispatchToFrontend));
+    frame->script().evaluate(ScriptSourceCode(dispatchToFrontend));
     return true;
 }
 
index 432c11a..c821bbe 100644 (file)
@@ -346,14 +346,14 @@ bool InspectorFrontendClientLocal::evaluateAsBoolean(const String& expression)
 {
     if (!m_frontendPage->mainFrame())
         return false;
-    ScriptValue value = m_frontendPage->mainFrame()->script()->executeScript(expression);
+    ScriptValue value = m_frontendPage->mainFrame()->script().executeScript(expression);
     return value.toString(mainWorldScriptState(m_frontendPage->mainFrame())) == "true";
 }
 
 void InspectorFrontendClientLocal::evaluateOnLoad(const String& expression)
 {
     if (m_frontendLoaded)
-        m_frontendPage->mainFrame()->script()->executeScript("InspectorFrontendAPI.dispatch(" + expression + ")");
+        m_frontendPage->mainFrame()->script().executeScript("InspectorFrontendAPI.dispatch(" + expression + ")");
     else
         m_evaluateOnLoad.append(expression);
 }
index 2e2d98f..c3541f8 100644 (file)
@@ -488,7 +488,7 @@ void InspectorOverlay::evaluateInOverlay(const String& method, const String& arg
     RefPtr<InspectorArray> command = InspectorArray::create();
     command->pushString(method);
     command->pushString(argument);
-    overlayPage()->mainFrame()->script()->evaluate(ScriptSourceCode(makeString("dispatch(", command->toJSONString(), ")")));
+    overlayPage()->mainFrame()->script().evaluate(ScriptSourceCode(makeString("dispatch(", command->toJSONString(), ")")));
 }
 
 void InspectorOverlay::evaluateInOverlay(const String& method, PassRefPtr<InspectorValue> argument)
@@ -496,7 +496,7 @@ void InspectorOverlay::evaluateInOverlay(const String& method, PassRefPtr<Inspec
     RefPtr<InspectorArray> command = InspectorArray::create();
     command->pushString(method);
     command->pushValue(argument);
-    overlayPage()->mainFrame()->script()->evaluate(ScriptSourceCode(makeString("dispatch(", command->toJSONString(), ")")));
+    overlayPage()->mainFrame()->script().evaluate(ScriptSourceCode(makeString("dispatch(", command->toJSONString(), ")")));
 }
 
 void InspectorOverlay::freePage()
index c43028b..67bed5c 100644 (file)
@@ -839,7 +839,7 @@ void InspectorPageAgent::getScriptExecutionStatus(ErrorString*, PageCommandHandl
     bool disabledInSettings = false;
     Frame* frame = mainFrame();
     if (frame) {
-        disabledByScriptController = !frame->script()->canExecuteScripts(NotAboutToExecuteScript);
+        disabledByScriptController = !frame->script().canExecuteScripts(NotAboutToExecuteScript);
         if (frame->settings())
             disabledInSettings = !frame->settings()->isScriptEnabled();
     }
@@ -886,11 +886,11 @@ void InspectorPageAgent::didClearWindowObjectInWorld(Frame* frame, DOMWrapperWor
         for (InspectorObject::const_iterator it = scripts->begin(); it != end; ++it) {
             String scriptText;
             if (it->value->asString(&scriptText))
-                frame->script()->executeScript(scriptText);
+                frame->script().executeScript(scriptText);
         }
     }
     if (!m_scriptToEvaluateOnLoadOnce.isEmpty())
-        frame->script()->executeScript(m_scriptToEvaluateOnLoadOnce);
+        frame->script().executeScript(m_scriptToEvaluateOnLoadOnce);
 }
 
 void InspectorPageAgent::domContentEventFired()
index ac5f8b5..35a3539 100644 (file)
@@ -161,13 +161,13 @@ void PageRuntimeAgent::reportExecutionContextCreation()
 {
     Vector<std::pair<ScriptState*, SecurityOrigin*> > isolatedContexts;
     for (Frame* frame = m_inspectedPage->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
-        if (!frame->script()->canExecuteScripts(NotAboutToExecuteScript))
+        if (!frame->script().canExecuteScripts(NotAboutToExecuteScript))
             continue;
         String frameId = m_pageAgent->frameId(frame);
 
         ScriptState* scriptState = mainWorldScriptState(frame);
         notifyContextCreated(frameId, scriptState, 0, true);
-        frame->script()->collectIsolatedContexts(isolatedContexts);
+        frame->script().collectIsolatedContexts(isolatedContexts);
         if (isolatedContexts.isEmpty())
             continue;
         for (size_t i = 0; i< isolatedContexts.size(); i++)
index 3b97dfb..9974292 100644 (file)
@@ -139,7 +139,7 @@ void DocumentWriter::begin(const KURL& urlReference, bool dispatch, Document* ow
     clear();
 
     if (!shouldReuseDefaultView)
-        m_frame->script()->updatePlatformScriptObjects();
+        m_frame->script().updatePlatformScriptObjects();
 
     m_frame->loader().setOutgoingReferrer(url);
     m_frame->setDocument(document);
index 3844262..197a309 100644 (file)
@@ -306,7 +306,7 @@ void FrameLoader::urlSelected(const FrameLoadRequest& passedRequest, PassRefPtr<
     RefPtr<Frame> protect(m_frame);
     FrameLoadRequest frameRequest(passedRequest);
 
-    if (m_frame->script()->executeIfJavaScriptURL(frameRequest.resourceRequest().url(), shouldReplaceDocumentIfJavaScriptURL))
+    if (m_frame->script().executeIfJavaScriptURL(frameRequest.resourceRequest().url(), shouldReplaceDocumentIfJavaScriptURL))
         return;
 
     if (frameRequest.frameName().isEmpty())
@@ -346,7 +346,7 @@ void FrameLoader::submitForm(PassRefPtr<FormSubmission> submission)
         if (!m_frame->document()->contentSecurityPolicy()->allowFormAction(KURL(submission->action())))
             return;
         m_isExecutingJavaScriptFormAction = true;
-        m_frame->script()->executeIfJavaScriptURL(submission->action(), DoNotReplaceDocumentIfJavaScriptURL);
+        m_frame->script().executeIfJavaScriptURL(submission->action(), DoNotReplaceDocumentIfJavaScriptURL);
         m_isExecutingJavaScriptFormAction = false;
         return;
     }
@@ -563,7 +563,7 @@ void FrameLoader::cancelAndClear()
         closeURL();
 
     clear(m_frame->document(), false);
-    m_frame->script()->updatePlatformScriptObjects();
+    m_frame->script().updatePlatformScriptObjects();
 }
 
 void FrameLoader::clear(Document* newDocument, bool clearWindowProperties, bool clearScriptObjects, bool clearFrameView)
@@ -587,7 +587,7 @@ void FrameLoader::clear(Document* newDocument, bool clearWindowProperties, bool
     if (clearWindowProperties) {
         InspectorInstrumentation::frameWindowDiscarded(m_frame, m_frame->document()->domWindow());
         m_frame->document()->domWindow()->resetUnlessSuspendedForPageCache();
-        m_frame->script()->clearWindowShell(newDocument->domWindow(), m_frame->document()->inPageCache());
+        m_frame->script().clearWindowShell(newDocument->domWindow(), m_frame->document()->inPageCache());
     }
 
     m_frame->selection()->prepareForDestruction();
@@ -602,9 +602,9 @@ void FrameLoader::clear(Document* newDocument, bool clearWindowProperties, bool
     m_subframeLoader.clear();
 
     if (clearScriptObjects)
-        m_frame->script()->clearScriptObjects();
+        m_frame->script().clearScriptObjects();
 
-    m_frame->script()->enableEval();
+    m_frame->script().enableEval();
 
     m_frame->navigationScheduler()->clear();
 
@@ -1970,7 +1970,7 @@ void FrameLoader::prepareForCachedPageRestore()
     closeURL();
     
     // Delete old status bar messages (if it _was_ activated on last URL).
-    if (m_frame->script()->canExecuteScripts(NotAboutToExecuteScript)) {
+    if (m_frame->script().canExecuteScripts(NotAboutToExecuteScript)) {
         DOMWindow* window = m_frame->document()->domWindow();
         window->setStatus(String());
         window->setDefaultStatus(String());
@@ -3264,7 +3264,7 @@ void FrameLoader::dispatchDocumentElementAvailable()
 
 void FrameLoader::dispatchDidClearWindowObjectsInAllWorlds()
 {
-    if (!m_frame->script()->canExecuteScripts(NotAboutToExecuteScript))
+    if (!m_frame->script().canExecuteScripts(NotAboutToExecuteScript))
         return;
 
     Vector<RefPtr<DOMWrapperWorld> > worlds;
@@ -3275,7 +3275,7 @@ void FrameLoader::dispatchDidClearWindowObjectsInAllWorlds()
 
 void FrameLoader::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world)
 {
-    if (!m_frame->script()->canExecuteScripts(NotAboutToExecuteScript) || !m_frame->script()->existingWindowShell(world))
+    if (!m_frame->script().canExecuteScripts(NotAboutToExecuteScript) || !m_frame->script().existingWindowShell(world))
         return;
 
     m_client->dispatchDidClearWindowObjectInWorld(world);
index 4f42a1c..144d13f 100644 (file)
@@ -91,7 +91,7 @@ bool SubframeLoader::requestFrame(HTMLFrameOwnerElement* ownerElement, const Str
         return false;
 
     if (!scriptURL.isEmpty())
-        frame->script()->executeIfJavaScriptURL(scriptURL);
+        frame->script().executeIfJavaScriptURL(scriptURL);
 
     return true;
 }
index 451d99b..60f9696 100644 (file)
@@ -313,7 +313,7 @@ bool CachedResourceLoader::canRequest(CachedResource::Type type, const KURL& url
     }
 
     // FIXME: Convert this to check the isolated world's Content Security Policy once webkit.org/b/104520 is solved.
-    bool shouldBypassMainWorldContentSecurityPolicy = (frame() && frame()->script()->shouldBypassMainWorldContentSecurityPolicy());
+    bool shouldBypassMainWorldContentSecurityPolicy = (frame() && frame()->script().shouldBypassMainWorldContentSecurityPolicy());
 
     // Some types of resources can be loaded only from the same origin.  Other
     // types of resources, like Images, Scripts, and CSS, can be loaded from
index d743775..6da3e96 100644 (file)
@@ -90,7 +90,7 @@ PassRefPtr<EventSource> EventSource::create(ScriptExecutionContext* context, con
     bool shouldBypassMainWorldContentSecurityPolicy = false;
     if (context->isDocument()) {
         Document* document = toDocument(context);
-        shouldBypassMainWorldContentSecurityPolicy = document->frame()->script()->shouldBypassMainWorldContentSecurityPolicy();
+        shouldBypassMainWorldContentSecurityPolicy = document->frame()->script().shouldBypassMainWorldContentSecurityPolicy();
     }
     if (!shouldBypassMainWorldContentSecurityPolicy && !context->contentSecurityPolicy()->allowConnectToSource(fullURL)) {
         // FIXME: Should this be throwing an exception?
index f9de753..d3c827b 100644 (file)
@@ -675,8 +675,8 @@ void Frame::willDetachPage()
     if (page() && page()->scrollingCoordinator() && m_view)
         page()->scrollingCoordinator()->willDestroyScrollableArea(m_view.get());
 
-    script()->clearScriptObjects();
-    script()->updatePlatformScriptObjects();
+    script().clearScriptObjects();
+    script().updatePlatformScriptObjects();
 }
 
 void Frame::disconnectOwnerElement()
index 3a59817..67ed375 100644 (file)
@@ -121,7 +121,7 @@ namespace WebCore {
         FrameSelection* selection() const;
         FrameTree* tree() const;
         AnimationController* animation() const;
-        ScriptController* script();
+        ScriptController& script();
         
         RenderView* contentRenderer() const; // Root of the render tree for the document contained in this frame.
         RenderPart* ownerRenderer() const; // Renderer for the element that contains this frame.
@@ -275,9 +275,9 @@ namespace WebCore {
         return m_view.get();
     }
 
-    inline ScriptController* Frame::script()
+    inline ScriptController& Frame::script()
     {
-        return m_script.get();
+        return *m_script;
     }
 
     inline Document* Frame::document() const
index 11f1f71..d00f007 100644 (file)
@@ -58,7 +58,7 @@ Navigator::~Navigator()
 // sites such as nwa.com -- the library thinks Safari is Netscape 4 if we don't do this!
 static bool shouldHideFourDot(Frame* frame)
 {
-    const String* sourceURL = frame->script()->sourceURL();
+    const String* sourceURL = frame->script().sourceURL();
     if (!sourceURL)
         return false;
     if (!(sourceURL->endsWith("/dqm_script.js") || sourceURL->endsWith("/dqm_loader.js") || sourceURL->endsWith("/tdqm_loader.js")))
index 87010ea..56be223 100644 (file)
@@ -1109,7 +1109,7 @@ void Page::setDebugger(JSC::Debugger* debugger)
     m_debugger = debugger;
 
     for (Frame* frame = m_mainFrame.get(); frame; frame = frame->tree()->traverseNext())
-        frame->script()->attachDebugger(m_debugger);
+        frame->script().attachDebugger(m_debugger);
 }
 
 StorageNamespace* Page::sessionStorage(bool optionalCreate)
index d02e2b5..be6b89b 100644 (file)
@@ -73,7 +73,7 @@ ScriptInstance WebMediaPlayerProxy::pluginInstance()
 
         RenderWidget* renderWidget = static_cast<RenderWidget*>(element()->renderer());
         if (renderWidget && renderWidget->widget())
-            m_instance = frame->script()->createScriptInstanceForWidget(renderWidget->widget());
+            m_instance = frame->script().createScriptInstanceForWidget(renderWidget->widget());
     }
 
     return m_instance;
@@ -123,7 +123,7 @@ HTMLMediaElement* WebMediaPlayerProxy::element()
 void WebMediaPlayerProxy::invokeMethod(const String& methodName)
 {
     Frame* frame = element()->document()->frame();
-    RootObject *root = frame->script()->bindingRootObject();
+    RootObject* root = frame->script().bindingRootObject();
     if (!root)
         return;
     ExecState *exec = root->globalObject()->globalExec();
index 01401d2..9a73b7f 100644 (file)
@@ -308,7 +308,7 @@ PluginView::~PluginView()
 
     platformDestroy();
 
-    m_parentFrame->script()->cleanupScriptObjectsForPlugin(this);
+    m_parentFrame->script().cleanupScriptObjectsForPlugin(this);
 
     if (m_plugin && !(m_plugin->quirks().contains(PluginQuirkDontUnloadPlugin)))
         m_plugin->unload();
@@ -464,12 +464,12 @@ void PluginView::performRequest(PluginRequest* request)
     
     // Executing a script can cause the plugin view to be destroyed, so we keep a reference to it.
     RefPtr<PluginView> protector(this);
-    ScriptValue result = m_parentFrame->script()->executeScript(jsString, request->shouldAllowPopups());
+    ScriptValue result = m_parentFrame->script().executeScript(jsString, request->shouldAllowPopups());
 
     if (targetFrameName.isNull()) {
         String resultString;
 
-        ScriptState* scriptState = m_parentFrame->script()->globalObject(pluginWorld())->globalExec();
+        ScriptState* scriptState = m_parentFrame->script().globalObject(pluginWorld())->globalExec();
         CString cstr;
         if (result.getString(scriptState, resultString))
             cstr = resultString.utf8();
@@ -524,7 +524,7 @@ NPError PluginView::load(const FrameLoadRequest& frameLoadRequest, bool sendNoti
 
     if (!jsString.isNull()) {
         // Return NPERR_GENERIC_ERROR if JS is disabled. This is what Mozilla does.
-        if (!m_parentFrame->script()->canExecuteScripts(NotAboutToExecuteScript))
+        if (!m_parentFrame->script().canExecuteScripts(NotAboutToExecuteScript))
             return NPERR_GENERIC_ERROR;
 
         // For security reasons, only allow JS requests to be made on the frame that contains the plug-in.
@@ -749,7 +749,7 @@ PassRefPtr<JSC::Bindings::Instance> PluginView::bindingInstance()
         return 0;
     }
 
-    RefPtr<JSC::Bindings::RootObject> root = m_parentFrame->script()->createRootObject(this);
+    RefPtr<JSC::Bindings::RootObject> root = m_parentFrame->script().createRootObject(this);
     RefPtr<JSC::Bindings::Instance> instance = JSC::Bindings::CInstance::create(object, root.release());
 
     _NPN_ReleaseObject(object);
@@ -1319,7 +1319,7 @@ NPError PluginView::getValue(NPNVariable variable, void* value)
         if (m_isJavaScriptPaused)
             return NPERR_GENERIC_ERROR;
 
-        NPObject* windowScriptObject = m_parentFrame->script()->windowScriptNPObject();
+        NPObject* windowScriptObject = m_parentFrame->script().windowScriptNPObject();
 
         // Return value is expected to be retained, as described here: <http://www.mozilla.org/projects/plugin/npruntime.html>
         if (windowScriptObject)
index 31acb12..34ffcd6 100644 (file)
@@ -251,7 +251,7 @@ bool PluginView::platformGetValue(NPNVariable variable, void* value, NPError* re
             return true;
         }
 
-        NPObject* windowScriptObject = m_parentFrame->script()->windowScriptNPObject();
+        NPObject* windowScriptObject = m_parentFrame->script().windowScriptNPObject();
 
         // Return value is expected to be retained, as described here: <http://www.mozilla.org/projects/plugin/npruntime.html>
         if (windowScriptObject)
index 533bc65..fd81970 100644 (file)
@@ -497,7 +497,7 @@ void XMLHttpRequest::open(const String& method, const KURL& url, bool async, Exc
     if (scriptExecutionContext()->isDocument()) {
         Document* document = static_cast<Document*>(scriptExecutionContext());
         if (document->frame())
-            shouldBypassMainWorldContentSecurityPolicy = document->frame()->script()->shouldBypassMainWorldContentSecurityPolicy();
+            shouldBypassMainWorldContentSecurityPolicy = document->frame()->script().shouldBypassMainWorldContentSecurityPolicy();
     }
     if (!shouldBypassMainWorldContentSecurityPolicy && !scriptExecutionContext()->contentSecurityPolicy()->allowConnectToSource(url)) {
         // FIXME: Should this be throwing an exception?
index 818c2b1..fd6400d 100644 (file)
@@ -56,9 +56,9 @@ void XMLTreeViewer::transformDocumentToTreeView()
 {
     m_document->setIsViewSource(true);
     String scriptString(reinterpret_cast<const char*>(XMLViewer_js), sizeof(XMLViewer_js));
-    m_document->frame()->script()->evaluate(ScriptSourceCode(scriptString));
+    m_document->frame()->script().evaluate(ScriptSourceCode(scriptString));
     String noStyleMessage("This XML file does not appear to have any style information associated with it. The document tree is shown below.");
-    m_document->frame()->script()->evaluate(ScriptSourceCode("prepareWebKitXMLViewer('" + noStyleMessage + "');"));
+    m_document->frame()->script().evaluate(ScriptSourceCode("prepareWebKitXMLViewer('" + noStyleMessage + "');"));
 
     String cssString(reinterpret_cast<const char*>(XMLViewer_css), sizeof(XMLViewer_css));
     RefPtr<Text> text = m_document->createTextNode(cssString);
index 132c51d..46be6a1 100644 (file)
@@ -667,7 +667,7 @@ public:
 private:
     virtual void performInternal(WebPagePrivate* webPagePrivate)
     {
-        webPagePrivate->m_mainFrame->script()->executeIfJavaScriptURL(webPagePrivate->m_cachedManualScript, DoNotReplaceDocumentIfJavaScriptURL);
+        webPagePrivate->m_mainFrame->script().executeIfJavaScriptURL(webPagePrivate->m_cachedManualScript, DoNotReplaceDocumentIfJavaScriptURL);
     }
 };
 
@@ -689,7 +689,7 @@ void WebPagePrivate::load(const Platform::NetworkRequest& netReq, bool needRefer
         if (m_page->defersLoading())
             m_deferredTasks.append(adoptPtr(new DeferredTaskLoadManualScript(this, kurl)));
         else
-            m_mainFrame->script()->executeIfJavaScriptURL(kurl, DoNotReplaceDocumentIfJavaScriptURL);
+            m_mainFrame->script().executeIfJavaScriptURL(kurl, DoNotReplaceDocumentIfJavaScriptURL);
         return;
     }
 
@@ -770,7 +770,7 @@ bool WebPagePrivate::executeJavaScript(const BlackBerry::Platform::String& scrip
         return true;
     }
 
-    ScriptValue result = m_mainFrame->script()->executeScript(script, false);
+    ScriptValue result = m_mainFrame->script().executeScript(script, false);
     JSC::JSValue value = result.jsValue();
     if (!value) {
         returnType = JSException;
@@ -793,7 +793,7 @@ bool WebPagePrivate::executeJavaScript(const BlackBerry::Platform::String& scrip
         returnType = JSUndefined;
 
     if (returnType == JSBoolean || returnType == JSNumber || returnType == JSString || returnType == JSObject) {
-        JSC::ExecState* exec = m_mainFrame->script()->globalObject(mainThreadNormalWorld())->globalExec();
+        JSC::ExecState* exec = m_mainFrame->script().globalObject(mainThreadNormalWorld())->globalExec();
         returnValue = result.toString(exec);
     }
 
@@ -808,10 +808,10 @@ bool WebPage::executeJavaScript(const BlackBerry::Platform::String& script, Java
 bool WebPagePrivate::executeJavaScriptInIsolatedWorld(const ScriptSourceCode& sourceCode, JavaScriptDataType& returnType, BlackBerry::Platform::String& returnValue)
 {
     if (!m_isolatedWorld)
-        m_isolatedWorld = m_mainFrame->script()->createWorld();
+        m_isolatedWorld = m_mainFrame->script().createWorld();
 
     // Use evaluateInWorld to avoid canExecuteScripts check.
-    ScriptValue result = m_mainFrame->script()->evaluateInWorld(sourceCode, m_isolatedWorld.get());
+    ScriptValue result = m_mainFrame->script().evaluateInWorld(sourceCode, m_isolatedWorld.get());
     JSC::JSValue value = result.jsValue();
     if (!value) {
         returnType = JSException;
@@ -834,7 +834,7 @@ bool WebPagePrivate::executeJavaScriptInIsolatedWorld(const ScriptSourceCode& so
         returnType = JSUndefined;
 
     if (returnType == JSBoolean || returnType == JSNumber || returnType == JSString || returnType == JSObject) {
-        JSC::ExecState* exec = m_mainFrame->script()->globalObject(mainThreadNormalWorld())->globalExec();
+        JSC::ExecState* exec = m_mainFrame->script().globalObject(mainThreadNormalWorld())->globalExec();
         returnValue = result.toString(exec);
     }
 
@@ -876,7 +876,7 @@ void WebPage::executeJavaScriptFunction(const std::vector<BlackBerry::Platform::
         return;
     }
 
-    JSC::Bindings::RootObject* root = d->m_mainFrame->script()->bindingRootObject();
+    JSC::Bindings::RootObject* root = d->m_mainFrame->script().bindingRootObject();
     if (!root) {
         returnValue.setType(JavaScriptVariant::Exception);
         return;
@@ -890,7 +890,7 @@ void WebPage::executeJavaScriptFunction(const std::vector<BlackBerry::Platform::
     for (unsigned i = 0; i < args.size(); ++i)
         argListRef[i] = BlackBerryJavaScriptVariantToJSValueRef(ctx, args[i]);
 
-    JSValueRef windowObjectValue = toRef(d->m_mainFrame->script()->globalObject(mainThreadNormalWorld()));
+    JSValueRef windowObjectValue = toRef(d->m_mainFrame->script().globalObject(mainThreadNormalWorld()));
     JSObjectRef obj = JSValueToObject(ctx, windowObjectValue, 0);
     JSObjectRef thisObject = obj;
     for (unsigned i = 0; i < function.size(); ++i) {
@@ -4759,7 +4759,7 @@ JSGlobalContextRef WebPage::globalContext() const
     if (!d->m_mainFrame)
         return 0;
 
-    return toGlobalRef(d->m_mainFrame->script()->globalObject(mainThreadNormalWorld())->globalExec());
+    return toGlobalRef(d->m_mainFrame->script().globalObject(mainThreadNormalWorld())->globalExec());
 }
 
 // Serialize only the members of HistoryItem which are needed by the client,
index 74dff76..91da598 100644 (file)
@@ -1,3 +1,21 @@
+2013-08-16  Pratik Solanki  <psolanki@apple.com>
+
+        <https://webkit.org/b/119852> Frame::scriptController() should return a reference
+
+        Reviewed by Andreas Kling.
+
+        m_script is never NULL so we can just return a reference. Also remove some pointless null
+        checks as a result of doing this.
+
+        * Api/WebPage.cpp:
+        (BlackBerry::WebKit::WebPagePrivate::load):
+        (BlackBerry::WebKit::WebPagePrivate::executeJavaScript):
+        (BlackBerry::WebKit::WebPagePrivate::executeJavaScriptInIsolatedWorld):
+        (BlackBerry::WebKit::WebPage::executeJavaScriptFunction):
+        (BlackBerry::WebKit::WebPage::globalContext):
+        * WebCoreSupport/FrameLoaderClientBlackBerry.cpp:
+        (WebCore::FrameLoaderClientBlackBerry::dispatchDidClearWindowObjectInWorld):
+
 2013-08-15  Anders Carlsson  <andersca@apple.com>
 
         <https://webkit.org/b/119859> Frame::loader() should return a reference
index 5d1c92b..a94d3fa 100644 (file)
@@ -921,8 +921,8 @@ void FrameLoaderClientBlackBerry::dispatchDidClearWindowObjectInWorld(DOMWrapper
     m_webPagePrivate->m_client->notifyWindowObjectCleared();
 
     if (m_webPagePrivate->m_dumpRenderTree) {
-        JSGlobalContextRef context = toGlobalRef(m_frame->script()->globalObject(mainThreadNormalWorld())->globalExec());
-        JSObjectRef windowObject = toRef(m_frame->script()->globalObject(mainThreadNormalWorld()));
+        JSGlobalContextRef context = toGlobalRef(m_frame->script().globalObject(mainThreadNormalWorld())->globalExec());
+        JSObjectRef windowObject = toRef(m_frame->script().globalObject(mainThreadNormalWorld()));
         ASSERT(windowObject);
         m_webPagePrivate->m_dumpRenderTree->didClearWindowObjectInWorld(world, context, windowObject);
     }
index f2dd540..5bd5d38 100644 (file)
@@ -1,3 +1,22 @@
+2013-08-16  Pratik Solanki  <psolanki@apple.com>
+
+        <https://webkit.org/b/119852> Frame::scriptController() should return a reference
+
+        Reviewed by Andreas Kling.
+
+        m_script is never NULL so we can just return a reference. Also remove some pointless null
+        checks as a result of doing this.
+
+        * WebCoreSupport/DumpRenderTreeSupportEfl.cpp:
+        (DumpRenderTreeSupportEfl::evaluateScriptInIsolatedWorld):
+        (DumpRenderTreeSupportEfl::globalContextRefForFrame):
+        * WebCoreSupport/FrameLoaderClientEfl.cpp:
+        (WebCore::FrameLoaderClientEfl::dispatchDidClearWindowObjectInWorld):
+        * ewk/ewk_frame.cpp:
+        (ewk_frame_script_execute):
+        * ewk/ewk_view.cpp:
+        (ewk_view_js_object_add):
+
 2013-08-15  Ryuan Choi  <ryuan.choi@samsung.com>
 
         [EFL] Unreviewed build fix after r154142 and r154144.
index 8bfc884..4a62d48 100644 (file)
@@ -482,7 +482,7 @@ void DumpRenderTreeSupportEfl::evaluateScriptInIsolatedWorld(const Evas_Object*
     DRT_SUPPORT_FRAME_GET_OR_RETURN(ewkFrame, frame);
 
     // Comment from mac: Start off with some guess at a frame and a global object, we'll try to do better...!
-    WebCore::JSDOMWindow* anyWorldGlobalObject = frame->script()->globalObject(WebCore::mainThreadNormalWorld());
+    WebCore::JSDOMWindow* anyWorldGlobalObject = frame->script().globalObject(WebCore::mainThreadNormalWorld());
 
     // Comment from mac: The global object is probably a shell object? - if so, we know how to use this!
     JSC::JSObject* globalObjectObj = toJS(globalObject);
@@ -522,7 +522,7 @@ JSGlobalContextRef DumpRenderTreeSupportEfl::globalContextRefForFrame(const Evas
 {
     DRT_SUPPORT_FRAME_GET_OR_RETURN(ewkFrame, frame, 0);
 
-    return toGlobalRef(frame->script()->globalObject(WebCore::mainThreadNormalWorld())->globalExec());
+    return toGlobalRef(frame->script().globalObject(WebCore::mainThreadNormalWorld())->globalExec());
 }
 
 void DumpRenderTreeSupportEfl::setMockScrollbarsEnabled(bool enable)
index eabf2c6..e6cbd33 100644 (file)
@@ -440,8 +440,8 @@ void FrameLoaderClientEfl::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*
         return;
 
     Ewk_Window_Object_Cleared_Event event;
-    event.context = toGlobalRef(coreFrame->script()->globalObject(mainThreadNormalWorld())->globalExec());
-    event.windowObject = toRef(coreFrame->script()->globalObject(mainThreadNormalWorld()));
+    event.context = toGlobalRef(coreFrame->script().globalObject(mainThreadNormalWorld())->globalExec());
+    event.windowObject = toRef(coreFrame->script().globalObject(mainThreadNormalWorld()));
     event.frame = m_frame;
 
     evas_object_smart_callback_call(m_view, "window,object,cleared", &event);
index 5d82b84..46a0a29 100644 (file)
@@ -450,7 +450,7 @@ const char* ewk_frame_script_execute(Evas_Object* ewkFrame, const char* script)
     EINA_SAFETY_ON_NULL_RETURN_VAL(script, 0);
 
     WTF::String resultString;
-    JSC::JSValue result = smartData->frame->script()->executeScript(WTF::String::fromUTF8(script), true).jsValue();
+    JSC::JSValue result = smartData->frame->script().executeScript(WTF::String::fromUTF8(script), true).jsValue();
 
     if (!smartData->frame) // In case the script removed our frame from the page.
         return 0;
@@ -458,7 +458,7 @@ const char* ewk_frame_script_execute(Evas_Object* ewkFrame, const char* script)
     if (!result || (!result.isBoolean() && !result.isString() && !result.isNumber()))
         return 0;
 
-    JSC::ExecState* exec = smartData->frame->script()->globalObject(WebCore::mainThreadNormalWorld())->globalExec();
+    JSC::ExecState* exec = smartData->frame->script().globalObject(WebCore::mainThreadNormalWorld())->globalExec();
     JSC::JSLockHolder lock(exec);
     resultString = result.toString(exec)->value(exec);
     return eina_stringshare_add(resultString.utf8().data());
index edb1a74..92e72b5 100644 (file)
@@ -4097,7 +4097,7 @@ Eina_Bool ewk_view_js_object_add(Evas_Object* ewkView, Ewk_JS_Object* object, co
     WebCore::JSDOMWindow* window = toJSDOMWindow(priv->mainFrame, WebCore::mainThreadNormalWorld());
     JSC::JSLockHolder lock(window->globalExec());
     JSC::Bindings::RootObject* root;
-    root = priv->mainFrame->script()->bindingRootObject();
+    root = priv->mainFrame->script().bindingRootObject();
 
     if (!window) {
         ERR("Warning: couldn't get window object");
index 5f83d45..0473d78 100644 (file)
@@ -1,3 +1,19 @@
+2013-08-16  Pratik Solanki  <psolanki@apple.com>
+
+        <https://webkit.org/b/119852> Frame::scriptController() should return a reference
+
+        Reviewed by Andreas Kling.
+
+        m_script is never NULL so we can just return a reference. Also remove some pointless null
+        checks as a result of doing this.
+
+        * WebCoreSupport/FrameLoaderClientGtk.cpp:
+        (WebKit::FrameLoaderClient::dispatchDidClearWindowObjectInWorld):
+        * webkit/webkitwebframe.cpp:
+        (webkit_web_frame_get_global_context):
+        * webkit/webkitwebview.cpp:
+        (webkit_web_view_execute_script):
+
 2013-08-15  Zan Dobersek  <zdobersek@igalia.com>
 
         Unreviewed GTK build fix for debug configurations.
index 0de925a..00079da 100644 (file)
@@ -591,8 +591,8 @@ void FrameLoaderClient::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* wor
 
     // TODO: Consider using g_signal_has_handler_pending() to avoid the overhead
     // when there are no handlers.
-    JSGlobalContextRef context = toGlobalRef(coreFrame->script()->globalObject(mainThreadNormalWorld())->globalExec());
-    JSObjectRef windowObject = toRef(coreFrame->script()->globalObject(mainThreadNormalWorld()));
+    JSGlobalContextRef context = toGlobalRef(coreFrame->script().globalObject(mainThreadNormalWorld())->globalExec());
+    JSObjectRef windowObject = toRef(coreFrame->script().globalObject(mainThreadNormalWorld()));
     ASSERT(windowObject);
 
     WebKitWebView* webView = getViewFromFrame(m_frame);
index 883c7c8..06b2ea8 100644 (file)
@@ -848,7 +848,7 @@ JSGlobalContextRef webkit_web_frame_get_global_context(WebKitWebFrame* frame)
     if (!coreFrame)
         return 0;
 
-    return toGlobalRef(coreFrame->script()->globalObject(mainThreadNormalWorld())->globalExec());
+    return toGlobalRef(coreFrame->script().globalObject(mainThreadNormalWorld())->globalExec());
 }
 
 /**
index 93603e0..ff58843 100644 (file)
@@ -4448,7 +4448,7 @@ void webkit_web_view_execute_script(WebKitWebView* webView, const gchar* script)
     g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
     g_return_if_fail(script);
 
-    core(webView)->mainFrame()->script()->executeScript(String::fromUTF8(script), true);
+    core(webView)->mainFrame()->script().executeScript(String::fromUTF8(script), true);
 }
 
 /**
index a8821ff..b556b0c 100644 (file)
@@ -1,3 +1,51 @@
+2013-08-16  Pratik Solanki  <psolanki@apple.com>
+
+        <https://webkit.org/b/119852> Frame::scriptController() should return a reference
+
+        Reviewed by Andreas Kling.
+
+        m_script is never NULL so we can just return a reference. Also remove some pointless null
+        checks as a result of doing this.
+
+        * Plugins/Hosted/NetscapePluginInstanceProxy.mm:
+        (WebKit::NetscapePluginInstanceProxy::cleanup):
+        (WebKit::NetscapePluginInstanceProxy::getWindowNPObject):
+        (WebKit::NetscapePluginInstanceProxy::getPluginElementNPObject):
+        (WebKit::NetscapePluginInstanceProxy::evaluate):
+        (WebKit::NetscapePluginInstanceProxy::invoke):
+        (WebKit::NetscapePluginInstanceProxy::invokeDefault):
+        (WebKit::NetscapePluginInstanceProxy::construct):
+        (WebKit::NetscapePluginInstanceProxy::getProperty):
+        (WebKit::NetscapePluginInstanceProxy::setProperty):
+        (WebKit::NetscapePluginInstanceProxy::removeProperty):
+        (WebKit::NetscapePluginInstanceProxy::hasProperty):
+        (WebKit::NetscapePluginInstanceProxy::hasMethod):
+        (WebKit::NetscapePluginInstanceProxy::enumerate):
+        (WebKit::NetscapePluginInstanceProxy::demarshalValueFromArray):
+        * Plugins/WebNetscapePluginView.mm:
+        (-[WebNetscapePluginView getVariable:value:]):
+        (-[WebNetscapePluginView _destroyPlugin]):
+        * Plugins/WebPluginController.mm:
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        * WebCoreSupport/WebInspectorClient.mm:
+        (WebInspectorFrontendClient::save):
+        (WebInspectorFrontendClient::append):
+        * WebView/WebFrame.mm:
+        (-[WebFrame _attachScriptDebugger]):
+        (-[WebFrame _stringByEvaluatingJavaScriptFromString:forceUserGesture:]):
+        (-[WebFrame _stringByEvaluatingJavaScriptFromString:withGlobalObject:inScriptWorld:]):
+        (-[WebFrame _globalContextForScriptWorld:]):
+        (-[WebFrame jsWrapperForNode:inScriptWorld:]):
+        (-[WebFrame windowObject]):
+        (-[WebFrame globalContext]):
+        (-[WebFrame javaScriptContext]):
+        * WebView/WebScriptDebugger.mm:
+        (WebScriptDebugger::initGlobalCallFrame):
+        (WebScriptDebugger::callEvent):
+        * WebView/WebView.mm:
+        (-[WebView windowScriptObject]):
+        (-[WebView aeDescByEvaluatingJavaScriptFromString:]):
+
 2013-08-15  Anders Carlsson  <andersca@apple.com>
 
         <https://webkit.org/b/119859> Frame::loader() should return a reference
index 340bfc3..c33cb51 100644 (file)
@@ -309,7 +309,7 @@ void NetscapePluginInstanceProxy::cleanup()
     m_localObjects.clear();
     
     if (Frame* frame = core([m_pluginView webFrame]))
-        frame->script()->cleanupScriptObjectsForPlugin(m_pluginView);
+        frame->script().cleanupScriptObjectsForPlugin(m_pluginView);
     
     ProxyInstanceSet instances;
     instances.swap(m_instances);
@@ -838,10 +838,10 @@ bool NetscapePluginInstanceProxy::getWindowNPObject(uint32_t& objectID)
     if (!frame)
         return false;
     
-    if (!frame->script()->canExecuteScripts(NotAboutToExecuteScript))
+    if (!frame->script().canExecuteScripts(NotAboutToExecuteScript))
         objectID = 0;
     else
-        objectID = m_localObjects.idForObject(*pluginWorld()->vm(), frame->script()->windowShell(pluginWorld())->window());
+        objectID = m_localObjects.idForObject(*pluginWorld()->vm(), frame->script().windowShell(pluginWorld())->window());
         
     return true;
 }
@@ -852,7 +852,7 @@ bool NetscapePluginInstanceProxy::getPluginElementNPObject(uint32_t& objectID)
     if (!frame)
         return false;
     
-    if (JSObject* object = frame->script()->jsObjectForPluginElement([m_pluginView element]))
+    if (JSObject* object = frame->script().jsObjectForPluginElement([m_pluginView element]))
         objectID = m_localObjects.idForObject(*pluginWorld()->vm(), object);
     else
         objectID = 0;
@@ -883,7 +883,7 @@ bool NetscapePluginInstanceProxy::evaluate(uint32_t objectID, const String& scri
         return false;
 
     JSLockHolder lock(pluginWorld()->vm());
-    Strong<JSGlobalObject> globalObject(*pluginWorld()->vm(), frame->script()->globalObject(pluginWorld()));
+    Strong<JSGlobalObject> globalObject(*pluginWorld()->vm(), frame->script().globalObject(pluginWorld()));
     ExecState* exec = globalObject->globalExec();
 
     UserGestureIndicator gestureIndicator(allowPopups ? DefinitelyProcessingUserGesture : PossiblyProcessingUserGesture);
@@ -913,7 +913,7 @@ bool NetscapePluginInstanceProxy::invoke(uint32_t objectID, const Identifier& me
     if (!frame)
         return false;
     
-    ExecState* exec = frame->script()->globalObject(pluginWorld())->globalExec();
+    ExecState* exec = frame->script().globalObject(pluginWorld())->globalExec();
     JSLockHolder lock(exec);
     JSValue function = object->get(exec, methodName);
     CallData callData;
@@ -946,7 +946,7 @@ bool NetscapePluginInstanceProxy::invokeDefault(uint32_t objectID, data_t argume
     if (!frame)
         return false;
     
-    ExecState* exec = frame->script()->globalObject(pluginWorld())->globalExec();
+    ExecState* exec = frame->script().globalObject(pluginWorld())->globalExec();
     JSLockHolder lock(exec);    
     CallData callData;
     CallType callType = object->methodTable()->getCallData(object, callData);
@@ -978,7 +978,7 @@ bool NetscapePluginInstanceProxy::construct(uint32_t objectID, data_t argumentsD
     if (!frame)
         return false;
     
-    ExecState* exec = frame->script()->globalObject(pluginWorld())->globalExec();
+    ExecState* exec = frame->script().globalObject(pluginWorld())->globalExec();
     JSLockHolder lock(exec);
 
     ConstructData constructData;
@@ -1011,7 +1011,7 @@ bool NetscapePluginInstanceProxy::getProperty(uint32_t objectID, const Identifie
     if (!frame)
         return false;
     
-    ExecState* exec = frame->script()->globalObject(pluginWorld())->globalExec();
+    ExecState* exec = frame->script().globalObject(pluginWorld())->globalExec();
     JSLockHolder lock(exec);    
     JSValue value = object->get(exec, propertyName);
     
@@ -1032,7 +1032,7 @@ bool NetscapePluginInstanceProxy::getProperty(uint32_t objectID, unsigned proper
     if (!frame)
         return false;
     
-    ExecState* exec = frame->script()->globalObject(pluginWorld())->globalExec();
+    ExecState* exec = frame->script().globalObject(pluginWorld())->globalExec();
     JSLockHolder lock(exec);    
     JSValue value = object->get(exec, propertyName);
     
@@ -1056,7 +1056,7 @@ bool NetscapePluginInstanceProxy::setProperty(uint32_t objectID, const Identifie
     if (!frame)
         return false;
     
-    ExecState* exec = frame->script()->globalObject(pluginWorld())->globalExec();
+    ExecState* exec = frame->script().globalObject(pluginWorld())->globalExec();
     JSLockHolder lock(exec);    
 
     JSValue value = demarshalValue(exec, valueData, valueLength);
@@ -1082,7 +1082,7 @@ bool NetscapePluginInstanceProxy::setProperty(uint32_t objectID, unsigned proper
     if (!frame)
         return false;
     
-    ExecState* exec = frame->script()->globalObject(pluginWorld())->globalExec();
+    ExecState* exec = frame->script().globalObject(pluginWorld())->globalExec();
     JSLockHolder lock(exec);    
     
     JSValue value = demarshalValue(exec, valueData, valueLength);
@@ -1107,7 +1107,7 @@ bool NetscapePluginInstanceProxy::removeProperty(uint32_t objectID, const Identi
     if (!frame)
         return false;
 
-    ExecState* exec = frame->script()->globalObject(pluginWorld())->globalExec();
+    ExecState* exec = frame->script().globalObject(pluginWorld())->globalExec();
     JSLockHolder lock(exec);
     if (!object->hasProperty(exec, propertyName)) {
         exec->clearException();
@@ -1134,7 +1134,7 @@ bool NetscapePluginInstanceProxy::removeProperty(uint32_t objectID, unsigned pro
     if (!frame)
         return false;
     
-    ExecState* exec = frame->script()->globalObject(pluginWorld())->globalExec();
+    ExecState* exec = frame->script().globalObject(pluginWorld())->globalExec();
     JSLockHolder lock(exec);
     if (!object->hasProperty(exec, propertyName)) {
         exec->clearException();
@@ -1161,7 +1161,7 @@ bool NetscapePluginInstanceProxy::hasProperty(uint32_t objectID, const Identifie
     if (!frame)
         return false;
     
-    ExecState* exec = frame->script()->globalObject(pluginWorld())->globalExec();
+    ExecState* exec = frame->script().globalObject(pluginWorld())->globalExec();
     bool result = object->hasProperty(exec, propertyName);
     exec->clearException();
     
@@ -1183,7 +1183,7 @@ bool NetscapePluginInstanceProxy::hasProperty(uint32_t objectID, unsigned proper
     if (!frame)
         return false;
     
-    ExecState* exec = frame->script()->globalObject(pluginWorld())->globalExec();
+    ExecState* exec = frame->script().globalObject(pluginWorld())->globalExec();
     bool result = object->hasProperty(exec, propertyName);
     exec->clearException();
     
@@ -1205,7 +1205,7 @@ bool NetscapePluginInstanceProxy::hasMethod(uint32_t objectID, const Identifier&
     if (!frame)
         return false;
     
-    ExecState* exec = frame->script()->globalObject(pluginWorld())->globalExec();
+    ExecState* exec = frame->script().globalObject(pluginWorld())->globalExec();
     JSLockHolder lock(exec);
     JSValue func = object->get(exec, methodName);
     exec->clearException();
@@ -1227,7 +1227,7 @@ bool NetscapePluginInstanceProxy::enumerate(uint32_t objectID, data_t& resultDat
     if (!frame)
         return false;
     
-    ExecState* exec = frame->script()->globalObject(pluginWorld())->globalExec();
+    ExecState* exec = frame->script().globalObject(pluginWorld())->globalExec();
     JSLockHolder lock(exec);
  
     PropertyNameArray propertyNames(exec);
@@ -1366,10 +1366,10 @@ bool NetscapePluginInstanceProxy::demarshalValueFromArray(ExecState* exec, NSArr
             if (!frame)
                 return false;
             
-            if (!frame->script()->canExecuteScripts(NotAboutToExecuteScript))
+            if (!frame->script().canExecuteScripts(NotAboutToExecuteScript))
                 return false;
 
-            RefPtr<RootObject> rootObject = frame->script()->createRootObject(m_pluginView);
+            RefPtr<RootObject> rootObject = frame->script().createRootObject(m_pluginView);
             if (!rootObject)
                 return false;
             
index dcd899c..7aa8197 100644 (file)
@@ -2001,7 +2001,7 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
         case NPNVWindowNPObject:
         {
             Frame* frame = core([self webFrame]);
-            NPObject* windowScriptObject = frame ? frame->script()->windowScriptNPObject() : 0;
+            NPObject* windowScriptObject = frame ? frame->script().windowScriptNPObject() : 0;
 
             // Return value is expected to be retained, as described here: <http://www.mozilla.org/projects/plugins/npruntime.html#browseraccess>
             if (windowScriptObject)
@@ -2396,7 +2396,7 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
     LOG(Plugins, "NPP_Destroy: %d", npErr);
     
     if (Frame* frame = core([self webFrame]))
-        frame->script()->cleanupScriptObjectsForPlugin(self);
+        frame->script().cleanupScriptObjectsForPlugin(self);
         
     free(plugin);
     plugin = NULL;
index 8afe2d3..dded2d9 100644 (file)
@@ -294,7 +294,7 @@ static NSMutableSet *pluginViews = nil;
         
 #if ENABLE(NETSCAPE_PLUGIN_API)
         if (Frame* frame = core([self webFrame]))
-            frame->script()->cleanupScriptObjectsForPlugin(self);
+            frame->script().cleanupScriptObjectsForPlugin(self);
 #endif
         
         [pluginViews removeObject:view];
@@ -343,7 +343,7 @@ static void cancelOutstandingCheck(const void *item, void *context)
         
 #if ENABLE(NETSCAPE_PLUGIN_API)
         if (Frame* frame = core([self webFrame]))
-            frame->script()->cleanupScriptObjectsForPlugin(self);
+            frame->script().cleanupScriptObjectsForPlugin(self);
 #endif
         
         [pluginViews removeObject:aView];
index ceb84f8..bb5cdab 100644 (file)
@@ -1961,21 +1961,21 @@ void WebFrameLoaderClient::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*
         return;
 
     Frame *frame = core(m_webFrame.get());
-    ScriptController *script = frame->script();
+    ScriptControllerscript = frame->script();
 
 #if JSC_OBJC_API_ENABLED
     if (implementations->didCreateJavaScriptContextForFrameFunc) {
         CallFrameLoadDelegate(implementations->didCreateJavaScriptContextForFrameFunc, webView, @selector(webView:didCreateJavaScriptContext:forFrame:),
-            script->javaScriptContext(), m_webFrame.get());
+            script.javaScriptContext(), m_webFrame.get());
     } else if (implementations->didClearWindowObjectForFrameFunc) {
 #else
     if (implementations->didClearWindowObjectForFrameFunc) {
 #endif
         CallFrameLoadDelegate(implementations->didClearWindowObjectForFrameFunc, webView, @selector(webView:didClearWindowObject:forFrame:),
-            script->windowScriptObject(), m_webFrame.get());
+            script.windowScriptObject(), m_webFrame.get());
     } else if (implementations->windowScriptObjectAvailableFunc) {
         CallFrameLoadDelegate(implementations->windowScriptObjectAvailableFunc, webView, @selector(webView:windowScriptObjectAvailable:),
-            script->windowScriptObject());
+            script.windowScriptObject());
     }
 
     if ([webView scriptDebugDelegate]) {
index 21c3657..65ba362 100644 (file)
@@ -327,7 +327,7 @@ void WebInspectorFrontendClient::save(const String& suggestedURL, const String&
         
         m_suggestedToActualURLMap.set(suggestedURLCopy, actualURL);
         [contentCopy writeToURL:actualURL atomically:YES encoding:NSUTF8StringEncoding error:NULL];
-        core([m_windowController webView])->mainFrame()->script()->executeScript([NSString stringWithFormat:@"InspectorFrontendAPI.savedURL(\"%@\")", actualURL.absoluteString]);
+        core([m_windowController webView])->mainFrame()->script().executeScript([NSString stringWithFormat:@"InspectorFrontendAPI.savedURL(\"%@\")", actualURL.absoluteString]);
     };
 
     if (!forceSaveDialog) {
@@ -361,7 +361,7 @@ void WebInspectorFrontendClient::append(const String& suggestedURL, const String
     [handle writeData:[content dataUsingEncoding:NSUTF8StringEncoding]];
     [handle closeFile];
 
-    core([m_windowController webView])->mainFrame()->script()->executeScript([NSString stringWithFormat:@"InspectorFrontendAPI.appendedToURL(\"%@\")", [actualURL absoluteString]]);
+    core([m_windowController webView])->mainFrame()->script().executeScript([NSString stringWithFormat:@"InspectorFrontendAPI.appendedToURL(\"%@\")", [actualURL absoluteString]]);
 }
 
 // MARK: -
index 6ffa084..9f3f75b 100644 (file)
@@ -299,15 +299,15 @@ WebView *getWebView(WebFrame *webFrame)
 
 - (void)_attachScriptDebugger
 {
-    ScriptController* scriptController = _private->coreFrame->script();
+    ScriptController& scriptController = _private->coreFrame->script();
 
     // Calling ScriptController::globalObject() would create a window shell, and dispatch corresponding callbacks, which may be premature
     // if the script debugger is attached before a document is created.  These calls use the debuggerWorld(), we will need to pass a world
     // to be able to debug isolated worlds.
-    if (!scriptController->existingWindowShell(debuggerWorld()))
+    if (!scriptController.existingWindowShell(debuggerWorld()))
         return;
 
-    JSGlobalObject* globalObject = scriptController->globalObject(debuggerWorld());
+    JSGlobalObject* globalObject = scriptController.globalObject(debuggerWorld());
     if (!globalObject)
         return;
 
@@ -591,7 +591,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
     ASSERT(_private->coreFrame->document());
     RetainPtr<WebFrame> protect(self); // Executing arbitrary JavaScript can destroy the frame.
     
-    JSC::JSValue result = _private->coreFrame->script()->executeScript(string, forceUserGesture).jsValue();
+    JSC::JSValue result = _private->coreFrame->script().executeScript(string, forceUserGesture).jsValue();
 
     if (!_private->coreFrame) // In case the script removed our frame from the page.
         return @"";
@@ -602,7 +602,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
     if (!result || (!result.isBoolean() && !result.isString() && !result.isNumber()))
         return @"";
 
-    JSC::ExecState* exec = _private->coreFrame->script()->globalObject(mainThreadNormalWorld())->globalExec();
+    JSC::ExecState* exec = _private->coreFrame->script().globalObject(mainThreadNormalWorld())->globalExec();
     JSC::JSLockHolder lock(exec);
     return result.toWTFString(exec);
 }
@@ -1059,7 +1059,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
         return @"";
 
     // Start off with some guess at a frame and a global object, we'll try to do better...!
-    JSDOMWindow* anyWorldGlobalObject = _private->coreFrame->script()->globalObject(mainThreadNormalWorld());
+    JSDOMWindow* anyWorldGlobalObject = _private->coreFrame->script().globalObject(mainThreadNormalWorld());
 
     // The global object is probably a shell object? - if so, we know how to use this!
     JSC::JSObject* globalObjectObj = toJS(globalObjectRef);
@@ -1071,7 +1071,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
     ASSERT(frame->document());
     RetainPtr<WebFrame> webFrame(kit(frame)); // Running arbitrary JavaScript can destroy the frame.
 
-    JSC::JSValue result = frame->script()->executeScriptInWorld(core(world), string, true).jsValue();
+    JSC::JSValue result = frame->script().executeScriptInWorld(core(world), string, true).jsValue();
 
     if (!webFrame->_private->coreFrame) // In case the script removed our frame from the page.
         return @"";
@@ -1095,7 +1095,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
     DOMWrapperWorld* coreWorld = core(world);
     if (!coreWorld)
         return 0;
-    return toGlobalRef(coreFrame->script()->globalObject(coreWorld)->globalExec());
+    return toGlobalRef(coreFrame->script().globalObject(coreWorld)->globalExec());
 }
 
 #if JSC_OBJC_API_ENABLED
@@ -1226,7 +1226,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
     if (!coreFrame)
         return 0;
 
-    JSDOMWindow* globalObject = coreFrame->script()->globalObject(core(world));
+    JSDOMWindow* globalObject = coreFrame->script().globalObject(core(world));
     JSC::ExecState* exec = globalObject->globalExec();
 
     JSC::JSLockHolder lock(exec);
@@ -1487,7 +1487,7 @@ static NSURL *createUniqueWebDataURL()
     Frame* coreFrame = _private->coreFrame;
     if (!coreFrame)
         return 0;
-    return coreFrame->script()->windowScriptObject();
+    return coreFrame->script().windowScriptObject();
 }
 
 - (JSGlobalContextRef)globalContext
@@ -1495,7 +1495,7 @@ static NSURL *createUniqueWebDataURL()
     Frame* coreFrame = _private->coreFrame;
     if (!coreFrame)
         return 0;
-    return toGlobalRef(coreFrame->script()->globalObject(mainThreadNormalWorld())->globalExec());
+    return toGlobalRef(coreFrame->script().globalObject(mainThreadNormalWorld())->globalExec());
 }
 
 #if JSC_OBJC_API_ENABLED
@@ -1504,7 +1504,7 @@ static NSURL *createUniqueWebDataURL()
     Frame* coreFrame = _private->coreFrame;
     if (!coreFrame)
         return 0;
-    return coreFrame->script()->javaScriptContext();
+    return coreFrame->script().javaScriptContext();
 }
 #endif
 
index e47e92b..3f6ce62 100644 (file)
@@ -87,7 +87,7 @@ void WebScriptDebugger::initGlobalCallFrame(const DebuggerCallFrame& debuggerCal
 
     WebFrame *webFrame = toWebFrame(debuggerCallFrame.dynamicGlobalObject());
 
-    m_topCallFrame = adoptNS([[WebScriptCallFrame alloc] _initWithGlobalObject:core(webFrame)->script()->windowScriptObject() debugger:this caller:m_topCallFrame.get() debuggerCallFrame:debuggerCallFrame]);
+    m_topCallFrame = adoptNS([[WebScriptCallFrame alloc] _initWithGlobalObject:core(webFrame)->script().windowScriptObject() debugger:this caller:m_topCallFrame.get() debuggerCallFrame:debuggerCallFrame]);
     m_globalCallFrame = m_topCallFrame;
 
     WebView *webView = [webFrame webView];
@@ -145,7 +145,7 @@ void WebScriptDebugger::callEvent(const DebuggerCallFrame& debuggerCallFrame, in
 
     WebFrame *webFrame = toWebFrame(debuggerCallFrame.dynamicGlobalObject());
 
-    m_topCallFrame = adoptNS([[WebScriptCallFrame alloc] _initWithGlobalObject:core(webFrame)->script()->windowScriptObject() debugger:this caller:m_topCallFrame.get() debuggerCallFrame:debuggerCallFrame]);
+    m_topCallFrame = adoptNS([[WebScriptCallFrame alloc] _initWithGlobalObject:core(webFrame)->script().windowScriptObject() debugger:this caller:m_topCallFrame.get() debuggerCallFrame:debuggerCallFrame]);
 
     WebView *webView = [webFrame webView];
     WebScriptDebugDelegateImplementationCache* implementations = WebViewGetScriptDebugDelegateImplementations(webView);
index ad71456..d6c5f84 100644 (file)
@@ -4195,7 +4195,7 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
     Frame* coreFrame = [self _mainCoreFrame];
     if (!coreFrame)
         return nil;
-    return coreFrame->script()->windowScriptObject();
+    return coreFrame->script().windowScriptObject();
 }
 
 - (String)_userAgentString
@@ -5075,11 +5075,11 @@ static NSAppleEventDescriptor* aeDescFromJSValue(ExecState* exec, JSC::JSValue j
         return nil;
     if (!coreFrame->document())
         return nil;
-    JSC::JSValue result = coreFrame->script()->executeScript(script, true).jsValue();
+    JSC::JSValue result = coreFrame->script().executeScript(script, true).jsValue();
     if (!result) // FIXME: pass errors
         return 0;
-    JSLockHolder lock(coreFrame->script()->globalObject(mainThreadNormalWorld())->globalExec());
-    return aeDescFromJSValue(coreFrame->script()->globalObject(mainThreadNormalWorld())->globalExec(), result);
+    JSLockHolder lock(coreFrame->script().globalObject(mainThreadNormalWorld())->globalExec());
+    return aeDescFromJSValue(coreFrame->script().globalObject(mainThreadNormalWorld())->globalExec(), result);
 }
 
 - (BOOL)canMarkAllTextMatches
index f555edf..6906e17 100644 (file)
@@ -711,7 +711,7 @@ QWebFrame *QWebElement::webFrame() const
     return frameAdapter->apiHandle();
 }
 
-static bool setupScriptContext(WebCore::Element* element, ScriptState*& state, ScriptController*& scriptController)
+static bool setupScriptContext(WebCore::Element* element, ScriptState*& state)
 {
     if (!element)
         return false;
@@ -724,11 +724,7 @@ static bool setupScriptContext(WebCore::Element* element, ScriptState*& state, S
     if (!frame)
         return false;
 
-    scriptController = frame->script();
-    if (!scriptController)
-        return false;
-
-    state = scriptController->globalObject(mainThreadNormalWorld())->globalExec();
+    state = frame->script().globalObject(mainThreadNormalWorld())->globalExec();
     if (!state)
         return false;
 
@@ -744,9 +740,8 @@ QVariant QWebElement::evaluateJavaScript(const QString& scriptSource)
         return QVariant();
 
     ScriptState* state = 0;
-    ScriptController* scriptController = 0;
 
-    if (!setupScriptContext(m_element, state, scriptController))
+    if (!setupScriptContext(m_element, state))
         return QVariant();
 
     JSC::JSLockHolder lock(state);
index 091b7f2..15993f9 100644 (file)
@@ -1,3 +1,21 @@
+2013-08-16  Pratik Solanki  <psolanki@apple.com>
+
+        <https://webkit.org/b/119852> Frame::scriptController() should return a reference
+
+        Reviewed by Andreas Kling.
+
+        m_script is never NULL so we can just return a reference. Also remove some pointless null
+        checks as a result of doing this.
+
+        * Api/qwebelement.cpp:
+        (setupScriptContext):
+        (QWebElement::evaluateJavaScript):
+        * WebCoreSupport/DumpRenderTreeSupportQt.cpp:
+        (DumpRenderTreeSupportQt::evaluateScriptInIsolatedWorld):
+        * WebCoreSupport/QWebFrameAdapter.cpp:
+        (QWebFrameAdapter::evaluateJavaScript):
+        (QWebFrameAdapter::addToJavaScriptWindowObject):
+
 2013-08-15  Anders Carlsson  <andersca@apple.com>
 
         <https://webkit.org/b/119859> Frame::loader() should return a reference
index 71f480b..98f226d 100644 (file)
@@ -623,11 +623,8 @@ void DumpRenderTreeSupportQt::evaluateScriptInIsolatedWorld(QWebFrameAdapter *ad
 
     WebCore::Frame* coreFrame = adapter->frame;
 
-    ScriptController* proxy = coreFrame->script();
-
-    if (!proxy)
-        return;
-    proxy->executeScriptInWorld(scriptWorld->world(), script, true);
+    ScriptController& proxy = coreFrame->script();
+    proxy.executeScriptInWorld(scriptWorld->world(), script, true);
 }
 
 void DumpRenderTreeSupportQt::addUserStyleSheet(QWebPageAdapter* adapter, const QString& sourceCode)
index 6182c0c..2af19ed 100644 (file)
@@ -197,18 +197,16 @@ void QWebFrameAdapter::handleGestureEvent(QGestureEventFacade* gestureEvent)
 
 QVariant QWebFrameAdapter::evaluateJavaScript(const QString &scriptSource)
 {
-    ScriptController* scriptController = frame->script();
+    ScriptController& scriptController = frame->script();
     QVariant rc;
-    if (scriptController) {
-        int distance = 0;
-        ScriptValue value = scriptController->executeScript(ScriptSourceCode(scriptSource));
-        JSC::ExecState* exec = scriptController->globalObject(mainThreadNormalWorld())->globalExec();
-        JSValueRef* ignoredException = 0;
-        exec->vm().apiLock().lock();
-        JSValueRef valueRef = toRef(exec, value.jsValue());
-        exec->vm().apiLock().unlock();
-        rc = JSC::Bindings::convertValueToQVariant(toRef(exec), valueRef, QMetaType::Void, &distance, ignoredException);
-    }
+    int distance = 0;
+    ScriptValue value = scriptController.executeScript(ScriptSourceCode(scriptSource));
+    JSC::ExecState* exec = scriptController.globalObject(mainThreadNormalWorld())->globalExec();
+    JSValueRef* ignoredException = 0;
+    exec->vm().apiLock().lock();
+    JSValueRef valueRef = toRef(exec, value.jsValue());
+    exec->vm().apiLock().unlock();
+    rc = JSC::Bindings::convertValueToQVariant(toRef(exec), valueRef, QMetaType::Void, &distance, ignoredException);
     return rc;
 }
 
@@ -220,9 +218,9 @@ void QWebFrameAdapter::addToJavaScriptWindowObject(const QString& name, QObject*
     JSDOMWindow* window = toJSDOMWindow(frame, mainThreadNormalWorld());
     JSC::Bindings::RootObject* root;
     if (valueOwnership == JSC::Bindings::QtInstance::QtOwnership)
-        root = frame->script()->cacheableBindingRootObject();
+        root = frame->script().cacheableBindingRootObject();
     else
-        root = frame->script()->bindingRootObject();
+        root = frame->script().bindingRootObject();
 
     if (!window) {
         qDebug() << "Warning: couldn't get window object";
index d5a1a42..b97263e 100644 (file)
@@ -1,3 +1,20 @@
+2013-08-16  Pratik Solanki  <psolanki@apple.com>
+
+        <https://webkit.org/b/119852> Frame::scriptController() should return a reference
+
+        Reviewed by Andreas Kling.
+
+        m_script is never NULL so we can just return a reference. Also remove some pointless null
+        checks as a result of doing this.
+
+        * WebFrame.cpp:
+        (WebFrame::globalContext):
+        (WebFrame::globalContextForScriptWorld):
+        (WebFrame::dispatchDidClearWindowObjectInWorld):
+        (WebFrame::stringByEvaluatingJavaScriptInScriptWorld):
+        * WebView.cpp:
+        (WebView::stringByEvaluatingJavaScriptFromString):
+
 2013-08-16  Andreas Kling  <akling@apple.com>
 
         Windows build juice.
index 29562cf..7ce70ee 100644 (file)
@@ -531,7 +531,7 @@ JSGlobalContextRef STDMETHODCALLTYPE WebFrame::globalContext()
     if (!coreFrame)
         return 0;
 
-    return toGlobalRef(coreFrame->script()->globalObject(mainThreadNormalWorld())->globalExec());
+    return toGlobalRef(coreFrame->script().globalObject(mainThreadNormalWorld())->globalExec());
 }
 
 JSGlobalContextRef WebFrame::globalContextForScriptWorld(IWebScriptWorld* iWorld)
@@ -544,7 +544,7 @@ JSGlobalContextRef WebFrame::globalContextForScriptWorld(IWebScriptWorld* iWorld
     if (!world)
         return 0;
 
-    return toGlobalRef(coreFrame->script()->globalObject(world->world())->globalExec());
+    return toGlobalRef(coreFrame->script().globalObject(world->world())->globalExec());
 }
 
 HRESULT STDMETHODCALLTYPE WebFrame::loadRequest( 
@@ -1897,8 +1897,8 @@ void WebFrame::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world)
     if (world != mainThreadNormalWorld())
         return;
 
-    JSContextRef context = toRef(coreFrame->script()->globalObject(world)->globalExec());
-    JSObjectRef windowObject = toRef(coreFrame->script()->globalObject(world));
+    JSContextRef context = toRef(coreFrame->script().globalObject(world)->globalExec());
+    JSObjectRef windowObject = toRef(coreFrame->script().globalObject(world));
     ASSERT(windowObject);
 
     if (FAILED(frameLoadDelegate->didClearWindowObject(d->webView, context, windowObject, this)))
@@ -2514,7 +2514,7 @@ HRESULT WebFrame::stringByEvaluatingJavaScriptInScriptWorld(IWebScriptWorld* iWo
     String string = String(script, SysStringLen(script));
 
     // Start off with some guess at a frame and a global object, we'll try to do better...!
-    JSDOMWindow* anyWorldGlobalObject = coreFrame->script()->globalObject(mainThreadNormalWorld());
+    JSDOMWindow* anyWorldGlobalObject = coreFrame->script().globalObject(mainThreadNormalWorld());
 
     // The global object is probably a shell object? - if so, we know how to use this!
     JSC::JSObject* globalObjectObj = toJS(globalObjectRef);
@@ -2524,7 +2524,7 @@ HRESULT WebFrame::stringByEvaluatingJavaScriptInScriptWorld(IWebScriptWorld* iWo
     // Get the frame frome the global object we've settled on.
     Frame* frame = anyWorldGlobalObject->impl()->frame();
     ASSERT(frame->document());
-    JSValue result = frame->script()->executeScriptInWorld(world->world(), string, true).jsValue();
+    JSValue result = frame->script().executeScriptInWorld(world->world(), string, true).jsValue();
 
     if (!frame) // In case the script removed our frame from the page.
         return S_OK;
index f2cbcd7..75522c3 100644 (file)
@@ -3268,11 +3268,11 @@ HRESULT STDMETHODCALLTYPE WebView::stringByEvaluatingJavaScriptFromString(
     if (!coreFrame)
         return E_FAIL;
 
-    JSC::JSValue scriptExecutionResult = coreFrame->script()->executeScript(WTF::String(script), true).jsValue();
+    JSC::JSValue scriptExecutionResult = coreFrame->script().executeScript(WTF::String(script), true).jsValue();
     if (!scriptExecutionResult)
         return E_FAIL;
     else if (scriptExecutionResult.isString()) {
-        JSC::ExecState* exec = coreFrame->script()->globalObject(mainThreadNormalWorld())->globalExec();
+        JSC::ExecState* exec = coreFrame->script().globalObject(mainThreadNormalWorld())->globalExec();
         JSC::JSLockHolder lock(exec);
         *result = BString(scriptExecutionResult.getString(exec));
     }
index 17e7b6d..eaf9ad3 100644 (file)
@@ -1,3 +1,28 @@
+2013-08-16  Pratik Solanki  <psolanki@apple.com>
+
+        <https://webkit.org/b/119852> Frame::scriptController() should return a reference
+
+        Reviewed by Andreas Kling.
+
+        m_script is never NULL so we can just return a reference. Also remove some pointless null
+        checks as a result of doing this.
+
+        * WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp:
+        (WebKit::NPRuntimeObjectMap::globalObject):
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::performJavaScriptURLRequest):
+        (WebKit::PluginView::windowScriptNPObject):
+        (WebKit::PluginView::pluginElementNPObject):
+        * WebProcess/WebPage/WebFrame.cpp:
+        (WebKit::WebFrame::jsContext):
+        (WebKit::WebFrame::jsContextForWorld):
+        (WebKit::WebFrame::jsWrapperForWorld):
+        * WebProcess/WebPage/WebInspector.cpp:
+        (WebKit::WebInspector::didSave):
+        (WebKit::WebInspector::didAppend):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::runJavaScriptInMainFrame):
+
 2013-08-16  Brady Eidson  <beidson@apple.com>
 
         (NetworkProcess)  Sync XHRs should load using async ResourceHandles, not ResourceHandle::loadResourceSynchronously
index 3b731f2..0461d27 100644 (file)
@@ -244,7 +244,7 @@ JSGlobalObject* NPRuntimeObjectMap::globalObject() const
     if (!frame)
         return 0;
 
-    return frame->script()->globalObject(pluginWorld());
+    return frame->script().globalObject(pluginWorld());
 }
 
 ExecState* NPRuntimeObjectMap::globalExec() const
index b59e681..4b6f3a8 100644 (file)
@@ -1176,7 +1176,7 @@ void PluginView::performJavaScriptURLRequest(URLRequest* request)
     // Evaluate the JavaScript code. Note that running JavaScript here could cause the plug-in to be destroyed, so we
     // grab references to the plug-in here.
     RefPtr<Plugin> plugin = m_plugin;
-    ScriptValue result = frame->script()->executeScript(jsString, request->allowPopups());
+    ScriptValue result = frame->script().executeScript(jsString, request->allowPopups());
 
     // Check if evaluating the JavaScript destroyed the plug-in.
     if (!plugin->controller())
@@ -1186,7 +1186,7 @@ void PluginView::performJavaScriptURLRequest(URLRequest* request)
     if (!request->target().isNull())
         return;
 
-    ScriptState* scriptState = frame->script()->globalObject(pluginWorld())->globalExec();
+    ScriptState* scriptState = frame->script().globalObject(pluginWorld())->globalExec();
     String resultString;
     result.getString(scriptState, resultString);
   
@@ -1359,12 +1359,12 @@ NPObject* PluginView::windowScriptNPObject()
     if (!frame())
         return 0;
 
-    if (!frame()->script()->canExecuteScripts(NotAboutToExecuteScript)) {
+    if (!frame()->script().canExecuteScripts(NotAboutToExecuteScript)) {
         // FIXME: Investigate if other browsers allow plug-ins to access JavaScript objects even if JavaScript is disabled.
         return 0;
     }
 
-    return m_npRuntimeObjectMap.getOrCreateNPObject(*pluginWorld()->vm(), frame()->script()->windowShell(pluginWorld())->window());
+    return m_npRuntimeObjectMap.getOrCreateNPObject(*pluginWorld()->vm(), frame()->script().windowShell(pluginWorld())->window());
 }
 
 NPObject* PluginView::pluginElementNPObject()
@@ -1372,12 +1372,12 @@ NPObject* PluginView::pluginElementNPObject()
     if (!frame())
         return 0;
 
-    if (!frame()->script()->canExecuteScripts(NotAboutToExecuteScript)) {
+    if (!frame()->script().canExecuteScripts(NotAboutToExecuteScript)) {
         // FIXME: Investigate if other browsers allow plug-ins to access JavaScript objects even if JavaScript is disabled.
         return 0;
     }
 
-    JSObject* object = frame()->script()->jsObjectForPluginElement(m_pluginElement.get());
+    JSObject* object = frame()->script().jsObjectForPluginElement(m_pluginElement.get());
     ASSERT(object);
 
     return m_npRuntimeObjectMap.getOrCreateNPObject(*pluginWorld()->vm(), object);
index 23904a2..bcec71d 100644 (file)
@@ -470,12 +470,12 @@ bool WebFrame::allowsFollowingLink(const WebCore::KURL& url) const
 
 JSGlobalContextRef WebFrame::jsContext()
 {
-    return toGlobalRef(m_coreFrame->script()->globalObject(mainThreadNormalWorld())->globalExec());
+    return toGlobalRef(m_coreFrame->script().globalObject(mainThreadNormalWorld())->globalExec());
 }
 
 JSGlobalContextRef WebFrame::jsContextForWorld(InjectedBundleScriptWorld* world)
 {
-    return toGlobalRef(m_coreFrame->script()->globalObject(world->coreWorld())->globalExec());
+    return toGlobalRef(m_coreFrame->script().globalObject(world->coreWorld())->globalExec());
 }
 
 bool WebFrame::handlesPageScaleGesture() const
@@ -649,7 +649,7 @@ JSValueRef WebFrame::jsWrapperForWorld(InjectedBundleNodeHandle* nodeHandle, Inj
     if (!m_coreFrame)
         return 0;
 
-    JSDOMWindow* globalObject = m_coreFrame->script()->globalObject(world->coreWorld());
+    JSDOMWindow* globalObject = m_coreFrame->script().globalObject(world->coreWorld());
     ExecState* exec = globalObject->globalExec();
 
     JSLockHolder lock(exec);
@@ -661,7 +661,7 @@ JSValueRef WebFrame::jsWrapperForWorld(InjectedBundleRangeHandle* rangeHandle, I
     if (!m_coreFrame)
         return 0;
 
-    JSDOMWindow* globalObject = m_coreFrame->script()->globalObject(world->coreWorld());
+    JSDOMWindow* globalObject = m_coreFrame->script().globalObject(world->coreWorld());
     ExecState* exec = globalObject->globalExec();
 
     JSLockHolder lock(exec);
index e4437d6..ba85400 100644 (file)
@@ -175,13 +175,13 @@ void WebInspector::close()
 void WebInspector::didSave(const String& url)
 {
     ASSERT(m_inspectorPage);
-    m_inspectorPage->corePage()->mainFrame()->script()->executeScript(makeString("InspectorFrontendAPI.savedURL(\"", url, "\")"));
+    m_inspectorPage->corePage()->mainFrame()->script().executeScript(makeString("InspectorFrontendAPI.savedURL(\"", url, "\")"));
 }
 
 void WebInspector::didAppend(const String& url)
 {
     ASSERT(m_inspectorPage);
-    m_inspectorPage->corePage()->mainFrame()->script()->executeScript(makeString("InspectorFrontendAPI.appendedToURL(\"", url, "\")"));
+    m_inspectorPage->corePage()->mainFrame()->script().executeScript(makeString("InspectorFrontendAPI.appendedToURL(\"", url, "\")"));
 }
 
 void WebInspector::attachedBottom()
index 2451aaa..1b21748 100644 (file)
@@ -2248,8 +2248,8 @@ void WebPage::runJavaScriptInMainFrame(const String& script, uint64_t callbackID
     CoreIPC::DataReference dataReference;
 
     JSLockHolder lock(JSDOMWindow::commonVM());
-    if (JSValue resultValue = m_mainFrame->coreFrame()->script()->executeScript(script, true).jsValue()) {
-        if ((serializedResultValue = SerializedScriptValue::create(m_mainFrame->jsContext(), toRef(m_mainFrame->coreFrame()->script()->globalObject(mainThreadNormalWorld())->globalExec(), resultValue), 0)))
+    if (JSValue resultValue = m_mainFrame->coreFrame()->script().executeScript(script, true).jsValue()) {
+        if ((serializedResultValue = SerializedScriptValue::create(m_mainFrame->jsContext(), toRef(m_mainFrame->coreFrame()->script().globalObject(mainThreadNormalWorld())->globalExec(), resultValue), 0)))
             dataReference = serializedResultValue->data();
     }
 
index dc8e5e8..d6d64b0 100644 (file)
@@ -1,3 +1,15 @@
+2013-08-16  Pratik Solanki  <psolanki@apple.com>
+
+        <https://webkit.org/b/119852> Frame::scriptController() should return a reference
+
+        Reviewed by Andreas Kling.
+
+        m_script is never NULL so we can just return a reference. Also remove some pointless null
+        checks as a result of doing this.
+
+        * DumpRenderTree/blackberry/DumpRenderTree.cpp:
+        (BlackBerry::WebKit::DumpRenderTree::resetToConsistentStateBeforeTesting):
+
 2013-08-15  Alexey Proskuryakov  <ap@apple.com>
 
         [WK2] NetworkProcess should use a temporary storage session for test
index 4f803af..fc7a517 100644 (file)
@@ -360,7 +360,7 @@ void DumpRenderTree::resetToConsistentStateBeforeTesting(const String& url, cons
             mainFrame->tree()->clearName();
             mainFrame->loader()->setOpener(0);
             // [WebKit bug #86899] Reset JS state settings.
-            JSGlobalContextRef jsContext = toGlobalRef(mainFrame->script()->globalObject(WebCore::mainThreadNormalWorld())->globalExec());
+            JSGlobalContextRef jsContext = toGlobalRef(mainFrame->script().globalObject(WebCore::mainThreadNormalWorld())->globalExec());
             WebCoreTestSupport::resetInternalsObject(jsContext);
         }
     }