From 6b31d5cec12166124fec7b8d593990054eeefd0a Mon Sep 17 00:00:00 2001 From: Alex Henrie Date: Fri, 27 Dec 2013 17:44:07 -0700 Subject: [PATCH] Bug 157846. nsTextControlFrame's padding should be inherited into its anonymous child so it appears inside the scroll area. r=roc The new code in nsTextControlFrame was written by Charly Molter :lahabana --HG-- extra : rebase_source : c9d91c3aef3a6029fc3b5d9693a2f3cc81b7b57e --- editor/reftests/xul/input.css | 12 ++--- editor/reftests/xul/reftest.list | 4 +- layout/forms/nsTextControlFrame.cpp | 45 +++++++------------ .../reftests/forms/input/number/reftest.list | 2 +- .../forms/input/text/intrinsic-size-ref.html | 11 +++++ .../forms/input/text/intrinsic-size.html | 11 +++++ layout/reftests/forms/input/text/reftest.list | 1 + .../padding-scrollbar-placement-ref.html | 23 ++++++++++ .../textarea/padding-scrollbar-placement.html | 23 ++++++++++ layout/reftests/forms/textarea/reftest.list | 1 + layout/style/forms.css | 11 ++--- toolkit/themes/faststripe/global/textbox.css | 6 +-- toolkit/themes/linux/global/autocomplete.css | 2 +- toolkit/themes/linux/global/numberbox.css | 2 +- toolkit/themes/linux/global/textbox.css | 6 +-- toolkit/themes/osx/global/textbox.css | 5 +-- toolkit/themes/windows/global/textbox.css | 6 +-- 17 files changed, 111 insertions(+), 60 deletions(-) create mode 100644 layout/reftests/forms/input/text/intrinsic-size-ref.html create mode 100644 layout/reftests/forms/input/text/intrinsic-size.html create mode 100644 layout/reftests/forms/textarea/padding-scrollbar-placement-ref.html create mode 100644 layout/reftests/forms/textarea/padding-scrollbar-placement.html diff --git a/editor/reftests/xul/input.css b/editor/reftests/xul/input.css index d18d6490ca87..f74bf3338622 100644 --- a/editor/reftests/xul/input.css +++ b/editor/reftests/xul/input.css @@ -3,12 +3,12 @@ #mac html|input, #mac html|textarea { margin: 4px; - padding: 0; + padding: 0 1px; } #win html|input, #win html|textarea { margin: 2px 4px; - padding: 2px 2px 3px; + padding: 2px 3px 3px; -moz-padding-start: 4px; } @@ -19,7 +19,7 @@ #linux html|input, #linux html|textarea { margin: 2px 4px; - padding: 2px 4px 3px; + padding: 2px 5px 3px; } textbox[multiline="true"], html|textarea { @@ -34,7 +34,7 @@ html|input, html|textarea { } html|input.ac { - padding: 0 3px !important; + padding: 0 4px !important; } html|input.empty { @@ -54,12 +54,12 @@ html|input.num { } #win html|input.num { - padding: 0 !important; + padding: 0 1px !important; } #linux html|input.num { -moz-margin-end: 3px; - padding: 3px; + padding: 3px 4px; } html|div.plainfield { diff --git a/editor/reftests/xul/reftest.list b/editor/reftests/xul/reftest.list index 14f639bad925..7ca152988185 100644 --- a/editor/reftests/xul/reftest.list +++ b/editor/reftests/xul/reftest.list @@ -15,9 +15,9 @@ fails-if(Android||B2G) == emptytextbox-5.xul emptytextbox-ref.xul # bug 783658 # Therefore, the equlity tests below should be marked as failing. != number-1.xul number-ref.xul != number-2.xul number-ref.xul -fails-if(Android||B2G) fails-if(windowsDefaultTheme&&/^Windows\x20NT\x20(5\.[12]|6\.[012])/.test(http.oscpu)) == number-3.xul number-ref.xul # bug 783658 +fails-if(Android||B2G) fails-if(windowsDefaultTheme&&/^Windows\x20NT\x20(5\.[12]|6\.[012])/.test(http.oscpu)) fuzzy(7,4) == number-3.xul number-ref.xul # bug 783658 != number-4.xul number-ref.xul -fails-if(Android||B2G) fails-if(windowsDefaultTheme&&/^Windows\x20NT\x20(5\.[12]|6\.[012])/.test(http.oscpu)) == number-5.xul number-ref.xul # bug 783658 +fails-if(Android||B2G) fails-if(windowsDefaultTheme&&/^Windows\x20NT\x20(5\.[12]|6\.[012])/.test(http.oscpu)) fuzzy(7,4) == number-5.xul number-ref.xul # bug 783658 fails-if(Android||B2G) fails-if(windowsDefaultTheme&&/^Windows\x20NT\x20(5\.[12]|6\.[012])/.test(http.oscpu)) == numberwithvalue-1.xul numberwithvalue-ref.xul # bug 783658 fails-if(Android||B2G) == passwd-1.xul passwd-ref.xul # bug 783658 fails-if(Android||B2G) == passwd-2.xul passwd-ref.xul # bug 783658 diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index ee3b0914c689..f404226ce936 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -190,17 +190,6 @@ nsTextControlFrame::CalcIntrinsicSize(nsRenderingContext* aRenderingContext, if (PresContext()->CompatibilityMode() == eCompatibility_FullStandards) { aIntrinsicSize.width += 1; } - - // Also add in the padding of our value div child. Note that it hasn't - // been reflowed yet, so we can't get its used padding, but it shouldn't be - // using percentage padding anyway. - nsMargin childPadding; - nsIFrame* firstChild = GetFirstPrincipalChild(); - if (firstChild && firstChild->StylePadding()->GetPadding(childPadding)) { - aIntrinsicSize.width += childPadding.LeftRight(); - } else { - NS_ERROR("Percentage padding on value div?"); - } } // Increment width with cols * letter-spacing. @@ -535,32 +524,28 @@ nsTextControlFrame::ReflowTextControlChild(nsIFrame* aKid, nsHTMLReflowMetrics& aParentDesiredSize) { // compute available size and frame offsets for child - nsSize availSize(aReflowState.ComputedWidth(), - aReflowState.ComputedHeight()); - availSize.width = std::max(availSize.width, 0); - availSize.height = std::max(availSize.height, 0); + nsSize availSize(aReflowState.ComputedWidth() + + aReflowState.ComputedPhysicalPadding().LeftRight(), + aReflowState.ComputedHeight() + + aReflowState.ComputedPhysicalPadding().TopBottom()); nsHTMLReflowState kidReflowState(aPresContext, aReflowState, aKid, availSize); // Set computed width and computed height for the child - nscoord width = availSize.width; - width -= kidReflowState.ComputedPhysicalMargin().LeftRight() + - kidReflowState.ComputedPhysicalBorderPadding().LeftRight(); - width = std::max(width, 0); - kidReflowState.SetComputedWidth(width); + // Set computed height for the child + kidReflowState.SetComputedHeight(aReflowState.ComputedHeight()); + kidReflowState.SetComputedWidth(aReflowState.ComputedWidth()); - nscoord height = availSize.height; - height -= kidReflowState.ComputedPhysicalMargin().TopBottom() + - kidReflowState.ComputedPhysicalBorderPadding().TopBottom(); - height = std::max(height, 0); - kidReflowState.SetComputedHeight(height); + // Set computed height for the child + kidReflowState.SetComputedHeight(aReflowState.ComputedHeight()); + kidReflowState.SetComputedWidth(aReflowState.ComputedWidth()); - // compute the offsets - nscoord xOffset = aReflowState.ComputedPhysicalBorderPadding().left - + kidReflowState.ComputedPhysicalMargin().left; - nscoord yOffset = aReflowState.ComputedPhysicalBorderPadding().top - + kidReflowState.ComputedPhysicalMargin().top; + // Offset the frame by the size of the parent's border. + nscoord xOffset = aReflowState.ComputedPhysicalBorderPadding().left - + aReflowState.ComputedPhysicalPadding().left; + nscoord yOffset = aReflowState.ComputedPhysicalBorderPadding().top - + aReflowState.ComputedPhysicalPadding().top; // reflow the child nsHTMLReflowMetrics desiredSize(aReflowState.GetWritingMode()); diff --git a/layout/reftests/forms/input/number/reftest.list b/layout/reftests/forms/input/number/reftest.list index 4c4888c72636..e989df275af2 100644 --- a/layout/reftests/forms/input/number/reftest.list +++ b/layout/reftests/forms/input/number/reftest.list @@ -15,7 +15,7 @@ fuzzy-if(/^Windows\x20NT\x205\.1/.test(http.oscpu),64,4) fuzzy-if(cocoaWidget,63 == from-number-to-other-type-unthemed-1.html from-number-to-other-type-unthemed-1-ref.html # dynamic value changes: -== show-value.html show-value-ref.html +fuzzy(2,6) == show-value.html show-value-ref.html # disabled == number-disabled.html number-disabled-ref.html diff --git a/layout/reftests/forms/input/text/intrinsic-size-ref.html b/layout/reftests/forms/input/text/intrinsic-size-ref.html new file mode 100644 index 000000000000..ca4a783862e3 --- /dev/null +++ b/layout/reftests/forms/input/text/intrinsic-size-ref.html @@ -0,0 +1,11 @@ + + + + Intrinsic Size Test Reference + + +
+ +
+ + diff --git a/layout/reftests/forms/input/text/intrinsic-size.html b/layout/reftests/forms/input/text/intrinsic-size.html new file mode 100644 index 000000000000..97941c4a417b --- /dev/null +++ b/layout/reftests/forms/input/text/intrinsic-size.html @@ -0,0 +1,11 @@ + + + + Intrinsic Size Test + + +
+ +
+ + diff --git a/layout/reftests/forms/input/text/reftest.list b/layout/reftests/forms/input/text/reftest.list index 7a5e5e5d732b..252869281a55 100644 --- a/layout/reftests/forms/input/text/reftest.list +++ b/layout/reftests/forms/input/text/reftest.list @@ -5,3 +5,4 @@ HTTP(..) == baseline-1.html baseline-1-ref.html HTTP(..) == centering-1.xul centering-1-ref.xul == dynamic-height-1.xul dynamic-height-1-ref.xul needs-focus == select.html select-ref.html +== intrinsic-size.html intrinsic-size-ref.html diff --git a/layout/reftests/forms/textarea/padding-scrollbar-placement-ref.html b/layout/reftests/forms/textarea/padding-scrollbar-placement-ref.html new file mode 100644 index 000000000000..db2fa6dce948 --- /dev/null +++ b/layout/reftests/forms/textarea/padding-scrollbar-placement-ref.html @@ -0,0 +1,23 @@ + + + + + Padding and Scrollbar Placement Test Reference + + + +
a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
+ + diff --git a/layout/reftests/forms/textarea/padding-scrollbar-placement.html b/layout/reftests/forms/textarea/padding-scrollbar-placement.html new file mode 100644 index 000000000000..a5ee61a4c74e --- /dev/null +++ b/layout/reftests/forms/textarea/padding-scrollbar-placement.html @@ -0,0 +1,23 @@ + + + + + Padding and Scrollbar Placement Test + + + + + + diff --git a/layout/reftests/forms/textarea/reftest.list b/layout/reftests/forms/textarea/reftest.list index e4b8e6344a5d..804bbba8cdcf 100644 --- a/layout/reftests/forms/textarea/reftest.list +++ b/layout/reftests/forms/textarea/reftest.list @@ -10,3 +10,4 @@ skip-if(B2G) fails-if(Android) fails-if(gtk2Widget) != rtl.html no-resize.html # == rtl.html rtl-dynamic-style.html == rtl.html in-dynamic-rtl-doc.html == setvalue-framereconstruction-1.html setvalue-framereconstruction-ref.html +fuzzy(51,6749) == padding-scrollbar-placement.html padding-scrollbar-placement-ref.html diff --git a/layout/style/forms.css b/layout/style/forms.css index 483a5bad1f99..27cabe75b227 100644 --- a/layout/style/forms.css +++ b/layout/style/forms.css @@ -54,7 +54,7 @@ input { /* The sum of border-top, border-bottom, padding-top, padding-bottom must be the same here, for buttons, and for