Bug 911786 - Part 2: Reapply relative positioning when moving frames without reflowing them. r=dholbert

This commit is contained in:
Corey Ford 2013-09-11 11:51:42 -07:00
Родитель 23d185d13b
Коммит c885568e56
5 изменённых файлов: 27 добавлений и 11 удалений

Просмотреть файл

@ -2582,9 +2582,7 @@ nsBlockFrame::SlideLine(nsBlockReflowState& aState,
if (aLine->IsBlock()) { if (aLine->IsBlock()) {
if (aDY) { if (aDY) {
nsPoint p = kid->GetPosition(); kid->MovePositionBy(nsPoint(0, aDY));
p.y += aDY;
kid->SetPosition(p);
} }
// Make sure the frame's view and any child views are updated // Make sure the frame's view and any child views are updated
@ -2598,9 +2596,7 @@ nsBlockFrame::SlideLine(nsBlockReflowState& aState,
int32_t n = aLine->GetChildCount(); int32_t n = aLine->GetChildCount();
while (--n >= 0) { while (--n >= 0) {
if (aDY) { if (aDY) {
nsPoint p = kid->GetPosition(); kid->MovePositionBy(nsPoint(0, aDY));
p.y += aDY;
kid->SetPosition(p);
} }
// Make sure the frame's view and any child views are updated // Make sure the frame's view and any child views are updated
::PlaceFrameView(kid); ::PlaceFrameView(kid);

Просмотреть файл

@ -386,8 +386,7 @@ nsBlockReflowState::RecoverFloats(nsLineList::iterator aLine,
while (fc) { while (fc) {
nsIFrame* floatFrame = fc->mFloat; nsIFrame* floatFrame = fc->mFloat;
if (aDeltaY != 0) { if (aDeltaY != 0) {
nsPoint p = floatFrame->GetPosition(); floatFrame->MovePositionBy(nsPoint(0, aDeltaY));
floatFrame->SetPosition(nsPoint(p.x, p.y + aDeltaY));
nsContainerFrame::PositionFrameView(floatFrame); nsContainerFrame::PositionFrameView(floatFrame);
nsContainerFrame::PositionChildViews(floatFrame); nsContainerFrame::PositionChildViews(floatFrame);
} }

Просмотреть файл

@ -5070,6 +5070,22 @@ ComputeOutlineAndEffectsRect(nsIFrame* aFrame,
return r; return r;
} }
void
nsIFrame::MovePositionBy(const nsPoint& aTranslation)
{
nsPoint position = GetNormalPosition() + aTranslation;
const nsMargin* computedOffsets = nullptr;
if (IsRelativelyPositioned()) {
computedOffsets = static_cast<nsMargin*>
(Properties().Get(nsIFrame::ComputedOffsetProperty()));
}
nsHTMLReflowState::ApplyRelativePositioning(this, computedOffsets ?
*computedOffsets : nsMargin(),
&position);
SetPosition(position);
}
nsPoint nsPoint
nsIFrame::GetNormalPosition() const nsIFrame::GetNormalPosition() const
{ {

Просмотреть файл

@ -866,6 +866,13 @@ public:
} }
void SetPosition(const nsPoint& aPt) { mRect.MoveTo(aPt); } void SetPosition(const nsPoint& aPt) { mRect.MoveTo(aPt); }
/**
* Move the frame, accounting for relative positioning. Use this when
* adjusting the frame's position by a known amount, to properly update its
* saved normal position (see GetNormalPosition below).
*/
void MovePositionBy(const nsPoint& aTranslation);
/** /**
* Return frame's position without relative positioning * Return frame's position without relative positioning
*/ */

Просмотреть файл

@ -2196,9 +2196,7 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd)
static void SlideSpanFrameRect(nsIFrame* aFrame, nscoord aDeltaWidth) static void SlideSpanFrameRect(nsIFrame* aFrame, nscoord aDeltaWidth)
{ {
nsRect r = aFrame->GetRect(); aFrame->MovePositionBy(nsPoint(-aDeltaWidth, 0));
r.x -= aDeltaWidth;
aFrame->SetRect(r);
} }
bool bool