Reviewed by Adele.
authoraliceli1 <aliceli1@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Jul 2006 05:18:42 +0000 (05:18 +0000)
committeraliceli1 <aliceli1@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Jul 2006 05:18:42 +0000 (05:18 +0000)
        Fixed <rdar://problem/4532113> REGRESSION (NativeTextField): Crash occurs after modifying field then reloading page -[FormDelegate frameLayoutHasChanged:]
        added a manual test because of the need to use AutoFill.

        * dom/Node.h:
        (WebCore::Node::aboutToUnload):
        added virtual function prototype
        * html/HTMLInputElement.cpp:
        (WebCore::HTMLInputElement::aboutToUnload):
        added implementation that sends textFieldDidEndEditing notification
        * html/HTMLInputElement.h:
        added virtual function prototype
        * manual-tests/input-type-file-autocomplete-frame-1.html: Added.
        * manual-tests/input-type-file-autocomplete-frame-2.html: Added.
        * manual-tests/input-type-file-autocomplete-refresh.html: Added.
        * page/Frame.cpp:
        (WebCore::Frame::stopLoading):
        before unloading, call aboutToUnload on the current focused node

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@15550 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/dom/Node.h
WebCore/html/HTMLInputElement.cpp
WebCore/html/HTMLInputElement.h
WebCore/manual-tests/input-type-file-autocomplete-frame-1.html [new file with mode: 0644]
WebCore/manual-tests/input-type-file-autocomplete-frame-2.html [new file with mode: 0644]
WebCore/manual-tests/input-type-file-autocomplete-refresh.html [new file with mode: 0644]
WebCore/page/Frame.cpp

index e39f6c6871d100d7628f8bbe5f977e5986d68a88..fc7ce5c9c171d6e2c65d6e2de511a91ff8ffa4f3 100644 (file)
@@ -1,3 +1,25 @@
+2006-07-20  Alice Liu  <alice.liu@apple.com>
+
+        Reviewed by Adele.
+
+        Fixed <rdar://problem/4532113> REGRESSION (NativeTextField): Crash occurs after modifying field then reloading page -[FormDelegate frameLayoutHasChanged:]
+        added a manual test because of the need to use AutoFill.
+
+        * dom/Node.h:
+        (WebCore::Node::aboutToUnload):
+        added virtual function prototype
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::aboutToUnload):
+        added implementation that sends textFieldDidEndEditing notification
+        * html/HTMLInputElement.h:
+        added virtual function prototype
+        * manual-tests/input-type-file-autocomplete-frame-1.html: Added.
+        * manual-tests/input-type-file-autocomplete-frame-2.html: Added.
+        * manual-tests/input-type-file-autocomplete-refresh.html: Added.
+        * page/Frame.cpp:
+        (WebCore::Frame::stopLoading):
+        before unloading, call aboutToUnload on the current focused node
+
 2006-07-20  Brady Eidson  <beidson@apple.com>
 
         Reviewed by Maciej
index edbd9c7c92cd9cdabef9b464bae57624b4e9bdef..7eeb4236b0d1562b6eaca0399b755e4669c33f2c 100644 (file)
@@ -197,6 +197,11 @@ public:
     // but making parsing a special case in this respect should be avoided if possible.
     virtual void closeRenderer() { }
 
+    // Called by the frame right before dispatching an unloadEvent. [Radar 4532113]
+    // This is needed for HTMLInputElements to tell the frame that it is done editing 
+    // (sends textFieldDidEndEditing notification)
+    virtual void aboutToUnload() { }
+
     // For <link> and <style> elements.
     virtual void sheetLoaded() { }
 
index 758d6f1405b9a9ec04e7b620c5a4d26b062afd4b..6708ab22cf07a87515a1bf41e6dc77cb8dab96ad 100644 (file)
@@ -204,6 +204,12 @@ void HTMLInputElement::updateFocusAppearance()
         HTMLGenericFormElement::updateFocusAppearance();
 }
 
+void HTMLInputElement::aboutToUnload()
+{
+    if (isNonWidgetTextField() && document()->frame())
+        document()->frame()->textFieldDidEndEditing(this);
+}
+
 void HTMLInputElement::dispatchFocusEvent()
 {
     if (isNonWidgetTextField())
index 3855e262576383700206595d1d4ed436040efdd7..b5e4925107f6f9a4811369299853f8653ea4dfcf 100644 (file)
@@ -65,6 +65,7 @@ public:
     virtual void dispatchFocusEvent();
     virtual void dispatchBlurEvent();
     virtual void updateFocusAppearance();
+    virtual void aboutToUnload();
 
     virtual const AtomicString& name() const;
 
diff --git a/WebCore/manual-tests/input-type-file-autocomplete-frame-1.html b/WebCore/manual-tests/input-type-file-autocomplete-frame-1.html
new file mode 100644 (file)
index 0000000..6abc90c
--- /dev/null
@@ -0,0 +1,23 @@
+<html>
+<body>
+<p><b>BUG ID:</b> <a href="<rdar://problem/4532113> REGRESSION (NativeTextField): Crash occurs after modifying field then reloading page -[FormDelegate frameLayoutHasChanged:]">4532113</a> REGRESSION (NativeTextField): Crash occurs after modifying field then reloading page -[FormDelegate frameLayoutHasChanged:]</p>
+
+<p id="test" style="background-color:skyblue; padding:3px;"><b>STEPS TO TEST:</b> 
+<ol>
+<li> enable Safari's auto fill
+<li> type something in the input field, and press enter to register it with autofill
+<li> clear the field and type part of the same string you did previously
+<li> without ever removing focus from the input field, select the suggestion autofill suggests
+<li> refresh the page or go to a bookmark (don't remove focus from the input field)
+</ol>
+</p>
+
+<p id="success" style="background-color:palegreen; padding:3px;"><b>TEST PASS:</b> 
+no crash. 
+</p>
+
+<p id="failure" style="background-color:#FF3300; padding:3px;"><b>TEST FAIL:</b>  
+Crash in -[FormDelegate frameLayoutHasChanged:]
+</p>
+</body>
+</html>
diff --git a/WebCore/manual-tests/input-type-file-autocomplete-frame-2.html b/WebCore/manual-tests/input-type-file-autocomplete-frame-2.html
new file mode 100644 (file)
index 0000000..d3cd114
--- /dev/null
@@ -0,0 +1,7 @@
+<html>
+<body>
+<table><tr><td>
+<form><input size=55 value="type something in here"></form>
+</td></tr></table>
+</body>
+</html>
diff --git a/WebCore/manual-tests/input-type-file-autocomplete-refresh.html b/WebCore/manual-tests/input-type-file-autocomplete-refresh.html
new file mode 100644 (file)
index 0000000..eea8dab
--- /dev/null
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+        "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+
+<frameset rows="50%,50%"> 
+    <frame src="./input-type-file-autocomplete-frame-1.html">   
+    <frame src="./input-type-file-autocomplete-frame-2.html">
+</frameset>
+
+</html>
index 01aff4f05cb136b78d8c566c049ced466cb44ca3..bd1818a2908a6eab190fbbc5e5d8343072f9a5c9 100644 (file)
@@ -52,6 +52,7 @@
 #include "HTMLGenericFormElement.h"
 #include "HTMLNames.h"
 #include "HTMLObjectElement.h"
+#include "HTMLInputElement.h"
 #include "ImageDocument.h"
 #include "MediaFeatureNames.h"
 #include "MouseEventWithHitTestResults.h"
@@ -280,6 +281,9 @@ void Frame::stopLoading(bool sendUnload)
   if (sendUnload) {
     if (d->m_doc) {
       if (d->m_bLoadEventEmitted && !d->m_bUnloadEventEmitted) {
+        Node* currentFocusNode = d->m_doc->focusNode();
+        if (currentFocusNode)
+            currentFocusNode->aboutToUnload();
         d->m_doc->dispatchWindowEvent(unloadEvent, false, false);
         if (d->m_doc)
           d->m_doc->updateRendering();