Changeset 98121 in webkit
- Timestamp:
- Oct 21, 2011 12:19:56 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r98120 r98121 1 2011-10-21 Rafael Weinstein <rafaelw@chromium.org> 2 3 [MutationObservers] Implement WebKitMutationObserver.observe for childList changes 4 https://bugs.webkit.org/show_bug.cgi?id=68955 5 6 Reviewed by Ryosuke Niwa. 7 8 * fast/mutation/observe-attributes-expected.txt: 9 * fast/mutation/observe-attributes.html: 10 * fast/mutation/observe-childList-expected.txt: Added. 11 * fast/mutation/observe-childList.html: Added. 12 1 13 2011-10-21 Julien Chaffraix <jchaffraix@webkit.org> 2 14 -
trunk/LayoutTests/fast/mutation/observe-attributes-expected.txt
r97789 r98121 24 24 PASS mutations is null 25 25 26 Testing that re-observing the same node with the same observ inghas the effect of resetting the options.26 Testing that re-observing the same node with the same observer has the effect of resetting the options. 27 27 PASS calls is 1 28 28 PASS mutations.length is 1 -
trunk/LayoutTests/fast/mutation/observe-attributes.html
r97925 r98121 11 11 12 12 window.jsTestIsAsync = true; 13 var mutations; 14 var mutations2; 13 var mutations, mutations2; 15 14 var calls; 16 15 … … 108 107 109 108 function start() { 110 debug('Testing that re-observing the same node with the same observ inghas the effect of resetting the options.');109 debug('Testing that re-observing the same node with the same observer has the effect of resetting the options.'); 111 110 112 111 calls = 0; -
trunk/Source/WebCore/CMakeLists.txt
r98069 r98121 514 514 dom/CharacterData.cpp 515 515 dom/CheckedRadioButtons.cpp 516 dom/ChildListMutationScope.cpp 516 517 dom/ChildNodeList.cpp 517 518 dom/ClassNodeList.cpp -
trunk/Source/WebCore/ChangeLog
r98117 r98121 1 2011-10-21 Rafael Weinstein <rafaelw@chromium.org> 2 3 [MutationObservers] Implement WebKitMutationObserver.observe for childList changes 4 https://bugs.webkit.org/show_bug.cgi?id=68955 5 6 Reviewed by Ryosuke Niwa. 7 8 This patch adds a ChildListMutationScope object which manages the coalescing of 9 multiple child removals and additions within DOM operations into single childList 10 mutation records. 11 12 Note that this patch doesn't cover all the cases which can be coalesced (it only 13 covers ContainerNode.*, and Node.innerHTML/innerText). A separate bug, 14 https://bugs.webkit.org/show_bug.cgi?id=70385, has been opened to track the 15 remaining cases. 16 17 Test: fast/mutation/observe-childList.html 18 19 * CMakeLists.txt: 20 * GNUmakefile.list.am: 21 * WebCore.gypi: 22 * WebCore.pro: 23 * WebCore.vcproj/WebCore.vcproj: 24 * WebCore.xcodeproj/project.pbxproj: 25 * dom/ChildListMutationScope.cpp: Added. 26 (WebCore::ChildListAccumulation::ChildListAccumulation::ChildListAccumulation): 27 (WebCore::ChildListAccumulation::ChildListAccumulation::~ChildListAccumulation): 28 (WebCore::ChildListAccumulation::ChildListAccumulation::childAdded): 29 (WebCore::ChildListAccumulation::ChildListAccumulation::willRemoveChild): 30 (WebCore::ChildListAccumulation::ChildListAccumulation::dispatch): 31 (WebCore::ChildListAccumulation::ChildListAccumulation::clear): 32 (WebCore::ChildListAccumulation::ChildListAccumulation::isEmpty): 33 (WebCore::ChildListAccumulation::ChildListAccumulator::ChildListAccumulator): 34 (WebCore::ChildListAccumulation::ChildListAccumulator::~ChildListAccumulator): 35 (WebCore::ChildListAccumulation::ChildListAccumulator::initialize): 36 (WebCore::ChildListAccumulation::ChildListAccumulator::instance): 37 (WebCore::ChildListAccumulation::ChildListAccumulator::childAdded): 38 (WebCore::ChildListAccumulation::ChildListAccumulator::willRemoveChild): 39 (WebCore::ChildListAccumulation::ChildListAccumulator::incrementScopingLevel): 40 (WebCore::ChildListAccumulation::ChildListAccumulator::decrementScopingLevel): 41 (WebCore::ChildListMutationScope::ChildListMutationScope): 42 (WebCore::ChildListMutationScope::~ChildListMutationScope): 43 (WebCore::ChildListMutationScope::childAdded): 44 (WebCore::ChildListMutationScope::willRemoveChild): 45 * dom/ChildListMutationScope.h: Added. 46 * dom/ContainerNode.cpp: 47 (WebCore::ContainerNode::insertBefore): 48 (WebCore::ContainerNode::replaceChild): 49 (WebCore::willRemoveChildren): 50 (WebCore::dispatchChildInsertionEvents): 51 (WebCore::dispatchChildRemovalEvents): 52 * dom/Element.cpp: 53 (WebCore::enqueueAttributesMutationRecord): 54 * dom/Node.cpp: 55 (WebCore::Node::setTextContent): 56 (WebCore::Node::registeredMutationObserversOfType): 57 * dom/WebKitMutationObserver.cpp: 58 (WebCore::WebKitMutationObserver::disconnect): 59 * html/HTMLElement.cpp: 60 (WebCore::replaceChildrenWithFragment): 61 (WebCore::replaceChildrenWithText): 62 1 63 2011-10-21 Sheriff Bot <webkit.review.bot@gmail.com> 2 64 -
trunk/Source/WebCore/GNUmakefile.list.am
r98044 r98121 1123 1123 Source/WebCore/dom/CheckedRadioButtons.cpp \ 1124 1124 Source/WebCore/dom/CheckedRadioButtons.h \ 1125 Source/WebCore/dom/ChildListMutationScope.cpp \ 1126 Source/WebCore/dom/ChildListMutationScope.h \ 1125 1127 Source/WebCore/dom/ChildNodeList.cpp \ 1126 1128 Source/WebCore/dom/ChildNodeList.h \ -
trunk/Source/WebCore/WebCore.gypi
r98044 r98121 5128 5128 'dom/CharacterData.cpp', 5129 5129 'dom/CheckedRadioButtons.cpp', 5130 'dom/ChildListMutationScope.cpp', 5131 'dom/ChildListMutationScope.h', 5130 5132 'dom/ChildNodeList.cpp', 5131 5133 'dom/ChildNodeList.h', -
trunk/Source/WebCore/WebCore.pro
r98000 r98121 466 466 dom/CharacterData.cpp \ 467 467 dom/CheckedRadioButtons.cpp \ 468 dom/ChildListMutationScope.cpp \ 468 469 dom/ChildNodeList.cpp \ 469 470 dom/ClassNodeList.cpp \ -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r98044 r98121 43875 43875 </File> 43876 43876 <File 43877 RelativePath="..\dom\ChildListMutationScope.cpp" 43878 > 43879 <FileConfiguration 43880 Name="Debug|Win32" 43881 ExcludedFromBuild="true" 43882 > 43883 <Tool 43884 Name="VCCLCompilerTool" 43885 /> 43886 </FileConfiguration> 43887 <FileConfiguration 43888 Name="Release|Win32" 43889 ExcludedFromBuild="true" 43890 > 43891 <Tool 43892 Name="VCCLCompilerTool" 43893 /> 43894 </FileConfiguration> 43895 <FileConfiguration 43896 Name="Debug_Cairo_CFLite|Win32" 43897 ExcludedFromBuild="true" 43898 > 43899 <Tool 43900 Name="VCCLCompilerTool" 43901 /> 43902 </FileConfiguration> 43903 <FileConfiguration 43904 Name="Release_Cairo_CFLite|Win32" 43905 ExcludedFromBuild="true" 43906 > 43907 <Tool 43908 Name="VCCLCompilerTool" 43909 /> 43910 </FileConfiguration> 43911 <FileConfiguration 43912 Name="Debug_All|Win32" 43913 ExcludedFromBuild="true" 43914 > 43915 <Tool 43916 Name="VCCLCompilerTool" 43917 /> 43918 </FileConfiguration> 43919 <FileConfiguration 43920 Name="Production|Win32" 43921 ExcludedFromBuild="true" 43922 > 43923 <Tool 43924 Name="VCCLCompilerTool" 43925 /> 43926 </FileConfiguration> 43927 </File> 43928 <File 43929 RelativePath="..\dom\ChildListMutationScope.h" 43930 > 43931 </File> 43932 <File 43877 43933 RelativePath="..\dom\ChildNodeList.cpp" 43878 43934 > -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r98044 r98121 5808 5808 D3D4E972130C7CFE007BA540 /* HTMLSummaryElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D3D4E970130C7CFE007BA540 /* HTMLSummaryElement.cpp */; }; 5809 5809 D3D4E973130C7CFE007BA540 /* HTMLSummaryElement.h in Headers */ = {isa = PBXBuildFile; fileRef = D3D4E971130C7CFE007BA540 /* HTMLSummaryElement.h */; }; 5810 D619A307144E00BE004BC302 /* ChildListMutationScope.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D619A305144E00BE004BC302 /* ChildListMutationScope.cpp */; }; 5811 D619A308144E00BE004BC302 /* ChildListMutationScope.h in Headers */ = {isa = PBXBuildFile; fileRef = D619A306144E00BE004BC302 /* ChildListMutationScope.h */; }; 5810 5812 D70AD65713E1342B005B50B4 /* RenderRegion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D70AD65513E1342B005B50B4 /* RenderRegion.cpp */; }; 5811 5813 D70AD65813E1342B005B50B4 /* RenderRegion.h in Headers */ = {isa = PBXBuildFile; fileRef = D70AD65613E1342B005B50B4 /* RenderRegion.h */; }; … … 13140 13142 D3D4E970130C7CFE007BA540 /* HTMLSummaryElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLSummaryElement.cpp; sourceTree = "<group>"; }; 13141 13143 D3D4E971130C7CFE007BA540 /* HTMLSummaryElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLSummaryElement.h; sourceTree = "<group>"; }; 13144 D619A305144E00BE004BC302 /* ChildListMutationScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ChildListMutationScope.cpp; sourceTree = "<group>"; }; 13145 D619A306144E00BE004BC302 /* ChildListMutationScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChildListMutationScope.h; sourceTree = "<group>"; }; 13142 13146 D70AD65513E1342B005B50B4 /* RenderRegion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderRegion.cpp; sourceTree = "<group>"; }; 13143 13147 D70AD65613E1342B005B50B4 /* RenderRegion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderRegion.h; sourceTree = "<group>"; }; … … 21016 21020 93F925420F7EF5B8007E37C9 /* CheckedRadioButtons.cpp */, 21017 21021 93F925410F7EF5B8007E37C9 /* CheckedRadioButtons.h */, 21022 D619A305144E00BE004BC302 /* ChildListMutationScope.cpp */, 21023 D619A306144E00BE004BC302 /* ChildListMutationScope.h */, 21018 21024 A818721A0977D3C0005826D9 /* ChildNodeList.cpp */, 21019 21025 A81872150977D3C0005826D9 /* ChildNodeList.h */, … … 21831 21837 A00B721A11DE6428008AB9FF /* CheckedInt.h in Headers */, 21832 21838 93F925430F7EF5B8007E37C9 /* CheckedRadioButtons.h in Headers */, 21839 D619A308144E00BE004BC302 /* ChildListMutationScope.h in Headers */, 21833 21840 A81872200977D3C0005826D9 /* ChildNodeList.h in Headers */, 21834 21841 14D823520AF92A790004F057 /* Chrome.h in Headers */, … … 25181 25188 F55B3DB11251F12D003EF269 /* CheckboxInputType.cpp in Sources */, 25182 25189 93F925440F7EF5B8007E37C9 /* CheckedRadioButtons.cpp in Sources */, 25190 D619A307144E00BE004BC302 /* ChildListMutationScope.cpp in Sources */, 25183 25191 A81872250977D3C0005826D9 /* ChildNodeList.cpp in Sources */, 25184 25192 14D8238B0AF92DF60004F057 /* Chrome.cpp in Sources */, -
trunk/Source/WebCore/dom/ContainerNode.cpp
r93071 r98121 25 25 26 26 #include "BeforeLoadEvent.h" 27 #include " MemoryCache.h"27 #include "ChildListMutationScope.h" 28 28 #include "ContainerNodeAlgorithms.h" 29 29 #include "DeleteButtonController.h" … … 35 35 #include "InlineTextBox.h" 36 36 #include "InspectorInstrumentation.h" 37 #include "MemoryCache.h" 37 38 #include "MutationEvent.h" 38 39 #include "ResourceLoadScheduler.h" … … 142 143 return true; 143 144 145 #if ENABLE(MUTATION_OBSERVERS) 146 ChildListMutationScope mutation(this); 147 #endif 148 144 149 RefPtr<Node> next = refChild; 145 150 RefPtr<Node> refChildPreviousSibling = refChild->previousSibling(); … … 273 278 } 274 279 280 #if ENABLE(MUTATION_OBSERVERS) 281 ChildListMutationScope mutation(this); 282 #endif 283 275 284 RefPtr<Node> prev = oldChild->previousSibling(); 276 285 RefPtr<Node> next = oldChild->nextSibling(); … … 401 410 collectNodes(container, children); 402 411 412 #if ENABLE(MUTATION_OBSERVERS) 413 ChildListMutationScope mutation(container); 414 #endif 415 403 416 for (NodeVector::const_iterator it = children.begin(); it != children.end(); it++) { 404 417 Node* child = it->get(); … … 611 624 if (targets.isEmpty()) 612 625 return true; 626 627 #if ENABLE(MUTATION_OBSERVERS) 628 ChildListMutationScope mutation(this); 629 #endif 613 630 614 631 // Now actually add the child(ren) … … 1096 1113 RefPtr<Document> document = child->document(); 1097 1114 1115 #if ENABLE(MUTATION_OBSERVERS) 1116 if (c->parentNode()) { 1117 ChildListMutationScope mutation(c->parentNode()); 1118 mutation.childAdded(c); 1119 } 1120 #endif 1121 1098 1122 if (c->parentNode() && document->hasListenerType(Document::DOMNODEINSERTED_LISTENER)) 1099 1123 c->dispatchScopedEvent(MutationEvent::create(eventNames().DOMNodeInsertedEvent, true, c->parentNode())); … … 1117 1141 RefPtr<Document> document = child->document(); 1118 1142 1143 #if ENABLE(MUTATION_OBSERVERS) 1144 if (c->parentNode()) { 1145 ChildListMutationScope mutation(c->parentNode()); 1146 mutation.willRemoveChild(c); 1147 } 1148 #endif 1149 1119 1150 // dispatch pre-removal mutation events 1120 1151 if (c->parentNode() && document->hasListenerType(Document::DOMNODEREMOVED_LISTENER)) -
trunk/Source/WebCore/dom/Element.cpp
r97670 r98121 626 626 627 627 RefPtr<MutationRecord> mutation = MutationRecord::createAttributes(element, name); 628 for ( Vector<WebKitMutationObserver*>::iterator iter = observers.begin(); iter != observers.end(); ++iter)629 (*iter)->enqueueMutationRecord(mutation);628 for (size_t i = 0; i < observers.size(); ++i) 629 observers[i]->enqueueMutationRecord(mutation); 630 630 } 631 631 #endif -
trunk/Source/WebCore/dom/Node.cpp
r97878 r98121 29 29 #include "Attr.h" 30 30 #include "Attribute.h" 31 #include "ChildListMutationScope.h" 31 32 #include "Chrome.h" 32 33 #include "ChromeClient.h" … … 2131 2132 case SHADOW_ROOT_NODE: { 2132 2133 ContainerNode* container = toContainerNode(this); 2134 #if ENABLE(MUTATION_OBSERVERS) 2135 ChildListMutationScope mutation(this); 2136 #endif 2133 2137 container->removeChildren(); 2134 2138 if (!text.isEmpty()) … … 2701 2705 return; 2702 2706 2703 for ( Vector<MutationObserverEntry>::iterator iter = observerEntries->begin(); iter != observerEntries->end(); ++iter) {2704 if ( iter->matches(type))2705 observers.append( iter->observer.get());2707 for (size_t i = 0; i < observerEntries->size(); ++i) { 2708 if ((*observerEntries)[i].matches(type)) 2709 observers.append((*observerEntries)[i].observer.get()); 2706 2710 } 2707 2711 } -
trunk/Source/WebCore/dom/WebKitMutationObserver.cpp
r97714 r98121 66 66 void WebKitMutationObserver::disconnect() 67 67 { 68 for ( Vector<Node*>::iterator iter = m_observedNodes.begin(); iter != m_observedNodes.end(); ++iter)69 (*iter)->unregisterMutationObserver(this);68 for (size_t i = 0; i < m_observedNodes.size(); ++i) 69 m_observedNodes[i]->unregisterMutationObserver(this); 70 70 71 71 m_observedNodes.clear(); -
trunk/Source/WebCore/html/HTMLElement.cpp
r97551 r98121 28 28 #include "CSSPropertyNames.h" 29 29 #include "CSSValueKeywords.h" 30 #include "ChildListMutationScope.h" 30 31 #include "DocumentFragment.h" 31 32 #include "Event.h" … … 318 319 static void replaceChildrenWithFragment(HTMLElement* element, PassRefPtr<DocumentFragment> fragment, ExceptionCode& ec) 319 320 { 321 #if ENABLE(MUTATION_OBSERVERS) 322 ChildListMutationScope mutation(element); 323 #endif 324 320 325 if (!fragment->firstChild()) { 321 326 element->removeChildren(); … … 339 344 static void replaceChildrenWithText(HTMLElement* element, const String& text, ExceptionCode& ec) 340 345 { 346 #if ENABLE(MUTATION_OBSERVERS) 347 ChildListMutationScope mutation(element); 348 #endif 349 341 350 if (hasOneTextChild(element)) { 342 351 static_cast<Text*>(element->firstChild())->setData(text, ec);
Note: See TracChangeset
for help on using the changeset viewer.