Bug 55086. Change nsContainerFrame::PositionFrameView() to position child views. Eliminate the |aView| parameter from that method, because the view can be retrieved from the frame and need not be done by the caller. Eliminate the NS_FRAME_NO_MOVE_CHILD_VIEWS flag, which was read-only; i.e., never set by anyone. r=dbaron, sr=attinasi

This commit is contained in:
waterson%netscape.com 2001-09-05 20:27:19 +00:00
Родитель 9590a6f66b
Коммит 48483431d2
30 изменённых файлов: 235 добавлений и 262 удалений

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

@ -2660,16 +2660,14 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
nsHTMLReflowState reflowState(mPresContext, rootFrame,
eReflowReason_Initial, rcx, maxSize);
nsIView* view;
rootFrame->WillReflow(mPresContext);
rootFrame->GetView(mPresContext, &view);
if (view) {
nsContainerFrame::PositionFrameView(mPresContext, rootFrame, view);
}
nsContainerFrame::PositionFrameView(mPresContext, rootFrame);
rootFrame->Reflow(mPresContext, desiredSize, reflowState, status);
rootFrame->SizeTo(mPresContext, desiredSize.width, desiredSize.height);
mPresContext->SetVisibleArea(nsRect(0,0,desiredSize.width,desiredSize.height));
nsIView* view;
rootFrame->GetView(mPresContext, &view);
if (view) {
nsContainerFrame::SyncFrameViewAfterReflow(mPresContext, rootFrame, view,
nsnull);
@ -2798,15 +2796,13 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
nsHTMLReflowState reflowState(mPresContext, rootFrame,
eReflowReason_Resize, rcx, maxSize);
nsIView* view;
rootFrame->WillReflow(mPresContext);
rootFrame->GetView(mPresContext, &view);
if (view) {
nsContainerFrame::PositionFrameView(mPresContext, rootFrame, view);
}
nsContainerFrame::PositionFrameView(mPresContext, rootFrame);
rootFrame->Reflow(mPresContext, desiredSize, reflowState, status);
rootFrame->SizeTo(mPresContext, desiredSize.width, desiredSize.height);
nsIView* view;
rootFrame->GetView(mPresContext, &view);
if (view) {
nsContainerFrame::SyncFrameViewAfterReflow(mPresContext, rootFrame, view,
nsnull);
@ -3335,16 +3331,14 @@ PresShell::StyleChangeReflow()
nsHTMLReflowState reflowState(mPresContext, rootFrame,
eReflowReason_StyleChange, rcx, maxSize);
nsIView* view;
rootFrame->WillReflow(mPresContext);
rootFrame->GetView(mPresContext, &view);
if (view) {
nsContainerFrame::PositionFrameView(mPresContext, rootFrame, view);
}
nsContainerFrame::PositionFrameView(mPresContext, rootFrame);
rootFrame->Reflow(mPresContext, desiredSize, reflowState, status);
rootFrame->SizeTo(mPresContext, desiredSize.width, desiredSize.height);
mPresContext->SetVisibleArea(nsRect(0,0,desiredSize.width,desiredSize.height));
nsIView* view;
rootFrame->GetView(mPresContext, &view);
if (view) {
nsContainerFrame::SyncFrameViewAfterReflow(mPresContext, rootFrame, view,
nsnull);

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

@ -231,6 +231,8 @@ struct nsHTMLReflowState {
#ifdef DEBUG
// hook for attaching debug info (e.g. tables may attach a timer during reflow)
void* mDebugHook;
static const char* ReasonToString(nsReflowReason aReason);
#endif
// Note: The copy constructor is written by the compiler

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

@ -1080,11 +1080,7 @@ nsComboboxControlFrame::ReflowCombobox(nsIPresContext * aPresContext,
aDisplayFrame->WillReflow(aPresContext);
//aDisplayFrame->MoveTo(aPresContext, dspBorderPadding.left + aBorderPadding.left, dspBorderPadding.top + aBorderPadding.top);
aDisplayFrame->MoveTo(aPresContext, aBorderPadding.left, aBorderPadding.top);
nsIView* view;
aDisplayFrame->GetView(aPresContext, &view);
if (view) {
nsAreaFrame::PositionFrameView(aPresContext, aDisplayFrame, view);
}
nsAreaFrame::PositionFrameView(aPresContext, aDisplayFrame);
nsReflowStatus status;
nsresult rv = aDisplayFrame->Reflow(aPresContext, txtKidSize, txtKidReflowState, status);
if (NS_FAILED(rv)) return;

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

@ -517,15 +517,8 @@ nsFieldSetFrame::Reflow(nsIPresContext* aPresContext,
// only if the origin changed
if ((curOrigin.x != mLegendRect.x) || (curOrigin.y != mLegendRect.y)) {
mLegendFrame->MoveTo(aPresContext, actualLegendRect.x , actualLegendRect.y);
nsIView* view;
mLegendFrame->GetView(aPresContext, &view);
if (view)
nsContainerFrame::PositionFrameView(aPresContext, mLegendFrame, view);
else
nsContainerFrame::PositionChildViews(aPresContext, mLegendFrame);
nsContainerFrame::PositionFrameView(aPresContext, mLegendFrame);
}
}

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

@ -409,12 +409,10 @@ nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegat
aKidFrame->MoveTo(aPresContext,
x, border.top + kidReflowState.mComputedOffsets.top + kidReflowState.mComputedMargin.top);
// Position its view
nsIView* kidView;
aKidFrame->GetView(aPresContext, &kidView);
// Don't bother it doing it now if we haven't yet determined the left offset
// Position its view, but don't bother it doing it now if we haven't
// yet determined the left offset
if (NS_AUTOOFFSET != kidReflowState.mComputedOffsets.left) {
nsContainerFrame::PositionFrameView(aPresContext, aKidFrame, kidView);
nsContainerFrame::PositionFrameView(aPresContext, aKidFrame);
}
// Do the reflow
@ -454,6 +452,8 @@ nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegat
// Size and position the view and set its opacity, visibility, content
// transparency, and clip
nsIView* kidView;
aKidFrame->GetView(aPresContext, &kidView);
nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, aKidFrame, kidView,
&kidDesiredSize.mOverflowArea);
aKidFrame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);

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

@ -583,8 +583,9 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext,
if (gNoisyReflow) {
IndentBy(stdout, gNoiseIndent);
ListTag(stdout);
printf(": begin reflow type %d availSize=%d,%d computedSize=%d,%d\n",
aReflowState.reason, aReflowState.availableWidth, aReflowState.availableHeight,
printf(": begin %s reflow availSize=%d,%d computedSize=%d,%d\n",
nsHTMLReflowState::ReasonToString(aReflowState.reason),
aReflowState.availableWidth, aReflowState.availableHeight,
aReflowState.mComputedWidth, aReflowState.mComputedHeight);
}
if (gNoisy) {
@ -2103,7 +2104,8 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState)
aState.AdvanceToNextLine();
}
// Pull data from a next-in-flow if we can
// Pull data from a next-in-flow if there's still room for more
// content here.
while (keepGoing && (nsnull != aState.mNextInFlow)) {
// Grab first line from our next-in-flow
line = aState.mNextInFlow->mLines;
@ -2153,8 +2155,7 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState)
// line to be created; see SplitLine's callers for examples of
// when this happens).
while (nsnull != line) {
rv = ReflowLine(aState, line, &keepGoing, incrementalReflow ?
PR_TRUE : PR_FALSE);
rv = ReflowLine(aState, line, &keepGoing, incrementalReflow /* force invalidate */);
if (NS_FAILED(rv)) {
return rv;
}
@ -2537,7 +2538,6 @@ PlaceFrameView(nsIPresContext* aPresContext,
aFrame->GetView(aPresContext, &view);
if (view) {
nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, aFrame, view, nsnull);
} else {
nsContainerFrame::PositionChildViews(aPresContext, aFrame);
}
@ -5507,7 +5507,22 @@ nsBlockFrame::GetFrameForPoint(nsIPresContext* aPresContext,
NS_IMETHODIMP
nsBlockFrame::ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild)
{
{
#ifdef DEBUG
if (gNoisyReflow) {
IndentBy(stdout, gNoiseIndent);
ListTag(stdout);
printf(": ReflowDirtyChild (");
if (aChild)
nsFrame::ListTag(stdout, aChild);
else
printf("null");
printf(")\n");
gNoiseIndent++;
}
#endif
if (aChild) {
// See if the child is absolutely positioned
nsFrameState childState;
@ -5531,6 +5546,15 @@ nsBlockFrame::ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild)
aPresShell->AppendReflowCommand(reflowCmd);
NS_RELEASE(reflowCmd);
}
#ifdef DEBUG
if (gNoisyReflow) {
IndentBy(stdout, gNoiseIndent);
printf("scheduled reflow command for absolutely positioned frame\n");
--gNoiseIndent;
}
#endif
return rv;
}
}
@ -5562,6 +5586,13 @@ nsBlockFrame::ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild)
nsFrame::CreateAndPostReflowCommand(aPresShell, this,
nsIReflowCommand::ReflowDirty, nsnull, nsnull, nsnull);
#ifdef DEBUG
if (gNoisyReflow) {
IndentBy(stdout, gNoiseIndent);
printf("scheduled reflow command targeted at self\n");
}
#endif
}
else {
if (!(mState & NS_FRAME_IS_DIRTY)) {
@ -5572,10 +5603,23 @@ nsBlockFrame::ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild)
nsIReflowCommand::ReflowType type = nsIReflowCommand::ReflowDirty;
aPresShell->CancelReflowCommand(this, &type);
#ifdef DEBUG
if (gNoisyReflow) {
IndentBy(stdout, gNoiseIndent);
printf("cancelled reflow targeted at self\n");
}
#endif
// Pass up the reflow request to the parent frame.
mParent->ReflowDirtyChild(aPresShell, this);
}
}
#ifdef DEBUG
if (gNoisyReflow) {
--gNoiseIndent;
}
#endif
return NS_OK;
}

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

@ -521,14 +521,7 @@ nsBlockReflowContext::DoReflowBlock(nsHTMLReflowState &aReflowState,
// Note: Use "x" and "y" and not "mX" and "mY" because they more accurately
// represents where we think the block will be placed
aFrame->MoveTo(mPresContext, x, y);
nsIView* view;
aFrame->GetView(mPresContext, &view);
if (view) {
nsContainerFrame::PositionFrameView(mPresContext, aFrame, view);
}
else {
nsContainerFrame::PositionChildViews(mPresContext, aFrame);
}
nsContainerFrame::PositionFrameView(mPresContext, aFrame);
#ifdef DEBUG
mMetrics.width = nscoord(0xdeadbeef);

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

@ -1014,14 +1014,8 @@ nsBlockReflowState::FlowAndPlaceFloater(nsFloaterCache* aFloaterCache,
}
// Position the floater and make sure and views are properly positioned
nsIView* view;
floater->MoveTo(mPresContext, x, y);
floater->GetView(mPresContext, &view);
if (view) {
nsContainerFrame::PositionFrameView(mPresContext, floater, view);
} else {
nsContainerFrame::PositionChildViews(mPresContext, floater);
}
nsContainerFrame::PositionFrameView(mPresContext, floater);
// Update the floater combined area state
nsRect combinedArea = aFloaterCache->mCombinedArea;

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

@ -356,23 +356,24 @@ TranslatePointTo(nsPoint& aPoint, nsIView* aChildView, nsIView* aParentView)
void
nsContainerFrame::PositionFrameView(nsIPresContext* aPresContext,
nsIFrame* aKidFrame,
nsIView* aView)
nsIFrame* aKidFrame)
{
if (aView) {
nsIView* view;
aKidFrame->GetView(aPresContext, &view);
if (view) {
// Position view relative to its parent, not relative to aKidFrame's
// frame which may not have a view
nsIView* parentView;
view->GetParent(parentView);
nsIView* containingView;
nsPoint origin;
nsIView* parentView;
nsIViewManager *vm;
aView->GetParent(parentView);
aKidFrame->GetOffsetFromView(aPresContext, origin, &containingView);
aView->GetViewManager(vm);
if (containingView != parentView)
{
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
if (containingView != parentView) {
// it is possible for parent view not to have a frame attached to it
// kind of an anonymous view. This happens with native scrollbars and
// the clip view. To fix this we need to go up and parentView chain
@ -405,9 +406,10 @@ nsContainerFrame::PositionFrameView(nsIPresContext* aPresContext,
}
}
vm->MoveViewTo(aView, origin.x, origin.y);
NS_RELEASE(vm);
vm->MoveViewTo(view, origin.x, origin.y);
}
else {
PositionChildViews(aPresContext, aKidFrame);
}
}
@ -714,11 +716,7 @@ nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
}
if (0 == (aFlags & NS_FRAME_NO_MOVE_VIEW)) {
nsIView* view;
aKidFrame->GetView(aPresContext, &view);
if (view) {
PositionFrameView(aPresContext, aKidFrame, view);
}
PositionFrameView(aPresContext, aKidFrame);
}
// Reflow the child frame
@ -781,20 +779,8 @@ nsContainerFrame::PositionChildViews(nsIPresContext* aPresContext,
nsIFrame* childFrame;
aFrame->FirstChild(aPresContext, childListName, &childFrame);
while (childFrame) {
nsIView* view;
// See if the child frame has a view
childFrame->GetView(aPresContext, &view);
if (view) {
// Position the view. Because any child views are relative to their
// parent, there's no need to recurse
PositionFrameView(aPresContext, childFrame, view);
} else {
// Recursively examine its child frames
PositionChildViews(aPresContext, childFrame);
}
// Position the frame's view, if it has one.
PositionFrameView(aPresContext, childFrame);
// Get the next sibling child frame
childFrame->GetNextSibling(&childFrame);
@ -821,11 +807,7 @@ nsContainerFrame::PositionChildViews(nsIPresContext* aPresContext,
* NS_FRAME_NO_MOVE_VIEW - don't position the frame's view. Set this if you
* don't want to automatically sync the frame and view
* NS_FRAME_NO_SIZE_VIEW - don't size the frame's view
* NS_FRAME_NO_MOVE_CHILD_VIEWS - don't move child views. This is for the case
* where the frame's new position differs from its current position and the
* frame itself doesn't have a view, so moving the frame would cause any child
* views to be out of sync
*/
*/
nsresult
nsContainerFrame::FinishReflowChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
@ -849,12 +831,12 @@ nsContainerFrame::FinishReflowChild(nsIFrame* aKidFrame,
&aDesiredSize.mOverflowArea,
aFlags);
} else if (0 == (aFlags & NS_FRAME_NO_MOVE_CHILD_VIEWS)) {
}
else if (0 == (aFlags & NS_FRAME_NO_MOVE_VIEW) &&
((curOrigin.x != aX) || (curOrigin.y != aY))) {
// If the frame has moved, then we need to make sure any child views are
// correctly positioned
if ((curOrigin.x != aX) || (curOrigin.y != aY)) {
PositionChildViews(aPresContext, aKidFrame);
}
PositionChildViews(aPresContext, aKidFrame);
}
return aKidFrame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);

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

@ -30,8 +30,7 @@
#define NS_FRAME_NO_MOVE_VIEW 0x0001
#define NS_FRAME_NO_MOVE_FRAME (0x0002 | NS_FRAME_NO_MOVE_VIEW)
#define NS_FRAME_NO_SIZE_VIEW 0x0004
#define NS_FRAME_NO_MOVE_CHILD_VIEWS 0x0008
#define NS_FRAME_NO_VISIBILITY 0x0010
#define NS_FRAME_NO_VISIBILITY 0x0008
/**
* Implementation of a container frame.
@ -83,8 +82,7 @@ public:
// Positions the frame's view based on the frame's origin
static void PositionFrameView(nsIPresContext* aPresContext,
nsIFrame* aKidFrame,
nsIView* aView);
nsIFrame* aKidFrame);
// Sets several view attributes:
// - if requested sizes the frame's view based on the current size and origin.
@ -141,10 +139,6 @@ public:
* NS_FRAME_NO_MOVE_VIEW - don't position the frame's view. Set this if you
* don't want to automatically sync the frame and view
* NS_FRAME_NO_SIZE_VIEW - don't size the frame's view
* NS_FRAME_NO_MOVE_CHILD_VIEWS - don't move child views. This is for the case
* where the frame's new position differs from its current position and the
* frame itself doesn't have a view, so moving the frame would cause any child
* views to be out of sync
*/
static nsresult FinishReflowChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,

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

@ -134,15 +134,13 @@ NS_IMETHODIMP nsHTMLReflowCommand::Dispatch(nsIPresContext* aPresContext,
nsHTMLReflowState reflowState(aPresContext, root, *this,
&aRendContext, aMaxSize);
nsReflowStatus status;
nsIView* view;
root->WillReflow(aPresContext);
root->GetView(aPresContext, &view);
if (view) {
nsContainerFrame::PositionFrameView(aPresContext, root, view);
}
nsContainerFrame::PositionFrameView(aPresContext, root);
root->Reflow(aPresContext, aDesiredSize, reflowState, status);
root->SizeTo(aPresContext, aDesiredSize.width, aDesiredSize.height);
nsIView* view;
root->GetView(aPresContext, &view);
if (view) {
nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, root, view,
nsnull);

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

@ -44,6 +44,18 @@
// hack for bug 50695
#include "nsIFormManager.h"
#ifdef DEBUG
const char*
nsHTMLReflowState::ReasonToString(nsReflowReason aReason)
{
static const char* reasons[] = {
"initial", "incremental", "resize", "style-change", "dirty"
};
return reasons[aReason];
}
#endif
// Initialize a <b>root</b> reflow state with a rendering context to
// use for measuring things.
nsHTMLReflowState::nsHTMLReflowState(nsIPresContext* aPresContext,

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

@ -231,6 +231,8 @@ struct nsHTMLReflowState {
#ifdef DEBUG
// hook for attaching debug info (e.g. tables may attach a timer during reflow)
void* mDebugHook;
static const char* ReasonToString(nsReflowReason aReason);
#endif
// Note: The copy constructor is written by the compiler

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

@ -354,9 +354,7 @@ ViewportFrame::ReflowFixedFrame(nsIPresContext* aPresContext,
kidReflowState.mComputedOffsets.top + kidReflowState.mComputedMargin.top);
// Position its view
nsIView* kidView;
aKidFrame->GetView(aPresContext, &kidView);
nsContainerFrame::PositionFrameView(aPresContext, aKidFrame, kidView);
nsContainerFrame::PositionFrameView(aPresContext, aKidFrame);
// Do the reflow
rv = aKidFrame->Reflow(aPresContext, kidDesiredSize, kidReflowState, aStatus);
@ -378,6 +376,8 @@ ViewportFrame::ReflowFixedFrame(nsIPresContext* aPresContext,
// Size and position the view and set its opacity, visibility, content
// transparency, and clip
nsIView* kidView;
aKidFrame->GetView(aPresContext, &kidView);
nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, aKidFrame, kidView,
&kidDesiredSize.mOverflowArea);
aKidFrame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);

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

@ -409,12 +409,10 @@ nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegat
aKidFrame->MoveTo(aPresContext,
x, border.top + kidReflowState.mComputedOffsets.top + kidReflowState.mComputedMargin.top);
// Position its view
nsIView* kidView;
aKidFrame->GetView(aPresContext, &kidView);
// Don't bother it doing it now if we haven't yet determined the left offset
// Position its view, but don't bother it doing it now if we haven't
// yet determined the left offset
if (NS_AUTOOFFSET != kidReflowState.mComputedOffsets.left) {
nsContainerFrame::PositionFrameView(aPresContext, aKidFrame, kidView);
nsContainerFrame::PositionFrameView(aPresContext, aKidFrame);
}
// Do the reflow
@ -454,6 +452,8 @@ nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegat
// Size and position the view and set its opacity, visibility, content
// transparency, and clip
nsIView* kidView;
aKidFrame->GetView(aPresContext, &kidView);
nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, aKidFrame, kidView,
&kidDesiredSize.mOverflowArea);
aKidFrame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);

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

@ -583,8 +583,9 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext,
if (gNoisyReflow) {
IndentBy(stdout, gNoiseIndent);
ListTag(stdout);
printf(": begin reflow type %d availSize=%d,%d computedSize=%d,%d\n",
aReflowState.reason, aReflowState.availableWidth, aReflowState.availableHeight,
printf(": begin %s reflow availSize=%d,%d computedSize=%d,%d\n",
nsHTMLReflowState::ReasonToString(aReflowState.reason),
aReflowState.availableWidth, aReflowState.availableHeight,
aReflowState.mComputedWidth, aReflowState.mComputedHeight);
}
if (gNoisy) {
@ -2103,7 +2104,8 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState)
aState.AdvanceToNextLine();
}
// Pull data from a next-in-flow if we can
// Pull data from a next-in-flow if there's still room for more
// content here.
while (keepGoing && (nsnull != aState.mNextInFlow)) {
// Grab first line from our next-in-flow
line = aState.mNextInFlow->mLines;
@ -2153,8 +2155,7 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState)
// line to be created; see SplitLine's callers for examples of
// when this happens).
while (nsnull != line) {
rv = ReflowLine(aState, line, &keepGoing, incrementalReflow ?
PR_TRUE : PR_FALSE);
rv = ReflowLine(aState, line, &keepGoing, incrementalReflow /* force invalidate */);
if (NS_FAILED(rv)) {
return rv;
}
@ -2537,7 +2538,6 @@ PlaceFrameView(nsIPresContext* aPresContext,
aFrame->GetView(aPresContext, &view);
if (view) {
nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, aFrame, view, nsnull);
} else {
nsContainerFrame::PositionChildViews(aPresContext, aFrame);
}
@ -5507,7 +5507,22 @@ nsBlockFrame::GetFrameForPoint(nsIPresContext* aPresContext,
NS_IMETHODIMP
nsBlockFrame::ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild)
{
{
#ifdef DEBUG
if (gNoisyReflow) {
IndentBy(stdout, gNoiseIndent);
ListTag(stdout);
printf(": ReflowDirtyChild (");
if (aChild)
nsFrame::ListTag(stdout, aChild);
else
printf("null");
printf(")\n");
gNoiseIndent++;
}
#endif
if (aChild) {
// See if the child is absolutely positioned
nsFrameState childState;
@ -5531,6 +5546,15 @@ nsBlockFrame::ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild)
aPresShell->AppendReflowCommand(reflowCmd);
NS_RELEASE(reflowCmd);
}
#ifdef DEBUG
if (gNoisyReflow) {
IndentBy(stdout, gNoiseIndent);
printf("scheduled reflow command for absolutely positioned frame\n");
--gNoiseIndent;
}
#endif
return rv;
}
}
@ -5562,6 +5586,13 @@ nsBlockFrame::ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild)
nsFrame::CreateAndPostReflowCommand(aPresShell, this,
nsIReflowCommand::ReflowDirty, nsnull, nsnull, nsnull);
#ifdef DEBUG
if (gNoisyReflow) {
IndentBy(stdout, gNoiseIndent);
printf("scheduled reflow command targeted at self\n");
}
#endif
}
else {
if (!(mState & NS_FRAME_IS_DIRTY)) {
@ -5572,10 +5603,23 @@ nsBlockFrame::ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild)
nsIReflowCommand::ReflowType type = nsIReflowCommand::ReflowDirty;
aPresShell->CancelReflowCommand(this, &type);
#ifdef DEBUG
if (gNoisyReflow) {
IndentBy(stdout, gNoiseIndent);
printf("cancelled reflow targeted at self\n");
}
#endif
// Pass up the reflow request to the parent frame.
mParent->ReflowDirtyChild(aPresShell, this);
}
}
#ifdef DEBUG
if (gNoisyReflow) {
--gNoiseIndent;
}
#endif
return NS_OK;
}

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

@ -521,14 +521,7 @@ nsBlockReflowContext::DoReflowBlock(nsHTMLReflowState &aReflowState,
// Note: Use "x" and "y" and not "mX" and "mY" because they more accurately
// represents where we think the block will be placed
aFrame->MoveTo(mPresContext, x, y);
nsIView* view;
aFrame->GetView(mPresContext, &view);
if (view) {
nsContainerFrame::PositionFrameView(mPresContext, aFrame, view);
}
else {
nsContainerFrame::PositionChildViews(mPresContext, aFrame);
}
nsContainerFrame::PositionFrameView(mPresContext, aFrame);
#ifdef DEBUG
mMetrics.width = nscoord(0xdeadbeef);

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

@ -1014,14 +1014,8 @@ nsBlockReflowState::FlowAndPlaceFloater(nsFloaterCache* aFloaterCache,
}
// Position the floater and make sure and views are properly positioned
nsIView* view;
floater->MoveTo(mPresContext, x, y);
floater->GetView(mPresContext, &view);
if (view) {
nsContainerFrame::PositionFrameView(mPresContext, floater, view);
} else {
nsContainerFrame::PositionChildViews(mPresContext, floater);
}
nsContainerFrame::PositionFrameView(mPresContext, floater);
// Update the floater combined area state
nsRect combinedArea = aFloaterCache->mCombinedArea;

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

@ -356,23 +356,24 @@ TranslatePointTo(nsPoint& aPoint, nsIView* aChildView, nsIView* aParentView)
void
nsContainerFrame::PositionFrameView(nsIPresContext* aPresContext,
nsIFrame* aKidFrame,
nsIView* aView)
nsIFrame* aKidFrame)
{
if (aView) {
nsIView* view;
aKidFrame->GetView(aPresContext, &view);
if (view) {
// Position view relative to its parent, not relative to aKidFrame's
// frame which may not have a view
nsIView* parentView;
view->GetParent(parentView);
nsIView* containingView;
nsPoint origin;
nsIView* parentView;
nsIViewManager *vm;
aView->GetParent(parentView);
aKidFrame->GetOffsetFromView(aPresContext, origin, &containingView);
aView->GetViewManager(vm);
if (containingView != parentView)
{
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
if (containingView != parentView) {
// it is possible for parent view not to have a frame attached to it
// kind of an anonymous view. This happens with native scrollbars and
// the clip view. To fix this we need to go up and parentView chain
@ -405,9 +406,10 @@ nsContainerFrame::PositionFrameView(nsIPresContext* aPresContext,
}
}
vm->MoveViewTo(aView, origin.x, origin.y);
NS_RELEASE(vm);
vm->MoveViewTo(view, origin.x, origin.y);
}
else {
PositionChildViews(aPresContext, aKidFrame);
}
}
@ -714,11 +716,7 @@ nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
}
if (0 == (aFlags & NS_FRAME_NO_MOVE_VIEW)) {
nsIView* view;
aKidFrame->GetView(aPresContext, &view);
if (view) {
PositionFrameView(aPresContext, aKidFrame, view);
}
PositionFrameView(aPresContext, aKidFrame);
}
// Reflow the child frame
@ -781,20 +779,8 @@ nsContainerFrame::PositionChildViews(nsIPresContext* aPresContext,
nsIFrame* childFrame;
aFrame->FirstChild(aPresContext, childListName, &childFrame);
while (childFrame) {
nsIView* view;
// See if the child frame has a view
childFrame->GetView(aPresContext, &view);
if (view) {
// Position the view. Because any child views are relative to their
// parent, there's no need to recurse
PositionFrameView(aPresContext, childFrame, view);
} else {
// Recursively examine its child frames
PositionChildViews(aPresContext, childFrame);
}
// Position the frame's view, if it has one.
PositionFrameView(aPresContext, childFrame);
// Get the next sibling child frame
childFrame->GetNextSibling(&childFrame);
@ -821,11 +807,7 @@ nsContainerFrame::PositionChildViews(nsIPresContext* aPresContext,
* NS_FRAME_NO_MOVE_VIEW - don't position the frame's view. Set this if you
* don't want to automatically sync the frame and view
* NS_FRAME_NO_SIZE_VIEW - don't size the frame's view
* NS_FRAME_NO_MOVE_CHILD_VIEWS - don't move child views. This is for the case
* where the frame's new position differs from its current position and the
* frame itself doesn't have a view, so moving the frame would cause any child
* views to be out of sync
*/
*/
nsresult
nsContainerFrame::FinishReflowChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,
@ -849,12 +831,12 @@ nsContainerFrame::FinishReflowChild(nsIFrame* aKidFrame,
&aDesiredSize.mOverflowArea,
aFlags);
} else if (0 == (aFlags & NS_FRAME_NO_MOVE_CHILD_VIEWS)) {
}
else if (0 == (aFlags & NS_FRAME_NO_MOVE_VIEW) &&
((curOrigin.x != aX) || (curOrigin.y != aY))) {
// If the frame has moved, then we need to make sure any child views are
// correctly positioned
if ((curOrigin.x != aX) || (curOrigin.y != aY)) {
PositionChildViews(aPresContext, aKidFrame);
}
PositionChildViews(aPresContext, aKidFrame);
}
return aKidFrame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);

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

@ -30,8 +30,7 @@
#define NS_FRAME_NO_MOVE_VIEW 0x0001
#define NS_FRAME_NO_MOVE_FRAME (0x0002 | NS_FRAME_NO_MOVE_VIEW)
#define NS_FRAME_NO_SIZE_VIEW 0x0004
#define NS_FRAME_NO_MOVE_CHILD_VIEWS 0x0008
#define NS_FRAME_NO_VISIBILITY 0x0010
#define NS_FRAME_NO_VISIBILITY 0x0008
/**
* Implementation of a container frame.
@ -83,8 +82,7 @@ public:
// Positions the frame's view based on the frame's origin
static void PositionFrameView(nsIPresContext* aPresContext,
nsIFrame* aKidFrame,
nsIView* aView);
nsIFrame* aKidFrame);
// Sets several view attributes:
// - if requested sizes the frame's view based on the current size and origin.
@ -141,10 +139,6 @@ public:
* NS_FRAME_NO_MOVE_VIEW - don't position the frame's view. Set this if you
* don't want to automatically sync the frame and view
* NS_FRAME_NO_SIZE_VIEW - don't size the frame's view
* NS_FRAME_NO_MOVE_CHILD_VIEWS - don't move child views. This is for the case
* where the frame's new position differs from its current position and the
* frame itself doesn't have a view, so moving the frame would cause any child
* views to be out of sync
*/
static nsresult FinishReflowChild(nsIFrame* aKidFrame,
nsIPresContext* aPresContext,

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

@ -134,15 +134,13 @@ NS_IMETHODIMP nsHTMLReflowCommand::Dispatch(nsIPresContext* aPresContext,
nsHTMLReflowState reflowState(aPresContext, root, *this,
&aRendContext, aMaxSize);
nsReflowStatus status;
nsIView* view;
root->WillReflow(aPresContext);
root->GetView(aPresContext, &view);
if (view) {
nsContainerFrame::PositionFrameView(aPresContext, root, view);
}
nsContainerFrame::PositionFrameView(aPresContext, root);
root->Reflow(aPresContext, aDesiredSize, reflowState, status);
root->SizeTo(aPresContext, aDesiredSize.width, aDesiredSize.height);
nsIView* view;
root->GetView(aPresContext, &view);
if (view) {
nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, root, view,
nsnull);

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

@ -44,6 +44,18 @@
// hack for bug 50695
#include "nsIFormManager.h"
#ifdef DEBUG
const char*
nsHTMLReflowState::ReasonToString(nsReflowReason aReason)
{
static const char* reasons[] = {
"initial", "incremental", "resize", "style-change", "dirty"
};
return reasons[aReason];
}
#endif
// Initialize a <b>root</b> reflow state with a rendering context to
// use for measuring things.
nsHTMLReflowState::nsHTMLReflowState(nsIPresContext* aPresContext,

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

@ -2660,16 +2660,14 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
nsHTMLReflowState reflowState(mPresContext, rootFrame,
eReflowReason_Initial, rcx, maxSize);
nsIView* view;
rootFrame->WillReflow(mPresContext);
rootFrame->GetView(mPresContext, &view);
if (view) {
nsContainerFrame::PositionFrameView(mPresContext, rootFrame, view);
}
nsContainerFrame::PositionFrameView(mPresContext, rootFrame);
rootFrame->Reflow(mPresContext, desiredSize, reflowState, status);
rootFrame->SizeTo(mPresContext, desiredSize.width, desiredSize.height);
mPresContext->SetVisibleArea(nsRect(0,0,desiredSize.width,desiredSize.height));
nsIView* view;
rootFrame->GetView(mPresContext, &view);
if (view) {
nsContainerFrame::SyncFrameViewAfterReflow(mPresContext, rootFrame, view,
nsnull);
@ -2798,15 +2796,13 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
nsHTMLReflowState reflowState(mPresContext, rootFrame,
eReflowReason_Resize, rcx, maxSize);
nsIView* view;
rootFrame->WillReflow(mPresContext);
rootFrame->GetView(mPresContext, &view);
if (view) {
nsContainerFrame::PositionFrameView(mPresContext, rootFrame, view);
}
nsContainerFrame::PositionFrameView(mPresContext, rootFrame);
rootFrame->Reflow(mPresContext, desiredSize, reflowState, status);
rootFrame->SizeTo(mPresContext, desiredSize.width, desiredSize.height);
nsIView* view;
rootFrame->GetView(mPresContext, &view);
if (view) {
nsContainerFrame::SyncFrameViewAfterReflow(mPresContext, rootFrame, view,
nsnull);
@ -3335,16 +3331,14 @@ PresShell::StyleChangeReflow()
nsHTMLReflowState reflowState(mPresContext, rootFrame,
eReflowReason_StyleChange, rcx, maxSize);
nsIView* view;
rootFrame->WillReflow(mPresContext);
rootFrame->GetView(mPresContext, &view);
if (view) {
nsContainerFrame::PositionFrameView(mPresContext, rootFrame, view);
}
nsContainerFrame::PositionFrameView(mPresContext, rootFrame);
rootFrame->Reflow(mPresContext, desiredSize, reflowState, status);
rootFrame->SizeTo(mPresContext, desiredSize.width, desiredSize.height);
mPresContext->SetVisibleArea(nsRect(0,0,desiredSize.width,desiredSize.height));
nsIView* view;
rootFrame->GetView(mPresContext, &view);
if (view) {
nsContainerFrame::SyncFrameViewAfterReflow(mPresContext, rootFrame, view,
nsnull);

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

@ -354,9 +354,7 @@ ViewportFrame::ReflowFixedFrame(nsIPresContext* aPresContext,
kidReflowState.mComputedOffsets.top + kidReflowState.mComputedMargin.top);
// Position its view
nsIView* kidView;
aKidFrame->GetView(aPresContext, &kidView);
nsContainerFrame::PositionFrameView(aPresContext, aKidFrame, kidView);
nsContainerFrame::PositionFrameView(aPresContext, aKidFrame);
// Do the reflow
rv = aKidFrame->Reflow(aPresContext, kidDesiredSize, kidReflowState, aStatus);
@ -378,6 +376,8 @@ ViewportFrame::ReflowFixedFrame(nsIPresContext* aPresContext,
// Size and position the view and set its opacity, visibility, content
// transparency, and clip
nsIView* kidView;
aKidFrame->GetView(aPresContext, &kidView);
nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, aKidFrame, kidView,
&kidDesiredSize.mOverflowArea);
aKidFrame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);

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

@ -1080,11 +1080,7 @@ nsComboboxControlFrame::ReflowCombobox(nsIPresContext * aPresContext,
aDisplayFrame->WillReflow(aPresContext);
//aDisplayFrame->MoveTo(aPresContext, dspBorderPadding.left + aBorderPadding.left, dspBorderPadding.top + aBorderPadding.top);
aDisplayFrame->MoveTo(aPresContext, aBorderPadding.left, aBorderPadding.top);
nsIView* view;
aDisplayFrame->GetView(aPresContext, &view);
if (view) {
nsAreaFrame::PositionFrameView(aPresContext, aDisplayFrame, view);
}
nsAreaFrame::PositionFrameView(aPresContext, aDisplayFrame);
nsReflowStatus status;
nsresult rv = aDisplayFrame->Reflow(aPresContext, txtKidSize, txtKidReflowState, status);
if (NS_FAILED(rv)) return;

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

@ -517,15 +517,8 @@ nsFieldSetFrame::Reflow(nsIPresContext* aPresContext,
// only if the origin changed
if ((curOrigin.x != mLegendRect.x) || (curOrigin.y != mLegendRect.y)) {
mLegendFrame->MoveTo(aPresContext, actualLegendRect.x , actualLegendRect.y);
nsIView* view;
mLegendFrame->GetView(aPresContext, &view);
if (view)
nsContainerFrame::PositionFrameView(aPresContext, mLegendFrame, view);
else
nsContainerFrame::PositionChildViews(aPresContext, mLegendFrame);
nsContainerFrame::PositionFrameView(aPresContext, mLegendFrame);
}
}

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

@ -385,13 +385,7 @@ void
nsTableFrame::RePositionViews(nsIPresContext* aPresContext,
nsIFrame* aFrame)
{
nsIView* view;
aFrame->GetView(aPresContext, &view);
if (view) {
nsContainerFrame::PositionFrameView(aPresContext, aFrame, view);
} else {
nsContainerFrame::PositionChildViews(aPresContext, aFrame);
}
nsContainerFrame::PositionFrameView(aPresContext, aFrame);
}
nsIPresShell*

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

@ -385,13 +385,7 @@ void
nsTableFrame::RePositionViews(nsIPresContext* aPresContext,
nsIFrame* aFrame)
{
nsIView* view;
aFrame->GetView(aPresContext, &view);
if (view) {
nsContainerFrame::PositionFrameView(aPresContext, aFrame, view);
} else {
nsContainerFrame::PositionChildViews(aPresContext, aFrame);
}
nsContainerFrame::PositionFrameView(aPresContext, aFrame);
}
nsIPresShell*

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

@ -549,22 +549,9 @@ nsBox::SetBounds(nsBoxLayoutState& aState, const nsRect& aRect)
frame->SetRect(presContext, aRect);
if (!(flags & NS_FRAME_NO_MOVE_VIEW) || !(flags & NS_FRAME_NO_MOVE_CHILD_VIEWS))
if (!(flags & NS_FRAME_NO_MOVE_VIEW))
{
nsIView* view;
frame->GetView(presContext, &view);
if (view) {
if (!(flags & NS_FRAME_NO_MOVE_VIEW)) {
nsContainerFrame::PositionFrameView(presContext, frame, view);
}
} else {
if (!(flags & NS_FRAME_NO_MOVE_CHILD_VIEWS)) {
// only if the origin changed
if ((rect.x != aRect.x) || (rect.y != aRect.y)) {
nsContainerFrame::PositionChildViews(presContext, frame);
}
}
}
nsContainerFrame::PositionFrameView(presContext, frame);
}

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

@ -1002,13 +1002,7 @@ nsBoxToBlockAdaptor::PlaceChild(nsIPresContext* aPresContext, nsIFrame* aFrame,
// only if the origin changed
if ((curOrigin.x != aX) || (curOrigin.y != aY)) {
aFrame->MoveTo(aPresContext, aX, aY);
nsIView* view;
aFrame->GetView(aPresContext, &view);
if (view) {
nsContainerFrame::PositionFrameView(aPresContext, aFrame, view);
} else
nsContainerFrame::PositionChildViews(aPresContext, aFrame);
nsContainerFrame::PositionFrameView(aPresContext, aFrame);
}
}