2010-04-27 Joseph Pecoraro <joepeck@webkit.org>
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Apr 2010 17:19:47 +0000 (17:19 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Apr 2010 17:19:47 +0000 (17:19 +0000)
        Reviewed by Dan Bernstein.

        <input type="search"> with uneven padding causes text clipping
        https://bugs.webkit.org/show_bug.cgi?id=38160

        * fast/css/input-search-padding.html: Added.
        * platform/mac/fast/css/input-search-padding-expected.checksum: Added.
        * platform/mac/fast/css/input-search-padding-expected.png: Added.
        * platform/mac/fast/css/input-search-padding-expected.txt: Added.

2010-04-27  Joseph Pecoraro  <joepeck@webkit.org>

        Reviewed by Dan Bernstein.

        <input type="search"> with uneven padding causes text clipping
        https://bugs.webkit.org/show_bug.cgi?id=38160

        Test: fast/css/input-search-padding.html

        An <input type="search"> contains an inner block, which is explicitly
        centered in RenderTextControlSingleLine based on the height of the element.
        However, the clipping rect was not using the set location, and instead
        calculated off of the top border and padding alone. This also vertically
        centers the Caps Lock indicator.

        * rendering/RenderTextControl.cpp: moved controlClipRect implementation to RenderTextControlSingleLine
        * rendering/RenderTextControl.h: allow a subclass implementation of controlClipRect, removed redundant hasControlClip implementation, and moved controlClipRect
        * rendering/RenderTextControlSingleLine.cpp:
        (WebCore::RenderTextControlSingleLine::paint): vertically center the Caps Lock indicator
        (WebCore::RenderTextControlSingleLine::controlClipRect): use the set location of the anonymous inner block instead
        * rendering/RenderTextControlSingleLine.h: allow for an implementation of controlClipRect for <input type="search">

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

LayoutTests/ChangeLog
LayoutTests/fast/css/input-search-padding.html [new file with mode: 0644]
LayoutTests/platform/mac/fast/css/input-search-padding-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/css/input-search-padding-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/css/input-search-padding-expected.txt [new file with mode: 0644]
WebCore/ChangeLog
WebCore/rendering/RenderTextControl.cpp
WebCore/rendering/RenderTextControl.h
WebCore/rendering/RenderTextControlSingleLine.cpp
WebCore/rendering/RenderTextControlSingleLine.h

index d2e0b8c..575b1eb 100644 (file)
@@ -1,3 +1,15 @@
+2010-04-27  Joseph Pecoraro  <joepeck@webkit.org>
+
+        Reviewed by Dan Bernstein.
+
+        <input type="search"> with uneven padding causes text clipping
+        https://bugs.webkit.org/show_bug.cgi?id=38160
+
+        * fast/css/input-search-padding.html: Added.
+        * platform/mac/fast/css/input-search-padding-expected.checksum: Added.
+        * platform/mac/fast/css/input-search-padding-expected.png: Added.
+        * platform/mac/fast/css/input-search-padding-expected.txt: Added.
+
 2010-04-27  Jeremy Orlow  <jorlow@chromium.org>
 
         Unreviewed.  Previous disabling only did so via
diff --git a/LayoutTests/fast/css/input-search-padding.html b/LayoutTests/fast/css/input-search-padding.html
new file mode 100644 (file)
index 0000000..fc17f38
--- /dev/null
@@ -0,0 +1,8 @@
+<style>
+input {
+    font-size: 30pt;
+    padding-bottom: 30px;
+}
+</style>
+<input type="search" value="value jgq not clipped" style="-webkit-appearance:none"><br>
+<input type="text" value="value jgq not clipped">
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/css/input-search-padding-expected.checksum b/LayoutTests/platform/mac/fast/css/input-search-padding-expected.checksum
new file mode 100644 (file)
index 0000000..6370726
--- /dev/null
@@ -0,0 +1 @@
+abd9ac07712b928b2a294bab536286b1
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/css/input-search-padding-expected.png b/LayoutTests/platform/mac/fast/css/input-search-padding-expected.png
new file mode 100644 (file)
index 0000000..7595511
Binary files /dev/null and b/LayoutTests/platform/mac/fast/css/input-search-padding-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/css/input-search-padding-expected.txt b/LayoutTests/platform/mac/fast/css/input-search-padding-expected.txt
new file mode 100644 (file)
index 0000000..f1ab110
--- /dev/null
@@ -0,0 +1,19 @@
+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
+      RenderTextControl {INPUT} at (2,2) size 429x82 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
+        RenderBlock {DIV} at (3,17) size 423x47
+          RenderBlock {DIV} at (0,26) size 10x13
+          RenderBlock {DIV} at (407,26) size 16x13
+      RenderBR {BR} at (433,86) size 0x0
+      RenderTextControl {INPUT} at (2,88) size 429x82 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
+layer at (23,27) size 397x47 scrollWidth 413
+  RenderBlock {DIV} at (10,0) size 397x47
+    RenderText {#text} at (1,0) size 411x47
+      text run at (1,0) width 411: "value jgq not clipped"
+layer at (13,113) size 423x47
+  RenderBlock {DIV} at (3,17) size 423x47
+    RenderText {#text} at (1,0) size 411x47
+      text run at (1,0) width 411: "value jgq not clipped"
index 9414e08..16d70bf 100644 (file)
@@ -1,3 +1,25 @@
+2010-04-27  Joseph Pecoraro  <joepeck@webkit.org>
+
+        Reviewed by Dan Bernstein.
+
+        <input type="search"> with uneven padding causes text clipping
+        https://bugs.webkit.org/show_bug.cgi?id=38160
+
+        Test: fast/css/input-search-padding.html
+
+        An <input type="search"> contains an inner block, which is explicitly
+        centered in RenderTextControlSingleLine based on the height of the element.
+        However, the clipping rect was not using the set location, and instead
+        calculated off of the top border and padding alone. This also vertically
+        centers the Caps Lock indicator.
+
+        * rendering/RenderTextControl.cpp: moved controlClipRect implementation to RenderTextControlSingleLine
+        * rendering/RenderTextControl.h: allow a subclass implementation of controlClipRect, removed redundant hasControlClip implementation, and moved controlClipRect
+        * rendering/RenderTextControlSingleLine.cpp:
+        (WebCore::RenderTextControlSingleLine::paint): vertically center the Caps Lock indicator
+        (WebCore::RenderTextControlSingleLine::controlClipRect): use the set location of the anonymous inner block instead
+        * rendering/RenderTextControlSingleLine.h: allow for an implementation of controlClipRect for <input type="search">
+
 2010-04-27  Thomas Zander <t.zander@nokia.com>
 
         Reviewed by Simon Hausmann.
index ce1c446..1e80ff0 100644 (file)
@@ -433,13 +433,6 @@ void RenderTextControl::forwardEvent(Event* event)
     m_innerText->defaultEventHandler(event);
 }
 
-IntRect RenderTextControl::controlClipRect(int tx, int ty) const
-{
-    IntRect clipRect = contentBoxRect();
-    clipRect.move(tx, ty);
-    return clipRect;
-}
-
 static const char* fontFamiliesWithInvalidCharWidth[] = {
     "American Typewriter",
     "Arial Hebrew",
index 2fc8edc..b76d1f2 100644 (file)
@@ -95,8 +95,6 @@ protected:
 private:
     virtual const char* renderName() const { return "RenderTextControl"; }
     virtual bool isTextControl() const { return true; }
-    virtual bool hasControlClip() const { return false; }
-    virtual IntRect controlClipRect(int tx, int ty) const;
     virtual void calcPrefWidths();
     virtual void removeLeftoverAnonymousBlock(RenderBlock*) { }
     virtual bool canHaveChildren() const { return false; }
index 7c43d3d..7766fd4 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2010 Apple Inc. All rights reserved.
  *           (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) 
  *
  * This library is free software; you can redistribute it and/or
@@ -185,6 +185,9 @@ void RenderTextControlSingleLine::paint(PaintInfo& paintInfo, int tx, int ty)
     if (paintInfo.phase == PaintPhaseBlockBackground && m_shouldDrawCapsLockIndicator) {
         IntRect contentsRect = contentBoxRect();
 
+        // Center vertically like the text.
+        contentsRect.setY((height() - contentsRect.height()) / 2);
+
         // Convert the rect into the coords used for painting the content
         contentsRect.move(tx + x(), ty + y());
         theme()->paintCapsLockIndicator(this, paintInfo, contentsRect);
@@ -358,6 +361,18 @@ void RenderTextControlSingleLine::capsLockStateMayHaveChanged()
     }
 }
 
+IntRect RenderTextControlSingleLine::controlClipRect(int tx, int ty) const
+{
+    // This should only get called for search inputs, which have an innerBlock.
+    ASSERT(hasControlClip());
+    ASSERT(m_innerBlock);
+
+    RenderBox* renderBox = m_innerBlock->renderBox();
+    IntRect clipRect = IntRect(renderBox->x(), renderBox->y(), contentWidth(), contentHeight());        
+    clipRect.move(tx, ty);
+    return clipRect;
+}
+
 int RenderTextControlSingleLine::textBlockWidth() const
 {
     int width = RenderTextControl::textBlockWidth();
index e1bcc84..1c4ba22 100644 (file)
@@ -55,6 +55,7 @@ public:
 
 private:
     virtual bool hasControlClip() const { return m_cancelButton; }
+    virtual IntRect controlClipRect(int tx, int ty) const;
     virtual bool isTextField() const { return true; }
 
     virtual void subtreeHasChanged();