Bug 931460. Part 2: Call ApplyRelativePositioning on fieldset legends so that sticky and relative positioning works on them. r=mats
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
#include "nsRenderingContext.h"
|
#include "nsRenderingContext.h"
|
||||||
#include "nsIScrollableFrame.h"
|
#include "nsIScrollableFrame.h"
|
||||||
#include "mozilla/Likely.h"
|
#include "mozilla/Likely.h"
|
||||||
|
#include "mozilla/Maybe.h"
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
using namespace mozilla::layout;
|
using namespace mozilla::layout;
|
||||||
@@ -475,13 +476,14 @@ nsFieldSetFrame::Reflow(nsPresContext* aPresContext,
|
|||||||
// get the legend's margin
|
// get the legend's margin
|
||||||
nsMargin legendMargin(0,0,0,0);
|
nsMargin legendMargin(0,0,0,0);
|
||||||
// reflow the legend only if needed
|
// reflow the legend only if needed
|
||||||
|
Maybe<nsHTMLReflowState> legendReflowState;
|
||||||
|
if (legend) {
|
||||||
|
legendReflowState.construct(aPresContext, aReflowState, legend, availSize);
|
||||||
|
}
|
||||||
if (reflowLegend) {
|
if (reflowLegend) {
|
||||||
nsHTMLReflowState legendReflowState(aPresContext, aReflowState,
|
|
||||||
legend, availSize);
|
|
||||||
|
|
||||||
nsHTMLReflowMetrics legendDesiredSize;
|
nsHTMLReflowMetrics legendDesiredSize;
|
||||||
|
|
||||||
ReflowChild(legend, aPresContext, legendDesiredSize, legendReflowState,
|
ReflowChild(legend, aPresContext, legendDesiredSize, legendReflowState.ref(),
|
||||||
0, 0, NS_FRAME_NO_MOVE_FRAME, aStatus);
|
0, 0, NS_FRAME_NO_MOVE_FRAME, aStatus);
|
||||||
#ifdef NOISY_REFLOW
|
#ifdef NOISY_REFLOW
|
||||||
printf(" returned (%d, %d)\n", legendDesiredSize.width, legendDesiredSize.height);
|
printf(" returned (%d, %d)\n", legendDesiredSize.width, legendDesiredSize.height);
|
||||||
@@ -508,7 +510,7 @@ nsFieldSetFrame::Reflow(nsPresContext* aPresContext,
|
|||||||
reflowInner = true;
|
reflowInner = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FinishReflowChild(legend, aPresContext, &legendReflowState,
|
FinishReflowChild(legend, aPresContext, &legendReflowState.ref(),
|
||||||
legendDesiredSize, 0, 0, NS_FRAME_NO_MOVE_FRAME);
|
legendDesiredSize, 0, 0, NS_FRAME_NO_MOVE_FRAME);
|
||||||
} else if (!legend) {
|
} else if (!legend) {
|
||||||
mLegendRect.SetEmpty();
|
mLegendRect.SetEmpty();
|
||||||
@@ -597,21 +599,15 @@ nsFieldSetFrame::Reflow(nsPresContext* aPresContext,
|
|||||||
innerContentRect.width = mLegendRect.width;
|
innerContentRect.width = mLegendRect.width;
|
||||||
contentRect.width = mLegendRect.width + aReflowState.mComputedPadding.LeftRight();
|
contentRect.width = mLegendRect.width + aReflowState.mComputedPadding.LeftRight();
|
||||||
}
|
}
|
||||||
|
|
||||||
// place the legend
|
// place the legend
|
||||||
nsRect actualLegendRect(mLegendRect);
|
nsRect actualLegendRect(mLegendRect);
|
||||||
actualLegendRect.Deflate(legendMargin);
|
actualLegendRect.Deflate(legendMargin);
|
||||||
|
nsPoint actualLegendPos(actualLegendRect.TopLeft());
|
||||||
nsPoint curOrigin = legend->GetPosition();
|
legendReflowState.ref().ApplyRelativePositioning(&actualLegendPos);
|
||||||
|
legend->SetPosition(actualLegendPos);
|
||||||
// only if the origin changed
|
nsContainerFrame::PositionFrameView(legend);
|
||||||
if ((curOrigin.x != actualLegendRect.x) || (curOrigin.y != actualLegendRect.y)) {
|
nsContainerFrame::PositionChildViews(legend);
|
||||||
legend->SetPosition(nsPoint(actualLegendRect.x , actualLegendRect.y));
|
|
||||||
nsContainerFrame::PositionFrameView(legend);
|
|
||||||
|
|
||||||
// We need to recursively process the legend frame's
|
|
||||||
// children since we're moving the frame after Reflow.
|
|
||||||
nsContainerFrame::PositionChildViews(legend);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return our size and our result
|
// Return our size and our result
|
||||||
|
|||||||
@@ -6,3 +6,6 @@
|
|||||||
== fieldset-scrolled-1.html fieldset-scrolled-1-ref.html
|
== fieldset-scrolled-1.html fieldset-scrolled-1-ref.html
|
||||||
random-if(B2G) == fieldset-overflow-auto-1.html fieldset-overflow-auto-1-ref.html
|
random-if(B2G) == fieldset-overflow-auto-1.html fieldset-overflow-auto-1-ref.html
|
||||||
== positioned-container-1.html positioned-container-1-ref.html
|
== positioned-container-1.html positioned-container-1-ref.html
|
||||||
|
== relpos-legend-1.html relpos-legend-1-ref.html
|
||||||
|
== relpos-legend-2.html relpos-legend-2-ref.html
|
||||||
|
== sticky-legend-1.html sticky-legend-1-ref.html
|
||||||
|
|||||||
8
layout/reftests/forms/fieldset/relpos-legend-1-ref.html
Normal file
8
layout/reftests/forms/fieldset/relpos-legend-1-ref.html
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<fieldset>
|
||||||
|
<legend><div style="position:relative; top:20px">Legend</div></legend>
|
||||||
|
</fieldset>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
8
layout/reftests/forms/fieldset/relpos-legend-1.html
Normal file
8
layout/reftests/forms/fieldset/relpos-legend-1.html
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<fieldset>
|
||||||
|
<legend style="position:relative; top:20px">Legend</legend>
|
||||||
|
</fieldset>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
8
layout/reftests/forms/fieldset/relpos-legend-2-ref.html
Normal file
8
layout/reftests/forms/fieldset/relpos-legend-2-ref.html
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<fieldset>
|
||||||
|
<legend><span style="position:relative; top:20px">Legend</span></legend>
|
||||||
|
</fieldset>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
8
layout/reftests/forms/fieldset/relpos-legend-2.html
Normal file
8
layout/reftests/forms/fieldset/relpos-legend-2.html
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<fieldset>
|
||||||
|
<legend style="display:inline; position:relative; top:20px">Legend</legend>
|
||||||
|
</fieldset>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
12
layout/reftests/forms/fieldset/sticky-legend-1-ref.html
Normal file
12
layout/reftests/forms/fieldset/sticky-legend-1-ref.html
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<fieldset style="overflow:hidden; height:300px;">
|
||||||
|
<legend style="position:fixed; top:0"><div style="width:200px; height:50px; background:yellow;"></div></legend>
|
||||||
|
</fieldset>
|
||||||
|
<div style="height:5000px;"></div>
|
||||||
|
<script>
|
||||||
|
window.scrollTo(0,100);
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
12
layout/reftests/forms/fieldset/sticky-legend-1.html
Normal file
12
layout/reftests/forms/fieldset/sticky-legend-1.html
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<fieldset style="overflow:hidden; height:300px;">
|
||||||
|
<legend style="position:sticky; top:0;"><div style="width:200px; height:50px; background:yellow;"></div></legend>
|
||||||
|
</fieldset>
|
||||||
|
<div style="height:5000px;"></div>
|
||||||
|
<script>
|
||||||
|
window.scrollTo(0,100);
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user