Changeset 49372 in webkit
- Timestamp:
- Oct 8, 2009 10:08:51 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 31 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r49333 r49372 1 2009-10-08 Adam Barth <abarth@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 Move executeScript from FrameLoader to ScriptController 6 https://bugs.webkit.org/show_bug.cgi?id=30200 7 8 These methods have virtually no interaction with FrameLoader. They 9 really seem like they ought to belong to ScriptController. 10 11 * WebCore.base.exp: 12 * bindings/js/ScheduledAction.cpp: 13 (WebCore::ScheduledAction::execute): 14 * bindings/js/ScriptController.cpp: 15 (WebCore::ScriptController::ScriptController): 16 (WebCore::ScriptController::executeScript): 17 (WebCore::ScriptController::executeIfJavaScriptURL): 18 (WebCore::ScriptController::evaluate): 19 * bindings/js/ScriptController.h: 20 * bindings/v8/ScriptController.cpp: 21 (WebCore::ScriptController::ScriptController): 22 (WebCore::ScriptController::executeScript): 23 (WebCore::ScriptController::executeIfJavaScriptURL): 24 * bindings/v8/ScriptController.h: 25 * dom/XMLTokenizer.cpp: 26 (WebCore::XMLTokenizer::notifyFinished): 27 * dom/XMLTokenizerLibxml2.cpp: 28 (WebCore::XMLTokenizer::endElementNs): 29 * dom/XMLTokenizerQt.cpp: 30 (WebCore::XMLTokenizer::parseEndElement): 31 * html/HTMLTokenizer.cpp: 32 (WebCore::HTMLTokenizer::scriptExecution): 33 * loader/FrameLoader.cpp: 34 (WebCore::FrameLoader::changeLocation): 35 (WebCore::FrameLoader::urlSelected): 36 (WebCore::FrameLoader::requestFrame): 37 (WebCore::FrameLoader::submitForm): 38 (WebCore::FrameLoader::replaceDocument): 39 * loader/FrameLoader.h: 40 * plugins/PluginView.cpp: 41 (WebCore::PluginView::performRequest): 42 1 43 2009-10-08 Geoffrey Garen <ggaren@apple.com> 2 44 -
trunk/WebCore/GNUmakefile.am
r49291 r49372 477 477 WebCore/bindings/js/SerializedScriptValue.h \ 478 478 WebCore/bindings/js/StringSourceProvider.h \ 479 WebCore/bindings/ScriptControllerBase.cpp \ 479 480 WebCore/bridge/IdentifierRep.cpp \ 480 481 WebCore/bridge/IdentifierRep.h \ -
trunk/WebCore/WebCore.base.exp
r49212 r49372 157 157 __ZN7WebCore11FrameLoader11setEncodingERKNS_6StringEb 158 158 __ZN7WebCore11FrameLoader12shouldReloadERKNS_4KURLES3_ 159 __ZN7WebCore11FrameLoader13executeScriptERKNS_6StringEb160 159 __ZN7WebCore11FrameLoader14detachChildrenEv 161 160 __ZN7WebCore11FrameLoader14scrollToAnchorERKNS_4KURLE … … 377 376 __ZN7WebCore16NavigationActionC1Ev 378 377 __ZN7WebCore16ScriptController10initScriptEv 378 __ZN7WebCore16ScriptController13executeScriptERKNS_6StringEb 379 379 __ZN7WebCore16ScriptController18windowScriptObjectEv 380 380 __ZN7WebCore16VisibleSelectionC1EPKNS_5RangeENS_9EAffinityE -
trunk/WebCore/WebCore.gypi
r49309 r49372 625 625 'bindings/js/WorkerScriptController.cpp', 626 626 'bindings/js/WorkerScriptController.h', 627 'bindings/ScriptControllerBase.cpp', 627 628 'bindings/v8/ChildThreadDOMData.cpp', 628 629 'bindings/v8/ChildThreadDOMData.h', -
trunk/WebCore/WebCore.pro
r49290 r49372 768 768 bindings/js/ScheduledAction.cpp \ 769 769 bindings/js/SerializedScriptValue.cpp \ 770 bindings/ScriptControllerBase.cpp \ 770 771 bridge/IdentifierRep.cpp \ 771 772 bridge/NP_jsobject.cpp \ -
trunk/WebCore/WebCore.vcproj/WebCore.vcproj
r49290 r49372 29708 29708 </File> 29709 29709 </Filter> 29710 <File 29711 RelativePath="..\bindings\ScriptControllerBase.cpp" 29712 > 29713 </File> 29710 29714 </Filter> 29711 29715 <Filter -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r49317 r49372 2354 2354 97DD4D860FDF4D6E00ECF9A4 /* XSSAuditor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97DD4D840FDF4D6D00ECF9A4 /* XSSAuditor.cpp */; }; 2355 2355 97DD4D870FDF4D6E00ECF9A4 /* XSSAuditor.h in Headers */ = {isa = PBXBuildFile; fileRef = 97DD4D850FDF4D6E00ECF9A4 /* XSSAuditor.h */; }; 2356 97EF7DFE107E55B700D7C49C /* ScriptControllerBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97EF7DFD107E55B700D7C49C /* ScriptControllerBase.cpp */; }; 2356 2357 A17C81220F2A5CF7005DAAEB /* HTMLElementFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A17C81200F2A5CF7005DAAEB /* HTMLElementFactory.cpp */; }; 2357 2358 A17C81230F2A5CF7005DAAEB /* HTMLElementFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = A17C81210F2A5CF7005DAAEB /* HTMLElementFactory.h */; }; … … 7547 7548 97DD4D840FDF4D6D00ECF9A4 /* XSSAuditor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XSSAuditor.cpp; sourceTree = "<group>"; }; 7548 7549 97DD4D850FDF4D6E00ECF9A4 /* XSSAuditor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XSSAuditor.h; sourceTree = "<group>"; }; 7550 97EF7DFD107E55B700D7C49C /* ScriptControllerBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptControllerBase.cpp; sourceTree = "<group>"; }; 7549 7551 A17C81200F2A5CF7005DAAEB /* HTMLElementFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLElementFactory.cpp; sourceTree = "<group>"; }; 7550 7552 A17C81210F2A5CF7005DAAEB /* HTMLElementFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLElementFactory.h; sourceTree = "<group>"; }; … … 14166 14168 14813BF309EDF88E00F757E1 /* IDLParser.pm */, 14167 14169 93F8B3080A300FEA00F61AB8 /* IDLStructure.pm */, 14170 97EF7DFD107E55B700D7C49C /* ScriptControllerBase.cpp */, 14168 14171 ); 14169 14172 path = bindings; … … 19668 19671 416E75BF0EDF8FD700360E1D /* ScriptCallStack.cpp in Sources */, 19669 19672 93B70D6F09EB0C7C009D8468 /* ScriptController.cpp in Sources */, 19673 97EF7DFE107E55B700D7C49C /* ScriptControllerBase.cpp in Sources */, 19670 19674 A83E1C740E49042C00140B9C /* ScriptControllerMac.mm in Sources */, 19671 19675 08A484770E5272C500C3FE76 /* ScriptElement.cpp in Sources */, -
trunk/WebCore/WebCoreSources.bkl
r49012 r49372 162 162 bindings/js/JSWebKitCSSMatrixConstructor.cpp 163 163 bindings/js/JSWebKitPointConstructor.cpp 164 bindings/ScriptControllerBase.cpp 164 165 </set> 165 166 -
trunk/WebCore/bindings/js/ScheduledAction.cpp
r46431 r49372 126 126 Document::updateStyleForAllDocuments(); 127 127 } else 128 frame-> loader()->executeScript(m_code);128 frame->script()->executeScript(m_code); 129 129 130 130 frame->script()->setProcessingTimerCallback(false); -
trunk/WebCore/bindings/js/ScriptController.cpp
r48680 r49372 49 49 , m_handlerLineNumber(0) 50 50 , m_sourceURL(0) 51 , m_inExecuteScript(false) 51 52 , m_processingTimerCallback(false) 52 53 , m_paused(false) … … 85 86 const SourceCode& jsSourceCode = sourceCode.jsSourceCode(); 86 87 String sourceURL = jsSourceCode.provider()->url(); 87 88 88 89 if (!m_XSSAuditor->canEvaluate(sourceCode.source())) { 89 90 // This script is not safe to be evaluated. -
trunk/WebCore/bindings/js/ScriptController.h
r48057 r49372 81 81 } 82 82 83 ScriptValue executeScript(const ScriptSourceCode&); 84 ScriptValue executeScript(const String& script, bool forceUserGesture = false); 85 86 // Returns true if argument is a JavaScript URL. 87 bool executeIfJavaScriptURL(const KURL&, bool userGesture = false, bool replaceDocument = true); 88 83 89 ScriptValue evaluate(const ScriptSourceCode&); 84 90 void evaluateInIsolatedWorld(unsigned worldID, const Vector<ScriptSourceCode>&); … … 156 162 const String* m_sourceURL; 157 163 164 bool m_inExecuteScript; 165 158 166 bool m_processingTimerCallback; 159 167 bool m_paused; -
trunk/WebCore/bindings/v8/ScriptController.cpp
r49278 r49372 89 89 : m_frame(frame) 90 90 , m_sourceURL(0) 91 , m_inExecuteScript(false) 91 92 , m_processingTimerCallback(false) 92 93 , m_paused(false) -
trunk/WebCore/bindings/v8/ScriptController.h
r49278 r49372 59 59 // or this accessor should be made JSProxy* 60 60 V8Proxy* proxy() { return m_proxy.get(); } 61 62 ScriptValue executeScript(const ScriptSourceCode&); 63 ScriptValue executeScript(const String& script, bool forceUserGesture = false); 64 65 // Returns true if argument is a JavaScript URL. 66 bool executeIfJavaScriptURL(const KURL&, bool userGesture = false, bool replaceDocument = true); 61 67 62 68 // Evaluate a script file in the environment of this proxy. … … 163 169 const String* m_sourceURL; 164 170 171 bool m_inExecuteScript; 172 165 173 bool m_processingTimerCallback; 166 174 bool m_paused; -
trunk/WebCore/dom/XMLTokenizer.cpp
r47313 r49372 297 297 scriptElement->dispatchErrorEvent(); 298 298 else { 299 m_view->frame()-> loader()->executeScript(sourceCode);299 m_view->frame()->script()->executeScript(sourceCode); 300 300 scriptElement->dispatchLoadEvent(); 301 301 } -
trunk/WebCore/dom/XMLTokenizerLibxml2.cpp
r49208 r49372 863 863 m_scriptElement = 0; 864 864 } else 865 m_view->frame()-> loader()->executeScript(ScriptSourceCode(scriptElement->scriptContent(), m_doc->url(), m_scriptStartLine));865 m_view->frame()->script()->executeScript(ScriptSourceCode(scriptElement->scriptContent(), m_doc->url(), m_scriptStartLine)); 866 866 } 867 867 m_requestingScript = false; -
trunk/WebCore/dom/XMLTokenizerQt.cpp
r49020 r49372 622 622 m_scriptElement = 0; 623 623 } else 624 m_view->frame()-> loader()->executeScript(ScriptSourceCode(scriptElement->scriptContent(), m_doc->url(), m_scriptStartLine));624 m_view->frame()->script()->executeScript(ScriptSourceCode(scriptElement->scriptContent(), m_doc->url(), m_scriptStartLine)); 625 625 } 626 626 m_requestingScript = false; -
trunk/WebCore/html/HTMLTokenizer.cpp
r49194 r49372 562 562 563 563 m_state = state; 564 m_doc->frame()-> loader()->executeScript(sourceCode);564 m_doc->frame()->script()->executeScript(sourceCode); 565 565 state = m_state; 566 566 -
trunk/WebCore/loader/FrameLoader.cpp
r49320 r49372 176 176 , m_inStopAllLoaders(false) 177 177 , m_isExecutingJavaScriptFormAction(false) 178 , m_isRunningScript(false)179 178 , m_didCallImplicitClose(false) 180 179 , m_wasUnloadEventEmitted(false) … … 316 315 ResourceRequest request(url, referrer, refresh ? ReloadIgnoringCacheData : UseProtocolCachePolicy); 317 316 318 if ( executeIfJavaScriptURL(request.url(), userGesture))317 if (m_frame->script()->executeIfJavaScriptURL(request.url(), userGesture)) 319 318 return; 320 319 … … 324 323 void FrameLoader::urlSelected(const ResourceRequest& request, const String& passedTarget, PassRefPtr<Event> triggeringEvent, bool lockHistory, bool lockBackForwardList, bool userGesture) 325 324 { 326 if ( executeIfJavaScriptURL(request.url(), userGesture, false))325 if (m_frame->script()->executeIfJavaScriptURL(request.url(), userGesture, false)) 327 326 return; 328 327 … … 361 360 362 361 if (!scriptURL.isEmpty()) 363 frame-> loader()->executeIfJavaScriptURL(scriptURL);362 frame->script()->executeIfJavaScriptURL(scriptURL); 364 363 365 364 return true; … … 433 432 if (protocolIsJavaScript(u)) { 434 433 m_isExecutingJavaScriptFormAction = true; 435 executeIfJavaScriptURL(u, false, false);434 m_frame->script()->executeIfJavaScriptURL(u, false, false); 436 435 m_isExecutingJavaScriptFormAction = false; 437 436 return; … … 648 647 } 649 648 650 bool FrameLoader::executeIfJavaScriptURL(const KURL& url, bool userGesture, bool replaceDocument)651 {652 if (!protocolIsJavaScript(url))653 return false;654 655 if (m_frame->page() && !m_frame->page()->javaScriptURLsAreAllowed())656 return true;657 658 const int javascriptSchemeLength = sizeof("javascript:") - 1;659 660 String script = url.string().substring(javascriptSchemeLength);661 ScriptValue result;662 if (m_frame->script()->xssAuditor()->canEvaluateJavaScriptURL(script))663 result = executeScript(decodeURLEscapeSequences(script), userGesture);664 665 String scriptResult;666 if (!result.getString(scriptResult))667 return true;668 669 SecurityOrigin* currentSecurityOrigin = m_frame->document()->securityOrigin();670 671 // FIXME: We should always replace the document, but doing so672 // synchronously can cause crashes:673 // http://bugs.webkit.org/show_bug.cgi?id=16782674 if (replaceDocument) {675 stopAllLoaders();676 begin(m_URL, true, currentSecurityOrigin);677 write(scriptResult);678 end();679 }680 681 return true;682 }683 684 ScriptValue FrameLoader::executeScript(const String& script, bool forceUserGesture)685 {686 return executeScript(ScriptSourceCode(script, forceUserGesture ? KURL() : m_URL));687 }688 689 ScriptValue FrameLoader::executeScript(const ScriptSourceCode& sourceCode)690 {691 if (!m_frame->script()->isEnabled() || m_frame->script()->isPaused())692 return ScriptValue();693 694 bool wasRunningScript = m_isRunningScript;695 m_isRunningScript = true;696 697 ScriptValue result = m_frame->script()->evaluate(sourceCode);698 699 if (!wasRunningScript) {700 m_isRunningScript = false;701 Document::updateStyleForAllDocuments();702 }703 704 return result;705 }706 649 707 650 void FrameLoader::cancelAndClear() … … 714 657 clear(false); 715 658 m_frame->script()->updatePlatformScriptObjects(); 659 } 660 661 void FrameLoader::replaceDocument(const String& html) 662 { 663 stopAllLoaders(); 664 begin(m_URL, true, m_frame->document()->securityOrigin()); 665 write(html); 666 end(); 716 667 } 717 668 -
trunk/WebCore/loader/FrameLoader.h
r49290 r49372 232 232 KURL baseURL() const; 233 233 234 void replaceDocument(const String&); 235 234 236 void begin(); 235 237 void begin(const KURL&, bool dispatchWindowObjectAvailable = true, SecurityOrigin* forcedSecurityOrigin = 0); … … 242 244 void setEncoding(const String& encoding, bool userChosen); 243 245 String encoding() const; 244 245 ScriptValue executeScript(const ScriptSourceCode&);246 ScriptValue executeScript(const String& script, bool forceUserGesture = false);247 246 248 247 void gotoAnchor(); … … 452 451 Frame* loadSubframe(HTMLFrameOwnerElement*, const KURL&, const String& name, const String& referrer); 453 452 454 // Returns true if argument is a JavaScript URL.455 bool executeIfJavaScriptURL(const KURL&, bool userGesture = false, bool replaceDocument = true);456 457 453 bool gotoAnchor(const String& name); // returns true if the anchor was found 458 454 void scrollToAnchor(const KURL&); … … 500 496 501 497 bool m_isExecutingJavaScriptFormAction; 502 bool m_isRunningScript;503 498 504 499 String m_responseMIMEType; -
trunk/WebCore/plugins/PluginView.cpp
r49244 r49372 451 451 // Executing a script can cause the plugin view to be destroyed, so we keep a reference to the parent frame. 452 452 RefPtr<Frame> parentFrame = m_parentFrame; 453 JSValue result = m_parentFrame-> loader()->executeScript(jsString, request->shouldAllowPopups()).jsValue();453 JSValue result = m_parentFrame->script()->executeScript(jsString, request->shouldAllowPopups()).jsValue(); 454 454 455 455 if (targetFrameName.isNull()) { -
trunk/WebKit/gtk/ChangeLog
r49288 r49372 1 2009-10-08 Adam Barth <abarth@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 Move executeScript from FrameLoader to ScriptController 6 https://bugs.webkit.org/show_bug.cgi?id=30200 7 8 Update API call. 9 10 * webkit/webkitwebview.cpp: 11 (webkit_web_view_execute_script): 12 1 13 2009-10-07 Xan Lopez <xlopez@igalia.com> 2 14 -
trunk/WebKit/gtk/webkit/webkitwebview.cpp
r49069 r49372 3153 3153 g_return_if_fail(script); 3154 3154 3155 if (FrameLoader* loader = core(webView)->mainFrame()->loader()) 3156 loader->executeScript(String::fromUTF8(script), true); 3155 core(webView)->mainFrame()->script()->executeScript(String::fromUTF8(script), true); 3157 3156 } 3158 3157 -
trunk/WebKit/mac/ChangeLog
r49369 r49372 1 2009-10-08 Adam Barth <abarth@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 Move executeScript from FrameLoader to ScriptController 6 https://bugs.webkit.org/show_bug.cgi?id=30200 7 8 Update API call. 9 10 * WebView/WebFrame.mm: 11 (-[WebFrame _stringByEvaluatingJavaScriptFromString:forceUserGesture:]): 12 * WebView/WebView.mm: 13 (-[WebView aeDescByEvaluatingJavaScriptFromString:]): 14 1 15 2009-10-08 Brady Eidson <beidson@apple.com> 2 16 -
trunk/WebKit/mac/WebView/WebFrame.mm
r49212 r49372 596 596 ASSERT(_private->coreFrame->document()); 597 597 598 JSValue result = _private->coreFrame-> loader()->executeScript(string, forceUserGesture).jsValue();598 JSValue result = _private->coreFrame->script()->executeScript(string, forceUserGesture).jsValue(); 599 599 600 600 if (!_private->coreFrame) // In case the script removed our frame from the page. -
trunk/WebKit/mac/WebView/WebView.mm
r49369 r49372 4097 4097 if (!coreFrame->document()) 4098 4098 return nil; 4099 JSValue result = coreFrame-> loader()->executeScript(script, true).jsValue();4099 JSValue result = coreFrame->script()->executeScript(script, true).jsValue(); 4100 4100 if (!result) // FIXME: pass errors 4101 4101 return 0; -
trunk/WebKit/qt/Api/qwebframe.cpp
r49020 r49372 1252 1252 QVariant rc; 1253 1253 if (proxy) { 1254 JSC::JSValue v = d->frame-> loader()->executeScript(ScriptSourceCode(scriptSource)).jsValue();1254 JSC::JSValue v = d->frame->script()->executeScript(ScriptSourceCode(scriptSource)).jsValue(); 1255 1255 int distance = 0; 1256 1256 rc = JSC::Bindings::convertValueToQVariant(proxy->globalObject()->globalExec(), v, QMetaType::Void, &distance); -
trunk/WebKit/qt/ChangeLog
r49294 r49372 1 2009-10-08 Adam Barth <abarth@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 Move executeScript from FrameLoader to ScriptController 6 https://bugs.webkit.org/show_bug.cgi?id=30200 7 8 Update API call. 9 10 * Api/qwebframe.cpp: 11 (QWebFrame::evaluateJavaScript): 12 1 13 2009-10-08 Jedrzej Nowacki <jedrzej.nowacki@nokia.com> 2 14 -
trunk/WebKit/win/ChangeLog
r49320 r49372 1 2009-10-08 Adam Barth <abarth@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 Move executeScript from FrameLoader to ScriptController 6 https://bugs.webkit.org/show_bug.cgi?id=30200 7 8 Update API call. 9 10 * WebView.cpp: 11 (WebView::stringByEvaluatingJavaScriptFromString): 12 1 13 2009-10-08 Anders Carlsson <andersca@apple.com> 2 14 -
trunk/WebKit/win/WebView.cpp
r49305 r49372 2866 2866 return E_FAIL; 2867 2867 2868 JSC::JSValue scriptExecutionResult = coreFrame-> loader()->executeScript(WebCore::String(script), true).jsValue();2868 JSC::JSValue scriptExecutionResult = coreFrame->script()->executeScript(WebCore::String(script), true).jsValue(); 2869 2869 if (!scriptExecutionResult) 2870 2870 return E_FAIL; -
trunk/WebKit/wx/ChangeLog
r49284 r49372 1 2009-10-08 Adam Barth <abarth@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 Move executeScript from FrameLoader to ScriptController 6 https://bugs.webkit.org/show_bug.cgi?id=30200 7 8 Update API call. 9 10 * WebFrame.cpp: 11 (wxWebFrame::RunScript): 12 1 13 2009-10-07 Adam Barth <abarth@webkit.org> 2 14 -
trunk/WebKit/wx/WebFrame.cpp
r48347 r49372 189 189 wxString returnValue = wxEmptyString; 190 190 if (m_impl->frame) { 191 JSC::JSValue result = m_impl->frame-> loader()->executeScript(javascript, true).jsValue();191 JSC::JSValue result = m_impl->frame->script()->executeScript(javascript, true).jsValue(); 192 192 if (result) 193 193 returnValue = wxString(result.toString(m_impl->frame->script()->globalObject()->globalExec()).UTF8String().c_str(), wxConvUTF8);
Note: See TracChangeset
for help on using the changeset viewer.