Changeset 38729 in webkit
- Timestamp:
- Nov 24, 2008 3:07:38 PM (15 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 1 added
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r38728 r38729 1 2008-11-24 Darin Fisher <darin@chromium.org> 2 3 Reviewed by Sam Weinig. 4 5 https://bugs.webkit.org/show_bug.cgi?id=22448 6 Create an abstraction for JSC::SourceCode 7 8 * WebCore.vcproj/WebCore.vcproj: 9 * bindings/js/CachedScriptSourceProvider.h: 10 * bindings/js/ScriptController.cpp: 11 (WebCore::ScriptController::evaluate): 12 * bindings/js/ScriptController.h: 13 * bindings/js/ScriptSourceCode.h: Added. 14 (WebCore::ScriptSourceCode::ScriptSourceCode): 15 (WebCore::ScriptSourceCode::length): 16 (WebCore::ScriptSourceCode::jsSourceCode): 17 * bindings/js/WorkerScriptController.cpp: 18 (WebCore::Workevn ScriptController::evaluate): 19 * bindings/js/WorkerScriptController.h: 20 * dom/ScriptElement.cpp: 21 (WebCore::ScriptElement::insertedIntoDocument): 22 (WebCore::ScriptElement::childrenChanged): 23 (WebCore::ScriptElementData::evaluateScript): 24 (WebCore::ScriptElementData::notifyFinished): 25 * dom/ScriptElement.h: 26 * dom/WorkerThread.cpp: 27 (WebCore::WorkerThread::workerThread): 28 * dom/WorkerThread.h: 29 * dom/XMLTokenizer.cpp: 30 (WebCore::XMLTokenizer::notifyFinished): 31 * dom/XMLTokenizerLibxml2.cpp: 32 (WebCore::XMLTokenizer::endElementNs): 33 * dom/XMLTokenizerQt.cpp: 34 (WebCore::XMLTokenizer::parseEndElement): 35 * html/HTMLTokenizer.cpp: 36 (WebCore::HTMLTokenizer::scriptHandler): 37 (WebCore::HTMLTokenizer::scriptExecution): 38 (WebCore::HTMLTokenizer::notifyFinished): 39 * html/HTMLTokenizer.h: 40 * loader/FrameLoader.cpp: 41 (WebCore::FrameLoader::executeScript): 42 * loader/FrameLoader.h: 43 1 44 2008-11-24 Darin Adler <darin@apple.com> 2 45 -
trunk/WebCore/WebCore.vcproj/WebCore.vcproj
r38698 r38729 13882 13882 </File> 13883 13883 <File 13884 RelativePath="..\bindings\js\ScriptSourceCode.h" 13885 > 13886 </File> 13887 <File 13884 13888 RelativePath="..\bindings\js\ScriptString.h" 13885 13889 > -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r38698 r38729 1802 1802 934CC0E10ED39D6F00A658F2 /* ScriptValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 934CC0DF0ED39D6F00A658F2 /* ScriptValue.cpp */; }; 1803 1803 934CC0E20ED39D6F00A658F2 /* ScriptValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 934CC0E00ED39D6F00A658F2 /* ScriptValue.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1804 934CC10A0EDB223900A658F2 /* ScriptSourceCode.h in Headers */ = {isa = PBXBuildFile; fileRef = 934CC1090EDB223900A658F2 /* ScriptSourceCode.h */; }; 1804 1805 934D9BA50B8C116B007B42A9 /* WebCoreNSStringExtras.mm in Sources */ = {isa = PBXBuildFile; fileRef = 934D9BA40B8C116B007B42A9 /* WebCoreNSStringExtras.mm */; }; 1805 1806 934D9BA70B8C1175007B42A9 /* WebCoreNSStringExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 934D9BA60B8C1175007B42A9 /* WebCoreNSStringExtras.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 6583 6584 934CC0DF0ED39D6F00A658F2 /* ScriptValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptValue.cpp; sourceTree = "<group>"; }; 6584 6585 934CC0E00ED39D6F00A658F2 /* ScriptValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptValue.h; sourceTree = "<group>"; }; 6586 934CC1090EDB223900A658F2 /* ScriptSourceCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptSourceCode.h; sourceTree = "<group>"; }; 6585 6587 934D9BA40B8C116B007B42A9 /* WebCoreNSStringExtras.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreNSStringExtras.mm; sourceTree = "<group>"; }; 6586 6588 934D9BA60B8C1175007B42A9 /* WebCoreNSStringExtras.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebCoreNSStringExtras.h; sourceTree = "<group>"; }; … … 13068 13070 93B70D5409EB0C7C009D8468 /* ScriptController.h */, 13069 13071 A83E1C720E49042B00140B9C /* ScriptControllerMac.mm */, 13072 934CC1090EDB223900A658F2 /* ScriptSourceCode.h */, 13070 13073 416F45EF0ED7B311008215B6 /* ScriptString.h */, 13071 13074 934CC0DF0ED39D6F00A658F2 /* ScriptValue.cpp */, … … 16389 16392 080AEC820ED8708B00DF4CCE /* WMLIntrinsicEvent.h in Headers */, 16390 16393 080AEC840ED8708B00DF4CCE /* WMLIntrinsicEventHandler.h in Headers */, 16394 934CC10A0EDB223900A658F2 /* ScriptSourceCode.h in Headers */, 16391 16395 ); 16392 16396 runOnlyForDeploymentPostprocessing = 0; -
trunk/WebCore/bindings/js/CachedScriptSourceProvider.h
r38664 r38729 29 29 #include "CachedResourceClient.h" 30 30 #include "CachedResourceHandle.h" 31 #include "CachedScript.h" 31 32 #include <parser/SourceCode.h> 32 33 -
trunk/WebCore/bindings/js/ScriptController.cpp
r38654 r38729 39 39 #include "PausedTimeouts.h" 40 40 #include "runtime_root.h" 41 #include "ScriptSourceCode.h" 41 42 #include "ScriptValue.h" 42 43 #include "Settings.h" 43 #include "StringSourceProvider.h"44 44 45 45 #include <runtime/Completion.h> … … 89 89 } 90 90 91 ScriptValue ScriptController::evaluate(const JSC::SourceCode& sourceCode)91 ScriptValue ScriptController::evaluate(const ScriptSourceCode& sourceCode) 92 92 { 93 93 // evaluate code. Returns the JS return value or 0 94 94 // if there was none, an error occured or the type couldn't be converted. 95 96 const SourceCode& jsSourceCode = sourceCode.jsSourceCode(); 95 97 96 98 initScriptIfNeeded(); … … 101 103 ExecState* exec = m_windowShell->window()->globalExec(); 102 104 const String* savedSourceURL = m_sourceURL; 103 String sourceURL = sourceCode.provider()->url();105 String sourceURL = jsSourceCode.provider()->url(); 104 106 m_sourceURL = &sourceURL; 105 107 … … 111 113 112 114 m_windowShell->window()->startTimeoutCheck(); 113 Completion comp = JSC::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), sourceCode, m_windowShell);115 Completion comp = JSC::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), jsSourceCode, m_windowShell); 114 116 m_windowShell->window()->stopTimeoutCheck(); 115 117 -
trunk/WebCore/bindings/js/ScriptController.h
r38654 r38729 41 41 namespace JSC { 42 42 class JSGlobalObject; 43 class SourceCode;44 43 45 44 namespace Bindings { … … 56 55 class Frame; 57 56 class Node; 57 class ScriptSourceCode; 58 58 class ScriptValue; 59 59 class String; … … 80 80 } 81 81 82 ScriptValue evaluate(const JSC::SourceCode&);82 ScriptValue evaluate(const ScriptSourceCode&); 83 83 84 84 PassRefPtr<EventListener> createInlineEventListener(const String& functionName, const String& code, Node*); -
trunk/WebCore/bindings/js/ScriptString.h
r38680 r38729 1 1 /* 2 * Copyright (c) 2008, Google Inc. 3 * All rights reserved. 2 * Copyright (c) 2008, Google Inc. All rights reserved. 4 3 * 5 4 * Redistribution and use in source and binary forms, with or without -
trunk/WebCore/bindings/js/ScriptValue.h
r38610 r38729 1 1 /* 2 * Copyright (c) 2008, Google Inc. 3 * All rights reserved. 2 * Copyright (c) 2008, Google Inc. All rights reserved. 4 3 * 5 4 * Redistribution and use in source and binary forms, with or without -
trunk/WebCore/bindings/js/WorkerScriptController.cpp
r38689 r38729 33 33 #include "JSDOMBinding.h" 34 34 #include "JSWorkerContext.h" 35 #include "ScriptSourceCode.h" 36 #include "ScriptValue.h" 35 37 #include "WorkerContext.h" 36 38 #include "WorkerMessagingProxy.h" 37 39 #include "WorkerThread.h" 38 40 #include <interpreter/Interpreter.h> 39 #include <parser/SourceCode.h>40 41 #include <runtime/Completion.h> 41 42 #include <runtime/Completion.h> … … 71 72 } 72 73 73 JSValue* WorkerScriptController::evaluate(const JSC::SourceCode& sourceCode)74 ScriptValue WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode) 74 75 { 75 76 { … … 84 85 ExecState* exec = m_workerContextWrapper->globalExec(); 85 86 m_workerContextWrapper->startTimeoutCheck(); 86 Completion comp = JSC::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), sourceCode , m_workerContextWrapper);87 Completion comp = JSC::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), sourceCode.jsSourceCode(), m_workerContextWrapper); 87 88 m_workerContextWrapper->stopTimeoutCheck(); 88 89 -
trunk/WebCore/bindings/js/WorkerScriptController.h
r38689 r38729 36 36 namespace JSC { 37 37 class JSGlobalData; 38 class JSValue;39 class SourceCode;40 38 } 41 39 … … 43 41 44 42 class JSWorkerContext; 43 class ScriptSourceCode; 44 class ScriptValue; 45 45 class String; 46 46 class WorkerContext; … … 57 57 } 58 58 59 JSC::JSValue* evaluate(const JSC::SourceCode&);59 ScriptValue evaluate(const ScriptSourceCode&); 60 60 61 61 void forbidExecution(); -
trunk/WebCore/dom/ScriptElement.cpp
r38664 r38729 26 26 27 27 #include "CachedScript.h" 28 #include "CachedScriptSourceProvider.h"29 28 #include "DocLoader.h" 30 29 #include "Document.h" … … 33 32 #include "MIMETypeRegistry.h" 34 33 #include "ScriptController.h" 34 #include "ScriptSourceCode.h" 35 35 #include "ScriptValue.h" 36 36 #include "StringHash.h" 37 #include "StringSourceProvider.h"38 37 #include "Text.h" 39 38 #include <wtf/StdLibExtras.h> 40 41 using namespace JSC;42 39 43 40 namespace WebCore { … … 56 53 // because if a script is inserted afterwards (by setting text or innerText) 57 54 // it should be evaluated, and evaluateScript only evaluates a script once. 58 data.evaluateScript( makeSource(data.scriptContent(), data.element()->document()->url().string())); // FIXME: Provide a real starting line number here.55 data.evaluateScript(ScriptSourceCode(data.scriptContent(), data.element()->document()->url())); // FIXME: Provide a real starting line number here. 59 56 } 60 57 … … 76 73 // we evaluate the script. 77 74 if (element->inDocument() && element->firstChild()) 78 data.evaluateScript( makeSource(data.scriptContent(), element->document()->url().string())); // FIXME: Provide a real starting line number here75 data.evaluateScript(ScriptSourceCode(data.scriptContent(), element->document()->url())); // FIXME: Provide a real starting line number here 79 76 } 80 77 … … 163 160 } 164 161 165 void ScriptElementData::evaluateScript(const S ourceCode& sourceCode)166 { 167 if (m_evaluated || !sourceCode.length() || !shouldExecuteAsJavaScript())162 void ScriptElementData::evaluateScript(const ScriptSourceCode& sourceCode) 163 { 164 if (m_evaluated || sourceCode.isEmpty() || !shouldExecuteAsJavaScript()) 168 165 return; 169 166 … … 199 196 m_scriptElement->dispatchErrorEvent(); 200 197 else { 201 evaluateScript( makeSource(cs));198 evaluateScript(ScriptSourceCode(cs)); 202 199 m_scriptElement->dispatchLoadEvent(); 203 200 } -
trunk/WebCore/dom/ScriptElement.h
r38654 r38729 25 25 #include "CachedResourceHandle.h" 26 26 27 namespace JSC {28 class SourceCode;29 }30 31 27 namespace WebCore { 32 28 … … 34 30 class Element; 35 31 class ScriptElementData; 32 class ScriptSourceCode; 36 33 37 34 class ScriptElement { … … 82 79 83 80 void requestScript(const String& sourceUrl); 84 void evaluateScript(const JSC::SourceCode&);81 void evaluateScript(const ScriptSourceCode&); 85 82 void stopLoadRequest(); 86 83 -
trunk/WebCore/dom/WorkerThread.cpp
r38711 r38729 32 32 33 33 #include "JSWorkerContext.h" 34 #include "StringSourceProvider.h" 34 #include "ScriptSourceCode.h" 35 #include "ScriptValue.h" 35 36 #include "Worker.h" 36 37 #include "WorkerContext.h" 37 38 #include "WorkerMessagingProxy.h" 38 39 #include "WorkerTask.h" 39 40 using namespace JSC;41 40 42 41 namespace WebCore { … … 79 78 // Mutex protection is necessary because stop() can be called before the context is fully created. 80 79 MutexLocker lock(m_workerContextMutex); 81 m_workerContext = WorkerContext::create( KURL(m_scriptURL), this);80 m_workerContext = WorkerContext::create(m_scriptURL, this); 82 81 } 83 82 84 83 WorkerScriptController* script = m_workerContext->script(); 85 script->evaluate( makeSource(m_sourceCode, m_scriptURL));84 script->evaluate(ScriptSourceCode(m_sourceCode, m_scriptURL)); 86 85 m_messagingProxy->confirmWorkerThreadMessage(m_workerContext->hasPendingActivity()); // This wasn't really a message, but it counts as one for GC. 87 86 -
trunk/WebCore/dom/WorkerThread.h
r38711 r38729 30 30 #if ENABLE(WORKERS) 31 31 32 #include " PlatformString.h"32 #include "KURL.h" 33 33 #include <wtf/MessageQueue.h> 34 34 #include <wtf/PassRefPtr.h> … … 36 36 namespace WebCore { 37 37 38 class KURL;39 38 class WorkerContext; 40 39 class WorkerMessagingProxy; … … 62 61 ThreadIdentifier m_threadID; 63 62 64 Stringm_scriptURL;63 KURL m_scriptURL; 65 64 String m_sourceCode; 66 65 WorkerMessagingProxy* m_messagingProxy; -
trunk/WebCore/dom/XMLTokenizer.cpp
r38664 r38729 30 30 #include "CString.h" 31 31 #include "CachedScript.h" 32 #include "CachedScriptSourceProvider.h"33 32 #include "Comment.h" 34 33 #include "DocLoader.h" … … 49 48 #include "ResourceResponse.h" 50 49 #include "ScriptController.h" 50 #include "ScriptSourceCode.h" 51 51 #include "ScriptValue.h" 52 52 #include "StringSourceProvider.h" … … 327 327 ASSERT(m_pendingScript->accessCount() > 0); 328 328 329 JSC::SourceCode sourceCode = makeSource(m_pendingScript.get());329 ScriptSourceCode sourceCode(m_pendingScript.get()); 330 330 bool errorOccurred = m_pendingScript->errorOccurred(); 331 331 -
trunk/WebCore/dom/XMLTokenizerLibxml2.cpp
r38654 r38729 48 48 #include "ScriptController.h" 49 49 #include "ScriptElement.h" 50 #include "ScriptSourceCode.h" 50 51 #include "ScriptValue.h" 51 #include "StringSourceProvider.h"52 52 #include "TextResourceDecoder.h" 53 53 #include <libxml/parser.h> … … 808 808 m_scriptElement = 0; 809 809 } else 810 m_view->frame()->loader()->executeScript( makeSource(scriptElement->scriptContent(), m_doc->url().string(), m_scriptStartLine));810 m_view->frame()->loader()->executeScript(ScriptSourceCode(scriptElement->scriptContent(), m_doc->url(), m_scriptStartLine)); 811 811 812 812 m_requestingScript = false; -
trunk/WebCore/dom/XMLTokenizerQt.cpp
r38654 r38729 48 48 #include "ScriptController.h" 49 49 #include "ScriptElement.h" 50 #include "ScriptSourceCode.h" 50 51 #include "ScriptValue.h" 51 #include "StringSourceProvider.h"52 52 #include "TextResourceDecoder.h" 53 53 #include <QDebug> … … 586 586 m_scriptElement = 0; 587 587 } else 588 m_view->frame()->loader()->executeScript( makeSource(scriptElement->scriptContent(), m_doc->url().string(), m_scriptStartLine));588 m_view->frame()->loader()->executeScript(ScriptSourceCode(scriptElement->scriptContent(), m_doc->url(), m_scriptStartLine)); 589 589 590 590 m_requestingScript = false; -
trunk/WebCore/html/HTMLTokenizer.cpp
r38664 r38729 31 31 #include "Cache.h" 32 32 #include "CachedScript.h" 33 #include "CachedScriptSourceProvider.h"34 33 #include "DocLoader.h" 35 34 #include "DocumentFragment.h" … … 46 45 #include "PreloadScanner.h" 47 46 #include "ScriptController.h" 47 #include "ScriptSourceCode.h" 48 48 #include "ScriptValue.h" 49 #include "StringSourceProvider.h"50 49 #include "SystemTime.h" 51 50 #include <wtf/ASCIICType.h> … … 56 55 // #define INSTRUMENT_LAYOUT_SCHEDULING 1 57 56 58 using namespace JSC;59 57 using namespace WTF; 60 58 using namespace std; … … 504 502 prependingSrc = m_src; 505 503 setSrc(SegmentedString()); 506 state = scriptExecution( makeSource(scriptString, m_doc->frame() ? m_doc->frame()->document()->url().string() : String(), startLine), state);504 state = scriptExecution(ScriptSourceCode(scriptString, m_doc->frame() ? m_doc->frame()->document()->url() : KURL(), startLine), state); 507 505 } 508 506 } … … 546 544 } 547 545 548 HTMLTokenizer::State HTMLTokenizer::scriptExecution(const S ourceCode& sourceCode, State state)546 HTMLTokenizer::State HTMLTokenizer::scriptExecution(const ScriptSourceCode& sourceCode, State state) 549 547 { 550 548 if (m_fragment || !m_doc->frame()) … … 1970 1968 // make sure we forget about the script before we execute the new one 1971 1969 // infinite recursion might happen otherwise 1972 JSC::SourceCode sourceCode = makeSource(cs);1970 ScriptSourceCode sourceCode(cs); 1973 1971 bool errorOccurred = cs->errorOccurred(); 1974 1972 cs->removeClient(this); -
trunk/WebCore/html/HTMLTokenizer.h
r38654 r38729 34 34 #include <wtf/OwnPtr.h> 35 35 #include <wtf/Vector.h> 36 37 namespace JSC {38 class SourceCode;39 }40 36 41 37 namespace WebCore { … … 51 47 class Node; 52 48 class PreloadScanner; 49 class ScriptSourceCode; 53 50 54 51 /** … … 182 179 State parseProcessingInstruction(SegmentedString&, State); 183 180 State scriptHandler(State); 184 State scriptExecution(const JSC::SourceCode&, State);181 State scriptExecution(const ScriptSourceCode&, State); 185 182 void setSrc(const SegmentedString&); 186 183 -
trunk/WebCore/loader/FrameLoader.cpp
r38654 r38729 81 81 #include "ResourceRequest.h" 82 82 #include "ScriptController.h" 83 #include "ScriptSourceCode.h" 83 84 #include "ScriptValue.h" 84 85 #include "SecurityOrigin.h" 85 86 #include "SegmentedString.h" 86 87 #include "Settings.h" 87 #include "StringSourceProvider.h"88 88 #include "SystemTime.h" 89 89 #include "TextResourceDecoder.h" … … 91 91 #include "XMLHttpRequest.h" 92 92 #include "XMLTokenizer.h" 93 #include <runtime/JSLock.h>94 #include <runtime/JSObject.h>95 93 #include <wtf/StdLibExtras.h> 96 94 … … 109 107 #include "SVGViewSpec.h" 110 108 #endif 111 112 using namespace JSC;113 109 114 110 namespace WebCore { … … 777 773 ScriptValue FrameLoader::executeScript(const String& script, bool forceUserGesture) 778 774 { 779 return executeScript( makeSource(script, forceUserGesture ? String() : m_URL.string()));780 } 781 782 ScriptValue FrameLoader::executeScript(const S ourceCode& sourceCode)775 return executeScript(ScriptSourceCode(script, forceUserGesture ? KURL() : m_URL)); 776 } 777 778 ScriptValue FrameLoader::executeScript(const ScriptSourceCode& sourceCode) 783 779 { 784 780 if (!m_frame->script()->isEnabled() || m_frame->script()->isPaused()) -
trunk/WebCore/loader/FrameLoader.h
r38654 r38729 50 50 #endif 51 51 52 namespace JSC {53 class SourceCode;54 }55 56 52 namespace WebCore { 57 53 … … 80 76 class ResourceRequest; 81 77 class ResourceResponse; 78 class ScriptSourceCode; 82 79 class ScriptValue; 83 80 class SecurityOrigin; … … 340 337 bool executeIfJavaScriptURL(const KURL& url, bool userGesture = false, bool replaceDocument = true); 341 338 342 ScriptValue executeScript(const JSC::SourceCode&);339 ScriptValue executeScript(const ScriptSourceCode&); 343 340 ScriptValue executeScript(const String& script, bool forceUserGesture = false); 344 341
Note: See TracChangeset
for help on using the changeset viewer.