Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
Backout bug 157681 in order to fix bug 775350 on Beta; a=lsblakk
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsan committed Sep 26, 2012
1 parent 589fce8 commit d919887
Show file tree
Hide file tree
Showing 149 changed files with 61 additions and 2,756 deletions.
153 changes: 1 addition & 152 deletions layout/base/nsCSSFrameConstructor.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@
#include "mozilla/dom/Element.h" #include "mozilla/dom/Element.h"
#include "FrameLayerBuilder.h" #include "FrameLayerBuilder.h"
#include "nsAutoLayoutPhase.h" #include "nsAutoLayoutPhase.h"
#include "nsCSSRenderingBorders.h"
#include "nsRenderingContext.h"
#include "nsStyleStructInlines.h" #include "nsStyleStructInlines.h"


#ifdef MOZ_XUL #ifdef MOZ_XUL
Expand Down Expand Up @@ -8045,7 +8043,6 @@ nsCSSFrameConstructor::ProcessRestyledFrames(nsStyleChangeList& aChangeList)
while (0 <= --index) { while (0 <= --index) {
nsIFrame* frame; nsIFrame* frame;
nsIContent* content; nsIContent* content;
bool didReflowThisFrame = false;
nsChangeHint hint; nsChangeHint hint;
aChangeList.ChangeAt(index, frame, content, hint); aChangeList.ChangeAt(index, frame, content, hint);


Expand Down Expand Up @@ -8098,25 +8095,17 @@ nsCSSFrameConstructor::ProcessRestyledFrames(nsStyleChangeList& aChangeList)
if (hint & nsChangeHint_NeedReflow) { if (hint & nsChangeHint_NeedReflow) {
StyleChangeReflow(frame, hint); StyleChangeReflow(frame, hint);
didReflow = true; didReflow = true;
didReflowThisFrame = true;
} }
if (hint & (nsChangeHint_RepaintFrame | nsChangeHint_SyncFrameView | if (hint & (nsChangeHint_RepaintFrame | nsChangeHint_SyncFrameView |
nsChangeHint_UpdateOpacityLayer | nsChangeHint_UpdateTransformLayer | nsChangeHint_UpdateOpacityLayer | nsChangeHint_UpdateTransformLayer |
nsChangeHint_ChildrenOnlyTransform)) { nsChangeHint_ChildrenOnlyTransform)) {
ApplyRenderingChangeToTree(presContext, frame, hint); ApplyRenderingChangeToTree(presContext, frame, hint);
didInvalidate = true; didInvalidate = true;
} }
if ((hint & nsChangeHint_RecomputePosition) && !didReflowThisFrame) {
// It is possible for this to fall back to a reflow
if (!RecomputePosition(frame)) {
didReflow = true;
didReflowThisFrame = true;
}
}
NS_ASSERTION(!(hint & nsChangeHint_ChildrenOnlyTransform) || NS_ASSERTION(!(hint & nsChangeHint_ChildrenOnlyTransform) ||
(hint & nsChangeHint_UpdateOverflow), (hint & nsChangeHint_UpdateOverflow),
"nsChangeHint_UpdateOverflow should be passed too"); "nsChangeHint_UpdateOverflow should be passed too");
if ((hint & nsChangeHint_UpdateOverflow) && !didReflowThisFrame) { if ((hint & nsChangeHint_UpdateOverflow) && !didReflow) {
if (hint & nsChangeHint_ChildrenOnlyTransform) { if (hint & nsChangeHint_ChildrenOnlyTransform) {
// When we process restyle events starting from the root of the frame // When we process restyle events starting from the root of the frame
// tree, we start at a ViewportFrame and traverse down the tree from // tree, we start at a ViewportFrame and traverse down the tree from
Expand Down Expand Up @@ -12420,143 +12409,3 @@ Iterator::DeleteItemsTo(const Iterator& aEnd)
delete item; delete item;
} while (*this != aEnd); } while (*this != aEnd);
} }

bool
nsCSSFrameConstructor::RecomputePosition(nsIFrame* aFrame)
{
// Don't process position changes on table frames, since we already handle
// the dynamic position change on the outer table frame, and the reflow-based
// fallback code path also ignores positions on inner table frames.
if (aFrame->GetType() == nsGkAtoms::tableFrame) {
return true;
}

// Don't process position changes on frames which have views or the ones which
// have a view somewhere in their descendants, because the corresponding view
// needs to be repositioned properly as well.
if (aFrame->HasView() ||
(aFrame->GetStateBits() & NS_FRAME_HAS_CHILD_WITH_VIEW)) {
StyleChangeReflow(aFrame, nsChangeHint_NeedReflow);
return false;
}

const nsStyleDisplay* display = aFrame->GetStyleDisplay();
// Changes to the offsets of a non-positioned element can safely be ignored.
if (display->mPosition == NS_STYLE_POSITION_STATIC) {
return true;
}

// For relative positioning, we can simply update the frame rect
if (display->mPosition == NS_STYLE_POSITION_RELATIVE) {
nsIFrame* cb = aFrame->GetContainingBlock();
const nsSize size = cb->GetSize();
const nsPoint oldOffsets = aFrame->GetRelativeOffset();
nsMargin newOffsets;

// Invalidate the old rect
aFrame->InvalidateOverflowRect();

// Move the frame
nsHTMLReflowState::ComputeRelativeOffsets(
cb->GetStyleVisibility()->mDirection,
aFrame, size.width, size.height, newOffsets);
NS_ASSERTION(newOffsets.left == -newOffsets.right &&
newOffsets.top == -newOffsets.bottom,
"ComputeRelativeOffsets should return valid results");
aFrame->SetPosition(aFrame->GetPosition() - oldOffsets +
nsPoint(newOffsets.left, newOffsets.top));

// Invalidate the new rect
aFrame->InvalidateFrameSubtree();

return true;
}

// For absolute positioning, the width can potentially change if width is
// auto and either of left or right are not. The height can also potentially
// change if height is auto and either of top or bottom are not. In these
// cases we fall back to a reflow, and in all other cases, we attempt to
// move the frame here.
// Note that it is possible for the dimensions to not change in the above
// cases, so we should be a little smarter here and only fall back to reflow
// when the dimensions will really change (bug 745485).
const nsStylePosition* position = aFrame->GetStylePosition();
if (position->mWidth.GetUnit() != eStyleUnit_Auto &&
position->mHeight.GetUnit() != eStyleUnit_Auto) {
// For the absolute positioning case, set up a fake HTML reflow state for
// the frame, and then get the offsets from it.
nsRefPtr<nsRenderingContext> rc = aFrame->PresContext()->GetPresShell()->
GetReferenceRenderingContext();

// Construct a bogus parent reflow state so that there's a usable
// containing block reflow state.
nsIFrame *parentFrame = aFrame->GetParent();
nsSize parentSize = parentFrame->GetSize();

nsFrameState savedState = parentFrame->GetStateBits();
nsHTMLReflowState parentReflowState(aFrame->PresContext(), parentFrame,
rc, parentSize);
parentFrame->RemoveStateBits(~nsFrameState(0));
parentFrame->AddStateBits(savedState);

NS_WARN_IF_FALSE(parentSize.width != NS_INTRINSICSIZE &&
parentSize.height != NS_INTRINSICSIZE,
"parentSize should be valid");
parentReflowState.SetComputedWidth(NS_MAX(parentSize.width, 0));
parentReflowState.SetComputedHeight(NS_MAX(parentSize.height, 0));
parentReflowState.mComputedMargin.SizeTo(0, 0, 0, 0);
parentSize.height = NS_AUTOHEIGHT;

parentReflowState.mComputedPadding = parentFrame->GetUsedPadding();
parentReflowState.mComputedBorderPadding =
parentFrame->GetUsedBorderAndPadding();

nsSize availSize(parentSize.width, NS_INTRINSICSIZE);

nsSize size = aFrame->GetSize();
nsSize cbSize = aFrame->GetContainingBlock()->GetSize();
const nsMargin& parentBorder =
parentReflowState.mStyleBorder->GetComputedBorder();
cbSize -= nsSize(parentBorder.LeftRight(), parentBorder.TopBottom());
nsHTMLReflowState reflowState(aFrame->PresContext(), parentReflowState,
aFrame, availSize, cbSize.width,
cbSize.height);

// If we're solving for 'left' or 'top', then compute it here, in order to
// match the reflow code path.
if (NS_AUTOOFFSET == reflowState.mComputedOffsets.left) {
reflowState.mComputedOffsets.left = cbSize.width -
reflowState.mComputedOffsets.right -
reflowState.mComputedMargin.right -
size.width -
reflowState.mComputedMargin.left;
}

if (NS_AUTOOFFSET == reflowState.mComputedOffsets.top) {
reflowState.mComputedOffsets.top = cbSize.height -
reflowState.mComputedOffsets.bottom -
reflowState.mComputedMargin.bottom -
size.height -
reflowState.mComputedMargin.top;
}

// Invalidate the old rect
aFrame->InvalidateFrameSubtree();

// Move the frame
nsPoint pos(parentBorder.left + reflowState.mComputedOffsets.left +
reflowState.mComputedMargin.left,
parentBorder.top + reflowState.mComputedOffsets.top +
reflowState.mComputedMargin.top);
aFrame->SetPosition(pos);

// Invalidate the new rect
aFrame->InvalidateFrameSubtree();

return true;
}

// Fall back to a reflow
StyleChangeReflow(aFrame, nsChangeHint_NeedReflow);
return false;
}
5 changes: 0 additions & 5 deletions layout/base/nsCSSFrameConstructor.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1642,11 +1642,6 @@ class nsCSSFrameConstructor : public nsFrameManager


nsresult StyleChangeReflow(nsIFrame* aFrame, nsChangeHint aHint); nsresult StyleChangeReflow(nsIFrame* aFrame, nsChangeHint aHint);


// Returns true if this function managed to successfully move a frame, and
// false if it could not process the position change, and a reflow should
// be performed instead.
bool RecomputePosition(nsIFrame* aFrame);

//---------------------------------------- //----------------------------------------


// Methods support :first-letter style // Methods support :first-letter style
Expand Down
32 changes: 1 addition & 31 deletions layout/base/nsChangeHint.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -89,43 +89,13 @@ enum nsChangeHint {
*/ */
nsChangeHint_ChildrenOnlyTransform = 0x1000, nsChangeHint_ChildrenOnlyTransform = 0x1000,


/**
* The frame's offsets have changed, while its dimensions might have
* changed as well. This hint is used for positioned frames if their
* offset changes. If we decide that the dimensions are likely to
* change, this will trigger a reflow.
*
* Note that this should probably be used in combination with
* nsChangeHint_UpdateOverflow in order to get the overflow areas of
* the ancestors updated as well.
*/
nsChangeHint_RecomputePosition = 0x2000,

/** /**
* Behaves like ReconstructFrame, but only if the frame has descendants * Behaves like ReconstructFrame, but only if the frame has descendants
* that are absolutely or fixed position. Use this hint when a style change * that are absolutely or fixed position. Use this hint when a style change
* has changed whether the frame is a container for fixed-pos or abs-pos * has changed whether the frame is a container for fixed-pos or abs-pos
* elements, but reframing is otherwise not needed. * elements, but reframing is otherwise not needed.
*/ */
nsChangeHint_AddOrRemoveTransform = 0x4000, nsChangeHint_AddOrRemoveTransform = 0x2000

/**
* We have an optimization when processing change hints which prevents
* us from visiting the descendants of a node when a hint on that node
* is being processed. This optimization does not apply in some of the
* cases where applying a hint to an element does not necessarily result
* in the same hint being handled on the descendants.
*
* If you're adding such a hint, you should add your hint to this list.
*/
nsChangeHint_NonInherited_Hints =
nsChangeHint_UpdateTransformLayer |
nsChangeHint_UpdateEffects |
nsChangeHint_UpdateOpacityLayer |
nsChangeHint_UpdateOverflow |
nsChangeHint_ChildrenOnlyTransform |
nsChangeHint_RecomputePosition |
nsChangeHint_AddOrRemoveTransform
}; };


// Redefine these operators to return nothing. This will catch any use // Redefine these operators to return nothing. This will catch any use
Expand Down
5 changes: 4 additions & 1 deletion layout/base/nsFrameManager.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1040,7 +1040,10 @@ nsFrameManager::ReResolveStyleContext(nsPresContext *aPresContext,
// We need to generate a new change list entry for every frame whose style // We need to generate a new change list entry for every frame whose style
// comparision returns one of these hints. These hints don't automatically // comparision returns one of these hints. These hints don't automatically
// update all their descendant frames. // update all their descendant frames.
aMinChange = NS_SubtractHint(aMinChange, nsChangeHint_NonInherited_Hints); aMinChange = NS_SubtractHint(aMinChange, nsChangeHint_UpdateTransformLayer);
aMinChange = NS_SubtractHint(aMinChange, nsChangeHint_UpdateOpacityLayer);
aMinChange = NS_SubtractHint(aMinChange, nsChangeHint_UpdateOverflow);
aMinChange = NS_SubtractHint(aMinChange, nsChangeHint_UpdateEffects);


// It would be nice if we could make stronger assertions here; they // It would be nice if we could make stronger assertions here; they
// would let us simplify the ?: expressions below setting |content| // would let us simplify the ?: expressions below setting |content|
Expand Down
Loading

0 comments on commit d919887

Please sign in to comment.