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 (aDY) {
nsPoint p = kid->GetPosition();
p.y += aDY;
kid->SetPosition(p);
kid->MovePositionBy(nsPoint(0, aDY));
}
// 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();
while (--n >= 0) {
if (aDY) {
nsPoint p = kid->GetPosition();
p.y += aDY;
kid->SetPosition(p);
kid->MovePositionBy(nsPoint(0, aDY));
}
// Make sure the frame's view and any child views are updated
::PlaceFrameView(kid);

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

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

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

@ -5070,6 +5070,22 @@ ComputeOutlineAndEffectsRect(nsIFrame* aFrame,
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
nsIFrame::GetNormalPosition() const
{

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

@ -866,6 +866,13 @@ public:
}
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
*/

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

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