LayoutTests:
authoradele <adele@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Nov 2006 21:37:46 +0000 (21:37 +0000)
committeradele <adele@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Nov 2006 21:37:46 +0000 (21:37 +0000)
        Reviewed by Mitz and Geoff.

        Test for <rdar://problem/4650271> REGRESSION(NativeTextArea): Textareas don't get scrollbars when text gets too big for content area (10105)

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

WebCore:

        Reviewed by Mitz and Geoff.

        - Fix for:
        <rdar://problem/4650271> REGRESSION(NativeTextArea): Textareas don't get scrollbars when text gets too big for content area (10105)
        <rdar://problem/4650813> REGRESSION(tiger-leopard): typing in a textarea in Safari is extremely slow (sample shows focus ring drawing)
        <rdar://problem/4658779> REGRESSION: Text selection is weird in textareas in Trac wiki editing pages

        Test: fast/forms/textarea-scrollbar.html

        To avoid some of our flexbox bugs for textareas, we're moving the text controls back to RenderBlock.  This should make them
        a lot more stable.  In the future, when we've worked out more of the flexbox kinks, we may want to consider moving them back.

        * rendering/RenderTextControl.h: Convert text controls back to RenderBlock instead of RenderFlexibleBox.
        * rendering/RenderTextControl.cpp:
        (WebCore::RenderTextControl::RenderTextControl):
        (WebCore::RenderTextControl::setStyle):
        (WebCore::RenderTextControl::createDivStyle):
        (WebCore::RenderTextControl::updateFromElement):
        (WebCore::RenderTextControl::calcHeight):
        (WebCore::RenderTextControl::baselinePosition):
        (WebCore::RenderTextControl::nodeAtPoint):
        (WebCore::RenderTextControl::layout): Set the inner div's height explicitly before doing a normal layout.
        (WebCore::RenderTextControl::scrollWidth):
        (WebCore::RenderTextControl::scrollHeight):
        (WebCore::RenderTextControl::scrollLeft):
        (WebCore::RenderTextControl::scrollTop):

        * rendering/RenderObject.cpp: (WebCore::RenderObject::markContainingBlocksForLayout): Make subtree layout optimization work for textareas.

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

LayoutTests/ChangeLog
LayoutTests/fast/forms/textarea-scrollbar-expected.checksum [new file with mode: 0644]
LayoutTests/fast/forms/textarea-scrollbar-expected.png [new file with mode: 0644]
LayoutTests/fast/forms/textarea-scrollbar-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/textarea-scrollbar.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/rendering/RenderObject.cpp
WebCore/rendering/RenderTextControl.cpp
WebCore/rendering/RenderTextControl.h

index 325c2ac6ec7407a0499669a6af2cc1fee9f14892..c09ce3f5373fa43745a687ece6e983a0ce9bd416 100644 (file)
@@ -1,3 +1,14 @@
+2006-11-02  Adele Peterson  <adele@apple.com>
+
+        Reviewed by Mitz and Geoff.
+
+        Test for <rdar://problem/4650271> REGRESSION(NativeTextArea): Textareas don't get scrollbars when text gets too big for content area (10105)
+
+        * fast/forms/textarea-scrollbar-expected.checksum: Added.
+        * fast/forms/textarea-scrollbar-expected.png: Added.
+        * fast/forms/textarea-scrollbar-expected.txt: Added.
+        * fast/forms/textarea-scrollbar.html: Added.
+
 2006-11-02  Kevin McCullough  <KMcCullough@apple.com>
 
         Reviewed by Maciej.
diff --git a/LayoutTests/fast/forms/textarea-scrollbar-expected.checksum b/LayoutTests/fast/forms/textarea-scrollbar-expected.checksum
new file mode 100644 (file)
index 0000000..fb6eaf1
--- /dev/null
@@ -0,0 +1 @@
+ad6b3b39864cef0d8b7b99bdc44e43b1
\ No newline at end of file
diff --git a/LayoutTests/fast/forms/textarea-scrollbar-expected.png b/LayoutTests/fast/forms/textarea-scrollbar-expected.png
new file mode 100644 (file)
index 0000000..0b3646a
Binary files /dev/null and b/LayoutTests/fast/forms/textarea-scrollbar-expected.png differ
diff --git a/LayoutTests/fast/forms/textarea-scrollbar-expected.txt b/LayoutTests/fast/forms/textarea-scrollbar-expected.txt
new file mode 100644 (file)
index 0000000..d001071
--- /dev/null
@@ -0,0 +1,68 @@
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of #text > DIV to 1 of #text > DIV affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > DIV to 1 of #text > DIV toDOMRange:range from 1 of #text > DIV to 1 of #text > DIV affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > DIV to 1 of #text > DIV toDOMRange:range from 1 of #text > DIV to 1 of #text > DIV affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > DIV to 1 of #text > DIV toDOMRange:range from 1 of #text > DIV to 1 of #text > DIV affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > DIV to 1 of #text > DIV toDOMRange:range from 1 of #text > DIV to 1 of #text > DIV affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > DIV to 1 of #text > DIV toDOMRange:range from 1 of #text > DIV to 1 of #text > DIV affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > DIV to 1 of #text > DIV toDOMRange:range from 1 of #text > DIV to 1 of #text > DIV affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > DIV to 1 of #text > DIV toDOMRange:range from 1 of #text > DIV to 1 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
+      RenderText {#text} at (0,0) size 442x18
+        text run at (0,0) width 442: "This tests that a scrollbar will appear when text overflows the textarea "
+      RenderBR {BR} at (442,14) size 0x0
+      RenderTextField {TEXTAREA} at (2,20) size 163x80 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
+      RenderText {#text} at (0,0) size 0x0
+      RenderText {#text} at (0,0) size 0x0
+      RenderText {#text} at (0,0) size 0x0
+layer at (11,29) size 161x78 clip at (11,29) size 146x78 scrollHeight 117
+  RenderBlock {DIV} at (1,1) size 161x78
+    RenderText {#text} at (3,0) size 7x52
+      text run at (3,0) width 7: "1"
+      text run at (10,0) width 0: " "
+      text run at (3,13) width 7: "2"
+      text run at (10,13) width 0: " "
+      text run at (3,26) width 7: "3"
+      text run at (10,26) width 0: " "
+      text run at (3,39) width 7: "4"
+      text run at (10,39) width 0: " "
+    RenderText {#text} at (3,52) size 7x13
+      text run at (3,52) width 7: "5"
+    RenderText {#text} at (10,52) size 0x13
+      text run at (10,52) width 0: " "
+    RenderText {#text} at (3,65) size 7x13
+      text run at (3,65) width 7: "6"
+    RenderText {#text} at (10,65) size 0x13
+      text run at (10,65) width 0: " "
+    RenderText {#text} at (3,78) size 7x13
+      text run at (3,78) width 7: "7"
+    RenderText {#text} at (10,78) size 0x13
+      text run at (10,78) width 0: " "
+    RenderText {#text} at (3,91) size 7x13
+      text run at (3,91) width 7: "8"
+    RenderText {#text} at (10,91) size 0x13
+      text run at (10,91) width 0: " "
+    RenderText {#text} at (3,104) size 0x13
+      text run at (3,104) width 0: " "
+caret: position 0 of child 9 {#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-scrollbar.html b/LayoutTests/fast/forms/textarea-scrollbar.html
new file mode 100644 (file)
index 0000000..4fd41ab
--- /dev/null
@@ -0,0 +1,27 @@
+<html>
+<head>
+    <script>
+    function test() {
+        document.getElementById('ta').focus();
+        document.execCommand("InsertText", false, '5');
+        document.execCommand("InsertText", false, '\n');
+        document.execCommand("InsertText", false, '6');
+        document.execCommand("InsertText", false, '\n');
+        document.execCommand("InsertText", false, '7');
+        document.execCommand("InsertText", false, '\n');
+        document.execCommand("InsertText", false, '8');
+        document.execCommand("InsertText", false, '\n');
+    }
+    </script>
+</head>
+<body onload="test()">
+This tests that a scrollbar will appear when text overflows the textarea
+<br>
+<textarea rows=6 id="ta">
+1
+2
+3
+4
+</textarea>
+</body>
+</html>
index 2b3f6ad037394324327b9141e9b11557f4304a66..8bd468f8bd7e1083313e4c3b0cdca47188a9fa3a 100644 (file)
@@ -1,3 +1,34 @@
+2006-11-02  Adele Peterson  <adele@apple.com>
+
+        Reviewed by Mitz and Geoff.
+
+        - Fix for:
+        <rdar://problem/4650271> REGRESSION(NativeTextArea): Textareas don't get scrollbars when text gets too big for content area (10105)
+        <rdar://problem/4650813> REGRESSION(tiger-leopard): typing in a textarea in Safari is extremely slow (sample shows focus ring drawing)
+        <rdar://problem/4658779> REGRESSION: Text selection is weird in textareas in Trac wiki editing pages
+
+        Test: fast/forms/textarea-scrollbar.html
+
+        To avoid some of our flexbox bugs for textareas, we're moving the text controls back to RenderBlock.  This should make them
+        a lot more stable.  In the future, when we've worked out more of the flexbox kinks, we may want to consider moving them back.
+
+        * rendering/RenderTextControl.h: Convert text controls back to RenderBlock instead of RenderFlexibleBox.
+        * rendering/RenderTextControl.cpp: 
+        (WebCore::RenderTextControl::RenderTextControl):
+        (WebCore::RenderTextControl::setStyle):
+        (WebCore::RenderTextControl::createDivStyle):
+        (WebCore::RenderTextControl::updateFromElement):
+        (WebCore::RenderTextControl::calcHeight):
+        (WebCore::RenderTextControl::baselinePosition):
+        (WebCore::RenderTextControl::nodeAtPoint):
+        (WebCore::RenderTextControl::layout): Set the inner div's height explicitly before doing a normal layout.
+        (WebCore::RenderTextControl::scrollWidth):
+        (WebCore::RenderTextControl::scrollHeight):
+        (WebCore::RenderTextControl::scrollLeft):
+        (WebCore::RenderTextControl::scrollTop):
+
+        * rendering/RenderObject.cpp: (WebCore::RenderObject::markContainingBlocksForLayout): Make subtree layout optimization work for textareas.
+
 2006-11-02  John Sullivan  <sullivan@apple.com>
 
         Reviewed by Geoff Garen
index f04aa87cefdf7a6aed2a883e5df405b80b93ada0..17867dcb812c9ad428b02792b39e84b0cf4e28fb 100644 (file)
@@ -758,7 +758,7 @@ void RenderObject::markContainingBlocksForLayout(bool scheduleRelayout)
         }
 
         last = o;
-        if (scheduleRelayout && last->isTextField())
+        if (scheduleRelayout && (last->isTextField() || last->isTextArea()))
             break;
         o = o->container();
     }
index c7b4e4be7006c34017d237d9a0525e16871f00a4..a43b1ef3ffa7f20dd2fbb0069fb5ebd122bb0779 100644 (file)
@@ -46,7 +46,7 @@ using namespace HTMLNames;
 using namespace std;
 
 RenderTextControl::RenderTextControl(Node* node, bool multiLine)
-    : RenderFlexibleBox(node), m_dirty(false), m_multiLine(multiLine)
+    : RenderBlock(node), m_dirty(false), m_multiLine(multiLine)
 {
 }
 
@@ -61,7 +61,7 @@ RenderTextControl::~RenderTextControl()
 
 void RenderTextControl::setStyle(RenderStyle* style)
 {
-    RenderFlexibleBox::setStyle(style);
+    RenderBlock::setStyle(style);
     if (m_div) {
         RenderBlock* divRenderer = static_cast<RenderBlock*>(m_div->renderer());
         RenderStyle* divStyle = createDivStyle(style);
@@ -81,7 +81,6 @@ RenderStyle* RenderTextControl::createDivStyle(RenderStyle* startStyle)
     
     divStyle->inheritFrom(startStyle);
     divStyle->setDisplay(BLOCK);
-    divStyle->setBoxFlex(1.0f);
     divStyle->setUserModify(element->isReadOnlyControl() || element->disabled() ? READ_ONLY : READ_WRITE_PLAINTEXT_ONLY);
 
     if (m_multiLine) {
@@ -141,7 +140,7 @@ void RenderTextControl::updateFromElement()
         divRenderer->setStyle(divStyle); 
         
         // Add div to Render tree
-        RenderFlexibleBox::addChild(divRenderer);
+        RenderBlock::addChild(divRenderer);
     }
 
     HTMLGenericFormElement* element = static_cast<HTMLGenericFormElement*>(node());
@@ -335,27 +334,40 @@ void RenderTextControl::calcHeight()
 
     m_height = line * rows + toAdd + scrollbarSize;
     
-    RenderFlexibleBox::calcHeight();
+    RenderBlock::calcHeight();
 }
 
 short RenderTextControl::baselinePosition(bool b, bool isRootLineBox) const
 {
     if (m_multiLine)
         return height() + marginTop() + marginBottom();
-    return RenderFlexibleBox::baselinePosition(b, isRootLineBox);
+    return RenderBlock::baselinePosition(b, isRootLineBox);
 }
 
 bool RenderTextControl::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int x, int y, int tx, int ty, HitTestAction hitTestAction)
 {
     // If we're within the text control, we want to act as if we've hit the inner div, incase the point 
     // was on the control but not on the div (see Radar 4617841).
-    if (RenderFlexibleBox::nodeAtPoint(request, result, x, y, tx, ty, hitTestAction)) {
+    if (RenderBlock::nodeAtPoint(request, result, x, y, tx, ty, hitTestAction)) {
         result.setInnerNode(m_div.get());
         return true;
     }  
     return false;
 }
 
+void RenderTextControl::layout()
+{    
+    int oldHeight = m_height;
+    calcHeight();
+    bool relayoutChildren = oldHeight != m_height;
+    
+    // Set the div's height
+    int divHeight = m_height - paddingTop() - paddingBottom() - borderTop() - borderBottom();
+    m_div->renderer()->style()->setHeight(Length(divHeight, Fixed));
+
+    RenderBlock::layoutBlock(relayoutChildren);
+}
+
 void RenderTextControl::calcMinMaxWidth()
 {
     m_minWidth = 0;
@@ -433,28 +445,28 @@ int RenderTextControl::scrollWidth() const
 {
     if (m_div)
         return m_div->scrollWidth();
-    return RenderFlexibleBox::scrollWidth();
+    return RenderBlock::scrollWidth();
 }
 
 int RenderTextControl::scrollHeight() const
 {
     if (m_div)
         return m_div->scrollHeight();
-    return RenderFlexibleBox::scrollHeight();
+    return RenderBlock::scrollHeight();
 }
 
 int RenderTextControl::scrollLeft() const
 {
     if (m_div)
         return m_div->scrollLeft();
-    return RenderFlexibleBox::scrollLeft();
+    return RenderBlock::scrollLeft();
 }
 
 int RenderTextControl::scrollTop() const
 {
     if (m_div)
         return m_div->scrollTop();
-    return RenderFlexibleBox::scrollTop();
+    return RenderBlock::scrollTop();
 }
 
 void RenderTextControl::setScrollLeft(int newLeft)
index c0a0c528e488c19ea94fab7c159b928139c71bc2..bb93b9501b26f074d6dffb8e66dc1f02d537671b 100644 (file)
 #ifndef RenderTextField_H
 #define RenderTextField_H
 
-#include "RenderFlexibleBox.h"
+#include "RenderBlock.h"
 
 namespace WebCore {
 
 class HTMLTextFieldInnerElement;
 
-class RenderTextControl : public RenderFlexibleBox {
+class RenderTextControl : public RenderBlock {
 public:
     RenderTextControl(Node*, bool multiLine);
     virtual ~RenderTextControl();
@@ -41,7 +41,9 @@ public:
     virtual bool canHaveChildren() const { return false; }
     virtual short baselinePosition( bool, bool ) const;
     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
-                             
+    virtual void layout();
+    virtual bool avoidsFloats() const { return true; }
+
     RenderStyle* createDivStyle(RenderStyle* startStyle);
 
     bool isEdited() const { return m_dirty; };