本文整理汇总了C++中nsHTMLReflowState::ComputedPhysicalBorderPadding方法的典型用法代码示例。如果您正苦于以下问题:C++ nsHTMLReflowState::ComputedPhysicalBorderPadding方法的具体用法?C++ nsHTMLReflowState::ComputedPhysicalBorderPadding怎么用?C++ nsHTMLReflowState::ComputedPhysicalBorderPadding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsHTMLReflowState
的用法示例。
在下文中一共展示了nsHTMLReflowState::ComputedPhysicalBorderPadding方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: innerSize
void
nsSubDocumentFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
DO_GLOBAL_REFLOW_COUNT("nsSubDocumentFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
// printf("OuterFrame::Reflow %X (%d,%d) \n", this, aReflowState.AvailableWidth(), aReflowState.AvailableHeight());
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
("enter nsSubDocumentFrame::Reflow: maxSize=%d,%d",
aReflowState.AvailableWidth(), aReflowState.AvailableHeight()));
aStatus = NS_FRAME_COMPLETE;
NS_ASSERTION(mContent->GetPrimaryFrame() == this,
"Shouldn't happen");
// XUL <iframe> or <browser>, or HTML <iframe>, <object> or <embed>
nsLeafFrame::DoReflow(aPresContext, aDesiredSize, aReflowState, aStatus);
// "offset" is the offset of our content area from our frame's
// top-left corner.
nsPoint offset = nsPoint(aReflowState.ComputedPhysicalBorderPadding().left,
aReflowState.ComputedPhysicalBorderPadding().top);
nsSize innerSize(aDesiredSize.Width(), aDesiredSize.Height());
innerSize.width -= aReflowState.ComputedPhysicalBorderPadding().LeftRight();
innerSize.height -= aReflowState.ComputedPhysicalBorderPadding().TopBottom();
if (mInnerView) {
nsViewManager* vm = mInnerView->GetViewManager();
vm->MoveViewTo(mInnerView, offset.x, offset.y);
vm->ResizeView(mInnerView, nsRect(nsPoint(0, 0), innerSize), true);
}
aDesiredSize.SetOverflowAreasToDesiredBounds();
if (!ShouldClipSubdocument()) {
nsIFrame* subdocRootFrame = GetSubdocumentRootFrame();
if (subdocRootFrame) {
aDesiredSize.mOverflowAreas.UnionWith(subdocRootFrame->GetOverflowAreas() + offset);
}
}
FinishAndStoreOverflow(&aDesiredSize);
if (!aPresContext->IsPaginated() && !mPostedReflowCallback) {
PresContext()->PresShell()->PostReflowCallback(this);
mPostedReflowCallback = true;
}
// printf("OuterFrame::Reflow DONE %X (%d,%d)\n", this,
// aDesiredSize.Width(), aDesiredSize.Height());
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
("exit nsSubDocumentFrame::Reflow: size=%d,%d status=%x",
aDesiredSize.Width(), aDesiredSize.Height(), aStatus));
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
}
示例2:
// XXX how should border&padding effect baseline alignment?
// => descent = borderPadding.bottom for example
void
nsLeafFrame::AddBordersAndPadding(const nsHTMLReflowState& aReflowState,
nsHTMLReflowMetrics& aMetrics)
{
aMetrics.Width() += aReflowState.ComputedPhysicalBorderPadding().LeftRight();
aMetrics.Height() += aReflowState.ComputedPhysicalBorderPadding().TopBottom();
}
示例3: ReflowAnonymousContent
void
nsRangeFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
DO_GLOBAL_REFLOW_COUNT("nsRangeFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
NS_ASSERTION(mTrackDiv, "::-moz-range-track div must exist!");
NS_ASSERTION(mProgressDiv, "::-moz-range-progress div must exist!");
NS_ASSERTION(mThumbDiv, "::-moz-range-thumb div must exist!");
NS_ASSERTION(!GetPrevContinuation() && !GetNextContinuation(),
"nsRangeFrame should not have continuations; if it does we "
"need to call RegUnregAccessKey only for the first.");
if (mState & NS_FRAME_FIRST_REFLOW) {
nsFormControlFrame::RegUnRegAccessKey(this, true);
}
nscoord computedHeight = aReflowState.ComputedHeight();
if (computedHeight == NS_AUTOHEIGHT) {
computedHeight = 0;
}
aDesiredSize.Width() = aReflowState.ComputedWidth() +
aReflowState.ComputedPhysicalBorderPadding().LeftRight();
aDesiredSize.Height() = computedHeight +
aReflowState.ComputedPhysicalBorderPadding().TopBottom();
ReflowAnonymousContent(aPresContext, aDesiredSize, aReflowState);
aDesiredSize.SetOverflowAreasToDesiredBounds();
nsIFrame* trackFrame = mTrackDiv->GetPrimaryFrame();
if (trackFrame) {
ConsiderChildOverflow(aDesiredSize.mOverflowAreas, trackFrame);
}
nsIFrame* rangeProgressFrame = mProgressDiv->GetPrimaryFrame();
if (rangeProgressFrame) {
ConsiderChildOverflow(aDesiredSize.mOverflowAreas, rangeProgressFrame);
}
nsIFrame* thumbFrame = mThumbDiv->GetPrimaryFrame();
if (thumbFrame) {
ConsiderChildOverflow(aDesiredSize.mOverflowAreas, thumbFrame);
}
FinishAndStoreOverflow(&aDesiredSize);
aStatus = NS_FRAME_COMPLETE;
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
}
示例4: max
nscoord
nsColumnSetFrame::GetAvailableContentHeight(const nsHTMLReflowState& aReflowState)
{
if (aReflowState.AvailableHeight() == NS_INTRINSICSIZE) {
return NS_INTRINSICSIZE;
}
nsMargin bp = aReflowState.ComputedPhysicalBorderPadding();
bp.ApplySkipSides(GetSkipSides(&aReflowState));
bp.bottom = aReflowState.ComputedPhysicalBorderPadding().bottom;
return std::max(0, aReflowState.AvailableHeight() - bp.TopBottom());
}
示例5: while
NS_IMETHODIMP
nsTextControlFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
DO_GLOBAL_REFLOW_COUNT("nsTextControlFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
// make sure that the form registers itself on the initial/first reflow
if (mState & NS_FRAME_FIRST_REFLOW) {
nsFormControlFrame::RegUnRegAccessKey(this, true);
}
// set values of reflow's out parameters
aDesiredSize.Width() = aReflowState.ComputedWidth() +
aReflowState.ComputedPhysicalBorderPadding().LeftRight();
aDesiredSize.Height() = aReflowState.ComputedHeight() +
aReflowState.ComputedPhysicalBorderPadding().TopBottom();
// computation of the ascent wrt the input height
nscoord lineHeight = aReflowState.ComputedHeight();
float inflation = nsLayoutUtils::FontSizeInflationFor(this);
if (!IsSingleLineTextControl()) {
lineHeight = nsHTMLReflowState::CalcLineHeight(StyleContext(),
NS_AUTOHEIGHT, inflation);
}
nsRefPtr<nsFontMetrics> fontMet;
nsresult rv = nsLayoutUtils::GetFontMetricsForFrame(this,
getter_AddRefs(fontMet),
inflation);
NS_ENSURE_SUCCESS(rv, rv);
// now adjust for our borders and padding
aDesiredSize.SetTopAscent(
nsLayoutUtils::GetCenteredFontBaseline(fontMet, lineHeight)
+ aReflowState.ComputedPhysicalBorderPadding().top);
// overflow handling
aDesiredSize.SetOverflowAreasToDesiredBounds();
// perform reflow on all kids
nsIFrame* kid = mFrames.FirstChild();
while (kid) {
ReflowTextControlChild(kid, aPresContext, aReflowState, aStatus, aDesiredSize);
kid = kid->GetNextSibling();
}
// take into account css properties that affect overflow handling
FinishAndStoreOverflow(&aDesiredSize);
aStatus = NS_FRAME_COMPLETE;
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
return NS_OK;
}
示例6: ApplySkipSides
void
nsGridContainerFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
DO_GLOBAL_REFLOW_COUNT("nsGridContainerFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
if (IsFrameTreeTooDeep(aReflowState, aDesiredSize, aStatus)) {
return;
}
nsMargin bp = aReflowState.ComputedPhysicalBorderPadding();
ApplySkipSides(bp);
nscoord contentHeight = GetEffectiveComputedHeight(aReflowState);
if (contentHeight == NS_AUTOHEIGHT) {
contentHeight = 0;
}
aDesiredSize.Width() = aReflowState.ComputedWidth() + bp.LeftRight();
aDesiredSize.Height() = contentHeight + bp.TopBottom();
aDesiredSize.SetOverflowAreasToDesiredBounds();
aStatus = NS_FRAME_COMPLETE;
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
}
示例7: availSize
void
nsTextControlFrame::ReflowTextControlChild(nsIFrame* aKid,
nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus,
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);
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);
nscoord height = availSize.height;
height -= kidReflowState.ComputedPhysicalMargin().TopBottom() +
kidReflowState.ComputedPhysicalBorderPadding().TopBottom();
height = std::max(height, 0);
kidReflowState.SetComputedHeight(height);
// compute the offsets
nscoord xOffset = aReflowState.ComputedPhysicalBorderPadding().left
+ kidReflowState.ComputedPhysicalMargin().left;
nscoord yOffset = aReflowState.ComputedPhysicalBorderPadding().top
+ kidReflowState.ComputedPhysicalMargin().top;
// reflow the child
nsHTMLReflowMetrics desiredSize(aReflowState.GetWritingMode());
ReflowChild(aKid, aPresContext, desiredSize, kidReflowState,
xOffset, yOffset, 0, aStatus);
// place the child
FinishReflowChild(aKid, aPresContext, &kidReflowState,
desiredSize, xOffset, yOffset, 0);
// consider the overflow
aParentDesiredSize.mOverflowAreas.UnionWith(desiredSize.mOverflowAreas);
}
示例8: reflowState
void
nsMeterFrame::ReflowBarFrame(nsIFrame* aBarFrame,
nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
bool vertical = ResolvedOrientationIsVertical();
WritingMode wm = aBarFrame->GetWritingMode();
LogicalSize availSize = aReflowState.ComputedSize(wm);
availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
nsHTMLReflowState reflowState(aPresContext, aReflowState,
aBarFrame, availSize);
nscoord size = vertical ? aReflowState.ComputedHeight()
: aReflowState.ComputedWidth();
nscoord xoffset = aReflowState.ComputedPhysicalBorderPadding().left;
nscoord yoffset = aReflowState.ComputedPhysicalBorderPadding().top;
// NOTE: Introduce a new function getPosition in the content part ?
HTMLMeterElement* meterElement = static_cast<HTMLMeterElement*>(mContent);
double max = meterElement->Max();
double min = meterElement->Min();
double value = meterElement->Value();
double position = max - min;
position = position != 0 ? (value - min) / position : 1;
size = NSToCoordRound(size * position);
if (!vertical && (wm.IsVertical() ? wm.IsVerticalRL() : !wm.IsBidiLTR())) {
xoffset += aReflowState.ComputedWidth() - size;
}
// The bar position is *always* constrained.
if (vertical) {
// We want the bar to begin at the bottom.
yoffset += aReflowState.ComputedHeight() - size;
size -= reflowState.ComputedPhysicalMargin().TopBottom() +
reflowState.ComputedPhysicalBorderPadding().TopBottom();
size = std::max(size, 0);
reflowState.SetComputedHeight(size);
} else {
size -= reflowState.ComputedPhysicalMargin().LeftRight() +
reflowState.ComputedPhysicalBorderPadding().LeftRight();
size = std::max(size, 0);
reflowState.SetComputedWidth(size);
}
xoffset += reflowState.ComputedPhysicalMargin().left;
yoffset += reflowState.ComputedPhysicalMargin().top;
nsHTMLReflowMetrics barDesiredSize(reflowState);
ReflowChild(aBarFrame, aPresContext, barDesiredSize, reflowState, xoffset,
yoffset, 0, aStatus);
FinishReflowChild(aBarFrame, aPresContext, barDesiredSize, &reflowState,
xoffset, yoffset, 0);
}
示例9: kidReflowState
void
nsTextControlFrame::ReflowTextControlChild(nsIFrame* aKid,
nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus,
nsHTMLReflowMetrics& aParentDesiredSize)
{
// compute available size and frame offsets for child
WritingMode wm = aKid->GetWritingMode();
LogicalSize availSize = aReflowState.ComputedSizeWithPadding(wm);
availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
nsHTMLReflowState kidReflowState(aPresContext, aReflowState,
aKid, availSize, nullptr,
nsHTMLReflowState::CALLER_WILL_INIT);
// Override padding with our computed padding in case we got it from theming or percentage
kidReflowState.Init(aPresContext, nullptr, nullptr, &aReflowState.ComputedPhysicalPadding());
// Set computed width and computed height for the child
kidReflowState.SetComputedWidth(aReflowState.ComputedWidth());
kidReflowState.SetComputedHeight(aReflowState.ComputedHeight());
// 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);
ReflowChild(aKid, aPresContext, desiredSize, kidReflowState,
xOffset, yOffset, 0, aStatus);
// place the child
FinishReflowChild(aKid, aPresContext, desiredSize,
&kidReflowState, xOffset, yOffset, 0);
// consider the overflow
aParentDesiredSize.mOverflowAreas.UnionWith(desiredSize.mOverflowAreas);
}
示例10: 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() ==
//.........这里部分代码省略.........
示例11: availSize
nsresult
nsFirstLetterFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aMetrics,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aReflowStatus)
{
DO_GLOBAL_REFLOW_COUNT("nsFirstLetterFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aReflowStatus);
nsresult rv = NS_OK;
// Grab overflow list
DrainOverflowFrames(aPresContext);
nsIFrame* kid = mFrames.FirstChild();
// Setup reflow state for our child
nsSize availSize(aReflowState.AvailableWidth(), aReflowState.AvailableHeight());
const nsMargin& bp = aReflowState.ComputedPhysicalBorderPadding();
nscoord lr = bp.left + bp.right;
nscoord tb = bp.top + bp.bottom;
NS_ASSERTION(availSize.width != NS_UNCONSTRAINEDSIZE,
"should no longer use unconstrained widths");
availSize.width -= lr;
if (NS_UNCONSTRAINEDSIZE != availSize.height) {
availSize.height -= tb;
}
// Reflow the child
if (!aReflowState.mLineLayout) {
// When there is no lineLayout provided, we provide our own. The
// only time that the first-letter-frame is not reflowing in a
// line context is when its floating.
nsHTMLReflowState rs(aPresContext, aReflowState, kid, availSize);
nsLineLayout ll(aPresContext, nullptr, &aReflowState, nullptr);
ll.BeginLineReflow(bp.left, bp.top, availSize.width, NS_UNCONSTRAINEDSIZE,
false, true,
ll.LineContainerFrame()->GetWritingMode(kid),
aReflowState.AvailableWidth());
rs.mLineLayout = ≪
ll.SetInFirstLetter(true);
ll.SetFirstLetterStyleOK(true);
kid->WillReflow(aPresContext);
kid->Reflow(aPresContext, aMetrics, rs, aReflowStatus);
ll.EndLineReflow();
ll.SetInFirstLetter(false);
// In the floating first-letter case, we need to set this ourselves;
// nsLineLayout::BeginSpan will set it in the other case
mBaseline = aMetrics.TopAscent();
}
else {
// Pretend we are a span and reflow the child frame
nsLineLayout* ll = aReflowState.mLineLayout;
bool pushedFrame;
ll->SetInFirstLetter(
mStyleContext->GetPseudo() == nsCSSPseudoElements::firstLetter);
ll->BeginSpan(this, &aReflowState, bp.left, availSize.width, &mBaseline);
ll->ReflowFrame(kid, aReflowStatus, &aMetrics, pushedFrame);
ll->EndSpan(this);
ll->SetInFirstLetter(false);
}
// Place and size the child and update the output metrics
kid->SetRect(nsRect(bp.left, bp.top, aMetrics.Width(), aMetrics.Height()));
kid->FinishAndStoreOverflow(&aMetrics);
kid->DidReflow(aPresContext, nullptr, nsDidReflowStatus::FINISHED);
aMetrics.Width() += lr;
aMetrics.Height() += tb;
aMetrics.SetTopAscent(aMetrics.TopAscent() + bp.top);
// Ensure that the overflow rect contains the child textframe's overflow rect.
// Note that if this is floating, the overline/underline drawable area is in
// the overflow rect of the child textframe.
aMetrics.UnionOverflowAreasWithDesiredBounds();
ConsiderChildOverflow(aMetrics.mOverflowAreas, kid);
if (!NS_INLINE_IS_BREAK_BEFORE(aReflowStatus)) {
// Create a continuation or remove existing continuations based on
// the reflow completion status.
if (NS_FRAME_IS_COMPLETE(aReflowStatus)) {
if (aReflowState.mLineLayout) {
aReflowState.mLineLayout->SetFirstLetterStyleOK(false);
}
nsIFrame* kidNextInFlow = kid->GetNextInFlow();
if (kidNextInFlow) {
// Remove all of the childs next-in-flows
static_cast<nsContainerFrame*>(kidNextInFlow->GetParent())
->DeleteNextInFlowChild(kidNextInFlow, true);
}
}
else {
// Create a continuation for the child frame if it doesn't already
// have one.
if (!IsFloating()) {
nsIFrame* nextInFlow;
//.........这里部分代码省略.........
示例12: innerSize
void
nsSubDocumentFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsSubDocumentFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
("enter nsSubDocumentFrame::Reflow: maxSize=%d,%d",
aReflowState.AvailableWidth(), aReflowState.AvailableHeight()));
NS_ASSERTION(aReflowState.ComputedWidth() != NS_UNCONSTRAINEDSIZE,
"Shouldn't have unconstrained stuff here "
"thanks to the rules of reflow");
NS_ASSERTION(NS_INTRINSICSIZE != aReflowState.ComputedHeight(),
"Shouldn't have unconstrained stuff here "
"thanks to ComputeAutoSize");
aStatus = NS_FRAME_COMPLETE;
NS_ASSERTION(mContent->GetPrimaryFrame() == this,
"Shouldn't happen");
// XUL <iframe> or <browser>, or HTML <iframe>, <object> or <embed>
aDesiredSize.SetSize(aReflowState.GetWritingMode(),
aReflowState.ComputedSizeWithBorderPadding());
// "offset" is the offset of our content area from our frame's
// top-left corner.
nsPoint offset = nsPoint(aReflowState.ComputedPhysicalBorderPadding().left,
aReflowState.ComputedPhysicalBorderPadding().top);
if (mInnerView) {
const nsMargin& bp = aReflowState.ComputedPhysicalBorderPadding();
nsSize innerSize(aDesiredSize.Width() - bp.LeftRight(),
aDesiredSize.Height() - bp.TopBottom());
// Size & position the view according to 'object-fit' & 'object-position'.
nsIFrame* subDocRoot = ObtainIntrinsicSizeFrame();
IntrinsicSize intrinsSize;
nsSize intrinsRatio;
if (subDocRoot) {
intrinsSize = subDocRoot->GetIntrinsicSize();
intrinsRatio = subDocRoot->GetIntrinsicRatio();
}
nsRect destRect =
nsLayoutUtils::ComputeObjectDestRect(nsRect(offset, innerSize),
intrinsSize, intrinsRatio,
StylePosition());
nsViewManager* vm = mInnerView->GetViewManager();
vm->MoveViewTo(mInnerView, destRect.x, destRect.y);
vm->ResizeView(mInnerView, nsRect(nsPoint(0, 0), destRect.Size()), true);
}
aDesiredSize.SetOverflowAreasToDesiredBounds();
if (!ShouldClipSubdocument()) {
nsIFrame* subdocRootFrame = GetSubdocumentRootFrame();
if (subdocRootFrame) {
aDesiredSize.mOverflowAreas.UnionWith(subdocRootFrame->GetOverflowAreas() + offset);
}
}
FinishAndStoreOverflow(&aDesiredSize);
if (!aPresContext->IsPaginated() && !mPostedReflowCallback) {
PresContext()->PresShell()->PostReflowCallback(this);
mPostedReflowCallback = true;
}
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
("exit nsSubDocumentFrame::Reflow: size=%d,%d status=%x",
aDesiredSize.Width(), aDesiredSize.Height(), aStatus));
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
}
示例13: wrappersDesiredSize
void
nsNumberControlFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
DO_GLOBAL_REFLOW_COUNT("nsNumberControlFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
NS_ASSERTION(mOuterWrapper, "Outer wrapper div must exist!");
NS_ASSERTION(!GetPrevContinuation() && !GetNextContinuation(),
"nsNumberControlFrame should not have continuations; if it does we "
"need to call RegUnregAccessKey only for the first");
NS_ASSERTION(!mFrames.FirstChild() ||
!mFrames.FirstChild()->GetNextSibling(),
"We expect at most one direct child frame");
if (mState & NS_FRAME_FIRST_REFLOW) {
nsFormControlFrame::RegUnRegAccessKey(this, true);
}
// The width of our content box, which is the available width
// for our anonymous content:
const nscoord contentBoxWidth = aReflowState.ComputedWidth();
nscoord contentBoxHeight = aReflowState.ComputedHeight();
nsIFrame* outerWrapperFrame = mOuterWrapper->GetPrimaryFrame();
if (!outerWrapperFrame) { // display:none?
if (contentBoxHeight == NS_INTRINSICSIZE) {
contentBoxHeight = 0;
}
} else {
NS_ASSERTION(outerWrapperFrame == mFrames.FirstChild(), "huh?");
nsHTMLReflowMetrics wrappersDesiredSize(aReflowState);
WritingMode wm = outerWrapperFrame->GetWritingMode();
LogicalSize availSize = aReflowState.ComputedSize(wm);
availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
nsHTMLReflowState wrapperReflowState(aPresContext, aReflowState,
outerWrapperFrame, availSize);
// offsets of wrapper frame
nscoord xoffset = aReflowState.ComputedPhysicalBorderPadding().left +
wrapperReflowState.ComputedPhysicalMargin().left;
nscoord yoffset = aReflowState.ComputedPhysicalBorderPadding().top +
wrapperReflowState.ComputedPhysicalMargin().top;
nsReflowStatus childStatus;
ReflowChild(outerWrapperFrame, aPresContext, wrappersDesiredSize,
wrapperReflowState, xoffset, yoffset, 0, childStatus);
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
FinishReflowChild(outerWrapperFrame, aPresContext, wrappersDesiredSize,
&wrapperReflowState, xoffset, yoffset, 0);
aDesiredSize.SetBlockStartAscent(
wrappersDesiredSize.BlockStartAscent() +
outerWrapperFrame->BStart(aReflowState.GetWritingMode(),
contentBoxWidth));
}
aDesiredSize.Width() = contentBoxWidth +
aReflowState.ComputedPhysicalBorderPadding().LeftRight();
aDesiredSize.Height() = contentBoxHeight +
aReflowState.ComputedPhysicalBorderPadding().TopBottom();
aDesiredSize.SetOverflowAreasToDesiredBounds();
if (outerWrapperFrame) {
ConsiderChildOverflow(aDesiredSize.mOverflowAreas, outerWrapperFrame);
//.........这里部分代码省略.........
示例14: kidDesiredSize
void
nsVideoFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aMetrics,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsVideoFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aStatus);
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
("enter nsVideoFrame::Reflow: availSize=%d,%d",
aReflowState.AvailableWidth(), aReflowState.AvailableHeight()));
NS_PRECONDITION(mState & NS_FRAME_IN_REFLOW, "frame is not in reflow");
aStatus = NS_FRAME_COMPLETE;
aMetrics.Width() = aReflowState.ComputedWidth();
aMetrics.Height() = aReflowState.ComputedHeight();
// stash this away so we can compute our inner area later
mBorderPadding = aReflowState.ComputedPhysicalBorderPadding();
aMetrics.Width() += mBorderPadding.left + mBorderPadding.right;
aMetrics.Height() += mBorderPadding.top + mBorderPadding.bottom;
// Reflow the child frames. We may have up to two, an image frame
// which is the poster, and a box frame, which is the video controls.
for (nsIFrame* child : mFrames) {
if (child->GetContent() == mPosterImage) {
// Reflow the poster frame.
nsImageFrame* imageFrame = static_cast<nsImageFrame*>(child);
nsHTMLReflowMetrics kidDesiredSize(aReflowState);
WritingMode wm = imageFrame->GetWritingMode();
LogicalSize availableSize = aReflowState.AvailableSize(wm);
LogicalSize cbSize = aMetrics.Size(aMetrics.GetWritingMode()).
ConvertTo(wm, aMetrics.GetWritingMode());
nsHTMLReflowState kidReflowState(aPresContext,
aReflowState,
imageFrame,
availableSize,
&cbSize);
nsRect posterRenderRect;
if (ShouldDisplayPoster()) {
posterRenderRect =
nsRect(nsPoint(mBorderPadding.left, mBorderPadding.top),
nsSize(aReflowState.ComputedWidth(),
aReflowState.ComputedHeight()));
}
kidReflowState.SetComputedWidth(posterRenderRect.width);
kidReflowState.SetComputedHeight(posterRenderRect.height);
ReflowChild(imageFrame, aPresContext, kidDesiredSize, kidReflowState,
posterRenderRect.x, posterRenderRect.y, 0, aStatus);
FinishReflowChild(imageFrame, aPresContext,
kidDesiredSize, &kidReflowState,
posterRenderRect.x, posterRenderRect.y, 0);
} else if (child->GetContent() == mVideoControls) {
// Reflow the video controls frame.
nsBoxLayoutState boxState(PresContext(), aReflowState.rendContext);
nsSize size = child->GetSize();
nsBoxFrame::LayoutChildAt(boxState,
child,
nsRect(mBorderPadding.left,
mBorderPadding.top,
aReflowState.ComputedWidth(),
aReflowState.ComputedHeight()));
if (child->GetSize() != size) {
RefPtr<nsRunnable> event = new DispatchResizeToControls(child->GetContent());
nsContentUtils::AddScriptRunner(event);
}
} else if (child->GetContent() == mCaptionDiv) {
// Reflow to caption div
nsHTMLReflowMetrics kidDesiredSize(aReflowState);
WritingMode wm = child->GetWritingMode();
LogicalSize availableSize = aReflowState.AvailableSize(wm);
LogicalSize cbSize = aMetrics.Size(aMetrics.GetWritingMode()).
ConvertTo(wm, aMetrics.GetWritingMode());
nsHTMLReflowState kidReflowState(aPresContext,
aReflowState,
child,
availableSize,
&cbSize);
nsSize size(aReflowState.ComputedWidth(), aReflowState.ComputedHeight());
size.width -= kidReflowState.ComputedPhysicalBorderPadding().LeftRight();
size.height -= kidReflowState.ComputedPhysicalBorderPadding().TopBottom();
kidReflowState.SetComputedWidth(std::max(size.width, 0));
kidReflowState.SetComputedHeight(std::max(size.height, 0));
ReflowChild(child, aPresContext, kidDesiredSize, kidReflowState,
mBorderPadding.left, mBorderPadding.top, 0, aStatus);
FinishReflowChild(child, aPresContext,
kidDesiredSize, &kidReflowState,
mBorderPadding.left, mBorderPadding.top, 0);
}
}
aMetrics.SetOverflowAreasToDesiredBounds();
FinishAndStoreOverflow(&aMetrics);
//.........这里部分代码省略.........
示例15: trackReflowState
void
nsRangeFrame::ReflowAnonymousContent(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState)
{
// The width/height of our content box, which is the available width/height
// for our anonymous content:
nscoord rangeFrameContentBoxWidth = aReflowState.ComputedWidth();
nscoord rangeFrameContentBoxHeight = aReflowState.ComputedHeight();
if (rangeFrameContentBoxHeight == NS_AUTOHEIGHT) {
rangeFrameContentBoxHeight = 0;
}
nsIFrame* trackFrame = mTrackDiv->GetPrimaryFrame();
if (trackFrame) { // display:none?
// Position the track:
// The idea here is that we allow content authors to style the width,
// height, border and padding of the track, but we ignore margin and
// positioning properties and do the positioning ourself to keep the center
// of the track's border box on the center of the nsRangeFrame's content
// box.
nsHTMLReflowState trackReflowState(aPresContext, aReflowState, trackFrame,
nsSize(aReflowState.ComputedWidth(),
NS_UNCONSTRAINEDSIZE));
// Find the x/y position of the track frame such that it will be positioned
// as described above. These coordinates are with respect to the
// nsRangeFrame's border-box.
nscoord trackX = rangeFrameContentBoxWidth / 2;
nscoord trackY = rangeFrameContentBoxHeight / 2;
// Account for the track's border and padding (we ignore its margin):
trackX -= trackReflowState.ComputedPhysicalBorderPadding().left +
trackReflowState.ComputedWidth() / 2;
trackY -= trackReflowState.ComputedPhysicalBorderPadding().top +
trackReflowState.ComputedHeight() / 2;
// Make relative to our border box instead of our content box:
trackX += aReflowState.ComputedPhysicalBorderPadding().left;
trackY += aReflowState.ComputedPhysicalBorderPadding().top;
nsReflowStatus frameStatus;
nsHTMLReflowMetrics trackDesiredSize(aReflowState);
ReflowChild(trackFrame, aPresContext, trackDesiredSize,
trackReflowState, trackX, trackY, 0, frameStatus);
MOZ_ASSERT(NS_FRAME_IS_FULLY_COMPLETE(frameStatus),
"We gave our child unconstrained height, so it should be complete");
FinishReflowChild(trackFrame, aPresContext, trackDesiredSize,
&trackReflowState, trackX, trackY, 0);
}
nsIFrame* thumbFrame = mThumbDiv->GetPrimaryFrame();
if (thumbFrame) { // display:none?
nsHTMLReflowState thumbReflowState(aPresContext, aReflowState, thumbFrame,
nsSize(aReflowState.ComputedWidth(),
NS_UNCONSTRAINEDSIZE));
// Where we position the thumb depends on its size, so we first reflow
// the thumb at {0,0} to obtain its size, then position it afterwards.
nsReflowStatus frameStatus;
nsHTMLReflowMetrics thumbDesiredSize(aReflowState);
ReflowChild(thumbFrame, aPresContext, thumbDesiredSize,
thumbReflowState, 0, 0, 0, frameStatus);
MOZ_ASSERT(NS_FRAME_IS_FULLY_COMPLETE(frameStatus),
"We gave our child unconstrained height, so it should be complete");
FinishReflowChild(thumbFrame, aPresContext, thumbDesiredSize,
&thumbReflowState, 0, 0, 0);
DoUpdateThumbPosition(thumbFrame, nsSize(aDesiredSize.Width(),
aDesiredSize.Height()));
}
nsIFrame* rangeProgressFrame = mProgressDiv->GetPrimaryFrame();
if (rangeProgressFrame) { // display:none?
nsHTMLReflowState progressReflowState(aPresContext, aReflowState,
rangeProgressFrame,
nsSize(aReflowState.ComputedWidth(),
NS_UNCONSTRAINEDSIZE));
// We first reflow the range-progress frame at {0,0} to obtain its
// unadjusted dimensions, then we adjust it to so that the appropriate edge
// ends at the thumb.
nsReflowStatus frameStatus;
nsHTMLReflowMetrics progressDesiredSize(aReflowState);
ReflowChild(rangeProgressFrame, aPresContext,
progressDesiredSize, progressReflowState, 0, 0,
0, frameStatus);
MOZ_ASSERT(NS_FRAME_IS_FULLY_COMPLETE(frameStatus),
"We gave our child unconstrained height, so it should be complete");
FinishReflowChild(rangeProgressFrame, aPresContext,
progressDesiredSize, &progressReflowState, 0, 0, 0);
DoUpdateRangeProgressFrame(rangeProgressFrame, nsSize(aDesiredSize.Width(),
aDesiredSize.Height()));
}
//.........这里部分代码省略.........