зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1079154 patch 5: convert callers of ApplyRelativePosition, ReflowChild and FinishReflowChild in layout/generic to the logical versions, r=jfkthame
This commit is contained in:
Родитель
f632d7bf9b
Коммит
1eacdee679
|
@ -424,20 +424,18 @@ nsBlockReflowContext::PlaceBlock(const nsHTMLReflowState& aReflowState,
|
|||
mMetrics.ISize(mWritingMode), mMetrics.BSize(mWritingMode),
|
||||
mContainerWidth);
|
||||
|
||||
// XXX temporary until other classes are logicalized
|
||||
nsPoint position = LogicalRect(mWritingMode,
|
||||
mICoord, mBCoord,
|
||||
mMetrics.ISize(mWritingMode),
|
||||
mMetrics.BSize(mWritingMode)).
|
||||
GetPhysicalPosition(mWritingMode, mContainerWidth);
|
||||
|
||||
aReflowState.ApplyRelativePositioning(&position);
|
||||
WritingMode frameWM = mFrame->GetWritingMode();
|
||||
LogicalPoint logPos =
|
||||
LogicalPoint(mWritingMode, mICoord, mBCoord).
|
||||
ConvertTo(frameWM, mWritingMode, mContainerWidth - mMetrics.Width());
|
||||
aReflowState.ApplyRelativePositioning(&logPos, mContainerWidth);
|
||||
|
||||
// Now place the frame and complete the reflow process
|
||||
nsContainerFrame::FinishReflowChild(mFrame, mPresContext, mMetrics,
|
||||
&aReflowState, position.x, position.y, 0);
|
||||
&aReflowState, frameWM, logPos,
|
||||
mContainerWidth, 0);
|
||||
|
||||
aOverflowAreas = mMetrics.mOverflowAreas + position;
|
||||
aOverflowAreas = mMetrics.mOverflowAreas + mFrame->GetPosition();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -913,35 +913,27 @@ nsBlockReflowState::FlowAndPlaceFloat(nsIFrame* aFloat)
|
|||
// Calculate the actual origin of the float frame's border rect
|
||||
// relative to the parent block; the margin must be added in
|
||||
// to get the border rect
|
||||
|
||||
//XXX temporary! ApplyRelativePositioning still uses physical margin and point
|
||||
LogicalSize size = aFloat->GetLogicalSize(wm);
|
||||
LogicalMargin margin = aFloat->GetLogicalUsedMargin(wm);
|
||||
size.ISize(wm) += margin.IStartEnd(wm);
|
||||
size.BSize(wm) += margin.BStartEnd(wm);
|
||||
nsPoint physicalPos =
|
||||
LogicalRect(wm, floatPos, size).GetPhysicalPosition(wm, mContainerWidth);
|
||||
nsPoint origin(floatMargin.Left(wm) + physicalPos.x,
|
||||
floatMargin.Top(wm) + physicalPos.y);
|
||||
LogicalPoint origin(wm, floatMargin.IStart(wm) + floatPos.I(wm),
|
||||
floatMargin.BStart(wm) + floatPos.B(wm));
|
||||
|
||||
// If float is relatively positioned, factor that in as well
|
||||
nsHTMLReflowState::ApplyRelativePositioning(aFloat,
|
||||
floatOffsets.GetPhysicalMargin(wm),
|
||||
&origin);
|
||||
nsHTMLReflowState::ApplyRelativePositioning(aFloat, wm, floatOffsets,
|
||||
&origin, mContainerWidth);
|
||||
|
||||
// Position the float and make sure and views are properly
|
||||
// positioned. We need to explicitly position its child views as
|
||||
// well, since we're moving the float after flowing it.
|
||||
bool moved = aFloat->GetPosition() != origin;
|
||||
bool moved = aFloat->GetLogicalPosition(wm, mContainerWidth) != origin;
|
||||
if (moved) {
|
||||
aFloat->SetPosition(origin);
|
||||
aFloat->SetPosition(wm, origin, mContainerWidth);
|
||||
nsContainerFrame::PositionFrameView(aFloat);
|
||||
nsContainerFrame::PositionChildViews(aFloat);
|
||||
}
|
||||
|
||||
// Update the float combined area state
|
||||
// XXX Floats should really just get invalidated here if necessary
|
||||
mFloatOverflowAreas.UnionWith(aFloat->GetOverflowAreas() + origin);
|
||||
mFloatOverflowAreas.UnionWith(aFloat->GetOverflowAreas() +
|
||||
aFloat->GetPosition());
|
||||
|
||||
// Place the float in the float manager
|
||||
// calculate region
|
||||
|
|
|
@ -602,18 +602,22 @@ nsCanvasFrame::Reflow(nsPresContext* aPresContext,
|
|||
kidReflowState.SetVResize(true);
|
||||
}
|
||||
|
||||
nsPoint kidPt(kidReflowState.ComputedPhysicalMargin().left,
|
||||
kidReflowState.ComputedPhysicalMargin().top);
|
||||
WritingMode wm = aReflowState.GetWritingMode();
|
||||
WritingMode kidWM = kidReflowState.GetWritingMode();
|
||||
nscoord containerWidth = aReflowState.ComputedWidth();
|
||||
|
||||
kidReflowState.ApplyRelativePositioning(&kidPt);
|
||||
LogicalMargin margin = kidReflowState.ComputedLogicalMargin();
|
||||
LogicalPoint kidPt(kidWM, margin.IStart(kidWM), margin.BStart(kidWM));
|
||||
|
||||
kidReflowState.ApplyRelativePositioning(&kidPt, containerWidth);
|
||||
|
||||
// Reflow the frame
|
||||
ReflowChild(kidFrame, aPresContext, kidDesiredSize, kidReflowState,
|
||||
kidPt.x, kidPt.y, 0, aStatus);
|
||||
kidWM, kidPt, containerWidth, 0, aStatus);
|
||||
|
||||
// Complete the reflow and position and size the child frame
|
||||
FinishReflowChild(kidFrame, aPresContext, kidDesiredSize, &kidReflowState,
|
||||
kidPt.x, kidPt.y, 0);
|
||||
kidWM, kidPt, containerWidth, 0);
|
||||
|
||||
if (!NS_FRAME_IS_FULLY_COMPLETE(aStatus)) {
|
||||
nsIFrame* nextFrame = kidFrame->GetNextInFlow();
|
||||
|
@ -651,7 +655,6 @@ nsCanvasFrame::Reflow(nsPresContext* aPresContext,
|
|||
// Return our desired size. Normally it's what we're told, but
|
||||
// sometimes we can be given an unconstrained height (when a window
|
||||
// is sizing-to-content), and we should compute our desired height.
|
||||
WritingMode wm = aReflowState.GetWritingMode();
|
||||
LogicalSize finalSize(wm);
|
||||
finalSize.ISize(wm) = aReflowState.ComputedISize();
|
||||
if (aReflowState.ComputedBSize() == NS_UNCONSTRAINEDSIZE) {
|
||||
|
@ -664,7 +667,7 @@ nsCanvasFrame::Reflow(nsPresContext* aPresContext,
|
|||
aDesiredSize.SetSize(wm, finalSize);
|
||||
aDesiredSize.SetOverflowAreasToDesiredBounds();
|
||||
aDesiredSize.mOverflowAreas.UnionWith(
|
||||
kidDesiredSize.mOverflowAreas + kidPt);
|
||||
kidDesiredSize.mOverflowAreas + kidFrame->GetPosition());
|
||||
}
|
||||
|
||||
if (prevCanvasFrame) {
|
||||
|
|
|
@ -359,13 +359,14 @@ nsColumnSetFrame::ReflowColumns(nsHTMLReflowMetrics& aDesiredSize,
|
|||
return feasible;
|
||||
}
|
||||
|
||||
static void MoveChildTo(nsIFrame* aParent, nsIFrame* aChild, nsPoint aOrigin)
|
||||
static void MoveChildTo(nsIFrame* aChild, LogicalPoint aOrigin,
|
||||
WritingMode aWM, nscoord aContainerWidth)
|
||||
{
|
||||
if (aChild->GetPosition() == aOrigin) {
|
||||
if (aChild->GetLogicalPosition(aWM, aContainerWidth) == aOrigin) {
|
||||
return;
|
||||
}
|
||||
|
||||
aChild->SetPosition(aOrigin);
|
||||
aChild->SetPosition(aWM, aOrigin, aContainerWidth);
|
||||
nsContainerFrame::PlaceFrameView(aChild);
|
||||
}
|
||||
|
||||
|
@ -485,22 +486,29 @@ nsColumnSetFrame::ReflowChildren(nsHTMLReflowMetrics& aDesiredSize,
|
|||
nsOverflowAreas overflowRects;
|
||||
|
||||
nsIFrame* child = mFrames.FirstChild();
|
||||
nsMargin physicalBP = borderPadding.GetPhysicalMargin(wm);
|
||||
nsPoint childOrigin(physicalBP.left, physicalBP.top);
|
||||
// For RTL, figure out where the last column's left edge should be. Since the
|
||||
// columns might not fill the frame exactly, we need to account for the
|
||||
// slop. Otherwise we'll waste time moving the columns by some tiny
|
||||
// amount unnecessarily.
|
||||
nscoord& childOriginICoord = isVertical ? childOrigin.y : childOrigin.x;
|
||||
if (isRTL) {
|
||||
LogicalPoint childOrigin(wm, borderPadding.IStart(wm),
|
||||
borderPadding.BStart(wm));
|
||||
// In vertical-rl mode we can't use the computed width as the
|
||||
// container width because it may be NS_UNCONSTRAINEDSIZE, so we use 0
|
||||
// for now and reposition the columns after reflowing them all.
|
||||
nscoord containerWidth = wm.IsVerticalRL() ? 0 : aReflowState.ComputedWidth();
|
||||
|
||||
// For RTL, since the columns might not fill the frame exactly, we
|
||||
// need to account for the slop. Otherwise we'll waste time moving the
|
||||
// columns by some tiny amount
|
||||
|
||||
// XXX when all of layout is converted to logical coordinates, we
|
||||
// probably won't need to do this hack any more. For now, we
|
||||
// confine it to the legacy horizontal-rl case
|
||||
if (!isVertical && isRTL) {
|
||||
nscoord availISize = aReflowState.AvailableISize();
|
||||
if (aReflowState.ComputedISize() != NS_INTRINSICSIZE) {
|
||||
availISize = aReflowState.ComputedISize();
|
||||
}
|
||||
if (availISize != NS_INTRINSICSIZE) {
|
||||
childOriginICoord += availISize - aConfig.mColISize;
|
||||
childOrigin.I(wm) = containerWidth - borderPadding.Left(wm) - availISize;
|
||||
#ifdef DEBUG_roc
|
||||
printf("*** childOrigin.iCoord = %d\n", childOriginICoord);
|
||||
printf("*** childOrigin.iCoord = %d\n", childOrigin.I(wm));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -559,7 +567,7 @@ nsColumnSetFrame::ReflowChildren(nsHTMLReflowMetrics& aDesiredSize,
|
|||
nscoord childContentBEnd = 0;
|
||||
if (!reflowNext && (skipIncremental || skipResizeBSizeShrink)) {
|
||||
// This child does not need to be reflowed, but we may need to move it
|
||||
MoveChildTo(this, child, childOrigin);
|
||||
MoveChildTo(child, childOrigin, wm, containerWidth);
|
||||
|
||||
// If this is the last frame then make sure we get the right status
|
||||
nsIFrame* kidNext = child->GetNextSibling();
|
||||
|
@ -621,13 +629,16 @@ nsColumnSetFrame::ReflowChildren(nsHTMLReflowMetrics& aDesiredSize,
|
|||
// columns would flow around it.
|
||||
|
||||
// Reflow the frame
|
||||
LogicalPoint origin(wm,
|
||||
childOrigin.I(wm) +
|
||||
kidReflowState.ComputedLogicalMargin().IStart(wm),
|
||||
childOrigin.B(wm) +
|
||||
kidReflowState.ComputedLogicalMargin().BStart(wm));
|
||||
ReflowChild(child, PresContext(), kidDesiredSize, kidReflowState,
|
||||
childOrigin.x + kidReflowState.ComputedPhysicalMargin().left,
|
||||
childOrigin.y + kidReflowState.ComputedPhysicalMargin().top,
|
||||
0, aStatus);
|
||||
wm, origin, containerWidth, 0, aStatus);
|
||||
|
||||
reflowNext = (aStatus & NS_FRAME_REFLOW_NEXTINFLOW) != 0;
|
||||
|
||||
|
||||
#ifdef DEBUG_roc
|
||||
printf("*** Reflowed child #%d %p: status = %d, desiredSize=%d,%d CarriedOutBEndMargin=%d\n",
|
||||
columnCount, (void*)child, aStatus, kidDesiredSize.Width(), kidDesiredSize.Height(),
|
||||
|
@ -639,7 +650,7 @@ nsColumnSetFrame::ReflowChildren(nsHTMLReflowMetrics& aDesiredSize,
|
|||
*aCarriedOutBEndMargin = kidDesiredSize.mCarriedOutBEndMargin;
|
||||
|
||||
FinishReflowChild(child, PresContext(), kidDesiredSize,
|
||||
&kidReflowState, childOrigin.x, childOrigin.y, 0);
|
||||
&kidReflowState, wm, childOrigin, containerWidth, 0);
|
||||
|
||||
childContentBEnd = nsLayoutUtils::CalculateContentBEnd(wm, child);
|
||||
if (childContentBEnd > aConfig.mColMaxBSize) {
|
||||
|
@ -732,14 +743,10 @@ nsColumnSetFrame::ReflowChildren(nsHTMLReflowMetrics& aDesiredSize,
|
|||
child = child->GetNextSibling();
|
||||
|
||||
if (child) {
|
||||
if (isRTL) {
|
||||
childOriginICoord -= aConfig.mColISize + aConfig.mColGap;
|
||||
} else {
|
||||
childOriginICoord += aConfig.mColISize + aConfig.mColGap;
|
||||
}
|
||||
childOrigin.I(wm) += aConfig.mColISize + aConfig.mColGap;
|
||||
|
||||
#ifdef DEBUG_roc
|
||||
printf("*** NEXT CHILD ORIGIN.iCoord = %d\n", childOriginICoord);
|
||||
printf("*** NEXT CHILD ORIGIN.icoord = %d\n", childOrigin.I(wm));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -764,21 +771,6 @@ nsColumnSetFrame::ReflowChildren(nsHTMLReflowMetrics& aDesiredSize,
|
|||
contentSize.BSize(wm) = std::max(contentSize.BSize(wm), contentBEnd);
|
||||
mLastFrameStatus = aStatus;
|
||||
|
||||
// In vertical-rl mode, where we want the column "top" (right) edge to be
|
||||
// aligned, we need to adjust the position of any short columns so as to
|
||||
// make them flush-right instead of flush-left within the entire set.
|
||||
if (wm.IsVerticalRL()) {
|
||||
child = mFrames.FirstChild();
|
||||
while (child) {
|
||||
nscoord offset = aColData.mMaxBSize - child->GetRect().width;
|
||||
if (offset) {
|
||||
nsPoint childPos = child->GetPosition();
|
||||
child->SetPosition(childPos + nsPoint(offset, 0));
|
||||
}
|
||||
child = child->GetNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
// Apply computed and min/max values
|
||||
if (aConfig.mComputedBSize != NS_INTRINSICSIZE) {
|
||||
if (aReflowState.AvailableBSize() != NS_INTRINSICSIZE) {
|
||||
|
@ -810,6 +802,20 @@ nsColumnSetFrame::ReflowChildren(nsHTMLReflowMetrics& aDesiredSize,
|
|||
aDesiredSize.mOverflowAreas = overflowRects;
|
||||
aDesiredSize.UnionOverflowAreasWithDesiredBounds();
|
||||
|
||||
// In vertical-rl mode, make a second pass to reposition the columns
|
||||
// with the correct container width
|
||||
if (wm.IsVerticalRL()) {
|
||||
child = mFrames.FirstChild();
|
||||
while (child) {
|
||||
// Get the logical position as set before with containerWidth=0
|
||||
// and reset with the correct container width (which is the block
|
||||
// size in vertical modes).
|
||||
child->SetPosition(wm, child->GetLogicalPosition(wm, 0),
|
||||
contentSize.BSize(wm));
|
||||
child = child->GetNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_roc
|
||||
printf("*** DONE PASS feasible=%d\n", allFit && NS_FRAME_IS_FULLY_COMPLETE(aStatus)
|
||||
&& !NS_FRAME_IS_TRUNCATED(aStatus));
|
||||
|
|
|
@ -1243,11 +1243,12 @@ nsContainerFrame::ReflowOverflowContainerChildren(nsPresContext* aPres
|
|||
"overflow container frame must have a prev-in-flow");
|
||||
NS_ASSERTION(frame->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER,
|
||||
"overflow container frame must have overflow container bit set");
|
||||
nsRect prevRect = prevInFlow->GetRect();
|
||||
WritingMode wm = frame->GetWritingMode();
|
||||
nscoord containerWidth = aReflowState.AvailableSize(wm).Width(wm);
|
||||
LogicalRect prevRect = prevInFlow->GetLogicalRect(wm, containerWidth);
|
||||
|
||||
// Initialize reflow params
|
||||
WritingMode wm = frame->GetWritingMode();
|
||||
LogicalSize availSpace(wm, LogicalSize(wm, prevRect.Size()).ISize(wm),
|
||||
LogicalSize availSpace(wm, prevRect.ISize(wm),
|
||||
aReflowState.AvailableSize(wm).BSize(wm));
|
||||
nsHTMLReflowMetrics desiredSize(aReflowState);
|
||||
nsHTMLReflowState frameState(aPresContext, aReflowState,
|
||||
|
@ -1255,12 +1256,13 @@ nsContainerFrame::ReflowOverflowContainerChildren(nsPresContext* aPres
|
|||
nsReflowStatus frameStatus;
|
||||
|
||||
// Reflow
|
||||
LogicalPoint pos(wm, prevRect.IStart(wm), 0);
|
||||
ReflowChild(frame, aPresContext, desiredSize, frameState,
|
||||
prevRect.x, 0, aFlags, frameStatus, &tracker);
|
||||
wm, pos, containerWidth, aFlags, frameStatus, &tracker);
|
||||
//XXXfr Do we need to override any shrinkwrap effects here?
|
||||
// e.g. desiredSize.Width() = prevRect.width;
|
||||
FinishReflowChild(frame, aPresContext, desiredSize, &frameState,
|
||||
prevRect.x, 0, aFlags);
|
||||
wm, pos, containerWidth, aFlags);
|
||||
|
||||
// Handle continuations
|
||||
if (!NS_FRAME_IS_FULLY_COMPLETE(frameStatus)) {
|
||||
|
|
|
@ -503,8 +503,11 @@ nsHTMLScrollFrame::ReflowScrolledFrame(ScrollReflowState* aState,
|
|||
mHelper.mHasVerticalScrollbar = aAssumeVScroll;
|
||||
|
||||
nsReflowStatus status;
|
||||
// No need to pass a container-width to ReflowChild or
|
||||
// FinishReflowChild, because it's only used there when positioning
|
||||
// the frame (i.e. if NS_FRAME_NO_MOVE_FRAME isn't set)
|
||||
ReflowChild(mHelper.mScrolledFrame, presContext, *aMetrics,
|
||||
kidReflowState, 0, 0,
|
||||
kidReflowState, wm, LogicalPoint(wm), 0,
|
||||
NS_FRAME_NO_MOVE_FRAME, status);
|
||||
|
||||
mHelper.mHasHorizontalScrollbar = didHaveHorizontalScrollbar;
|
||||
|
@ -516,7 +519,7 @@ nsHTMLScrollFrame::ReflowScrolledFrame(ScrollReflowState* aState,
|
|||
// which will usually be different from the scrollport height;
|
||||
// invalidating the difference will cause unnecessary repainting.
|
||||
FinishReflowChild(mHelper.mScrolledFrame, presContext,
|
||||
*aMetrics, &kidReflowState, 0, 0,
|
||||
*aMetrics, &kidReflowState, wm, LogicalPoint(wm), 0,
|
||||
NS_FRAME_NO_MOVE_FRAME | NS_FRAME_NO_SIZE_VIEW);
|
||||
|
||||
// XXX Some frames (e.g., nsPluginFrame, nsFrameFrame, nsTextFrame) don't bother
|
||||
|
|
|
@ -3033,19 +3033,17 @@ nsLineLayout::RelativePositionFrames(PerSpanData* psd, nsOverflowAreas& aOverflo
|
|||
|
||||
for (PerFrameData* pfd = psd->mFirstFrame; pfd; pfd = pfd->mNext) {
|
||||
nsIFrame* frame = pfd->mFrame;
|
||||
nsPoint origin = frame->GetPosition();
|
||||
|
||||
// Adjust the origin of the frame
|
||||
if (pfd->mRelativePos) {
|
||||
//XXX temporary until ApplyRelativePositioning can handle logical offsets
|
||||
nsMargin physicalOffsets =
|
||||
pfd->mOffsets.GetPhysicalMargin(pfd->mFrame->GetWritingMode());
|
||||
WritingMode frameWM = frame->GetWritingMode();
|
||||
LogicalPoint origin = frame->GetLogicalPosition(mContainerWidth);
|
||||
// right and bottom are handled by
|
||||
// nsHTMLReflowState::ComputeRelativeOffsets
|
||||
nsHTMLReflowState::ApplyRelativePositioning(pfd->mFrame,
|
||||
physicalOffsets,
|
||||
&origin);
|
||||
frame->SetPosition(origin);
|
||||
nsHTMLReflowState::ApplyRelativePositioning(frame, frameWM,
|
||||
pfd->mOffsets, &origin,
|
||||
mContainerWidth);
|
||||
frame->SetPosition(frameWM, origin, mContainerWidth);
|
||||
}
|
||||
|
||||
// We must position the view correctly before positioning its
|
||||
|
@ -3099,7 +3097,7 @@ nsLineLayout::RelativePositionFrames(PerSpanData* psd, nsOverflowAreas& aOverflo
|
|||
r.VisualOverflow(),
|
||||
NS_FRAME_NO_MOVE_VIEW);
|
||||
|
||||
overflowAreas.UnionWith(r + origin);
|
||||
overflowAreas.UnionWith(r + frame->GetPosition());
|
||||
}
|
||||
|
||||
// If we just computed a spans combined area, we need to update its
|
||||
|
|
Загрузка…
Ссылка в новой задаче