Changeset 38654 in webkit
- Timestamp:
- Nov 20, 2008 9:51:28 PM (15 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r38653 r38654 1 2008-11-20 Sam Weinig <sam@webkit.org> 2 3 Reviewed by Geoffrey Garen. 4 5 First step in https://bugs.webkit.org/show_bug.cgi?id=22394 6 Be more eager in destroying script decoded data 7 8 Pass data to be used in script execution around as JSC::SourceCode instead 9 of a source, url, and starting line. 10 11 * bindings/js/ScriptController.cpp: 12 (WebCore::ScriptController::evaluate): 13 * bindings/js/ScriptController.h: 14 * bindings/js/StringSourceProvider.h: 15 (WebCore::makeSource): 16 * bindings/js/WorkerScriptController.cpp: 17 (WebCore::WorkerScriptController::evaluate): 18 * bindings/js/WorkerScriptController.h: 19 * dom/ScriptElement.cpp: 20 (WebCore::ScriptElement::insertedIntoDocument): 21 (WebCore::ScriptElement::childrenChanged): 22 (WebCore::ScriptElementData::evaluateScript): 23 (WebCore::ScriptElementData::notifyFinished): 24 * dom/ScriptElement.h: 25 * dom/WorkerThread.cpp: 26 (WebCore::WorkerThread::workerThread): 27 * dom/XMLTokenizer.cpp: 28 (WebCore::XMLTokenizer::notifyFinished): 29 * dom/XMLTokenizerLibxml2.cpp: 30 (WebCore::XMLTokenizer::endElementNs): 31 * dom/XMLTokenizerQt.cpp: 32 (WebCore::XMLTokenizer::parseEndElement): 33 * html/HTMLTokenizer.cpp: 34 (WebCore::HTMLTokenizer::scriptHandler): 35 (WebCore::HTMLTokenizer::scriptExecution): 36 (WebCore::HTMLTokenizer::notifyFinished): 37 * html/HTMLTokenizer.h: 38 * loader/FrameLoader.cpp: 39 (WebCore::FrameLoader::executeScript): 40 * loader/FrameLoader.h: 41 1 42 2008-11-20 Sam Weinig <sam@webkit.org> 2 43 -
trunk/WebCore/bindings/js/ScriptController.cpp
r38610 r38654 89 89 } 90 90 91 ScriptValue ScriptController::evaluate(const String& sourceURL, int baseLine, const String& str)91 ScriptValue ScriptController::evaluate(const JSC::SourceCode& sourceCode) 92 92 { 93 93 // evaluate code. Returns the JS return value or 0 … … 101 101 ExecState* exec = m_windowShell->window()->globalExec(); 102 102 const String* savedSourceURL = m_sourceURL; 103 String sourceURL = sourceCode.provider()->url(); 103 104 m_sourceURL = &sourceURL; 104 105 … … 110 111 111 112 m_windowShell->window()->startTimeoutCheck(); 112 Completion comp = JSC::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), makeSource(str, sourceURL, baseLine), m_windowShell);113 Completion comp = JSC::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), sourceCode, m_windowShell); 113 114 m_windowShell->window()->stopTimeoutCheck(); 114 115 -
trunk/WebCore/bindings/js/ScriptController.h
r38610 r38654 41 41 namespace JSC { 42 42 class JSGlobalObject; 43 class SourceCode; 43 44 44 45 namespace Bindings { … … 79 80 } 80 81 81 ScriptValue evaluate(const String& sourceURL, int baseLine, const String& code);82 ScriptValue evaluate(const JSC::SourceCode&); 82 83 83 84 PassRefPtr<EventListener> createInlineEventListener(const String& functionName, const String& code, Node*); -
trunk/WebCore/bindings/js/StringSourceProvider.h
r38205 r38654 52 52 }; 53 53 54 inline JSC::SourceCode makeSource(const String& source, const JSC::UString& url = JSC::UString(), int firstLine = 1)54 inline JSC::SourceCode makeSource(const String& source, const String& url = String(), int firstLine = 1) 55 55 { 56 56 return JSC::SourceCode(StringSourceProvider::create(source, url), firstLine); 57 57 } 58 }59 58 60 #endif 59 } // namespace WebCore 60 61 #endif // StringSourceProvider_h -
trunk/WebCore/bindings/js/WorkerScriptController.cpp
r38595 r38654 69 69 } 70 70 71 JSValue* WorkerScriptController::evaluate(const String& sourceURL, int baseLine, const String& code)71 JSValue* WorkerScriptController::evaluate(const JSC::SourceCode& sourceCode) 72 72 { 73 73 initScriptIfNeeded(); … … 76 76 ExecState* exec = m_workerContextWrapper->globalExec(); 77 77 m_workerContextWrapper->startTimeoutCheck(); 78 Completion comp = JSC::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), makeSource(code, sourceURL, baseLine), m_workerContextWrapper);78 Completion comp = JSC::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), sourceCode, m_workerContextWrapper); 79 79 m_workerContextWrapper->stopTimeoutCheck(); 80 80 -
trunk/WebCore/bindings/js/WorkerScriptController.h
r38365 r38654 36 36 class JSGlobalData; 37 37 class JSValue; 38 class SourceCode; 38 39 } 39 40 … … 55 56 } 56 57 57 JSC::JSValue* evaluate(const String& sourceURL, int baseLine, const String& code);58 JSC::JSValue* evaluate(const JSC::SourceCode&); 58 59 59 60 private: -
trunk/WebCore/dom/ScriptElement.cpp
r38610 r38654 34 34 #include "ScriptValue.h" 35 35 #include "StringHash.h" 36 #include "StringSourceProvider.h" 36 37 #include "Text.h" 37 38 #include <wtf/StdLibExtras.h> 39 40 using namespace JSC; 38 41 39 42 namespace WebCore { … … 52 55 // because if a script is inserted afterwards (by setting text or innerText) 53 56 // it should be evaluated, and evaluateScript only evaluates a script once. 54 data.evaluateScript( data.element()->document()->url().string(), data.scriptContent());57 data.evaluateScript(makeSource(data.scriptContent(), data.element()->document()->url().string())); // FIXME: Provide a real starting line number here. 55 58 } 56 59 … … 72 75 // we evaluate the script. 73 76 if (element->inDocument() && element->firstChild()) 74 data.evaluateScript( element->document()->url().string(), data.scriptContent());77 data.evaluateScript(makeSource(data.scriptContent(), element->document()->url().string())); // FIXME: Provide a real starting line number here 75 78 } 76 79 … … 159 162 } 160 163 161 void ScriptElementData::evaluateScript(const S tring& sourceUrl, const String& content)162 { 163 if (m_evaluated || content.isEmpty() || !shouldExecuteAsJavaScript())164 void ScriptElementData::evaluateScript(const SourceCode& sourceCode) 165 { 166 if (m_evaluated || !sourceCode.length() || !shouldExecuteAsJavaScript()) 164 167 return; 165 168 … … 170 173 m_evaluated = true; 171 174 172 // FIXME: This starting line number will be incorrect for evaluation triggered 173 // from insertedIntoDocument or childrenChanged. 174 frame->script()->evaluate(sourceUrl, 1, content); 175 frame->script()->evaluate(sourceCode); 175 176 Document::updateDocumentsRendering(); 176 177 } … … 197 198 m_scriptElement->dispatchErrorEvent(); 198 199 else { 199 evaluateScript( cs->url(), cs->script());200 evaluateScript(makeSource(cs->script(), cs->url())); 200 201 m_scriptElement->dispatchLoadEvent(); 201 202 } -
trunk/WebCore/dom/ScriptElement.h
r37924 r38654 24 24 #include "CachedResourceClient.h" 25 25 #include "CachedResourceHandle.h" 26 27 namespace JSC { 28 class SourceCode; 29 } 26 30 27 31 namespace WebCore { … … 78 82 79 83 void requestScript(const String& sourceUrl); 80 void evaluateScript(const String& sourceUrl, const String& content);84 void evaluateScript(const JSC::SourceCode&); 81 85 void stopLoadRequest(); 82 86 -
trunk/WebCore/dom/WorkerThread.cpp
r38626 r38654 32 32 33 33 #include "JSWorkerContext.h" 34 #include "StringSourceProvider.h" 34 35 #include "Worker.h" 35 36 #include "WorkerContext.h" … … 78 79 WorkerScriptController* script = workerContext->script(); 79 80 80 script->evaluate(m _scriptURL, 1, m_sourceCode);81 script->evaluate(makeSource(m_sourceCode, m_scriptURL)); 81 82 m_messagingProxy->confirmWorkerThreadMessage(workerContext->hasPendingActivity()); // This wasn't really a message, but it counts as one for GC. 82 83 -
trunk/WebCore/dom/XMLTokenizer.cpp
r38610 r38654 42 42 #include "HTMLScriptElement.h" 43 43 #include "HTMLStyleElement.h" 44 #include "ScriptController.h"45 #include "ScriptValue.h"46 44 #include "ProcessingInstruction.h" 47 45 #include "ResourceError.h" … … 49 47 #include "ResourceRequest.h" 50 48 #include "ResourceResponse.h" 49 #include "ScriptController.h" 50 #include "ScriptValue.h" 51 #include "StringSourceProvider.h" 51 52 #include "TextResourceDecoder.h" 52 53 #include <wtf/Platform.h> … … 340 341 scriptElement->dispatchErrorEvent(); 341 342 else { 342 m_view->frame()->loader()->executeScript( cachedScriptUrl, 1, scriptSource);343 m_view->frame()->loader()->executeScript(makeSource(scriptSource, cachedScriptUrl)); 343 344 scriptElement->dispatchLoadEvent(); 344 345 } -
trunk/WebCore/dom/XMLTokenizerLibxml2.cpp
r38610 r38654 41 41 #include "HTMLStyleElement.h" 42 42 #include "HTMLTokenizer.h" // for decodeNamedEntity 43 #include "ScriptController.h"44 #include "ScriptValue.h"45 43 #include "ProcessingInstruction.h" 46 44 #include "ResourceError.h" … … 48 46 #include "ResourceRequest.h" 49 47 #include "ResourceResponse.h" 48 #include "ScriptController.h" 50 49 #include "ScriptElement.h" 50 #include "ScriptValue.h" 51 #include "StringSourceProvider.h" 51 52 #include "TextResourceDecoder.h" 52 53 #include <libxml/parser.h> … … 806 807 } else 807 808 m_scriptElement = 0; 808 809 } else { 810 String scriptCode = scriptElement->scriptContent(); 811 m_view->frame()->loader()->executeScript(m_doc->url().string(), m_scriptStartLine, scriptCode); 812 } 809 } else 810 m_view->frame()->loader()->executeScript(makeSource(scriptElement->scriptContent(), m_doc->url().string(), m_scriptStartLine)); 813 811 814 812 m_requestingScript = false; -
trunk/WebCore/dom/XMLTokenizerQt.cpp
r38613 r38654 41 41 #include "HTMLStyleElement.h" 42 42 #include "HTMLTokenizer.h" 43 #include "ScriptController.h"44 #include "ScriptElement.h"45 #include "ScriptValue.h"46 43 #include "ProcessingInstruction.h" 47 44 #include "ResourceError.h" … … 49 46 #include "ResourceRequest.h" 50 47 #include "ResourceResponse.h" 48 #include "ScriptController.h" 49 #include "ScriptElement.h" 50 #include "ScriptValue.h" 51 #include "StringSourceProvider.h" 51 52 #include "TextResourceDecoder.h" 52 53 #include <QDebug> … … 584 585 } else 585 586 m_scriptElement = 0; 586 587 } else { 588 String scriptCode = scriptElement->scriptContent(); 589 m_view->frame()->loader()->executeScript(m_doc->url().string(), m_scriptStartLine, scriptCode); 590 } 587 } else 588 m_view->frame()->loader()->executeScript(makeSource(scriptElement->scriptContent(), m_doc->url().string(), m_scriptStartLine)); 591 589 592 590 m_requestingScript = false; -
trunk/WebCore/html/HTMLTokenizer.cpp
r38610 r38654 46 46 #include "ScriptController.h" 47 47 #include "ScriptValue.h" 48 #include "StringSourceProvider.h" 48 49 #include "SystemTime.h" 49 50 #include <wtf/ASCIICType.h> … … 54 55 // #define INSTRUMENT_LAYOUT_SCHEDULING 1 55 56 57 using namespace JSC; 58 using namespace WTF; 56 59 using namespace std; 57 using namespace WTF;58 60 59 61 namespace WebCore { … … 501 503 prependingSrc = m_src; 502 504 setSrc(SegmentedString()); 503 state = scriptExecution( scriptString, state, String(), startLine);505 state = scriptExecution(makeSource(scriptString, m_doc->frame() ? m_doc->frame()->document()->url().string() : String(), startLine), state); 504 506 } 505 507 } … … 543 545 } 544 546 545 HTMLTokenizer::State HTMLTokenizer::scriptExecution(const S tring& str, State state, const String& scriptURL, int baseLine)547 HTMLTokenizer::State HTMLTokenizer::scriptExecution(const SourceCode& sourceCode, State state) 546 548 { 547 549 if (m_fragment || !m_doc->frame()) 548 550 return state; 549 551 m_executingScript++; 550 String url = scriptURL.isNull() ? m_doc->frame()->document()->url().string() : scriptURL;551 552 552 553 SegmentedString* savedPrependingSrc = m_currentPrependingSrc; … … 560 561 561 562 m_state = state; 562 m_doc->frame()->loader()->executeScript( url, baseLine, str);563 m_doc->frame()->loader()->executeScript(sourceCode); 563 564 state = m_state; 564 565 … … 1983 1984 else { 1984 1985 if (static_cast<HTMLScriptElement*>(n.get())->shouldExecuteAsJavaScript()) 1985 m_state = scriptExecution( scriptSource, m_state, cachedScriptUrl);1986 m_state = scriptExecution(makeSource(scriptSource, cachedScriptUrl), m_state); 1986 1987 EventTargetNodeCast(n.get())->dispatchEventForType(eventNames().loadEvent, false, false); 1987 1988 } -
trunk/WebCore/html/HTMLTokenizer.h
r38327 r38654 34 34 #include <wtf/OwnPtr.h> 35 35 #include <wtf/Vector.h> 36 37 namespace JSC { 38 class SourceCode; 39 } 36 40 37 41 namespace WebCore { … … 178 182 State parseProcessingInstruction(SegmentedString&, State); 179 183 State scriptHandler(State); 180 State scriptExecution(const String& script, State, const String& scriptURL, int baseLine = 1);184 State scriptExecution(const JSC::SourceCode&, State); 181 185 void setSrc(const SegmentedString&); 182 186 -
trunk/WebCore/loader/FrameLoader.cpp
r38610 r38654 66 66 #include "IconLoader.h" 67 67 #include "InspectorController.h" 68 #include "JSDOMBinding.h" 68 69 #include "Logging.h" 69 70 #include "MIMETypeRegistry.h" … … 75 76 #include "ProgressTracker.h" 76 77 #include "RenderPart.h" 78 #include "RenderView.h" 77 79 #include "RenderWidget.h" 78 #include "RenderView.h"79 80 #include "ResourceHandle.h" 80 81 #include "ResourceRequest.h" 82 #include "ScriptController.h" 83 #include "ScriptValue.h" 81 84 #include "SecurityOrigin.h" 82 85 #include "SegmentedString.h" 83 86 #include "Settings.h" 87 #include "StringSourceProvider.h" 84 88 #include "SystemTime.h" 85 89 #include "TextResourceDecoder.h" … … 87 91 #include "XMLHttpRequest.h" 88 92 #include "XMLTokenizer.h" 89 #include "JSDOMBinding.h"90 #include "ScriptController.h"91 #include "ScriptValue.h"92 93 #include <runtime/JSLock.h> 93 94 #include <runtime/JSObject.h> … … 108 109 #include "SVGViewSpec.h" 109 110 #endif 111 112 using namespace JSC; 110 113 111 114 namespace WebCore { … … 774 777 ScriptValue FrameLoader::executeScript(const String& script, bool forceUserGesture) 775 778 { 776 return executeScript( forceUserGesture ? String() : m_URL.string(), 1, script);777 } 778 779 ScriptValue FrameLoader::executeScript(const S tring& url, int baseLine, const String& script)779 return executeScript(makeSource(script, forceUserGesture ? String() : m_URL.string())); 780 } 781 782 ScriptValue FrameLoader::executeScript(const SourceCode& sourceCode) 780 783 { 781 784 if (!m_frame->script()->isEnabled() || m_frame->script()->isPaused()) … … 785 788 m_isRunningScript = true; 786 789 787 ScriptValue result = m_frame->script()->evaluate( url, baseLine, script);790 ScriptValue result = m_frame->script()->evaluate(sourceCode); 788 791 789 792 if (!wasRunningScript) { -
trunk/WebCore/loader/FrameLoader.h
r38610 r38654 49 49 #include "CachedResourceClient.h" 50 50 #endif 51 52 namespace JSC { 53 class SourceCode; 54 } 51 55 52 56 namespace WebCore { … … 336 340 bool executeIfJavaScriptURL(const KURL& url, bool userGesture = false, bool replaceDocument = true); 337 341 338 ScriptValue executeScript(const String& url, int baseLine, const String& script);342 ScriptValue executeScript(const JSC::SourceCode&); 339 343 ScriptValue executeScript(const String& script, bool forceUserGesture = false); 340 344
Note: See TracChangeset
for help on using the changeset viewer.