Changeset 142204 in webkit
- Timestamp:
- Feb 7, 2013 4:35:17 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r142200 r142204 1 2013-02-07 Elliott Sprehn <esprehn@chromium.org> 2 3 HTML parser should queue MutationRecords for its operations 4 https://bugs.webkit.org/show_bug.cgi?id=89351 5 6 Reviewed by Eric Seidel. 7 8 Add new test mutation records in the parser and fix shadow-dom.html 9 test since it used setTimeout and sometimes could observe parser 10 mutations. 11 12 * fast/dom/MutationObserver/parser-mutations-expected.txt: Added. 13 * fast/dom/MutationObserver/parser-mutations.html: Added. 14 * fast/dom/MutationObserver/shadow-dom-expected.txt: 15 * fast/dom/MutationObserver/shadow-dom.html: 16 1 17 2013-02-07 Adam Barth <abarth@webkit.org> 2 18 -
trunk/LayoutTests/fast/dom/MutationObserver/shadow-dom-expected.txt
r137662 r142204 12 12 13 13 Observing from outside shadow DOM should not see mutations in the shadow: 14 PASS mutations is null14 PASS mutations.length is 0 15 15 PASS successfullyParsed is true 16 16 -
trunk/LayoutTests/fast/dom/MutationObserver/shadow-dom.html
r137662 r142204 6 6 description('Test that MutationObservers operate in Shadow DOM'); 7 7 8 function doTest() { 9 function mutate(elt) { 8 function doTest() 9 { 10 function mutate(elt) 11 { 10 12 elt.setAttribute('data-foo', 'bar'); 11 13 elt.insertBefore(document.createTextNode('hello'), elt.firstChild); … … 15 17 16 18 var shadowRoot = internals.shadowRoot(document.querySelector('input')); 17 var observer = new WebKitMutationObserver(function(mutations) { 18 window.mutations = mutations; 19 }); 19 var observer = new WebKitMutationObserver(function() { }); 20 20 21 21 observer.observe(shadowRoot.firstChild, {attributes: true, childList: true, characterData: true, subtree: true}); 22 22 mutate(shadowRoot.firstChild); 23 23 24 setTimeout(function() {25 26 27 28 29 30 31 24 window.mutations = observer.takeRecords(); 25 debug('Mutations in shadow DOM should have been observed:'); 26 shouldBe('mutations.length', '4'); 27 shouldBe('mutations[0].type', '"attributes"'); 28 shouldBe('mutations[1].type', '"childList"'); 29 shouldBe('mutations[2].type', '"characterData"'); 30 shouldBe('mutations[3].type', '"childList"'); 31 observer.disconnect(); 32 32 33 window.mutations = null; 34 observer.observe(document, {attributes: true, childList: true, characterData: true, subtree: true}); 35 mutate(shadowRoot.firstChild); 36 setTimeout(function() { 37 debug('\nObserving from outside shadow DOM should not see mutations in the shadow:'); 38 shouldBeNull('mutations'); 39 finishJSTest(); 40 }, 0); 41 }, 0); 33 window.mutations = observer.takeRecords(); 34 observer.observe(document, {attributes: true, childList: true, characterData: true, subtree: true}); 35 mutate(shadowRoot.firstChild); 36 debug('\nObserving from outside shadow DOM should not see mutations in the shadow:'); 37 shouldBe('mutations.length', '0'); 42 38 } 43 39 44 if (window.internals) {40 if (window.internals) 45 41 doTest(); 46 window.jsTestIsAsync = true; 47 } else 42 else 48 43 testFailed('This test only runs in DRT'); 49 44 </script> -
trunk/Source/WebCore/ChangeLog
r142202 r142204 1 2013-02-07 Elliott Sprehn <esprehn@chromium.org> 2 3 HTML parser should queue MutationRecords for its operations 4 https://bugs.webkit.org/show_bug.cgi?id=89351 5 6 Reviewed by Eric Seidel. 7 8 Generate mutation records inside the parser. This is done by using a 9 ChildListMutationScope in the ContainerNode::parser* methods and then 10 adding delivery before each <script> element would be processed by 11 the parser. 12 13 Test: fast/dom/MutationObserver/parser-mutations.html 14 15 * dom/ContainerNode.cpp: 16 (WebCore::ContainerNode::takeAllChildrenFrom): 17 (WebCore::ContainerNode::parserInsertBefore): 18 (WebCore::ContainerNode::parserRemoveChild): 19 (WebCore::ContainerNode::parserAppendChild): 20 * html/parser/HTMLScriptRunner.cpp: 21 (WebCore::HTMLScriptRunner::executeParsingBlockingScript): 22 (WebCore::HTMLScriptRunner::executePendingScriptAndDispatchEvent): 23 (WebCore::HTMLScriptRunner::execute): 24 (WebCore::HTMLScriptRunner::executeScriptsWaitingForLoad): 25 (WebCore::HTMLScriptRunner::executeScriptsWaitingForStylesheets): 26 (WebCore::HTMLScriptRunner::executeScriptsWaitingForParsing): 27 (WebCore::HTMLScriptRunner::runScript): 28 1 29 2013-02-07 Kentaro Hara <haraken@chromium.org> 2 30 -
trunk/Source/WebCore/dom/ContainerNode.cpp
r142126 r142204 106 106 NodeVector children; 107 107 getChildNodes(oldParent, children); 108 109 if (oldParent->document()->hasMutationObserversOfType(MutationObserver::ChildList)) { 110 ChildListMutationScope mutation(oldParent); 111 for (unsigned i = 0; i < children.size(); ++i) 112 mutation.willRemoveChild(children[i].get()); 113 } 114 115 // FIXME: We need to do notifyMutationObserversNodeWillDetach() for each child, 116 // probably inside removeDetachedChildrenInContainer. 117 108 118 oldParent->removeDetachedChildren(); 109 119 … … 343 353 newChild->updateAncestorConnectedSubframeCountForInsertion(); 344 354 355 ChildListMutationScope(this).childAdded(newChild.get()); 356 345 357 childrenChanged(true, newChild->previousSibling(), nextChild, 1); 346 358 ChildNodeInsertionNotifier(this).notify(newChild.get()); … … 565 577 566 578 oldChild->updateAncestorConnectedSubframeCountForRemoval(); 579 580 ChildListMutationScope(this).willRemoveChild(oldChild); 581 oldChild->notifyMutationObserversNodeWillDetach(); 567 582 568 583 removeBetween(prev, next, oldChild); … … 716 731 717 732 newChild->updateAncestorConnectedSubframeCountForInsertion(); 733 734 ChildListMutationScope(this).childAdded(newChild.get()); 718 735 719 736 childrenChanged(true, last, 0, 1); -
trunk/Source/WebCore/html/parser/HTMLScriptRunner.cpp
r139799 r142204 37 37 #include "HTMLScriptRunnerHost.h" 38 38 #include "IgnoreDestructiveWriteCountIncrementer.h" 39 #include "MutationObserver.h" 39 40 #include "NestingLevelIncrementer.h" 40 41 #include "NotImplemented.h" … … 111 112 { 112 113 ASSERT(m_document); 113 ASSERT(! m_scriptNestingLevel);114 ASSERT(!isExecutingScript()); 114 115 ASSERT(m_document->haveStylesheetsLoaded()); 115 116 ASSERT(isPendingScriptReady(m_parserBlockingScript)); … … 127 128 if (pendingScript.cachedScript() && pendingScript.watchingForLoad()) 128 129 stopWatchingForLoad(pendingScript); 130 131 if (!isExecutingScript()) 132 MutationObserver::deliverAllMutations(); 129 133 130 134 // Clear the pending script before possible rentrancy from executeScript() … … 141 145 } 142 146 } 143 ASSERT(! m_scriptNestingLevel);147 ASSERT(!isExecutingScript()); 144 148 } 145 149 … … 171 175 172 176 if (hasParserBlockingScript()) { 173 if ( m_scriptNestingLevel)177 if (isExecutingScript()) 174 178 return; // Unwind to the outermost HTMLScriptRunner::execute before continuing parsing. 175 179 // If preload scanner got created, it is missing the source after the current insertion point. Append it and scan. … … 193 197 void HTMLScriptRunner::executeScriptsWaitingForLoad(CachedResource* cachedScript) 194 198 { 195 ASSERT(! m_scriptNestingLevel);199 ASSERT(!isExecutingScript()); 196 200 ASSERT(hasParserBlockingScript()); 197 201 ASSERT_UNUSED(cachedScript, m_parserBlockingScript.cachedScript() == cachedScript); … … 206 210 // to prevent parser or script re-entry during </style> parsing. 207 211 ASSERT(hasScriptsWaitingForStylesheets()); 208 ASSERT(! m_scriptNestingLevel);212 ASSERT(!isExecutingScript()); 209 213 ASSERT(m_document->haveStylesheetsLoaded()); 210 214 executeParsingBlockingScripts(); … … 214 218 { 215 219 while (!m_scriptsToExecuteAfterParsing.isEmpty()) { 216 ASSERT(! m_scriptNestingLevel);220 ASSERT(!isExecutingScript()); 217 221 ASSERT(!hasParserBlockingScript()); 218 222 ASSERT(m_scriptsToExecuteAfterParsing.first().cachedScript()); … … 275 279 ASSERT(!hasParserBlockingScript()); 276 280 { 277 InsertionPointRecord insertionPointRecord(m_host->inputStream());278 NestingLevelIncrementer nestingLevelIncrementer(m_scriptNestingLevel);279 280 281 ScriptElement* scriptElement = toScriptElement(script); 281 282 … … 287 288 if (!scriptElement) 288 289 return; 290 291 // FIXME: This may be too agressive as we always deliver mutations at 292 // every script element, even if it's not ready to execute yet. There's 293 // unfortuantely no obvious way to tell if prepareScript is going to 294 // execute the script from out here. 295 if (!isExecutingScript()) 296 MutationObserver::deliverAllMutations(); 297 298 InsertionPointRecord insertionPointRecord(m_host->inputStream()); 299 NestingLevelIncrementer nestingLevelIncrementer(m_scriptNestingLevel); 289 300 290 301 scriptElement->prepareScript(scriptStartPosition);
Note: See TracChangeset
for help on using the changeset viewer.