Title: [139216] trunk
Revision
139216
Author
o...@chromium.org
Date
2013-01-09 11:41:01 -0800 (Wed, 09 Jan 2013)

Log Message

min-content gets the wrong value if min-width is set on some form controls
https://bugs.webkit.org/show_bug.cgi?id=106389

Reviewed by Tony Chang.

Source/WebCore:

Simplify the logic. The only exposed change in behavior is that
m_minPreferredLogicalWidth gets set to m_maxPreferredLogicalWidth
instead of 0 when min-width is set.

Test: fast/forms/min-content-form-controls.html

* rendering/RenderFileUploadControl.cpp:
(WebCore::RenderFileUploadControl::computePreferredLogicalWidths):
* rendering/RenderListBox.cpp:
(WebCore::RenderListBox::computePreferredLogicalWidths):
* rendering/RenderMenuList.cpp:
(WebCore::RenderMenuList::computePreferredLogicalWidths):
* rendering/RenderSlider.cpp:
(WebCore::RenderSlider::computePreferredLogicalWidths):
* rendering/RenderTextControl.cpp:
(WebCore::RenderTextControl::computePreferredLogicalWidths):

LayoutTests:

* fast/forms/min-content-form-controls-expected.txt: Added.
* fast/forms/min-content-form-controls.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (139215 => 139216)


--- trunk/LayoutTests/ChangeLog	2013-01-09 19:36:21 UTC (rev 139215)
+++ trunk/LayoutTests/ChangeLog	2013-01-09 19:41:01 UTC (rev 139216)
@@ -1,3 +1,13 @@
+2013-01-08  Ojan Vafai  <o...@chromium.org>
+
+        min-content gets the wrong value if min-width is set on some form controls
+        https://bugs.webkit.org/show_bug.cgi?id=106389
+
+        Reviewed by Tony Chang.
+
+        * fast/forms/min-content-form-controls-expected.txt: Added.
+        * fast/forms/min-content-form-controls.html: Added.
+
 2013-01-09  Roger Fong  <roger_f...@apple.com>
 
         Unreviewed. Skipping 4 video controls tests on Windows.

Added: trunk/LayoutTests/fast/forms/min-content-form-controls-expected.txt (0 => 139216)


--- trunk/LayoutTests/fast/forms/min-content-form-controls-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/min-content-form-controls-expected.txt	2013-01-09 19:41:01 UTC (rev 139216)
@@ -0,0 +1,11 @@
+PASS document.getElementById("text-a").offsetWidth is document.getElementById("text-b").offsetWidth
+PASS document.getElementById("file-a").offsetWidth is document.getElementById("file-b").offsetWidth
+PASS document.getElementById("range-a").offsetWidth is document.getElementById("range-b").offsetWidth
+PASS document.getElementById("select-a").offsetWidth is document.getElementById("select-b").offsetWidth
+PASS document.getElementById("multiple-a").offsetWidth is document.getElementById("multiple-b").offsetWidth
+PASS successfullyParsed is true
+
+TEST COMPLETE
+The form controls of the same type below should be the same width.
+
+             

Added: trunk/LayoutTests/fast/forms/min-content-form-controls.html (0 => 139216)


--- trunk/LayoutTests/fast/forms/min-content-form-controls.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/min-content-form-controls.html	2013-01-09 19:41:01 UTC (rev 139216)
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<style>
+.min-content {
+    min-width: 10px;
+    width: -webkit-min-content;
+    width: -moz-min-content;
+    width: -ie-min-content;
+    width: -o-min-content;
+    width: min-content;
+}
+</style>
+<p>The form controls of the same type below should be the same width.</p>
+
+<input id="text-a" class="min-content">
+<input id="text-b">
+
+<input id="file-a" type=file class="min-content">
+<input id="file-b" type=file>
+
+<input id="range-a" type=range class="min-content">
+<input id="range-b" type=range>
+
+<select id="select-a" class="min-content"><option>aaaaaaaaaaaaaaaaaaaaaaaaa</option></select>
+<select id="select-b"><option>aaaaaaaaaaaaaaaaaaaaaaaaa</option></select>
+
+<select id="multiple-a" multiple class="min-content"><option>aaaaaaaaaaaaaaaaaaaaaaaaa</option></select>
+<select id="multiple-b" multiple><option>aaaaaaaaaaaaaaaaaaaaaaaaa</option></select>
+
+<script src=""
+<script>
+var ids = ['text', 'file', 'range', 'select', 'multiple'];
+ids.forEach(function(id) {
+    shouldBe('document.getElementById("' + id + '-a").offsetWidth', 'document.getElementById("' + id + '-b").offsetWidth');
+})
+</script>
+<script src=""

Modified: trunk/LayoutTests/platform/mac/TestExpectations (139215 => 139216)


--- trunk/LayoutTests/platform/mac/TestExpectations	2013-01-09 19:36:21 UTC (rev 139215)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2013-01-09 19:41:01 UTC (rev 139216)
@@ -1244,6 +1244,10 @@
 
 webkit.org/b/105932 [ MountainLion Debug ] http/tests/inspector/resource-har-pages.html [ Crash ]
 
+# Need to see this run on the bots to see what's wrong. The code change in 
+# https://bugs.webkit.org/show_bug.cgi?id=106389 is only touching cross-platform code.
+Bug(ojan) fast/forms/min-content-form-controls.html [ Failure ]
+
 webkit.org/b/105986 [ Debug ] transitions/hang-with-bad-transition-list.html [ Pass Crash ]
 webkit.org/b/105986 [ Debug ] svg/dynamic-updates/SVGFEMorphologyElement-dom-in-attr.html [ Pass Crash ]
 webkit.org/b/105986 [ Debug ] svg/dynamic-updates/SVGFEMorphologyElement-dom-radius-attr.html [ Pass Crash ]

Modified: trunk/Source/WebCore/ChangeLog (139215 => 139216)


--- trunk/Source/WebCore/ChangeLog	2013-01-09 19:36:21 UTC (rev 139215)
+++ trunk/Source/WebCore/ChangeLog	2013-01-09 19:41:01 UTC (rev 139216)
@@ -1,3 +1,27 @@
+2013-01-08  Ojan Vafai  <o...@chromium.org>
+
+        min-content gets the wrong value if min-width is set on some form controls
+        https://bugs.webkit.org/show_bug.cgi?id=106389
+
+        Reviewed by Tony Chang.
+
+        Simplify the logic. The only exposed change in behavior is that
+        m_minPreferredLogicalWidth gets set to m_maxPreferredLogicalWidth
+        instead of 0 when min-width is set.
+
+        Test: fast/forms/min-content-form-controls.html
+
+        * rendering/RenderFileUploadControl.cpp:
+        (WebCore::RenderFileUploadControl::computePreferredLogicalWidths):
+        * rendering/RenderListBox.cpp:
+        (WebCore::RenderListBox::computePreferredLogicalWidths):
+        * rendering/RenderMenuList.cpp:
+        (WebCore::RenderMenuList::computePreferredLogicalWidths):
+        * rendering/RenderSlider.cpp:
+        (WebCore::RenderSlider::computePreferredLogicalWidths):
+        * rendering/RenderTextControl.cpp:
+        (WebCore::RenderTextControl::computePreferredLogicalWidths):
+
 2013-01-09  Abhishek Arya  <infe...@chromium.org>
 
         Mitigate out-of-bounds access in InlineIterator

Modified: trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp (139215 => 139216)


--- trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp	2013-01-09 19:36:21 UTC (rev 139215)
+++ trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp	2013-01-09 19:41:01 UTC (rev 139216)
@@ -190,15 +190,15 @@
             if (RenderObject* buttonRenderer = button->renderer())
                 defaultLabelWidth += buttonRenderer->maxPreferredLogicalWidth() + afterButtonSpacing;
         m_maxPreferredLogicalWidth = static_cast<int>(ceilf(max(minDefaultLabelWidth, defaultLabelWidth)));
+
+        if (!style->width().isPercent())
+            m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth;
     }
 
     if (style->minWidth().isFixed() && style->minWidth().value() > 0) {
         m_maxPreferredLogicalWidth = max(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style->minWidth().value()));
         m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style->minWidth().value()));
-    } else if (style->width().isPercent())
-        m_minPreferredLogicalWidth = 0;
-    else
-        m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth;
+    }
 
     if (style->maxWidth().isFixed()) {
         m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style->maxWidth().value()));

Modified: trunk/Source/WebCore/rendering/RenderListBox.cpp (139215 => 139216)


--- trunk/Source/WebCore/rendering/RenderListBox.cpp	2013-01-09 19:36:21 UTC (rev 139215)
+++ trunk/Source/WebCore/rendering/RenderListBox.cpp	2013-01-09 19:41:01 UTC (rev 139216)
@@ -216,15 +216,15 @@
         m_maxPreferredLogicalWidth = m_optionsWidth + 2 * optionsSpacingHorizontal;
         if (m_vBar)
             m_maxPreferredLogicalWidth += m_vBar->width();
+
+        if (!style()->width().isPercent())
+            m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth;
     }
 
     if (style()->minWidth().isFixed() && style()->minWidth().value() > 0) {
         m_maxPreferredLogicalWidth = max(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->minWidth().value()));
         m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->minWidth().value()));
-    } else if (style()->width().isPercent())
-        m_minPreferredLogicalWidth = 0;
-    else
-        m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth;
+    }
 
     if (style()->maxWidth().isFixed()) {
         m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->maxWidth().value()));

Modified: trunk/Source/WebCore/rendering/RenderMenuList.cpp (139215 => 139216)


--- trunk/Source/WebCore/rendering/RenderMenuList.cpp	2013-01-09 19:36:21 UTC (rev 139215)
+++ trunk/Source/WebCore/rendering/RenderMenuList.cpp	2013-01-09 19:41:01 UTC (rev 139216)
@@ -279,16 +279,17 @@
     
     if (style()->width().isFixed() && style()->width().value() > 0)
         m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = adjustContentBoxLogicalWidthForBoxSizing(style()->width().value());
-    else
+    else {
         m_maxPreferredLogicalWidth = max(m_optionsWidth, theme()->minimumMenuListSize(style())) + m_innerBlock->paddingLeft() + m_innerBlock->paddingRight();
 
+        if (!style()->width().isPercent())
+            m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth;
+    }
+
     if (style()->minWidth().isFixed() && style()->minWidth().value() > 0) {
         m_maxPreferredLogicalWidth = max(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->minWidth().value()));
         m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->minWidth().value()));
-    } else if (style()->width().isPercent())
-        m_minPreferredLogicalWidth = 0;
-    else
-        m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth;
+    }
 
     if (style()->maxWidth().isFixed()) {
         m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->maxWidth().value()));

Modified: trunk/Source/WebCore/rendering/RenderSlider.cpp (139215 => 139216)


--- trunk/Source/WebCore/rendering/RenderSlider.cpp	2013-01-09 19:36:21 UTC (rev 139215)
+++ trunk/Source/WebCore/rendering/RenderSlider.cpp	2013-01-09 19:41:01 UTC (rev 139216)
@@ -77,17 +77,18 @@
 
     if (style()->width().isFixed() && style()->width().value() > 0)
         m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = adjustContentBoxLogicalWidthForBoxSizing(style()->width().value());
-    else
+    else {
         m_maxPreferredLogicalWidth = defaultTrackLength * style()->effectiveZoom();
 
+        if (!style()->width().isPercent())
+            m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth;
+    }
+
     if (style()->minWidth().isFixed() && style()->minWidth().value() > 0) {
         m_maxPreferredLogicalWidth = max(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->minWidth().value()));
         m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->minWidth().value()));
-    } else if (style()->width().isPercent())
-        m_minPreferredLogicalWidth = 0;
-    else
-        m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth;
-    
+    }
+
     if (style()->maxWidth().isFixed()) {
         m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->maxWidth().value()));
         m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->maxWidth().value()));

Modified: trunk/Source/WebCore/rendering/RenderTextControl.cpp (139215 => 139216)


--- trunk/Source/WebCore/rendering/RenderTextControl.cpp	2013-01-09 19:36:21 UTC (rev 139215)
+++ trunk/Source/WebCore/rendering/RenderTextControl.cpp	2013-01-09 19:41:01 UTC (rev 139216)
@@ -269,15 +269,15 @@
         m_maxPreferredLogicalWidth = preferredContentWidth(getAvgCharWidth(family));
         if (RenderBox* innerTextRenderBox = innerTextElement()->renderBox())
             m_maxPreferredLogicalWidth += innerTextRenderBox->paddingLeft() + innerTextRenderBox->paddingRight();
+
+        if (!style()->width().isPercent())
+            m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth;
     }
 
     if (style()->minWidth().isFixed() && style()->minWidth().value() > 0) {
         m_maxPreferredLogicalWidth = max(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->minWidth().value()));
         m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->minWidth().value()));
-    } else if (style()->width().isPercent())
-        m_minPreferredLogicalWidth = 0;
-    else
-        m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth;
+    }
 
     if (style()->maxWidth().isFixed()) {
         m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->maxWidth().value()));
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to