本文整理汇总了C++中nsMargin::TopBottom方法的典型用法代码示例。如果您正苦于以下问题:C++ nsMargin::TopBottom方法的具体用法?C++ nsMargin::TopBottom怎么用?C++ nsMargin::TopBottom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsMargin
的用法示例。
在下文中一共展示了nsMargin::TopBottom方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Deflate
// Deflate the rect by the specified margin
void nsRect::Deflate(const nsMargin &aMargin)
{
x += aMargin.left;
y += aMargin.top;
width = PR_MAX(0, width - aMargin.LeftRight());
height = PR_MAX(0, height - aMargin.TopBottom());
}
示例2: clone
// 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 nsHTMLReflowState
CloneReflowStateWithReducedContentBox(
const nsHTMLReflowState& aButtonReflowState,
const nsMargin& aFocusPadding)
{
nscoord adjustedWidth =
aButtonReflowState.ComputedWidth() - aFocusPadding.LeftRight();
adjustedWidth = std::max(0, adjustedWidth);
// (Only adjust height if it's an actual length.)
nscoord adjustedHeight = aButtonReflowState.ComputedHeight();
if (adjustedHeight != NS_INTRINSICSIZE) {
adjustedHeight -= aFocusPadding.TopBottom();
adjustedHeight = std::max(0, adjustedHeight);
}
nsHTMLReflowState clone(aButtonReflowState);
clone.SetComputedWidth(adjustedWidth);
clone.SetComputedHeight(adjustedHeight);
return clone;
}
示例3: availSize
void
nsHTMLButtonControlFrame::ReflowButtonContents(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsIFrame* aFirstKid,
nsMargin aFocusPadding,
nsReflowStatus& aStatus)
{
nsSize availSize(aReflowState.ComputedWidth(), NS_INTRINSICSIZE);
// Indent the child inside us by the focus border. We must do this separate
// from the regular border.
availSize.width -= aFocusPadding.LeftRight();
// See whether out availSize's width is big enough. If it's smaller than our
// intrinsic min width, that means that the kid wouldn't really fit; for a
// better look in such cases we adjust the available width and our left
// offset to allow the kid to spill left into our padding.
nscoord xoffset = aFocusPadding.left + aReflowState.mComputedBorderPadding.left;
nscoord extrawidth = GetMinWidth(aReflowState.rendContext) -
aReflowState.ComputedWidth();
if (extrawidth > 0) {
nscoord extraleft = extrawidth / 2;
nscoord extraright = extrawidth - extraleft;
NS_ASSERTION(extraright >=0, "How'd that happen?");
// Do not allow the extras to be bigger than the relevant padding
extraleft = std::min(extraleft, aReflowState.mComputedPadding.left);
extraright = std::min(extraright, aReflowState.mComputedPadding.right);
xoffset -= extraleft;
availSize.width += extraleft + extraright;
}
availSize.width = std::max(availSize.width,0);
nsHTMLReflowState reflowState(aPresContext, aReflowState, aFirstKid,
availSize);
ReflowChild(aFirstKid, aPresContext, aDesiredSize, reflowState,
xoffset,
aFocusPadding.top + aReflowState.mComputedBorderPadding.top,
0, aStatus);
// Compute our desired height before vertically centering our children
nscoord actualDesiredHeight = 0;
if (aReflowState.ComputedHeight() != NS_INTRINSICSIZE) {
actualDesiredHeight = aReflowState.ComputedHeight();
} else {
actualDesiredHeight = aDesiredSize.height + aFocusPadding.TopBottom();
// 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.
actualDesiredHeight = NS_CSS_MINMAX(actualDesiredHeight,
aReflowState.mComputedMinHeight,
aReflowState.mComputedMaxHeight);
}
// center child vertically in the content area
nscoord yoff = (actualDesiredHeight - aFocusPadding.TopBottom() - aDesiredSize.height) / 2;
if (yoff < 0) {
yoff = 0;
}
// Place the child
FinishReflowChild(aFirstKid, aPresContext, &reflowState, aDesiredSize,
xoffset,
yoff + aFocusPadding.top + aReflowState.mComputedBorderPadding.top, 0);
if (aDesiredSize.ascent == nsHTMLReflowMetrics::ASK_FOR_BASELINE)
aDesiredSize.ascent = aFirstKid->GetBaseline();
// Adjust the baseline by our offset (since we moved the child's
// baseline by that much), and set our actual desired height.
aDesiredSize.ascent += yoff;
aDesiredSize.height = actualDesiredHeight;
}
示例4: contentsReflowState
void
nsHTMLButtonControlFrame::ReflowButtonContents(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aButtonDesiredSize,
const nsHTMLReflowState& aButtonReflowState,
nsIFrame* aFirstKid)
{
// Buttons have some bonus renderer-determined border/padding,
// which occupies part of the button's content-box area:
const nsMargin focusPadding = mRenderer.GetAddedButtonBorderAndPadding();
WritingMode wm = aFirstKid->GetWritingMode();
LogicalSize availSize = aButtonReflowState.ComputedSize(GetWritingMode());
availSize.BSize(wm) = NS_INTRINSICSIZE;
// Indent the child inside us by the focus border. We must do this separate
// from the regular border.
availSize.ISize(wm) -= LogicalMargin(wm, focusPadding).IStartEnd(wm);
// See whether out availSize's width is big enough. If it's smaller than our
// intrinsic min width, that means that the kid wouldn't really fit; for a
// better look in such cases we adjust the available width and our left
// offset to allow the kid to spill left into our padding.
nscoord xoffset = focusPadding.left +
aButtonReflowState.ComputedPhysicalBorderPadding().left;
nscoord extrawidth = GetMinISize(aButtonReflowState.rendContext) -
aButtonReflowState.ComputedWidth();
if (extrawidth > 0) {
nscoord extraleft = extrawidth / 2;
nscoord extraright = extrawidth - extraleft;
NS_ASSERTION(extraright >=0, "How'd that happen?");
// Do not allow the extras to be bigger than the relevant padding
extraleft = std::min(extraleft, aButtonReflowState.ComputedPhysicalPadding().left);
extraright = std::min(extraright, aButtonReflowState.ComputedPhysicalPadding().right);
xoffset -= extraleft;
availSize.Width(wm) = availSize.Width(wm) + extraleft + extraright;
}
availSize.Width(wm) = std::max(availSize.Width(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.
nsHTMLReflowState adjustedButtonReflowState =
CloneReflowStateWithReducedContentBox(aButtonReflowState, focusPadding);
nsHTMLReflowState contentsReflowState(aPresContext,
adjustedButtonReflowState,
aFirstKid, availSize);
nsReflowStatus contentsReflowStatus;
nsHTMLReflowMetrics contentsDesiredSize(aButtonReflowState);
ReflowChild(aFirstKid, aPresContext,
contentsDesiredSize, contentsReflowState,
xoffset,
focusPadding.top + aButtonReflowState.ComputedPhysicalBorderPadding().top,
0, contentsReflowStatus);
MOZ_ASSERT(NS_FRAME_IS_COMPLETE(contentsReflowStatus),
"We gave button-contents frame unconstrained available height, "
"so it should be complete");
// Compute the button's content-box height:
nscoord buttonContentBoxHeight = 0;
if (aButtonReflowState.ComputedHeight() != NS_INTRINSICSIZE) {
// Button has a fixed height -- that's its content-box height.
buttonContentBoxHeight = aButtonReflowState.ComputedHeight();
} else {
// Button is intrinsically sized -- it should shrinkwrap the
// button-contents' height, plus any focus-padding space:
buttonContentBoxHeight =
contentsDesiredSize.Height() + focusPadding.TopBottom();
// 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
// aButtonReflowState.ComputedHeight()). Note that we do this before
// adjusting for borderpadding, since mComputedMaxHeight and
// mComputedMinHeight are content heights.
buttonContentBoxHeight =
NS_CSS_MINMAX(buttonContentBoxHeight,
aButtonReflowState.ComputedMinHeight(),
aButtonReflowState.ComputedMaxHeight());
}
// Center child vertically in the button
// (technically, inside of the button's focus-padding area)
nscoord extraSpace =
buttonContentBoxHeight - focusPadding.TopBottom() -
contentsDesiredSize.Height();
nscoord yoffset = std::max(0, extraSpace / 2);
// Adjust yoffset to be in terms of the button's frame-rect, instead of
// its focus-padding rect:
yoffset += focusPadding.top + aButtonReflowState.ComputedPhysicalBorderPadding().top;
// Place the child
FinishReflowChild(aFirstKid, aPresContext,
contentsDesiredSize, &contentsReflowState,
xoffset, yoffset, 0);
// Make sure we have a useful 'ascent' value for the child
if (contentsDesiredSize.BlockStartAscent() ==
//.........这里部分代码省略.........