From 613ce7eae37df03b87baca0cb5fbeb0715cde3d6 Mon Sep 17 00:00:00 2001 From: "dbaron%fas.harvard.edu" Date: Sat, 9 Dec 2000 04:04:17 +0000 Subject: [PATCH] Make relatively positioned elements matter to their parents only at the original position by switching the order of computing the combined rect and computing relative positioning. b=4519 r=buster@netscape.com sr=waterson@netscape.com git-svn-id: svn://10.0.0.236/trunk@83437 18797224-902f-48f8-a5cc-f745e15eee43 --- .../layout/generic/nsBlockReflowContext.cpp | 22 +++++++++++-------- .../html/base/src/nsBlockReflowContext.cpp | 22 +++++++++++-------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/mozilla/layout/generic/nsBlockReflowContext.cpp b/mozilla/layout/generic/nsBlockReflowContext.cpp index 5cda9fdd24f..5bdce97e42e 100644 --- a/mozilla/layout/generic/nsBlockReflowContext.cpp +++ b/mozilla/layout/generic/nsBlockReflowContext.cpp @@ -18,6 +18,7 @@ * Rights Reserved. * * Contributor(s): + * David Baron */ #include "nsBlockReflowContext.h" #include "nsLineLayout.h" @@ -737,15 +738,6 @@ nsBlockReflowContext::PlaceBlock(PRBool aForceFit, mMetrics.height); - // Apply CSS relative positioning to update x,y coordinates - const nsStylePosition* stylePos; - mFrame->GetStyleData(eStyleStruct_Position, - (const nsStyleStruct*&)stylePos); - if (NS_STYLE_POSITION_RELATIVE == stylePos->mPosition) { - x += aComputedOffsets.left; - y += aComputedOffsets.top; - } - // Compute combined-rect in callers coordinate system. The value // returned in the reflow metrics is relative to the child // frame. @@ -754,6 +746,18 @@ nsBlockReflowContext::PlaceBlock(PRBool aForceFit, aCombinedRect.width = mMetrics.mOverflowArea.width; aCombinedRect.height = mMetrics.mOverflowArea.height; + // Apply CSS relative positioning to update x,y coordinates + // Note that this must be done after changing aCombinedRect + // since relatively positioned elements should act as if they + // were at their original position. + const nsStylePosition* stylePos; + mFrame->GetStyleData(eStyleStruct_Position, + (const nsStyleStruct*&)stylePos); + if (NS_STYLE_POSITION_RELATIVE == stylePos->mPosition) { + x += aComputedOffsets.left; + y += aComputedOffsets.top; + } + // Now place the frame and complete the reflow process nsContainerFrame::FinishReflowChild(mFrame, mPresContext, mMetrics, x, y, 0); diff --git a/mozilla/layout/html/base/src/nsBlockReflowContext.cpp b/mozilla/layout/html/base/src/nsBlockReflowContext.cpp index 5cda9fdd24f..5bdce97e42e 100644 --- a/mozilla/layout/html/base/src/nsBlockReflowContext.cpp +++ b/mozilla/layout/html/base/src/nsBlockReflowContext.cpp @@ -18,6 +18,7 @@ * Rights Reserved. * * Contributor(s): + * David Baron */ #include "nsBlockReflowContext.h" #include "nsLineLayout.h" @@ -737,15 +738,6 @@ nsBlockReflowContext::PlaceBlock(PRBool aForceFit, mMetrics.height); - // Apply CSS relative positioning to update x,y coordinates - const nsStylePosition* stylePos; - mFrame->GetStyleData(eStyleStruct_Position, - (const nsStyleStruct*&)stylePos); - if (NS_STYLE_POSITION_RELATIVE == stylePos->mPosition) { - x += aComputedOffsets.left; - y += aComputedOffsets.top; - } - // Compute combined-rect in callers coordinate system. The value // returned in the reflow metrics is relative to the child // frame. @@ -754,6 +746,18 @@ nsBlockReflowContext::PlaceBlock(PRBool aForceFit, aCombinedRect.width = mMetrics.mOverflowArea.width; aCombinedRect.height = mMetrics.mOverflowArea.height; + // Apply CSS relative positioning to update x,y coordinates + // Note that this must be done after changing aCombinedRect + // since relatively positioned elements should act as if they + // were at their original position. + const nsStylePosition* stylePos; + mFrame->GetStyleData(eStyleStruct_Position, + (const nsStyleStruct*&)stylePos); + if (NS_STYLE_POSITION_RELATIVE == stylePos->mPosition) { + x += aComputedOffsets.left; + y += aComputedOffsets.top; + } + // Now place the frame and complete the reflow process nsContainerFrame::FinishReflowChild(mFrame, mPresContext, mMetrics, x, y, 0);