Bug 1173662 part 3: Use a LogicalPoint for child position in nsNumberControlFrame::Reflow. r=jfkthame

This commit is contained in:
Daniel Holbert 2015-06-12 14:20:01 -07:00
parent fd1f93dac8
commit 7bd62af350
4 changed files with 53 additions and 16 deletions

View File

@ -131,11 +131,24 @@ nsNumberControlFrame::Reflow(nsPresContext* aPresContext,
const nscoord contentBoxISize = aReflowState.ComputedISize(); const nscoord contentBoxISize = aReflowState.ComputedISize();
nscoord contentBoxBSize = aReflowState.ComputedBSize(); nscoord contentBoxBSize = aReflowState.ComputedBSize();
// Figure out our border-box sizes as well (by adding borderPadding to
// content-box sizes):
const nscoord borderBoxISize = contentBoxISize +
aReflowState.ComputedLogicalBorderPadding().IStartEnd(myWM);
nscoord borderBoxBSize;
if (contentBoxBSize != NS_INTRINSICSIZE) {
borderBoxBSize = contentBoxBSize +
aReflowState.ComputedLogicalBorderPadding().BStartEnd(myWM);
} // else, we'll figure out borderBoxBSize after we resolve contentBoxBSize.
nsIFrame* outerWrapperFrame = mOuterWrapper->GetPrimaryFrame(); nsIFrame* outerWrapperFrame = mOuterWrapper->GetPrimaryFrame();
if (!outerWrapperFrame) { // display:none? if (!outerWrapperFrame) { // display:none?
if (contentBoxBSize == NS_INTRINSICSIZE) { if (contentBoxBSize == NS_INTRINSICSIZE) {
contentBoxBSize = 0; contentBoxBSize = 0;
borderBoxBSize =
aReflowState.ComputedLogicalBorderPadding().BStartEnd(myWM);
} }
} else { } else {
NS_ASSERTION(outerWrapperFrame == mFrames.FirstChild(), "huh?"); NS_ASSERTION(outerWrapperFrame == mFrames.FirstChild(), "huh?");
@ -149,21 +162,25 @@ nsNumberControlFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowState wrapperReflowState(aPresContext, aReflowState, nsHTMLReflowState wrapperReflowState(aPresContext, aReflowState,
outerWrapperFrame, availSize); outerWrapperFrame, availSize);
// offsets of wrapper frame // Convert wrapper margin into my own writing-mode (in case it differs):
nscoord xoffset = aReflowState.ComputedPhysicalBorderPadding().left + LogicalMargin wrapperMargin =
wrapperReflowState.ComputedPhysicalMargin().left; wrapperReflowState.ComputedLogicalMargin().ConvertTo(myWM, wrapperWM);
nscoord yoffset = aReflowState.ComputedPhysicalBorderPadding().top +
wrapperReflowState.ComputedPhysicalMargin().top; // offsets of wrapper frame within this frame:
LogicalPoint
wrapperOffset(myWM,
aReflowState.ComputedLogicalBorderPadding().IStart(myWM) +
wrapperMargin.IStart(myWM),
aReflowState.ComputedLogicalBorderPadding().BStart(myWM) +
wrapperMargin.BStart(myWM));
nsReflowStatus childStatus; nsReflowStatus childStatus;
ReflowChild(outerWrapperFrame, aPresContext, wrappersDesiredSize, ReflowChild(outerWrapperFrame, aPresContext, wrappersDesiredSize,
wrapperReflowState, xoffset, yoffset, 0, childStatus); wrapperReflowState, myWM, wrapperOffset, 0, 0, childStatus);
MOZ_ASSERT(NS_FRAME_IS_FULLY_COMPLETE(childStatus), MOZ_ASSERT(NS_FRAME_IS_FULLY_COMPLETE(childStatus),
"We gave our child unconstrained available block-size, " "We gave our child unconstrained available block-size, "
"so it should be complete"); "so it should be complete");
LogicalMargin wrapperMargin =
wrapperReflowState.ComputedLogicalMargin().ConvertTo(myWM, wrapperWM);
nscoord wrappersMarginBoxBSize = nscoord wrappersMarginBoxBSize =
wrappersDesiredSize.BSize(myWM) + wrapperMargin.BStartEnd(myWM); wrappersDesiredSize.BSize(myWM) + wrapperMargin.BStartEnd(myWM);
@ -181,15 +198,23 @@ nsNumberControlFrame::Reflow(nsPresContext* aPresContext,
NS_CSS_MINMAX(contentBoxBSize, NS_CSS_MINMAX(contentBoxBSize,
aReflowState.ComputedMinBSize(), aReflowState.ComputedMinBSize(),
aReflowState.ComputedMaxBSize()); aReflowState.ComputedMaxBSize());
borderBoxBSize = contentBoxBSize +
aReflowState.ComputedLogicalBorderPadding().BStartEnd(myWM);
} }
// Center child in block axis // Center child in block axis
nscoord extraSpace = contentBoxBSize - wrappersMarginBoxBSize; nscoord extraSpace = contentBoxBSize - wrappersMarginBoxBSize;
yoffset += std::max(0, extraSpace / 2); wrapperOffset.B(myWM) += std::max(0, extraSpace / 2);
// Needed in FinishReflowChild, for logical-to-physical conversion:
nscoord borderBoxWidth = myWM.IsVertical() ?
borderBoxBSize : borderBoxISize;
// Place the child // Place the child
FinishReflowChild(outerWrapperFrame, aPresContext, wrappersDesiredSize, FinishReflowChild(outerWrapperFrame, aPresContext, wrappersDesiredSize,
&wrapperReflowState, xoffset, yoffset, 0); &wrapperReflowState, myWM, wrapperOffset,
borderBoxWidth, 0);
aDesiredSize.SetBlockStartAscent( aDesiredSize.SetBlockStartAscent(
wrappersDesiredSize.BlockStartAscent() + wrappersDesiredSize.BlockStartAscent() +
@ -197,12 +222,7 @@ nsNumberControlFrame::Reflow(nsPresContext* aPresContext,
contentBoxISize)); contentBoxISize));
} }
LogicalSize LogicalSize logicalDesiredSize(myWM, borderBoxISize, borderBoxBSize);
logicalDesiredSize(myWM,
contentBoxISize +
aReflowState.ComputedLogicalBorderPadding().IStartEnd(myWM),
contentBoxBSize +
aReflowState.ComputedLogicalBorderPadding().BStartEnd(myWM));
aDesiredSize.SetSize(myWM, logicalDesiredSize); aDesiredSize.SetSize(myWM, logicalDesiredSize);
aDesiredSize.SetOverflowAreasToDesiredBounds(); aDesiredSize.SetOverflowAreasToDesiredBounds();

View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<body style="direction: rtl">
<input type="text" style="-moz-appearance:none; width:200px;" value="1">
<!-- div to cover spin box area -->
<div style="display:block; position:absolute; background-color:black; width:200px; height:100px; top:0px; right:100px;"></div>
</body>
</html>

View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<body style="direction: rtl">
<input type="number" style="-moz-appearance:none; width:200px;" value="1">
<!-- div to cover spin box area -->
<div style="display:block; position:absolute; background-color:black; width:200px; height:100px; top:0px; right:100px;"></div>
</body>
</html>

View File

@ -9,6 +9,7 @@ skip-if(!Android&&!B2G&&!Mulet) == number-same-as-text-unthemed.html number-same
# should look the same as type=text, except for the spin box # should look the same as type=text, except for the spin box
== number-similar-to-text-unthemed.html number-similar-to-text-unthemed-ref.html == number-similar-to-text-unthemed.html number-similar-to-text-unthemed-ref.html
== number-similar-to-text-unthemed-rtl.html number-similar-to-text-unthemed-rtl-ref.html
# dynamic type changes: # dynamic type changes:
fuzzy-if(/^Windows\x20NT\x205\.1/.test(http.oscpu),64,4) fuzzy-if(cocoaWidget,63,4) == to-number-from-other-type-unthemed-1.html to-number-from-other-type-unthemed-1-ref.html fuzzy-if(/^Windows\x20NT\x205\.1/.test(http.oscpu),64,4) fuzzy-if(cocoaWidget,63,4) == to-number-from-other-type-unthemed-1.html to-number-from-other-type-unthemed-1-ref.html