Title: [110130] trunk
Revision
110130
Author
tk...@chromium.org
Date
2012-03-07 19:02:40 -0800 (Wed, 07 Mar 2012)

Log Message

Remove meaningless code in RenderTextControlSingleLine::preferredContentWidth()
https://bugs.webkit.org/show_bug.cgi?id=80493

Reviewed by Hajime Morita.

Source/WebCore:

preferredContentWidth() added border+padding widths of the search result
button, search cancel button, and speech input button. It makes no sense
to make the intrinsic width wider by only their border+padding width,
not their content width.

The default borders and paddings of these buttons are 0 in all
platforms, and adding border or padding to these elements by page
authors made unreasonable behavior. So we had better remove this
code.

Tests: fast/forms/search/intrinsic-search-width-with-decoration-border-padding.html
       fast/speech/intrinsic-input-width-with-speech-border-padding.html

* rendering/RenderTextControlSingleLine.cpp:
(WebCore::RenderTextControlSingleLine::preferredContentWidth):
 Remove the meaningless code.
* rendering/RenderTextControlSingleLine.h:
(RenderTextControlSingleLine): Remove speechButtonElement(). It's unnecessary.

Source/WebKit/chromium:

* src/WebInputElement.cpp:
RenderTextControlSingleLine::speechButtonElement() is removed. The
following functions get it from HTMLInputElement.
(WebKit::WebInputElement::getSpeechInputState):
(WebKit::WebInputElement::startSpeechInput):
(WebKit::WebInputElement::stopSpeechInput):

LayoutTests:

Add tests to confirm that borders and paddings for decoration elements
don't affect intrinsic width of <input> elements.

* fast/forms/search/intrinsic-search-width-with-decoration-border-padding-expected.txt: Added.
* fast/forms/search/intrinsic-search-width-with-decoration-border-padding.html: Added.
* fast/speech/intrinsic-input-width-with-speech-border-padding-expected.txt: Added.
* fast/speech/intrinsic-input-width-with-speech-border-padding.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (110129 => 110130)


--- trunk/LayoutTests/ChangeLog	2012-03-08 02:50:39 UTC (rev 110129)
+++ trunk/LayoutTests/ChangeLog	2012-03-08 03:02:40 UTC (rev 110130)
@@ -1,3 +1,18 @@
+2012-03-07  Kent Tamura  <tk...@chromium.org>
+
+        Remove meaningless code in RenderTextControlSingleLine::preferredContentWidth()
+        https://bugs.webkit.org/show_bug.cgi?id=80493
+
+        Reviewed by Hajime Morita.
+
+        Add tests to confirm that borders and paddings for decoration elements
+        don't affect intrinsic width of <input> elements.
+
+        * fast/forms/search/intrinsic-search-width-with-decoration-border-padding-expected.txt: Added.
+        * fast/forms/search/intrinsic-search-width-with-decoration-border-padding.html: Added.
+        * fast/speech/intrinsic-input-width-with-speech-border-padding-expected.txt: Added.
+        * fast/speech/intrinsic-input-width-with-speech-border-padding.html: Added.
+
 2012-03-07  Sheriff Bot  <webkit.review....@gmail.com>
 
         Unreviewed, rolling out r110126.

Added: trunk/LayoutTests/fast/forms/search/intrinsic-search-width-with-decoration-border-padding-expected.txt (0 => 110130)


--- trunk/LayoutTests/fast/forms/search/intrinsic-search-width-with-decoration-border-padding-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/search/intrinsic-search-width-with-decoration-border-padding-expected.txt	2012-03-08 03:02:40 UTC (rev 110130)
@@ -0,0 +1,5 @@
+PASS document.getElementById("search1").offsetWidth is document.getElementById("search2").offsetWidth
+PASS successfullyParsed is true
+
+TEST COMPLETE
+ 

Added: trunk/LayoutTests/fast/forms/search/intrinsic-search-width-with-decoration-border-padding.html (0 => 110130)


--- trunk/LayoutTests/fast/forms/search/intrinsic-search-width-with-decoration-border-padding.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/search/intrinsic-search-width-with-decoration-border-padding.html	2012-03-08 03:02:40 UTC (rev 110130)
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<style>
+#search1::-webkit-search-cancel-button {
+    border: 10px solid lime;
+    padding: 10px;
+}
+#search1::-webkit-search-decoration {
+    border: 10px solid lime;
+    padding: 10px;
+}
+</style>
+<body>
+<script src=""
+
+<input type="search" id="search1">
+<input type="search" id="search2">
+<script>
+shouldBe('document.getElementById("search1").offsetWidth', 'document.getElementById("search2").offsetWidth');
+</script>
+
+<script src=""
+</body>
Property changes on: trunk/LayoutTests/fast/forms/search/intrinsic-search-width-with-decoration-border-padding.html
___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/fast/speech/intrinsic-input-width-with-speech-border-padding-expected.txt (0 => 110130)


--- trunk/LayoutTests/fast/speech/intrinsic-input-width-with-speech-border-padding-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/speech/intrinsic-input-width-with-speech-border-padding-expected.txt	2012-03-08 03:02:40 UTC (rev 110130)
@@ -0,0 +1,5 @@
+PASS document.getElementById("speechInput1").offsetWidth is document.getElementById("input1").offsetWidth
+PASS successfullyParsed is true
+
+TEST COMPLETE
+ 

Added: trunk/LayoutTests/fast/speech/intrinsic-input-width-with-speech-border-padding.html (0 => 110130)


--- trunk/LayoutTests/fast/speech/intrinsic-input-width-with-speech-border-padding.html	                        (rev 0)
+++ trunk/LayoutTests/fast/speech/intrinsic-input-width-with-speech-border-padding.html	2012-03-08 03:02:40 UTC (rev 110130)
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<style>
+input::-webkit-input-speech-button {
+    border: 10px solid lime;
+    padding: 10px;
+}
+</style>
+<body>
+<script src=""
+
+<input id="input1">
+<input x-webkit-speech id="speechInput1">
+<script>
+shouldBe('document.getElementById("speechInput1").offsetWidth', 'document.getElementById("input1").offsetWidth');
+</script>
+
+<script src=""
+</body>
Property changes on: trunk/LayoutTests/fast/speech/intrinsic-input-width-with-speech-border-padding.html
___________________________________________________________________

Added: svn:mime-type

Modified: trunk/Source/WebCore/ChangeLog (110129 => 110130)


--- trunk/Source/WebCore/ChangeLog	2012-03-08 02:50:39 UTC (rev 110129)
+++ trunk/Source/WebCore/ChangeLog	2012-03-08 03:02:40 UTC (rev 110130)
@@ -1,3 +1,29 @@
+2012-03-07  Kent Tamura  <tk...@chromium.org>
+
+        Remove meaningless code in RenderTextControlSingleLine::preferredContentWidth()
+        https://bugs.webkit.org/show_bug.cgi?id=80493
+
+        Reviewed by Hajime Morita.
+
+        preferredContentWidth() added border+padding widths of the search result
+        button, search cancel button, and speech input button. It makes no sense
+        to make the intrinsic width wider by only their border+padding width,
+        not their content width.
+
+        The default borders and paddings of these buttons are 0 in all
+        platforms, and adding border or padding to these elements by page
+        authors made unreasonable behavior. So we had better remove this
+        code.
+
+        Tests: fast/forms/search/intrinsic-search-width-with-decoration-border-padding.html
+               fast/speech/intrinsic-input-width-with-speech-border-padding.html
+
+        * rendering/RenderTextControlSingleLine.cpp:
+        (WebCore::RenderTextControlSingleLine::preferredContentWidth):
+         Remove the meaningless code.
+        * rendering/RenderTextControlSingleLine.h:
+        (RenderTextControlSingleLine): Remove speechButtonElement(). It's unnecessary.
+
 2012-03-07  Sheriff Bot  <webkit.review....@gmail.com>
 
         Unreviewed, rolling out r110126.

Modified: trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp (110129 => 110130)


--- trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp	2012-03-08 02:50:39 UTC (rev 110129)
+++ trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp	2012-03-08 03:02:40 UTC (rev 110130)
@@ -361,13 +361,6 @@
     }
 }
 
-#if ENABLE(INPUT_SPEECH)
-HTMLElement* RenderTextControlSingleLine::speechButtonElement() const
-{
-    return inputElement()->speechButtonElement();
-}
-#endif
-
 bool RenderTextControlSingleLine::hasControlClip() const
 {
     // Apply control clip for text fields with decorations.
@@ -418,16 +411,6 @@
     if (maxCharWidth > 0.f)
         result += maxCharWidth - charWidth;
 
-    HTMLElement* resultsButton = resultsButtonElement();
-    if (RenderBox* resultsRenderer = resultsButton ? resultsButton->renderBox() : 0)
-        result += resultsRenderer->borderLeft() + resultsRenderer->borderRight() +
-                  resultsRenderer->paddingLeft() + resultsRenderer->paddingRight();
-
-    HTMLElement* cancelButton = cancelButtonElement();
-    if (RenderBox* cancelRenderer = cancelButton ? cancelButton->renderBox() : 0)
-        result += cancelRenderer->borderLeft() + cancelRenderer->borderRight() +
-                  cancelRenderer->paddingLeft() + cancelRenderer->paddingRight();
-
     if (includesDecoration) {
         HTMLElement* spinButton = innerSpinButtonElement();
         if (RenderBox* spinRenderer = spinButton ? spinButton->renderBox() : 0) {
@@ -439,13 +422,6 @@
         }
     }
 
-#if ENABLE(INPUT_SPEECH)
-    HTMLElement* speechButton = speechButtonElement();
-    if (RenderBox* speechRenderer = speechButton ? speechButton->renderBox() : 0) {
-        result += speechRenderer->borderLeft() + speechRenderer->borderRight() +
-                  speechRenderer->paddingLeft() + speechRenderer->paddingRight();
-    }
-#endif
     return result;
 }
 

Modified: trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h (110129 => 110130)


--- trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h	2012-03-08 02:50:39 UTC (rev 110129)
+++ trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h	2012-03-08 03:02:40 UTC (rev 110130)
@@ -49,10 +49,6 @@
 
     void capsLockStateMayHaveChanged();
 
-#if ENABLE(INPUT_SPEECH)
-    HTMLElement* speechButtonElement() const;
-#endif
-
 private:
     virtual bool hasControlClip() const;
     virtual LayoutRect controlClipRect(const LayoutPoint&) const;

Modified: trunk/Source/WebKit/chromium/ChangeLog (110129 => 110130)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-03-08 02:50:39 UTC (rev 110129)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-03-08 03:02:40 UTC (rev 110130)
@@ -1,3 +1,17 @@
+2012-03-07  Kent Tamura  <tk...@chromium.org>
+
+        Remove meaningless code in RenderTextControlSingleLine::preferredContentWidth()
+        https://bugs.webkit.org/show_bug.cgi?id=80493
+
+        Reviewed by Hajime Morita.
+
+        * src/WebInputElement.cpp:
+        RenderTextControlSingleLine::speechButtonElement() is removed. The
+        following functions get it from HTMLInputElement.
+        (WebKit::WebInputElement::getSpeechInputState):
+        (WebKit::WebInputElement::startSpeechInput):
+        (WebKit::WebInputElement::stopSpeechInput):
+
 2012-03-07  Adam Barth  <aba...@webkit.org>
 
         Remove #define private public from WebCache.cpp

Modified: trunk/Source/WebKit/chromium/src/WebInputElement.cpp (110129 => 110130)


--- trunk/Source/WebKit/chromium/src/WebInputElement.cpp	2012-03-08 02:50:39 UTC (rev 110129)
+++ trunk/Source/WebKit/chromium/src/WebInputElement.cpp	2012-03-08 03:02:40 UTC (rev 110130)
@@ -33,8 +33,6 @@
 
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
-#include "RenderObject.h"
-#include "RenderTextControlSingleLine.h"
 #include "TextControlInnerElements.h"
 #include "platform/WebString.h"
 #include <wtf/PassRefPtr.h>
@@ -165,12 +163,7 @@
 WebInputElement::SpeechInputState WebInputElement::getSpeechInputState() const
 {
 #if ENABLE(INPUT_SPEECH)
-    RenderObject* renderer = constUnwrap<HTMLInputElement>()->renderer();
-    if (!renderer)
-        return Idle;
-
-    RenderTextControlSingleLine* control = toRenderTextControlSingleLine(renderer);
-    InputFieldSpeechButtonElement* speechButton = toInputFieldSpeechButtonElement(control->speechButtonElement());
+    InputFieldSpeechButtonElement* speechButton = toInputFieldSpeechButtonElement(constUnwrap<HTMLInputElement>()->speechButtonElement());
     if (speechButton)
         return static_cast<WebInputElement::SpeechInputState>(speechButton->state());
 #endif
@@ -181,12 +174,7 @@
 void WebInputElement::startSpeechInput()
 {
 #if ENABLE(INPUT_SPEECH)
-    RenderObject* renderer = constUnwrap<HTMLInputElement>()->renderer();
-    if (!renderer)
-        return;
-
-    RenderTextControlSingleLine* control = toRenderTextControlSingleLine(renderer);
-    InputFieldSpeechButtonElement* speechButton = toInputFieldSpeechButtonElement(control->speechButtonElement());
+    InputFieldSpeechButtonElement* speechButton = toInputFieldSpeechButtonElement(constUnwrap<HTMLInputElement>()->speechButtonElement());
     if (speechButton)
         speechButton->startSpeechInput();
 #endif
@@ -195,12 +183,7 @@
 void WebInputElement::stopSpeechInput()
 {
 #if ENABLE(INPUT_SPEECH)
-    RenderObject* renderer = constUnwrap<HTMLInputElement>()->renderer();
-    if (!renderer)
-        return;
-
-    RenderTextControlSingleLine* control = toRenderTextControlSingleLine(renderer);
-    InputFieldSpeechButtonElement* speechButton = toInputFieldSpeechButtonElement(control->speechButtonElement());
+    InputFieldSpeechButtonElement* speechButton = toInputFieldSpeechButtonElement(constUnwrap<HTMLInputElement>()->speechButtonElement());
     if (speechButton)
         speechButton->stopSpeechInput();
 #endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to