Bug 1055658 part 1 - Move code for applying relative position to an independent method. r=dbaron
--- a/layout/generic/nsLineLayout.cpp
+++ b/layout/generic/nsLineLayout.cpp
@@ -3016,16 +3016,35 @@ nsLineLayout::TextAlignLine(nsLineBox* a
}
void
nsLineLayout::RelativePositionFrames(nsOverflowAreas& aOverflowAreas)
{
RelativePositionFrames(mRootSpan, aOverflowAreas);
}
+// This method applies any relative positioning to the given frame.
+void
+nsLineLayout::ApplyRelativePositioning(PerFrameData* aPFD)
+{
+ if (!aPFD->mRelativePos) {
+ return;
+ }
+
+ nsIFrame* frame = aPFD->mFrame;
+ WritingMode frameWM = frame->GetWritingMode();
+ LogicalPoint origin = frame->GetLogicalPosition(mContainerWidth);
+ // right and bottom are handled by
+ // nsHTMLReflowState::ComputeRelativeOffsets
+ nsHTMLReflowState::ApplyRelativePositioning(frame, frameWM,
+ aPFD->mOffsets, &origin,
+ mContainerWidth);
+ frame->SetPosition(frameWM, origin, mContainerWidth);
+}
+
void
nsLineLayout::RelativePositionFrames(PerSpanData* psd, nsOverflowAreas& aOverflowAreas)
{
nsOverflowAreas overflowAreas;
WritingMode wm = psd->mWritingMode;
if (psd != mRootSpan) {
// The span's overflow areas come in three parts:
// -- this frame's width and height
@@ -3054,26 +3073,17 @@ nsLineLayout::RelativePositionFrames(Per
overflowAreas.VisualOverflow() = rect.GetPhysicalRect(wm, mContainerWidth);
overflowAreas.ScrollableOverflow() = overflowAreas.VisualOverflow();
}
for (PerFrameData* pfd = psd->mFirstFrame; pfd; pfd = pfd->mNext) {
nsIFrame* frame = pfd->mFrame;
// Adjust the origin of the frame
- if (pfd->mRelativePos) {
- WritingMode frameWM = frame->GetWritingMode();
- LogicalPoint origin = frame->GetLogicalPosition(mContainerWidth);
- // right and bottom are handled by
- // nsHTMLReflowState::ComputeRelativeOffsets
- nsHTMLReflowState::ApplyRelativePositioning(frame, frameWM,
- pfd->mOffsets, &origin,
- mContainerWidth);
- frame->SetPosition(frameWM, origin, mContainerWidth);
- }
+ ApplyRelativePositioning(pfd);
// We must position the view correctly before positioning its
// descendants so that widgets are positioned properly (since only
// some views have widgets).
if (frame->HasView())
nsContainerFrame::SyncFrameViewAfterReflow(mPresContext, frame,
frame->GetView(), pfd->mOverflowAreas.VisualOverflow(),
NS_FRAME_NO_SIZE_VIEW);
--- a/layout/generic/nsLineLayout.h
+++ b/layout/generic/nsLineLayout.h
@@ -660,16 +660,18 @@ protected:
nsHTMLReflowMetrics& aMetrics);
void VerticalAlignFrames(PerSpanData* psd);
void PlaceTopBottomFrames(PerSpanData* psd,
nscoord aDistanceFromStart,
nscoord aLineBSize);
+ void ApplyRelativePositioning(PerFrameData* aPFD);
+
void RelativePositionFrames(PerSpanData* psd, nsOverflowAreas& aOverflowAreas);
bool TrimTrailingWhiteSpaceIn(PerSpanData* psd, nscoord* aDeltaISize);
struct JustificationComputationState;
int32_t ComputeFrameJustification(PerSpanData* psd,
JustificationComputationState& aState);