summaryrefslogtreecommitdiff
path: root/layout/forms/nsHTMLButtonControlFrame.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'layout/forms/nsHTMLButtonControlFrame.cpp')
-rw-r--r--layout/forms/nsHTMLButtonControlFrame.cpp101
1 files changed, 10 insertions, 91 deletions
diff --git a/layout/forms/nsHTMLButtonControlFrame.cpp b/layout/forms/nsHTMLButtonControlFrame.cpp
index afedfa7748..1ec0ec6c94 100644
--- a/layout/forms/nsHTMLButtonControlFrame.cpp
+++ b/layout/forms/nsHTMLButtonControlFrame.cpp
@@ -157,10 +157,6 @@ nsHTMLButtonControlFrame::GetMinISize(nsRenderingContext* aRenderingContext)
kid,
nsLayoutUtils::MIN_ISIZE);
- result += GetWritingMode().IsVertical()
- ? mRenderer.GetAddedButtonBorderAndPadding().TopBottom()
- : mRenderer.GetAddedButtonBorderAndPadding().LeftRight();
-
return result;
}
@@ -175,10 +171,6 @@ nsHTMLButtonControlFrame::GetPrefISize(nsRenderingContext* aRenderingContext)
kid,
nsLayoutUtils::PREF_ISIZE);
- result += GetWritingMode().IsVertical()
- ? mRenderer.GetAddedButtonBorderAndPadding().TopBottom()
- : mRenderer.GetAddedButtonBorderAndPadding().LeftRight();
-
return result;
}
@@ -192,9 +184,6 @@ nsHTMLButtonControlFrame::Reflow(nsPresContext* aPresContext,
DO_GLOBAL_REFLOW_COUNT("nsHTMLButtonControlFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
- NS_PRECONDITION(aReflowInput.ComputedISize() != NS_INTRINSICSIZE,
- "Should have real computed inline-size by now");
-
if (mState & NS_FRAME_FIRST_REFLOW) {
nsFormControlFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), true);
}
@@ -237,34 +226,6 @@ nsHTMLButtonControlFrame::Reflow(nsPresContext* aPresContext,
NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize);
}
-// Helper-function that lets us clone the button's reflow state, but with its
-// ComputedWidth and ComputedHeight reduced by the amount of renderer-specific
-// focus border and padding that we're using. (This lets us provide a more
-// appropriate content-box size for descendents' percent sizes to resolve
-// against.)
-static ReflowInput
-CloneReflowInputWithReducedContentBox(
- const ReflowInput& aButtonReflowInput,
- const nsMargin& aFocusPadding)
-{
- nscoord adjustedWidth =
- aButtonReflowInput.ComputedWidth() - aFocusPadding.LeftRight();
- adjustedWidth = std::max(0, adjustedWidth);
-
- // (Only adjust height if it's an actual length.)
- nscoord adjustedHeight = aButtonReflowInput.ComputedHeight();
- if (adjustedHeight != NS_INTRINSICSIZE) {
- adjustedHeight -= aFocusPadding.TopBottom();
- adjustedHeight = std::max(0, adjustedHeight);
- }
-
- ReflowInput clone(aButtonReflowInput);
- clone.SetComputedWidth(adjustedWidth);
- clone.SetComputedHeight(adjustedHeight);
-
- return clone;
-}
-
void
nsHTMLButtonControlFrame::ReflowButtonContents(nsPresContext* aPresContext,
ReflowOutput& aButtonDesiredSize,
@@ -275,53 +236,17 @@ nsHTMLButtonControlFrame::ReflowButtonContents(nsPresContext* aPresContext,
LogicalSize availSize = aButtonReflowInput.ComputedSize(wm);
availSize.BSize(wm) = NS_INTRINSICSIZE;
- // Buttons have some bonus renderer-determined border/padding,
- // which occupies part of the button's content-box area:
- LogicalMargin focusPadding =
- LogicalMargin(wm, mRenderer.GetAddedButtonBorderAndPadding());
-
- // See whether out availSize's inline-size is big enough. If it's
- // smaller than our intrinsic min iSize, that means that the kid
- // wouldn't really fit. In that case, we overflow into our internal
- // focuspadding (which other browsers don't have) so that there's a
- // little more space for it.
- // Note that GetMinISize includes the focusPadding.
- nscoord IOverflow = GetMinISize(aButtonReflowInput.mRenderingContext) -
- aButtonReflowInput.ComputedISize();
- nscoord IFocusPadding = focusPadding.IStartEnd(wm);
- nscoord focusPaddingReduction = std::min(IFocusPadding,
- std::max(IOverflow, 0));
- if (focusPaddingReduction > 0) {
- nscoord startReduction = focusPadding.IStart(wm);
- if (focusPaddingReduction != IFocusPadding) {
- startReduction = NSToCoordRound(startReduction *
- (float(focusPaddingReduction) /
- float(IFocusPadding)));
- }
- focusPadding.IStart(wm) -= startReduction;
- focusPadding.IEnd(wm) -= focusPaddingReduction - startReduction;
- }
-
// shorthand for a value we need to use in a bunch of places
const LogicalMargin& clbp = aButtonReflowInput.ComputedLogicalBorderPadding();
- // Indent the child inside us by the focus border. We must do this separate
- // from the regular border.
- availSize.ISize(wm) -= focusPadding.IStartEnd(wm);
-
LogicalPoint childPos(wm);
- childPos.I(wm) = focusPadding.IStart(wm) + clbp.IStart(wm);
+ childPos.I(wm) = clbp.IStart(wm);
availSize.ISize(wm) = std::max(availSize.ISize(wm), 0);
- // Give child a clone of the button's reflow state, with height/width reduced
- // by focusPadding, so that descendants with height:100% don't protrude.
- ReflowInput adjustedButtonReflowInput =
- CloneReflowInputWithReducedContentBox(aButtonReflowInput,
- focusPadding.GetPhysicalMargin(wm));
-
ReflowInput contentsReflowInput(aPresContext,
- adjustedButtonReflowInput,
- aFirstKid, availSize);
+ aButtonReflowInput,
+ aFirstKid,
+ availSize);
nsReflowStatus contentsReflowStatus;
ReflowOutput contentsDesiredSize(aButtonReflowInput);
@@ -346,9 +271,8 @@ nsHTMLButtonControlFrame::ReflowButtonContents(nsPresContext* aPresContext,
buttonContentBox.BSize(wm) = aButtonReflowInput.ComputedBSize();
} else {
// Button is intrinsically sized -- it should shrinkwrap the
- // button-contents' bSize, plus any focus-padding space:
- buttonContentBox.BSize(wm) =
- contentsDesiredSize.BSize(wm) + focusPadding.BStartEnd(wm);
+ // button-contents' bSize:
+ buttonContentBox.BSize(wm) = contentsDesiredSize.BSize(wm);
// Make sure we obey min/max-bSize in the case when we're doing intrinsic
// sizing (we get it for free when we have a non-intrinsic
@@ -363,8 +287,7 @@ nsHTMLButtonControlFrame::ReflowButtonContents(nsPresContext* aPresContext,
if (aButtonReflowInput.ComputedISize() != NS_INTRINSICSIZE) {
buttonContentBox.ISize(wm) = aButtonReflowInput.ComputedISize();
} else {
- buttonContentBox.ISize(wm) =
- contentsDesiredSize.ISize(wm) + focusPadding.IStartEnd(wm);
+ buttonContentBox.ISize(wm) = contentsDesiredSize.ISize(wm);
buttonContentBox.ISize(wm) =
NS_CSS_MINMAX(buttonContentBox.ISize(wm),
aButtonReflowInput.ComputedMinISize(),
@@ -372,16 +295,12 @@ nsHTMLButtonControlFrame::ReflowButtonContents(nsPresContext* aPresContext,
}
// Center child in the block-direction in the button
- // (technically, inside of the button's focus-padding area)
- nscoord extraSpace =
- buttonContentBox.BSize(wm) - focusPadding.BStartEnd(wm) -
- contentsDesiredSize.BSize(wm);
+ nscoord extraSpace = buttonContentBox.BSize(wm) - contentsDesiredSize.BSize(wm);
childPos.B(wm) = std::max(0, extraSpace / 2);
- // Adjust childPos.B() to be in terms of the button's frame-rect, instead of
- // its focus-padding rect:
- childPos.B(wm) += focusPadding.BStart(wm) + clbp.BStart(wm);
+ // Adjust childPos.B() to be in terms of the button's frame-rect:
+ childPos.B(wm) += clbp.BStart(wm);
nsSize containerSize =
(buttonContentBox + clbp.Size(wm)).GetPhysicalSize(wm);