LayoutTests:
authoradele <adele@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 23 Jul 2006 08:52:48 +0000 (08:52 +0000)
committeradele <adele@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 23 Jul 2006 08:52:48 +0000 (08:52 +0000)
        Reviewed by Maciej.

        Test for: <rdar://problem/4644614> REGRESSION: Typing, pasting or dragging in new text areas causes unnecessary scrolling

        * fast/forms/textarea-scrolled-type-expected.checksum: Added.
        * fast/forms/textarea-scrolled-type-expected.png: Added.
        * fast/forms/textarea-scrolled-type-expected.txt: Added.
        * fast/forms/textarea-scrolled-type.html: Added.

WebCore:

        Reviewed by Maciej.

        - Fix for <rdar://problem/4644614> REGRESSION: Typing, pasting or dragging in new text areas causes unnecessary scrolling

        * rendering/RenderBlock.cpp: (WebCore::RenderBlock::layoutBlock): Don't updateScrollInfoAfterLayout if an ancestor flexible box is just on
        its first layout.
        * rendering/RenderFlexibleBox.cpp:
        (WebCore::RenderFlexibleBox::layoutBlock): ditto.
        (WebCore::RenderFlexibleBox::layoutVerticalBox): Let the view know if this flex box is doing its first pass at layout.

        * rendering/RenderView.cpp: (WebCore::RenderView::RenderView): Caches a flexible box that's doing its first layout.
        * rendering/RenderView.h:
        (WebCore::RenderView::setFlexBoxInFirstLayout):
        (WebCore::RenderView::flexBoxInFirstLayout):

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

LayoutTests/ChangeLog
LayoutTests/fast/forms/textarea-scrolled-type-expected.checksum [new file with mode: 0644]
LayoutTests/fast/forms/textarea-scrolled-type-expected.png [new file with mode: 0644]
LayoutTests/fast/forms/textarea-scrolled-type-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/textarea-scrolled-type.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/rendering/RenderBlock.cpp
WebCore/rendering/RenderFlexibleBox.cpp
WebCore/rendering/RenderView.cpp
WebCore/rendering/RenderView.h

index 3477d3ca55d6725bfbe7d7ed3aee065d98abc67e..91b43d72b03d7ffa32e0609dc098c9ed429a62b9 100644 (file)
@@ -1,3 +1,14 @@
+2006-07-23  Adele Peterson  <adele@apple.com>
+
+        Reviewed by Maciej.
+
+        Test for: <rdar://problem/4644614> REGRESSION: Typing, pasting or dragging in new text areas causes unnecessary scrolling
+
+        * fast/forms/textarea-scrolled-type-expected.checksum: Added.
+        * fast/forms/textarea-scrolled-type-expected.png: Added.
+        * fast/forms/textarea-scrolled-type-expected.txt: Added.
+        * fast/forms/textarea-scrolled-type.html: Added.
+
 2006-07-22  Alexey Proskuryakov  <ap@nypop.com>
 
         Reviewed by Darin.
diff --git a/LayoutTests/fast/forms/textarea-scrolled-type-expected.checksum b/LayoutTests/fast/forms/textarea-scrolled-type-expected.checksum
new file mode 100644 (file)
index 0000000..6098b26
--- /dev/null
@@ -0,0 +1 @@
+7f38cf2e654f194ce1a95e256537fbfe
\ No newline at end of file
diff --git a/LayoutTests/fast/forms/textarea-scrolled-type-expected.png b/LayoutTests/fast/forms/textarea-scrolled-type-expected.png
new file mode 100644 (file)
index 0000000..74f36b5
Binary files /dev/null and b/LayoutTests/fast/forms/textarea-scrolled-type-expected.png differ
diff --git a/LayoutTests/fast/forms/textarea-scrolled-type-expected.txt b/LayoutTests/fast/forms/textarea-scrolled-type-expected.txt
new file mode 100644 (file)
index 0000000..b382958
--- /dev/null
@@ -0,0 +1,94 @@
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 2 of #text > DIV to 2 of #text > DIV toDOMRange:range from 3 of #text > DIV to 3 of #text > DIV affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 3 of #text > DIV to 3 of #text > DIV toDOMRange:range from 4 of #text > DIV to 4 of #text > DIV affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 4 of #text > DIV to 4 of #text > DIV toDOMRange:range from 5 of #text > DIV to 5 of #text > DIV affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 5 of #text > DIV to 5 of #text > DIV toDOMRange:range from 6 of #text > DIV to 6 of #text > DIV affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 6 of #text > DIV to 6 of #text > DIV toDOMRange:range from 7 of #text > DIV to 7 of #text > DIV affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock (anonymous) at (0,0) size 784x119
+        RenderText {#text} at (0,0) size 502x18
+          text run at (0,0) width 502: "This tests that typing in a scrolled textarea does not cause unnecessary scrolling."
+        RenderBR {BR} at (502,14) size 0x0
+        RenderTextField {TEXTAREA} at (2,20) size 163x93 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
+        RenderText {#text} at (167,101) size 4x18
+          text run at (167,101) width 4: " "
+        RenderBR {BR} at (171,115) size 0x0
+      RenderBlock {DIV} at (0,119) size 784x0
+layer at (11,29) size 161x91 clip at (11,29) size 146x91 scrollY 169 scrollHeight 260
+  RenderBlock {DIV} at (1,1) size 161x91
+    RenderText {#text} at (3,0) size 7x13
+      text run at (3,0) width 7: "1"
+    RenderBR {BR} at (10,11) size 0x0
+    RenderText {#text} at (3,13) size 7x13
+      text run at (3,13) width 7: "2"
+    RenderBR {BR} at (10,24) size 0x0
+    RenderText {#text} at (3,26) size 7x13
+      text run at (3,26) width 7: "3"
+    RenderBR {BR} at (10,37) size 0x0
+    RenderText {#text} at (3,39) size 7x13
+      text run at (3,39) width 7: "4"
+    RenderBR {BR} at (10,50) size 0x0
+    RenderText {#text} at (3,52) size 7x13
+      text run at (3,52) width 7: "5"
+    RenderBR {BR} at (10,63) size 0x0
+    RenderText {#text} at (3,65) size 7x13
+      text run at (3,65) width 7: "6"
+    RenderBR {BR} at (10,76) size 0x0
+    RenderText {#text} at (3,78) size 7x13
+      text run at (3,78) width 7: "7"
+    RenderBR {BR} at (10,89) size 0x0
+    RenderText {#text} at (3,91) size 7x13
+      text run at (3,91) width 7: "8"
+    RenderBR {BR} at (10,102) size 0x0
+    RenderText {#text} at (3,104) size 7x13
+      text run at (3,104) width 7: "9"
+    RenderBR {BR} at (10,115) size 0x0
+    RenderText {#text} at (3,117) size 14x13
+      text run at (3,117) width 14: "10"
+    RenderBR {BR} at (17,128) size 0x0
+    RenderText {#text} at (3,130) size 14x13
+      text run at (3,130) width 14: "11"
+    RenderBR {BR} at (17,141) size 0x0
+    RenderText {#text} at (3,143) size 14x13
+      text run at (3,143) width 14: "12"
+    RenderBR {BR} at (17,154) size 0x0
+    RenderText {#text} at (3,156) size 14x13
+      text run at (3,156) width 14: "13"
+    RenderBR {BR} at (17,167) size 0x0
+    RenderText {#text} at (3,169) size 14x13
+      text run at (3,169) width 14: "14"
+    RenderBR {BR} at (17,180) size 0x0
+    RenderText {#text} at (3,182) size 14x13
+      text run at (3,182) width 14: "15"
+    RenderBR {BR} at (17,193) size 0x0
+    RenderText {#text} at (3,195) size 14x13
+      text run at (3,195) width 14: "16"
+    RenderBR {BR} at (17,206) size 0x0
+    RenderText {#text} at (3,208) size 14x13
+      text run at (3,208) width 14: "17"
+    RenderBR {BR} at (17,219) size 0x0
+    RenderText {#text} at (3,221) size 41x13
+      text run at (3,221) width 41: "18 Pass"
+    RenderBR {BR} at (44,232) size 0x0
+    RenderText {#text} at (3,234) size 14x13
+      text run at (3,234) width 14: "19"
+    RenderBR {BR} at (17,245) size 0x0
+    RenderText {#text} at (3,247) size 14x13
+      text run at (3,247) width 14: "20"
+    RenderBR {BR} at (17,258) size 0x0
+caret: position 7 of child 34 {#text} of child 0 {DIV} of child 3 {TEXTAREA} of child 1 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/fast/forms/textarea-scrolled-type.html b/LayoutTests/fast/forms/textarea-scrolled-type.html
new file mode 100644 (file)
index 0000000..a846fbb
--- /dev/null
@@ -0,0 +1,47 @@
+<html>
+<head>
+<script src=../../editing/editing.js language="JavaScript" type="text/JavaScript" ></script>
+<script>
+function test()
+{
+    var res = document.getElementById('res');
+    var ta = document.getElementById('ta');
+    ta.focus();
+    ta.setSelectionRange(44, 44);
+    typeCharacterCommand(' ');
+    typeCharacterCommand('P');
+    typeCharacterCommand('a');
+    typeCharacterCommand('s');
+    typeCharacterCommand('s');
+
+}
+</script>
+</head>
+<body onload="test()">
+This tests that typing in a scrolled textarea does not cause unnecessary scrolling.<br>
+<textarea id="ta" rows=7>
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+</textarea>
+<br>
+<div id="res"></div>
+</body>
+</html>
\ No newline at end of file
index 6d4414a21016371e76f5d91d53d975f7d9a49116..503348b2a4af547980893c5a49ae81249b032c73 100644 (file)
@@ -1,3 +1,20 @@
+2006-07-23  Adele Peterson  <adele@apple.com>
+
+        Reviewed by Maciej.
+
+        - Fix for <rdar://problem/4644614> REGRESSION: Typing, pasting or dragging in new text areas causes unnecessary scrolling
+
+        * rendering/RenderBlock.cpp: (WebCore::RenderBlock::layoutBlock): Don't updateScrollInfoAfterLayout if an ancestor flexible box is just on
+        its first layout.
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore::RenderFlexibleBox::layoutBlock): ditto.
+        (WebCore::RenderFlexibleBox::layoutVerticalBox): Let the view know if this flex box is doing its first pass at layout.
+
+        * rendering/RenderView.cpp: (WebCore::RenderView::RenderView): Caches a flexible box that's doing its first layout.
+        * rendering/RenderView.h:
+        (WebCore::RenderView::setFlexBoxInFirstLayout):
+        (WebCore::RenderView::flexBoxInFirstLayout):
+
 2006-07-22  Alexey Proskuryakov  <ap@nypop.com>
 
         Reviewed by Darin.
index a3577b4f40c528fb9f9e5cca89b80edafb62b3e4..557c7240469066a26b9836d97312d3fe4000b26a 100644 (file)
@@ -538,7 +538,8 @@ void RenderBlock::layoutBlock(bool relayoutChildren)
 
     // Update our scroll information if we're overflow:auto/scroll/hidden now that we know if
     // we overflow or not.
-    if (hasOverflowClip())
+    RenderObject* flexbox = view()->flexBoxInFirstLayout();
+    if (hasOverflowClip() && !(flexbox && flexbox != this && hasAncestor(flexbox)))
         m_layer->updateScrollInfoAfterLayout();
 
     // Repaint with our new bounds if they are different from our old bounds.
index 67c0ba0b7ebdbef1034b0b73718196a02e3c3650..6612f0e87bd6e0b5a56f73c1672fa3eee9d0cee6 100644 (file)
@@ -25,6 +25,8 @@
 #include "config.h"
 #include "RenderFlexibleBox.h"
 
+#include "RenderView.h"
+
 using namespace std;
 
 namespace WebCore {
@@ -318,7 +320,8 @@ void RenderFlexibleBox::layoutBlock(bool relayoutChildren)
 
     // Update our scrollbars if we're overflow:auto/scroll/hidden now that we know if
     // we overflow or not.
-    if (hasOverflowClip())
+    RenderObject* flexbox = view()->flexBoxInFirstLayout();
+    if (hasOverflowClip() && !(flexbox && flexbox != this && hasAncestor(flexbox)))
         m_layer->updateScrollInfoAfterLayout();
 
     // Repaint with our new bounds if they are different from our old bounds.
@@ -797,6 +800,12 @@ void RenderFlexibleBox::layoutVerticalBox(bool relayoutChildren)
     // Our first pass is done without flexing.  We simply lay the children
     // out within the box.
     do {
+    
+        if (view()->flexBoxInFirstLayout() == this)
+            view()->setFlexBoxInFirstLayout(0);
+        else
+            view()->setFlexBoxInFirstLayout(this);
+            
         m_height = borderTop() + paddingTop();
         int minHeight = m_height + toAdd;
         m_overflowHeight = m_height;
index 9c14a28d2bef4bf66047bd62d41fe44491f9ff37..88d00ec35f70f33ff041199c21668033a98bff8f 100644 (file)
@@ -65,6 +65,8 @@ RenderView::RenderView(Node* node, FrameView *view)
 
     // Create a new root layer for our layer hierarchy.
     m_layer = new (node->document()->renderArena()) RenderLayer(this);
+    
+    m_flexBoxInFirstLayout = 0;
 }
 
 RenderView::~RenderView()
index 385b58de8490f78b0cfa554706c74140388e3494..965c5eec62d44a87cffc4cef97f681d01c3bd6bc 100644 (file)
@@ -95,6 +95,9 @@ public:
     void updateWidgetPositions();
     void addWidget(RenderObject *);
     void removeWidget(RenderObject *);
+    
+    void setFlexBoxInFirstLayout(RenderObject* r) { m_flexBoxInFirstLayout = r; }
+    RenderObject* flexBoxInFirstLayout() { return m_flexBoxInFirstLayout; }
 
 protected:
 
@@ -116,6 +119,8 @@ protected:
     typedef HashSet<RenderObject *> RenderObjectSet;
 
     RenderObjectSet m_widgets;
+    
+    RenderObject* m_flexBoxInFirstLayout;
 };
 
 }