diff --git a/editor/libeditor/tests/browserscope/lib/richtext2/currentStatus.js b/editor/libeditor/tests/browserscope/lib/richtext2/currentStatus.js index ea5216eed1..d1ff51a8ea 100644 --- a/editor/libeditor/tests/browserscope/lib/richtext2/currentStatus.js +++ b/editor/libeditor/tests/browserscope/lib/richtext2/currentStatus.js @@ -531,15 +531,9 @@ const knownFailures = { "S-Proposed-SM:e.f.w_TEXT-1_SIR-3-dM": true, "S-Proposed-SM:e.f.w_TEXT-1_SIR-3-body": true, "S-Proposed-SM:e.f.w_TEXT-1_SIR-3-div": true, - "S-Proposed-SM:e.f.lb_BR.BR-1_SC-1-dM": true, - "S-Proposed-SM:e.f.lb_BR.BR-1_SC-1-body": true, - "S-Proposed-SM:e.f.lb_BR.BR-1_SC-1-div": true, "S-Proposed-SM:e.f.lb_BR.BR-1_SI-1-dM": true, "S-Proposed-SM:e.f.lb_BR.BR-1_SI-1-body": true, "S-Proposed-SM:e.f.lb_BR.BR-1_SI-1-div": true, - "S-Proposed-SM:e.f.lb_BR.BR-1_SM-1-dM": true, - "S-Proposed-SM:e.f.lb_BR.BR-1_SM-1-body": true, - "S-Proposed-SM:e.f.lb_BR.BR-1_SM-1-div": true, "S-Proposed-SM:e.f.lb_P.P.P-1_SI-1-dM": true, "S-Proposed-SM:e.f.lb_P.P.P-1_SI-1-body": true, "S-Proposed-SM:e.f.lb_P.P.P-1_SI-1-div": true, diff --git a/editor/libeditor/tests/test_selection_move_commands.xul b/editor/libeditor/tests/test_selection_move_commands.xul index 7398920542..000861db7b 100644 --- a/editor/libeditor/tests/test_selection_move_commands.xul +++ b/editor/libeditor/tests/test_selection_move_commands.xul @@ -171,9 +171,9 @@ function execTests() { testSelectCommand("cmd_selectCharNext", node(0), 1); doCommand("cmd_moveTop"); - testMoveCommand("cmd_endLine", body, 1); + testMoveCommand("cmd_endLine", node(0), 1); testMoveCommand("cmd_beginLine", node(0), 0); - testSelectCommand("cmd_selectEndLine", body, 1); + testSelectCommand("cmd_selectEndLine", node(0), 1); doCommand("cmd_moveBottom"); testSelectCommand("cmd_selectBeginLine", node(22), 0); diff --git a/layout/base/RestyleManager.cpp b/layout/base/RestyleManager.cpp index d0bf4d34e6..d4a86f61db 100644 --- a/layout/base/RestyleManager.cpp +++ b/layout/base/RestyleManager.cpp @@ -413,6 +413,9 @@ RestyleManager::RecomputePosition(nsIFrame* aFrame) if (display->IsInnerTableStyle()) { // We don't currently support sticky positioning of inner table // elements (bug 975644). Bail. + // + // When this is fixed, remove the null-check for the computed + // offsets in nsTableRowFrame::ReflowChildren. return true; } diff --git a/layout/base/nsBidiPresUtils.cpp b/layout/base/nsBidiPresUtils.cpp index cbe58195d6..a7e0f060ec 100644 --- a/layout/base/nsBidiPresUtils.cpp +++ b/layout/base/nsBidiPresUtils.cpp @@ -1449,10 +1449,11 @@ nsBidiPresUtils::RepositionRubyContentFrame( // When ruby-align is not "start", if the content does not fill this // frame, we need to center the children. + const nsSize dummyContainerSize; for (nsIFrame* child : childList) { - LogicalRect rect = child->GetLogicalRect(aFrameWM, 0); + LogicalRect rect = child->GetLogicalRect(aFrameWM, dummyContainerSize); rect.IStart(aFrameWM) += residualISize / 2; - child->SetRect(aFrameWM, rect, 0); + child->SetRect(aFrameWM, rect, dummyContainerSize); } } @@ -1602,28 +1603,23 @@ nsBidiPresUtils::RepositionFrame(nsIFrame* aFrame, frameWM.IsOrthogonalTo(aContainerWM) ? aFrame->BSize() : frameISize; } - // LogicalRect doesn't correctly calculate the vertical position - // in vertical writing modes with right-to-left direction (Bug 1131451). - // This does the correct calculation ad hoc pending the fix for that. - nsRect rect = aFrame->GetRect(); - - LogicalMargin margin = frameMargin.ConvertTo(aContainerWM, frameWM); // In the following variables, if aContainerReverseDir is true, i.e. // the container is positioning its children in reverse of its logical // direction, the "StartOrEnd" refers to the distance from the frame // to the inline end edge of the container, elsewise, it refers to the // distance to the inline start edge. - nscoord marginStartOrEnd = aContainerReverseDir ? - margin.IEnd(aContainerWM) : margin.IStart(aContainerWM); + const LogicalMargin margin = frameMargin.ConvertTo(aContainerWM, frameWM); + nscoord marginStartOrEnd = + aContainerReverseDir ? margin.IEnd(aContainerWM) + : margin.IStart(aContainerWM); nscoord frameStartOrEnd = aStartOrEnd + marginStartOrEnd; - // Whether we are placing frames from right to left. - // e.g. If the frames are placed reversely in LTR mode, they are - // actually placed from right to left. - bool orderingRTL = aContainerReverseDir == aContainerWM.IsBidiLTR(); - (aContainerWM.IsVertical() ? rect.y : rect.x) = orderingRTL ? - lineSize - (frameStartOrEnd + icoord) : frameStartOrEnd; - (aContainerWM.IsVertical() ? rect.height : rect.width) = icoord; - aFrame->SetRect(rect); + + LogicalRect rect = aFrame->GetLogicalRect(aContainerWM, aContainerSize); + rect.ISize(aContainerWM) = icoord; + rect.IStart(aContainerWM) = + aContainerReverseDir ? lineSize - frameStartOrEnd - icoord + : frameStartOrEnd; + aFrame->SetRect(aContainerWM, rect, aContainerSize); return icoord + margin.IStartEnd(aContainerWM); } diff --git a/layout/base/nsIPresShell.h b/layout/base/nsIPresShell.h index 3c02e85481..c1e8df02ab 100644 --- a/layout/base/nsIPresShell.h +++ b/layout/base/nsIPresShell.h @@ -22,6 +22,7 @@ #include "mozilla/EventForwards.h" #include "mozilla/MemoryReporting.h" +#include "mozilla/StaticPtr.h" #include "mozilla/WeakPtr.h" #include "gfxPoint.h" #include "nsTHashtable.h" @@ -135,7 +136,7 @@ typedef struct CapturingContentInfo { bool mPointerLock; bool mRetargetToElement; bool mPreventDrag; - nsIContent* mContent; + mozilla::StaticRefPtr mContent; } CapturingContentInfo; // a7ef8bb3-d628-4965-80f3-a326e089fb7f @@ -1683,18 +1684,21 @@ protected: // These are the same Document and PresContext owned by the DocViewer. // we must share ownership. - nsIDocument* mDocument; // [STRONG] - nsPresContext* mPresContext; // [STRONG] + nsCOMPtr mDocument; + nsRefPtr mPresContext; nsStyleSet* mStyleSet; // [OWNS] nsCSSFrameConstructor* mFrameConstructor; // [OWNS] nsViewManager* mViewManager; // [WEAK] docViewer owns it so I don't have to nsPresArena mFrameArena; - nsFrameSelection* mSelection; + nsRefPtr mSelection; // Pointer into mFrameConstructor - this is purely so that FrameManager() and // GetRootFrame() can be inlined: nsFrameManagerBase* mFrameManager; mozilla::WeakPtr mForwardingContainer; - nsRefreshDriver* mHiddenInvalidationObserverRefreshDriver; + nsRefreshDriver* MOZ_UNSAFE_REF("These two objects hold weak references " + "to each other, and the validity of this " + "member is ensured by the logic in nsIPresShell.") + mHiddenInvalidationObserverRefreshDriver; #ifdef ACCESSIBILITY mozilla::a11y::DocAccessible* mDocAccessible; #endif diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index c2f07892f6..f347c65f5f 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -5741,7 +5741,7 @@ nsLayoutUtils::GetFirstLinePosition(WritingMode aWM, // kid might be a legend frame here, but that's ok. if (GetFirstLinePosition(aWM, kid, &kidPosition)) { *aResult = kidPosition + - kid->GetLogicalNormalPosition(aWM, aFrame->GetSize().width).B(aWM); + kid->GetLogicalNormalPosition(aWM, aFrame->GetSize()).B(aWM); return true; } return false; @@ -5761,9 +5761,9 @@ nsLayoutUtils::GetFirstLinePosition(WritingMode aWM, //XXX Not sure if this is the correct value to use for container // width here. It will only be used in vertical-rl layout, // which we don't have full support and testing for yet. - nscoord containerWidth = line->mContainerWidth; + const nsSize& containerSize = line->mContainerSize; *aResult = kidPosition + - kid->GetLogicalNormalPosition(aWM, containerWidth).B(aWM); + kid->GetLogicalNormalPosition(aWM, containerSize).B(aWM); return true; } } else { @@ -5796,16 +5796,16 @@ nsLayoutUtils::GetLastLineBaseline(WritingMode aWM, if (line->IsBlock()) { nsIFrame *kid = line->mFirstChild; nscoord kidBaseline; - nscoord containerWidth = line->mContainerWidth; + const nsSize& containerSize = line->mContainerSize; if (GetLastLineBaseline(aWM, kid, &kidBaseline)) { // Ignore relative positioning for baseline calculations *aResult = kidBaseline + - kid->GetLogicalNormalPosition(aWM, containerWidth).B(aWM); + kid->GetLogicalNormalPosition(aWM, containerSize).B(aWM); return true; } else if (kid->GetType() == nsGkAtoms::scrollFrame) { // Use the bottom of the scroll frame. // XXX CSS2.1 really doesn't say what to do here. - *aResult = kid->GetLogicalNormalPosition(aWM, containerWidth).B(aWM) + + *aResult = kid->GetLogicalNormalPosition(aWM, containerSize).B(aWM) + kid->BSize(aWM); return true; } @@ -5833,9 +5833,9 @@ CalculateBlockContentBEnd(WritingMode aWM, nsBlockFrame* aFrame) line != line_end; ++line) { if (line->IsBlock()) { nsIFrame* child = line->mFirstChild; - nscoord containerWidth = line->mContainerWidth; + const nsSize& containerSize = line->mContainerSize; nscoord offset = - child->GetLogicalNormalPosition(aWM, containerWidth).B(aWM); + child->GetLogicalNormalPosition(aWM, containerSize).B(aWM); contentBEnd = std::max(contentBEnd, nsLayoutUtils::CalculateContentBEnd(aWM, child) + offset); @@ -5875,7 +5875,7 @@ nsLayoutUtils::CalculateContentBEnd(WritingMode aWM, nsIFrame* aFrame) nsIFrame* child = childFrames.get(); nscoord offset = child->GetLogicalNormalPosition(aWM, - aFrame->GetSize().width).B(aWM); + aFrame->GetSize()).B(aWM); contentBEnd = std::max(contentBEnd, CalculateContentBEnd(aWM, child) + offset); } diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 1f715bbc6d..d7f4a8ac4f 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -203,7 +203,7 @@ using namespace mozilla::layout; CapturingContentInfo nsIPresShell::gCaptureInfo = { false /* mAllowed */, false /* mPointerLock */, false /* mRetargetToElement */, - false /* mPreventDrag */, nullptr /* mContent */ }; + false /* mPreventDrag */ }; nsIContent* nsIPresShell::gKeyDownTarget; nsClassHashtable* nsIPresShell::gPointerCaptureList; nsClassHashtable* nsIPresShell::gActivePointersIds; @@ -760,7 +760,6 @@ PresShell::BeforeAfterKeyboardEventEnabled() PresShell::PresShell() : mMouseLocation(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE) { - mSelection = nullptr; #ifdef MOZ_REFLOW_PERF mReflowCountMgr = new ReflowCountMgr(); mReflowCountMgr->SetPresContext(mPresContext); @@ -847,10 +846,6 @@ PresShell::~PresShell() delete mFrameConstructor; mCurrentEventContent = nullptr; - - NS_IF_RELEASE(mPresContext); - NS_IF_RELEASE(mDocument); - NS_IF_RELEASE(mSelection); } /** @@ -876,7 +871,6 @@ PresShell::Init(nsIDocument* aDocument, } mDocument = aDocument; - NS_ADDREF(mDocument); mViewManager = aViewManager; // Create our frame constructor. @@ -889,7 +883,6 @@ PresShell::Init(nsIDocument* aDocument, // Bind the context to the presentation shell. mPresContext = aPresContext; - NS_ADDREF(mPresContext); aPresContext->SetShell(this); // Now we can initialize the style set. @@ -922,7 +915,7 @@ PresShell::Init(nsIDocument* aDocument, mAccessibleCaretEventHub = new AccessibleCaretEventHub(); } - NS_ADDREF(mSelection = new nsFrameSelection()); + mSelection = new nsFrameSelection(); mSelection->Init(this, nullptr); @@ -3881,7 +3874,7 @@ PresShell::ClearMouseCaptureOnView(nsView* aView) if (view) { do { if (view == aView) { - NS_RELEASE(gCaptureInfo.mContent); + gCaptureInfo.mContent = nullptr; // the view containing the captured content likely disappeared so // disable capture for now. gCaptureInfo.mAllowed = false; @@ -3896,7 +3889,7 @@ PresShell::ClearMouseCaptureOnView(nsView* aView) } } - NS_RELEASE(gCaptureInfo.mContent); + gCaptureInfo.mContent = nullptr; } // disable mouse capture until the next mousedown as a dialog has opened @@ -3915,20 +3908,20 @@ nsIPresShell::ClearMouseCapture(nsIFrame* aFrame) // null frame argument means clear the capture if (!aFrame) { - NS_RELEASE(gCaptureInfo.mContent); + gCaptureInfo.mContent = nullptr; gCaptureInfo.mAllowed = false; return; } nsIFrame* capturingFrame = gCaptureInfo.mContent->GetPrimaryFrame(); if (!capturingFrame) { - NS_RELEASE(gCaptureInfo.mContent); + gCaptureInfo.mContent = nullptr; gCaptureInfo.mAllowed = false; return; } if (nsLayoutUtils::IsAncestorFrameCrossDoc(aFrame, capturingFrame)) { - NS_RELEASE(gCaptureInfo.mContent); + gCaptureInfo.mContent = nullptr; gCaptureInfo.mAllowed = false; } } @@ -6379,14 +6372,14 @@ nsIPresShell::SetCapturingContent(nsIContent* aContent, uint8_t aFlags) return; } - NS_IF_RELEASE(gCaptureInfo.mContent); + gCaptureInfo.mContent = nullptr; // only set capturing content if allowed or the CAPTURE_IGNOREALLOWED or // CAPTURE_POINTERLOCK flags are used. if ((aFlags & CAPTURE_IGNOREALLOWED) || gCaptureInfo.mAllowed || (aFlags & CAPTURE_POINTERLOCK)) { if (aContent) { - NS_ADDREF(gCaptureInfo.mContent = aContent); + gCaptureInfo.mContent = aContent; } // CAPTURE_POINTERLOCK is the same as CAPTURE_RETARGETTOELEMENT & CAPTURE_IGNOREALLOWED gCaptureInfo.mRetargetToElement = ((aFlags & CAPTURE_RETARGETTOELEMENT) != 0) || diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index c569f72e9a..041a297a87 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -458,19 +458,20 @@ nsComboboxControlFrame::ReflowDropdown(nsPresContext* aPresContext, //XXX Can this be different from the dropdown's writing mode? // That would be odd! - // Note that we don't need to pass the true frame position or container width + // Note that we don't need to pass the true frame position or container size // to ReflowChild or FinishReflowChild here; it will be positioned as needed // by AbsolutelyPositionDropDown(). WritingMode outerWM = GetWritingMode(); + const nsSize dummyContainerSize; nsHTMLReflowMetrics desiredSize(aReflowState); nsReflowStatus ignoredStatus; ReflowChild(mDropdownFrame, aPresContext, desiredSize, - kidReflowState, outerWM, LogicalPoint(outerWM), 0, - flags, ignoredStatus); + kidReflowState, outerWM, LogicalPoint(outerWM), + dummyContainerSize, flags, ignoredStatus); // Set the child's width and height to its desired size FinishReflowChild(mDropdownFrame, aPresContext, desiredSize, &kidReflowState, - outerWM, LogicalPoint(outerWM), 0, flags); + outerWM, LogicalPoint(outerWM), dummyContainerSize, flags); } nsPoint @@ -570,16 +571,19 @@ nsComboboxControlFrame::GetAvailableDropdownSpace(WritingMode aWM, // Normal frame geometry (eg GetOffsetTo, mRect) doesn't include transforms. // In the special case that our transform is only a 2D translation we // introduce this hack so that the dropdown will show up in the right place. - *aTranslation = LogicalPoint(aWM, GetCSSTransformTranslation(), 0); + // Use null container size when converting a vector from logical to physical. + const nsSize nullContainerSize; + *aTranslation = LogicalPoint(aWM, GetCSSTransformTranslation(), + nullContainerSize); *aBefore = 0; *aAfter = 0; nsRect screen = nsFormControlFrame::GetUsableScreenRect(PresContext()); - nscoord containerWidth = screen.width; - LogicalRect logicalScreen(aWM, screen, containerWidth); + nsSize containerSize = screen.Size(); + LogicalRect logicalScreen(aWM, screen, containerSize); if (mLastDropDownAfterScreenBCoord == nscoord_MIN) { LogicalRect thisScreenRect(aWM, GetScreenRectInAppUnits(), - containerWidth); + containerSize); mLastDropDownAfterScreenBCoord = thisScreenRect.BEnd(aWM) + aTranslation->B(aWM); mLastDropDownBeforeScreenBCoord = thisScreenRect.BEnd(aWM) + @@ -592,7 +596,7 @@ nsComboboxControlFrame::GetAvailableDropdownSpace(WritingMode aWM, if (root) { minBCoord = LogicalRect(aWM, root->GetScreenRectInAppUnits(), - containerWidth).BStart(aWM); + containerSize).BStart(aWM); if (mLastDropDownAfterScreenBCoord < minBCoord) { // Don't allow the drop-down to be placed before the content area. return; @@ -664,12 +668,12 @@ nsComboboxControlFrame::AbsolutelyPositionDropDown() // Don't position the view unless the position changed since it might cause // a call to NotifyGeometryChange() and an infinite loop here. - nscoord containerWidth = GetRect().width; + nsSize containerSize = GetSize(); const LogicalPoint currentPos = - mDropdownFrame->GetLogicalPosition(containerWidth); + mDropdownFrame->GetLogicalPosition(containerSize); const LogicalPoint newPos = dropdownPosition + translation; if (currentPos != newPos) { - mDropdownFrame->SetPosition(wm, newPos, containerWidth); + mDropdownFrame->SetPosition(wm, newPos, containerSize); nsContainerFrame::PositionFrameView(mDropdownFrame); } return eDropDownPositionFinal; @@ -861,9 +865,8 @@ nsComboboxControlFrame::Reflow(nsPresContext* aPresContext, // The button should occupy the same space as a scrollbar WritingMode wm = aReflowState.GetWritingMode(); - nscoord containerWidth = - aReflowState.ComputedSizeAsContainerIfConstrained().width; - LogicalRect buttonRect = mButtonFrame->GetLogicalRect(containerWidth); + nsSize containerSize = aReflowState.ComputedSizeAsContainerIfConstrained(); + LogicalRect buttonRect = mButtonFrame->GetLogicalRect(containerSize); buttonRect.IStart(wm) = aReflowState.ComputedLogicalBorderPadding().IStartEnd(wm) + @@ -876,7 +879,7 @@ nsComboboxControlFrame::Reflow(nsPresContext* aPresContext, buttonRect.BSize(wm) = mDisplayFrame->BSize(wm) + this->GetLogicalUsedPadding(wm).BStartEnd(wm); - mButtonFrame->SetRect(buttonRect, containerWidth); + mButtonFrame->SetRect(buttonRect, containerSize); if (!NS_INLINE_IS_BREAK_BEFORE(aStatus) && !NS_FRAME_IS_FULLY_COMPLETE(aStatus)) { diff --git a/layout/forms/nsFieldSetFrame.cpp b/layout/forms/nsFieldSetFrame.cpp index 6d43f9a4ec..c262ce8c6c 100644 --- a/layout/forms/nsFieldSetFrame.cpp +++ b/layout/forms/nsFieldSetFrame.cpp @@ -55,13 +55,13 @@ nsFieldSetFrame::VisualBorderRectRelativeToSelf() const css::Side legendSide = wm.PhysicalSide(eLogicalSideBStart); nscoord legendBorder = StyleBorder()->GetComputedBorderWidth(legendSide); LogicalRect r(wm, LogicalPoint(wm, 0, 0), GetLogicalSize(wm)); - nscoord containerWidth = r.Width(wm); + nsSize containerSize = r.Size(wm).GetPhysicalSize(wm); if (legendBorder < mLegendRect.BSize(wm)) { nscoord off = (mLegendRect.BSize(wm) - legendBorder) / 2; r.BStart(wm) += off; r.BSize(wm) -= off; } - return r.GetPhysicalRect(wm, containerWidth); + return r.GetPhysicalRect(wm, containerSize); } nsIFrame* @@ -237,11 +237,11 @@ nsFieldSetFrame::PaintBorderBackground(nsRenderingContext& aRenderingContext, // Use the rect of the legend frame, not mLegendRect, so we draw our // border under the legend's inline-start and -end margins. - LogicalRect legendRect(wm, legend->GetRect() + aPt, rect.width); + LogicalRect legendRect(wm, legend->GetRect() + aPt, rect.Size()); // Compute clipRect using logical coordinates, so that the legend space // will be clipped out of the appropriate physical side depending on mode. - LogicalRect clipRect = LogicalRect(wm, rect, rect.width); + LogicalRect clipRect = LogicalRect(wm, rect, rect.Size()); DrawTarget* drawTarget = aRenderingContext.GetDrawTarget(); gfxContext* gfx = aRenderingContext.ThebesContext(); int32_t appUnitsPerDevPixel = presContext->AppUnitsPerDevPixel(); @@ -251,33 +251,32 @@ nsFieldSetFrame::PaintBorderBackground(nsRenderingContext& aRenderingContext, clipRect.BSize(wm) = legendBorderWidth; gfx->Save(); - gfx->Clip(NSRectToSnappedRect(clipRect.GetPhysicalRect(wm, rect.width), + gfx->Clip(NSRectToSnappedRect(clipRect.GetPhysicalRect(wm, rect.Size()), appUnitsPerDevPixel, *drawTarget)); nsCSSRendering::PaintBorder(presContext, aRenderingContext, this, aDirtyRect, rect, mStyleContext); gfx->Restore(); // draw inline-end portion of the block-start side of the border - clipRect = LogicalRect(wm, rect, rect.width); + clipRect = LogicalRect(wm, rect, rect.Size()); clipRect.ISize(wm) = clipRect.IEnd(wm) - legendRect.IEnd(wm); clipRect.IStart(wm) = legendRect.IEnd(wm); clipRect.BSize(wm) = legendBorderWidth; gfx->Save(); - gfx->Clip(NSRectToSnappedRect(clipRect.GetPhysicalRect(wm, rect.width), + gfx->Clip(NSRectToSnappedRect(clipRect.GetPhysicalRect(wm, rect.Size()), appUnitsPerDevPixel, *drawTarget)); nsCSSRendering::PaintBorder(presContext, aRenderingContext, this, aDirtyRect, rect, mStyleContext); gfx->Restore(); // draw remainder of the border (omitting the block-start side) - clipRect = LogicalRect(wm, rect, rect.width); + clipRect = LogicalRect(wm, rect, rect.Size()); clipRect.BStart(wm) += legendBorderWidth; - clipRect.BSize(wm) = - GetLogicalRect(rect.width).BSize(wm) - (off + legendBorderWidth); + clipRect.BSize(wm) = BSize(wm) - (off + legendBorderWidth); gfx->Save(); - gfx->Clip(NSRectToSnappedRect(clipRect.GetPhysicalRect(wm, rect.width), + gfx->Clip(NSRectToSnappedRect(clipRect.GetPhysicalRect(wm, rect.Size()), appUnitsPerDevPixel, *drawTarget)); nsCSSRendering::PaintBorder(presContext, aRenderingContext, this, aDirtyRect, rect, mStyleContext); @@ -449,8 +448,12 @@ nsFieldSetFrame::Reflow(nsPresContext* aPresContext, if (reflowLegend) { nsHTMLReflowMetrics legendDesiredSize(aReflowState); + // We'll move the legend to its proper place later, so the position + // and containerSize passed here are unimportant. + const nsSize dummyContainerSize; ReflowChild(legend, aPresContext, legendDesiredSize, *legendReflowState, - wm, LogicalPoint(wm), 0, NS_FRAME_NO_MOVE_FRAME, aStatus); + wm, LogicalPoint(wm), dummyContainerSize, + NS_FRAME_NO_MOVE_FRAME, aStatus); #ifdef NOISY_REFLOW printf(" returned (%d, %d)\n", legendDesiredSize.Width(), legendDesiredSize.Height()); @@ -477,10 +480,9 @@ nsFieldSetFrame::Reflow(nsPresContext* aPresContext, reflowInner = true; } - // We'll move the legend to its proper place later. FinishReflowChild(legend, aPresContext, legendDesiredSize, - legendReflowState.ptr(), wm, LogicalPoint(wm), 0, - NS_FRAME_NO_MOVE_FRAME); + legendReflowState.ptr(), wm, LogicalPoint(wm), + dummyContainerSize, NS_FRAME_NO_MOVE_FRAME); } else if (!legend) { mLegendRect.SetEmpty(); mLegendSpace = 0; @@ -490,8 +492,10 @@ nsFieldSetFrame::Reflow(nsPresContext* aPresContext, legendMargin = legend->GetLogicalUsedMargin(wm); } - nscoord containerWidth = (wm.IsVertical() ? mLegendSpace : 0) + - border.LeftRight(wm); + // This containerSize is incomplete as yet: it does not include the size + // of the |inner| frame itself. + nsSize containerSize = (LogicalSize(wm, 0, mLegendSpace) + + border.Size(wm)).GetPhysicalSize(wm); // reflow the content frame only if needed if (reflowInner) { nsHTMLReflowState kidReflowState(aPresContext, aReflowState, inner, @@ -525,26 +529,31 @@ nsFieldSetFrame::Reflow(nsPresContext* aPresContext, "Margins on anonymous fieldset child not supported!"); LogicalPoint pt(wm, border.IStart(wm), border.BStart(wm) + mLegendSpace); + // We don't know the correct containerSize until we have reflowed |inner|, + // so we use a dummy value for now; FinishReflowChild will fix the position + // if necessary. + const nsSize dummyContainerSize; ReflowChild(inner, aPresContext, kidDesiredSize, kidReflowState, - wm, pt, containerWidth, 0, aStatus); + wm, pt, dummyContainerSize, 0, aStatus); - // update the container width after reflowing the inner frame + // Update containerSize to account for size of the inner frame, so that + // FinishReflowChild can position it correctly. + containerSize += kidDesiredSize.PhysicalSize(); FinishReflowChild(inner, aPresContext, kidDesiredSize, - &kidReflowState, wm, pt, - containerWidth + kidDesiredSize.Width(), 0); + &kidReflowState, wm, pt, containerSize, 0); NS_FRAME_TRACE_REFLOW_OUT("FieldSet::Reflow", aStatus); - } - - if (inner) { - containerWidth += inner->GetSize().width; + } else if (inner) { + // |inner| didn't need to be reflowed but we do need to include its size + // in containerSize. + containerSize += inner->GetSize(); } LogicalRect contentRect(wm); if (inner) { // We don't support margins on inner, so our content rect is just the - // inner's border-box. We don't care about container-width at this point, - // as we'll figure out the actual positioning later. - contentRect = inner->GetLogicalRect(wm, containerWidth); + // inner's border-box. (We don't really care about container size at this + // point, as we'll figure out the actual positioning later.) + contentRect = inner->GetLogicalRect(wm, containerSize); } // Our content rect must fill up the available width @@ -607,9 +616,9 @@ nsFieldSetFrame::Reflow(nsPresContext* aPresContext, ConvertTo(wm, legendReflowState->GetWritingMode()); nsHTMLReflowState::ApplyRelativePositioning(legend, wm, offsets, &actualLegendPos, - containerWidth); + containerSize); - legend->SetPosition(wm, actualLegendPos, containerWidth); + legend->SetPosition(wm, actualLegendPos, containerSize); nsContainerFrame::PositionFrameView(legend); nsContainerFrame::PositionChildViews(legend); } @@ -682,6 +691,6 @@ nscoord nsFieldSetFrame::GetLogicalBaseline(WritingMode aWritingMode) const { nsIFrame* inner = GetInner(); - return inner->BStart(aWritingMode, GetParent()->GetSize().width) + + return inner->BStart(aWritingMode, GetParent()->GetSize()) + inner->GetLogicalBaseline(aWritingMode); } diff --git a/layout/forms/nsHTMLButtonControlFrame.cpp b/layout/forms/nsHTMLButtonControlFrame.cpp index 58efc857fd..852d538432 100644 --- a/layout/forms/nsHTMLButtonControlFrame.cpp +++ b/layout/forms/nsHTMLButtonControlFrame.cpp @@ -320,11 +320,12 @@ nsHTMLButtonControlFrame::ReflowButtonContents(nsPresContext* aPresContext, childPos.B(wm) = 0; // This will be set properly later, after reflowing the // child to determine its size. - // We just pass 0 for containerWidth here, as the child will be repositioned - // later by FinishReflowChild. + // We just pass a dummy containerSize here, as the child will be + // repositioned later by FinishReflowChild. + nsSize dummyContainerSize; ReflowChild(aFirstKid, aPresContext, contentsDesiredSize, contentsReflowState, - wm, childPos, 0, 0, contentsReflowStatus); + wm, childPos, dummyContainerSize, 0, contentsReflowStatus); MOZ_ASSERT(NS_FRAME_IS_COMPLETE(contentsReflowStatus), "We gave button-contents frame unconstrained available height, " "so it should be complete"); @@ -373,12 +374,13 @@ nsHTMLButtonControlFrame::ReflowButtonContents(nsPresContext* aPresContext, // its focus-padding rect: childPos.B(wm) += focusPadding.BStart(wm) + clbp.BStart(wm); - nscoord containerWidth = buttonContentBox.Width(wm) + clbp.LeftRight(wm); + nsSize containerSize = + (buttonContentBox + clbp.Size(wm)).GetPhysicalSize(wm); // Place the child FinishReflowChild(aFirstKid, aPresContext, contentsDesiredSize, &contentsReflowState, - wm, childPos, containerWidth, 0); + wm, childPos, containerSize, 0); // Make sure we have a useful 'ascent' value for the child if (contentsDesiredSize.BlockStartAscent() == diff --git a/layout/forms/nsMeterFrame.cpp b/layout/forms/nsMeterFrame.cpp index 616837fa0e..6a26b85e49 100644 --- a/layout/forms/nsMeterFrame.cpp +++ b/layout/forms/nsMeterFrame.cpp @@ -236,10 +236,10 @@ nsMeterFrame::ComputeAutoSize(nsRenderingContext *aRenderingContext, LogicalSize autoSize(wm); autoSize.BSize(wm) = autoSize.ISize(wm) = fontMet->Font().size; // 1em - if (ResolvedOrientationIsVertical()) { - autoSize.Height(wm) *= 5; // 5em + if (ResolvedOrientationIsVertical() == wm.IsVertical()) { + autoSize.ISize(wm) *= 5; // 5em } else { - autoSize.Width(wm) *= 5; // 5em + autoSize.BSize(wm) *= 5; // 5em } return autoSize.ConvertTo(aWM, wm); diff --git a/layout/forms/nsNumberControlFrame.cpp b/layout/forms/nsNumberControlFrame.cpp index 8d82d63415..67f8bd5d2a 100644 --- a/layout/forms/nsNumberControlFrame.cpp +++ b/layout/forms/nsNumberControlFrame.cpp @@ -175,8 +175,12 @@ nsNumberControlFrame::Reflow(nsPresContext* aPresContext, wrapperMargin.BStart(myWM)); nsReflowStatus childStatus; + // We initially reflow the child with a dummy containerSize; positioning + // will be fixed later. + const nsSize dummyContainerSize; ReflowChild(outerWrapperFrame, aPresContext, wrappersDesiredSize, - wrapperReflowState, myWM, wrapperOffset, 0, 0, childStatus); + wrapperReflowState, myWM, wrapperOffset, dummyContainerSize, 0, + childStatus); MOZ_ASSERT(NS_FRAME_IS_FULLY_COMPLETE(childStatus), "We gave our child unconstrained available block-size, " "so it should be complete"); @@ -208,18 +212,21 @@ nsNumberControlFrame::Reflow(nsPresContext* aPresContext, wrapperOffset.B(myWM) += std::max(0, extraSpace / 2); // Needed in FinishReflowChild, for logical-to-physical conversion: - nscoord borderBoxWidth = myWM.IsVertical() ? - borderBoxBSize : borderBoxISize; + nsSize borderBoxSize = LogicalSize(myWM, borderBoxISize, borderBoxBSize). + GetPhysicalSize(myWM); // Place the child FinishReflowChild(outerWrapperFrame, aPresContext, wrappersDesiredSize, &wrapperReflowState, myWM, wrapperOffset, - borderBoxWidth, 0); + borderBoxSize, 0); + nsSize contentBoxSize = + LogicalSize(myWM, contentBoxISize, contentBoxBSize). + GetPhysicalSize(myWM); aDesiredSize.SetBlockStartAscent( wrappersDesiredSize.BlockStartAscent() + outerWrapperFrame->BStart(aReflowState.GetWritingMode(), - contentBoxISize)); + contentBoxSize)); } LogicalSize logicalDesiredSize(myWM, borderBoxISize, borderBoxBSize); diff --git a/layout/forms/nsProgressFrame.cpp b/layout/forms/nsProgressFrame.cpp index a3596ba583..f41eeba5d1 100644 --- a/layout/forms/nsProgressFrame.cpp +++ b/layout/forms/nsProgressFrame.cpp @@ -242,10 +242,10 @@ nsProgressFrame::ComputeAutoSize(nsRenderingContext *aRenderingContext, NSToCoordRound(StyleFont()->mFont.size * nsLayoutUtils::FontSizeInflationFor(this)); // 1em - if (ResolvedOrientationIsVertical()) { - autoSize.Height(wm) *= 10; // 10em + if (ResolvedOrientationIsVertical() == wm.IsVertical()) { + autoSize.ISize(wm) *= 10; // 10em } else { - autoSize.Width(wm) *= 10; // 10em + autoSize.BSize(wm) *= 10; // 10em } return autoSize.ConvertTo(aWM, wm); diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index f09ea109b6..96f1137c1f 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -216,11 +216,12 @@ nsTextControlFrame::CalcIntrinsicSize(nsRenderingContext* aRenderingContext, NS_ASSERTION(scrollableFrame, "Child must be scrollable"); if (scrollableFrame) { - nsMargin scrollbarSizes = - scrollableFrame->GetDesiredScrollbarSizes(PresContext(), aRenderingContext); + LogicalMargin scrollbarSizes(aWM, + scrollableFrame->GetDesiredScrollbarSizes(PresContext(), + aRenderingContext)); - aIntrinsicSize.Width(aWM) += scrollbarSizes.LeftRight(); - aIntrinsicSize.Height(aWM) += scrollbarSizes.TopBottom(); + aIntrinsicSize.ISize(aWM) += scrollbarSizes.IStartEnd(aWM); + aIntrinsicSize.BSize(aWM) += scrollbarSizes.BStartEnd(aWM); } } diff --git a/layout/generic/TextOverflow.cpp b/layout/generic/TextOverflow.cpp index ed4fa56ab0..d398aea328 100644 --- a/layout/generic/TextOverflow.cpp +++ b/layout/generic/TextOverflow.cpp @@ -263,11 +263,11 @@ TextOverflow::TextOverflow(nsDisplayListBuilder* aBuilder, nsIFrame* aBlockFrame) : mContentArea(aBlockFrame->GetWritingMode(), aBlockFrame->GetContentRectRelativeToSelf(), - aBlockFrame->GetRect().width) + aBlockFrame->GetSize()) , mBuilder(aBuilder) , mBlock(aBlockFrame) , mScrollableFrame(nsLayoutUtils::GetScrollableFrameFor(aBlockFrame)) - , mBlockWidth(aBlockFrame->GetRect().width) + , mBlockSize(aBlockFrame->GetSize()) , mBlockWM(aBlockFrame->GetWritingMode()) , mAdjustForPixelSnapping(false) { @@ -296,9 +296,12 @@ TextOverflow::TextOverflow(nsDisplayListBuilder* aBuilder, // to pixel snapping behaviour in our scrolling code. mAdjustForPixelSnapping = mCanHaveInlineAxisScrollbar; } + // Use a null containerSize to convert a vector from logical to physical. + const nsSize nullContainerSize; mContentArea.MoveBy(mBlockWM, LogicalPoint(mBlockWM, - mScrollableFrame->GetScrollPosition(), 0)); + mScrollableFrame->GetScrollPosition(), + nullContainerSize)); nsIFrame* scrollFrame = do_QueryFrame(mScrollableFrame); scrollFrame->AddStateBits(NS_SCROLLFRAME_INVALIDATE_CONTENTS_ON_SCROLL); } @@ -394,7 +397,7 @@ TextOverflow::AnalyzeMarkerEdges(nsIFrame* aFrame, LogicalRect borderRect(mBlockWM, nsRect(aFrame->GetOffsetTo(mBlock), aFrame->GetSize()), - mBlockWidth); + mBlockSize); nscoord istartOverlap = std::max( aInsideMarkersArea.IStart(mBlockWM) - borderRect.IStart(mBlockWM), 0); nscoord iendOverlap = std::max( @@ -468,9 +471,9 @@ TextOverflow::ExamineLineFrames(nsLineBox* aLine, bool suppressIEnd = mIEnd.mStyle->mType == NS_STYLE_TEXT_OVERFLOW_CLIP; if (mCanHaveInlineAxisScrollbar) { LogicalPoint pos(mBlockWM, mScrollableFrame->GetScrollPosition(), - mBlockWidth); + mBlockSize); LogicalRect scrollRange(mBlockWM, mScrollableFrame->GetScrollRange(), - mBlockWidth); + mBlockSize); // No ellipsing when nothing to scroll to on that side (this includes // overflow:auto that doesn't trigger a horizontal scrollbar). if (pos.I(mBlockWM) <= scrollRange.IStart(mBlockWM)) { @@ -487,7 +490,7 @@ TextOverflow::ExamineLineFrames(nsLineBox* aLine, InflateIStart(mBlockWM, &contentArea, scrollAdjust); InflateIEnd(mBlockWM, &contentArea, scrollAdjust); LogicalRect lineRect(mBlockWM, aLine->GetScrollableOverflowArea(), - mBlockWidth); + mBlockSize); const bool istartOverflow = !suppressIStart && lineRect.IStart(mBlockWM) < contentArea.IStart(mBlockWM); const bool iendOverflow = @@ -760,8 +763,8 @@ TextOverflow::CreateMarkers(const nsLineBox* aLine, aLine->BStart(), mIStart.mIntrinsicISize, aLine->BSize()); nsPoint offset = mBuilder->ToReferenceFrame(mBlock); nsRect markerRect = - markerLogicalRect.GetPhysicalRect(mBlockWM, mBlockWidth) + offset; - ClipMarker(mContentArea.GetPhysicalRect(mBlockWM, mBlockWidth) + offset, + markerLogicalRect.GetPhysicalRect(mBlockWM, mBlockSize) + offset; + ClipMarker(mContentArea.GetPhysicalRect(mBlockWM, mBlockSize) + offset, markerRect, clipState); nsDisplayItem* marker = new (mBuilder) nsDisplayTextOverflowMarker(mBuilder, mBlock, markerRect, @@ -777,8 +780,8 @@ TextOverflow::CreateMarkers(const nsLineBox* aLine, mIEnd.mIntrinsicISize, aLine->BSize()); nsPoint offset = mBuilder->ToReferenceFrame(mBlock); nsRect markerRect = - markerLogicalRect.GetPhysicalRect(mBlockWM, mBlockWidth) + offset; - ClipMarker(mContentArea.GetPhysicalRect(mBlockWM, mBlockWidth) + offset, + markerLogicalRect.GetPhysicalRect(mBlockWM, mBlockSize) + offset; + ClipMarker(mContentArea.GetPhysicalRect(mBlockWM, mBlockSize) + offset, markerRect, clipState); nsDisplayItem* marker = new (mBuilder) nsDisplayTextOverflowMarker(mBuilder, mBlock, markerRect, diff --git a/layout/generic/TextOverflow.h b/layout/generic/TextOverflow.h index 2156c069f4..6c8083e3ef 100644 --- a/layout/generic/TextOverflow.h +++ b/layout/generic/TextOverflow.h @@ -117,7 +117,7 @@ class TextOverflow { return LogicalRect(mBlockWM, aFrame->GetScrollableOverflowRect() + aFrame->GetOffsetTo(mBlock), - mBlockWidth); + mBlockSize); } /** @@ -210,7 +210,7 @@ class TextOverflow { nsIFrame* mBlock; nsIScrollableFrame* mScrollableFrame; nsDisplayList mMarkerList; - nscoord mBlockWidth; + nsSize mBlockSize; WritingMode mBlockWM; bool mCanHaveInlineAxisScrollbar; bool mAdjustForPixelSnapping; diff --git a/layout/generic/WritingModes.h b/layout/generic/WritingModes.h index 641d2fca6e..06b088e44e 100644 --- a/layout/generic/WritingModes.h +++ b/layout/generic/WritingModes.h @@ -641,27 +641,29 @@ public: { } // Construct from a writing mode and a physical point, within a given - // containing rectangle's width (defining the conversion between LTR - // and RTL coordinates). + // containing rectangle's size (defining the conversion between LTR + // and RTL coordinates, and between TTB and BTT coordinates). LogicalPoint(WritingMode aWritingMode, const nsPoint& aPoint, - nscoord aContainerWidth) + const nsSize& aContainerSize) #ifdef DEBUG : mWritingMode(aWritingMode) #endif { if (aWritingMode.IsVertical()) { - I() = aPoint.y; - B() = aWritingMode.IsVerticalLR() ? aPoint.x : aContainerWidth - aPoint.x; + I() = aWritingMode.IsBidiLTR() ? aPoint.y + : aContainerSize.height - aPoint.y; + B() = aWritingMode.IsVerticalLR() ? aPoint.x + : aContainerSize.width - aPoint.x; } else { - I() = aWritingMode.IsBidiLTR() ? aPoint.x : aContainerWidth - aPoint.x; + I() = aWritingMode.IsBidiLTR() ? aPoint.x + : aContainerSize.width - aPoint.x; B() = aPoint.y; } } /** - * Read-only (const) access to the coordinates, in both logical - * and physical terms. + * Read-only (const) access to the logical coordinates. */ nscoord I(WritingMode aWritingMode) const // inline-axis { @@ -674,21 +676,6 @@ public: return mPoint.y; } - nscoord X(WritingMode aWritingMode, nscoord aContainerWidth) const - { - CHECK_WRITING_MODE(aWritingMode); - if (aWritingMode.IsVertical()) { - return aWritingMode.IsVerticalLR() ? B() : aContainerWidth - B(); - } else { - return aWritingMode.IsBidiLTR() ? I() : aContainerWidth - I(); - } - } - nscoord Y(WritingMode aWritingMode) const - { - CHECK_WRITING_MODE(aWritingMode); - return aWritingMode.IsVertical() ? I() : B(); - } - /** * These non-const accessors return a reference (lvalue) that can be * assigned to by callers. @@ -704,41 +691,22 @@ public: return mPoint.y; } - /** - * Setters for the physical coordinates. - */ - void SetX(WritingMode aWritingMode, nscoord aX, nscoord aContainerWidth) - { - CHECK_WRITING_MODE(aWritingMode); - if (aWritingMode.IsVertical()) { - B() = aWritingMode.IsVerticalLR() ? aX : aContainerWidth - aX; - } else { - I() = aWritingMode.IsBidiLTR() ? aX : aContainerWidth - aX; - } - } - void SetY(WritingMode aWritingMode, nscoord aY) - { - CHECK_WRITING_MODE(aWritingMode); - if (aWritingMode.IsVertical()) { - B() = aY; - } else { - I() = aY; - } - } - /** * Return a physical point corresponding to our logical coordinates, * converted according to our writing mode. */ nsPoint GetPhysicalPoint(WritingMode aWritingMode, - nscoord aContainerWidth) const + const nsSize& aContainerSize) const { CHECK_WRITING_MODE(aWritingMode); if (aWritingMode.IsVertical()) { - return nsPoint(aWritingMode.IsVerticalLR() ? B() : aContainerWidth - B(), - I()); + return nsPoint(aWritingMode.IsVerticalLR() + ? B() : aContainerSize.width - B(), + aWritingMode.IsBidiLTR() + ? I() : aContainerSize.height - I()); } else { - return nsPoint(aWritingMode.IsBidiLTR() ? I() : aContainerWidth - I(), + return nsPoint(aWritingMode.IsBidiLTR() + ? I() : aContainerSize.width - I(), B()); } } @@ -747,13 +715,13 @@ public: * Return the equivalent point in a different writing mode. */ LogicalPoint ConvertTo(WritingMode aToMode, WritingMode aFromMode, - nscoord aContainerWidth) const + const nsSize& aContainerSize) const { CHECK_WRITING_MODE(aFromMode); return aToMode == aFromMode ? *this : LogicalPoint(aToMode, - GetPhysicalPoint(aFromMode, aContainerWidth), - aContainerWidth); + GetPhysicalPoint(aFromMode, aContainerSize), + aContainerSize); } bool operator==(const LogicalPoint& aOther) const @@ -929,7 +897,7 @@ public: } /** - * Writable references to the logical and physical dimensions + * Writable references to the logical dimensions */ nscoord& ISize(WritingMode aWritingMode) // inline-size { @@ -942,17 +910,6 @@ public: return mSize.height; } - nscoord& Width(WritingMode aWritingMode) - { - CHECK_WRITING_MODE(aWritingMode); - return aWritingMode.IsVertical() ? BSize() : ISize(); - } - nscoord& Height(WritingMode aWritingMode) - { - CHECK_WRITING_MODE(aWritingMode); - return aWritingMode.IsVertical() ? ISize() : BSize(); - } - /** * Return an nsSize containing our physical dimensions */ @@ -978,7 +935,7 @@ public: // optimization for non-DEBUG builds where LogicalSize doesn't store // the writing mode return (aToMode == aFromMode || !aToMode.IsOrthogonalTo(aFromMode)) - ? *this : LogicalSize(aToMode, BSize(), ISize()); + ? *this : LogicalSize(aToMode, BSize(), ISize()); #endif } @@ -1241,49 +1198,23 @@ public: mMargin.SizeTo(aBStart, aIEnd, aBEnd, aIStart); } - nscoord& Top(WritingMode aWritingMode) - { - CHECK_WRITING_MODE(aWritingMode); - return aWritingMode.IsVertical() ? - (aWritingMode.IsBidiLTR() ? IStart() : IEnd()) : BStart(); - } - - nscoord& Bottom(WritingMode aWritingMode) - { - CHECK_WRITING_MODE(aWritingMode); - return aWritingMode.IsVertical() ? - (aWritingMode.IsBidiLTR() ? IEnd() : IStart()) : BEnd(); - } - - nscoord& Left(WritingMode aWritingMode) - { - CHECK_WRITING_MODE(aWritingMode); - return aWritingMode.IsVertical() ? - (aWritingMode.IsVerticalLR() ? BStart() : BEnd()) : - (aWritingMode.IsBidiLTR() ? IStart() : IEnd()); - } - - nscoord& Right(WritingMode aWritingMode) - { - CHECK_WRITING_MODE(aWritingMode); - return aWritingMode.IsVertical() ? - (aWritingMode.IsVerticalLR() ? BEnd() : BStart()) : - (aWritingMode.IsBidiLTR() ? IEnd() : IStart()); - } - /** * Return an nsMargin containing our physical coordinates */ nsMargin GetPhysicalMargin(WritingMode aWritingMode) const { CHECK_WRITING_MODE(aWritingMode); - return aWritingMode.IsVertical() ? - (aWritingMode.IsVerticalLR() ? - nsMargin(IStart(), BEnd(), IEnd(), BStart()) : - nsMargin(IStart(), BStart(), IEnd(), BEnd())) : - (aWritingMode.IsBidiLTR() ? - nsMargin(BStart(), IEnd(), BEnd(), IStart()) : - nsMargin(BStart(), IStart(), BEnd(), IEnd())); + return aWritingMode.IsVertical() + ? (aWritingMode.IsVerticalLR() + ? (aWritingMode.IsBidiLTR() + ? nsMargin(IStart(), BEnd(), IEnd(), BStart()) + : nsMargin(IEnd(), BEnd(), IStart(), BStart())) + : (aWritingMode.IsBidiLTR() + ? nsMargin(IStart(), BStart(), IEnd(), BEnd()) + : nsMargin(IEnd(), BStart(), IStart(), BEnd()))) + : (aWritingMode.IsBidiLTR() + ? nsMargin(BStart(), IEnd(), BEnd(), IStart()) + : nsMargin(BStart(), IStart(), BEnd(), IEnd())); } /** @@ -1442,28 +1373,23 @@ public: LogicalRect(WritingMode aWritingMode, const nsRect& aRect, - nscoord aContainerWidth) + const nsSize& aContainerSize) #ifdef DEBUG : mWritingMode(aWritingMode) #endif { if (aWritingMode.IsVertical()) { - if (aWritingMode.IsVerticalLR()) { - mRect.y = aRect.x; - } else { - mRect.y = aContainerWidth - aRect.XMost(); - } + mRect.y = aWritingMode.IsVerticalLR() + ? aRect.x : aContainerSize.width - aRect.XMost(); + mRect.x = aWritingMode.IsBidiLTR() + ? aRect.y : aContainerSize.height - aRect.YMost(); mRect.height = aRect.width; - mRect.x = aRect.y; mRect.width = aRect.height; } else { - if (aWritingMode.IsBidiLTR()) { - mRect.x = aRect.x; - } else { - mRect.x = aContainerWidth - aRect.XMost(); - } - mRect.width = aRect.width; + mRect.x = aWritingMode.IsBidiLTR() + ? aRect.x : aContainerSize.width - aRect.XMost(); mRect.y = aRect.y; + mRect.width = aRect.width; mRect.height = aRect.height; } } @@ -1531,25 +1457,27 @@ public: /** * Accessors for line-relative coordinates */ - nscoord LineLeft(WritingMode aWritingMode, nscoord aContainerWidth) const + nscoord LineLeft(WritingMode aWritingMode, + const nsSize& aContainerSize) const { CHECK_WRITING_MODE(aWritingMode); - if (aWritingMode.IsVertical()) { - return IStart(); // sideways-left will require aContainerHeight - } else { - return aWritingMode.IsBidiLTR() ? IStart() - : aContainerWidth - IEnd(); + if (aWritingMode.IsBidiLTR()) { + return IStart(); } + nscoord containerISize = + aWritingMode.IsVertical() ? aContainerSize.height : aContainerSize.width; + return containerISize - IEnd(); } - nscoord LineRight(WritingMode aWritingMode, nscoord aContainerWidth) const + nscoord LineRight(WritingMode aWritingMode, + const nsSize& aContainerSize) const { CHECK_WRITING_MODE(aWritingMode); - if (aWritingMode.IsVertical()) { - return IEnd(); // sideways-left will require aContainerHeight - } else { - return aWritingMode.IsBidiLTR() ? IEnd() - : aContainerWidth - IStart(); + if (aWritingMode.IsBidiLTR()) { + return IEnd(); } + nscoord containerISize = + aWritingMode.IsVertical() ? aContainerSize.height : aContainerSize.width; + return containerISize - IStart(); } /** @@ -1567,37 +1495,14 @@ public: } } - void SetX(WritingMode aWritingMode, nscoord aX, nscoord aContainerWidth) + nscoord Y(WritingMode aWritingMode, nscoord aContainerHeight) const { CHECK_WRITING_MODE(aWritingMode); if (aWritingMode.IsVertical()) { - if (aWritingMode.IsVerticalLR()) { - BStart() = aX; - } else { - BStart() = aContainerWidth - aX - BSize(); - } + return aWritingMode.IsBidiLTR() ? mRect.X() + : aContainerHeight - mRect.XMost(); } else { - if (aWritingMode.IsBidiLTR()) { - IStart() = aX; - } else { - IStart() = aContainerWidth - aX - ISize(); - } - } - } - - nscoord Y(WritingMode aWritingMode) const - { - CHECK_WRITING_MODE(aWritingMode); - return aWritingMode.IsVertical() ? mRect.X() : mRect.Y(); - } - - void SetY(WritingMode aWritingMode, nscoord aY) - { - CHECK_WRITING_MODE(aWritingMode); - if (aWritingMode.IsVertical()) { - IStart() = aY; - } else { - BStart() = aY; + return mRect.Y(); } } @@ -1607,41 +1512,12 @@ public: return aWritingMode.IsVertical() ? mRect.Height() : mRect.Width(); } - // When setting the Width of a rect, we keep its physical X-coord fixed - // and modify XMax. This means that in the RTL case, we'll be moving - // the IStart, so that IEnd remains constant. - void SetWidth(WritingMode aWritingMode, nscoord aWidth) - { - CHECK_WRITING_MODE(aWritingMode); - if (aWritingMode.IsVertical()) { - if (!aWritingMode.IsVerticalLR()) { - BStart() = BStart() + BSize() - aWidth; - } - BSize() = aWidth; - } else { - if (!aWritingMode.IsBidiLTR()) { - IStart() = IStart() + ISize() - aWidth; - } - ISize() = aWidth; - } - } - nscoord Height(WritingMode aWritingMode) const { CHECK_WRITING_MODE(aWritingMode); return aWritingMode.IsVertical() ? mRect.Width() : mRect.Height(); } - void SetHeight(WritingMode aWritingMode, nscoord aHeight) - { - CHECK_WRITING_MODE(aWritingMode); - if (aWritingMode.IsVertical()) { - ISize() = aHeight; - } else { - BSize() = aHeight; - } - } - nscoord XMost(WritingMode aWritingMode, nscoord aContainerWidth) const { CHECK_WRITING_MODE(aWritingMode); @@ -1654,10 +1530,15 @@ public: } } - nscoord YMost(WritingMode aWritingMode) const + nscoord YMost(WritingMode aWritingMode, nscoord aContainerHeight) const { CHECK_WRITING_MODE(aWritingMode); - return aWritingMode.IsVertical() ? mRect.XMost() : mRect.YMost(); + if (aWritingMode.IsVertical()) { + return aWritingMode.IsBidiLTR() ? mRect.XMost() + : aContainerHeight - mRect.x; + } else { + return mRect.YMost(); + } } bool IsEmpty() const @@ -1759,19 +1640,21 @@ public: /** * Return an nsRect containing our physical coordinates within the given - * container width + * container size. */ nsRect GetPhysicalRect(WritingMode aWritingMode, - nscoord aContainerWidth) const + const nsSize& aContainerSize) const { CHECK_WRITING_MODE(aWritingMode); if (aWritingMode.IsVertical()) { - return nsRect(aWritingMode.IsVerticalLR() ? - BStart() : aContainerWidth - BEnd(), - IStart(), BSize(), ISize()); + return nsRect(aWritingMode.IsVerticalLR() + ? BStart() : aContainerSize.width - BEnd(), + aWritingMode.IsBidiLTR() + ? IStart() : aContainerSize.height - IEnd(), + BSize(), ISize()); } else { - return nsRect(aWritingMode.IsBidiLTR() ? - IStart() : aContainerWidth - IEnd(), + return nsRect(aWritingMode.IsBidiLTR() + ? IStart() : aContainerSize.width - IEnd(), BStart(), ISize(), BSize()); } } @@ -1780,12 +1663,12 @@ public: * Return a LogicalRect representing this rect in a different writing mode */ LogicalRect ConvertTo(WritingMode aToMode, WritingMode aFromMode, - nscoord aContainerWidth) const + const nsSize& aContainerSize) const { CHECK_WRITING_MODE(aFromMode); return aToMode == aFromMode ? - *this : LogicalRect(aToMode, GetPhysicalRect(aFromMode, aContainerWidth), - aContainerWidth); + *this : LogicalRect(aToMode, GetPhysicalRect(aFromMode, aContainerSize), + aContainerSize); } /** diff --git a/layout/generic/nsAbsoluteContainingBlock.cpp b/layout/generic/nsAbsoluteContainingBlock.cpp index 98064442be..521a0cbc03 100644 --- a/layout/generic/nsAbsoluteContainingBlock.cpp +++ b/layout/generic/nsAbsoluteContainingBlock.cpp @@ -408,7 +408,7 @@ nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegat // 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.width).BStart(wm) <= + && (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 @@ -468,12 +468,8 @@ nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegat margin.BStart(outerWM), kidSize.ISize(outerWM), kidSize.BSize(outerWM)); nsRect r = - rect.GetPhysicalRect(outerWM, logicalCBSize.Width(wm) + - border.LeftRight(outerWM)); - // XXX hack to correct for lack of bidi support in vertical mode - if (outerWM.IsVertical() && !outerWM.IsBidiLTR()) { - r.y = logicalCBSize.Height(wm) + border.TopBottom(outerWM) - r.YMost(); - } + 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 diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index 324700e7f7..383657c356 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -1277,9 +1277,9 @@ nsBlockFrame::Reflow(nsPresContext* aPresContext, // bullets that are placed next to a child block (bug 92896) // Tall bullets won't look particularly nice here... - LogicalRect bbox = bullet->GetLogicalRect(wm, metrics.Width()); + LogicalRect bbox = bullet->GetLogicalRect(wm, metrics.PhysicalSize()); bbox.BStart(wm) = position.mBaseline - metrics.BlockStartAscent(); - bullet->SetRect(wm, bbox, metrics.Width()); + bullet->SetRect(wm, bbox, metrics.PhysicalSize()); } // Otherwise just leave the bullet where it is, up against our // block-start padding. @@ -1292,12 +1292,11 @@ nsBlockFrame::Reflow(nsPresContext* aPresContext, ComputeFinalSize(*reflowState, state, aMetrics, &blockEndEdgeOfChildren); // If the block direction is right-to-left, we need to update the bounds of - // lines that were placed relative to mContainerWidth during reflow, as - // we typically do not know the true container width (block-dir size of the - // finished paragraph/block) until we've reflowed all its children. So we - // use a "fake" mContainerWidth during reflow (see nsBlockReflowState's - // constructor) and then fix up the positions of the lines here, once the - // final block size is known. + // lines that were placed relative to mContainerSize during reflow, as + // we typically do not know the true container size until we've reflowed all + // its children. So we use a dummy mContainerSize during reflow (see + // nsBlockReflowState's constructor) and then fix up the positions of the + // lines here, once the final block size is known. // // Note that writing-mode:vertical-rl is the only case where the block // logical direction progresses in a negative physical direction, and @@ -1305,12 +1304,12 @@ nsBlockFrame::Reflow(nsPresContext* aPresContext, // of the coordinate space in order to translate between the logical and // physical origins. if (wm.IsVerticalRL()) { - nscoord containerWidth = aMetrics.Width(); - nscoord deltaX = containerWidth - state.ContainerWidth(); - if (deltaX) { + nsSize containerSize = aMetrics.PhysicalSize(); + nscoord deltaX = containerSize.width - state.ContainerSize().width; + if (deltaX != 0) { for (line_iterator line = begin_lines(), end = end_lines(); line != end; line++) { - UpdateLineContainerWidth(line, containerWidth); + UpdateLineContainerSize(line, containerSize); } for (nsIFrame* f : mFloats) { nsPoint physicalDelta(deltaX, 0); @@ -1966,9 +1965,9 @@ nsBlockFrame::PropagateFloatDamage(nsBlockReflowState& aState, // Scrollable overflow should be sufficient for things that affect // layout. WritingMode wm = aState.mReflowState.GetWritingMode(); - nscoord containerWidth = aState.ContainerWidth(); + nsSize containerSize = aState.ContainerSize(); LogicalRect overflow = aLine->GetOverflowArea(eScrollableOverflow, wm, - containerWidth); + containerSize); nscoord lineBCoordCombinedBefore = overflow.BStart(wm) + aDeltaBCoord; nscoord lineBCoordCombinedAfter = lineBCoordCombinedBefore + overflow.BSize(wm); @@ -2209,11 +2208,11 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState) PropagateFloatDamage(aState, line, deltaBCoord); } - // If the container width has changed reset the container width. If the + // If the container size has changed, reset mContainerSize. If the // line's writing mode is not ltr, or if the line is not left-aligned, also // mark the line dirty. - if (aState.ContainerWidth() != line->mContainerWidth) { - line->mContainerWidth = aState.ContainerWidth(); + if (aState.ContainerSize() != line->mContainerSize) { + line->mContainerSize = aState.ContainerSize(); bool isLastLine = line == mLines.back() && !GetNextInFlow() && @@ -2850,26 +2849,26 @@ nsBlockFrame::SlideLine(nsBlockReflowState& aState, NS_PRECONDITION(aDeltaBCoord != 0, "why slide a line nowhere?"); // Adjust line state - aLine->SlideBy(aDeltaBCoord, aState.ContainerWidth()); + aLine->SlideBy(aDeltaBCoord, aState.ContainerSize()); // Adjust the frames in the line MoveChildFramesOfLine(aLine, aDeltaBCoord); } void -nsBlockFrame::UpdateLineContainerWidth(nsLineBox* aLine, - nscoord aNewContainerWidth) +nsBlockFrame::UpdateLineContainerSize(nsLineBox* aLine, + const nsSize& aNewContainerSize) { - if (aNewContainerWidth == aLine->mContainerWidth) { + if (aNewContainerSize == aLine->mContainerSize) { return; } // Adjust line state - nscoord widthDelta = aLine->UpdateContainerWidth(aNewContainerWidth); + nsSize sizeDelta = aLine->UpdateContainerSize(aNewContainerSize); // Changing container width only matters if writing mode is vertical-rl if (GetWritingMode().IsVerticalRL()) { - MoveChildFramesOfLine(aLine, widthDelta); + MoveChildFramesOfLine(aLine, sizeDelta.width); } } @@ -3828,7 +3827,7 @@ nsBlockFrame::DoReflowInlineFrames(nsBlockReflowState& aState, WritingMode lineWM = GetWritingMode(aLine->mFirstChild); LogicalRect lineRect = aFloatAvailableSpace.mRect.ConvertTo(lineWM, outerWM, - aState.ContainerWidth()); + aState.ContainerSize()); nscoord iStart = lineRect.IStart(lineWM); nscoord availISize = lineRect.ISize(lineWM); @@ -6301,14 +6300,14 @@ nsBlockFrame::ReflowPushedFloats(nsBlockReflowState& aState, void nsBlockFrame::RecoverFloats(nsFloatManager& aFloatManager, WritingMode aWM, - nscoord aContainerWidth) + const nsSize& aContainerSize) { // Recover our own floats nsIFrame* stop = nullptr; // Stop before we reach pushed floats that // belong to our next-in-flow for (nsIFrame* f = mFloats.FirstChild(); f && f != stop; f = f->GetNextSibling()) { - LogicalRect region = nsFloatManager::GetRegionFor(aWM, f, aContainerWidth); - aFloatManager.AddFloat(f, region, aWM, aContainerWidth); + LogicalRect region = nsFloatManager::GetRegionFor(aWM, f, aContainerSize); + aFloatManager.AddFloat(f, region, aWM, aContainerSize); if (!stop && f->GetNextInFlow()) stop = f->GetNextInFlow(); } @@ -6316,13 +6315,13 @@ nsBlockFrame::RecoverFloats(nsFloatManager& aFloatManager, WritingMode aWM, // Recurse into our overflow container children for (nsIFrame* oc = GetFirstChild(kOverflowContainersList); oc; oc = oc->GetNextSibling()) { - RecoverFloatsFor(oc, aFloatManager, aWM, aContainerWidth); + RecoverFloatsFor(oc, aFloatManager, aWM, aContainerSize); } // Recurse into our normal children for (nsBlockFrame::line_iterator line = begin_lines(); line != end_lines(); ++line) { if (line->IsBlock()) { - RecoverFloatsFor(line->mFirstChild, aFloatManager, aWM, aContainerWidth); + RecoverFloatsFor(line->mFirstChild, aFloatManager, aWM, aContainerSize); } } } @@ -6331,7 +6330,7 @@ void nsBlockFrame::RecoverFloatsFor(nsIFrame* aFrame, nsFloatManager& aFloatManager, WritingMode aWM, - nscoord aContainerWidth) + const nsSize& aContainerSize) { NS_PRECONDITION(aFrame, "null frame"); // Only blocks have floats @@ -6344,11 +6343,11 @@ nsBlockFrame::RecoverFloatsFor(nsIFrame* aFrame, // accordingly so that we consider relatively positioned frames // at their original position. - LogicalRect rect(aWM, block->GetNormalRect(), aContainerWidth); - nscoord lineLeft = rect.LineLeft(aWM, aContainerWidth); + LogicalRect rect(aWM, block->GetNormalRect(), aContainerSize); + nscoord lineLeft = rect.LineLeft(aWM, aContainerSize); nscoord blockStart = rect.BStart(aWM); aFloatManager.Translate(lineLeft, blockStart); - block->RecoverFloats(aFloatManager, aWM, aContainerWidth); + block->RecoverFloats(aFloatManager, aWM, aContainerSize); aFloatManager.Translate(-lineLeft, -blockStart); } } @@ -7204,7 +7203,7 @@ nsBlockFrame::ReflowBullet(nsIFrame* aBulletFrame, aBulletFrame->SetRect(wm, LogicalRect(wm, iStart, bStart, aMetrics.ISize(wm), aMetrics.BSize(wm)), - aState.ContainerWidth()); + aState.ContainerSize()); aBulletFrame->DidReflow(aState.mPresContext, &aState.mReflowState, nsDidReflowStatus::FINISHED); } diff --git a/layout/generic/nsBlockFrame.h b/layout/generic/nsBlockFrame.h index 411437ff98..7446f40f97 100644 --- a/layout/generic/nsBlockFrame.h +++ b/layout/generic/nsBlockFrame.h @@ -412,10 +412,10 @@ protected: void SlideLine(nsBlockReflowState& aState, nsLineBox* aLine, nscoord aDeltaBCoord); - void UpdateLineContainerWidth(nsLineBox* aLine, - nscoord aNewContainerWidth); + void UpdateLineContainerSize(nsLineBox* aLine, + const nsSize& aNewContainerSize); - // helper for SlideLine and UpdateLineContainerWidth + // helper for SlideLine and UpdateLineContainerSize void MoveChildFramesOfLine(nsLineBox* aLine, nscoord aDeltaBCoord); void ComputeFinalSize(const nsHTMLReflowState& aReflowState, @@ -492,7 +492,7 @@ public: static void RecoverFloatsFor(nsIFrame* aFrame, nsFloatManager& aFloatManager, mozilla::WritingMode aWM, - nscoord aContainerWidth); + const nsSize& aContainerSize); /** * Determine if we have any pushed floats from a previous continuation. @@ -564,7 +564,7 @@ protected: */ void RecoverFloats(nsFloatManager& aFloatManager, mozilla::WritingMode aWM, - nscoord aContainerWidth); + const nsSize& aContainerSize); /** Reflow pushed floats */ diff --git a/layout/generic/nsBlockReflowContext.cpp b/layout/generic/nsBlockReflowContext.cpp index 9a11caee60..169e703086 100644 --- a/layout/generic/nsBlockReflowContext.cpp +++ b/layout/generic/nsBlockReflowContext.cpp @@ -233,7 +233,7 @@ nsBlockReflowContext::ReflowBlock(const LogicalRect& aSpace, { mFrame = aFrameRS.frame; mWritingMode = aState.mReflowState.GetWritingMode(); - mContainerWidth = aState.ContainerWidth(); + mContainerSize = aState.ContainerSize(); mSpace = aSpace; if (!aIsAdjacentWithBStart) { @@ -283,7 +283,7 @@ nsBlockReflowContext::ReflowBlock(const LogicalRect& aSpace, usedMargin.IStartEnd(mWritingMode), mSpace.BSize(mWritingMode) - usedMargin.BStartEnd(mWritingMode)); - tI = space.LineLeft(mWritingMode, mContainerWidth); + tI = space.LineLeft(mWritingMode, mContainerSize); tB = mBCoord; if ((mFrame->GetStateBits() & NS_BLOCK_FLOAT_MGR) == 0) @@ -433,22 +433,23 @@ nsBlockReflowContext::PlaceBlock(const nsHTMLReflowState& aReflowState, aLine->SetBounds(mWritingMode, mICoord, mBCoord - backupContainingBlockAdvance, mMetrics.ISize(mWritingMode), mMetrics.BSize(mWritingMode), - mContainerWidth); + mContainerSize); WritingMode frameWM = mFrame->GetWritingMode(); LogicalPoint logPos = LogicalPoint(mWritingMode, mICoord, mBCoord). - ConvertTo(frameWM, mWritingMode, mContainerWidth - mMetrics.Width()); + ConvertTo(frameWM, mWritingMode, + mContainerSize - mMetrics.PhysicalSize()); // ApplyRelativePositioning in right-to-left writing modes needs to // know the updated frame width mFrame->SetSize(mWritingMode, mMetrics.Size(mWritingMode)); - aReflowState.ApplyRelativePositioning(&logPos, mContainerWidth); + aReflowState.ApplyRelativePositioning(&logPos, mContainerSize); // Now place the frame and complete the reflow process nsContainerFrame::FinishReflowChild(mFrame, mPresContext, mMetrics, &aReflowState, frameWM, logPos, - mContainerWidth, 0); + mContainerSize, 0); aOverflowAreas = mMetrics.mOverflowAreas + mFrame->GetPosition(); diff --git a/layout/generic/nsBlockReflowContext.h b/layout/generic/nsBlockReflowContext.h index 7afec5ae3a..248f877b55 100644 --- a/layout/generic/nsBlockReflowContext.h +++ b/layout/generic/nsBlockReflowContext.h @@ -83,7 +83,8 @@ protected: nsIFrame* mFrame; mozilla::LogicalRect mSpace; - nscoord mICoord, mBCoord, mContainerWidth; + nscoord mICoord, mBCoord; + nsSize mContainerSize; mozilla::WritingMode mWritingMode; nsHTMLReflowMetrics mMetrics; nsCollapsingMargin mBStartMargin; diff --git a/layout/generic/nsBlockReflowState.cpp b/layout/generic/nsBlockReflowState.cpp index 75816d7bbd..f880b1fba1 100644 --- a/layout/generic/nsBlockReflowState.cpp +++ b/layout/generic/nsBlockReflowState.cpp @@ -349,7 +349,7 @@ nsBlockReflowState::GetFloatAvailableSpaceWithState( nsFlowAreaRect result = mFloatManager->GetFlowArea(wm, aBCoord, nsFloatManager::BAND_FROM_POINT, blockSize, mContentArea, aState, - ContainerWidth()); + ContainerSize()); // Keep the inline size >= 0 for compatibility with nsSpaceManager. if (result.mRect.ISize(wm) < 0) { result.mRect.ISize(wm) = 0; @@ -382,7 +382,7 @@ nsBlockReflowState::GetFloatAvailableSpaceForBSize( #endif nsFlowAreaRect result = mFloatManager->GetFlowArea(wm, aBCoord, nsFloatManager::WIDTH_WITHIN_HEIGHT, - aBSize, mContentArea, aState, ContainerWidth()); + aBSize, mContentArea, aState, ContainerSize()); // Keep the width >= 0 for compatibility with nsSpaceManager. if (result.mRect.ISize(wm) < 0) { result.mRect.ISize(wm) = 0; @@ -506,7 +506,7 @@ nsBlockReflowState::RecoverFloats(nsLineList::iterator aLine, tI, tB, mFloatManagerI, mFloatManagerB); nsFrame::ListTag(stdout, floatFrame); LogicalRect region = nsFloatManager::GetRegionFor(wm, floatFrame, - ContainerWidth()); + ContainerSize()); printf(" aDeltaBCoord=%d region={%d,%d,%d,%d}\n", aDeltaBCoord, region.IStart(wm), region.BStart(wm), region.ISize(wm), region.BSize(wm)); @@ -514,13 +514,13 @@ nsBlockReflowState::RecoverFloats(nsLineList::iterator aLine, #endif mFloatManager->AddFloat(floatFrame, nsFloatManager::GetRegionFor(wm, floatFrame, - ContainerWidth()), - wm, ContainerWidth()); + ContainerSize()), + wm, ContainerSize()); fc = fc->Next(); } } else if (aLine->IsBlock()) { nsBlockFrame::RecoverFloatsFor(aLine->mFirstChild, *mFloatManager, wm, - ContainerWidth()); + ContainerSize()); } } @@ -727,7 +727,7 @@ nsBlockReflowState::FlowAndPlaceFloat(nsIFrame* aFloat) // The float's old region, so we can propagate damage. LogicalRect oldRegion = nsFloatManager::GetRegionFor(wm, aFloat, - ContainerWidth()); + ContainerSize()); // Enforce CSS2 9.5.1 rule [2], i.e., make sure that a float isn't // ``above'' another float that preceded it in the flow. @@ -877,7 +877,9 @@ nsBlockReflowState::FlowAndPlaceFloat(nsIFrame* aFloat) // LineLeft() and LineRight() here, because we would only have to // convert the result back into this block's writing mode. LogicalPoint floatPos(wm); - if ((NS_STYLE_FLOAT_LEFT == floatDisplay->mFloats) == wm.IsBidiLTR()) { + bool leftFloat = NS_STYLE_FLOAT_LEFT == floatDisplay->mFloats; + + if (leftFloat == wm.IsBidiLTR()) { floatPos.I(wm) = floatAvailableSpace.mRect.IStart(wm); } else { @@ -952,14 +954,14 @@ nsBlockReflowState::FlowAndPlaceFloat(nsIFrame* aFloat) // If float is relatively positioned, factor that in as well nsHTMLReflowState::ApplyRelativePositioning(aFloat, wm, floatOffsets, - &origin, ContainerWidth()); + &origin, ContainerSize()); // 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->GetLogicalPosition(wm, ContainerWidth()) != origin; + bool moved = aFloat->GetLogicalPosition(wm, ContainerSize()) != origin; if (moved) { - aFloat->SetPosition(wm, origin, ContainerWidth()); + aFloat->SetPosition(wm, origin, ContainerSize()); nsContainerFrame::PositionFrameView(aFloat); nsContainerFrame::PositionChildViews(aFloat); } @@ -973,7 +975,7 @@ nsBlockReflowState::FlowAndPlaceFloat(nsIFrame* aFloat) // calculate region LogicalRect region = nsFloatManager::CalculateRegionFor(wm, aFloat, floatMargin, - ContainerWidth()); + ContainerSize()); // if the float split, then take up all of the vertical height if (NS_FRAME_IS_NOT_COMPLETE(reflowStatus) && (NS_UNCONSTRAINEDSIZE != ContentBSize())) { @@ -981,10 +983,10 @@ nsBlockReflowState::FlowAndPlaceFloat(nsIFrame* aFloat) ContentBSize() - floatPos.B(wm)); } DebugOnly rv = mFloatManager->AddFloat(aFloat, region, wm, - ContainerWidth()); + ContainerSize()); MOZ_ASSERT(NS_SUCCEEDED(rv), "bad float placement"); // store region - nsFloatManager::StoreRegionFor(wm, aFloat, region, ContainerWidth()); + nsFloatManager::StoreRegionFor(wm, aFloat, region, ContainerSize()); // If the float's dimensions have changed, note the damage in the // float manager. diff --git a/layout/generic/nsBlockReflowState.h b/layout/generic/nsBlockReflowState.h index 370c87af1a..e3574a3d15 100644 --- a/layout/generic/nsBlockReflowState.h +++ b/layout/generic/nsBlockReflowState.h @@ -233,8 +233,7 @@ public: // Physical size. Use only for physical <-> logical coordinate conversion. nsSize mContainerSize; - nscoord ContainerWidth() const { return mContainerSize.width; } - nscoord ContainerHeight() const { return mContainerSize.height; } + const nsSize& ContainerSize() const { return mContainerSize; } // Continuation out-of-flow float frames that need to move to our // next in flow are placed here during reflow. It's a pointer to diff --git a/layout/generic/nsCanvasFrame.cpp b/layout/generic/nsCanvasFrame.cpp index eb6ef63434..5738091c28 100644 --- a/layout/generic/nsCanvasFrame.cpp +++ b/layout/generic/nsCanvasFrame.cpp @@ -661,20 +661,20 @@ nsCanvasFrame::Reflow(nsPresContext* aPresContext, WritingMode wm = aReflowState.GetWritingMode(); WritingMode kidWM = kidReflowState.GetWritingMode(); - nscoord containerWidth = aReflowState.ComputedWidth(); + nsSize containerSize = aReflowState.ComputedPhysicalSize(); LogicalMargin margin = kidReflowState.ComputedLogicalMargin(); LogicalPoint kidPt(kidWM, margin.IStart(kidWM), margin.BStart(kidWM)); - kidReflowState.ApplyRelativePositioning(&kidPt, containerWidth); + kidReflowState.ApplyRelativePositioning(&kidPt, containerSize); // Reflow the frame ReflowChild(kidFrame, aPresContext, kidDesiredSize, kidReflowState, - kidWM, kidPt, containerWidth, 0, aStatus); + kidWM, kidPt, containerSize, 0, aStatus); // Complete the reflow and position and size the child frame FinishReflowChild(kidFrame, aPresContext, kidDesiredSize, &kidReflowState, - kidWM, kidPt, containerWidth, 0); + kidWM, kidPt, containerSize, 0); if (!NS_FRAME_IS_FULLY_COMPLETE(aStatus)) { nsIFrame* nextFrame = kidFrame->GetNextInFlow(); diff --git a/layout/generic/nsColumnSetFrame.cpp b/layout/generic/nsColumnSetFrame.cpp index fbebf744fd..c9f560145f 100644 --- a/layout/generic/nsColumnSetFrame.cpp +++ b/layout/generic/nsColumnSetFrame.cpp @@ -360,13 +360,13 @@ nsColumnSetFrame::ReflowColumns(nsHTMLReflowMetrics& aDesiredSize, } static void MoveChildTo(nsIFrame* aChild, LogicalPoint aOrigin, - WritingMode aWM, nscoord aContainerWidth) + WritingMode aWM, const nsSize& aContainerSize) { - if (aChild->GetLogicalPosition(aWM, aContainerWidth) == aOrigin) { + if (aChild->GetLogicalPosition(aWM, aContainerSize) == aOrigin) { return; } - aChild->SetPosition(aWM, aOrigin, aContainerWidth); + aChild->SetPosition(aWM, aOrigin, aContainerSize); nsContainerFrame::PlaceFrameView(aChild); } @@ -488,10 +488,11 @@ nsColumnSetFrame::ReflowChildren(nsHTMLReflowMetrics& aDesiredSize, nsIFrame* child = mFrames.FirstChild(); 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(); + // In vertical-rl mode, columns will not be correctly placed if the + // reflowState's ComputedWidth() is UNCONSTRAINED (in which case we'll get + // a containerSize.width of zero here). In that case, the column positions + // will be adjusted later, after our correct contentSize is known. + nsSize containerSize = aReflowState.ComputedSizeAsContainerIfConstrained(); // 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 @@ -506,7 +507,8 @@ nsColumnSetFrame::ReflowChildren(nsHTMLReflowMetrics& aDesiredSize, availISize = aReflowState.ComputedISize(); } if (availISize != NS_INTRINSICSIZE) { - childOrigin.I(wm) = containerWidth - borderPadding.Left(wm) - availISize; + childOrigin.I(wm) = containerSize.width - borderPadding.Left(wm) - + availISize; #ifdef DEBUG_roc printf("*** childOrigin.iCoord = %d\n", childOrigin.I(wm)); #endif @@ -567,7 +569,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(child, childOrigin, wm, containerWidth); + MoveChildTo(child, childOrigin, wm, containerSize); // If this is the last frame then make sure we get the right status nsIFrame* kidNext = child->GetNextSibling(); @@ -634,7 +636,7 @@ nsColumnSetFrame::ReflowChildren(nsHTMLReflowMetrics& aDesiredSize, childOrigin.B(wm) + kidReflowState.ComputedLogicalMargin().BStart(wm)); ReflowChild(child, PresContext(), kidDesiredSize, kidReflowState, - wm, origin, containerWidth, 0, aStatus); + wm, origin, containerSize, 0, aStatus); reflowNext = (aStatus & NS_FRAME_REFLOW_NEXTINFLOW) != 0; @@ -649,7 +651,7 @@ nsColumnSetFrame::ReflowChildren(nsHTMLReflowMetrics& aDesiredSize, *aCarriedOutBEndMargin = kidDesiredSize.mCarriedOutBEndMargin; FinishReflowChild(child, PresContext(), kidDesiredSize, - &kidReflowState, wm, childOrigin, containerWidth, 0); + &kidReflowState, wm, childOrigin, containerSize, 0); childContentBEnd = nsLayoutUtils::CalculateContentBEnd(wm, child); if (childContentBEnd > aConfig.mColMaxBSize) { @@ -801,17 +803,17 @@ 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(); + // In vertical-rl mode, make a second pass if necessary to reposition the + // columns with the correct container width. (In other writing modes, + // correct containerSize was not required for column positioning so we don't + // need this fixup.) + if (wm.IsVerticalRL() && containerSize.width != contentSize.Width(wm)) { + const nsSize finalContainerSize = aDesiredSize.PhysicalSize(); + for (nsIFrame* child : mFrames) { + // Get the logical position as set previously using a provisional or + // dummy containerSize, and reset with the correct container size. + child->SetPosition(wm, child->GetLogicalPosition(wm, containerSize), + finalContainerSize); } } diff --git a/layout/generic/nsContainerFrame.cpp b/layout/generic/nsContainerFrame.cpp index 9e0deeb645..71aaf91291 100644 --- a/layout/generic/nsContainerFrame.cpp +++ b/layout/generic/nsContainerFrame.cpp @@ -974,20 +974,20 @@ nsContainerFrame::ReflowChild(nsIFrame* aKidFrame, const nsHTMLReflowState& aReflowState, const WritingMode& aWM, const LogicalPoint& aPos, - nscoord aContainerWidth, + const nsSize& aContainerSize, uint32_t aFlags, nsReflowStatus& aStatus, nsOverflowContinuationTracker* aTracker) { NS_PRECONDITION(aReflowState.frame == aKidFrame, "bad reflow state"); if (aWM.IsVerticalRL() || (!aWM.IsVertical() && !aWM.IsBidiLTR())) { - NS_ASSERTION(aContainerWidth != NS_UNCONSTRAINEDSIZE, + NS_ASSERTION(aContainerSize.width != NS_UNCONSTRAINEDSIZE, "ReflowChild with unconstrained container width!"); } // Position the child frame and its view if requested. if (NS_FRAME_NO_MOVE_FRAME != (aFlags & NS_FRAME_NO_MOVE_FRAME)) { - aKidFrame->SetPosition(aWM, aPos, aContainerWidth); + aKidFrame->SetPosition(aWM, aPos, aContainerSize); } if (0 == (aFlags & NS_FRAME_NO_MOVE_VIEW)) { @@ -1114,11 +1114,11 @@ nsContainerFrame::FinishReflowChild(nsIFrame* aKidFrame, const nsHTMLReflowState* aReflowState, const WritingMode& aWM, const LogicalPoint& aPos, - nscoord aContainerWidth, + const nsSize& aContainerSize, uint32_t aFlags) { if (aWM.IsVerticalRL() || (!aWM.IsVertical() && !aWM.IsBidiLTR())) { - NS_ASSERTION(aContainerWidth != NS_UNCONSTRAINEDSIZE, + NS_ASSERTION(aContainerSize.width != NS_UNCONSTRAINEDSIZE, "FinishReflowChild with unconstrained container width!"); } @@ -1129,7 +1129,7 @@ nsContainerFrame::FinishReflowChild(nsIFrame* aKidFrame, if (NS_FRAME_NO_MOVE_FRAME != (aFlags & NS_FRAME_NO_MOVE_FRAME)) { aKidFrame->SetRect(aWM, LogicalRect(aWM, aPos, convertedSize), - aContainerWidth); + aContainerSize); } else { aKidFrame->SetSize(aWM, convertedSize); } @@ -1261,8 +1261,8 @@ nsContainerFrame::ReflowOverflowContainerChildren(nsPresContext* aPres NS_ASSERTION(frame->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER, "overflow container frame must have overflow container bit set"); WritingMode wm = frame->GetWritingMode(); - nscoord containerWidth = aReflowState.AvailableSize(wm).Width(wm); - LogicalRect prevRect = prevInFlow->GetLogicalRect(wm, containerWidth); + nsSize containerSize = aReflowState.AvailableSize(wm).GetPhysicalSize(wm); + LogicalRect prevRect = prevInFlow->GetLogicalRect(wm, containerSize); // Initialize reflow params LogicalSize availSpace(wm, prevRect.ISize(wm), @@ -1275,11 +1275,11 @@ nsContainerFrame::ReflowOverflowContainerChildren(nsPresContext* aPres // Reflow LogicalPoint pos(wm, prevRect.IStart(wm), 0); ReflowChild(frame, aPresContext, desiredSize, frameState, - wm, pos, containerWidth, aFlags, frameStatus, &tracker); + wm, pos, containerSize, aFlags, frameStatus, &tracker); //XXXfr Do we need to override any shrinkwrap effects here? // e.g. desiredSize.Width() = prevRect.width; FinishReflowChild(frame, aPresContext, desiredSize, &frameState, - wm, pos, containerWidth, aFlags); + wm, pos, containerSize, aFlags); // Handle continuations if (!NS_FRAME_IS_FULLY_COMPLETE(frameStatus)) { @@ -1321,7 +1321,7 @@ nsContainerFrame::ReflowOverflowContainerChildren(nsPresContext* aPres if (aReflowState.mFloatManager) { nsBlockFrame::RecoverFloatsFor(frame, *aReflowState.mFloatManager, aReflowState.GetWritingMode(), - aReflowState.ComputedWidth()); + aReflowState.ComputedPhysicalSize()); } } ConsiderChildOverflow(aOverflowRects, frame); diff --git a/layout/generic/nsContainerFrame.h b/layout/generic/nsContainerFrame.h index 2911361f0f..86dd4fbdde 100644 --- a/layout/generic/nsContainerFrame.h +++ b/layout/generic/nsContainerFrame.h @@ -241,7 +241,7 @@ public: * If the reflow status after reflowing the child is FULLY_COMPLETE then any * next-in-flows are deleted using DeleteNextInFlowChild(). * - * @param aContainerWidth width of the border-box of the containing frame + * @param aContainerSize size of the border-box of the containing frame * * Flags: * NS_FRAME_NO_MOVE_VIEW - don't position the frame's view. Set this if you @@ -255,7 +255,7 @@ public: const nsHTMLReflowState& aReflowState, const mozilla::WritingMode& aWM, const mozilla::LogicalPoint& aPos, - nscoord aContainerWidth, + const nsSize& aContainerSize, uint32_t aFlags, nsReflowStatus& aStatus, nsOverflowContinuationTracker* aTracker = nullptr); @@ -270,7 +270,7 @@ public: * - sets the view's visibility, opacity, content transparency, and clip * - invoked the DidReflow() function * - * @param aContainerWidth width of the border-box of the containing frame + * @param aContainerSize size of the border-box of the containing frame * * Flags: * NS_FRAME_NO_MOVE_FRAME - don't move the frame. aPos is ignored in this @@ -285,7 +285,7 @@ public: const nsHTMLReflowState* aReflowState, const mozilla::WritingMode& aWM, const mozilla::LogicalPoint& aPos, - nscoord aContainerWidth, + const nsSize& aContainerSize, uint32_t aFlags); //XXX temporary: hold on to a copy of the old physical versions of diff --git a/layout/generic/nsFlexContainerFrame.cpp b/layout/generic/nsFlexContainerFrame.cpp index 6995663641..15b97f5ba0 100644 --- a/layout/generic/nsFlexContainerFrame.cpp +++ b/layout/generic/nsFlexContainerFrame.cpp @@ -152,11 +152,13 @@ PhysicalCoordFromFlexRelativeCoord(nscoord aFlexRelativeCoord, (axisTracker_).IsCrossAxisHorizontal() ? (width_) : (height_) // Logical versions of helper-macros above: -#define GET_MAIN_COMPONENT_LOGICAL(axisTracker_, isize_, bsize_) \ - (axisTracker_).IsRowOriented() ? (isize_) : (bsize_) +#define GET_MAIN_COMPONENT_LOGICAL(axisTracker_, wm_, isize_, bsize_) \ + wm_.IsOrthogonalTo(axisTracker_.GetWritingMode()) != \ + (axisTracker_).IsRowOriented() ? (isize_) : (bsize_) -#define GET_CROSS_COMPONENT_LOGICAL(axisTracker_, inline_, block_) \ - (axisTracker_).IsRowOriented() ? (block_) : (inline_) +#define GET_CROSS_COMPONENT_LOGICAL(axisTracker_, wm_, isize_, bsize_) \ + wm_.IsOrthogonalTo(axisTracker_.GetWritingMode()) != \ + (axisTracker_).IsRowOriented() ? (bsize_) : (isize_) // Encapsulates our flex container's main & cross axes. class MOZ_STACK_CLASS nsFlexContainerFrame::FlexboxAxisTracker { @@ -180,6 +182,9 @@ public: } // XXXdholbert [END DEPRECATED] + // Returns the flex container's writing mode. + WritingMode GetWritingMode() const { return mWM; } + // Returns true if our main axis is in the reverse direction of our // writing mode's corresponding axis. (From 'flex-direction: *-reverse') bool IsMainAxisReversed() const { @@ -343,7 +348,11 @@ public: const FlexboxAxisTracker& aAxisTracker); // Simplified constructor, to be used only for generating "struts": - FlexItem(nsIFrame* aChildFrame, nscoord aCrossSize); + // (NOTE: This "strut" constructor uses the *container's* writing mode, which + // we'll use on this FlexItem instead of the child frame's real writing mode. + // This is fine - it doesn't matter what writing mode we use for a + // strut, since it won't render any content and we already know its size.) + FlexItem(nsIFrame* aChildFrame, nscoord aCrossSize, WritingMode aContainerWM); // Accessors nsIFrame* Frame() const { return mFrame; } @@ -376,10 +385,9 @@ public: // will matter more (& can be expanded/tested) once we officially support // logical directions & vertical writing-modes in flexbox, in bug 1079155 // or a dependency. - WritingMode wm = mFrame->GetWritingMode(); // Use GetFirstLineBaseline(), or just GetBaseline() if that fails. - if (!nsLayoutUtils::GetFirstLineBaseline(wm, mFrame, &mAscent)) { - mAscent = mFrame->GetLogicalBaseline(wm); + if (!nsLayoutUtils::GetFirstLineBaseline(mWM, mFrame, &mAscent)) { + mAscent = mFrame->GetLogicalBaseline(mWM); } } return mAscent; @@ -431,6 +439,7 @@ public: // visibility:collapse. bool IsStrut() const { return mIsStrut; } + WritingMode GetWritingMode() const { return mWM; } uint8_t GetAlignSelf() const { return mAlignSelf; } // Returns the flex factor (flex-grow or flex-shrink), depending on @@ -720,6 +729,7 @@ protected: // Does this item need to resolve a min-[width|height]:auto (in main-axis). bool mNeedsMinSizeAutoResolution; + const WritingMode mWM; // The flex item's writing mode. uint8_t mAlignSelf; // My "align-self" computed value (with "auto" // swapped out for parent"s "align-items" value, // in our constructor). @@ -1082,16 +1092,17 @@ nsFlexContainerFrame::GenerateFlexItemForChild( const nsStylePosition* stylePos = aChildFrame->StylePosition(); float flexGrow = stylePos->mFlexGrow; float flexShrink = stylePos->mFlexShrink; + WritingMode childWM = childRS.GetWritingMode(); // MAIN SIZES (flex base size, min/max size) // ----------------------------------------- - nscoord flexBaseSize = GET_MAIN_COMPONENT_LOGICAL(aAxisTracker, + nscoord flexBaseSize = GET_MAIN_COMPONENT_LOGICAL(aAxisTracker, childWM, childRS.ComputedISize(), childRS.ComputedBSize()); - nscoord mainMinSize = GET_MAIN_COMPONENT_LOGICAL(aAxisTracker, + nscoord mainMinSize = GET_MAIN_COMPONENT_LOGICAL(aAxisTracker, childWM, childRS.ComputedMinISize(), childRS.ComputedMinBSize()); - nscoord mainMaxSize = GET_MAIN_COMPONENT_LOGICAL(aAxisTracker, + nscoord mainMaxSize = GET_MAIN_COMPONENT_LOGICAL(aAxisTracker, childWM, childRS.ComputedMaxISize(), childRS.ComputedMaxBSize()); // This is enforced by the nsHTMLReflowState where these values come from: @@ -1103,15 +1114,15 @@ nsFlexContainerFrame::GenerateFlexItemForChild( // or we might resolve it to something else in SizeItemInCrossAxis(); hence, // it's tentative. See comment under "Cross Size Determination" for more. nscoord tentativeCrossSize = - GET_CROSS_COMPONENT_LOGICAL(aAxisTracker, + GET_CROSS_COMPONENT_LOGICAL(aAxisTracker, childWM, childRS.ComputedISize(), childRS.ComputedBSize()); nscoord crossMinSize = - GET_CROSS_COMPONENT_LOGICAL(aAxisTracker, + GET_CROSS_COMPONENT_LOGICAL(aAxisTracker, childWM, childRS.ComputedMinISize(), childRS.ComputedMinBSize()); nscoord crossMaxSize = - GET_CROSS_COMPONENT_LOGICAL(aAxisTracker, + GET_CROSS_COMPONENT_LOGICAL(aAxisTracker, childWM, childRS.ComputedMaxISize(), childRS.ComputedMaxBSize()); @@ -1232,7 +1243,7 @@ CrossSizeToUseWithRatio(const FlexItem& aFlexItem, if (IsCrossSizeDefinite(aItemReflowState, aAxisTracker)) { // Definite cross size. - return GET_CROSS_COMPONENT_LOGICAL(aAxisTracker, + return GET_CROSS_COMPONENT_LOGICAL(aAxisTracker, aFlexItem.GetWritingMode(), aItemReflowState.ComputedISize(), aItemReflowState.ComputedBSize()); } @@ -1240,7 +1251,7 @@ CrossSizeToUseWithRatio(const FlexItem& aFlexItem, if (aMinSizeFallback) { // Indefinite cross-size, and we're resolving main min-size, so we'll fall // back to ussing the cross min-size (which should be definite). - return GET_CROSS_COMPONENT_LOGICAL(aAxisTracker, + return GET_CROSS_COMPONENT_LOGICAL(aAxisTracker, aFlexItem.GetWritingMode(), aItemReflowState.ComputedMinISize(), aItemReflowState.ComputedMinBSize()); } @@ -1301,7 +1312,7 @@ PartiallyResolveAutoMinSize(const FlexItem& aFlexItem, // * the computed max-width (max-height), if that value is definite: nscoord maxSize = - GET_MAIN_COMPONENT_LOGICAL(aAxisTracker, + GET_MAIN_COMPONENT_LOGICAL(aAxisTracker, aFlexItem.GetWritingMode(), aItemReflowState.ComputedMaxISize(), aItemReflowState.ComputedMaxBSize()); if (maxSize != NS_UNCONSTRAINEDSIZE) { @@ -1404,7 +1415,7 @@ nsFlexContainerFrame:: // XXXdholbert Maybe this should share logic with ComputeCrossSize()... // Alternately, maybe tentative container cross size should be passed down. nscoord containerCrossSize = - GET_CROSS_COMPONENT_LOGICAL(aAxisTracker, + GET_CROSS_COMPONENT_LOGICAL(aAxisTracker, aAxisTracker.GetWritingMode(), flexContainerRS->ComputedISize(), flexContainerRS->ComputedBSize()); // Is container's cross size "definite"? @@ -1576,6 +1587,7 @@ FlexItem::FlexItem(nsHTMLReflowState& aFlexItemReflowState, mIsStretched(false), mIsStrut(false), // mNeedsMinSizeAutoResolution is initialized in CheckForMinSizeAuto() + mWM(aFlexItemReflowState.GetWritingMode()), mAlignSelf(aFlexItemReflowState.mStylePosition->mAlignSelf) { MOZ_ASSERT(mFrame, "expecting a non-null child frame"); @@ -1627,7 +1639,8 @@ FlexItem::FlexItem(nsHTMLReflowState& aFlexItemReflowState, // Simplified constructor for creating a special "strut" FlexItem, for a child // with visibility:collapse. The strut has 0 main-size, and it only exists to // impose a minimum cross size on whichever FlexLine it ends up in. -FlexItem::FlexItem(nsIFrame* aChildFrame, nscoord aCrossSize) +FlexItem::FlexItem(nsIFrame* aChildFrame, nscoord aCrossSize, + WritingMode aContainerWM) : mFrame(aChildFrame), mFlexGrow(0.0f), mFlexShrink(0.0f), @@ -1652,6 +1665,7 @@ FlexItem::FlexItem(nsIFrame* aChildFrame, nscoord aCrossSize) mIsStretched(false), mIsStrut(true), // (this is the constructor for making struts, after all) mNeedsMinSizeAutoResolution(false), + mWM(aContainerWM), mAlignSelf(NS_STYLE_ALIGN_ITEMS_FLEX_START) { MOZ_ASSERT(mFrame, "expecting a non-null child frame"); @@ -3178,7 +3192,7 @@ nsFlexContainerFrame::GenerateFlexLines( // least wrap when we hit its max main-size. if (wrapThreshold == NS_UNCONSTRAINEDSIZE) { const nscoord flexContainerMaxMainSize = - GET_MAIN_COMPONENT_LOGICAL(aAxisTracker, + GET_MAIN_COMPONENT_LOGICAL(aAxisTracker, aAxisTracker.GetWritingMode(), aReflowState.ComputedMaxISize(), aReflowState.ComputedMaxBSize()); @@ -3214,7 +3228,8 @@ nsFlexContainerFrame::GenerateFlexLines( aStruts[nextStrutIdx].mItemIdx == itemIdxInContainer) { // Use the simplified "strut" FlexItem constructor: - item = new FlexItem(childFrame, aStruts[nextStrutIdx].mStrutCrossSize); + item = new FlexItem(childFrame, aStruts[nextStrutIdx].mStrutCrossSize, + aReflowState.GetWritingMode()); nextStrutIdx++; } else { item = GenerateFlexItemForChild(aPresContext, childFrame, @@ -3899,9 +3914,12 @@ nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext, containerBP.IStart(flexWM), containerBP.BStart(flexWM)); - nscoord containerWidth = aAxisTracker.IsMainAxisHorizontal() ? - aContentBoxMainSize : contentBoxCrossSize; - containerWidth += aReflowState.ComputedPhysicalBorderPadding().LeftRight(); + // Determine flex container's border-box size (used in positioning children): + LogicalSize logSize = + aAxisTracker.LogicalSizeFromFlexRelativeSizes(aContentBoxMainSize, + contentBoxCrossSize); + logSize += aReflowState.ComputedLogicalBorderPadding().Size(flexWM); + nsSize containerSize = logSize.GetPhysicalSize(flexWM); // FINAL REFLOW: Give each child frame another chance to reflow, now that // we know its final size and position. @@ -3944,13 +3962,13 @@ nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext, // position. itemNeedsReflow = false; MoveFlexItemToFinalPosition(aReflowState, *item, framePos, - containerWidth); + containerSize); } } } if (itemNeedsReflow) { ReflowFlexItem(aPresContext, aAxisTracker, aReflowState, - *item, framePos, containerWidth); + *item, framePos, containerSize); } // If this is our first child and we haven't established a baseline for @@ -4035,7 +4053,7 @@ nsFlexContainerFrame::MoveFlexItemToFinalPosition( const nsHTMLReflowState& aReflowState, const FlexItem& aItem, LogicalPoint& aFramePos, - nscoord aContainerWidth) + const nsSize& aContainerSize) { WritingMode outerWM = aReflowState.GetWritingMode(); @@ -4051,8 +4069,8 @@ nsFlexContainerFrame::MoveFlexItemToFinalPosition( } nsHTMLReflowState::ApplyRelativePositioning(aItem.Frame(), outerWM, logicalOffsets, &aFramePos, - aContainerWidth); - aItem.Frame()->SetPosition(outerWM, aFramePos, aContainerWidth); + aContainerSize); + aItem.Frame()->SetPosition(outerWM, aFramePos, aContainerSize); PositionChildViews(aItem.Frame()); } @@ -4062,7 +4080,7 @@ nsFlexContainerFrame::ReflowFlexItem(nsPresContext* aPresContext, const nsHTMLReflowState& aReflowState, const FlexItem& aItem, LogicalPoint& aFramePos, - nscoord aContainerWidth) + const nsSize& aContainerSize) { WritingMode outerWM = aReflowState.GetWritingMode(); WritingMode wm = aItem.Frame()->GetWritingMode(); @@ -4136,7 +4154,7 @@ nsFlexContainerFrame::ReflowFlexItem(nsPresContext* aPresContext, nsReflowStatus childReflowStatus; ReflowChild(aItem.Frame(), aPresContext, childDesiredSize, childReflowState, - outerWM, aFramePos, aContainerWidth, + outerWM, aFramePos, aContainerSize, 0, childReflowStatus); // XXXdholbert Once we do pagination / splitting, we'll need to actually @@ -4151,11 +4169,11 @@ nsFlexContainerFrame::ReflowFlexItem(nsPresContext* aPresContext, childReflowState.ComputedLogicalOffsets().ConvertTo(outerWM, wm); nsHTMLReflowState::ApplyRelativePositioning(aItem.Frame(), outerWM, offsets, &aFramePos, - aContainerWidth); + aContainerSize); FinishReflowChild(aItem.Frame(), aPresContext, childDesiredSize, &childReflowState, - outerWM, aFramePos, aContainerWidth, 0); + outerWM, aFramePos, aContainerSize, 0); // Save the first child's ascent; it may establish container's baseline. if (aItem.Frame() == mFrames.FirstChild()) { diff --git a/layout/generic/nsFlexContainerFrame.h b/layout/generic/nsFlexContainerFrame.h index df1d11418c..ee24052c2c 100644 --- a/layout/generic/nsFlexContainerFrame.h +++ b/layout/generic/nsFlexContainerFrame.h @@ -183,13 +183,13 @@ protected: * @param aItem The flex item whose frame should be moved. * @param aFramePos The position where the flex item's frame should * be placed. (pre-relative positioning) - * @param aContainerWidth The flex container's width (required by some methods + * @param aContainerSize The flex container's size (required by some methods * that we call, to interpret aFramePos correctly). */ void MoveFlexItemToFinalPosition(const nsHTMLReflowState& aReflowState, const FlexItem& aItem, mozilla::LogicalPoint& aFramePos, - nscoord aContainerWidth); + const nsSize& aContainerSize); /** * Helper-function to reflow a child frame, at its final position determined * by flex layout. @@ -200,7 +200,7 @@ protected: * @param aItem The flex item to be reflowed. * @param aFramePos The position where the flex item's frame should * be placed. (pre-relative positioning) - * @param aContainerWidth The flex container's width (required by some methods + * @param aContainerSize The flex container's size (required by some methods * that we call, to interpret aFramePos correctly). */ void ReflowFlexItem(nsPresContext* aPresContext, @@ -208,7 +208,7 @@ protected: const nsHTMLReflowState& aReflowState, const FlexItem& aItem, mozilla::LogicalPoint& aFramePos, - nscoord aContainerWidth); + const nsSize& aContainerSize); bool mChildrenHaveBeenReordered; // Have we ever had to reorder our kids // to satisfy their 'order' values? diff --git a/layout/generic/nsFloatManager.cpp b/layout/generic/nsFloatManager.cpp index 3f5fe77f7b..0a69c1a42d 100644 --- a/layout/generic/nsFloatManager.cpp +++ b/layout/generic/nsFloatManager.cpp @@ -39,7 +39,10 @@ PSArenaFreeCB(size_t aSize, void* aPtr, void* aClosure) nsFloatManager::nsFloatManager(nsIPresShell* aPresShell, mozilla::WritingMode aWM) - : mWritingMode(aWM), + : +#ifdef DEBUG + mWritingMode(aWM), +#endif mLineLeft(0), mBlockStart(0), mFloatDamage(PSArenaAllocCB, PSArenaFreeCB, aPresShell), mPushedLeftFloatPastBreak(false), @@ -111,12 +114,17 @@ void nsFloatManager::Shutdown() sCachedFloatManagerCount = -1; } +#define CHECK_BLOCK_DIR(aWM) \ + NS_ASSERTION(aWM.GetBlockDir() == mWritingMode.value.GetBlockDir(), \ + "incompatible writing modes") + nsFlowAreaRect nsFloatManager::GetFlowArea(WritingMode aWM, nscoord aBOffset, BandInfoType aInfoType, nscoord aBSize, LogicalRect aContentArea, SavedState* aState, - nscoord aContainerWidth) const + const nsSize& aContainerSize) const { + CHECK_BLOCK_DIR(aWM); NS_ASSERTION(aBSize >= 0, "unexpected max block size"); NS_ASSERTION(aContentArea.ISize(aWM) >= 0, "unexpected content area inline size"); @@ -161,8 +169,8 @@ nsFloatManager::GetFlowArea(WritingMode aWM, nscoord aBOffset, blockEnd = nscoord_MAX; } } - nscoord lineLeft = mLineLeft + aContentArea.LineLeft(aWM, aContainerWidth); - nscoord lineRight = mLineLeft + aContentArea.LineRight(aWM, aContainerWidth); + nscoord lineLeft = mLineLeft + aContentArea.LineLeft(aWM, aContainerSize); + nscoord lineRight = mLineLeft + aContentArea.LineRight(aWM, aContainerSize); if (lineRight < lineLeft) { NS_WARNING("bad value"); lineRight = lineLeft; @@ -234,9 +242,10 @@ nsFloatManager::GetFlowArea(WritingMode aWM, nscoord aBOffset, nscoord blockSize = (blockEnd == nscoord_MAX) ? nscoord_MAX : (blockEnd - blockStart); // convert back from LineLeft/Right to IStart - nscoord inlineStart = aWM.IsVertical() || aWM.IsBidiLTR() - ? lineLeft - mLineLeft - : mLineLeft + aContainerWidth - lineRight; + nscoord inlineStart = aWM.IsBidiLTR() + ? lineLeft - mLineLeft + : mLineLeft - lineRight + + LogicalSize(aWM, aContainerSize).ISize(aWM); return nsFlowAreaRect(aWM, inlineStart, blockStart - mBlockStart, lineRight - lineLeft, blockSize, haveFloats); @@ -244,13 +253,14 @@ nsFloatManager::GetFlowArea(WritingMode aWM, nscoord aBOffset, nsresult nsFloatManager::AddFloat(nsIFrame* aFloatFrame, const LogicalRect& aMarginRect, - WritingMode aWM, nscoord aContainerWidth) + WritingMode aWM, const nsSize& aContainerSize) { + CHECK_BLOCK_DIR(aWM); NS_ASSERTION(aMarginRect.ISize(aWM) >= 0, "negative inline size!"); NS_ASSERTION(aMarginRect.BSize(aWM) >= 0, "negative block size!"); FloatInfo info(aFloatFrame, - aMarginRect.LineLeft(aWM, aContainerWidth) + mLineLeft, + aMarginRect.LineLeft(aWM, aContainerSize) + mLineLeft, aMarginRect.BStart(aWM) + mBlockStart, aMarginRect.ISize(aWM), aMarginRect.BSize(aWM)); @@ -284,12 +294,12 @@ LogicalRect nsFloatManager::CalculateRegionFor(WritingMode aWM, nsIFrame* aFloat, const LogicalMargin& aMargin, - nscoord aContainerWidth) + const nsSize& aContainerSize) { // We consider relatively positioned frames at their original position. LogicalRect region(aWM, nsRect(aFloat->GetNormalPosition(), aFloat->GetSize()), - aContainerWidth); + aContainerSize); // Float region includes its margin region.Inflate(aWM, aMargin); @@ -315,9 +325,9 @@ NS_DECLARE_FRAME_PROPERTY(FloatRegionProperty, DeleteValue) LogicalRect nsFloatManager::GetRegionFor(WritingMode aWM, nsIFrame* aFloat, - nscoord aContainerWidth) + const nsSize& aContainerSize) { - LogicalRect region = aFloat->GetLogicalRect(aWM, aContainerWidth); + LogicalRect region = aFloat->GetLogicalRect(aWM, aContainerSize); void* storedRegion = aFloat->Properties().Get(FloatRegionProperty()); if (storedRegion) { nsMargin margin = *static_cast(storedRegion); @@ -329,9 +339,9 @@ nsFloatManager::GetRegionFor(WritingMode aWM, nsIFrame* aFloat, void nsFloatManager::StoreRegionFor(WritingMode aWM, nsIFrame* aFloat, const LogicalRect& aRegion, - nscoord aContainerWidth) + const nsSize& aContainerSize) { - nsRect region = aRegion.GetPhysicalRect(aWM, aContainerWidth); + nsRect region = aRegion.GetPhysicalRect(aWM, aContainerSize); nsRect rect = aFloat->GetRect(); FrameProperties props = aFloat->Properties(); if (region.IsEqualEdges(rect)) { @@ -405,7 +415,6 @@ nsFloatManager::PushState(SavedState* aState) // reflow. In the typical case A and C will be the same, but not always. // Allowing mFloatDamage to accumulate the damage incurred during both // reflows ensures that nothing gets missed. - aState->mWritingMode = mWritingMode; aState->mLineLeft = mLineLeft; aState->mBlockStart = mBlockStart; aState->mPushedLeftFloatPastBreak = mPushedLeftFloatPastBreak; @@ -420,7 +429,6 @@ nsFloatManager::PopState(SavedState* aState) { NS_PRECONDITION(aState, "No state to restore?"); - mWritingMode = aState->mWritingMode; mLineLeft = aState->mLineLeft; mBlockStart = aState->mBlockStart; mPushedLeftFloatPastBreak = aState->mPushedLeftFloatPastBreak; diff --git a/layout/generic/nsFloatManager.h b/layout/generic/nsFloatManager.h index 07b5ab105e..a6c60adcf3 100644 --- a/layout/generic/nsFloatManager.h +++ b/layout/generic/nsFloatManager.h @@ -59,7 +59,7 @@ public: */ static mozilla::LogicalRect GetRegionFor(mozilla::WritingMode aWM, nsIFrame* aFloatFrame, - nscoord aContainerWidth); + const nsSize& aContainerSize); /** * Calculate the float region for this frame using aMargin and the * frame's mRect. The region includes the margins around the float, @@ -71,7 +71,7 @@ public: mozilla::WritingMode aWM, nsIFrame* aFloatFrame, const mozilla::LogicalMargin& aMargin, - nscoord aContainerWidth); + const nsSize& aContainerSize); /** * Store the float region on the frame. The region is stored * as a delta against the mRect, so repositioning the frame will @@ -80,7 +80,7 @@ public: static void StoreRegionFor(mozilla::WritingMode aWM, nsIFrame* aFloat, const mozilla::LogicalRect& aRegion, - nscoord aContainerWidth); + const nsSize& aContainerSize); // Structure that stores the current state of a frame manager for // Save/Restore purposes. @@ -88,7 +88,6 @@ public: explicit SavedState() {} private: uint32_t mFloatInfoCount; - mozilla::WritingMode mWritingMode; nscoord mLineLeft, mBlockStart; bool mPushedLeftFloatPastBreak; bool mPushedRightFloatPastBreak; @@ -163,7 +162,8 @@ public: nsFlowAreaRect GetFlowArea(mozilla::WritingMode aWM, nscoord aBCoord, BandInfoType aInfoType, nscoord aBSize, mozilla::LogicalRect aContentArea, - SavedState* aState, nscoord mContainerWidth) const; + SavedState* aState, + const nsSize& aContainerSize) const; /** * Add a float that comes after all floats previously added. Its @@ -175,7 +175,7 @@ public: */ nsresult AddFloat(nsIFrame* aFloatFrame, const mozilla::LogicalRect& aMarginRect, - mozilla::WritingMode aWM, nscoord aContainerWidth); + mozilla::WritingMode aWM, const nsSize& aContainerSize); /** * Notify that we tried to place a float that could not fit at all and @@ -287,8 +287,7 @@ public: void AssertStateMatches(SavedState *aState) const { - NS_ASSERTION(aState->mWritingMode == mWritingMode && - aState->mLineLeft == mLineLeft && + NS_ASSERTION(aState->mLineLeft == mLineLeft && aState->mBlockStart == mBlockStart && aState->mPushedLeftFloatPastBreak == mPushedLeftFloatPastBreak && @@ -343,7 +342,7 @@ private: nsRect mRect; }; - mozilla::WritingMode mWritingMode; + mozilla::DebugOnly mWritingMode; // Translation from local to global coordinate space. nscoord mLineLeft, mBlockStart; diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index f874d6f86b..fdac05e9e0 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -3586,13 +3586,19 @@ static FrameTarget GetSelectionClosestFrameForLine( nsIFrame *closestFromIStart = nullptr, *closestFromIEnd = nullptr; nscoord closestIStart = aLine->IStart(), closestIEnd = aLine->IEnd(); WritingMode wm = aLine->mWritingMode; - LogicalPoint pt(wm, aPoint, aLine->mContainerWidth); + LogicalPoint pt(wm, aPoint, aLine->mContainerSize); + bool canSkipBr = false; for (int32_t n = aLine->GetChildCount(); n; --n, frame = frame->GetNextSibling()) { - if (!SelfIsSelectable(frame, aFlags) || frame->IsEmpty()) + // Skip brFrames. Can only skip if the line contains at least + // one selectable and non-empty frame before + if (!SelfIsSelectable(frame, aFlags) || frame->IsEmpty() || + (canSkipBr && frame->GetType() == nsGkAtoms::brFrame)) { continue; + } + canSkipBr = true; LogicalRect frameRect = LogicalRect(wm, frame->GetRect(), - aLine->mContainerWidth); + aLine->mContainerSize); if (pt.I(wm) >= frameRect.IStart(wm)) { if (pt.I(wm) < frameRect.IEnd(wm)) { return GetSelectionClosestFrameForChild(frame, aPoint, aFlags); @@ -3650,7 +3656,7 @@ static FrameTarget GetSelectionClosestFrameForBlock(nsIFrame* aFrame, nsBlockFrame::line_iterator closestLine = end; // Convert aPoint into a LogicalPoint in the writing-mode of this block WritingMode wm = curLine->mWritingMode; - LogicalPoint pt(wm, aPoint, curLine->mContainerWidth); + LogicalPoint pt(wm, aPoint, curLine->mContainerSize); while (curLine != end) { // Check to see if our point lies within the line's block-direction bounds nscoord BCoord = pt.B(wm) - curLine->BStart(); @@ -4366,20 +4372,20 @@ nsFrame::ComputeSize(nsRenderingContext *aRenderingContext, GetMinimumWidgetSize(presContext, this, disp->mAppearance, &widget, &canOverride); - // Dimensions from themed widgets are applied physically... - nsSize size; - size.width = presContext->DevPixelsToAppUnits(widget.width); - size.height = presContext->DevPixelsToAppUnits(widget.height); + // Convert themed widget's physical dimensions to logical coords + LogicalSize size(aWM, + nsSize(presContext->DevPixelsToAppUnits(widget.width), + presContext->DevPixelsToAppUnits(widget.height))); // GMWS() returns border-box; we need content-box - size.width -= aBorder.Width(aWM) + aPadding.Width(aWM); - size.height -= aBorder.Height(aWM) + aPadding.Height(aWM); + size.ISize(aWM) -= aBorder.ISize(aWM) + aPadding.ISize(aWM); + size.BSize(aWM) -= aBorder.BSize(aWM) + aPadding.BSize(aWM); - if (size.height > result.Height(aWM) || !canOverride) { - result.Height(aWM) = size.height; + if (size.BSize(aWM) > result.BSize(aWM) || !canOverride) { + result.BSize(aWM) = size.BSize(aWM); } - if (size.width > result.Width(aWM) || !canOverride) { - result.Width(aWM) = size.width; + if (size.ISize(aWM) > result.ISize(aWM) || !canOverride) { + result.ISize(aWM) = size.ISize(aWM); } } @@ -5718,14 +5724,16 @@ nsIFrame::ListGeneric(nsACString& aTo, const char* aPrefix, uint32_t aFlags) con if (parent) { WritingMode pWM = parent->GetWritingMode(); if (pWM.IsVertical() || !pWM.IsBidiLTR()) { - nscoord cw = parent->mRect.width; - LogicalRect lr(pWM, mRect, cw); - aTo += nsPrintfCString(" parent wm=%s-%s,width=%d,logicalRect={%d,%d,%d,%d}", + nsSize containerSize = parent->mRect.Size(); + LogicalRect lr(pWM, mRect, containerSize); + aTo += nsPrintfCString(" parent wm=%s-%s, cs={%d,%d}, " + " logicalRect={%d,%d,%d,%d}", pWM.IsVertical() ? pWM.IsVerticalLR() ? "vlr" : "vrl" : "htb", wm.IsBidiLTR() ? "ltr" : "rtl", - cw, lr.IStart(pWM), lr.BStart(pWM), + containerSize.width, containerSize.height, + lr.IStart(pWM), lr.BStart(pWM), lr.ISize(pWM), lr.BSize(pWM)); } } @@ -6879,6 +6887,12 @@ nsIFrame::PeekOffset(nsPeekOffsetStruct* aPos) for (int32_t count = lineFrameCount; count; --count, frame = frame->GetNextSibling()) { if (!frame->IsGeneratedContentFrame()) { + // When jumping to the end of the line with the "end" key, + // skip over brFrames + if (endOfLine && lineFrameCount > 1 && + frame->GetType() == nsGkAtoms::brFrame) { + continue; + } baseFrame = frame; if (!endOfLine) break; @@ -7161,6 +7175,23 @@ nsIFrame::GetFrameFromDirection(nsDirection aDirection, bool aVisual, return NS_ERROR_FAILURE; } + // Skip brFrames, but only if they are not the only frame in the line + if (atLineEdge && aDirection == eDirPrevious && + traversedFrame->GetType() == nsGkAtoms::brFrame) { + int32_t lineFrameCount; + nsIFrame *currentBlockFrame, *currentFirstFrame; + nsRect usedRect; + int32_t currentLine = nsFrame::GetLineNumber(traversedFrame, aScrollViewStop, ¤tBlockFrame); + nsAutoLineIterator iter = currentBlockFrame->GetLineIterator(); + result = iter->GetLine(currentLine, ¤tFirstFrame, &lineFrameCount, usedRect); + if (NS_FAILED(result)) { + return result; + } + if (lineFrameCount > 1) { + continue; + } + } + traversedFrame->IsSelectable(&selectable, nullptr); if (!selectable) { *aOutMovedOverNonSelectableText = true; diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index 5a506859eb..a8165d892c 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -513,11 +513,12 @@ nsHTMLScrollFrame::ReflowScrolledFrame(ScrollReflowState* aState, mHelper.mHasVerticalScrollbar = aAssumeVScroll; nsReflowStatus status; - // No need to pass a container-width to ReflowChild or + // No need to pass a true container-size 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) + const nsSize dummyContainerSize; ReflowChild(mHelper.mScrolledFrame, presContext, *aMetrics, - kidReflowState, wm, LogicalPoint(wm), 0, + kidReflowState, wm, LogicalPoint(wm), dummyContainerSize, NS_FRAME_NO_MOVE_FRAME, status); mHelper.mHasHorizontalScrollbar = didHaveHorizontalScrollbar; @@ -529,7 +530,8 @@ 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, wm, LogicalPoint(wm), 0, + *aMetrics, &kidReflowState, wm, LogicalPoint(wm), + dummyContainerSize, NS_FRAME_NO_MOVE_FRAME | NS_FRAME_NO_SIZE_VIEW); // XXX Some frames (e.g., nsPluginFrame, nsFrameFrame, nsTextFrame) don't bother diff --git a/layout/generic/nsGridContainerFrame.cpp b/layout/generic/nsGridContainerFrame.cpp index 68ff06cab2..a843e6ddae 100644 --- a/layout/generic/nsGridContainerFrame.cpp +++ b/layout/generic/nsGridContainerFrame.cpp @@ -1157,8 +1157,9 @@ nsGridContainerFrame::ReflowChildren(GridItemCSSOrderIterator& aIter, { WritingMode wm = aReflowState.GetWritingMode(); const LogicalPoint gridOrigin(aContentArea.Origin(wm)); - const nscoord containerWidth = aContentArea.Width(wm) + - aReflowState.ComputedPhysicalBorderPadding().LeftRight(); + const nsSize containerSize = + (aContentArea.Size(wm) + + aReflowState.ComputedLogicalBorderPadding().Size(wm)).GetPhysicalSize(wm); nsPresContext* pc = PresContext(); for (; !aIter.AtEnd(); aIter.Next()) { nsIFrame* child = *aIter; @@ -1186,20 +1187,22 @@ nsGridContainerFrame::ReflowChildren(GridItemCSSOrderIterator& aIter, childRS.SetComputedBSize(std::max(bSize, 0)); } // We need the width of the child before we can correctly convert - // the writing-mode of its origin, so we reflow at (0, 0) and then - // pass the correct position to FinishReflowChild. + // the writing-mode of its origin, so we reflow at (0, 0) using a dummy + // containerSize, and then pass the correct position to FinishReflowChild. nsHTMLReflowMetrics childSize(childRS); nsReflowStatus childStatus; + const nsSize dummyContainerSize; ReflowChild(child, pc, childSize, childRS, childWM, LogicalPoint(childWM), - 0, 0, childStatus); + dummyContainerSize, 0, childStatus); LogicalPoint childPos = - cb.Origin(wm).ConvertTo(childWM, wm, containerWidth - childSize.Width() - - margin.LeftRight(childWM)); + cb.Origin(wm).ConvertTo(childWM, wm, + containerSize - childSize.PhysicalSize() - + margin.Size(childWM).GetPhysicalSize(childWM)); childPos.I(childWM) += margin.IStart(childWM); childPos.B(childWM) += margin.BStart(childWM); - childRS.ApplyRelativePositioning(&childPos, containerWidth); + childRS.ApplyRelativePositioning(&childPos, containerSize); FinishReflowChild(child, pc, childSize, &childRS, childWM, childPos, - containerWidth, 0); + containerSize, 0); ConsiderChildOverflow(aDesiredSize.mOverflowAreas, child); // XXX deal with 'childStatus' not being COMPLETE } @@ -1229,7 +1232,7 @@ nsGridContainerFrame::ReflowChildren(GridItemCSSOrderIterator& aIter, cb = new nsRect; child->Properties().Set(GridItemContainingBlockRect(), cb); } - *cb = itemCB.GetPhysicalRect(wm, containerWidth); + *cb = itemCB.GetPhysicalRect(wm, containerSize); } // This rect isn't used at all for layout so we use it to optimize // away the virtual GetType() call in the callee in most cases. diff --git a/layout/generic/nsHTMLReflowMetrics.h b/layout/generic/nsHTMLReflowMetrics.h index 687413b7d6..94df2cc8fb 100644 --- a/layout/generic/nsHTMLReflowMetrics.h +++ b/layout/generic/nsHTMLReflowMetrics.h @@ -272,6 +272,11 @@ public: nscoord& Width() { return mWritingMode.IsVertical() ? mBSize : mISize; } nscoord& Height() { return mWritingMode.IsVertical() ? mISize : mBSize; } + nsSize PhysicalSize() + { + return Size(mWritingMode).GetPhysicalSize(mWritingMode); + } + void SetBlockStartAscent(nscoord aAscent) { mBlockStartAscent = aAscent; diff --git a/layout/generic/nsHTMLReflowState.cpp b/layout/generic/nsHTMLReflowState.cpp index 198ffed182..f36d5fd641 100644 --- a/layout/generic/nsHTMLReflowState.cpp +++ b/layout/generic/nsHTMLReflowState.cpp @@ -1260,18 +1260,12 @@ nsHTMLReflowState::CalculateHypotheticalBox(nsPresContext* aPresContext, // XXXbz the placeholder is not fully reflowed yet if our containing block is // relatively positioned... WritingMode cbwm = cbrs->GetWritingMode(); - nscoord containerWidth = containingBlock->GetStateBits() & NS_FRAME_IN_REFLOW - ? cbrs->ComputedSizeAsContainerIfConstrained().width - : containingBlock->GetSize().width; - LogicalPoint placeholderOffset(wm, aPlaceholderFrame->GetOffsetTo(containingBlock), - containerWidth); - - // XXX hack to correct for lack of LogicalPoint bidi support in vertical mode - if (wm.IsVertical() && !wm.IsBidiLTR()) { - placeholderOffset.I(wm) = cbrs->ComputedHeight() + - cbrs->ComputedLogicalBorderPadding().TopBottom(cbwm) - - placeholderOffset.I(wm); - } + nsSize containerSize = containingBlock->GetStateBits() & NS_FRAME_IN_REFLOW + ? cbrs->ComputedSizeAsContainerIfConstrained() + : containingBlock->GetSize(); + LogicalPoint + placeholderOffset(wm, aPlaceholderFrame->GetOffsetTo(containingBlock), + containerSize); // First, determine the hypothetical box's mBStart. We want to check the // content insertion frame of containingBlock for block-ness, but make @@ -1280,7 +1274,11 @@ nsHTMLReflowState::CalculateHypotheticalBox(nsPresContext* aPresContext, nsBlockFrame* blockFrame = nsLayoutUtils::GetAsBlock(containingBlock->GetContentInsertionFrame()); if (blockFrame) { - LogicalPoint blockOffset(wm, blockFrame->GetOffsetTo(containingBlock), 0); + // Use a null containerSize to convert a LogicalPoint functioning as a + // vector into a physical nsPoint vector. + const nsSize nullContainerSize; + LogicalPoint blockOffset(wm, blockFrame->GetOffsetTo(containingBlock), + nullContainerSize); bool isValid; nsBlockInFlowLineIterator iter(blockFrame, aPlaceholderFrame, &isValid); if (!isValid) { @@ -1296,7 +1294,7 @@ nsHTMLReflowState::CalculateHypotheticalBox(nsPresContext* aPresContext, // would have been inline-level or block-level LogicalRect lineBounds = lineBox->GetBounds().ConvertTo(wm, lineBox->mWritingMode, - lineBox->mContainerWidth); + lineBox->mContainerSize); if (mStyleDisplay->IsOriginalDisplayInlineOutsideStyle()) { // Use the block-start of the inline box which the placeholder lives in // as the hypothetical box's block-start. @@ -1409,9 +1407,10 @@ nsHTMLReflowState::CalculateHypotheticalBox(nsPresContext* aPresContext, // scroll, and thus avoid the resulting incremental reflow bugs. cbOffset = containingBlock->GetOffsetTo(cbrs->frame); } - nscoord cbrsWidth = cbrs->ComputedWidth() + - cbrs->ComputedLogicalBorderPadding().LeftRight(cbwm); - LogicalPoint logCBOffs(wm, cbOffset, cbrsWidth - containerWidth); + nsSize cbrsSize = + cbrs->ComputedPhysicalSize() + + cbrs->ComputedLogicalBorderPadding().Size(cbwm).GetPhysicalSize(cbwm); + LogicalPoint logCBOffs(wm, cbOffset, cbrsSize - containerSize); aHypotheticalBox.mIStart += logCBOffs.I(wm); aHypotheticalBox.mIEnd += logCBOffs.I(wm); aHypotheticalBox.mBStart += logCBOffs.B(wm); @@ -1954,10 +1953,10 @@ nsHTMLReflowState::ComputeContainingBlockRectangle( // Note: We don't emulate this quirk for percents in calc() or in // vertical writing modes. if (!wm.IsVertical() && - NS_AUTOHEIGHT == cbSize.Height(wm)) { + NS_AUTOHEIGHT == cbSize.BSize(wm)) { if (eCompatibility_NavQuirks == aPresContext->CompatibilityMode() && mStylePosition->mHeight.GetUnit() == eStyleUnit_Percent) { - cbSize.Height(wm) = CalcQuirkContainingBlockHeight(aContainingBlockRS); + cbSize.BSize(wm) = CalcQuirkContainingBlockHeight(aContainingBlockRS); } } } diff --git a/layout/generic/nsHTMLReflowState.h b/layout/generic/nsHTMLReflowState.h index 35d964cff6..9a017546bb 100644 --- a/layout/generic/nsHTMLReflowState.h +++ b/layout/generic/nsHTMLReflowState.h @@ -436,6 +436,11 @@ struct nsHTMLReflowState : public nsCSSOffsetState { GetWritingMode()); } + nsSize + ComputedPhysicalSize() const { + return nsSize(ComputedWidth(), ComputedHeight()); + } + // XXX this will need to change when we make mComputedOffsets logical; // we won't be able to return a reference for the physical offsets const nsMargin& ComputedPhysicalOffsets() const { return mComputedOffsets; } @@ -849,27 +854,27 @@ public: mozilla::WritingMode aWritingMode, const mozilla::LogicalMargin& aComputedOffsets, mozilla::LogicalPoint* aPosition, - nscoord aContainerWidth) { - // Subtract the width of the frame from the container width that we + const nsSize& aContainerSize) { + // Subtract the size of the frame from the container size that we // use for converting between the logical and physical origins of // the frame. This accounts for the fact that logical origins in RTL // coordinate systems are at the top right of the frame instead of // the top left. - nscoord frameWidth = aFrame->GetSize().width; + nsSize frameSize = aFrame->GetSize(); nsPoint pos = aPosition->GetPhysicalPoint(aWritingMode, - aContainerWidth - frameWidth); + aContainerSize - frameSize); ApplyRelativePositioning(aFrame, aComputedOffsets.GetPhysicalMargin(aWritingMode), &pos); *aPosition = mozilla::LogicalPoint(aWritingMode, pos, - aContainerWidth - frameWidth); + aContainerSize - frameSize); } void ApplyRelativePositioning(mozilla::LogicalPoint* aPosition, - nscoord aContainerWidth) const { + const nsSize& aContainerSize) const { ApplyRelativePositioning(frame, mWritingMode, ComputedLogicalOffsets(), aPosition, - aContainerWidth); + aContainerSize); } #ifdef DEBUG diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index af69996dd3..df07d53740 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -659,39 +659,39 @@ public: * Dimensions and position in logical coordinates in the frame's writing mode * or another writing mode */ - mozilla::LogicalRect GetLogicalRect(nscoord aContainerWidth) const { - return GetLogicalRect(GetWritingMode(), aContainerWidth); + mozilla::LogicalRect GetLogicalRect(const nsSize& aContainerSize) const { + return GetLogicalRect(GetWritingMode(), aContainerSize); } - mozilla::LogicalPoint GetLogicalPosition(nscoord aContainerWidth) const { - return GetLogicalPosition(GetWritingMode(), aContainerWidth); + mozilla::LogicalPoint GetLogicalPosition(const nsSize& aContainerSize) const { + return GetLogicalPosition(GetWritingMode(), aContainerSize); } mozilla::LogicalSize GetLogicalSize() const { return GetLogicalSize(GetWritingMode()); } mozilla::LogicalRect GetLogicalRect(mozilla::WritingMode aWritingMode, - nscoord aContainerWidth) const { - return mozilla::LogicalRect(aWritingMode, GetRect(), aContainerWidth); + const nsSize& aContainerSize) const { + return mozilla::LogicalRect(aWritingMode, GetRect(), aContainerSize); } mozilla::LogicalPoint GetLogicalPosition(mozilla::WritingMode aWritingMode, - nscoord aContainerWidth) const { - return GetLogicalRect(aWritingMode, aContainerWidth).Origin(aWritingMode); + const nsSize& aContainerSize) const { + return GetLogicalRect(aWritingMode, aContainerSize).Origin(aWritingMode); } mozilla::LogicalSize GetLogicalSize(mozilla::WritingMode aWritingMode) const { return mozilla::LogicalSize(aWritingMode, GetSize()); } - nscoord IStart(nscoord aContainerWidth) const { - return IStart(GetWritingMode(), aContainerWidth); + nscoord IStart(const nsSize& aContainerSize) const { + return IStart(GetWritingMode(), aContainerSize); } nscoord IStart(mozilla::WritingMode aWritingMode, - nscoord aContainerWidth) const { - return GetLogicalPosition(aWritingMode, aContainerWidth).I(aWritingMode); + const nsSize& aContainerSize) const { + return GetLogicalPosition(aWritingMode, aContainerSize).I(aWritingMode); } - nscoord BStart(nscoord aContainerWidth) const { - return BStart(GetWritingMode(), aContainerWidth); + nscoord BStart(const nsSize& aContainerSize) const { + return BStart(GetWritingMode(), aContainerSize); } nscoord BStart(mozilla::WritingMode aWritingMode, - nscoord aContainerWidth) const { - return GetLogicalPosition(aWritingMode, aContainerWidth).B(aWritingMode); + const nsSize& aContainerSize) const { + return GetLogicalPosition(aWritingMode, aContainerSize).B(aWritingMode); } nscoord ISize() const { return ISize(GetWritingMode()); } nscoord ISize(mozilla::WritingMode aWritingMode) const { @@ -721,8 +721,9 @@ public: /** * Set this frame's rect from a logical rect in its own writing direction */ - void SetRect(const mozilla::LogicalRect& aRect, nscoord aContainerWidth) { - SetRect(GetWritingMode(), aRect, aContainerWidth); + void SetRect(const mozilla::LogicalRect& aRect, + const nsSize& aContainerSize) { + SetRect(GetWritingMode(), aRect, aContainerSize); } /** * Set this frame's rect from a logical rect in a different writing direction @@ -730,8 +731,8 @@ public: */ void SetRect(mozilla::WritingMode aWritingMode, const mozilla::LogicalRect& aRect, - nscoord aContainerWidth) { - SetRect(aRect.GetPhysicalRect(aWritingMode, aContainerWidth)); + const nsSize& aContainerSize) { + SetRect(aRect.GetPhysicalRect(aWritingMode, aContainerSize)); } /** @@ -753,12 +754,12 @@ public: void SetPosition(const nsPoint& aPt) { mRect.MoveTo(aPt); } void SetPosition(mozilla::WritingMode aWritingMode, const mozilla::LogicalPoint& aPt, - nscoord aContainerWidth) { - // We subtract mRect.width from the container width to account for + const nsSize& aContainerSize) { + // We subtract mRect.Size() from the container size to account for // the fact that logical origins in RTL coordinate systems are at // the top right of the frame instead of the top left. mRect.MoveTo(aPt.GetPhysicalPoint(aWritingMode, - aContainerWidth - mRect.width)); + aContainerSize - mRect.Size())); } /** @@ -780,7 +781,12 @@ public: void MovePositionBy(mozilla::WritingMode aWritingMode, const mozilla::LogicalPoint& aTranslation) { - MovePositionBy(aTranslation.GetPhysicalPoint(aWritingMode, 0)); + // The LogicalPoint represents a vector rather than a point within a + // rectangular coordinate space, so we use a null containerSize when + // converting logical to physical. + const nsSize nullContainerSize; + MovePositionBy(aTranslation.GetPhysicalPoint(aWritingMode, + nullContainerSize)); } /** @@ -794,14 +800,14 @@ public: nsPoint GetNormalPosition() const; mozilla::LogicalPoint GetLogicalNormalPosition(mozilla::WritingMode aWritingMode, - nscoord aContainerWidth) const + const nsSize& aContainerSize) const { - // Subtract the width of this frame from the container width to get + // Subtract the size of this frame from the container size to get // the correct position in rtl frames where the origin is on the // right instead of the left return mozilla::LogicalPoint(aWritingMode, GetNormalPosition(), - aContainerWidth - mRect.width); + aContainerSize - mRect.Size()); } virtual nsPoint GetPositionOfChildIgnoringScrolling(nsIFrame* aChild) diff --git a/layout/generic/nsLineBox.cpp b/layout/generic/nsLineBox.cpp index 7e01ea2ffa..f4ce228976 100644 --- a/layout/generic/nsLineBox.cpp +++ b/layout/generic/nsLineBox.cpp @@ -32,7 +32,7 @@ using namespace mozilla; nsLineBox::nsLineBox(nsIFrame* aFrame, int32_t aCount, bool aIsBlock) : mFirstChild(aFrame) - , mContainerWidth(-1) + , mContainerSize(-1, -1) , mBounds(WritingMode()) // mBounds will be initialized with the correct // writing mode when it is set // NOTE: memory is already zeroed since we allocate with AllocateByObjectID. @@ -80,7 +80,7 @@ NS_NewLineBox(nsIPresShell* aPresShell, nsLineBox* aFromLine, { nsLineBox* newLine = new (aPresShell) nsLineBox(aFrame, aCount, false); newLine->NoteFramesMovedFrom(aFromLine); - newLine->mContainerWidth = aFromLine->mContainerWidth; + newLine->mContainerSize = aFromLine->mContainerSize; return newLine; } @@ -249,13 +249,13 @@ nsLineBox::List(FILE* out, const char* aPrefix, uint32_t aFlags) const str += nsPrintfCString("{%d,%d,%d,%d} ", bounds.x, bounds.y, bounds.width, bounds.height); if (mWritingMode.IsVertical() || !mWritingMode.IsBidiLTR()) { - str += nsPrintfCString("{%s-%s: %d,%d,%d,%d; cw=%d} ", + str += nsPrintfCString("{%s-%s: %d,%d,%d,%d; cs=%d,%d} ", mWritingMode.IsVertical() ? mWritingMode.IsVerticalLR() ? "vlr" : "vrl" : "htb", mWritingMode.IsBidiLTR() ? "ltr" : "rtl", IStart(), BStart(), ISize(), BSize(), - mContainerWidth); + mContainerSize.width, mContainerSize.height); } if (mData && (!mData->mOverflowAreas.VisualOverflow().IsEqualEdges(bounds) || @@ -737,13 +737,13 @@ nsLineIterator::FindFrameAt(int32_t aLineNumber, nsIFrame* closestFromEnd = nullptr; WritingMode wm = line->mWritingMode; - nscoord cw = line->mContainerWidth; + nsSize containerSize = line->mContainerSize; - LogicalPoint pos(wm, aPos, cw); + LogicalPoint pos(wm, aPos, containerSize); int32_t n = line->GetChildCount(); while (n--) { - LogicalRect rect = frame->GetLogicalRect(wm, cw); + LogicalRect rect = frame->GetLogicalRect(wm, containerSize); if (rect.ISize(wm) > 0) { // If pos.I() is inside this frame - this is it if (rect.IStart(wm) <= pos.I(wm) && rect.IEnd(wm) > pos.I(wm)) { @@ -752,12 +752,14 @@ nsLineIterator::FindFrameAt(int32_t aLineNumber, } if (rect.IStart(wm) < pos.I(wm)) { if (!closestFromStart || - rect.IEnd(wm) > closestFromStart->GetLogicalRect(wm, cw).IEnd(wm)) + rect.IEnd(wm) > closestFromStart-> + GetLogicalRect(wm, containerSize).IEnd(wm)) closestFromStart = frame; } else { if (!closestFromEnd || - rect.IStart(wm) < closestFromEnd->GetLogicalRect(wm, cw).IStart(wm)) + rect.IStart(wm) < closestFromEnd-> + GetLogicalRect(wm, containerSize).IStart(wm)) closestFromEnd = frame; } } @@ -779,12 +781,15 @@ nsLineIterator::FindFrameAt(int32_t aLineNumber, *aFrameFound = closestFromStart; } else { // we're between two frames - nscoord delta = closestFromEnd->GetLogicalRect(wm, cw).IStart(wm) - - closestFromStart->GetLogicalRect(wm, cw).IEnd(wm); - if (pos.I(wm) < closestFromStart->GetLogicalRect(wm, cw).IEnd(wm) + delta/2) + nscoord delta = + closestFromEnd->GetLogicalRect(wm, containerSize).IStart(wm) - + closestFromStart->GetLogicalRect(wm, containerSize).IEnd(wm); + if (pos.I(wm) < closestFromStart-> + GetLogicalRect(wm, containerSize).IEnd(wm) + delta/2) { *aFrameFound = closestFromStart; - else + } else { *aFrameFound = closestFromEnd; + } } return NS_OK; } diff --git a/layout/generic/nsLineBox.h b/layout/generic/nsLineBox.h index 832fc1f685..64f2f59734 100644 --- a/layout/generic/nsLineBox.h +++ b/layout/generic/nsLineBox.h @@ -448,9 +448,9 @@ public: void SetOverflowAreas(const nsOverflowAreas& aOverflowAreas); mozilla::LogicalRect GetOverflowArea(nsOverflowType aType, mozilla::WritingMode aWM, - nscoord aContainerWidth) + const nsSize& aContainerSize) { - return mozilla::LogicalRect(aWM, GetOverflowArea(aType), aContainerWidth); + return mozilla::LogicalRect(aWM, GetOverflowArea(aType), aContainerSize); } nsRect GetOverflowArea(nsOverflowType aType) { return mData ? mData->mOverflowAreas.Overflow(aType) : GetPhysicalBounds(); @@ -467,33 +467,36 @@ public: nsRect GetScrollableOverflowArea() { return GetOverflowArea(eScrollableOverflow); } - void SlideBy(nscoord aDBCoord, nscoord aContainerWidth) { - NS_ASSERTION(aContainerWidth == mContainerWidth || mContainerWidth == -1, - "container width doesn't match"); - mContainerWidth = aContainerWidth; + void SlideBy(nscoord aDBCoord, const nsSize& aContainerSize) { + NS_ASSERTION(aContainerSize == mContainerSize || + mContainerSize == nsSize(-1, -1), + "container size doesn't match"); + mContainerSize = aContainerSize; mBounds.BStart(mWritingMode) += aDBCoord; if (mData) { - nsPoint physicalDelta = mozilla::LogicalPoint(mWritingMode, 0, aDBCoord). - GetPhysicalPoint(mWritingMode, 0); + // Use a null containerSize to convert vector from logical to physical. + const nsSize nullContainerSize; + nsPoint physicalDelta = + mozilla::LogicalPoint(mWritingMode, 0, aDBCoord). + GetPhysicalPoint(mWritingMode, nullContainerSize); NS_FOR_FRAME_OVERFLOW_TYPES(otype) { mData->mOverflowAreas.Overflow(otype) += physicalDelta; } } } - // Container-width for the line is changing (and therefore if writing mode + // Container-size for the line is changing (and therefore if writing mode // was vertical-rl, the line will move physically; this is like SlideBy, - // but it is the container width instead of the line's own logical coord + // but it is the container size instead of the line's own logical coord // that is changing. - nscoord UpdateContainerWidth(nscoord aNewContainerWidth) + nsSize UpdateContainerSize(const nsSize aNewContainerSize) { - NS_ASSERTION(mContainerWidth != -1, "container width not set"); - nscoord delta = mContainerWidth - aNewContainerWidth; - mContainerWidth = aNewContainerWidth; + NS_ASSERTION(mContainerSize != nsSize(-1, -1), "container size not set"); + nsSize delta = mContainerSize - aNewContainerSize; + mContainerSize = aNewContainerSize; // this has a physical-coordinate effect only in vertical-rl mode if (mWritingMode.IsVerticalRL() && mData) { - nsPoint physicalDelta = mozilla::LogicalPoint(mWritingMode, 0, delta). - GetPhysicalPoint(mWritingMode, 0); + nsPoint physicalDelta(-delta.width, 0); NS_FOR_FRAME_OVERFLOW_TYPES(otype) { mData->mOverflowAreas.Overflow(otype) += physicalDelta; } @@ -501,17 +504,19 @@ public: return delta; } - void IndentBy(nscoord aDICoord, nscoord aContainerWidth) { - NS_ASSERTION(aContainerWidth == mContainerWidth || mContainerWidth == -1, - "container width doesn't match"); - mContainerWidth = aContainerWidth; + void IndentBy(nscoord aDICoord, const nsSize& aContainerSize) { + NS_ASSERTION(aContainerSize == mContainerSize || + mContainerSize == nsSize(-1, -1), + "container size doesn't match"); + mContainerSize = aContainerSize; mBounds.IStart(mWritingMode) += aDICoord; } - void ExpandBy(nscoord aDISize, nscoord aContainerWidth) { - NS_ASSERTION(aContainerWidth == mContainerWidth || mContainerWidth == -1, - "container width doesn't match"); - mContainerWidth = aContainerWidth; + void ExpandBy(nscoord aDISize, const nsSize& aContainerSize) { + NS_ASSERTION(aContainerSize == mContainerSize || + mContainerSize == nsSize(-1, -1), + "container size doesn't match"); + mContainerSize = aContainerSize; mBounds.ISize(mWritingMode) += aDISize; } @@ -608,8 +613,8 @@ public: mozilla::WritingMode mWritingMode; - // Physical width. Use only for physical <-> logical coordinate conversion. - nscoord mContainerWidth; + // Physical size. Use only for physical <-> logical coordinate conversion. + nsSize mContainerSize; private: mozilla::LogicalRect mBounds; @@ -622,25 +627,26 @@ public: return nsRect(0, 0, 0, 0); } - NS_ASSERTION(mContainerWidth != -1, "mContainerWidth not initialized"); - return mBounds.GetPhysicalRect(mWritingMode, mContainerWidth); + NS_ASSERTION(mContainerSize != nsSize(-1, -1), + "mContainerSize not initialized"); + return mBounds.GetPhysicalRect(mWritingMode, mContainerSize); } void SetBounds(mozilla::WritingMode aWritingMode, nscoord aIStart, nscoord aBStart, nscoord aISize, nscoord aBSize, - nscoord aContainerWidth) + const nsSize& aContainerSize) { mWritingMode = aWritingMode; - mContainerWidth = aContainerWidth; + mContainerSize = aContainerSize; mBounds = mozilla::LogicalRect(aWritingMode, aIStart, aBStart, aISize, aBSize); } void SetBounds(mozilla::WritingMode aWritingMode, - nsRect aRect, nscoord aContainerWidth) + nsRect aRect, const nsSize& aContainerSize) { mWritingMode = aWritingMode; - mContainerWidth = aContainerWidth; - mBounds = mozilla::LogicalRect(aWritingMode, aRect, aContainerWidth); + mContainerSize = aContainerSize; + mBounds = mozilla::LogicalRect(aWritingMode, aRect, aContainerSize); } // mFlags.mHasHashedFrames says which one to use diff --git a/layout/generic/nsLineLayout.cpp b/layout/generic/nsLineLayout.cpp index a56262df30..f3ba905332 100644 --- a/layout/generic/nsLineLayout.cpp +++ b/layout/generic/nsLineLayout.cpp @@ -315,7 +315,7 @@ nsLineLayout::UpdateBand(WritingMode aWM, // need to convert to our writing mode, because we might have a different // mode from the caller due to dir: auto LogicalRect availSpace = aNewAvailSpace.ConvertTo(lineWM, aWM, - ContainerWidth()); + ContainerSize()); #ifdef REALLY_NOISY_REFLOW printf("nsLL::UpdateBand %d, %d, %d, %d, (converted to %d, %d, %d, %d); frame=%p\n will set mImpacted to true\n", aNewAvailSpace.x, aNewAvailSpace.y, @@ -941,7 +941,7 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame, metrics.ISize(lineWM) = nscoord(0xdeadbeef); metrics.BSize(lineWM) = nscoord(0xdeadbeef); #endif - nscoord tI = pfd->mBounds.LineLeft(lineWM, ContainerWidth()); + nscoord tI = pfd->mBounds.LineLeft(lineWM, ContainerSize()); nscoord tB = pfd->mBounds.BStart(lineWM); mFloatManager->Translate(tI, tB); @@ -1070,7 +1070,7 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame, pfd->mBounds.BSize(lineWM) = metrics.BSize(lineWM); // Size the frame, but |RelativePositionFrames| will size the view. - aFrame->SetRect(lineWM, pfd->mBounds, ContainerWidthForSpan(psd)); + aFrame->SetRect(lineWM, pfd->mBounds, ContainerSizeForSpan(psd)); // Tell the frame that we're done reflowing it aFrame->DidReflow(mPresContext, @@ -1250,13 +1250,16 @@ nsLineLayout::SyncAnnotationBounds(PerFrameData* aRubyFrame) for (PerFrameData* rtc = pfd->mNextAnnotation; rtc; rtc = rtc->mNextAnnotation) { // When the annotation container is reflowed, the width of the - // ruby container is unknown, hence zero should be used here - // as container width to get the correct logical rect. - LogicalRect rtcBounds(lineWM, rtc->mFrame->GetRect(), 0); + // ruby container is unknown so we use a dummy container size; + // in the case of RTL block direction, the final position will be + // fixed up later. + const nsSize dummyContainerSize; + LogicalRect rtcBounds(lineWM, rtc->mFrame->GetRect(), + dummyContainerSize); rtc->mBounds = rtcBounds; - nscoord rtcWidth = rtcBounds.Width(lineWM); + nsSize rtcSize = rtcBounds.Size(lineWM).GetPhysicalSize(lineWM); for (PerFrameData* rt = rtc->mSpan->mFirstFrame; rt; rt = rt->mNext) { - LogicalRect rtBounds = rt->mFrame->GetLogicalRect(lineWM, rtcWidth); + LogicalRect rtBounds = rt->mFrame->GetLogicalRect(lineWM, rtcSize); MOZ_ASSERT(rt->mBounds.Size(lineWM) == rtBounds.Size(lineWM), "Size of the annotation should not have been changed"); rt->mBounds.SetOrigin(lineWM, rtBounds.Origin(lineWM)); @@ -1492,7 +1495,7 @@ nsLineLayout::AddBulletFrame(nsIFrame* aFrame, } // Note: block-coord value will be updated during block-direction alignment - pfd->mBounds = LogicalRect(lineWM, aFrame->GetRect(), ContainerWidth()); + pfd->mBounds = LogicalRect(lineWM, aFrame->GetRect(), ContainerSize()); pfd->mOverflowAreas = aMetrics.mOverflowAreas; } @@ -1508,7 +1511,7 @@ nsLineLayout::DumpPerSpanData(PerSpanData* psd, int32_t aIndent) nsFrame::IndentBy(stdout, aIndent+1); nsFrame::ListTag(stdout, pfd->mFrame); nsRect rect = pfd->mBounds.GetPhysicalRect(psd->mWritingMode, - ContainerWidth()); + ContainerSize()); printf(" %d,%d,%d,%d\n", rect.x, rect.y, rect.width, rect.height); if (pfd->mSpan) { DumpPerSpanData(pfd->mSpan, aIndent + 1); @@ -1597,7 +1600,7 @@ nsLineLayout::VerticalAlignLine() for (PerFrameData* pfd = psd->mFirstFrame; pfd; pfd = pfd->mNext) { if (pfd->mBlockDirAlign == VALIGN_OTHER) { pfd->mBounds.BStart(lineWM) += baselineBCoord; - pfd->mFrame->SetRect(lineWM, pfd->mBounds, ContainerWidth()); + pfd->mFrame->SetRect(lineWM, pfd->mBounds, ContainerSize()); } } PlaceTopBottomFrames(psd, -mBStartEdge, lineBSize); @@ -1608,7 +1611,7 @@ nsLineLayout::VerticalAlignLine() mLineBox->SetBounds(lineWM, psd->mIStart, mBStartEdge, psd->mICoord - psd->mIStart, lineBSize, - ContainerWidth()); + ContainerSize()); mLineBox->SetLogicalAscent(baselineBCoord - mBStartEdge); #ifdef NOISY_BLOCKDIR_ALIGN @@ -1633,7 +1636,7 @@ nsLineLayout::PlaceTopBottomFrames(PerSpanData* psd, NS_ASSERTION(0xFF != pfd->mBlockDirAlign, "umr"); #endif WritingMode lineWM = mRootSpan->mWritingMode; - nscoord containerWidth = ContainerWidthForSpan(psd); + nsSize containerSize = ContainerSizeForSpan(psd); switch (pfd->mBlockDirAlign) { case VALIGN_TOP: if (span) { @@ -1643,7 +1646,7 @@ nsLineLayout::PlaceTopBottomFrames(PerSpanData* psd, pfd->mBounds.BStart(lineWM) = -aDistanceFromStart + pfd->mMargin.BStart(lineWM); } - pfd->mFrame->SetRect(lineWM, pfd->mBounds, containerWidth); + pfd->mFrame->SetRect(lineWM, pfd->mBounds, containerSize); #ifdef NOISY_BLOCKDIR_ALIGN printf(" "); nsFrame::ListTag(stdout, pfd->mFrame); @@ -1663,7 +1666,7 @@ nsLineLayout::PlaceTopBottomFrames(PerSpanData* psd, pfd->mBounds.BStart(lineWM) = -aDistanceFromStart + aLineBSize - pfd->mMargin.BEnd(lineWM) - pfd->mBounds.BSize(lineWM); } - pfd->mFrame->SetRect(lineWM, pfd->mBounds, containerWidth); + pfd->mFrame->SetRect(lineWM, pfd->mBounds, containerSize); #ifdef NOISY_BLOCKDIR_ALIGN printf(" "); nsFrame::ListTag(stdout, pfd->mFrame); @@ -2232,7 +2235,7 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd) #endif } if (psd != mRootSpan) { - frame->SetRect(lineWM, pfd->mBounds, ContainerWidthForSpan(psd)); + frame->SetRect(lineWM, pfd->mBounds, ContainerSizeForSpan(psd)); } } pfd = pfd->mNext; @@ -2395,7 +2398,7 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd) while (nullptr != pfd) { pfd->mBounds.BStart(lineWM) -= minBCoord; // move all the children // back up - pfd->mFrame->SetRect(lineWM, pfd->mBounds, ContainerWidthForSpan(psd)); + pfd->mFrame->SetRect(lineWM, pfd->mBounds, ContainerSizeForSpan(psd)); pfd = pfd->mNext; } maxBCoord -= minBCoord; // since minBCoord is in the frame's own @@ -2473,11 +2476,11 @@ nsLineLayout::TrimTrailingWhiteSpaceIn(PerSpanData* psd, // that are direct children of the block will be updated // later, however, because the VerticalAlignFrames method // will be run after this method. - nscoord containerWidth = ContainerWidthForSpan(childSpan); + nsSize containerSize = ContainerSizeForSpan(childSpan); nsIFrame* f = pfd->mFrame; - LogicalRect r(lineWM, f->GetRect(), containerWidth); + LogicalRect r(lineWM, f->GetRect(), containerSize); r.ISize(lineWM) -= deltaISize; - f->SetRect(lineWM, r, containerWidth); + f->SetRect(lineWM, r, containerSize); } // Adjust the inline end edge of the span that contains the child span @@ -2541,7 +2544,7 @@ nsLineLayout::TrimTrailingWhiteSpaceIn(PerSpanData* psd, // The frame was already placed during psd's // reflow. Update the frames rectangle now. pfd->mFrame->SetRect(lineWM, pfd->mBounds, - ContainerWidthForSpan(psd)); + ContainerSizeForSpan(psd)); } // Adjust containing span's right edge @@ -2757,7 +2760,7 @@ nsLineLayout::ComputeFrameJustification(PerSpanData* aPSD, void nsLineLayout::AdvanceAnnotationInlineBounds(PerFrameData* aPFD, - nscoord aContainerWidth, + const nsSize& aContainerSize, nscoord aDeltaICoord, nscoord aDeltaISize) { @@ -2795,7 +2798,7 @@ nsLineLayout::AdvanceAnnotationInlineBounds(PerFrameData* aPFD, // themselves properly. We only need to expand its own size here. aPFD->mBounds.ISize(lineWM) += aDeltaISize; } - aPFD->mFrame->SetRect(lineWM, aPFD->mBounds, aContainerWidth); + aPFD->mFrame->SetRect(lineWM, aPFD->mBounds, aContainerSize); } /** @@ -2809,8 +2812,8 @@ nsLineLayout::ApplyLineJustificationToAnnotations(PerFrameData* aPFD, { PerFrameData* pfd = aPFD->mNextAnnotation; while (pfd) { - nscoord containerWidth = pfd->mFrame->GetParent()->GetRect().Width(); - AdvanceAnnotationInlineBounds(pfd, containerWidth, + nsSize containerSize = pfd->mFrame->GetParent()->GetSize(); + AdvanceAnnotationInlineBounds(pfd, containerSize, aDeltaICoord, aDeltaISize); // There are two cases where an annotation frame has siblings which @@ -2822,7 +2825,7 @@ nsLineLayout::ApplyLineJustificationToAnnotations(PerFrameData* aPFD, // need to move them so that they won't overlap other frames. PerFrameData* sibling = pfd->mNext; while (sibling && !sibling->mIsLinkedToBase) { - AdvanceAnnotationInlineBounds(sibling, containerWidth, + AdvanceAnnotationInlineBounds(sibling, containerSize, aDeltaICoord + aDeltaISize, 0); sibling = sibling->mNext; } @@ -2880,7 +2883,7 @@ nsLineLayout::ApplyFrameJustification(PerSpanData* aPSD, // excluded from the isize added to the annotation. ApplyLineJustificationToAnnotations(pfd, deltaICoord, dw - gapsAtEnd); deltaICoord += dw; - pfd->mFrame->SetRect(lineWM, pfd->mBounds, ContainerWidthForSpan(aPSD)); + pfd->mFrame->SetRect(lineWM, pfd->mBounds, ContainerSizeForSpan(aPSD)); } } return deltaICoord; @@ -2905,7 +2908,7 @@ FindNearestRubyBaseAncestor(nsIFrame* aFrame) */ void nsLineLayout::ExpandRubyBox(PerFrameData* aFrame, nscoord aReservedISize, - nscoord aContainerWidth) + const nsSize& aContainerSize) { WritingMode lineWM = mRootSpan->mWritingMode; auto rubyAlign = aFrame->mFrame->StyleText()->mRubyAlign; @@ -2937,7 +2940,7 @@ nsLineLayout::ExpandRubyBox(PerFrameData* aFrame, nscoord aReservedISize, for (PerFrameData* child = aFrame->mSpan->mFirstFrame; child; child = child->mNext) { child->mBounds.IStart(lineWM) += aReservedISize / 2; - child->mFrame->SetRect(lineWM, child->mBounds, aContainerWidth); + child->mFrame->SetRect(lineWM, child->mBounds, aContainerSize); } break; default: @@ -2945,7 +2948,7 @@ nsLineLayout::ExpandRubyBox(PerFrameData* aFrame, nscoord aReservedISize, } aFrame->mBounds.ISize(lineWM) += aReservedISize; - aFrame->mFrame->SetRect(lineWM, aFrame->mBounds, aContainerWidth); + aFrame->mFrame->SetRect(lineWM, aFrame->mBounds, aContainerSize); } /** @@ -2955,11 +2958,11 @@ nsLineLayout::ExpandRubyBox(PerFrameData* aFrame, nscoord aReservedISize, */ void nsLineLayout::ExpandRubyBoxWithAnnotations(PerFrameData* aFrame, - nscoord aContainerWidth) + const nsSize& aContainerSize) { nscoord reservedISize = RubyUtils::GetReservedISize(aFrame->mFrame); if (reservedISize) { - ExpandRubyBox(aFrame, reservedISize, aContainerWidth); + ExpandRubyBox(aFrame, reservedISize, aContainerSize); } WritingMode lineWM = mRootSpan->mWritingMode; @@ -2977,7 +2980,7 @@ nsLineLayout::ExpandRubyBoxWithAnnotations(PerFrameData* aFrame, MOZ_ASSERT( rtcFrame->GetLogicalSize(lineWM) == annotation->mBounds.Size(lineWM)); rtcFrame->SetPosition(lineWM, annotation->mBounds.Origin(lineWM), - aContainerWidth); + aContainerSize); } nscoord reservedISize = RubyUtils::GetReservedISize(annotation->mFrame); @@ -2997,13 +3000,13 @@ nsLineLayout::ExpandRubyBoxWithAnnotations(PerFrameData* aFrame, computeState.mLastParticipant->mJustificationAssignment.mGapsAtEnd = 1; } nsIFrame* parentFrame = annotation->mFrame->GetParent(); - nscoord containerWidth = parentFrame->GetRect().Width(); - MOZ_ASSERT(containerWidth == aContainerWidth || + nsSize containerSize = parentFrame->GetSize(); + MOZ_ASSERT(containerSize == aContainerSize || parentFrame->GetType() == nsGkAtoms::rubyTextContainerFrame, "Container width should only be different when the current " "annotation is a ruby text frame, whose parent is not same " "as its base frame."); - ExpandRubyBox(annotation, reservedISize, containerWidth); + ExpandRubyBox(annotation, reservedISize, containerSize); ExpandInlineRubyBoxes(annotation->mSpan); } } @@ -3015,10 +3018,10 @@ nsLineLayout::ExpandRubyBoxWithAnnotations(PerFrameData* aFrame, void nsLineLayout::ExpandInlineRubyBoxes(PerSpanData* aSpan) { - nscoord containerWidth = ContainerWidthForSpan(aSpan); + nsSize containerSize = ContainerSizeForSpan(aSpan); for (PerFrameData* pfd = aSpan->mFirstFrame; pfd; pfd = pfd->mNext) { if (RubyUtils::IsExpandableRubyBox(pfd->mFrame)) { - ExpandRubyBoxWithAnnotations(pfd, containerWidth); + ExpandRubyBoxWithAnnotations(pfd, containerSize); } if (pfd->mSpan) { ExpandInlineRubyBoxes(pfd->mSpan); @@ -3112,7 +3115,7 @@ nsLineLayout::TextAlignLine(nsLineBox* aLine, // Apply the justification, and make sure to update our linebox // width to account for it. aLine->ExpandBy(ApplyFrameJustification(psd, applyState), - ContainerWidthForSpan(psd)); + ContainerSizeForSpan(psd)); MOZ_ASSERT(applyState.mGaps.mHandled == applyState.mGaps.mCount, "Unprocessed justification gaps"); @@ -3164,14 +3167,14 @@ nsLineLayout::TextAlignLine(nsLineBox* aLine, lineWM, mContainerSize, psd->mIStart + mTextIndent + dx); if (dx) { - aLine->IndentBy(dx, ContainerWidth()); + aLine->IndentBy(dx, ContainerSize()); } } else if (dx) { for (PerFrameData* pfd = psd->mFirstFrame; pfd; pfd = pfd->mNext) { pfd->mBounds.IStart(lineWM) += dx; - pfd->mFrame->SetRect(lineWM, pfd->mBounds, ContainerWidthForSpan(psd)); + pfd->mFrame->SetRect(lineWM, pfd->mBounds, ContainerSizeForSpan(psd)); } - aLine->IndentBy(dx, ContainerWidth()); + aLine->IndentBy(dx, ContainerSize()); } } @@ -3185,13 +3188,13 @@ nsLineLayout::ApplyRelativePositioning(PerFrameData* aPFD) nsIFrame* frame = aPFD->mFrame; WritingMode frameWM = frame->GetWritingMode(); - LogicalPoint origin = frame->GetLogicalPosition(ContainerWidth()); + LogicalPoint origin = frame->GetLogicalPosition(ContainerSize()); // right and bottom are handled by // nsHTMLReflowState::ComputeRelativeOffsets nsHTMLReflowState::ApplyRelativePositioning(frame, frameWM, aPFD->mOffsets, &origin, - ContainerWidth()); - frame->SetPosition(frameWM, origin, ContainerWidth()); + ContainerSize()); + frame->SetPosition(frameWM, origin, ContainerSize()); } // This method do relative positioning for ruby annotations. @@ -3244,7 +3247,7 @@ nsLineLayout::RelativePositionFrames(PerSpanData* psd, nsOverflowAreas& aOverflo // children of the block starts at the upper left corner of the // line and is sized to match the size of the line's bounding box // (the same size as the values returned from VerticalAlignFrames) - overflowAreas.VisualOverflow() = rect.GetPhysicalRect(wm, ContainerWidth()); + overflowAreas.VisualOverflow() = rect.GetPhysicalRect(wm, ContainerSize()); overflowAreas.ScrollableOverflow() = overflowAreas.VisualOverflow(); } diff --git a/layout/generic/nsLineLayout.h b/layout/generic/nsLineLayout.h index 3470eef874..75234d231f 100644 --- a/layout/generic/nsLineLayout.h +++ b/layout/generic/nsLineLayout.h @@ -544,14 +544,15 @@ protected: PerSpanData* mRootSpan; PerSpanData* mCurrentSpan; - // The container width to use when converting between logical and + // The container size to use when converting between logical and // physical coordinates for frames in this span. For the root span - // this is the width of the block cached in mContainerSize.width; for - // child spans it's the width of the root span - nscoord ContainerWidthForSpan(PerSpanData* aPSD) { + // this is the size of the block cached in mContainerSize; for + // child spans it's the size of the root span. + nsSize ContainerSizeForSpan(PerSpanData* aPSD) { return (aPSD == mRootSpan) - ? ContainerWidth() - : aPSD->mFrame->mBounds.Width(mRootSpan->mWritingMode); + ? mContainerSize + : aPSD->mFrame->mBounds.Size(mRootSpan->mWritingMode). + GetPhysicalSize(mRootSpan->mWritingMode); } gfxBreakPriority mLastOptionalBreakPriority; @@ -587,8 +588,7 @@ protected: // Physical size. Use only for physical <-> logical coordinate conversion. nsSize mContainerSize; - nscoord ContainerWidth() const { return mContainerSize.width; } - nscoord ContainerHeight() const { return mContainerSize.height; } + const nsSize& ContainerSize() const { return mContainerSize; } bool mFirstLetterStyleOK : 1; bool mIsTopOfPage : 1; @@ -686,7 +686,7 @@ protected: JustificationComputationState& aState); void AdvanceAnnotationInlineBounds(PerFrameData* aPFD, - nscoord aContainerWidth, + const nsSize& aContainerSize, nscoord aDeltaICoord, nscoord aDeltaISize); @@ -700,10 +700,10 @@ protected: PerSpanData* aPSD, mozilla::JustificationApplicationState& aState); void ExpandRubyBox(PerFrameData* aFrame, nscoord aReservedISize, - nscoord aContainerWidth); + const nsSize& aContainerSize); void ExpandRubyBoxWithAnnotations(PerFrameData* aFrame, - nscoord aContainerWidth); + const nsSize& aContainerSize); void ExpandInlineRubyBoxes(PerSpanData* aSpan); diff --git a/layout/generic/nsRubyFrame.cpp b/layout/generic/nsRubyFrame.cpp index c2982ca473..0b6409f48c 100644 --- a/layout/generic/nsRubyFrame.cpp +++ b/layout/generic/nsRubyFrame.cpp @@ -253,7 +253,9 @@ nsRubyFrame::ReflowSegment(nsPresContext* aPresContext, } nscoord segmentISize = baseMetrics.ISize(lineWM); - LogicalRect baseRect = aBaseContainer->GetLogicalRect(lineWM, 0); + const nsSize dummyContainerSize; + LogicalRect baseRect = + aBaseContainer->GetLogicalRect(lineWM, dummyContainerSize); // We need to position our rtc frames on one side or the other of the // base container's rect, using a coordinate space that's relative to // the ruby frame. Right now, the base container's rect's block-axis @@ -318,10 +320,11 @@ nsRubyFrame::ReflowSegment(nsPresContext* aPresContext, MOZ_ASSERT_UNREACHABLE("???"); } } - // Container width is set to zero here. We will fix it in - // nsLineLayout after the whole line get reflowed. + // Using a dummy container-size here, so child positioning may not be + // correct. We will fix it in nsLineLayout after the whole line is + // reflowed. FinishReflowChild(textContainer, aPresContext, textMetrics, - &textReflowState, lineWM, position, 0, 0); + &textReflowState, lineWM, position, dummyContainerSize, 0); } MOZ_ASSERT(baseRect.ISize(lineWM) == offsetRect.ISize(lineWM), "Annotations should only be placed on the block directions"); diff --git a/layout/generic/nsRubyTextContainerFrame.cpp b/layout/generic/nsRubyTextContainerFrame.cpp index 82b5fa8a16..f1899cf80b 100644 --- a/layout/generic/nsRubyTextContainerFrame.cpp +++ b/layout/generic/nsRubyTextContainerFrame.cpp @@ -135,11 +135,14 @@ nsRubyTextContainerFrame::Reflow(nsPresContext* aPresContext, nscoord minBCoord = nscoord_MAX; nscoord maxBCoord = nscoord_MIN; + // The container size is not yet known, so we use a dummy (0, 0) size. + // The block-dir position will be corrected below after containerSize + // is finalized. + const nsSize dummyContainerSize; for (nsFrameList::Enumerator e(mFrames); !e.AtEnd(); e.Next()) { nsIFrame* child = e.get(); MOZ_ASSERT(child->GetType() == nsGkAtoms::rubyTextFrame); - // The container width is still unknown yet. - LogicalRect rect = child->GetLogicalRect(lineWM, 0); + LogicalRect rect = child->GetLogicalRect(lineWM, dummyContainerSize); LogicalMargin margin = child->GetLogicalUsedMargin(lineWM); nscoord blockStart = rect.BStart(lineWM) - margin.BStart(lineWM); minBCoord = std::min(minBCoord, blockStart); @@ -155,18 +158,18 @@ nsRubyTextContainerFrame::Reflow(nsPresContext* aPresContext, minBCoord = maxBCoord = 0; } size.BSize(lineWM) = maxBCoord - minBCoord; - nscoord containerWidth = size.Width(lineWM); + nsSize containerSize = size.GetPhysicalSize(lineWM); for (nsFrameList::Enumerator e(mFrames); !e.AtEnd(); e.Next()) { nsIFrame* child = e.get(); - // We reflowed the child with container width 0, as the true width + // We reflowed the child with a dummy container size, as the true size // was not yet known at that time. - LogicalPoint pos = child->GetLogicalPosition(lineWM, 0); + LogicalPoint pos = child->GetLogicalPosition(lineWM, dummyContainerSize); // Adjust block position to account for minBCoord, // then reposition child based on the true container width. pos.B(lineWM) -= minBCoord; // Relative positioning hasn't happened yet. // So MovePositionBy should not be used here. - child->SetPosition(lineWM, pos, containerWidth); + child->SetPosition(lineWM, pos, containerSize); nsContainerFrame::PlaceFrameView(child); } } diff --git a/layout/generic/test/mochitest.ini b/layout/generic/test/mochitest.ini index 8f338d5991..19acee2f48 100644 --- a/layout/generic/test/mochitest.ini +++ b/layout/generic/test/mochitest.ini @@ -82,6 +82,7 @@ support-files = bug633762_iframe.html [test_bug735641.html] skip-if = (buildapp == 'b2g' && toolkit != 'gonk') #Bug 931116, b2g desktop specific, initial triage [test_bug748961.html] +[test_bug756984.html] [test_bug784410.html] skip-if = buildapp == 'b2g' #Bug 931116, 1129060 no wheel events on b2g [test_bug785324.html] diff --git a/layout/generic/test/test_bug756984.html b/layout/generic/test/test_bug756984.html new file mode 100644 index 0000000000..e1a4c3d8e8 --- /dev/null +++ b/layout/generic/test/test_bug756984.html @@ -0,0 +1,66 @@ + + + + + + Test for Bug 756984 + + + + + +Mozilla Bug 756984 +

+ + +
123
45678
+
123
45678
+
123
45678
+

45678
+ +
+
+ 
+
+
+ + diff --git a/layout/generic/test/test_movement_by_characters.html b/layout/generic/test/test_movement_by_characters.html index 7573fb4571..ffd4233355 100644 --- a/layout/generic/test/test_movement_by_characters.html +++ b/layout/generic/test/test_movement_by_characters.html @@ -70,7 +70,7 @@ function test() { testRight(editor.firstChild.nextSibling.nextSibling, 0); testRight(editor.firstChild.nextSibling.nextSibling, 1); testLeft(editor.firstChild.nextSibling.nextSibling, 0); - testLeft(editor, 1); + testLeft(editor.firstChild, 2); testLeft(editor.firstChild, 1); testLeft(editor.firstChild, 0); diff --git a/layout/mathml/nsMathMLmtableFrame.cpp b/layout/mathml/nsMathMLmtableFrame.cpp index fba6e2dcbb..73d84641f8 100644 --- a/layout/mathml/nsMathMLmtableFrame.cpp +++ b/layout/mathml/nsMathMLmtableFrame.cpp @@ -820,10 +820,11 @@ nsMathMLmtableOuterFrame::Reflow(nsPresContext* aPresContext, if (rowFrame) { // translate the coordinates to be relative to us and in our writing mode nsIFrame* frame = rowFrame; - LogicalRect frameRect(wm, frame->GetRect(), aReflowState.ComputedWidth()); - blockSize = frameRect.BSize(wm); + LogicalRect rect(wm, frame->GetRect(), + aReflowState.ComputedSizeAsContainerIfConstrained()); + blockSize = rect.BSize(wm); do { - dy += frameRect.BStart(wm); + dy += rect.BStart(wm); frame = frame->GetParent(); } while (frame != this); } diff --git a/layout/reftests/bugs/reftest.list b/layout/reftests/bugs/reftest.list index 08ad5e718d..801b7337ca 100644 --- a/layout/reftests/bugs/reftest.list +++ b/layout/reftests/bugs/reftest.list @@ -717,10 +717,10 @@ skip-if(B2G||Mulet) fails-if(Android) != 379461-3-container-xhtml.html 379461-3- == 383035-2.html about:blank == 383488-1.html 383488-1-ref.html == 383551-1.html 383551-1-ref.html -== 383883-1.html 383883-1-ref.html -== 383883-2.html 383883-2-ref.html -== 383883-3.html 383883-3-ref.html -== 383883-4.html 383883-4-ref.html +fuzzy-if(B2G,68,26) == 383883-1.html 383883-1-ref.html +fuzzy-if(B2G,68,26) == 383883-2.html 383883-2-ref.html +fuzzy-if(B2G,68,26) == 383883-3.html 383883-3-ref.html +fuzzy-if(B2G,68,26) == 383883-4.html 383883-4-ref.html == 383884-1.html 383884-1-ref.html == 383885-1.html 383885-1-ref.html == 384322-1.html 384322-1-ref.html diff --git a/layout/reftests/floats/float-in-rtl-vlr-1-ref.html b/layout/reftests/floats/float-in-rtl-vlr-1-ref.html new file mode 100644 index 0000000000..fa28701b6f --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vlr-1-ref.html @@ -0,0 +1,24 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+This text should appear ABOVE the red and green blocks. +
+ + diff --git a/layout/reftests/floats/float-in-rtl-vlr-1a.html b/layout/reftests/floats/float-in-rtl-vlr-1a.html new file mode 100644 index 0000000000..acbc2ed6af --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vlr-1a.html @@ -0,0 +1,24 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+This text should appear ABOVE the red and green blocks. +
+ + diff --git a/layout/reftests/floats/float-in-rtl-vlr-1b.html b/layout/reftests/floats/float-in-rtl-vlr-1b.html new file mode 100644 index 0000000000..422c338b9d --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vlr-1b.html @@ -0,0 +1,24 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+This text should appear ABOVE the red and green blocks. +
+ + diff --git a/layout/reftests/floats/float-in-rtl-vlr-1c.html b/layout/reftests/floats/float-in-rtl-vlr-1c.html new file mode 100644 index 0000000000..76c91e1198 --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vlr-1c.html @@ -0,0 +1,24 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+This text should appear ABOVE the red and green blocks. +
+ + diff --git a/layout/reftests/floats/float-in-rtl-vlr-1d.html b/layout/reftests/floats/float-in-rtl-vlr-1d.html new file mode 100644 index 0000000000..24bff2400e --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vlr-1d.html @@ -0,0 +1,26 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+
+
+This text should appear ABOVE the red and green blocks. +
+ + diff --git a/layout/reftests/floats/float-in-rtl-vlr-2-ref.html b/layout/reftests/floats/float-in-rtl-vlr-2-ref.html new file mode 100644 index 0000000000..9640a3345c --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vlr-2-ref.html @@ -0,0 +1,24 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+This text should appear BELOW the green and red blocks. +
+ + diff --git a/layout/reftests/floats/float-in-rtl-vlr-2a.html b/layout/reftests/floats/float-in-rtl-vlr-2a.html new file mode 100644 index 0000000000..325ed9311b --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vlr-2a.html @@ -0,0 +1,24 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+This text should appear BELOW the green and red blocks. +
+ + diff --git a/layout/reftests/floats/float-in-rtl-vlr-2b.html b/layout/reftests/floats/float-in-rtl-vlr-2b.html new file mode 100644 index 0000000000..827b594496 --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vlr-2b.html @@ -0,0 +1,24 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+This text should appear BELOW the green and red blocks. +
+ + diff --git a/layout/reftests/floats/float-in-rtl-vlr-2c.html b/layout/reftests/floats/float-in-rtl-vlr-2c.html new file mode 100644 index 0000000000..58a5a7363e --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vlr-2c.html @@ -0,0 +1,24 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+This text should appear BELOW the green and red blocks. +
+ + diff --git a/layout/reftests/floats/float-in-rtl-vlr-2d.html b/layout/reftests/floats/float-in-rtl-vlr-2d.html new file mode 100644 index 0000000000..916bb61ad5 --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vlr-2d.html @@ -0,0 +1,26 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+
+
+This text should appear BELOW the green and red blocks. +
+ + diff --git a/layout/reftests/floats/float-in-rtl-vlr-3-ref.html b/layout/reftests/floats/float-in-rtl-vlr-3-ref.html new file mode 100644 index 0000000000..28c8869ff7 --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vlr-3-ref.html @@ -0,0 +1,26 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+
+This text should appear BELOW the green and red blocks. +
+
+ + diff --git a/layout/reftests/floats/float-in-rtl-vlr-3a.html b/layout/reftests/floats/float-in-rtl-vlr-3a.html new file mode 100644 index 0000000000..8064205b4b --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vlr-3a.html @@ -0,0 +1,26 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+
+This text should appear BELOW the green and red blocks. +
+
+ + diff --git a/layout/reftests/floats/float-in-rtl-vlr-3b.html b/layout/reftests/floats/float-in-rtl-vlr-3b.html new file mode 100644 index 0000000000..b481c234b0 --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vlr-3b.html @@ -0,0 +1,26 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+
+This text should appear BELOW the green and red blocks. +
+
+ + diff --git a/layout/reftests/floats/float-in-rtl-vlr-3c.html b/layout/reftests/floats/float-in-rtl-vlr-3c.html new file mode 100644 index 0000000000..7cbf8d9f2b --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vlr-3c.html @@ -0,0 +1,26 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+
+This text should appear BELOW the green and red blocks. +
+
+ + diff --git a/layout/reftests/floats/float-in-rtl-vlr-3d.html b/layout/reftests/floats/float-in-rtl-vlr-3d.html new file mode 100644 index 0000000000..d97e9f2f54 --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vlr-3d.html @@ -0,0 +1,28 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+
+
+
+This text should appear BELOW the green and red blocks. +
+
+ + diff --git a/layout/reftests/floats/float-in-rtl-vlr-4-ref.html b/layout/reftests/floats/float-in-rtl-vlr-4-ref.html new file mode 100644 index 0000000000..b81b8eb172 --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vlr-4-ref.html @@ -0,0 +1,25 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+This text should appear ABOVE the red and green blocks. +
+ + diff --git a/layout/reftests/floats/float-in-rtl-vlr-4a.html b/layout/reftests/floats/float-in-rtl-vlr-4a.html new file mode 100644 index 0000000000..b3eba9e8dc --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vlr-4a.html @@ -0,0 +1,25 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+This text should appear ABOVE the red and green blocks. +
+ + diff --git a/layout/reftests/floats/float-in-rtl-vlr-4b.html b/layout/reftests/floats/float-in-rtl-vlr-4b.html new file mode 100644 index 0000000000..61c37c009f --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vlr-4b.html @@ -0,0 +1,25 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+This text should appear ABOVE the red and green blocks. +
+ + diff --git a/layout/reftests/floats/float-in-rtl-vlr-4c.html b/layout/reftests/floats/float-in-rtl-vlr-4c.html new file mode 100644 index 0000000000..7117781067 --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vlr-4c.html @@ -0,0 +1,25 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+This text should appear ABOVE the red and green blocks. +
+ + diff --git a/layout/reftests/floats/float-in-rtl-vlr-4d.html b/layout/reftests/floats/float-in-rtl-vlr-4d.html new file mode 100644 index 0000000000..dca2ae9088 --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vlr-4d.html @@ -0,0 +1,27 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+
+
+This text should appear ABOVE the red and green blocks. +
+ + diff --git a/layout/reftests/floats/float-in-rtl-vrl-1-ref.html b/layout/reftests/floats/float-in-rtl-vrl-1-ref.html new file mode 100644 index 0000000000..b7c6f8f1f9 --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vrl-1-ref.html @@ -0,0 +1,26 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+
+This text should appear ABOVE the red and green blocks. +
+ + diff --git a/layout/reftests/floats/float-in-rtl-vrl-1a.html b/layout/reftests/floats/float-in-rtl-vrl-1a.html new file mode 100644 index 0000000000..dd7413d554 --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vrl-1a.html @@ -0,0 +1,25 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+This text should appear ABOVE the red and green blocks. +
+ + diff --git a/layout/reftests/floats/float-in-rtl-vrl-1b.html b/layout/reftests/floats/float-in-rtl-vrl-1b.html new file mode 100644 index 0000000000..e0071bc571 --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vrl-1b.html @@ -0,0 +1,25 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+This text should appear ABOVE the red and green blocks. +
+ + diff --git a/layout/reftests/floats/float-in-rtl-vrl-1c.html b/layout/reftests/floats/float-in-rtl-vrl-1c.html new file mode 100644 index 0000000000..eaad5a0aff --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vrl-1c.html @@ -0,0 +1,25 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+This text should appear ABOVE the red and green blocks. +
+ + diff --git a/layout/reftests/floats/float-in-rtl-vrl-1d.html b/layout/reftests/floats/float-in-rtl-vrl-1d.html new file mode 100644 index 0000000000..ad0b234703 --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vrl-1d.html @@ -0,0 +1,27 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+
+
+This text should appear ABOVE the red and green blocks. +
+ + diff --git a/layout/reftests/floats/float-in-rtl-vrl-2-ref.html b/layout/reftests/floats/float-in-rtl-vrl-2-ref.html new file mode 100644 index 0000000000..007c8b49ea --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vrl-2-ref.html @@ -0,0 +1,25 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+This text should appear BELOW the green and red blocks. +
+ + diff --git a/layout/reftests/floats/float-in-rtl-vrl-2a.html b/layout/reftests/floats/float-in-rtl-vrl-2a.html new file mode 100644 index 0000000000..6f4696b675 --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vrl-2a.html @@ -0,0 +1,25 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+This text should appear BELOW the green and red blocks. +
+ + diff --git a/layout/reftests/floats/float-in-rtl-vrl-2b.html b/layout/reftests/floats/float-in-rtl-vrl-2b.html new file mode 100644 index 0000000000..a823c18958 --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vrl-2b.html @@ -0,0 +1,25 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+This text should appear BELOW the green and red blocks. +
+ + diff --git a/layout/reftests/floats/float-in-rtl-vrl-2c.html b/layout/reftests/floats/float-in-rtl-vrl-2c.html new file mode 100644 index 0000000000..c5f265d0f6 --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vrl-2c.html @@ -0,0 +1,25 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+This text should appear BELOW the green and red blocks. +
+ + diff --git a/layout/reftests/floats/float-in-rtl-vrl-2d.html b/layout/reftests/floats/float-in-rtl-vrl-2d.html new file mode 100644 index 0000000000..14cc9ad26b --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vrl-2d.html @@ -0,0 +1,27 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+
+
+This text should appear BELOW the green and red blocks. +
+ + diff --git a/layout/reftests/floats/float-in-rtl-vrl-3-ref.html b/layout/reftests/floats/float-in-rtl-vrl-3-ref.html new file mode 100644 index 0000000000..3ca4fba074 --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vrl-3-ref.html @@ -0,0 +1,26 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+
+This text should appear BELOW the green and red blocks. +
+
+ + diff --git a/layout/reftests/floats/float-in-rtl-vrl-3a.html b/layout/reftests/floats/float-in-rtl-vrl-3a.html new file mode 100644 index 0000000000..e4e1841f59 --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vrl-3a.html @@ -0,0 +1,26 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+
+This text should appear BELOW the green and red blocks. +
+
+ + diff --git a/layout/reftests/floats/float-in-rtl-vrl-3b.html b/layout/reftests/floats/float-in-rtl-vrl-3b.html new file mode 100644 index 0000000000..f084df553e --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vrl-3b.html @@ -0,0 +1,26 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+
+This text should appear BELOW the green and red blocks. +
+
+ + diff --git a/layout/reftests/floats/float-in-rtl-vrl-3c.html b/layout/reftests/floats/float-in-rtl-vrl-3c.html new file mode 100644 index 0000000000..c284ab8a18 --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vrl-3c.html @@ -0,0 +1,26 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+
+This text should appear BELOW the green and red blocks. +
+
+ + diff --git a/layout/reftests/floats/float-in-rtl-vrl-3d.html b/layout/reftests/floats/float-in-rtl-vrl-3d.html new file mode 100644 index 0000000000..85ecae2409 --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vrl-3d.html @@ -0,0 +1,28 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+
+
+
+This text should appear BELOW the green and red blocks. +
+
+ + diff --git a/layout/reftests/floats/float-in-rtl-vrl-4-ref.html b/layout/reftests/floats/float-in-rtl-vrl-4-ref.html new file mode 100644 index 0000000000..452bfc7c76 --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vrl-4-ref.html @@ -0,0 +1,25 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+This text should appear ABOVE the red and green blocks. +
+ + diff --git a/layout/reftests/floats/float-in-rtl-vrl-4a.html b/layout/reftests/floats/float-in-rtl-vrl-4a.html new file mode 100644 index 0000000000..2c97d18eae --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vrl-4a.html @@ -0,0 +1,25 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+This text should appear ABOVE the red and green blocks. +
+ + diff --git a/layout/reftests/floats/float-in-rtl-vrl-4b.html b/layout/reftests/floats/float-in-rtl-vrl-4b.html new file mode 100644 index 0000000000..b30010460d --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vrl-4b.html @@ -0,0 +1,25 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+This text should appear ABOVE the red and green blocks. +
+ + diff --git a/layout/reftests/floats/float-in-rtl-vrl-4c.html b/layout/reftests/floats/float-in-rtl-vrl-4c.html new file mode 100644 index 0000000000..8e07a74f8f --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vrl-4c.html @@ -0,0 +1,25 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+This text should appear ABOVE the red and green blocks. +
+ + diff --git a/layout/reftests/floats/float-in-rtl-vrl-4d.html b/layout/reftests/floats/float-in-rtl-vrl-4d.html new file mode 100644 index 0000000000..e7e3b27e0e --- /dev/null +++ b/layout/reftests/floats/float-in-rtl-vrl-4d.html @@ -0,0 +1,27 @@ + + + +Bug 1114329 testcase + + + +
+
+
+
+
+
+
+
+
+This text should appear ABOVE the red and green blocks. +
+ + diff --git a/layout/reftests/floats/reftest.list b/layout/reftests/floats/reftest.list index 3b9bcbb654..b6269f2e2e 100644 --- a/layout/reftests/floats/reftest.list +++ b/layout/reftests/floats/reftest.list @@ -46,7 +46,46 @@ fails == 345369-2.html 345369-2-ref.html == bfc-displace-4.html bfc-displace-4-ref.html == bfc-shrink-1.html bfc-shrink-1-ref.html -pref(layout.css.vertical-text.enabled,true) fuzzy-if(OSX==1010,26,7) fuzzy-if(Android,16,2) == orthogonal-floats-1a.html orthogonal-floats-1-ref.html -pref(layout.css.vertical-text.enabled,true) fuzzy-if(OSX==1010,26,7) == orthogonal-floats-1b.html orthogonal-floats-1-ref.html -pref(layout.css.vertical-text.enabled,true) fuzzy-if(OSX==1010,103,802) fuzzy-if(winWidget,116,700) HTTP(..) == orthogonal-floats-1c.html orthogonal-floats-1-ref.html -pref(layout.css.vertical-text.enabled,true) fuzzy-if(OSX==1010,103,802) fuzzy-if(winWidget,116,700) HTTP(..) == orthogonal-floats-1d.html orthogonal-floats-1-ref.html +# Testcases that involve vertical writing mode. +# +# XXX The default-preferences setting here can be removed after the +# pref has been made true by default for all channels (bug 1138384). + +default-preferences pref(layout.css.vertical-text.enabled,true) + +== float-in-rtl-vlr-1a.html float-in-rtl-vlr-1-ref.html +== float-in-rtl-vlr-1b.html float-in-rtl-vlr-1-ref.html +== float-in-rtl-vlr-1c.html float-in-rtl-vlr-1-ref.html +== float-in-rtl-vlr-1d.html float-in-rtl-vlr-1-ref.html +== float-in-rtl-vlr-2a.html float-in-rtl-vlr-2-ref.html +== float-in-rtl-vlr-2b.html float-in-rtl-vlr-2-ref.html +== float-in-rtl-vlr-2c.html float-in-rtl-vlr-2-ref.html +== float-in-rtl-vlr-2d.html float-in-rtl-vlr-2-ref.html +== float-in-rtl-vlr-3a.html float-in-rtl-vlr-3-ref.html +== float-in-rtl-vlr-3b.html float-in-rtl-vlr-3-ref.html +== float-in-rtl-vlr-3c.html float-in-rtl-vlr-3-ref.html +== float-in-rtl-vlr-3d.html float-in-rtl-vlr-3-ref.html +== float-in-rtl-vlr-4a.html float-in-rtl-vlr-4-ref.html +== float-in-rtl-vlr-4b.html float-in-rtl-vlr-4-ref.html +== float-in-rtl-vlr-4c.html float-in-rtl-vlr-4-ref.html +== float-in-rtl-vlr-4d.html float-in-rtl-vlr-4-ref.html +== float-in-rtl-vrl-1a.html float-in-rtl-vrl-1-ref.html +== float-in-rtl-vrl-1b.html float-in-rtl-vrl-1-ref.html +== float-in-rtl-vrl-1c.html float-in-rtl-vrl-1-ref.html +== float-in-rtl-vrl-1d.html float-in-rtl-vrl-1-ref.html +== float-in-rtl-vrl-2a.html float-in-rtl-vrl-2-ref.html +== float-in-rtl-vrl-2b.html float-in-rtl-vrl-2-ref.html +== float-in-rtl-vrl-2c.html float-in-rtl-vrl-2-ref.html +== float-in-rtl-vrl-2d.html float-in-rtl-vrl-2-ref.html +== float-in-rtl-vrl-3a.html float-in-rtl-vrl-3-ref.html +== float-in-rtl-vrl-3b.html float-in-rtl-vrl-3-ref.html +== float-in-rtl-vrl-3c.html float-in-rtl-vrl-3-ref.html +== float-in-rtl-vrl-3d.html float-in-rtl-vrl-3-ref.html +== float-in-rtl-vrl-4a.html float-in-rtl-vrl-4-ref.html +== float-in-rtl-vrl-4b.html float-in-rtl-vrl-4-ref.html +== float-in-rtl-vrl-4c.html float-in-rtl-vrl-4-ref.html +== float-in-rtl-vrl-4d.html float-in-rtl-vrl-4-ref.html +fuzzy-if(OSX==1010,26,7) fuzzy-if(Android,16,2) == orthogonal-floats-1a.html orthogonal-floats-1-ref.html +fuzzy-if(OSX==1010,26,7) == orthogonal-floats-1b.html orthogonal-floats-1-ref.html +fuzzy-if(OSX==1010,103,802) fuzzy-if(winWidget,116,700) HTTP(..) == orthogonal-floats-1c.html orthogonal-floats-1-ref.html +fuzzy-if(OSX==1010,103,802) fuzzy-if(winWidget,116,700) HTTP(..) == orthogonal-floats-1d.html orthogonal-floats-1-ref.html diff --git a/layout/reftests/w3c-css/submitted/flexbox/flexbox-writing-mode-007-ref.html b/layout/reftests/w3c-css/submitted/flexbox/flexbox-writing-mode-007-ref.html new file mode 100644 index 0000000000..0d2e9207be --- /dev/null +++ b/layout/reftests/w3c-css/submitted/flexbox/flexbox-writing-mode-007-ref.html @@ -0,0 +1,56 @@ + + + + + CSS Reftest Reference + + + + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + diff --git a/layout/reftests/w3c-css/submitted/flexbox/flexbox-writing-mode-007.html b/layout/reftests/w3c-css/submitted/flexbox/flexbox-writing-mode-007.html new file mode 100644 index 0000000000..521af54af4 --- /dev/null +++ b/layout/reftests/w3c-css/submitted/flexbox/flexbox-writing-mode-007.html @@ -0,0 +1,75 @@ + + + + + CSS Test: Verify that explicit sizes are honored on flex items whose writing-mode may differ from the flex container's writing-mode + + + + + + + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + diff --git a/layout/reftests/w3c-css/submitted/flexbox/flexbox-writing-mode-008-ref.html b/layout/reftests/w3c-css/submitted/flexbox/flexbox-writing-mode-008-ref.html new file mode 100644 index 0000000000..8a21dd65f3 --- /dev/null +++ b/layout/reftests/w3c-css/submitted/flexbox/flexbox-writing-mode-008-ref.html @@ -0,0 +1,56 @@ + + + + + CSS Reftest Reference + + + + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + diff --git a/layout/reftests/w3c-css/submitted/flexbox/flexbox-writing-mode-008.html b/layout/reftests/w3c-css/submitted/flexbox/flexbox-writing-mode-008.html new file mode 100644 index 0000000000..98fd83fbc8 --- /dev/null +++ b/layout/reftests/w3c-css/submitted/flexbox/flexbox-writing-mode-008.html @@ -0,0 +1,75 @@ + + + + + CSS Test: Verify that explicit sizes are honored on flex items whose writing-mode may differ from the flex container's writing-mode + + + + + + + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + diff --git a/layout/reftests/w3c-css/submitted/flexbox/flexbox-writing-mode-009-ref.html b/layout/reftests/w3c-css/submitted/flexbox/flexbox-writing-mode-009-ref.html new file mode 100644 index 0000000000..5a96eb9998 --- /dev/null +++ b/layout/reftests/w3c-css/submitted/flexbox/flexbox-writing-mode-009-ref.html @@ -0,0 +1,56 @@ + + + + + CSS Reftest Reference + + + + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + diff --git a/layout/reftests/w3c-css/submitted/flexbox/flexbox-writing-mode-009.html b/layout/reftests/w3c-css/submitted/flexbox/flexbox-writing-mode-009.html new file mode 100644 index 0000000000..edd63a982a --- /dev/null +++ b/layout/reftests/w3c-css/submitted/flexbox/flexbox-writing-mode-009.html @@ -0,0 +1,75 @@ + + + + + CSS Test: Verify that explicit sizes are honored on flex items whose writing-mode may differ from the flex container's writing-mode + + + + + + + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + diff --git a/layout/reftests/w3c-css/submitted/flexbox/reftest.list b/layout/reftests/w3c-css/submitted/flexbox/reftest.list index ca546ce51a..4257fc4cec 100644 --- a/layout/reftests/w3c-css/submitted/flexbox/reftest.list +++ b/layout/reftests/w3c-css/submitted/flexbox/reftest.list @@ -188,5 +188,8 @@ test-pref(layout.css.vertical-text.enabled,true) == flexbox-writing-mode-001.htm test-pref(layout.css.vertical-text.enabled,true) == flexbox-writing-mode-002.html flexbox-writing-mode-002-ref.html test-pref(layout.css.vertical-text.enabled,true) == flexbox-writing-mode-003.html flexbox-writing-mode-003-ref.html test-pref(layout.css.vertical-text.enabled,true) == flexbox-writing-mode-004.html flexbox-writing-mode-004-ref.html -test-pref(layout.css.vertical-text.enabled,true) fails == flexbox-writing-mode-005.html flexbox-writing-mode-005-ref.html # bug 1131451 -test-pref(layout.css.vertical-text.enabled,true) fails == flexbox-writing-mode-006.html flexbox-writing-mode-006-ref.html # bug 1131451 +test-pref(layout.css.vertical-text.enabled,true) == flexbox-writing-mode-005.html flexbox-writing-mode-005-ref.html +test-pref(layout.css.vertical-text.enabled,true) == flexbox-writing-mode-006.html flexbox-writing-mode-006-ref.html +test-pref(layout.css.vertical-text.enabled,true) == flexbox-writing-mode-007.html flexbox-writing-mode-007-ref.html +test-pref(layout.css.vertical-text.enabled,true) == flexbox-writing-mode-008.html flexbox-writing-mode-008-ref.html +test-pref(layout.css.vertical-text.enabled,true) == flexbox-writing-mode-009.html flexbox-writing-mode-009-ref.html diff --git a/layout/reftests/writing-mode/reftest.list b/layout/reftests/writing-mode/reftest.list index 17b06dadab..4fe9f36564 100644 --- a/layout/reftests/writing-mode/reftest.list +++ b/layout/reftests/writing-mode/reftest.list @@ -130,9 +130,9 @@ test-pref(dom.meta-viewport.enabled,true) test-pref(font.size.inflation.emPerLin == 1147834-relative-overconstrained-horizontal-tb-ltr.html 1147834-bottom-right-ref.html == 1147834-relative-overconstrained-horizontal-tb-rtl.html 1147834-bottom-left-ref.html == 1147834-relative-overconstrained-vertical-lr-ltr.html 1147834-bottom-right-ref.html -fails == 1147834-relative-overconstrained-vertical-lr-rtl.html 1147834-top-right-ref.html # bug 1131451 +== 1147834-relative-overconstrained-vertical-lr-rtl.html 1147834-top-right-ref.html == 1147834-relative-overconstrained-vertical-rl-ltr.html 1147834-bottom-left-ref.html -fails == 1147834-relative-overconstrained-vertical-rl-rtl.html 1147834-top-left-ref.html # bug 1131451 +== 1147834-relative-overconstrained-vertical-rl-rtl.html 1147834-top-left-ref.html == 1151993-1-orthogonal-block-size.html 1151993-1-orthogonal-block-size-ref.html == 1152941-1-orthogonal-blocksize-overflow.html 1152941-1-orthogonal-blocksize-overflow-ref.html == 1156021-text-indent-percent.html 1156021-text-indent-percent-ref.html diff --git a/layout/reftests/writing-mode/tables/border-collapse-bevels-1-ref.html b/layout/reftests/writing-mode/tables/border-collapse-bevels-1-ref.html new file mode 100644 index 0000000000..5d5a430589 --- /dev/null +++ b/layout/reftests/writing-mode/tables/border-collapse-bevels-1-ref.html @@ -0,0 +1,28 @@ + + + + + + + + +
+ + +
+
diff --git a/layout/reftests/writing-mode/tables/border-collapse-bevels-1a.html b/layout/reftests/writing-mode/tables/border-collapse-bevels-1a.html new file mode 100644 index 0000000000..4bfcc00770 --- /dev/null +++ b/layout/reftests/writing-mode/tables/border-collapse-bevels-1a.html @@ -0,0 +1,29 @@ + + + + + + + + +
+ + +
+
diff --git a/layout/reftests/writing-mode/tables/border-collapse-bevels-1b.html b/layout/reftests/writing-mode/tables/border-collapse-bevels-1b.html new file mode 100644 index 0000000000..d1535ce443 --- /dev/null +++ b/layout/reftests/writing-mode/tables/border-collapse-bevels-1b.html @@ -0,0 +1,29 @@ + + + + + + + + +
+ + +
+
diff --git a/layout/reftests/writing-mode/tables/border-collapse-bevels-1c.html b/layout/reftests/writing-mode/tables/border-collapse-bevels-1c.html new file mode 100644 index 0000000000..30e8bdb8bf --- /dev/null +++ b/layout/reftests/writing-mode/tables/border-collapse-bevels-1c.html @@ -0,0 +1,29 @@ + + + + + + + + +
+ + +
+
diff --git a/layout/reftests/writing-mode/tables/border-collapse-bevels-1d.html b/layout/reftests/writing-mode/tables/border-collapse-bevels-1d.html new file mode 100644 index 0000000000..b621cde1a0 --- /dev/null +++ b/layout/reftests/writing-mode/tables/border-collapse-bevels-1d.html @@ -0,0 +1,30 @@ + + + + + + + + +
+ + +
+
diff --git a/layout/reftests/writing-mode/tables/border-collapse-bevels-1e.html b/layout/reftests/writing-mode/tables/border-collapse-bevels-1e.html new file mode 100644 index 0000000000..82ea6e1520 --- /dev/null +++ b/layout/reftests/writing-mode/tables/border-collapse-bevels-1e.html @@ -0,0 +1,30 @@ + + + + + + + + +
+ + +
+
diff --git a/layout/reftests/writing-mode/tables/reftest.list b/layout/reftests/writing-mode/tables/reftest.list index b547941663..35555b1b48 100644 --- a/layout/reftests/writing-mode/tables/reftest.list +++ b/layout/reftests/writing-mode/tables/reftest.list @@ -82,3 +82,9 @@ fuzzy-if(Android,255,38) == table-caption-top-1.html table-caption-top-1-ref.htm fuzzy-if(Android,255,38) == table-caption-bottom-1.html table-caption-bottom-1-ref.html == table-caption-left-1.html table-caption-left-1-ref.html == table-caption-right-1.html table-caption-right-1-ref.html + +== border-collapse-bevels-1a.html border-collapse-bevels-1-ref.html +fuzzy-if(cocoaWidget,23,162) == border-collapse-bevels-1b.html border-collapse-bevels-1-ref.html +fuzzy-if(cocoaWidget,23,162) == border-collapse-bevels-1c.html border-collapse-bevels-1-ref.html +fuzzy-if(cocoaWidget,23,162) == border-collapse-bevels-1d.html border-collapse-bevels-1-ref.html +fuzzy-if(cocoaWidget,23,162) == border-collapse-bevels-1e.html border-collapse-bevels-1-ref.html diff --git a/layout/tables/crashtests/1183896.html b/layout/tables/crashtests/1183896.html new file mode 100644 index 0000000000..3995ba09f3 --- /dev/null +++ b/layout/tables/crashtests/1183896.html @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + +
+ + + diff --git a/layout/tables/crashtests/crashtests.list b/layout/tables/crashtests/crashtests.list index e7ed892f22..ea4fdae620 100644 --- a/layout/tables/crashtests/crashtests.list +++ b/layout/tables/crashtests/crashtests.list @@ -149,3 +149,4 @@ load 759249-2.html load 814713.html load 1027611-1.html load 1031934.html +load 1183896.html diff --git a/layout/tables/nsTableCellFrame.cpp b/layout/tables/nsTableCellFrame.cpp index e24e51d758..d02628b0f5 100644 --- a/layout/tables/nsTableCellFrame.cpp +++ b/layout/tables/nsTableCellFrame.cpp @@ -596,10 +596,10 @@ void nsTableCellFrame::BlockDirAlignChild(WritingMode aWM, nscoord aMaxAscent) nscoord bSize = BSize(aWM); nsIFrame* firstKid = mFrames.FirstChild(); - nscoord containerWidth = mRect.width; + nsSize containerSize = mRect.Size(); NS_ASSERTION(firstKid, "Frame construction error, a table cell always has " "an inner cell frame"); - LogicalRect kidRect = firstKid->GetLogicalRect(aWM, containerWidth); + LogicalRect kidRect = firstKid->GetLogicalRect(aWM, containerSize); nscoord childBSize = kidRect.BSize(aWM); // Vertically align the child @@ -636,7 +636,7 @@ void nsTableCellFrame::BlockDirAlignChild(WritingMode aWM, nscoord aMaxAscent) } firstKid->SetPosition(aWM, LogicalPoint(aWM, kidRect.IStart(aWM), - kidBStart), containerWidth); + kidBStart), containerSize); nsHTMLReflowMetrics desiredSize(aWM); desiredSize.SetSize(aWM, GetLogicalSize(aWM)); @@ -944,8 +944,8 @@ nsTableCellFrame::Reflow(nsPresContext* aPresContext, kidReflowState.SetBResize(true); } - nscoord containerWidth = - aReflowState.ComputedSizeAsContainerIfConstrained().width; + nsSize containerSize = + aReflowState.ComputedSizeAsContainerIfConstrained(); LogicalPoint kidOrigin(wm, borderPadding.IStart(wm), borderPadding.BStart(wm)); @@ -954,7 +954,7 @@ nsTableCellFrame::Reflow(nsPresContext* aPresContext, bool firstReflow = firstKid->HasAnyStateBits(NS_FRAME_FIRST_REFLOW); ReflowChild(firstKid, aPresContext, kidSize, kidReflowState, - wm, kidOrigin, containerWidth, 0, aStatus); + wm, kidOrigin, containerSize, 0, aStatus); if (NS_FRAME_OVERFLOW_IS_INCOMPLETE(aStatus)) { // Don't pass OVERFLOW_INCOMPLETE through tables until they can actually handle it //XXX should paginate overflow as overflow, but not in this patch (bug 379349) @@ -984,7 +984,7 @@ nsTableCellFrame::Reflow(nsPresContext* aPresContext, // Place the child FinishReflowChild(firstKid, aPresContext, kidSize, &kidReflowState, - wm, kidOrigin, containerWidth, 0); + wm, kidOrigin, containerSize, 0); nsTableFrame::InvalidateTableFrame(firstKid, origRect, origVisualOverflow, firstReflow); diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index 94538d747f..9a4aa78d44 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -1422,7 +1422,7 @@ nsTableFrame::GetLogicalSkipSides(const nsHTMLReflowState* aReflowState) const void nsTableFrame::SetColumnDimensions(nscoord aBSize, WritingMode aWM, const LogicalMargin& aBorderPadding, - nscoord aContainerWidth) + const nsSize& aContainerSize) { const nscoord colBSize = aBSize - (aBorderPadding.BStartEnd(aWM) + GetRowSpacing(-1) + GetRowSpacing(GetRowCount())); @@ -1454,8 +1454,8 @@ nsTableFrame::SetColumnDimensions(nscoord aBSize, WritingMode aWM, LogicalRect colGroupRect(aWM, colGroupOrigin.I(aWM), colGroupOrigin.B(aWM), colGroupISize, colBSize); - colGroupFrame->SetRect(aWM, colGroupRect, aContainerWidth); - nscoord colGroupWidth = colGroupFrame->GetSize().width; + colGroupFrame->SetRect(aWM, colGroupRect, aContainerSize); + nsSize colGroupSize = colGroupFrame->GetSize(); // then we can place the columns correctly within the group colIdx = groupFirstCol; @@ -1466,7 +1466,7 @@ nsTableFrame::SetColumnDimensions(nscoord aBSize, WritingMode aWM, nscoord colISize = fif->GetColumnISizeFromFirstInFlow(colIdx); LogicalRect colRect(aWM, colOrigin.I(aWM), colOrigin.B(aWM), colISize, colBSize); - colFrame->SetRect(aWM, colRect, colGroupWidth); + colFrame->SetRect(aWM, colRect, colGroupSize); cellSpacingI = GetColSpacing(colIdx); colOrigin.I(aWM) += colISize + cellSpacingI; ++colIdx; @@ -1879,8 +1879,8 @@ nsTableFrame::Reflow(nsPresContext* aPresContext, ReflowTable(aDesiredSize, aReflowState, availBSize, lastChildReflowed, aStatus); // If ComputedWidth is unconstrained, we may need to fix child positions - // later (in vertical-rl mode) due to use of 0 as a fake containerWidth - // during ReflowChildren. + // later (in vertical-rl mode) due to use of 0 as a dummy + // containerSize.width during ReflowChildren. fixupKidPositions = wm.IsVerticalRL() && aReflowState.ComputedWidth() == NS_UNCONSTRAINEDSIZE; @@ -1933,7 +1933,7 @@ nsTableFrame::Reflow(nsPresContext* aPresContext, } if (fixupKidPositions) { - // If we didn't already know the containerWidth (and so used zero during + // If we didn't already know the containerSize (and so used zero during // ReflowChildren), then we need to update the block-position of our kids. for (nsIFrame* kid : mFrames) { kid->MovePositionBy(nsPoint(aDesiredSize.Width(), 0)); @@ -1943,7 +1943,7 @@ nsTableFrame::Reflow(nsPresContext* aPresContext, LogicalMargin borderPadding = GetChildAreaOffset(wm, &aReflowState); SetColumnDimensions(aDesiredSize.BSize(wm), wm, borderPadding, - aDesiredSize.Width()); + aDesiredSize.PhysicalSize()); if (NeedToCollapse() && (NS_UNCONSTRAINEDSIZE != aReflowState.AvailableISize())) { AdjustForCollapsingRowsCols(aDesiredSize, wm, borderPadding); @@ -2895,8 +2895,8 @@ nsTableFrame::SetupHeaderFooterChild(const nsTableReflowState& aReflowState, WritingMode wm = aFrame->GetWritingMode(); LogicalSize availSize = aReflowState.reflowState.AvailableSize(wm); - nscoord containerWidth = availSize.Width(wm); - // XXX check for containerWidth == NS_UNCONSTRAINEDSIZE + nsSize containerSize = availSize.GetPhysicalSize(wm); + // XXX check for containerSize.* == NS_UNCONSTRAINEDSIZE availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE; nsHTMLReflowState kidReflowState(presContext, aReflowState.reflowState, @@ -2909,7 +2909,7 @@ nsTableFrame::SetupHeaderFooterChild(const nsTableReflowState& aReflowState, nsReflowStatus status; ReflowChild(aFrame, presContext, desiredSize, kidReflowState, wm, LogicalPoint(wm, aReflowState.iCoord, aReflowState.bCoord), - containerWidth, 0, status); + containerSize, 0, status); // The child will be reflowed again "for real" so no need to place it now aFrame->SetRepeatable(IsRepeatable(desiredSize.Height(), pageHeight)); @@ -2926,8 +2926,8 @@ nsTableFrame::PlaceRepeatedFooter(nsTableReflowState& aReflowState, WritingMode wm = aTfoot->GetWritingMode(); LogicalSize kidAvailSize = aReflowState.availSize; - nscoord containerWidth = kidAvailSize.Width(wm); - // XXX check for containerWidth == NS_UNCONSTRAINEDSIZE + nsSize containerSize = kidAvailSize.GetPhysicalSize(wm); + // XXX check for containerSize.* == NS_UNCONSTRAINEDSIZE kidAvailSize.BSize(wm) = aFooterHeight; nsHTMLReflowState footerReflowState(presContext, @@ -2946,15 +2946,16 @@ nsTableFrame::PlaceRepeatedFooter(nsTableReflowState& aReflowState, desiredSize.ClearSize(); LogicalPoint kidPosition(wm, aReflowState.iCoord, aReflowState.bCoord); ReflowChild(aTfoot, presContext, desiredSize, footerReflowState, - wm, kidPosition, containerWidth, 0, footerStatus); - footerReflowState.ApplyRelativePositioning(&kidPosition, containerWidth); + wm, kidPosition, containerSize, 0, footerStatus); + footerReflowState.ApplyRelativePositioning(&kidPosition, containerSize); PlaceChild(aReflowState, aTfoot, - // We subtract desiredSize.Width() from containerWidth here + // We subtract desiredSize.PhysicalSize() from containerSize here // to account for the fact that in RTL modes, the origin is // on the right-hand side so we're not simply converting a // point, we're also swapping the child's origin side. - kidPosition.GetPhysicalPoint(wm, containerWidth - desiredSize.Width()), + kidPosition.GetPhysicalPoint(wm, containerSize - + desiredSize.PhysicalSize()), desiredSize, origTfootRect, origTfootVisualOverflow); } @@ -2974,8 +2975,8 @@ nsTableFrame::ReflowChildren(nsTableReflowState& aReflowState, NS_WARN_IF_FALSE(wm.IsVertical() || NS_UNCONSTRAINEDSIZE != aReflowState.reflowState.ComputedWidth(), "shouldn't have unconstrained width in horizontal mode"); - nscoord containerWidth = - aReflowState.reflowState.ComputedSizeAsContainerIfConstrained().width; + nsSize containerSize = + aReflowState.reflowState.ComputedSizeAsContainerIfConstrained(); nsPresContext* presContext = PresContext(); // XXXldb Should we be checking constrained height instead? @@ -3094,8 +3095,8 @@ nsTableFrame::ReflowChildren(nsTableReflowState& aReflowState, LogicalPoint kidPosition(wm, aReflowState.iCoord, aReflowState.bCoord); ReflowChild(kidFrame, presContext, desiredSize, kidReflowState, - wm, kidPosition, containerWidth, 0, aStatus); - kidReflowState.ApplyRelativePositioning(&kidPosition, containerWidth); + wm, kidPosition, containerSize, 0, aStatus); + kidReflowState.ApplyRelativePositioning(&kidPosition, containerSize); if (reorder) { // reorder row groups the reflow may have changed the nextinflows @@ -3128,8 +3129,8 @@ nsTableFrame::ReflowChildren(nsTableReflowState& aReflowState, nsIFrame* nextRowGroupFrame = rowGroups[childX + 1]; if (nextRowGroupFrame) { PlaceChild(aReflowState, kidFrame, - kidPosition.GetPhysicalPoint(wm, containerWidth - - desiredSize.Width()), + kidPosition.GetPhysicalPoint(wm, + containerSize - desiredSize.PhysicalSize()), desiredSize, oldKidRect, oldKidVisualOverflow); if (allowRepeatedFooter) { PlaceRepeatedFooter(aReflowState, tfoot, footerHeight); @@ -3159,8 +3160,8 @@ nsTableFrame::ReflowChildren(nsTableReflowState& aReflowState, } else { // we can't push so lets make clear how much space we need PlaceChild(aReflowState, kidFrame, - kidPosition.GetPhysicalPoint(wm, containerWidth - - desiredSize.Width()), + kidPosition.GetPhysicalPoint(wm, + containerSize - desiredSize.PhysicalSize()), desiredSize, oldKidRect, oldKidVisualOverflow); aLastChildReflowed = kidFrame; if (allowRepeatedFooter) { @@ -3185,8 +3186,8 @@ nsTableFrame::ReflowChildren(nsTableReflowState& aReflowState, // Place the child PlaceChild(aReflowState, kidFrame, - kidPosition.GetPhysicalPoint(wm, containerWidth - - desiredSize.Width()), + kidPosition.GetPhysicalPoint(wm, containerSize - + desiredSize.PhysicalSize()), desiredSize, oldKidRect, oldKidVisualOverflow); // Remember where we just were in case we end up pushing children @@ -3233,7 +3234,7 @@ nsTableFrame::ReflowChildren(nsTableReflowState& aReflowState, } else { // it isn't being reflowed aReflowState.bCoord += cellSpacingB; - LogicalRect kidRect(wm, kidFrame->GetNormalRect(), containerWidth); + LogicalRect kidRect(wm, kidFrame->GetNormalRect(), containerSize); if (kidRect.BStart(wm) != aReflowState.bCoord) { // invalidate the old position kidFrame->InvalidateFrameSubtree(); @@ -3379,8 +3380,8 @@ nsTableFrame::DistributeBSizeToRows(const nsHTMLReflowState& aReflowState, WritingMode wm = aReflowState.GetWritingMode(); LogicalMargin borderPadding = GetChildAreaOffset(wm, &aReflowState); - nscoord containerWidth = - aReflowState.ComputedSizeAsContainerIfConstrained().width; + nsSize containerSize = + aReflowState.ComputedSizeAsContainerIfConstrained(); RowGroupArray rowGroups; OrderRowGroups(rowGroups); @@ -3397,14 +3398,16 @@ nsTableFrame::DistributeBSizeToRows(const nsHTMLReflowState& aReflowState, nsTableRowGroupFrame* rgFrame = rowGroups[rgIdx]; nscoord amountUsedByRG = 0; nscoord bOriginRow = 0; - LogicalRect rgNormalRect(wm, rgFrame->GetNormalRect(), containerWidth); + LogicalRect rgNormalRect(wm, rgFrame->GetNormalRect(), containerSize); if (!rgFrame->HasStyleBSize()) { nsTableRowFrame* rowFrame = rgFrame->GetFirstRow(); while (rowFrame) { - // We don't know the final width of the rowGroupFrame yet, so use zero - // as a "fake" containerWidth here; we'll adjust the row positions at + // We don't know the final width of the rowGroupFrame yet, so use 0,0 + // as a dummy containerSize here; we'll adjust the row positions at // the end, after the rowGroup size is finalized. - LogicalRect rowNormalRect(wm, rowFrame->GetNormalRect(), 0); + const nsSize dummyContainerSize; + LogicalRect rowNormalRect(wm, rowFrame->GetNormalRect(), + dummyContainerSize); nscoord cellSpacingB = GetRowSpacing(rowFrame->GetRowIndex()); if ((amountUsed < aAmount) && rowFrame->HasPctBSize()) { nscoord pctBSize = rowFrame->GetInitialBSize(pctBasis); @@ -3541,14 +3544,19 @@ nsTableFrame::DistributeBSizeToRows(const nsHTMLReflowState& aReflowState, nsTableRowGroupFrame* rgFrame = rowGroups[rgIdx]; nscoord amountUsedByRG = 0; nscoord bOriginRow = 0; - LogicalRect rgNormalRect(wm, rgFrame->GetNormalRect(), containerWidth); + LogicalRect rgNormalRect(wm, rgFrame->GetNormalRect(), containerSize); nsRect rgVisualOverflow = rgFrame->GetVisualOverflowRect(); // see if there is an eligible row group or we distribute to all rows if (!firstUnStyledRG || !rgFrame->HasStyleBSize() || !eligibleRows) { for (nsTableRowFrame* rowFrame = rgFrame->GetFirstRow(); rowFrame; rowFrame = rowFrame->GetNextRow()) { nscoord cellSpacingB = GetRowSpacing(rowFrame->GetRowIndex()); - LogicalRect rowNormalRect(wm, rowFrame->GetNormalRect(), 0); + // We don't know the final width of the rowGroupFrame yet, so use 0,0 + // as a dummy containerSize here; we'll adjust the row positions at + // the end, after the rowGroup size is finalized. + const nsSize dummyContainerSize; + LogicalRect rowNormalRect(wm, rowFrame->GetNormalRect(), + dummyContainerSize); nsRect rowVisualOverflow = rowFrame->GetVisualOverflowRect(); // see if there is an eligible row or we distribute to all rows if (!firstUnStyledRow || !rowFrame->HasStyleBSize() || !eligibleRows) { @@ -3630,11 +3638,11 @@ nsTableFrame::DistributeBSizeToRows(const nsHTMLReflowState& aReflowState, // For vertical-rl mode, we needed to position the rows relative to the // right-hand (block-start) side of the group; but we couldn't do that // above, as we didn't know the rowGroupFrame's final block size yet. - // So we used a containerWidth of zero earlier, placing the rows to the - // left of the rowGroupFrame's (physical) origin. Now we move them all - // rightwards by its final width. + // So we used a dummyContainerSize of 0,0 earlier, placing the rows to + // the left of the rowGroupFrame's (physical) origin. Now we move them + // all rightwards by its final width. if (wm.IsVerticalRL()) { - nscoord rgWidth = rgFrame->GetRect().width; + nscoord rgWidth = rgFrame->GetSize().width; for (nsTableRowFrame* rowFrame = rgFrame->GetFirstRow(); rowFrame; rowFrame = rowFrame->GetNextRow()) { rowFrame->InvalidateFrameSubtree(); @@ -3745,18 +3753,18 @@ nsTableFrame::GetLogicalBaseline(WritingMode aWritingMode) const RowGroupArray orderedRowGroups; OrderRowGroups(orderedRowGroups); nsTableRowFrame* firstRow = nullptr; - // XXX not sure if this should be the width of the containing block instead. - nscoord containerWidth = mRect.width; + // XXX not sure if this should be the size of the containing block instead. + nsSize containerSize = mRect.Size(); for (uint32_t rgIndex = 0; rgIndex < orderedRowGroups.Length(); rgIndex++) { nsTableRowGroupFrame* rgFrame = orderedRowGroups[rgIndex]; if (rgFrame->GetRowCount()) { firstRow = rgFrame->GetFirstRow(); nscoord rgNormalBStart = - LogicalRect(aWritingMode, rgFrame->GetNormalRect(), containerWidth) + LogicalRect(aWritingMode, rgFrame->GetNormalRect(), containerSize) .Origin(aWritingMode).B(aWritingMode); nscoord firstRowNormalBStart = - LogicalRect(aWritingMode, firstRow->GetNormalRect(), containerWidth) + LogicalRect(aWritingMode, firstRow->GetNormalRect(), containerSize) .Origin(aWritingMode).B(aWritingMode); ascent = rgNormalBStart + firstRowNormalBStart + @@ -6406,8 +6414,8 @@ BCPaintBorderIterator::BCPaintBorderIterator(nsTableFrame* aTable) bool BCPaintBorderIterator::SetDamageArea(const nsRect& aDirtyRect) { - nscoord containerWidth = mTable->GetRect().width; - LogicalRect dirtyRect(mTableWM, aDirtyRect, containerWidth); + nsSize containerSize = mTable->GetSize(); + LogicalRect dirtyRect(mTableWM, aDirtyRect, containerSize); uint32_t startRowIndex, endRowIndex, startColIndex, endColIndex; startRowIndex = endRowIndex = startColIndex = endColIndex = 0; bool done = false; @@ -6986,7 +6994,7 @@ BCBlockDirSeg::Paint(BCPaintBorderIterator& aIter, // Convert logical to physical sides/coordinates for DrawTableBorderSegment. nsRect physicalRect = segRect.GetPhysicalRect(aIter.mTableWM, - aIter.mTable->GetSize().width); + aIter.mTable->GetSize()); // XXX For reversed vertical writing-modes (with direction:rtl), we need to // invert physicalRect's y-position here, with respect to the table. // However, it's not worth fixing the border positions here until the @@ -7194,7 +7202,7 @@ BCInlineDirSeg::Paint(BCPaintBorderIterator& aIter, // Convert logical to physical sides/coordinates for DrawTableBorderSegment. nsRect physicalRect = segRect.GetPhysicalRect(aIter.mTableWM, - aIter.mTable->GetSize().width); + aIter.mTable->GetSize()); uint8_t startBevelSide = aIter.mTableWM.PhysicalSide(mIStartBevelSide); uint8_t endBevelSide = aIter.mTableWM.PhysicalSide(mIEndBevelSide); nscoord startBevelOffset = diff --git a/layout/tables/nsTableFrame.h b/layout/tables/nsTableFrame.h index ee5d1ac302..2e36aae437 100644 --- a/layout/tables/nsTableFrame.h +++ b/layout/tables/nsTableFrame.h @@ -814,7 +814,7 @@ protected: void SetColumnDimensions(nscoord aHeight, WritingMode aWM, const LogicalMargin& aBorderPadding, - nscoord aContainerWidth); + const nsSize& aContainerSize); int32_t CollectRows(nsIFrame* aFrame, nsTArray& aCollection); diff --git a/layout/tables/nsTableOuterFrame.cpp b/layout/tables/nsTableOuterFrame.cpp index f0cf4af62f..e72f397a8d 100644 --- a/layout/tables/nsTableOuterFrame.cpp +++ b/layout/tables/nsTableOuterFrame.cpp @@ -39,7 +39,7 @@ nsTableOuterFrame::GetLogicalBaseline(WritingMode aWritingMode) const } return kid->GetLogicalBaseline(aWritingMode) + - kid->BStart(aWritingMode, mRect.width); + kid->BStart(aWritingMode, mRect.Size()); } nsTableOuterFrame::nsTableOuterFrame(nsStyleContext* aContext): @@ -786,15 +786,15 @@ nsTableOuterFrame::OuterDoReflowChild(nsPresContext* aPresContext, nsHTMLReflowMetrics& aMetrics, nsReflowStatus& aStatus) { - // Using zero as containerWidth here because we want consistency between + // Using zero as containerSize here because we want consistency between // the GetLogicalPosition and ReflowChild calls, to avoid unnecessarily // changing the frame's coordinates; but we don't yet know its final // position anyway so the actual value is unimportant. - const nscoord zeroCWidth = 0; + const nsSize zeroCSize; WritingMode wm = aChildRS.GetWritingMode(); // Use the current position as a best guess for placement. - LogicalPoint childPt = aChildFrame->GetLogicalPosition(wm, zeroCWidth); + LogicalPoint childPt = aChildFrame->GetLogicalPosition(wm, zeroCSize); uint32_t flags = NS_FRAME_NO_MOVE_FRAME; // We don't want to delete our next-in-flow's child if it's an inner table @@ -807,7 +807,7 @@ nsTableOuterFrame::OuterDoReflowChild(nsPresContext* aPresContext, } ReflowChild(aChildFrame, aPresContext, aMetrics, aChildRS, - wm, childPt, zeroCWidth, flags, aStatus); + wm, childPt, zeroCSize, flags, aStatus); } void @@ -960,14 +960,14 @@ nsTableOuterFrame::Reflow(nsPresContext* aPresContext, // XXX Need to recompute inner table's auto margins for the case of side // captions. (Caption's are broken too, but that should be fixed earlier.) - // Compute the desiredSize so that we can use its Width() as containerWidth + // Compute the desiredSize so that we can use it as the containerSize // for the FinishReflowChild calls below. LogicalSize desiredSize(wm); SetDesiredSize(captionSide, innerSize, captionSize, innerMargin, captionMargin, desiredSize.ISize(wm), desiredSize.BSize(wm), wm); aDesiredSize.SetSize(wm, desiredSize); - nscoord containerWidth = aDesiredSize.Width(); + nsSize containerSize = aDesiredSize.PhysicalSize(); // XXX It's possible for this to be NS_UNCONSTRAINEDSIZE, which will result // in assertions from FinishReflowChild. @@ -976,8 +976,7 @@ nsTableOuterFrame::Reflow(nsPresContext* aPresContext, GetCaptionOrigin(captionSide, containSize, innerSize, innerMargin, captionSize, captionMargin, captionOrigin, wm); FinishReflowChild(mCaptionFrames.FirstChild(), aPresContext, *captionMet, - captionRS.ptr(), wm, captionOrigin, containerWidth, - 0); + captionRS.ptr(), wm, captionOrigin, containerSize, 0); captionRS.reset(); } // XXX If the bsize is constrained then we need to check whether @@ -987,7 +986,7 @@ nsTableOuterFrame::Reflow(nsPresContext* aPresContext, GetInnerOrigin(captionSide, containSize, captionSize, captionMargin, innerSize, innerMargin, innerOrigin, wm); FinishReflowChild(InnerTableFrame(), aPresContext, innerMet, innerRS.ptr(), - wm, innerOrigin, containerWidth, 0); + wm, innerOrigin, containerSize, 0); innerRS.reset(); nsTableFrame::InvalidateTableFrame(InnerTableFrame(), origInnerRect, diff --git a/layout/tables/nsTableRowFrame.cpp b/layout/tables/nsTableRowFrame.cpp index ccc372ce3e..c7c00b9b19 100644 --- a/layout/tables/nsTableRowFrame.cpp +++ b/layout/tables/nsTableRowFrame.cpp @@ -326,7 +326,7 @@ nsTableRowFrame::DidResize() desiredSize.SetSize(wm, GetLogicalSize(wm)); desiredSize.SetOverflowAreasToDesiredBounds(); - nscoord containerWidth = mRect.width; + nsSize containerSize = mRect.Size(); for (nsIFrame* childFrame : mFrames) { nsTableCellFrame *cellFrame = do_QueryFrame(childFrame); @@ -336,7 +336,7 @@ nsTableRowFrame::DidResize() // If the bsize for the cell has changed, we need to reset it; // and in vertical-rl mode, we need to update the cell's block position - // to account for the containerWidth, which may not have been known + // to account for the containerSize, which may not have been known // earlier, so we always apply it here. LogicalSize cellSize = cellFrame->GetLogicalSize(wm); if (cellSize.BSize(wm) != cellBSize || wm.IsVerticalRL()) { @@ -347,7 +347,7 @@ nsTableRowFrame::DidResize() // Get the old position of the cell, as we want to preserve its // inline coordinate. LogicalPoint oldPos = - cellFrame->GetLogicalPosition(wm, containerWidth); + cellFrame->GetLogicalPosition(wm, containerSize); // The cell should normally be aligned with the row's block-start, // so set the B component of the position to zero: @@ -359,7 +359,7 @@ nsTableRowFrame::DidResize() // Find out where the cell would have been without relative // positioning. LogicalPoint oldNormalPos = - cellFrame->GetLogicalNormalPosition(wm, containerWidth); + cellFrame->GetLogicalNormalPosition(wm, containerSize); // The difference (if any) between oldPos and oldNormalPos reflects // relative positioning that was applied to the cell, and which we // need to incorporate when resetting the position. @@ -367,7 +367,7 @@ nsTableRowFrame::DidResize() } if (oldPos != newPos) { - cellFrame->SetPosition(wm, newPos, containerWidth); + cellFrame->SetPosition(wm, newPos, containerSize); nsTableFrame::RePositionViews(cellFrame); } } @@ -432,13 +432,13 @@ nscoord nsTableRowFrame::GetRowBaseline(WritingMode aWM) // bbbbbbbbbbbbbbbbbb nscoord ascent = 0; - nscoord containerWidth = GetRect().width; + nsSize containerSize = GetSize(); for (nsIFrame* childFrame : mFrames) { if (IS_TABLE_CELL(childFrame->GetType())) { nsIFrame* firstKid = childFrame->GetFirstPrincipalChild(); ascent = std::max(ascent, LogicalRect(aWM, firstKid->GetNormalRect(), - containerWidth).BEnd(aWM)); + containerSize).BEnd(aWM)); } } return ascent; @@ -817,8 +817,8 @@ nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext, // Reflow each of our existing cell frames WritingMode wm = aReflowState.GetWritingMode(); - nscoord containerWidth = - aReflowState.ComputedSizeAsContainerIfConstrained().width; + nsSize containerSize = + aReflowState.ComputedSizeAsContainerIfConstrained(); for (nsIFrame* kidFrame : mFrames) { nsTableCellFrame *cellFrame = do_QueryFrame(kidFrame); @@ -878,11 +878,11 @@ nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext, // Reflow the child frame nsRect kidRect = kidFrame->GetRect(); LogicalPoint origKidNormalPosition = - kidFrame->GetLogicalNormalPosition(wm, containerWidth); + kidFrame->GetLogicalNormalPosition(wm, containerSize); // All cells' no-relative-positioning position should be snapped to the // row's bstart edge. // This doesn't hold in vertical-rl mode, where we don't yet know the - // correct containerWidth for the row frame. In that case, we'll have to + // correct containerSize for the row frame. In that case, we'll have to // fix up child positions later, after determining our desiredSize. NS_ASSERTION(origKidNormalPosition.B(wm) == 0 || wm.IsVerticalRL(), "unexpected kid position"); @@ -929,7 +929,7 @@ nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext, nsReflowStatus status; ReflowChild(kidFrame, aPresContext, desiredSize, *kidReflowState, - wm, kidPosition, containerWidth, 0, status); + wm, kidPosition, containerSize, 0, status); // allow the table to determine if/how the table needs to be rebalanced // If any of the cells are not complete, then we're not complete @@ -982,7 +982,7 @@ nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext, if (kidReflowState) { // We reflowed. Apply relative positioning in the normal way. - kidReflowState->ApplyRelativePositioning(&kidPosition, containerWidth); + kidReflowState->ApplyRelativePositioning(&kidPosition, containerSize); } else if (kidFrame->IsRelativelyPositioned()) { // We didn't reflow. Do the positioning part of what // MovePositionBy does internally. (This codepath should really @@ -994,20 +994,14 @@ nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext, LogicalMargin computedOffsets(wm, computedOffsetProp ? *computedOffsetProp : nsMargin()); nsHTMLReflowState::ApplyRelativePositioning(kidFrame, wm, computedOffsets, - &kidPosition, containerWidth); + &kidPosition, containerSize); } - // In vertical-rl writing mode, we are likely to have containerWidth 0 - // because ComputedWidth() was NS_UNCONSTRAINEDSIZE. The true value - // we need is the row's bsize, but we don't know that yet. So we'll use - // the kid's (cell's) desiredSize.Width() value for now. + // In vertical-rl mode, we are likely to have containerSize.width = 0 + // because ComputedWidth() was NS_UNCONSTRAINEDSIZE. // For cases where that's wrong, we will fix up the position later. FinishReflowChild(kidFrame, aPresContext, desiredSize, nullptr, - wm, kidPosition, - wm.IsVerticalRL() && containerWidth == 0 - ? desiredSize.Width() - : containerWidth, - 0); + wm, kidPosition, containerSize, 0); nsTableFrame::InvalidateTableFrame(kidFrame, kidRect, kidVisualOverflow, firstReflow); @@ -1162,8 +1156,8 @@ nsTableRowFrame::ReflowCellFrame(nsPresContext* aPresContext, WritingMode wm = aReflowState.GetWritingMode(); // Reflow the cell frame with the specified height. Use the existing width - nscoord containerWidth = aCellFrame->GetSize().width; - LogicalRect cellRect = aCellFrame->GetLogicalRect(wm, containerWidth); + nsSize containerSize = aCellFrame->GetSize(); + LogicalRect cellRect = aCellFrame->GetLogicalRect(wm, containerSize); nsRect cellVisualOverflow = aCellFrame->GetVisualOverflowRect(); LogicalSize cellSize = cellRect.Size(wm); @@ -1196,7 +1190,7 @@ nsTableRowFrame::ReflowCellFrame(nsPresContext* aPresContext, } nsTableFrame::InvalidateTableFrame(aCellFrame, - cellRect.GetPhysicalRect(wm, containerWidth), + cellRect.GetPhysicalRect(wm, containerSize), cellVisualOverflow, aCellFrame-> HasAnyStateBits(NS_FRAME_FIRST_REFLOW)); @@ -1227,8 +1221,8 @@ nsTableRowFrame::CollapseRowIfNecessary(nscoord aRowOffset, WritingMode wm = GetWritingMode(); - nscoord parentWidth = GetParent()->GetRect().width; - LogicalRect rowRect = GetLogicalRect(wm, parentWidth); + nsSize parentSize = GetParent()->GetSize(); + LogicalRect rowRect = GetLogicalRect(wm, parentSize); nsRect oldRect = mRect; nsRect oldVisualOverflow = GetVisualOverflowRect(); @@ -1236,7 +1230,7 @@ nsTableRowFrame::CollapseRowIfNecessary(nscoord aRowOffset, rowRect.ISize(wm) = aISize; nsOverflowAreas overflow; nscoord shift = 0; - nscoord containerWidth = mRect.width; + nsSize containerSize = mRect.Size(); if (aCollapseGroup || collapseRow) { aDidCollapse = true; @@ -1247,7 +1241,7 @@ nsTableRowFrame::CollapseRowIfNecessary(nscoord aRowOffset, cellFrame->GetRowIndex(rowIndex); shift += tableFrame->GetRowSpacing(rowIndex); while (cellFrame) { - LogicalRect cRect = cellFrame->GetLogicalRect(wm, containerWidth); + LogicalRect cRect = cellFrame->GetLogicalRect(wm, containerSize); // If aRowOffset != 0, there's no point in invalidating the cells, since // we've already invalidated our overflow area. Note that we _do_ still // need to invalidate if our row is not moving, because the cell might @@ -1256,7 +1250,7 @@ nsTableRowFrame::CollapseRowIfNecessary(nscoord aRowOffset, InvalidateFrame(); } cRect.BSize(wm) = 0; - cellFrame->SetRect(wm, cRect, containerWidth); + cellFrame->SetRect(wm, cRect, containerSize); cellFrame = cellFrame->GetNextCell(); } } else { @@ -1330,7 +1324,7 @@ nsTableRowFrame::CollapseRowIfNecessary(nscoord aRowOffset, nextRowVis->mVisible); if (!collapseNextRow) { LogicalRect nextRect = rowFrame->GetLogicalRect(wm, - containerWidth); + containerSize); cRect.BSize(wm) += nextRect.BSize(wm) + tableFrame->GetRowSpacing(rowFrame->GetRowIndex()); @@ -1340,7 +1334,7 @@ nsTableRowFrame::CollapseRowIfNecessary(nscoord aRowOffset, nsRect oldCellRect = cellFrame->GetRect(); LogicalPoint oldCellNormalPos = - cellFrame->GetLogicalNormalPosition(wm, containerWidth); + cellFrame->GetLogicalNormalPosition(wm, containerSize); nsRect oldCellVisualOverflow = cellFrame->GetVisualOverflowRect(); @@ -1356,7 +1350,7 @@ nsTableRowFrame::CollapseRowIfNecessary(nscoord aRowOffset, // collapse the cell! LogicalRect cellBounds(wm, 0, 0, cRect.ISize(wm), cRect.BSize(wm)); nsRect cellPhysicalBounds = - cellBounds.GetPhysicalRect(wm, containerWidth); + cellBounds.GetPhysicalRect(wm, containerSize); nsOverflowAreas cellOverflow(cellPhysicalBounds, cellPhysicalBounds); cellFrame->FinishAndStoreOverflow(cellOverflow, cRect.Size(wm).GetPhysicalSize(wm)); @@ -1371,7 +1365,7 @@ nsTableRowFrame::CollapseRowIfNecessary(nscoord aRowOffset, } } - SetRect(wm, rowRect, containerWidth); + SetRect(wm, rowRect, containerSize); overflow.UnionAllWith(nsRect(0, 0, rowRect.Width(wm), rowRect.Height(wm))); FinishAndStoreOverflow(overflow, rowRect.Size(wm).GetPhysicalSize(wm)); diff --git a/layout/tables/nsTableRowGroupFrame.cpp b/layout/tables/nsTableRowGroupFrame.cpp index c0d44882f2..f049c23933 100644 --- a/layout/tables/nsTableRowGroupFrame.cpp +++ b/layout/tables/nsTableRowGroupFrame.cpp @@ -261,7 +261,7 @@ nsTableRowGroupFrame::PlaceChild(nsPresContext* aPresContext, nsIFrame* aKidFrame, WritingMode aWM, const LogicalPoint& aKidPosition, - nscoord aContainerWidth, + const nsSize& aContainerSize, nsHTMLReflowMetrics& aDesiredSize, const nsRect& aOriginalKidRect, const nsRect& aOriginalKidVisualOverflow) @@ -270,7 +270,7 @@ nsTableRowGroupFrame::PlaceChild(nsPresContext* aPresContext, // Place and size the child FinishReflowChild(aKidFrame, aPresContext, aDesiredSize, nullptr, - aWM, aKidPosition, aContainerWidth, 0); + aWM, aKidPosition, aContainerSize, 0); nsTableFrame::InvalidateTableFrame(aKidFrame, aOriginalKidRect, aOriginalKidVisualOverflow, isFirstReflow); @@ -343,11 +343,11 @@ nsTableRowGroupFrame::ReflowChildren(nsPresContext* aPresContext, tableFrame->IsGeometryDirty(); // in vertical-rl mode, we always need the row bsizes in order to - // get the necessary containerWidth for placing our kids + // get the necessary containerSize for placing our kids bool needToCalcRowBSizes = reflowAllKids || wm.IsVerticalRL(); - nscoord containerWidth = - aReflowState.reflowState.ComputedSizeAsContainerIfConstrained().width; + nsSize containerSize = + aReflowState.reflowState.ComputedSizeAsContainerIfConstrained(); nsIFrame *prevKidFrame = nullptr; for (nsIFrame* kidFrame = mFrames.FirstChild(); kidFrame; @@ -367,7 +367,7 @@ nsTableRowGroupFrame::ReflowChildren(nsPresContext* aPresContext, (aReflowState.reflowState.mFlags.mSpecialBSizeReflow && (isPaginated || kidFrame->HasAnyStateBits(NS_FRAME_CONTAINS_RELATIVE_BSIZE)))) { - LogicalRect oldKidRect = kidFrame->GetLogicalRect(wm, containerWidth); + LogicalRect oldKidRect = kidFrame->GetLogicalRect(wm, containerSize); nsRect oldKidVisualOverflow = kidFrame->GetVisualOverflowRect(); // XXXldb We used to only pass aDesiredSize.mFlags through for the @@ -402,13 +402,13 @@ nsTableRowGroupFrame::ReflowChildren(nsPresContext* aPresContext, LogicalPoint kidPosition(wm, 0, aReflowState.bCoord); ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, - wm, kidPosition, containerWidth, 0, aStatus); - kidReflowState.ApplyRelativePositioning(&kidPosition, containerWidth); + wm, kidPosition, containerSize, 0, aStatus); + kidReflowState.ApplyRelativePositioning(&kidPosition, containerSize); // Place the child PlaceChild(aPresContext, aReflowState, kidFrame, - wm, kidPosition, containerWidth, - desiredSize, oldKidRect.GetPhysicalRect(wm, containerWidth), + wm, kidPosition, containerSize, + desiredSize, oldKidRect.GetPhysicalRect(wm, containerSize), oldKidVisualOverflow); aReflowState.bCoord += cellSpacingB; @@ -552,10 +552,10 @@ nsTableRowGroupFrame::CalculateRowBSizes(nsPresContext* aPresContext, // The current row group block-size is the block-origin of the 1st row // we are about to calculate a block-size for. WritingMode wm = aReflowState.GetWritingMode(); - nscoord containerWidth = 0; // actual value is unimportant as we're initially - // computing sizes, not physical positions + nsSize containerSize; // actual value is unimportant as we're initially + // computing sizes, not physical positions nscoord startRowGroupBSize = - startRowFrame->GetLogicalNormalPosition(wm, containerWidth).B(wm); + startRowFrame->GetLogicalNormalPosition(wm, containerSize).B(wm); int32_t numRows = GetRowCount() - (startRowFrame->GetRowIndex() - GetStartRowIndex()); // Collect the current bsize of each row. @@ -781,9 +781,9 @@ nsTableRowGroupFrame::CalculateRowBSizes(nsPresContext* aPresContext, } if (wm.IsVertical()) { - // we need the correct containerWidth below for block positioning in + // we need the correct containerSize below for block positioning in // vertical-rl writing mode - containerWidth = rowGroupBSize; + containerSize.width = rowGroupBSize; } nscoord bOrigin = startRowGroupBSize; @@ -794,7 +794,7 @@ nsTableRowGroupFrame::CalculateRowBSizes(nsPresContext* aPresContext, LogicalSize rowBoundsSize(wm, rowBounds.Size()); nsRect rowVisualOverflow = rowFrame->GetVisualOverflowRect(); nscoord deltaB = - bOrigin - rowFrame->GetLogicalNormalPosition(wm, containerWidth).B(wm); + bOrigin - rowFrame->GetLogicalNormalPosition(wm, containerSize).B(wm); nscoord rowBSize = (rowInfo[rowIndex].bSize > 0) ? rowInfo[rowIndex].bSize : 0; @@ -835,7 +835,7 @@ nsTableRowGroupFrame::CollapseRowGroupIfNecessary(nscoord aBTotalOffset, WritingMode aWM) { nsTableFrame* tableFrame = GetTableFrame(); - nscoord containerWidth = tableFrame->GetRect().width; + nsSize containerSize = tableFrame->GetSize(); const nsStyleVisibility* groupVis = StyleVisibility(); bool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupVis->mVisible); if (collapseGroup) { @@ -855,7 +855,7 @@ nsTableRowGroupFrame::CollapseRowGroupIfNecessary(nscoord aBTotalOffset, rowFrame = rowFrame->GetNextRow(); } - LogicalRect groupRect = GetLogicalRect(aWM, containerWidth); + LogicalRect groupRect = GetLogicalRect(aWM, containerSize); nsRect oldGroupRect = GetRect(); nsRect oldGroupVisualOverflow = GetVisualOverflowRect(); @@ -873,7 +873,7 @@ nsTableRowGroupFrame::CollapseRowGroupIfNecessary(nscoord aBTotalOffset, InvalidateFrameSubtree(); } - SetRect(aWM, groupRect, containerWidth); + SetRect(aWM, groupRect, containerSize); overflow.UnionAllWith(nsRect(0, 0, groupRect.Width(aWM), groupRect.Height(aWM))); FinishAndStoreOverflow(overflow, groupRect.Size(aWM).GetPhysicalSize(aWM)); @@ -889,15 +889,19 @@ void nsTableRowGroupFrame::SlideChild(nsRowGroupReflowState& aReflowState, nsIFrame* aKidFrame) { - // Move the frame if we need to + // Move the frame if we need to. WritingMode wm = aReflowState.reflowState.GetWritingMode(); - LogicalPoint oldPosition = aKidFrame->GetLogicalNormalPosition(wm, 0); + const nsSize containerSize = + aReflowState.reflowState.ComputedSizeAsContainerIfConstrained(); + LogicalPoint oldPosition = + aKidFrame->GetLogicalNormalPosition(wm, containerSize); LogicalPoint newPosition = oldPosition; newPosition.B(wm) = aReflowState.bCoord; if (oldPosition.B(wm) != newPosition.B(wm)) { aKidFrame->InvalidateFrameSubtree(); - aReflowState.reflowState.ApplyRelativePositioning(&newPosition, 0); - aKidFrame->SetPosition(wm, newPosition, 0); + aReflowState.reflowState.ApplyRelativePositioning(&newPosition, + containerSize); + aKidFrame->SetPosition(wm, newPosition, containerSize); nsTableFrame::RePositionViews(aKidFrame); aKidFrame->InvalidateFrameSubtree(); } @@ -1762,8 +1766,8 @@ nsTableRowGroupFrame::FindFrameAt(int32_t aLineNumber, nsTableCellMap* cellMap = table->GetCellMap(); WritingMode wm = table->GetWritingMode(); - nscoord cw = table->GetRect().width; - LogicalPoint pos(wm, aPos, cw); + nsSize containerSize = table->GetSize(); + LogicalPoint pos(wm, aPos, containerSize); *aFrameFound = nullptr; *aPosIsBeforeFirstFrame = true; @@ -1793,7 +1797,7 @@ nsTableRowGroupFrame::FindFrameAt(int32_t aLineNumber, int32_t n = numCells; nsIFrame* firstFrame = frame; while (n--) { - LogicalRect rect = frame->GetLogicalRect(wm, cw); + LogicalRect rect = frame->GetLogicalRect(wm, containerSize); if (rect.ISize(wm) > 0) { // If pos.I() is inside this frame - this is it if (rect.IStart(wm) <= pos.I(wm) && rect.IEnd(wm) > pos.I(wm)) { @@ -1802,12 +1806,14 @@ nsTableRowGroupFrame::FindFrameAt(int32_t aLineNumber, } if (rect.IStart(wm) < pos.I(wm)) { if (!closestFromStart || - rect.IEnd(wm) > closestFromStart->GetLogicalRect(wm, cw).IEnd(wm)) + rect.IEnd(wm) > closestFromStart-> + GetLogicalRect(wm, containerSize).IEnd(wm)) closestFromStart = frame; } else { if (!closestFromEnd || - rect.IStart(wm) < closestFromEnd->GetLogicalRect(wm, cw).IStart(wm)) + rect.IStart(wm) < closestFromEnd-> + GetLogicalRect(wm, containerSize).IStart(wm)) closestFromEnd = frame; } } @@ -1829,9 +1835,11 @@ nsTableRowGroupFrame::FindFrameAt(int32_t aLineNumber, *aFrameFound = closestFromStart; } else { // we're between two frames - nscoord delta = closestFromEnd->GetLogicalRect(wm, cw).IStart(wm) - - closestFromStart->GetLogicalRect(wm, cw).IEnd(wm); - if (pos.I(wm) < closestFromStart->GetLogicalRect(wm, cw).IEnd(wm) + delta/2) { + nscoord delta = + closestFromEnd->GetLogicalRect(wm, containerSize).IStart(wm) - + closestFromStart->GetLogicalRect(wm, containerSize).IEnd(wm); + if (pos.I(wm) < closestFromStart-> + GetLogicalRect(wm, containerSize).IEnd(wm) + delta/2) { *aFrameFound = closestFromStart; } else { *aFrameFound = closestFromEnd; diff --git a/layout/tables/nsTableRowGroupFrame.h b/layout/tables/nsTableRowGroupFrame.h index a60669eead..bc03b75d64 100644 --- a/layout/tables/nsTableRowGroupFrame.h +++ b/layout/tables/nsTableRowGroupFrame.h @@ -355,7 +355,7 @@ protected: nsIFrame* aKidFrame, mozilla::WritingMode aWM, const mozilla::LogicalPoint& aKidPosition, - nscoord aContainerWidth, + const nsSize& aContainerSize, nsHTMLReflowMetrics& aDesiredSize, const nsRect& aOriginalKidRect, const nsRect& aOriginalKidVisualOverflow); diff --git a/layout/xul/nsTextBoxFrame.cpp b/layout/xul/nsTextBoxFrame.cpp index e24561e2b2..6e05a6d883 100644 --- a/layout/xul/nsTextBoxFrame.cpp +++ b/layout/xul/nsTextBoxFrame.cpp @@ -964,7 +964,7 @@ nsTextBoxFrame::DoLayout(nsBoxLayoutState& aBoxLayoutState) aBoxLayoutState.GetRenderingContext()); WritingMode wm = GetWritingMode(); - LogicalRect tr(wm, textRect, GetSize().width); + LogicalRect tr(wm, textRect, GetSize()); tr.IStart(wm) -= metrics.leftBearing; tr.ISize(wm) = metrics.width; @@ -972,7 +972,7 @@ nsTextBoxFrame::DoLayout(nsBoxLayoutState& aBoxLayoutState) tr.BStart(wm) += fontMet->MaxAscent() - metrics.ascent; tr.BSize(wm) = metrics.ascent + metrics.descent; - textRect = tr.GetPhysicalRect(wm, GetSize().width); + textRect = tr.GetPhysicalRect(wm, GetSize()); // Our scrollable overflow is our bounds; our visual overflow may // extend beyond that. @@ -1095,7 +1095,7 @@ nsTextBoxFrame::CalcDrawRect(nsRenderingContext &aRenderingContext) textRect.IStart(wm) += (outerISize - textRect.ISize(wm)); } - mTextDrawRect = textRect.GetPhysicalRect(wm, GetSize().width); + mTextDrawRect = textRect.GetPhysicalRect(wm, GetSize()); } /** diff --git a/media/webrtc/moz.build b/media/webrtc/moz.build index f6ff3c15be..04d4566929 100644 --- a/media/webrtc/moz.build +++ b/media/webrtc/moz.build @@ -105,3 +105,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': build_for_standalone=1 ) GYP_DIRS['signalingstandalone'].non_unified_sources += signaling_non_unified_sources + +if CONFIG['MOZ_X11']: + CXXFLAGS += CONFIG['TK_CFLAGS'] +