Files
mozilla45esr/layout/generic/nsAbsoluteContainingBlock.cpp
T
roytam1 ac0651448a import changes from tenfourfox: https://github.com/classilla/tenfourfox/compare/966d8cab820858bcda2fa8e945ed14b66d9e83f9...e7767cdaa56ee060b14702ed64ae594958fcb1dd
- issue #385: unconditionally disable JS source compression (6a91f9666)
- #359: security.pki.sha1_enforcement_level -> 1 (966d8cab8)
- for #375: M1349940 M1355595 M1334635 M1353708 M1354782 M1354781 M1349742 M1345315 M1356655 M1356663 M1357638 M1358809 M1307134 M1331342 M1220466 (964aa7e7c)
- #378: ensure remaining users of faulty LZ4 module never execute (922a32738)
- #387: pulled nsGenConList.* with relevant deps up to mozilla-central (b1831fc75)
- prerequisite for #375: M1347759 (8e58b5c8f)
- #375: M1348278 (8d665811d)
- #368: pref on Brotli (7da09aa4e)
- #375: M1330912 (sync patch only) (bea84e507)
- #375: M1342719 M1342720 (f4015e0c1)
- Bug 1071646 - Light refactoring of lexical binding helpers in Parser. (r=jorendorff) (167ad8564)
- Bug 1071646 - Make functions block-scoped in JS and implement Annex B semantics for compatibility. (r=jorendorff) (25844de1b)
- Bug 1071646 - Support labelled function declarations in sloppy mode per Annex B.3.2. (r=jorendorff) (37bf861a9)
- Bug 1071646 - Introduce JSOP_BINDVAR to support Annex B.3.3.3. (r=jorendorff) (884bd2ab5)
- Bug 1071646 - Cast ParseNode to Definition using as<T>. (r=jorendorff) (feba46e3f)
- Bug 1071646 - Support JSOP_BINDVAR in Baseline. (r=jandem) (92b6a3b48)
- #372: merge changeset 299512 (c28302281)
- Bug 1071646 - Support JSOP_BINDVAR in Ion. (r=jandem) (d05f77998)
- Bug 1231758 - Fix bogus assertion in BCE for Annex B function assignment. (r=jorendorff) (a11dcf0cc)
- Bug 1234717 - Fix upvar TDZ for block-scoped functions. (r=jorendorff) (2ec542b5a)
- Bug 1071646 - Forgot to commit tests on backout and relanding cycle. (r=me) (069a26bf9)
- #372: merge changeset 303861 (745f7e7a2)
- Bug 1235590 - Allow redeclaring block-scoped functions and warn about deprecation for now. (r=jorendorff) (8a51cc1f9)
- Bug 1243793 - Fix handling of labels when emitting hoisted function definitions. (r=jorendorff) (c0ffd70f9)
- Bug 1236875 - Fix BytecodeEmitter::atBodyLevel() for modules r=efaust (5b2c22f62)
- Bug 1304641 - TraceLogger: Also throw compartment mismatch error when running in the jits, r=bbouvier (717134569)
- Bug 1198833 - Variable redeclaration should be a syntax error r=shu (ac6710b0f)
- #393, Bug 1135377 - Part 1: Implement RegExp unicode flag. r=till, f=anba (d00063089)
- #393, Bug 1135377 - Part 2: Parse RegExp unicode character in non-CharacterClass. r=till, f=anba (c85a176bd)
- #393, Bug 1135377 - Part 3: Parse RegExp unicode character in CharacterClass. r=till, f=anba (68f44ec41)
- #393, Bug 1135377 - Part 4: Support everything Atom in RegExp with unicode flag. r=till, f=anba (4e924a688)
- #393, Bug 1135377 - Part 5: Support CharacterClassEscape in RegExp with unicode flag. r=till, f=anba (45a4712b0)
- #393, Bug 1135377 - Part 6: Support ignoreCase for BMP in RegExp with unicode flag. r=till, f=anba (cf744e9d3)
- #393, Bug 1135377 - Part 7: Support ignoreCase for non-BMP in RegExp with unicode flag. r=till, f=anba (f31a9f9e8)
- #393, Bug 1135377 - Part 8: Disallow extended pattern in RegExp with unicode flag. r=till, f=anba (c05db4075)
- #393, Bug 1135377 - Part 9: Use RegExp unicode flag in String.prototype.{match,replace,split}. r=till, f=anba (8636a96b7)
- #393, Bug 1135377 - Part 10: Decrement index when it points trail surrogate that has corresponding lead surrogate. r=till, f=anba (522d06ab3)
- #393, Bug 1135377 - Part 11: Support back reference with unicode flag. r=till, f=anba (122e41a28)
- #393, Bug 1279467 - Fix null handling in RegExp character class with unicode flag. r=till (741f170e6)
- #393: bustage fix (3e39760c8)
- #393, Bug 1281739 - Do not match K, S, k, s, KELVIN SIGN, LATIN SMALL LETTER LONG S with \W in unicode ignoreCase RegExp. r=till (3c5d4bab8)
- #375: M1233101 (a6a0b895f)
- #375, #391: branch hint malloc and recursion checks, clean up MAsm type barrier spooge (a008a1978)
- closes #380: fix toSource() tests (f9de6783b)
- #394: fix and enable ES7 exponentiation operator (6dc5f54dc)
- #396: M1342009, plus refactor to PLDHashTable a la M1352888 (06fcc091f)
- #375: M1347634 1352235 (aa6b13c59)
- #375: M1351303 (f7badd24e)
- #375: M1287277 M1259677; temporarily disable M1351303 due to crashes (75d95f15b)
- #375: M1363423 M1273828 M1364661 (e7767cdaa)
2018-05-31 14:43:16 +08:00

538 lines
21 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* code for managing absolutely positioned children of a rendering
* object that is a containing block for them
*/
#include "nsAbsoluteContainingBlock.h"
#include "nsContainerFrame.h"
#include "nsGkAtoms.h"
#include "nsIPresShell.h"
#include "nsHTMLReflowState.h"
#include "nsPresContext.h"
#include "nsCSSFrameConstructor.h"
#include "nsGridContainerFrame.h"
#include "mozilla/Snprintf.h"
#ifdef DEBUG
#include "nsBlockFrame.h"
static void PrettyUC(nscoord aSize, char* aBuf, int aBufSize)
{
if (NS_UNCONSTRAINEDSIZE == aSize) {
strcpy(aBuf, "UC");
} else {
if((int32_t)0xdeadbeef == aSize) {
strcpy(aBuf, "deadbeef");
} else {
snprintf(aBuf, aBufSize, "%d", aSize);
}
}
}
#endif
using namespace mozilla;
void
nsAbsoluteContainingBlock::SetInitialChildList(nsIFrame* aDelegatingFrame,
ChildListID aListID,
nsFrameList& aChildList)
{
NS_PRECONDITION(mChildListID == aListID, "unexpected child list name");
#ifdef DEBUG
nsFrame::VerifyDirtyBitSet(aChildList);
#endif
mAbsoluteFrames.SetFrames(aChildList);
}
void
nsAbsoluteContainingBlock::AppendFrames(nsIFrame* aDelegatingFrame,
ChildListID aListID,
nsFrameList& aFrameList)
{
NS_ASSERTION(mChildListID == aListID, "unexpected child list");
// Append the frames to our list of absolutely positioned frames
#ifdef DEBUG
nsFrame::VerifyDirtyBitSet(aFrameList);
#endif
mAbsoluteFrames.AppendFrames(nullptr, aFrameList);
// no damage to intrinsic widths, since absolutely positioned frames can't
// change them
aDelegatingFrame->PresContext()->PresShell()->
FrameNeedsReflow(aDelegatingFrame, nsIPresShell::eResize,
NS_FRAME_HAS_DIRTY_CHILDREN);
}
void
nsAbsoluteContainingBlock::InsertFrames(nsIFrame* aDelegatingFrame,
ChildListID aListID,
nsIFrame* aPrevFrame,
nsFrameList& aFrameList)
{
NS_ASSERTION(mChildListID == aListID, "unexpected child list");
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == aDelegatingFrame,
"inserting after sibling frame with different parent");
#ifdef DEBUG
nsFrame::VerifyDirtyBitSet(aFrameList);
#endif
mAbsoluteFrames.InsertFrames(nullptr, aPrevFrame, aFrameList);
// no damage to intrinsic widths, since absolutely positioned frames can't
// change them
aDelegatingFrame->PresContext()->PresShell()->
FrameNeedsReflow(aDelegatingFrame, nsIPresShell::eResize,
NS_FRAME_HAS_DIRTY_CHILDREN);
}
void
nsAbsoluteContainingBlock::RemoveFrame(nsIFrame* aDelegatingFrame,
ChildListID aListID,
nsIFrame* aOldFrame)
{
NS_ASSERTION(mChildListID == aListID, "unexpected child list");
nsIFrame* nif = aOldFrame->GetNextInFlow();
if (nif) {
nif->GetParent()->DeleteNextInFlowChild(nif, false);
}
mAbsoluteFrames.DestroyFrame(aOldFrame);
}
void
nsAbsoluteContainingBlock::Reflow(nsContainerFrame* aDelegatingFrame,
nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aReflowStatus,
const nsRect& aContainingBlock,
bool aConstrainHeight,
bool aCBWidthChanged,
bool aCBHeightChanged,
nsOverflowAreas* aOverflowAreas)
{
nsReflowStatus reflowStatus = NS_FRAME_COMPLETE;
bool reflowAll = aReflowState.ShouldReflowAllKids();
// The 'width' check below is an optimization to avoid the virtual GetType()
// call in most cases. 'aContainingBlock' isn't used for grid items,
// each item has its own CB on a frame property instead.
// @see nsGridContainerFrame::ReflowChildren
const bool isGrid =
aContainingBlock.width == nsGridContainerFrame::VERY_LIKELY_A_GRID_CONTAINER &&
aDelegatingFrame->GetType() == nsGkAtoms::gridContainerFrame;
nsIFrame* kidFrame;
nsOverflowContinuationTracker tracker(aDelegatingFrame, true);
for (kidFrame = mAbsoluteFrames.FirstChild(); kidFrame; kidFrame = kidFrame->GetNextSibling()) {
bool kidNeedsReflow = reflowAll || NS_SUBTREE_DIRTY(kidFrame) ||
FrameDependsOnContainer(kidFrame, aCBWidthChanged, aCBHeightChanged);
if (kidNeedsReflow && !aPresContext->HasPendingInterrupt()) {
// Reflow the frame
nsReflowStatus kidStatus = NS_FRAME_COMPLETE;
const nsRect& cb = isGrid ? nsGridContainerFrame::GridItemCB(kidFrame)
: aContainingBlock;
ReflowAbsoluteFrame(aDelegatingFrame, aPresContext, aReflowState, cb,
aConstrainHeight, kidFrame, kidStatus,
aOverflowAreas);
nsIFrame* nextFrame = kidFrame->GetNextInFlow();
if (!NS_FRAME_IS_FULLY_COMPLETE(kidStatus) &&
aDelegatingFrame->IsFrameOfType(nsIFrame::eCanContainOverflowContainers)) {
// Need a continuation
if (!nextFrame) {
nextFrame =
aPresContext->PresShell()->FrameConstructor()->
CreateContinuingFrame(aPresContext, kidFrame, aDelegatingFrame);
}
// Add it as an overflow container.
//XXXfr This is a hack to fix some of our printing dataloss.
// See bug 154892. Not sure how to do it "right" yet; probably want
// to keep continuations within an nsAbsoluteContainingBlock eventually.
tracker.Insert(nextFrame, kidStatus);
NS_MergeReflowStatusInto(&reflowStatus, kidStatus);
}
else {
// Delete any continuations
if (nextFrame) {
nsOverflowContinuationTracker::AutoFinish fini(&tracker, kidFrame);
nextFrame->GetParent()->DeleteNextInFlowChild(nextFrame, true);
}
}
}
else {
tracker.Skip(kidFrame, reflowStatus);
if (aOverflowAreas) {
aDelegatingFrame->ConsiderChildOverflow(*aOverflowAreas, kidFrame);
}
}
// Make a CheckForInterrupt call, here, not just HasPendingInterrupt. That
// will make sure that we end up reflowing aDelegatingFrame in cases when
// one of our kids interrupted. Otherwise we'd set the dirty or
// dirty-children bit on the kid in the condition below, and then when
// reflow completes and we go to mark dirty bits on all ancestors of that
// kid we'll immediately bail out, because the kid already has a dirty bit.
// In particular, we won't set any dirty bits on aDelegatingFrame, so when
// the following reflow happens we won't reflow the kid in question. This
// might be slightly suboptimal in cases where |kidFrame| itself did not
// interrupt, since we'll trigger a reflow of it too when it's not strictly
// needed. But the logic to not do that is enough more complicated, and
// the case enough of an edge case, that this is probably better.
if (kidNeedsReflow && aPresContext->CheckForInterrupt(aDelegatingFrame)) {
if (aDelegatingFrame->GetStateBits() & NS_FRAME_IS_DIRTY) {
kidFrame->AddStateBits(NS_FRAME_IS_DIRTY);
} else {
kidFrame->AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN);
}
}
}
// Abspos frames can't cause their parent to be incomplete,
// only overflow incomplete.
if (NS_FRAME_IS_NOT_COMPLETE(reflowStatus))
NS_FRAME_SET_OVERFLOW_INCOMPLETE(reflowStatus);
NS_MergeReflowStatusInto(&aReflowStatus, reflowStatus);
}
static inline bool IsFixedPaddingSize(const nsStyleCoord& aCoord)
{ return aCoord.ConvertsToLength(); }
static inline bool IsFixedMarginSize(const nsStyleCoord& aCoord)
{ return aCoord.ConvertsToLength(); }
static inline bool IsFixedOffset(const nsStyleCoord& aCoord)
{ return aCoord.ConvertsToLength(); }
bool
nsAbsoluteContainingBlock::FrameDependsOnContainer(nsIFrame* f,
bool aCBWidthChanged,
bool aCBHeightChanged)
{
const nsStylePosition* pos = f->StylePosition();
// See if f's position might have changed because it depends on a
// placeholder's position
// This can happen in the following cases:
// 1) Vertical positioning. "top" must be auto and "bottom" must be auto
// (otherwise the vertical position is completely determined by
// whichever of them is not auto and the height).
// 2) Horizontal positioning. "left" must be auto and "right" must be auto
// (otherwise the horizontal position is completely determined by
// whichever of them is not auto and the width).
// See nsHTMLReflowState::InitAbsoluteConstraints -- these are the
// only cases when we call CalculateHypotheticalBox().
if ((pos->mOffset.GetTopUnit() == eStyleUnit_Auto &&
pos->mOffset.GetBottomUnit() == eStyleUnit_Auto) ||
(pos->mOffset.GetLeftUnit() == eStyleUnit_Auto &&
pos->mOffset.GetRightUnit() == eStyleUnit_Auto)) {
return true;
}
if (!aCBWidthChanged && !aCBHeightChanged) {
// skip getting style data
return false;
}
const nsStylePadding* padding = f->StylePadding();
const nsStyleMargin* margin = f->StyleMargin();
WritingMode wm = f->GetWritingMode();
if (wm.IsVertical() ? aCBHeightChanged : aCBWidthChanged) {
// See if f's inline-size might have changed.
// If margin-inline-start/end, padding-inline-start/end,
// inline-size, min/max-inline-size are all lengths, 'none', or enumerated,
// then our frame isize does not depend on the parent isize.
// Note that borders never depend on the parent isize.
// XXX All of the enumerated values except -moz-available are ok too.
if (pos->ISizeDependsOnContainer(wm) ||
pos->MinISizeDependsOnContainer(wm) ||
pos->MaxISizeDependsOnContainer(wm) ||
!IsFixedPaddingSize(padding->mPadding.GetIStart(wm)) ||
!IsFixedPaddingSize(padding->mPadding.GetIEnd(wm))) {
return true;
}
// See if f's position might have changed. If we're RTL then the
// rules are slightly different. We'll assume percentage or auto
// margins will always induce a dependency on the size
if (!IsFixedMarginSize(margin->mMargin.GetIStart(wm)) ||
!IsFixedMarginSize(margin->mMargin.GetIEnd(wm))) {
return true;
}
}
if (wm.IsVertical() ? aCBWidthChanged : aCBHeightChanged) {
// See if f's block-size might have changed.
// If margin-block-start/end, padding-block-start/end,
// min-block-size, and max-block-size are all lengths or 'none',
// and bsize is a length or bsize and bend are auto and bstart is not auto,
// then our frame bsize does not depend on the parent bsize.
// Note that borders never depend on the parent bsize.
if ((pos->BSizeDependsOnContainer(wm) &&
!(pos->BSize(wm).GetUnit() == eStyleUnit_Auto &&
pos->mOffset.GetBEndUnit(wm) == eStyleUnit_Auto &&
pos->mOffset.GetBStartUnit(wm) != eStyleUnit_Auto)) ||
pos->MinBSizeDependsOnContainer(wm) ||
pos->MaxBSizeDependsOnContainer(wm) ||
!IsFixedPaddingSize(padding->mPadding.GetBStart(wm)) ||
!IsFixedPaddingSize(padding->mPadding.GetBEnd(wm))) {
return true;
}
// See if f's position might have changed.
if (!IsFixedMarginSize(margin->mMargin.GetBStart(wm)) ||
!IsFixedMarginSize(margin->mMargin.GetBEnd(wm))) {
return true;
}
}
// Since we store coordinates relative to top and left, the position
// of a frame depends on that of its container if it is fixed relative
// to the right or bottom, or if it is positioned using percentages
// relative to the left or top. Because of the dependency on the
// sides (left and top) that we use to store coordinates, these tests
// are easier to do using physical coordinates rather than logical.
if (aCBWidthChanged) {
if (!IsFixedOffset(pos->mOffset.GetLeft())) {
return true;
}
// Note that even if 'left' is a length, our position can still
// depend on the containing block width, because if our direction or
// writing-mode moves from right to left (in either block or inline
// progression) and 'right' is not 'auto', we will discard 'left'
// and be positioned relative to the containing block right edge.
// 'left' length and 'right' auto is the only combination we can be
// sure of.
if ((wm.GetInlineDir() == WritingMode::eInlineRTL ||
wm.GetBlockDir() == WritingMode::eBlockRL) &&
pos->mOffset.GetRightUnit() != eStyleUnit_Auto) {
return true;
}
}
if (aCBHeightChanged) {
if (!IsFixedOffset(pos->mOffset.GetTop())) {
return true;
}
// See comment above for width changes.
if (wm.GetInlineDir() == WritingMode::eInlineBTT &&
pos->mOffset.GetBottomUnit() != eStyleUnit_Auto) {
return true;
}
}
return false;
}
void
nsAbsoluteContainingBlock::DestroyFrames(nsIFrame* aDelegatingFrame,
nsIFrame* aDestructRoot)
{
mAbsoluteFrames.DestroyFramesFrom(aDestructRoot);
}
void
nsAbsoluteContainingBlock::MarkSizeDependentFramesDirty()
{
DoMarkFramesDirty(false);
}
void
nsAbsoluteContainingBlock::MarkAllFramesDirty()
{
DoMarkFramesDirty(true);
}
void
nsAbsoluteContainingBlock::DoMarkFramesDirty(bool aMarkAllDirty)
{
for (nsIFrame* kidFrame : mAbsoluteFrames) {
if (aMarkAllDirty) {
kidFrame->AddStateBits(NS_FRAME_IS_DIRTY);
} else if (FrameDependsOnContainer(kidFrame, true, true)) {
// Add the weakest flags that will make sure we reflow this frame later
kidFrame->AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN);
}
}
}
// XXX Optimize the case where it's a resize reflow and the absolutely
// positioned child has the exact same size and position and skip the
// reflow...
// When bug 154892 is checked in, make sure that when
// mChildListID == kFixedList, the height is unconstrained.
// since we don't allow replicated frames to split.
void
nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegatingFrame,
nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
const nsRect& aContainingBlock,
bool aConstrainBSize,
nsIFrame* aKidFrame,
nsReflowStatus& aStatus,
nsOverflowAreas* aOverflowAreas)
{
#ifdef DEBUG
if (nsBlockFrame::gNoisyReflow) {
nsFrame::IndentBy(stdout,nsBlockFrame::gNoiseIndent);
printf("abs pos ");
if (aKidFrame) {
nsAutoString name;
aKidFrame->GetFrameName(name);
printf("%s ", NS_LossyConvertUTF16toASCII(name).get());
}
char width[16];
char height[16];
PrettyUC(aReflowState.AvailableWidth(), width, 16);
PrettyUC(aReflowState.AvailableHeight(), height, 16);
printf(" a=%s,%s ", width, height);
PrettyUC(aReflowState.ComputedWidth(), width, 16);
PrettyUC(aReflowState.ComputedHeight(), height, 16);
printf("c=%s,%s \n", width, height);
}
AutoNoisyIndenter indent(nsBlockFrame::gNoisy);
#endif // DEBUG
WritingMode wm = aKidFrame->GetWritingMode();
LogicalSize logicalCBSize(wm, aContainingBlock.Size());
nscoord availISize = logicalCBSize.ISize(wm);
if (availISize == -1) {
NS_ASSERTION(aReflowState.ComputedSize(wm).ISize(wm) !=
NS_UNCONSTRAINEDSIZE,
"Must have a useful inline-size _somewhere_");
availISize =
aReflowState.ComputedSizeWithPadding(wm).ISize(wm);
}
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, aKidFrame,
LogicalSize(wm, availISize,
NS_UNCONSTRAINEDSIZE),
&logicalCBSize);
// Get the border values
WritingMode outerWM = aReflowState.GetWritingMode();
const LogicalMargin border(outerWM,
aReflowState.mStyleBorder->GetComputedBorder());
const LogicalMargin margin =
kidReflowState.ComputedLogicalMargin().ConvertTo(outerWM, wm);
bool constrainBSize = (aReflowState.AvailableBSize() != NS_UNCONSTRAINEDSIZE)
&& aConstrainBSize
// Don't split if told not to (e.g. for fixed frames)
&& (aDelegatingFrame->GetType() != nsGkAtoms::inlineFrame)
//XXX we don't handle splitting frames for inline absolute containing blocks yet
&& (aKidFrame->GetLogicalRect(aContainingBlock.Size()).BStart(wm) <=
aReflowState.AvailableBSize());
// Don't split things below the fold. (Ideally we shouldn't *have*
// anything totally below the fold, but we can't position frames
// across next-in-flow breaks yet.
if (constrainBSize) {
kidReflowState.AvailableBSize() =
aReflowState.AvailableBSize() - border.ConvertTo(wm, outerWM).BStart(wm) -
kidReflowState.ComputedLogicalMargin().BStart(wm);
if (NS_AUTOOFFSET != kidReflowState.ComputedLogicalOffsets().BStart(wm)) {
kidReflowState.AvailableBSize() -=
kidReflowState.ComputedLogicalOffsets().BStart(wm);
}
}
// Do the reflow
nsHTMLReflowMetrics kidDesiredSize(kidReflowState);
aKidFrame->Reflow(aPresContext, kidDesiredSize, kidReflowState, aStatus);
const LogicalSize kidSize = kidDesiredSize.Size(wm).ConvertTo(outerWM, wm);
LogicalMargin offsets =
kidReflowState.ComputedLogicalOffsets().ConvertTo(outerWM, wm);
// If we're solving for start in either inline or block direction,
// then compute it now that we know the dimensions.
if ((NS_AUTOOFFSET == offsets.IStart(outerWM)) ||
(NS_AUTOOFFSET == offsets.BStart(outerWM))) {
if (-1 == logicalCBSize.ISize(wm)) {
// Get the containing block width/height
logicalCBSize =
kidReflowState.ComputeContainingBlockRectangle(aPresContext,
&aReflowState);
}
if (NS_AUTOOFFSET == offsets.IStart(outerWM)) {
NS_ASSERTION(NS_AUTOOFFSET != offsets.IEnd(outerWM),
"Can't solve for both start and end");
offsets.IStart(outerWM) =
logicalCBSize.ConvertTo(outerWM, wm).ISize(outerWM) -
offsets.IEnd(outerWM) - margin.IStartEnd(outerWM) -
kidSize.ISize(outerWM);
}
if (NS_AUTOOFFSET == offsets.BStart(outerWM)) {
offsets.BStart(outerWM) =
logicalCBSize.ConvertTo(outerWM, wm).BSize(outerWM) -
offsets.BEnd(outerWM) - margin.BStartEnd(outerWM) -
kidSize.BSize(outerWM);
}
kidReflowState.SetComputedLogicalOffsets(offsets.ConvertTo(wm, outerWM));
}
// Position the child relative to our padding edge
LogicalRect rect(outerWM,
border.IStart(outerWM) + offsets.IStart(outerWM) +
margin.IStart(outerWM),
border.BStart(outerWM) + offsets.BStart(outerWM) +
margin.BStart(outerWM),
kidSize.ISize(outerWM), kidSize.BSize(outerWM));
nsRect r =
rect.GetPhysicalRect(outerWM, logicalCBSize.GetPhysicalSize(wm) +
border.Size(outerWM).GetPhysicalSize(outerWM));
// Offset the frame rect by the given origin of the absolute containing block.
// If the frame is auto-positioned on both sides of an axis, it will be
// positioned based on its containing block and we don't need to offset.
if (aContainingBlock.TopLeft() != nsPoint(0, 0)) {
const nsStyleSides& offsets = kidReflowState.mStylePosition->mOffset;
if (!(offsets.GetLeftUnit() == eStyleUnit_Auto &&
offsets.GetRightUnit() == eStyleUnit_Auto)) {
r.x += aContainingBlock.x;
}
if (!(offsets.GetTopUnit() == eStyleUnit_Auto &&
offsets.GetBottomUnit() == eStyleUnit_Auto)) {
r.y += aContainingBlock.y;
}
}
aKidFrame->SetRect(r);
nsView* view = aKidFrame->GetView();
if (view) {
// Size and position the view and set its opacity, visibility, content
// transparency, and clip
nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, aKidFrame, view,
kidDesiredSize.VisualOverflow());
} else {
nsContainerFrame::PositionChildViews(aKidFrame);
}
aKidFrame->DidReflow(aPresContext, &kidReflowState,
nsDidReflowStatus::FINISHED);
#ifdef DEBUG
if (nsBlockFrame::gNoisyReflow) {
nsFrame::IndentBy(stdout,nsBlockFrame::gNoiseIndent - 1);
printf("abs pos ");
if (aKidFrame) {
nsAutoString name;
aKidFrame->GetFrameName(name);
printf("%s ", NS_LossyConvertUTF16toASCII(name).get());
}
printf("%p rect=%d,%d,%d,%d\n", static_cast<void*>(aKidFrame),
r.x, r.y, r.width, r.height);
}
#endif
if (aOverflowAreas) {
aOverflowAreas->UnionWith(kidDesiredSize.mOverflowAreas + r.TopLeft());
}
}