LayoutTests:
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 1 Apr 2006 23:35:17 +0000 (23:35 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 1 Apr 2006 23:35:17 +0000 (23:35 +0000)
        Reviewed by Justin.

        - test for http://bugzilla.opendarwin.org/show_bug.cgi?id=8106
          REGRESSION (NativeTextField): New text fields don't scroll to the beginning when losing focus

        * fast/forms/input-text-scroll-left-on-blur-expected.png: Added.
        * fast/forms/input-text-scroll-left-on-blur-expected.txt: Added.
        * fast/forms/input-text-scroll-left-on-blur-expected.checksum: Added.
        * fast/forms/input-text-scroll-left-on-blur.html: Added.

WebCore:

        Reviewed by Justin.

        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=8106
          REGRESSION (NativeTextField): New text fields don't scroll to the beginning when losing focus

        Test: fast/forms/input-text-scroll-left-on-blur.html

        * html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::defaultEventHandler): Pass blur events
        through to the RenderTextField, as well as mouse, drag, and wheel events.
        * rendering/RenderTextField.cpp: (WebCore::RenderTextField::forwardEvent): Scroll all the way to
        the left on a blur.

        - unrelated small changes

        * html/HTMLTextFieldInnerElement.cpp: Removed excess includes.
        (WebCore::HTMLTextFieldInnerElement::defaultEventHandler): Tweaked comments a bit.

        * dom/Element.cpp:
        (WebCore::Element::scrollIntoView): Removed unneeded this-> before function call.
        (WebCore::Element::scrollIntoViewIfNeeded): Ditto.

        * page/FrameView.cpp: (WebCore::FrameView::dispatchMouseEvent): Removed obsolete comment.

WebKitTools:

        Reviewed by Justin.

        * DumpRenderTree/EventSendingController.m: (-[EventSendingController keyDown:withModifiers:]):
        Fixed keyDown function so that it will work if you don't pass an array of modifiers or if
        elements in that array are not strings.

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

12 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/forms/input-text-scroll-left-on-blur-expected.checksum [new file with mode: 0644]
LayoutTests/fast/forms/input-text-scroll-left-on-blur-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/input-text-scroll-left-on-blur.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/dom/Element.cpp
WebCore/html/HTMLInputElement.cpp
WebCore/html/HTMLTextFieldInnerElement.cpp
WebCore/page/FrameView.cpp
WebCore/rendering/RenderTextField.cpp
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/EventSendingController.m

index 6ead52d73260cf74f47cef79599ba0b311a5431e..40c46ee604f1ed1d85125712b807e18d8cc85cce 100644 (file)
@@ -1,3 +1,15 @@
+2006-04-01  Darin Adler  <darin@apple.com>
+
+        Reviewed by Justin.
+
+        - test for http://bugzilla.opendarwin.org/show_bug.cgi?id=8106
+          REGRESSION (NativeTextField): New text fields don't scroll to the beginning when losing focus
+
+        * fast/forms/input-text-scroll-left-on-blur-expected.png: Added.
+        * fast/forms/input-text-scroll-left-on-blur-expected.txt: Added.
+        * fast/forms/input-text-scroll-left-on-blur-expected.checksum: Added.
+        * fast/forms/input-text-scroll-left-on-blur.html: Added.
+
 2006-04-01  Darin Adler  <darin@apple.com>
 
         - re-updated many pixel results to try to create a new baseline
diff --git a/LayoutTests/fast/forms/input-text-scroll-left-on-blur-expected.checksum b/LayoutTests/fast/forms/input-text-scroll-left-on-blur-expected.checksum
new file mode 100644 (file)
index 0000000..a1915c3
--- /dev/null
@@ -0,0 +1 @@
+861eb966f62499267d70711e0fc911f8
\ No newline at end of file
diff --git a/LayoutTests/fast/forms/input-text-scroll-left-on-blur-expected.txt b/LayoutTests/fast/forms/input-text-scroll-left-on-blur-expected.txt
new file mode 100644 (file)
index 0000000..575d25d
--- /dev/null
@@ -0,0 +1,37 @@
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldInsertText:l replacingDOMRange:range from 65 of #text > DIV to 65 of #text > DIV givenAction:WebViewInsertActionTyped
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 65 of #text > DIV to 65 of #text > DIV toDOMRange:range from 66 of #text > DIV to 66 of #text > DIV affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldInsertText:l replacingDOMRange:range from 65 of #text > DIV to 65 of #text > DIV givenAction:WebViewInsertActionTyped
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 65 of #text > DIV to 65 of #text > DIV toDOMRange:range from 66 of #text > DIV to 66 of #text > DIV affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+layer at (0,0) size 800x600
+  RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x576
+      RenderBlock (anonymous) at (0,0) size 784x23
+        RenderTextField {INPUT} at (2,2) size 148x19 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
+        RenderText {TEXT} at (152,2) size 4x18
+          text run at (152,2) width 4: " "
+        RenderTextField {INPUT} at (158,2) size 148x19 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
+        RenderText {TEXT} at (0,0) size 0x0
+      RenderBlock {P} at (0,39) size 784x36
+        RenderText {TEXT} at (0,0) size 777x36
+          text run at (0,0) width 777: "Tests scrolling back to the beginning when a text field blurs. The first field should be scrolled to the left, the second scrolled"
+          text run at (0,18) width 72: "to the right."
+layer at (13,13) size 142x13 scrollWidth 321
+  RenderBlock {DIV} at (3,3) size 142x13
+    RenderText {TEXT} at (1,0) size 319x13
+      text run at (1,0) width 319: "this text field has a lot of text in it so that it needs to scroll"
+layer at (169,13) size 142x13 scrollX 179 scrollWidth 321
+  RenderBlock {DIV} at (3,3) size 142x13
+    RenderText {TEXT} at (1,0) size 319x13
+      text run at (1,0) width 319: "this text field has a lot of text in it so that it needs to scroll"
+caret: position 66 of child 0 {TEXT} of document
diff --git a/LayoutTests/fast/forms/input-text-scroll-left-on-blur.html b/LayoutTests/fast/forms/input-text-scroll-left-on-blur.html
new file mode 100644 (file)
index 0000000..d8145e8
--- /dev/null
@@ -0,0 +1,18 @@
+<input id="a" type="text" value="this text field has a lot of text in it so that it needs to scrol">
+<input id="b" type="text" value="this text field has a lot of text in it so that it needs to scrol">
+<p>Tests scrolling back to the beginning when a text field blurs. The first field should be scrolled to the left, the second scrolled to the right.</p>
+<script>
+var a = document.getElementById("a");
+a.focus();
+a.setSelectionRange(66, 66);
+if (window.eventSender) {
+    eventSender.keyDown("l");
+}
+a.blur();
+var b = document.getElementById("b");
+b.focus();
+b.setSelectionRange(66, 66);
+if (window.eventSender) {
+    eventSender.keyDown("l");
+}
+</script>
index 6591d0ce8902140dc5d35c12381dfdfb625abca8..530cf7ee4d0d3e467d5b852d85ae93c42ec8eb91 100644 (file)
@@ -1,3 +1,28 @@
+2006-04-01  Darin Adler  <darin@apple.com>
+
+        Reviewed by Justin.
+
+        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=8106
+          REGRESSION (NativeTextField): New text fields don't scroll to the beginning when losing focus
+
+        Test: fast/forms/input-text-scroll-left-on-blur.html
+
+        * html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::defaultEventHandler): Pass blur events
+        through to the RenderTextField, as well as mouse, drag, and wheel events.
+        * rendering/RenderTextField.cpp: (WebCore::RenderTextField::forwardEvent): Scroll all the way to
+        the left on a blur.
+
+        - unrelated small changes
+
+        * html/HTMLTextFieldInnerElement.cpp: Removed excess includes.
+        (WebCore::HTMLTextFieldInnerElement::defaultEventHandler): Tweaked comments a bit.
+
+        * dom/Element.cpp:
+        (WebCore::Element::scrollIntoView): Removed unneeded this-> before function call.
+        (WebCore::Element::scrollIntoViewIfNeeded): Ditto.
+
+        * page/FrameView.cpp: (WebCore::FrameView::dispatchMouseEvent): Removed obsolete comment.
+
 2006-03-31  Maciej Stachowiak  <mjs@apple.com>
 
         Reviewed by Adele.
index cc343228959c281992c91861f61b659c65f077e5..715da4d6f6289ae1d2e4ce9f3f0e5b32699d1f72 100644 (file)
@@ -130,7 +130,7 @@ const AtomicString& Element::getAttribute(const QualifiedName& name) const
 
 void Element::scrollIntoView(bool alignToTop) 
 {
-    IntRect bounds = this->getRect();    
+    IntRect bounds = getRect();    
     if (renderer()) {
         // Align to the top / bottom and to the closest edge.
         if (alignToTop)
@@ -142,7 +142,7 @@ void Element::scrollIntoView(bool alignToTop)
 
 void Element::scrollIntoViewIfNeeded(bool centerIfNeeded)
 {
-    IntRect bounds = this->getRect();    
+    IntRect bounds = getRect();    
     if (renderer()) {
         if (centerIfNeeded)
             renderer()->enclosingLayer()->scrollRectToVisible(bounds, RenderLayer::gAlignCenterIfNeeded, RenderLayer::gAlignCenterIfNeeded);
index 8ef6eb9a05d6833067ec749a77f17ad955d3bae7..72ae8e49a19743033c84689b381bae8aa0125961 100644 (file)
@@ -1191,7 +1191,7 @@ void HTMLInputElement::defaultEventHandler(Event *evt)
         }        
     }
     
-    if (m_type == TEXT && (evt->isMouseEvent() || evt->isDragEvent() || evt->isWheelEvent()) && renderer())
+    if (m_type == TEXT && (evt->isMouseEvent() || evt->isDragEvent() || evt->isWheelEvent() || evt->type() == blurEvent) && renderer())
         static_cast<RenderTextField*>(renderer())->forwardEvent(evt);
     
     HTMLGenericFormElement::defaultEventHandler(evt);
index 30fbf2c589c1ea81ff3cef4417b1a72b0379778c..ce2b3c905130378e6f37ae9c6468ae7a796cd4db 100644 (file)
 
 #include "BeforeTextInsertedEvent.h"
 #include "EventNames.h"
-#include "dom2_eventsimpl.h"
-#include "HTMLDocument.h"
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
-#include "RenderObject.h"
 #include "RenderTextField.h"
 
 namespace WebCore {
@@ -47,17 +44,18 @@ HTMLTextFieldInnerElement::HTMLTextFieldInnerElement(Document* doc, Node* shadow
 
 void HTMLTextFieldInnerElement::defaultEventHandler(Event* evt)
 {
-    // FIXME:  In the future, we should add a way to have default event listeners.  Then we would add one to the text field's inner div, and we wouldn't need this subclass.
+    // FIXME: In the future, we should add a way to have default event listeners.  Then we would add one to the text field's inner div, and we wouldn't need this subclass.
     if (shadowParentNode() && shadowParentNode()->hasTagName(inputTag) && shadowParentNode()->renderer() && shadowParentNode()->renderer()->isTextField()) {
         if (evt->isBeforeTextInsertedEvent())
             static_cast<HTMLInputElement*>(shadowParentNode())->defaultEventHandler(evt);
 
         if (evt->type() == khtmlEditableContentChangedEvent) {
-            // FIXME:  When other text fields switch to the Non-NSView implementation, we may beed to add them here.
+            // FIXME: When other text fields switch to the Non-NSView implementation, we may beed to add them here.
             if (static_cast<HTMLInputElement*>(shadowParentNode())->inputType() == HTMLInputElement::TEXT) 
                 static_cast<RenderTextField*>(shadowParentNode()->renderer())->subtreeHasChanged();
         }
     }
+
     HTMLDivElement::defaultEventHandler(evt);
 }
 
index 60f0650e692f837fa9ed5a0d76b65106cb21913e..ca5ab8be1b9b9276ff2ac20b08c6d8d30914e99e 100644 (file)
@@ -977,7 +977,6 @@ bool FrameView::dispatchMouseEvent(const AtomicString& eventType, Node* targetNo
         swallowEvent = EventTargetNodeCast(targetNode)->dispatchMouseEvent(mouseEvent, eventType, clickCount);
     
     if (!swallowEvent && eventType == mousedownEvent) {
-        // Focus should be shifted on mouse down, not on a click.  -dwh
         // Blur current focus node when a link/button is clicked; this
         // is expected by some sites that rely on onChange handlers running
         // from form fields before the button click is processed.
index dc47e1c39dcc59b9cb534e9d889eb5b0e1682db6..5cbd4f48c65d8c86c3d2a7af60b03b859cc25dff 100644 (file)
 #include "config.h"
 #include "RenderTextField.h"
 
-#include <algorithm>
 #include "Document.h"
+#include "EventNames.h"
 #include "Frame.h"
-#include "RenderText.h"
-#include "HTMLNames.h"
 #include "HTMLInputElement.h"
+#include "HTMLNames.h"
 #include "HTMLTextFieldInnerElement.h"
+#include "RenderText.h"
 #include "SelectionController.h"
-#include "VisiblePosition.h"
 #include "TextIterator.h"
+#include "VisiblePosition.h"
+#include "dom2_eventsimpl.h"
+#include <algorithm>
 
 namespace WebCore {
 
+using namespace EventNames;
 using namespace HTMLNames;
 using namespace std;
 
 RenderTextField::RenderTextField(Node* node)
-:RenderBlock(node), m_dirty(false)
+    : RenderBlock(node), m_dirty(false)
 {
 }
 
@@ -128,7 +131,6 @@ void RenderTextField::updateFromElement()
     }
 }
 
-
 int RenderTextField::selectionStart()
 {
     return indexForVisiblePosition(document()->frame()->selection().start());        
@@ -228,7 +230,15 @@ void RenderTextField::calcMinMaxWidth()
 
 void RenderTextField::forwardEvent(Event* evt)
 {
-    m_div->defaultEventHandler(evt);
+    if (evt->type() == blurEvent) {
+        RenderObject* innerRenderer = m_div->renderer();
+        if (innerRenderer) {
+            RenderLayer* innerLayer = innerRenderer->layer();
+            if (innerLayer)
+                innerLayer->scrollToOffset(0, 0);
+        }
+    } else
+        m_div->defaultEventHandler(evt);
 }
 
 }
index 6bf4cebf49e5f571e93044877baa67ce3660d63a..8328754115d66cc499782a61bbbb7d8d96e88e86 100644 (file)
@@ -1,3 +1,11 @@
+2006-04-01  Darin Adler  <darin@apple.com>
+
+        Reviewed by Justin.
+
+        * DumpRenderTree/EventSendingController.m: (-[EventSendingController keyDown:withModifiers:]):
+        Fixed keyDown function so that it will work if you don't pass an array of modifiers or if
+        elements in that array are not strings.
+
 2006-03-31  Darin Adler  <darin@apple.com>
 
         Reviewed by John Sullivan.
index 8b399ffcdd84f486224c1d5e307a322f0e7b72dc..afb4053632d927130fb03dc7a643db0f774d06ff 100644 (file)
@@ -201,19 +201,20 @@ NSPoint lastMousePosition;
     NSString *modifier = nil;
     int mask = 0;
     
-    for (unsigned i = 0; modifiers && [modifiers webScriptValueAtIndex:i]; i++) {
-        modifier = (NSString *)[modifiers webScriptValueAtIndex:i];
-        if ([modifier isEqual:@"ctrlKey"])
-            mask |= NSControlKeyMask;
-        else if ([modifier isEqual:@"shiftKey"])
-            mask |= NSShiftKeyMask;
-        else if ([modifier isEqual:@"altKey"])
-            mask |= NSAlternateKeyMask;
-        else if ([modifier isEqual:@"metaKey"])
-            mask |= NSCommandKeyMask;
-        else
-            break;
-    }
+    if ([modifiers isKindOfClass:[WebScriptObject class]])
+        for (unsigned i = 0; [[modifiers webScriptValueAtIndex:i] isKindOfClass:[NSString class]]; i++) {
+            modifier = (NSString *)[modifiers webScriptValueAtIndex:i];
+            if ([modifier isEqual:@"ctrlKey"])
+                mask |= NSControlKeyMask;
+            else if ([modifier isEqual:@"shiftKey"])
+                mask |= NSShiftKeyMask;
+            else if ([modifier isEqual:@"altKey"])
+                mask |= NSAlternateKeyMask;
+            else if ([modifier isEqual:@"metaKey"])
+                mask |= NSCommandKeyMask;
+            else
+                break;
+        }
 
     [[[frame frameView] documentView] layout];