Changeset 122584 in webkit
- Timestamp:
- Jul 13, 2012 8:36:50 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r122583 r122584 1 2012-07-13 Keishi Hattori <keishi@webkit.org> 2 3 Form of FormAssociatedElement is not updated when id target changes. 4 https://bugs.webkit.org/show_bug.cgi?id=91042 5 6 Reviewed by Kent Tamura. 7 8 * fast/forms/update-form-attribute-element-expected.txt: Added. 9 * fast/forms/update-form-attribute-element.html: Added. 10 1 11 2012-07-13 Vsevolod Vlasov <vsevik@chromium.org> 2 12 -
trunk/Source/WebCore/CMakeLists.txt
r122582 r122584 611 611 dom/GenericEventQueue.cpp 612 612 dom/IconURL.cpp 613 dom/IdTargetObserver.cpp 614 dom/IdTargetObserverRegistry.cpp 613 615 dom/KeyboardEvent.cpp 614 616 dom/MessageChannel.cpp -
trunk/Source/WebCore/ChangeLog
r122582 r122584 1 2012-07-13 Keishi Hattori <keishi@webkit.org> 2 3 Form of FormAssociatedElement is not updated when id target changes. 4 https://bugs.webkit.org/show_bug.cgi?id=91042 5 6 Reviewed by Kent Tamura. 7 8 Test: fast/forms/update-form-attribute-element.html 9 10 This patch introduces the IdTargetObserver and IdTargetObserverRegistry class. 11 They can be used to be notified when the element that an id is pointing to (the id target) 12 changes. 13 14 * CMakeLists.txt: Added IdTargetObserverRegistry.{h,cpp} and IdTargetObserver.{h,cpp} 15 * GNUmakefile.list.am: Ditto. 16 * Target.pri: Ditto. 17 * WebCore.gypi: Ditto. 18 * WebCore.vcproj/WebCore.vcproj: Ditto. 19 * WebCore.xcodeproj/project.pbxproj: Ditto. 20 * dom/DOMAllInOne.cpp: 21 * dom/IdTargetObserver.cpp: Added. When you want notified of changes to an id target, you should create a new class that inherits this. 22 (WebCore): 23 (WebCore::IdTargetObserver::IdTargetObserver): 24 (WebCore::IdTargetObserver::~IdTargetObserver): 25 * dom/IdTargetObserver.h: Added. 26 (WebCore): 27 (IdTargetObserver): 28 * dom/IdTargetObserverRegistry.cpp: Added. 29 (WebCore): 30 (WebCore::IdTargetObserverRegistry::create): 31 (WebCore::IdTargetObserverRegistry::addObserver): Register an IdTargetObserver to observe an id target. 32 (WebCore::IdTargetObserverRegistry::removeObserver): Unregisters an IdTargetObserver from observing. 33 (WebCore::IdTargetObserverRegistry::notifyObserversInternal): 34 * dom/IdTargetObserverRegistry.h: Added. 35 (WebCore): 36 (IdTargetObserverRegistry): 37 (WebCore::IdTargetObserverRegistry::IdTargetObserverRegistry): 38 (WebCore::IdTargetObserverRegistry::notifyObservers): Calls idTargetChanged on all observers for an id. Inlining first part of function for performance. 39 * dom/TreeScope.cpp: 40 (WebCore::TreeScope::TreeScope): 41 (WebCore::TreeScope::addElementById): Calls IdTargetObserverRegistry::notifyObservers because the id target might have changed. 42 (WebCore::TreeScope::removeElementById): Ditto. 43 * dom/TreeScope.h: 44 (WebCore): 45 (WebCore::TreeScope::idTargetObserverRegistry): 46 (TreeScope): 47 * html/FormAssociatedElement.cpp: Observer for id targets defined by the form attribute. 48 (WebCore::FormAssociatedElement::didMoveToNewDocument): 49 (WebCore::FormAssociatedElement::insertedInto): 50 (WebCore::FormAssociatedElement::removedFrom): 51 (WebCore::FormAssociatedElement::formAttributeChanged): 52 (WebCore::FormAssociatedElement::resetFormAttributeTargetObserver): Creates and sets up a new FormAttributeTargetObserver. 53 (WebCore): 54 (WebCore::FormAssociatedElement::formAttributeTargetChanged): 55 (WebCore::FormAttributeTargetObserver::create): 56 (WebCore::FormAttributeTargetObserver::FormAttributeTargetObserver): 57 (WebCore::FormAttributeTargetObserver::idTargetChanged): 58 * html/FormAssociatedElement.h: 59 (FormAssociatedElement): 60 * html/FormController.cpp: 61 * html/FormController.h: 62 (FormController): 63 * html/HTMLFormElement.cpp: 64 (WebCore::HTMLFormElement::removedFrom): 65 (WebCore::HTMLFormElement::formElementIndexWithFormAttribute): Modified to take a range. It 66 scans the range and returns the index to insert the element in m_associatedElement. 67 (WebCore::HTMLFormElement::formElementIndex): Modified to only scan the elements in 68 m_associatedElement that precede and follow the form element. 69 * html/HTMLFormElement.h: 70 (HTMLFormElement): 71 1 72 2012-07-13 Gabor Rapcsanyi <rgabor@webkit.org> 2 73 -
trunk/Source/WebCore/GNUmakefile.list.am
r122582 r122584 1943 1943 Source/WebCore/dom/IconURL.cpp \ 1944 1944 Source/WebCore/dom/IconURL.h \ 1945 Source/WebCore/dom/IdTargetObserver.cpp \ 1946 Source/WebCore/dom/IdTargetObserver.h \ 1947 Source/WebCore/dom/IdTargetObserverRegistry.cpp \ 1948 Source/WebCore/dom/IdTargetObserverRegistry.h \ 1945 1949 Source/WebCore/dom/HashChangeEvent.h \ 1946 1950 Source/WebCore/dom/KeyboardEvent.cpp \ -
trunk/Source/WebCore/Target.pri
r122582 r122584 574 574 dom/GenericEventQueue.cpp \ 575 575 dom/IconURL.cpp \ 576 dom/IdTargetObserver.cpp \ 577 dom/IdTargetObserverRegistry.cpp \ 576 578 dom/KeyboardEvent.cpp \ 577 579 dom/MessageChannel.cpp \ … … 1761 1763 dom/ExceptionCode.h \ 1762 1764 dom/FragmentScriptingPermission.h \ 1765 dom/IdTargetObserver.h \ 1766 dom/IdTargetObserverRegistry.h \ 1763 1767 dom/KeyboardEvent.h \ 1764 1768 dom/MemoryInstrumentation.h \ -
trunk/Source/WebCore/WebCore.gypi
r122582 r122584 5182 5182 'dom/IconURL.cpp', 5183 5183 'dom/IconURL.h', 5184 'dom/IdTargetObserver.cpp', 5185 'dom/IdTargetObserver.h', 5186 'dom/IdTargetObserverRegistry.cpp', 5187 'dom/IdTargetObserverRegistry.h', 5184 5188 'dom/KeyboardEvent.cpp', 5185 5189 'dom/MemoryInstrumentation.h', -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r122582 r122584 51204 51204 </File> 51205 51205 <File 51206 RelativePath="..\dom\IdTargetObserver.cpp" 51207 > 51208 <FileConfiguration 51209 Name="Debug|Win32" 51210 ExcludedFromBuild="true" 51211 > 51212 <Tool 51213 Name="VCCLCompilerTool" 51214 /> 51215 </FileConfiguration> 51216 <FileConfiguration 51217 Name="Release|Win32" 51218 ExcludedFromBuild="true" 51219 > 51220 <Tool 51221 Name="VCCLCompilerTool" 51222 /> 51223 </FileConfiguration> 51224 <FileConfiguration 51225 Name="Debug_Cairo_CFLite|Win32" 51226 ExcludedFromBuild="true" 51227 > 51228 <Tool 51229 Name="VCCLCompilerTool" 51230 /> 51231 </FileConfiguration> 51232 <FileConfiguration 51233 Name="Release_Cairo_CFLite|Win32" 51234 ExcludedFromBuild="true" 51235 > 51236 <Tool 51237 Name="VCCLCompilerTool" 51238 /> 51239 </FileConfiguration> 51240 <FileConfiguration 51241 Name="Debug_All|Win32" 51242 ExcludedFromBuild="true" 51243 > 51244 <Tool 51245 Name="VCCLCompilerTool" 51246 /> 51247 </FileConfiguration> 51248 <FileConfiguration 51249 Name="Production|Win32" 51250 ExcludedFromBuild="true" 51251 > 51252 <Tool 51253 Name="VCCLCompilerTool" 51254 /> 51255 </FileConfiguration> 51256 </File> 51257 <File 51258 RelativePath="..\dom\IdTargetObserver.h" 51259 > 51260 </File> 51261 <File 51262 RelativePath="..\dom\IdTargetObserverRegistry.cpp" 51263 > 51264 <FileConfiguration 51265 Name="Debug|Win32" 51266 ExcludedFromBuild="true" 51267 > 51268 <Tool 51269 Name="VCCLCompilerTool" 51270 /> 51271 </FileConfiguration> 51272 <FileConfiguration 51273 Name="Release|Win32" 51274 ExcludedFromBuild="true" 51275 > 51276 <Tool 51277 Name="VCCLCompilerTool" 51278 /> 51279 </FileConfiguration> 51280 <FileConfiguration 51281 Name="Debug_Cairo_CFLite|Win32" 51282 ExcludedFromBuild="true" 51283 > 51284 <Tool 51285 Name="VCCLCompilerTool" 51286 /> 51287 </FileConfiguration> 51288 <FileConfiguration 51289 Name="Release_Cairo_CFLite|Win32" 51290 ExcludedFromBuild="true" 51291 > 51292 <Tool 51293 Name="VCCLCompilerTool" 51294 /> 51295 </FileConfiguration> 51296 <FileConfiguration 51297 Name="Debug_All|Win32" 51298 ExcludedFromBuild="true" 51299 > 51300 <Tool 51301 Name="VCCLCompilerTool" 51302 /> 51303 </FileConfiguration> 51304 <FileConfiguration 51305 Name="Production|Win32" 51306 ExcludedFromBuild="true" 51307 > 51308 <Tool 51309 Name="VCCLCompilerTool" 51310 /> 51311 </FileConfiguration> 51312 </File> 51313 <File 51314 RelativePath="..\dom\IdTargetObserverRegistry.h" 51315 > 51316 </File> 51317 <File 51206 51318 RelativePath="..\dom\IgnoreDestructiveWriteCountIncrementer.h" 51207 51319 > -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r122582 r122584 5727 5727 C33EE5C514FB49610002095A /* BaseClickableWithKeyInputType.h in Headers */ = {isa = PBXBuildFile; fileRef = C33EE5C314FB49610002095A /* BaseClickableWithKeyInputType.h */; }; 5728 5728 C37CDEBD149EF2030042090D /* ColorChooserClient.h in Headers */ = {isa = PBXBuildFile; fileRef = C37CDEBC149EF2030042090D /* ColorChooserClient.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5729 C3CF17A415B0063F00276D39 /* IdTargetObserver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C3CF17A015B0063F00276D39 /* IdTargetObserver.cpp */; }; 5730 C3CF17A515B0063F00276D39 /* IdTargetObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = C3CF17A115B0063F00276D39 /* IdTargetObserver.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5731 C3CF17A615B0063F00276D39 /* IdTargetObserverRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C3CF17A215B0063F00276D39 /* IdTargetObserverRegistry.cpp */; }; 5732 C3CF17A715B0063F00276D39 /* IdTargetObserverRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = C3CF17A315B0063F00276D39 /* IdTargetObserverRegistry.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5729 5733 C50B561612119D23008B46E0 /* GroupSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C50B561412119D23008B46E0 /* GroupSettings.cpp */; }; 5730 5734 C50B561712119D23008B46E0 /* GroupSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = C50B561512119D23008B46E0 /* GroupSettings.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 12954 12958 C33EE5C314FB49610002095A /* BaseClickableWithKeyInputType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseClickableWithKeyInputType.h; sourceTree = "<group>"; }; 12955 12959 C37CDEBC149EF2030042090D /* ColorChooserClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColorChooserClient.h; sourceTree = "<group>"; }; 12960 C3CF17A015B0063F00276D39 /* IdTargetObserver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IdTargetObserver.cpp; sourceTree = "<group>"; }; 12961 C3CF17A115B0063F00276D39 /* IdTargetObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IdTargetObserver.h; sourceTree = "<group>"; }; 12962 C3CF17A215B0063F00276D39 /* IdTargetObserverRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IdTargetObserverRegistry.cpp; sourceTree = "<group>"; }; 12963 C3CF17A315B0063F00276D39 /* IdTargetObserverRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IdTargetObserverRegistry.h; sourceTree = "<group>"; }; 12956 12964 C50B561412119D23008B46E0 /* GroupSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GroupSettings.cpp; sourceTree = "<group>"; }; 12957 12965 C50B561512119D23008B46E0 /* GroupSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GroupSettings.h; sourceTree = "<group>"; }; … … 21469 21477 45099C401370A7800058D513 /* IconURL.cpp */, 21470 21478 45BAC2AF1360BBAB005DA258 /* IconURL.h */, 21479 C3CF17A015B0063F00276D39 /* IdTargetObserver.cpp */, 21480 C3CF17A115B0063F00276D39 /* IdTargetObserver.h */, 21481 C3CF17A215B0063F00276D39 /* IdTargetObserverRegistry.cpp */, 21482 C3CF17A315B0063F00276D39 /* IdTargetObserverRegistry.h */, 21471 21483 8AB4BC76126FDB7100DEB727 /* IgnoreDestructiveWriteCountIncrementer.h */, 21472 21484 85031B2D0A44EFC700F992E0 /* KeyboardEvent.cpp */, … … 25222 25234 977E2E0F12F0FC9C00C13379 /* XSSAuditor.h in Headers */, 25223 25235 FD537353137B651800008DCE /* ZeroPole.h in Headers */, 25236 C3CF17A515B0063F00276D39 /* IdTargetObserver.h in Headers */, 25237 C3CF17A715B0063F00276D39 /* IdTargetObserverRegistry.h in Headers */, 25224 25238 ); 25225 25239 runOnlyForDeploymentPostprocessing = 0; … … 28281 28295 977E2E0E12F0FC9C00C13379 /* XSSAuditor.cpp in Sources */, 28282 28296 FD537352137B651800008DCE /* ZeroPole.cpp in Sources */, 28297 C3CF17A415B0063F00276D39 /* IdTargetObserver.cpp in Sources */, 28298 C3CF17A615B0063F00276D39 /* IdTargetObserverRegistry.cpp in Sources */, 28283 28299 ); 28284 28300 runOnlyForDeploymentPostprocessing = 0; -
trunk/Source/WebCore/dom/DOMAllInOne.cpp
r122556 r122584 85 85 #include "ExceptionCodePlaceholder.cpp" 86 86 #include "IconURL.cpp" 87 #include "IdTargetObserver.cpp" 88 #include "IdTargetObserverRegistry.cpp" 87 89 #include "KeyboardEvent.cpp" 88 90 #include "MessageChannel.cpp" -
trunk/Source/WebCore/dom/TreeScope.cpp
r122498 r122584 40 40 #include "HTMLMapElement.h" 41 41 #include "HTMLNames.h" 42 #include "IdTargetObserverRegistry.h" 42 43 #include "InsertionPoint.h" 43 44 #include "Page.h" … … 55 56 : m_rootNode(rootNode) 56 57 , m_parentTreeScope(0) 58 , m_idTargetObserverRegistry(IdTargetObserverRegistry::create()) 57 59 { 58 60 ASSERT(rootNode); … … 93 95 { 94 96 m_elementsById.add(elementId.impl(), element); 97 m_idTargetObserverRegistry->notifyObservers(elementId); 95 98 } 96 99 … … 98 101 { 99 102 m_elementsById.remove(elementId.impl(), element); 103 m_idTargetObserverRegistry->notifyObservers(elementId); 100 104 } 101 105 -
trunk/Source/WebCore/dom/TreeScope.h
r122498 r122584 37 37 class Element; 38 38 class HTMLMapElement; 39 class IdTargetObserverRegistry; 39 40 class Node; 40 41 … … 79 80 ContainerNode* rootNode() const { return m_rootNode; } 80 81 82 IdTargetObserverRegistry& idTargetObserverRegistry() const { return *m_idTargetObserverRegistry.get(); } 83 81 84 protected: 82 85 TreeScope(ContainerNode*); … … 91 94 DocumentOrderedMap m_elementsById; 92 95 DocumentOrderedMap m_imageMapsByName; 96 97 OwnPtr<IdTargetObserverRegistry> m_idTargetObserverRegistry; 93 98 94 99 mutable RefPtr<DOMSelection> m_selection; -
trunk/Source/WebCore/html/FormAssociatedElement.cpp
r122559 r122584 31 31 #include "HTMLNames.h" 32 32 #include "HTMLObjectElement.h" 33 #include "IdTargetObserver.h" 33 34 #include "ValidityState.h" 34 35 … … 36 37 37 38 using namespace HTMLNames; 39 40 class FormAttributeTargetObserver : IdTargetObserver { 41 public: 42 static PassOwnPtr<FormAttributeTargetObserver> create(const AtomicString& id, FormAssociatedElement*); 43 virtual void idTargetChanged() OVERRIDE; 44 45 private: 46 FormAttributeTargetObserver(const AtomicString& id, FormAssociatedElement*); 47 48 FormAssociatedElement* m_element; 49 }; 38 50 39 51 FormAssociatedElement::FormAssociatedElement() … … 59 71 HTMLElement* element = toHTMLElement(this); 60 72 if (oldDocument && element->fastHasAttribute(formAttr)) 61 oldDocument->formController()->unregisterFormElementWithFormAttribute(this);73 resetFormAttributeTargetObserver(); 62 74 } 63 75 … … 70 82 HTMLElement* element = toHTMLElement(this); 71 83 if (element->fastHasAttribute(formAttr)) 72 element->document()->formController()->registerFormElementWithFormAttribute(this);84 resetFormAttributeTargetObserver(); 73 85 } 74 86 … … 77 89 HTMLElement* element = toHTMLElement(this); 78 90 if (insertionPoint->inDocument() && element->fastHasAttribute(formAttr)) 79 element->document()->formController()->unregisterFormElementWithFormAttribute(this);91 m_formAttributeTargetObserver = nullptr; 80 92 // If the form and element are both in the same tree, preserve the connection to the form. 81 93 // Otherwise, null out our form and remove ourselves from the form's list of elements. … … 154 166 // The form attribute removed. We need to reset form owner here. 155 167 setForm(element->findFormAncestor()); 156 element->document()->formController()->unregisterFormElementWithFormAttribute(this);157 } else 168 m_formAttributeTargetObserver = nullptr; 169 } else { 158 170 resetFormOwner(); 171 resetFormAttributeTargetObserver(); 172 } 159 173 } 160 174 … … 220 234 { 221 235 m_customValidationMessage = error; 236 } 237 238 void FormAssociatedElement::resetFormAttributeTargetObserver() 239 { 240 m_formAttributeTargetObserver = FormAttributeTargetObserver::create(toHTMLElement(this)->fastGetAttribute(formAttr), this); 241 } 242 243 void FormAssociatedElement::formAttributeTargetChanged() 244 { 245 resetFormOwner(); 222 246 } 223 247 … … 248 272 } 249 273 274 PassOwnPtr<FormAttributeTargetObserver> FormAttributeTargetObserver::create(const AtomicString& id, FormAssociatedElement* element) 275 { 276 return adoptPtr(new FormAttributeTargetObserver(id, element)); 277 } 278 279 FormAttributeTargetObserver::FormAttributeTargetObserver(const AtomicString& id, FormAssociatedElement* element) 280 : IdTargetObserver(toHTMLElement(element)->treeScope()->idTargetObserverRegistry(), id) 281 , m_element(element) 282 { 283 } 284 285 void FormAttributeTargetObserver::idTargetChanged() 286 { 287 m_element->formAttributeTargetChanged(); 288 } 289 250 290 } // namespace Webcore -
trunk/Source/WebCore/html/FormAssociatedElement.h
r122559 r122584 29 29 namespace WebCore { 30 30 31 class FormAttributeTargetObserver; 31 32 class FormDataList; 32 33 class HTMLFormElement; … … 81 82 virtual void setCustomValidity(const String&); 82 83 84 void formAttributeTargetChanged(); 85 83 86 protected: 84 87 FormAssociatedElement(); … … 103 106 virtual void derefFormAssociatedElement() = 0; 104 107 108 void resetFormAttributeTargetObserver(); 109 110 OwnPtr<FormAttributeTargetObserver> m_formAttributeTargetObserver; 105 111 HTMLFormElement* m_form; 106 112 OwnPtr<ValidityState> m_validityState; -
trunk/Source/WebCore/html/FormController.cpp
r122559 r122584 277 277 } 278 278 279 void FormController::registerFormElementWithFormAttribute(FormAssociatedElement* element)280 {281 ASSERT(toHTMLElement(element)->fastHasAttribute(formAttr));282 m_formElementsWithFormAttribute.add(element);283 }284 285 void FormController::unregisterFormElementWithFormAttribute(FormAssociatedElement* element)286 {287 m_formElementsWithFormAttribute.remove(element);288 }289 290 void FormController::resetFormElementsOwner()291 {292 typedef FormAssociatedElementListHashSet::iterator Iterator;293 Iterator end = m_formElementsWithFormAttribute.end();294 for (Iterator it = m_formElementsWithFormAttribute.begin(); it != end; ++it)295 (*it)->resetFormOwner();296 }297 298 279 FormElementKey::FormElementKey(AtomicStringImpl* name, AtomicStringImpl* type, AtomicStringImpl* formKey) 299 280 : m_name(name) -
trunk/Source/WebCore/html/FormController.h
r122559 r122584 134 134 void restoreControlStateIn(HTMLFormElement&); 135 135 136 void registerFormElementWithFormAttribute(FormAssociatedElement*);137 void unregisterFormElementWithFormAttribute(FormAssociatedElement*);138 void resetFormElementsOwner();139 140 136 private: 141 137 FormController(); … … 146 142 typedef ListHashSet<HTMLFormControlElementWithState*, 64> FormElementListHashSet; 147 143 FormElementListHashSet m_formElementsWithState; 148 typedef ListHashSet<RefPtr<FormAssociatedElement>, 32> FormAssociatedElementListHashSet;149 FormAssociatedElementListHashSet m_formElementsWithFormAttribute;150 144 151 145 typedef HashMap<FormElementKey, Deque<FormControlState>, FormElementKeyHash, FormElementKeyHashTraits> FormElementStateMap; -
trunk/Source/WebCore/html/HTMLFormElement.cpp
r122559 r122584 142 142 } 143 143 144 void HTMLFormElement::didNotifyDescendantInsertions(ContainerNode* insertionPoint)145 {146 ASSERT(insertionPoint->inDocument());147 HTMLElement::didNotifyDescendantInsertions(insertionPoint);148 if (hasID())149 document()->formController()->resetFormElementsOwner();150 }151 152 144 static inline Node* findRoot(Node* n) 153 145 { … … 165 157 associatedElements[i]->formRemovedFromTree(root); 166 158 HTMLElement::removedFrom(insertionPoint); 167 if (insertionPoint->inDocument() && hasID())168 document()->formController()->resetFormElementsOwner();169 159 } 170 160 … … 437 427 } 438 428 439 unsigned HTMLFormElement::formElementIndexWithFormAttribute(Element* element) 440 { 441 // Compares the position of the form element and the inserted element. 442 // Updates the indeces in order to the relation of the position: 443 unsigned short position = compareDocumentPosition(element); 444 if (position & (DOCUMENT_POSITION_CONTAINS | DOCUMENT_POSITION_CONTAINED_BY)) 445 ++m_associatedElementsAfterIndex; 446 else if (position & DOCUMENT_POSITION_PRECEDING) { 447 ++m_associatedElementsBeforeIndex; 448 ++m_associatedElementsAfterIndex; 449 } 450 429 unsigned HTMLFormElement::formElementIndexWithFormAttribute(Element* element, unsigned rangeStart, unsigned rangeEnd) 430 { 451 431 if (m_associatedElements.isEmpty()) 452 432 return 0; 453 433 434 ASSERT(rangeStart <= rangeEnd); 435 436 if (rangeStart == rangeEnd) 437 return rangeStart; 438 439 unsigned left = rangeStart; 440 unsigned right = rangeEnd - 1; 441 unsigned short position; 442 454 443 // Does binary search on m_associatedElements in order to find the index 455 444 // to be inserted. 456 unsigned left = 0, right = m_associatedElements.size() - 1;457 445 while (left != right) { 458 446 unsigned middle = left + ((right - left) / 2); 447 ASSERT(middle < m_associatedElementsBeforeIndex || middle >= m_associatedElementsAfterIndex); 459 448 position = element->compareDocumentPosition(toHTMLElement(m_associatedElements[middle])); 460 449 if (position & DOCUMENT_POSITION_FOLLOWING) … … 463 452 left = middle + 1; 464 453 } 465 454 455 ASSERT(left < m_associatedElementsBeforeIndex || left >= m_associatedElementsAfterIndex); 466 456 position = element->compareDocumentPosition(toHTMLElement(m_associatedElements[left])); 467 457 if (position & DOCUMENT_POSITION_FOLLOWING) … … 475 465 // Treats separately the case where this element has the form attribute 476 466 // for performance consideration. 477 if (element->fastHasAttribute(formAttr)) 478 return formElementIndexWithFormAttribute(element); 467 if (element->fastHasAttribute(formAttr)) { 468 unsigned short position = compareDocumentPosition(element); 469 if (position & DOCUMENT_POSITION_PRECEDING) { 470 ++m_associatedElementsBeforeIndex; 471 ++m_associatedElementsAfterIndex; 472 return HTMLFormElement::formElementIndexWithFormAttribute(element, 0, m_associatedElementsBeforeIndex - 1); 473 } 474 if (position & DOCUMENT_POSITION_FOLLOWING && !(position & DOCUMENT_POSITION_CONTAINED_BY)) 475 return HTMLFormElement::formElementIndexWithFormAttribute(element, m_associatedElementsAfterIndex, m_associatedElements.size()); 476 } 479 477 480 478 // Check for the special case where this element is the very last thing in -
trunk/Source/WebCore/html/HTMLFormElement.h
r122559 r122584 120 120 virtual bool rendererIsNeeded(const NodeRenderingContext&); 121 121 virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE; 122 virtual void didNotifyDescendantInsertions(ContainerNode*) OVERRIDE;123 122 virtual void removedFrom(ContainerNode*) OVERRIDE; 124 123 virtual void finishParsingChildren() OVERRIDE; … … 137 136 void submit(Event*, bool activateSubmitButton, bool processingUserGesture, FormSubmissionTrigger); 138 137 139 unsigned formElementIndexWithFormAttribute(Element* );138 unsigned formElementIndexWithFormAttribute(Element*, unsigned rangeStart, unsigned rangeEnd); 140 139 unsigned formElementIndex(FormAssociatedElement*); 141 140
Note: See TracChangeset
for help on using the changeset viewer.