Changeset 64873 in webkit
- Timestamp:
- Aug 6, 2010 3:07:50 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/Android.mk
r64857 r64873 99 99 \ 100 100 dom/ActiveDOMObject.cpp \ 101 dom/AsyncScriptRunner.cpp \ 101 102 dom/Attr.cpp \ 102 103 dom/Attribute.cpp \ -
trunk/WebCore/CMakeLists.txt
r64857 r64873 774 774 775 775 dom/ActiveDOMObject.cpp 776 dom/AsyncScriptRunner.cpp 776 777 dom/Attr.cpp 777 778 dom/Attribute.cpp -
trunk/WebCore/ChangeLog
r64872 r64873 1 2010-08-06 Tony Gentilcore <tonyg@chromium.org> 2 3 Reviewed by Eric Seidel. 4 5 Factor an AsyncScriptRunner out of Document 6 https://bugs.webkit.org/show_bug.cgi?id=43633 7 8 This copies the existing implementation exactly. In the future 9 this will use PendingScript which handles ref counting without 10 the need for those manual ref()/deref()s. This is also currently 11 a trivial class, but a little more logic will be added to it to 12 support <script async>. 13 14 No new tests because no new functionality. 15 16 * Android.mk: 17 * CMakeLists.txt: 18 * GNUmakefile.am: 19 * WebCore.gypi: 20 * WebCore.pro: 21 * WebCore.vcproj/WebCore.vcproj: 22 * WebCore.xcodeproj/project.pbxproj: 23 * dom/AsyncScriptRunner.cpp: Added. 24 (WebCore::AsyncScriptRunner::AsyncScriptRunner): 25 (WebCore::AsyncScriptRunner::~AsyncScriptRunner): 26 (WebCore::AsyncScriptRunner::executeScriptSoon): 27 (WebCore::AsyncScriptRunner::suspend): 28 (WebCore::AsyncScriptRunner::resume): 29 (WebCore::AsyncScriptRunner::timerFired): 30 * dom/AsyncScriptRunner.h: Added. 31 (WebCore::AsyncScriptRunner::create): 32 (WebCore::AsyncScriptRunner::hasPendingScripts): 33 * dom/Document.cpp: 34 (WebCore::Document::Document): 35 (WebCore::Document::~Document): 36 * dom/Document.h: 37 (WebCore::Document::asyncScriptRunner): 38 * dom/ScriptElement.cpp: 39 (WebCore::ScriptElementData::notifyFinished): 40 * page/PageGroupLoadDeferrer.cpp: 41 (WebCore::PageGroupLoadDeferrer::PageGroupLoadDeferrer): 42 (WebCore::PageGroupLoadDeferrer::~PageGroupLoadDeferrer): 43 1 44 2010-08-06 James Robinson <jamesr@chromium.org> 2 45 -
trunk/WebCore/GNUmakefile.am
r64865 r64873 970 970 WebCore/dom/ActiveDOMObject.cpp \ 971 971 WebCore/dom/ActiveDOMObject.h \ 972 WebCore/dom/AsyncScriptRunner.cpp \ 973 WebCore/dom/AsyncScriptRunner.h \ 972 974 WebCore/dom/Attr.cpp \ 973 975 WebCore/dom/Attr.h \ -
trunk/WebCore/WebCore.gypi
r64870 r64873 1076 1076 'dom/ActiveDOMObject.cpp', 1077 1077 'dom/ActiveDOMObject.h', 1078 'dom/AsyncScriptRunner.cpp', 1079 'dom/AsyncScriptRunner.h', 1078 1080 'dom/Attr.cpp', 1079 1081 'dom/Attr.h', -
trunk/WebCore/WebCore.pro
r64857 r64873 460 460 css/WebKitCSSTransformValue.cpp \ 461 461 dom/ActiveDOMObject.cpp \ 462 dom/AsyncScriptRunner.cpp \ 462 463 dom/Attr.cpp \ 463 464 dom/Attribute.cpp \ -
trunk/WebCore/WebCore.vcproj/WebCore.vcproj
r64857 r64873 32530 32530 </File> 32531 32531 <File 32532 RelativePath="..\dom\AsyncScriptRunner.cpp" 32533 > 32534 </File> 32535 <File 32536 RelativePath="..\dom\AsyncScriptRunner.h" 32537 > 32538 </File> 32539 <File 32532 32540 RelativePath="..\dom\Attr.cpp" 32533 32541 > -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r64863 r64873 2357 2357 89CD029411C85B870070B791 /* JSBlobBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 89CD029211C85B870070B791 /* JSBlobBuilder.h */; }; 2358 2358 8A12E35D11FA33280025836A /* DocumentLoadTiming.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A12E35C11FA33280025836A /* DocumentLoadTiming.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2359 8A413AE01207BBA50082016E /* AsyncScriptRunner.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A413ADE1207BBA50082016E /* AsyncScriptRunner.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2360 8A413AE11207BBA50082016E /* AsyncScriptRunner.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A413ADF1207BBA50082016E /* AsyncScriptRunner.cpp */; }; 2359 2361 8A7CC96B12076D73001D4588 /* PendingScript.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A7CC96A12076D73001D4588 /* PendingScript.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2360 2362 8A7CC97012076F8A001D4588 /* PendingScript.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A7CC96F12076F8A001D4588 /* PendingScript.cpp */; }; … … 8160 8162 89CD029211C85B870070B791 /* JSBlobBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSBlobBuilder.h; sourceTree = "<group>"; }; 8161 8163 8A12E35C11FA33280025836A /* DocumentLoadTiming.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentLoadTiming.h; sourceTree = "<group>"; }; 8164 8A413ADE1207BBA50082016E /* AsyncScriptRunner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AsyncScriptRunner.h; sourceTree = "<group>"; }; 8165 8A413ADF1207BBA50082016E /* AsyncScriptRunner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AsyncScriptRunner.cpp; sourceTree = "<group>"; }; 8162 8166 8A7CC96A12076D73001D4588 /* PendingScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PendingScript.h; sourceTree = "<group>"; }; 8163 8167 8A7CC96F12076F8A001D4588 /* PendingScript.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PendingScript.cpp; sourceTree = "<group>"; }; … … 17082 17086 E1C4DE6D0EA75C650023CCD6 /* ActiveDOMObject.cpp */, 17083 17087 E1C4DE680EA75C1E0023CCD6 /* ActiveDOMObject.h */, 17088 8A413ADE1207BBA50082016E /* AsyncScriptRunner.h */, 17089 8A413ADF1207BBA50082016E /* AsyncScriptRunner.cpp */, 17084 17090 A8C4A7FC09D563270003AC8D /* Attr.cpp */, 17085 17091 A8C4A7FB09D563270003AC8D /* Attr.h */, … … 20083 20089 97DD4D870FDF4D6E00ECF9A4 /* XSSAuditor.h in Headers */, 20084 20090 CE172E011136E8CE0062A533 /* ZoomMode.h in Headers */, 20091 8A413AE01207BBA50082016E /* AsyncScriptRunner.h in Headers */, 20085 20092 ); 20086 20093 runOnlyForDeploymentPostprocessing = 0; … … 22499 22506 E1BE512D0CF6C512002EA959 /* XSLTUnicodeSort.cpp in Sources */, 22500 22507 97DD4D860FDF4D6E00ECF9A4 /* XSSAuditor.cpp in Sources */, 22508 8A413AE11207BBA50082016E /* AsyncScriptRunner.cpp in Sources */, 22501 22509 ); 22502 22510 runOnlyForDeploymentPostprocessing = 0; -
trunk/WebCore/dom/Document.cpp
r64845 r64873 29 29 #include "AXObjectCache.h" 30 30 #include "AnimationController.h" 31 #include "AsyncScriptRunner.h" 31 32 #include "Attr.h" 32 33 #include "Attribute.h" … … 374 375 , m_overMinimumLayoutThreshold(false) 375 376 , m_extraLayoutDelay(0) 376 , m_ executeScriptSoonTimer(this, &Document::executeScriptSoonTimerFired)377 , m_asyncScriptRunner(AsyncScriptRunner::create()) 377 378 , m_xmlVersion("1.0") 378 379 , m_xmlStandalone(false) … … 523 524 ASSERT(!m_styleRecalcTimer.isActive()); 524 525 525 for (size_t i = 0; i < m_scriptsToExecuteSoon.size(); ++i) 526 m_scriptsToExecuteSoon[i].first->element()->deref(); // Balances ref() in executeScriptSoon(). 526 m_asyncScriptRunner.clear(); 527 527 528 528 removeAllEventListeners(); … … 4832 4832 } 4833 4833 4834 void Document::executeScriptSoonTimerFired(Timer<Document>* timer)4835 {4836 ASSERT_UNUSED(timer, timer == &m_executeScriptSoonTimer);4837 4838 Vector<pair<ScriptElementData*, CachedResourceHandle<CachedScript> > > scripts;4839 scripts.swap(m_scriptsToExecuteSoon);4840 size_t size = scripts.size();4841 for (size_t i = 0; i < size; ++i) {4842 scripts[i].first->execute(scripts[i].second.get());4843 scripts[i].first->element()->deref(); // Balances ref() in executeScriptSoon().4844 }4845 }4846 4847 void Document::executeScriptSoon(ScriptElementData* data, CachedResourceHandle<CachedScript> cachedScript)4848 {4849 ASSERT_ARG(data, data);4850 4851 Element* element = data->element();4852 ASSERT(element);4853 ASSERT(element->document() == this);4854 ASSERT(element->inDocument());4855 4856 m_scriptsToExecuteSoon.append(make_pair(data, cachedScript));4857 element->ref(); // Balanced by deref()s in executeScriptSoonTimerFired() and ~Document().4858 if (!m_executeScriptSoonTimer.isActive())4859 m_executeScriptSoonTimer.startOneShot(0);4860 }4861 4862 void Document::suspendExecuteScriptSoonTimer()4863 {4864 m_executeScriptSoonTimer.stop();4865 }4866 4867 void Document::resumeExecuteScriptSoonTimer()4868 {4869 if (!m_scriptsToExecuteSoon.isEmpty())4870 m_executeScriptSoonTimer.startOneShot(0);4871 }4872 4873 4834 // FF method for accessing the selection added for compatibility. 4874 4835 DOMSelection* Document::getSelection() const -
trunk/WebCore/dom/Document.h
r64272 r64873 49 49 namespace WebCore { 50 50 51 class AsyncScriptRunner; 51 52 class Attr; 52 53 class AXObjectCache; … … 842 843 843 844 int docID() const { return m_docID; } 844 845 void executeScriptSoon(ScriptElementData*, CachedResourceHandle<CachedScript>); 846 847 void suspendExecuteScriptSoonTimer(); 848 void resumeExecuteScriptSoonTimer(); 845 846 AsyncScriptRunner* asyncScriptRunner() { return m_asyncScriptRunner.get(); } 849 847 850 848 #if ENABLE(XSLT) … … 1050 1048 1051 1049 String encoding() const; 1052 1053 void executeScriptSoonTimerFired(Timer<Document>*);1054 1050 1055 1051 void updateTitle(); … … 1202 1198 // points during the lifetime of the Document. 1203 1199 int m_extraLayoutDelay; 1204 1205 Vector<std::pair<ScriptElementData*, CachedResourceHandle<CachedScript> > > m_scriptsToExecuteSoon; 1206 Timer<Document> m_executeScriptSoonTimer; 1207 1200 1201 OwnPtr<AsyncScriptRunner> m_asyncScriptRunner; 1202 1208 1203 #if ENABLE(XSLT) 1209 1204 OwnPtr<TransformSource> m_transformSource; -
trunk/WebCore/dom/ScriptElement.cpp
r63998 r64873 25 25 #include "ScriptElement.h" 26 26 27 #include "AsyncScriptRunner.h" 27 28 #include "CachedScript.h" 28 29 #include "DocLoader.h" … … 247 248 { 248 249 ASSERT_UNUSED(o, o == m_cachedScript); 249 m_element->document()-> executeScriptSoon(this, m_cachedScript);250 m_element->document()->asyncScriptRunner()->executeScriptSoon(this, m_cachedScript); 250 251 m_cachedScript = 0; 251 252 } -
trunk/WebCore/page/PageGroupLoadDeferrer.cpp
r63080 r64873 22 22 #include "PageGroupLoadDeferrer.h" 23 23 24 #include "AsyncScriptRunner.h" 24 25 #include "Frame.h" 25 26 #include "Page.h" … … 46 47 for (Frame* frame = otherPage->mainFrame(); frame; frame = frame->tree()->traverseNext()) { 47 48 frame->document()->suspendActiveDOMObjects(); 48 frame->document()-> suspendExecuteScriptSoonTimer();49 frame->document()->asyncScriptRunner()->suspend(); 49 50 } 50 51 } … … 65 66 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()->traverseNext()) { 66 67 frame->document()->resumeActiveDOMObjects(); 67 frame->document()-> resumeExecuteScriptSoonTimer();68 frame->document()->asyncScriptRunner()->resume(); 68 69 } 69 70 }
Note: See TracChangeset
for help on using the changeset viewer.