Changeset 21447 in webkit
- Timestamp:
- May 13, 2007 8:28:01 AM (17 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r21446 r21447 1 2007-05-13 Brady Eidson <beidson@apple.com> 2 3 Reviewed by Mitz 4 5 http://bugs.webkit.org/show_bug.cgi?id=13701 6 7 Since HTMLInputElements register themselves with their Document for special handling, if their document 8 ever changes then bad things can happen. 9 10 Unfortunately, with adoptNode, the document can change. This has been a long standing crasher with all 11 input fields but was given recent high visibility by r21430 12 13 The solution is to add functionality for a Node to react to its owner document changing via a pair of 14 virtual callbacks. Then we can tap into those callbacks in HTMLInputElement. 15 16 No layout test possible until http://bugs.webkit.org/show_bug.cgi?id=13672 is resolved 17 18 * dom/Node.cpp: 19 (WebCore::Node::setDocument): Call willMoveToNewOwnerDocument and didMoveToNewOwnerDocument 20 21 * dom/Node.h: 22 (WebCore::Node::willMoveToNewOwnerDocument): Virtual callback to a node for before an owner document change 23 (WebCore::Node::didMoveToNewOwnerDocument): Virtual callback to a node for after an owner document change 24 25 * html/HTMLInputElement.cpp: 26 (WebCore::HTMLInputElement::~HTMLInputElement): Unconditionally unregister both for both form state 27 and the cache restoration callback 28 (WebCore::HTMLInputElement::setInputType): Change registration with the document only if we're in one 29 (WebCore::HTMLInputElement::attach): Don't bother registering for the callback here - that will be 30 handled by setInputType() or by a change in owner document 31 (WebCore::HTMLInputElement::willMoveToNewOwnerDocument): Unregister with the old owner document 32 (WebCore::HTMLInputElement::didMoveToNewOwnerDocument): Register with the new owner document 33 * html/HTMLInputElement.h: 34 1 35 2007-05-13 Darin Adler <darin@apple.com> 2 36 -
trunk/WebCore/dom/Node.cpp
r21405 r21447 169 169 return; 170 170 171 willMoveToNewOwnerDocument(); 172 171 173 { 172 174 KJS::JSLock lock; 173 175 KJS::ScriptInterpreter::updateDOMNodeDocument(this, m_document.get(), doc); 174 } 176 } 175 177 m_document = doc; 178 179 didMoveToNewOwnerDocument(); 176 180 } 177 181 -
trunk/WebCore/dom/Node.h
r21278 r21447 456 456 457 457 protected: 458 virtual void willMoveToNewOwnerDocument() { } 459 virtual void didMoveToNewOwnerDocument() { } 460 458 461 NodeListsNodeData* m_nodeLists; 459 462 -
trunk/WebCore/html/HTMLInputElement.cpp
r21445 r21447 137 137 HTMLInputElement::~HTMLInputElement() 138 138 { 139 document()->unregisterFormElementWithState(this);140 document()->unregisterForDidRestoreFromCacheCallback(this);139 ownerDocument()->unregisterFormElementWithState(this); 140 ownerDocument()->unregisterForDidRestoreFromCacheCallback(this); 141 141 delete m_imageLoader; 142 142 } … … 324 324 325 325 if (wasPasswordField && !isPasswordField) { 326 document()->registerFormElementWithState(this);327 document()->unregisterForDidRestoreFromCacheCallback(this);326 ownerDocument()->registerFormElementWithState(this); 327 ownerDocument()->unregisterForDidRestoreFromCacheCallback(this); 328 328 } else if (!wasPasswordField && isPasswordField) { 329 document()->unregisterFormElementWithState(this);330 document()->registerForDidRestoreFromCacheCallback(this);329 ownerDocument()->unregisterFormElementWithState(this); 330 ownerDocument()->registerForDidRestoreFromCacheCallback(this); 331 331 } 332 332 … … 762 762 } 763 763 } 764 765 if (inputType() == PASSWORD)766 document()->registerForDidRestoreFromCacheCallback(this);767 764 } 768 765 … … 1479 1476 reset(); 1480 1477 } 1478 1479 void HTMLInputElement::willMoveToNewOwnerDocument() 1480 { 1481 if (inputType() == PASSWORD) 1482 ownerDocument()->unregisterForDidRestoreFromCacheCallback(this); 1483 else 1484 ownerDocument()->unregisterFormElementWithState(this); 1485 1486 HTMLGenericFormElement::willMoveToNewOwnerDocument(); 1487 } 1488 1489 void HTMLInputElement::didMoveToNewOwnerDocument() 1490 { 1491 if (inputType() == PASSWORD) 1492 document()->registerForDidRestoreFromCacheCallback(this); 1493 else 1494 document()->registerFormElementWithState(this); 1495 1496 HTMLGenericFormElement::didMoveToNewOwnerDocument(); 1497 } 1481 1498 1482 1499 } // namespace -
trunk/WebCore/html/HTMLInputElement.h
r21430 r21447 187 187 188 188 protected: 189 virtual void willMoveToNewOwnerDocument(); 190 virtual void didMoveToNewOwnerDocument(); 191 189 192 AtomicString m_name; 190 193
Note: See TracChangeset
for help on using the changeset viewer.