From 3cc070312f2bc201ae30b23a7ce937f4b43b6d29 Mon Sep 17 00:00:00 2001 From: Jonathan Watt Date: Wed, 5 Feb 2014 00:42:57 +0000 Subject: [PATCH] Bug 951310 - Make GetPrimaryFrame(); - if (outerWrapperFrame) { // display:none? + + if (!outerWrapperFrame) { // display:none? + if (contentBoxHeight == NS_INTRINSICSIZE) { + contentBoxHeight = 0; + } + } else { NS_ASSERTION(outerWrapperFrame == mFrames.FirstChild(), "huh?"); - nsresult rv = - ReflowAnonymousContent(aPresContext, wrappersDesiredSize, - aReflowState, outerWrapperFrame); + + nsHTMLReflowMetrics wrappersDesiredSize(aReflowState.GetWritingMode()); + + nsHTMLReflowState wrapperReflowState(aPresContext, aReflowState, + outerWrapperFrame, + nsSize(contentBoxWidth, + NS_UNCONSTRAINEDSIZE)); + + // offsets of wrapper frame + nscoord xoffset = aReflowState.ComputedPhysicalBorderPadding().left + + wrapperReflowState.ComputedPhysicalMargin().left; + nscoord yoffset = aReflowState.ComputedPhysicalBorderPadding().top + + wrapperReflowState.ComputedPhysicalMargin().top; + + nsReflowStatus childStatus; + nsresult rv = ReflowChild(outerWrapperFrame, aPresContext, + wrappersDesiredSize, wrapperReflowState, + xoffset, yoffset, 0, childStatus); NS_ENSURE_SUCCESS(rv, rv); - ConsiderChildOverflow(aDesiredSize.mOverflowAreas, outerWrapperFrame); + MOZ_ASSERT(NS_FRAME_IS_FULLY_COMPLETE(childStatus), + "We gave our child unconstrained height, so it should be complete"); + + nscoord wrappersMarginBoxHeight = wrappersDesiredSize.Height() + + wrapperReflowState.ComputedPhysicalMargin().TopBottom(); + + if (contentBoxHeight == NS_INTRINSICSIZE) { + // We are intrinsically sized -- we should shrinkwrap the outer wrapper's + // height: + contentBoxHeight = wrappersMarginBoxHeight; + + // Make sure we obey min/max-height in the case when we're doing intrinsic + // sizing (we get it for free when we have a non-intrinsic + // aReflowState.ComputedHeight()). Note that we do this before + // adjusting for borderpadding, since mComputedMaxHeight and + // mComputedMinHeight are content heights. + contentBoxHeight = + NS_CSS_MINMAX(contentBoxHeight, + aReflowState.ComputedMinHeight(), + aReflowState.ComputedMaxHeight()); + } + + // Center child vertically + nscoord extraSpace = contentBoxHeight - wrappersMarginBoxHeight; + yoffset += std::max(0, extraSpace / 2); + + // Place the child + rv = FinishReflowChild(outerWrapperFrame, aPresContext, + wrappersDesiredSize, &wrapperReflowState, + xoffset, yoffset, 0); + NS_ENSURE_SUCCESS(rv, rv); + + aDesiredSize.SetTopAscent(wrappersDesiredSize.TopAscent() + + outerWrapperFrame->GetPosition().y); } - nscoord computedHeight = aReflowState.ComputedHeight(); - if (computedHeight == NS_AUTOHEIGHT) { - computedHeight = - outerWrapperFrame ? outerWrapperFrame->GetSize().height : 0; - } - aDesiredSize.Width() = aReflowState.ComputedWidth() + + aDesiredSize.Width() = contentBoxWidth + aReflowState.ComputedPhysicalBorderPadding().LeftRight(); - aDesiredSize.Height() = computedHeight + + aDesiredSize.Height() = contentBoxHeight + aReflowState.ComputedPhysicalBorderPadding().TopBottom(); - if (outerWrapperFrame) { - aDesiredSize.SetTopAscent(wrappersDesiredSize.TopAscent() + - outerWrapperFrame->GetPosition().y); - } - aDesiredSize.SetOverflowAreasToDesiredBounds(); + if (outerWrapperFrame) { + ConsiderChildOverflow(aDesiredSize.mOverflowAreas, outerWrapperFrame); + } + FinishAndStoreOverflow(&aDesiredSize); aStatus = NS_FRAME_COMPLETE; @@ -120,41 +171,6 @@ nsNumberControlFrame::Reflow(nsPresContext* aPresContext, return NS_OK; } -nsresult -nsNumberControlFrame:: - ReflowAnonymousContent(nsPresContext* aPresContext, - nsHTMLReflowMetrics& aWrappersDesiredSize, - const nsHTMLReflowState& aParentReflowState, - nsIFrame* aOuterWrapperFrame) -{ - MOZ_ASSERT(aOuterWrapperFrame); - - // The width of our content box, which is the available width - // for our anonymous content: - nscoord inputFrameContentBoxWidth = aParentReflowState.ComputedWidth(); - - nsHTMLReflowState wrapperReflowState(aPresContext, aParentReflowState, - aOuterWrapperFrame, - nsSize(inputFrameContentBoxWidth, - NS_UNCONSTRAINEDSIZE)); - - nscoord xoffset = aParentReflowState.ComputedPhysicalBorderPadding().left + - wrapperReflowState.ComputedPhysicalMargin().left; - nscoord yoffset = aParentReflowState.ComputedPhysicalBorderPadding().top + - wrapperReflowState.ComputedPhysicalMargin().top; - - nsReflowStatus childStatus; - nsresult rv = ReflowChild(aOuterWrapperFrame, aPresContext, - aWrappersDesiredSize, wrapperReflowState, - xoffset, yoffset, 0, childStatus); - NS_ENSURE_SUCCESS(rv, rv); - MOZ_ASSERT(NS_FRAME_IS_FULLY_COMPLETE(childStatus), - "We gave our child unconstrained height, so it should be complete"); - return FinishReflowChild(aOuterWrapperFrame, aPresContext, - aWrappersDesiredSize, &wrapperReflowState, - xoffset, yoffset, 0); -} - void nsNumberControlFrame::SyncDisabledState() { diff --git a/layout/forms/nsNumberControlFrame.h b/layout/forms/nsNumberControlFrame.h index d76d122102ed..c4021767c5b8 100644 --- a/layout/forms/nsNumberControlFrame.h +++ b/layout/forms/nsNumberControlFrame.h @@ -159,11 +159,6 @@ private: nsCSSPseudoElements::Type aPseudoType, nsStyleContext* aParentContext); - nsresult ReflowAnonymousContent(nsPresContext* aPresContext, - nsHTMLReflowMetrics& aWrappersDesiredSize, - const nsHTMLReflowState& aReflowState, - nsIFrame* aOuterWrapperFrame); - class SyncDisabledStateEvent; friend class SyncDisabledStateEvent; class SyncDisabledStateEvent : public nsRunnable diff --git a/layout/reftests/forms/input/number/number-max-height-1-ref.html b/layout/reftests/forms/input/number/number-max-height-1-ref.html new file mode 100644 index 000000000000..5f17a624259d --- /dev/null +++ b/layout/reftests/forms/input/number/number-max-height-1-ref.html @@ -0,0 +1,17 @@ + + + + + + +
+ + diff --git a/layout/reftests/forms/input/number/number-max-height-1.html b/layout/reftests/forms/input/number/number-max-height-1.html new file mode 100644 index 000000000000..bf671a0f9e66 --- /dev/null +++ b/layout/reftests/forms/input/number/number-max-height-1.html @@ -0,0 +1,27 @@ + + + + + + + + + diff --git a/layout/reftests/forms/input/number/number-max-height-2-ref.html b/layout/reftests/forms/input/number/number-max-height-2-ref.html new file mode 100644 index 000000000000..8b654e7f98d6 --- /dev/null +++ b/layout/reftests/forms/input/number/number-max-height-2-ref.html @@ -0,0 +1,17 @@ + + + + + + +
+ + diff --git a/layout/reftests/forms/input/number/number-max-height-2.html b/layout/reftests/forms/input/number/number-max-height-2.html new file mode 100644 index 000000000000..ff118ea2382d --- /dev/null +++ b/layout/reftests/forms/input/number/number-max-height-2.html @@ -0,0 +1,27 @@ + + + + + + + + + diff --git a/layout/reftests/forms/input/number/number-min-height-1-ref.html b/layout/reftests/forms/input/number/number-min-height-1-ref.html new file mode 100644 index 000000000000..5f17a624259d --- /dev/null +++ b/layout/reftests/forms/input/number/number-min-height-1-ref.html @@ -0,0 +1,17 @@ + + + + + + +
+ + diff --git a/layout/reftests/forms/input/number/number-min-height-1.html b/layout/reftests/forms/input/number/number-min-height-1.html new file mode 100644 index 000000000000..75923b98b182 --- /dev/null +++ b/layout/reftests/forms/input/number/number-min-height-1.html @@ -0,0 +1,26 @@ + + + + + + + + + diff --git a/layout/reftests/forms/input/number/number-min-height-2-ref.html b/layout/reftests/forms/input/number/number-min-height-2-ref.html new file mode 100644 index 000000000000..8b654e7f98d6 --- /dev/null +++ b/layout/reftests/forms/input/number/number-min-height-2-ref.html @@ -0,0 +1,17 @@ + + + + + + +
+ + diff --git a/layout/reftests/forms/input/number/number-min-height-2.html b/layout/reftests/forms/input/number/number-min-height-2.html new file mode 100644 index 000000000000..9f69e1eaeee1 --- /dev/null +++ b/layout/reftests/forms/input/number/number-min-height-2.html @@ -0,0 +1,26 @@ + + + + + + + + + diff --git a/layout/reftests/forms/input/number/reftest.list b/layout/reftests/forms/input/number/reftest.list index 6784648cffe9..ac08170ff572 100644 --- a/layout/reftests/forms/input/number/reftest.list +++ b/layout/reftests/forms/input/number/reftest.list @@ -20,6 +20,12 @@ fuzzy-if(/^Windows\x20NT\x205\.1/.test(http.oscpu),64,4) fuzzy-if(cocoaWidget,63 # disabled == number-disabled.html number-disabled-ref.html +# min-height/max-height tests: +skip-if(B2G) == number-min-height-1.html number-min-height-1-ref.html +skip-if(B2G) == number-min-height-2.html number-min-height-2-ref.html +skip-if(B2G) == number-max-height-1.html number-max-height-1-ref.html +skip-if(B2G) == number-max-height-2.html number-max-height-2-ref.html + # focus # autofocus is disabled on B2G # https://bugzilla.mozilla.org/show_bug.cgi?id=965763