From fd1d6fc2a3e99259da13d85d9335dd8a2dd62fdd Mon Sep 17 00:00:00 2001 From: "troy%netscape.com" Date: Wed, 27 Oct 1999 03:56:14 +0000 Subject: [PATCH] Changed view to be stored as a frame property instead of a member data of nsFrame git-svn-id: svn://10.0.0.236/trunk@51940 18797224-902f-48f8-a5cc-f745e15eee43 --- .../content/shared/public/nsLayoutAtomList.h | 1 + mozilla/layout/base/nsLayoutAtomList.h | 1 + mozilla/layout/base/public/nsIFrame.h | 2 +- mozilla/layout/base/public/nsLayoutAtomList.h | 1 + mozilla/layout/generic/nsFrame.cpp | 137 ++++++++++++------ mozilla/layout/generic/nsFrame.h | 11 +- mozilla/layout/generic/nsIFrame.h | 2 +- mozilla/layout/generic/nsSplittableFrame.cpp | 4 +- mozilla/layout/generic/nsSplittableFrame.h | 2 +- mozilla/layout/html/base/src/nsFrame.cpp | 137 ++++++++++++------ mozilla/layout/html/base/src/nsFrame.h | 11 +- .../html/base/src/nsSplittableFrame.cpp | 4 +- .../layout/html/base/src/nsSplittableFrame.h | 2 +- .../webshell/tests/viewer/nsWebCrawler.cpp | 7 +- 14 files changed, 200 insertions(+), 122 deletions(-) diff --git a/mozilla/content/shared/public/nsLayoutAtomList.h b/mozilla/content/shared/public/nsLayoutAtomList.h index 60cddb17fe0..c85be3e008f 100644 --- a/mozilla/content/shared/public/nsLayoutAtomList.h +++ b/mozilla/content/shared/public/nsLayoutAtomList.h @@ -103,6 +103,7 @@ LAYOUT_ATOM(viewportFrame, "ViewportFrame") LAYOUT_ATOM(collapseOffsetProperty, "CollapseOffsetProperty") LAYOUT_ATOM(maxElementSizeProperty, "MaxElementSizeProperty") LAYOUT_ATOM(overflowProperty, "OverflowProperty") +LAYOUT_ATOM(viewProperty, "ViewProperty") #ifdef DEBUG // Alphabetical list of atoms used by debugging code diff --git a/mozilla/layout/base/nsLayoutAtomList.h b/mozilla/layout/base/nsLayoutAtomList.h index 60cddb17fe0..c85be3e008f 100644 --- a/mozilla/layout/base/nsLayoutAtomList.h +++ b/mozilla/layout/base/nsLayoutAtomList.h @@ -103,6 +103,7 @@ LAYOUT_ATOM(viewportFrame, "ViewportFrame") LAYOUT_ATOM(collapseOffsetProperty, "CollapseOffsetProperty") LAYOUT_ATOM(maxElementSizeProperty, "MaxElementSizeProperty") LAYOUT_ATOM(overflowProperty, "OverflowProperty") +LAYOUT_ATOM(viewProperty, "ViewProperty") #ifdef DEBUG // Alphabetical list of atoms used by debugging code diff --git a/mozilla/layout/base/public/nsIFrame.h b/mozilla/layout/base/public/nsIFrame.h index 7e92977db80..8d637f97062 100644 --- a/mozilla/layout/base/public/nsIFrame.h +++ b/mozilla/layout/base/public/nsIFrame.h @@ -631,7 +631,7 @@ public: * the caveat that some base types are defined. * For more information, see XXX. */ - NS_IMETHOD DumpRegressionData(FILE* out, PRInt32 aIndent) = 0; + NS_IMETHOD DumpRegressionData(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) = 0; /** * Get the size of the frame object. The size value should include diff --git a/mozilla/layout/base/public/nsLayoutAtomList.h b/mozilla/layout/base/public/nsLayoutAtomList.h index 60cddb17fe0..c85be3e008f 100644 --- a/mozilla/layout/base/public/nsLayoutAtomList.h +++ b/mozilla/layout/base/public/nsLayoutAtomList.h @@ -103,6 +103,7 @@ LAYOUT_ATOM(viewportFrame, "ViewportFrame") LAYOUT_ATOM(collapseOffsetProperty, "CollapseOffsetProperty") LAYOUT_ATOM(maxElementSizeProperty, "MaxElementSizeProperty") LAYOUT_ATOM(overflowProperty, "OverflowProperty") +LAYOUT_ATOM(viewProperty, "ViewProperty") #ifdef DEBUG // Alphabetical list of atoms used by debugging code diff --git a/mozilla/layout/generic/nsFrame.cpp b/mozilla/layout/generic/nsFrame.cpp index 264cad0a564..fd488419012 100644 --- a/mozilla/layout/generic/nsFrame.cpp +++ b/mozilla/layout/generic/nsFrame.cpp @@ -36,6 +36,7 @@ #include #include "nsIPtr.h" #include "nsISizeOfHandler.h" +#include "nsIFrameManager.h" #include "nsIDOMText.h" #include "nsDocument.h" @@ -207,11 +208,6 @@ nsFrame::~nsFrame() NS_IF_RELEASE(mContent); NS_IF_RELEASE(mStyleContext); - if (nsnull != mView) { - // Break association between view and frame - mView->Destroy(); - mView = nsnull; - } } ///////////////////////////////////////////////////////////////////////////// @@ -340,6 +336,11 @@ nsFrame::Destroy(nsIPresContext& aPresContext) { nsCOMPtr shell; aPresContext.GetShell(getter_AddRefs(shell)); + + // Get the view pointer now before the frame properties disappear + // when we call NotifyDestroyingFrame() + nsIView* view; + GetView(&aPresContext, &view); // XXX Rather than always doing this it would be better if it was part of // a frame observer mechanism and the pres shell could register as an @@ -359,9 +360,12 @@ nsFrame::Destroy(nsIPresContext& aPresContext) // that actually loads images? aPresContext.StopAllLoadImagesFor(this); - //Set to prevent event dispatch during destruct - if (nsnull != mView) { - mView->SetClientData(nsnull); + if (view) { + // Break association between view and frame + view->SetClientData(nsnull); + + // Destroy the view + view->Destroy(); } delete this; @@ -500,7 +504,9 @@ NS_IMETHODIMP nsFrame::MoveTo(nsIPresContext* aPresContext, nscoord aX, nscoord mRect.x = aX; mRect.y = aY; - if (nsnull != mView) { + nsIView* view; + GetView(aPresContext, &view); + if (view) { // If we should keep the view position and size in sync with the frame // then position the view. Don't do this if we're in the middle of reflow. // Instead wait until the DidReflow() notification @@ -512,8 +518,8 @@ NS_IMETHODIMP nsFrame::MoveTo(nsIPresContext* aPresContext, nscoord aX, nscoord nsPoint origin; GetOffsetFromView(aPresContext, origin, &parentWithView); nsIViewManager *vm; - mView->GetViewManager(vm); - vm->MoveViewTo(mView, origin.x, origin.y); + view->GetViewManager(vm); + vm->MoveViewTo(view, origin.x, origin.y); NS_RELEASE(vm); } } @@ -527,7 +533,9 @@ NS_IMETHODIMP nsFrame::SizeTo(nsIPresContext* aPresContext, nscoord aWidth, nsco mRect.height = aHeight; // Let the view know - if (nsnull != mView) { + nsIView* view; + GetView(aPresContext, &view); + if (view) { // If we should keep the view position and size in sync with the frame // then resize the view. Don't do this if we're in the middle of reflow. // Instead wait until the DidReflow() notification @@ -535,8 +543,8 @@ NS_IMETHODIMP nsFrame::SizeTo(nsIPresContext* aPresContext, nscoord aWidth, nsco NS_FRAME_SYNC_FRAME_AND_VIEW))) { // Resize the view to be the same size as the frame nsIViewManager *vm; - mView->GetViewManager(vm); - vm->ResizeView(mView, aWidth, aHeight); + view->GetViewManager(vm); + vm->ResizeView(view, aWidth, aHeight); NS_RELEASE(vm); } } @@ -1187,9 +1195,11 @@ nsFrame::DidReflow(nsIPresContext& aPresContext, // Make sure the view is sized and positioned correctly and it's // visibility, opacity, content transparency, and clip are correct - if (mView) { + nsIView* view; + GetView(&aPresContext, &view); + if (view) { nsIViewManager *vm; - mView->GetViewManager(vm); + view->GetViewManager(vm); if (NS_FRAME_SYNC_FRAME_AND_VIEW & mState) { // Position and size view relative to its parent, not relative to our @@ -1197,8 +1207,8 @@ nsFrame::DidReflow(nsIPresContext& aPresContext, nsIView* parentWithView; nsPoint origin; GetOffsetFromView(&aPresContext, origin, &parentWithView); - vm->ResizeView(mView, mRect.width, mRect.height); - vm->MoveViewTo(mView, origin.x, origin.y); + vm->ResizeView(view, mRect.width, mRect.height); + vm->MoveViewTo(view, origin.x, origin.y); } const nsStyleColor* color = @@ -1207,7 +1217,7 @@ nsFrame::DidReflow(nsIPresContext& aPresContext, (const nsStyleDisplay*)mStyleContext->GetStyleData(eStyleStruct_Display); // Set the view's opacity - vm->SetViewOpacity(mView, color->mOpacity); + vm->SetViewOpacity(view, color->mOpacity); // See if the view should be hidden or visible PRBool viewIsVisible = PR_TRUE; @@ -1220,7 +1230,7 @@ nsFrame::DidReflow(nsIPresContext& aPresContext, else if (NS_STYLE_VISIBILITY_HIDDEN == display->mVisible) { // If it has a widget, hide the view because the widget can't deal with it nsIWidget* widget = nsnull; - mView->GetWidget(widget); + view->GetWidget(widget); if (widget) { viewIsVisible = PR_FALSE; NS_RELEASE(widget); @@ -1266,12 +1276,12 @@ nsFrame::DidReflow(nsIPresContext& aPresContext, } // Make sure visibility is correct - vm->SetViewVisibility(mView, viewIsVisible ? nsViewVisibility_kShow : + vm->SetViewVisibility(view, viewIsVisible ? nsViewVisibility_kShow : nsViewVisibility_kHide); // Make sure content transparency is correct if (viewIsVisible) { - vm->SetViewContentTransparency(mView, viewHasTransparentContent); + vm->SetViewContentTransparency(view, viewHasTransparentContent); } // Clip applies to block-level and replaced elements with overflow @@ -1298,11 +1308,11 @@ nsFrame::DidReflow(nsIPresContext& aPresContext, if (0 == (NS_STYLE_CLIP_LEFT_AUTO & display->mClipFlags)) { left += display->mClip.left; } - mView->SetClip(left, top, right, bottom); + view->SetClip(left, top, right, bottom); } else { // Make sure no clip is set - mView->SetClip(0, 0, 0, 0); + view->SetClip(0, 0, 0, 0); } } NS_RELEASE(vm); @@ -1429,24 +1439,50 @@ NS_IMETHODIMP nsFrame::SetNextInFlow(nsIFrame*) // Associated view object NS_IMETHODIMP nsFrame::GetView(nsIPresContext* aPresContext, nsIView** aView) const { - NS_PRECONDITION(nsnull != aView, "null OUT parameter pointer"); - *aView = mView; + NS_ENSURE_ARG_POINTER(aView); + + // Initialize OUT parameter + *aView = nsnull; + + // Check for a property on the frame + nsCOMPtr presShell; + aPresContext->GetShell(getter_AddRefs(presShell)); + + if (presShell) { + nsCOMPtr frameManager; + presShell->GetFrameManager(getter_AddRefs(frameManager)); + + if (frameManager) { + void* value; + frameManager->GetFrameProperty((nsIFrame*)this, nsLayoutAtoms::viewProperty, 0, &value); + *aView = (nsIView*)value; + } + } + return NS_OK; } NS_IMETHODIMP nsFrame::SetView(nsIPresContext* aPresContext, nsIView* aView) { - nsresult rv; - - if (nsnull != aView) { - mView = aView; + if (aView) { aView->SetClientData(this); - rv = NS_OK; - } - else - rv = NS_OK; - return rv; + // Set a property on the frame + nsCOMPtr presShell; + aPresContext->GetShell(getter_AddRefs(presShell)); + + if (presShell) { + nsCOMPtr frameManager; + presShell->GetFrameManager(getter_AddRefs(frameManager)); + + if (frameManager) { + frameManager->SetFrameProperty(this, nsLayoutAtoms::viewProperty, + aView, nsnull); + } + } + } + + return NS_OK; } // Find the first geometric parent that has a view @@ -1543,14 +1579,16 @@ nsFrame::Invalidate(nsIPresContext* aPresContext, } PRUint32 flags = aImmediate ? NS_VMREFRESH_IMMEDIATE : NS_VMREFRESH_NO_SYNC; - if (nsnull != mView) { - mView->GetViewManager(viewManager); - viewManager->UpdateView(mView, damageRect, flags); + nsIView* view; + + GetView(aPresContext, &view); + if (view) { + view->GetViewManager(viewManager); + viewManager->UpdateView(view, damageRect, flags); } else { nsRect rect(damageRect); nsPoint offset; - nsIView* view; GetOffsetFromView(aPresContext, offset, &view); NS_ASSERTION(nsnull != view, "no view"); @@ -1660,8 +1698,11 @@ nsFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) const { IndentBy(out, aIndent); ListTag(out); - if (nsnull != mView) { - fprintf(out, " [view=%p]", mView); + + nsIView* view; + GetView(aPresContext, &view); + if (view) { + fprintf(out, " [view=%p]", view); } fprintf(out, " {%d,%d,%d,%d}", mRect.x, mRect.y, mRect.width, mRect.height); if (0 != mState) { @@ -1749,7 +1790,7 @@ nsFrame::ParentDisablesSelection() const } NS_IMETHODIMP -nsFrame::DumpRegressionData(FILE* out, PRInt32 aIndent) +nsFrame::DumpRegressionData(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) { IndentBy(out, aIndent); fprintf(out, "\n", PRUptrdiff(mNextSibling)); } - if (nsnull != mView) { + nsIView* view; + GetView(aPresContext, &view); + if (view) { IndentBy(out, aIndent); - fprintf(out, "\n", PRUptrdiff(mView)); + fprintf(out, "\n", PRUptrdiff(view)); aIndent++; // XXX add in code to dump out view state too... aIndent--; @@ -1813,7 +1856,7 @@ nsFrame::DumpBaseRegressionData(FILE* out, PRInt32 aIndent) } aIndent++; while (nsnull != kid) { - kid->DumpRegressionData(out, aIndent); + kid->DumpRegressionData(aPresContext, out, aIndent); kid->GetNextSibling(&kid); } aIndent--; diff --git a/mozilla/layout/generic/nsFrame.h b/mozilla/layout/generic/nsFrame.h index 56ec5d9fdef..846254d191e 100644 --- a/mozilla/layout/generic/nsFrame.h +++ b/mozilla/layout/generic/nsFrame.h @@ -218,7 +218,7 @@ public: NS_IMETHOD Scrolled(nsIView *aView); NS_IMETHOD List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) const; NS_IMETHOD GetFrameName(nsString& aResult) const; - NS_IMETHOD DumpRegressionData(FILE* out, PRInt32 aIndent); + NS_IMETHOD DumpRegressionData(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent); NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const; NS_IMETHOD VerifyTree() const; NS_IMETHOD SetSelected(nsIPresContext* aPresContext, nsIDOMRange *aRange,PRBool aSelected, nsSpread aSpread); @@ -353,7 +353,7 @@ protected: * some custom behavior that requires changing how the outer "frame" * XML container is dumped. */ - virtual void DumpBaseRegressionData(FILE* out, PRInt32 aIndent); + virtual void DumpBaseRegressionData(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent); nsresult MakeFrameName(const char* aKind, nsString& aResult) const; @@ -373,13 +373,6 @@ protected: nsIFrame* mNextSibling; // singly linked list of frames nsFrameState mState; - - // Selection data is valid only from the Mouse Press to the Mouse Release - /////////////////////////////////// - - -private: - nsIView* mView; // must use accessor member functions protected: NS_IMETHOD_(nsrefcnt) AddRef(void); NS_IMETHOD_(nsrefcnt) Release(void); diff --git a/mozilla/layout/generic/nsIFrame.h b/mozilla/layout/generic/nsIFrame.h index 7e92977db80..8d637f97062 100644 --- a/mozilla/layout/generic/nsIFrame.h +++ b/mozilla/layout/generic/nsIFrame.h @@ -631,7 +631,7 @@ public: * the caveat that some base types are defined. * For more information, see XXX. */ - NS_IMETHOD DumpRegressionData(FILE* out, PRInt32 aIndent) = 0; + NS_IMETHOD DumpRegressionData(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) = 0; /** * Get the size of the frame object. The size value should include diff --git a/mozilla/layout/generic/nsSplittableFrame.cpp b/mozilla/layout/generic/nsSplittableFrame.cpp index 63a44600f53..17d487f71c8 100644 --- a/mozilla/layout/generic/nsSplittableFrame.cpp +++ b/mozilla/layout/generic/nsSplittableFrame.cpp @@ -155,9 +155,9 @@ nsIFrame * nsSplittableFrame::GetNextInFlow() } void -nsSplittableFrame::DumpBaseRegressionData(FILE* out, PRInt32 aIndent) +nsSplittableFrame::DumpBaseRegressionData(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) { - nsFrame::DumpBaseRegressionData(out, aIndent); + nsFrame::DumpBaseRegressionData(aPresContext, out, aIndent); if (nsnull != mNextInFlow) { IndentBy(out, aIndent); fprintf(out, "\n", PRUptrdiff(mNextInFlow)); diff --git a/mozilla/layout/generic/nsSplittableFrame.h b/mozilla/layout/generic/nsSplittableFrame.h index 4e76734c9ec..0f31de11b8a 100644 --- a/mozilla/layout/generic/nsSplittableFrame.h +++ b/mozilla/layout/generic/nsSplittableFrame.h @@ -62,7 +62,7 @@ public: nsIFrame* GetNextInFlow(); protected: - virtual void DumpBaseRegressionData(FILE* out, PRInt32 aIndent); + virtual void DumpBaseRegressionData(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent); nsIFrame* mPrevInFlow; nsIFrame* mNextInFlow; diff --git a/mozilla/layout/html/base/src/nsFrame.cpp b/mozilla/layout/html/base/src/nsFrame.cpp index 264cad0a564..fd488419012 100644 --- a/mozilla/layout/html/base/src/nsFrame.cpp +++ b/mozilla/layout/html/base/src/nsFrame.cpp @@ -36,6 +36,7 @@ #include #include "nsIPtr.h" #include "nsISizeOfHandler.h" +#include "nsIFrameManager.h" #include "nsIDOMText.h" #include "nsDocument.h" @@ -207,11 +208,6 @@ nsFrame::~nsFrame() NS_IF_RELEASE(mContent); NS_IF_RELEASE(mStyleContext); - if (nsnull != mView) { - // Break association between view and frame - mView->Destroy(); - mView = nsnull; - } } ///////////////////////////////////////////////////////////////////////////// @@ -340,6 +336,11 @@ nsFrame::Destroy(nsIPresContext& aPresContext) { nsCOMPtr shell; aPresContext.GetShell(getter_AddRefs(shell)); + + // Get the view pointer now before the frame properties disappear + // when we call NotifyDestroyingFrame() + nsIView* view; + GetView(&aPresContext, &view); // XXX Rather than always doing this it would be better if it was part of // a frame observer mechanism and the pres shell could register as an @@ -359,9 +360,12 @@ nsFrame::Destroy(nsIPresContext& aPresContext) // that actually loads images? aPresContext.StopAllLoadImagesFor(this); - //Set to prevent event dispatch during destruct - if (nsnull != mView) { - mView->SetClientData(nsnull); + if (view) { + // Break association between view and frame + view->SetClientData(nsnull); + + // Destroy the view + view->Destroy(); } delete this; @@ -500,7 +504,9 @@ NS_IMETHODIMP nsFrame::MoveTo(nsIPresContext* aPresContext, nscoord aX, nscoord mRect.x = aX; mRect.y = aY; - if (nsnull != mView) { + nsIView* view; + GetView(aPresContext, &view); + if (view) { // If we should keep the view position and size in sync with the frame // then position the view. Don't do this if we're in the middle of reflow. // Instead wait until the DidReflow() notification @@ -512,8 +518,8 @@ NS_IMETHODIMP nsFrame::MoveTo(nsIPresContext* aPresContext, nscoord aX, nscoord nsPoint origin; GetOffsetFromView(aPresContext, origin, &parentWithView); nsIViewManager *vm; - mView->GetViewManager(vm); - vm->MoveViewTo(mView, origin.x, origin.y); + view->GetViewManager(vm); + vm->MoveViewTo(view, origin.x, origin.y); NS_RELEASE(vm); } } @@ -527,7 +533,9 @@ NS_IMETHODIMP nsFrame::SizeTo(nsIPresContext* aPresContext, nscoord aWidth, nsco mRect.height = aHeight; // Let the view know - if (nsnull != mView) { + nsIView* view; + GetView(aPresContext, &view); + if (view) { // If we should keep the view position and size in sync with the frame // then resize the view. Don't do this if we're in the middle of reflow. // Instead wait until the DidReflow() notification @@ -535,8 +543,8 @@ NS_IMETHODIMP nsFrame::SizeTo(nsIPresContext* aPresContext, nscoord aWidth, nsco NS_FRAME_SYNC_FRAME_AND_VIEW))) { // Resize the view to be the same size as the frame nsIViewManager *vm; - mView->GetViewManager(vm); - vm->ResizeView(mView, aWidth, aHeight); + view->GetViewManager(vm); + vm->ResizeView(view, aWidth, aHeight); NS_RELEASE(vm); } } @@ -1187,9 +1195,11 @@ nsFrame::DidReflow(nsIPresContext& aPresContext, // Make sure the view is sized and positioned correctly and it's // visibility, opacity, content transparency, and clip are correct - if (mView) { + nsIView* view; + GetView(&aPresContext, &view); + if (view) { nsIViewManager *vm; - mView->GetViewManager(vm); + view->GetViewManager(vm); if (NS_FRAME_SYNC_FRAME_AND_VIEW & mState) { // Position and size view relative to its parent, not relative to our @@ -1197,8 +1207,8 @@ nsFrame::DidReflow(nsIPresContext& aPresContext, nsIView* parentWithView; nsPoint origin; GetOffsetFromView(&aPresContext, origin, &parentWithView); - vm->ResizeView(mView, mRect.width, mRect.height); - vm->MoveViewTo(mView, origin.x, origin.y); + vm->ResizeView(view, mRect.width, mRect.height); + vm->MoveViewTo(view, origin.x, origin.y); } const nsStyleColor* color = @@ -1207,7 +1217,7 @@ nsFrame::DidReflow(nsIPresContext& aPresContext, (const nsStyleDisplay*)mStyleContext->GetStyleData(eStyleStruct_Display); // Set the view's opacity - vm->SetViewOpacity(mView, color->mOpacity); + vm->SetViewOpacity(view, color->mOpacity); // See if the view should be hidden or visible PRBool viewIsVisible = PR_TRUE; @@ -1220,7 +1230,7 @@ nsFrame::DidReflow(nsIPresContext& aPresContext, else if (NS_STYLE_VISIBILITY_HIDDEN == display->mVisible) { // If it has a widget, hide the view because the widget can't deal with it nsIWidget* widget = nsnull; - mView->GetWidget(widget); + view->GetWidget(widget); if (widget) { viewIsVisible = PR_FALSE; NS_RELEASE(widget); @@ -1266,12 +1276,12 @@ nsFrame::DidReflow(nsIPresContext& aPresContext, } // Make sure visibility is correct - vm->SetViewVisibility(mView, viewIsVisible ? nsViewVisibility_kShow : + vm->SetViewVisibility(view, viewIsVisible ? nsViewVisibility_kShow : nsViewVisibility_kHide); // Make sure content transparency is correct if (viewIsVisible) { - vm->SetViewContentTransparency(mView, viewHasTransparentContent); + vm->SetViewContentTransparency(view, viewHasTransparentContent); } // Clip applies to block-level and replaced elements with overflow @@ -1298,11 +1308,11 @@ nsFrame::DidReflow(nsIPresContext& aPresContext, if (0 == (NS_STYLE_CLIP_LEFT_AUTO & display->mClipFlags)) { left += display->mClip.left; } - mView->SetClip(left, top, right, bottom); + view->SetClip(left, top, right, bottom); } else { // Make sure no clip is set - mView->SetClip(0, 0, 0, 0); + view->SetClip(0, 0, 0, 0); } } NS_RELEASE(vm); @@ -1429,24 +1439,50 @@ NS_IMETHODIMP nsFrame::SetNextInFlow(nsIFrame*) // Associated view object NS_IMETHODIMP nsFrame::GetView(nsIPresContext* aPresContext, nsIView** aView) const { - NS_PRECONDITION(nsnull != aView, "null OUT parameter pointer"); - *aView = mView; + NS_ENSURE_ARG_POINTER(aView); + + // Initialize OUT parameter + *aView = nsnull; + + // Check for a property on the frame + nsCOMPtr presShell; + aPresContext->GetShell(getter_AddRefs(presShell)); + + if (presShell) { + nsCOMPtr frameManager; + presShell->GetFrameManager(getter_AddRefs(frameManager)); + + if (frameManager) { + void* value; + frameManager->GetFrameProperty((nsIFrame*)this, nsLayoutAtoms::viewProperty, 0, &value); + *aView = (nsIView*)value; + } + } + return NS_OK; } NS_IMETHODIMP nsFrame::SetView(nsIPresContext* aPresContext, nsIView* aView) { - nsresult rv; - - if (nsnull != aView) { - mView = aView; + if (aView) { aView->SetClientData(this); - rv = NS_OK; - } - else - rv = NS_OK; - return rv; + // Set a property on the frame + nsCOMPtr presShell; + aPresContext->GetShell(getter_AddRefs(presShell)); + + if (presShell) { + nsCOMPtr frameManager; + presShell->GetFrameManager(getter_AddRefs(frameManager)); + + if (frameManager) { + frameManager->SetFrameProperty(this, nsLayoutAtoms::viewProperty, + aView, nsnull); + } + } + } + + return NS_OK; } // Find the first geometric parent that has a view @@ -1543,14 +1579,16 @@ nsFrame::Invalidate(nsIPresContext* aPresContext, } PRUint32 flags = aImmediate ? NS_VMREFRESH_IMMEDIATE : NS_VMREFRESH_NO_SYNC; - if (nsnull != mView) { - mView->GetViewManager(viewManager); - viewManager->UpdateView(mView, damageRect, flags); + nsIView* view; + + GetView(aPresContext, &view); + if (view) { + view->GetViewManager(viewManager); + viewManager->UpdateView(view, damageRect, flags); } else { nsRect rect(damageRect); nsPoint offset; - nsIView* view; GetOffsetFromView(aPresContext, offset, &view); NS_ASSERTION(nsnull != view, "no view"); @@ -1660,8 +1698,11 @@ nsFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) const { IndentBy(out, aIndent); ListTag(out); - if (nsnull != mView) { - fprintf(out, " [view=%p]", mView); + + nsIView* view; + GetView(aPresContext, &view); + if (view) { + fprintf(out, " [view=%p]", view); } fprintf(out, " {%d,%d,%d,%d}", mRect.x, mRect.y, mRect.width, mRect.height); if (0 != mState) { @@ -1749,7 +1790,7 @@ nsFrame::ParentDisablesSelection() const } NS_IMETHODIMP -nsFrame::DumpRegressionData(FILE* out, PRInt32 aIndent) +nsFrame::DumpRegressionData(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) { IndentBy(out, aIndent); fprintf(out, "\n", PRUptrdiff(mNextSibling)); } - if (nsnull != mView) { + nsIView* view; + GetView(aPresContext, &view); + if (view) { IndentBy(out, aIndent); - fprintf(out, "\n", PRUptrdiff(mView)); + fprintf(out, "\n", PRUptrdiff(view)); aIndent++; // XXX add in code to dump out view state too... aIndent--; @@ -1813,7 +1856,7 @@ nsFrame::DumpBaseRegressionData(FILE* out, PRInt32 aIndent) } aIndent++; while (nsnull != kid) { - kid->DumpRegressionData(out, aIndent); + kid->DumpRegressionData(aPresContext, out, aIndent); kid->GetNextSibling(&kid); } aIndent--; diff --git a/mozilla/layout/html/base/src/nsFrame.h b/mozilla/layout/html/base/src/nsFrame.h index 56ec5d9fdef..846254d191e 100644 --- a/mozilla/layout/html/base/src/nsFrame.h +++ b/mozilla/layout/html/base/src/nsFrame.h @@ -218,7 +218,7 @@ public: NS_IMETHOD Scrolled(nsIView *aView); NS_IMETHOD List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) const; NS_IMETHOD GetFrameName(nsString& aResult) const; - NS_IMETHOD DumpRegressionData(FILE* out, PRInt32 aIndent); + NS_IMETHOD DumpRegressionData(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent); NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const; NS_IMETHOD VerifyTree() const; NS_IMETHOD SetSelected(nsIPresContext* aPresContext, nsIDOMRange *aRange,PRBool aSelected, nsSpread aSpread); @@ -353,7 +353,7 @@ protected: * some custom behavior that requires changing how the outer "frame" * XML container is dumped. */ - virtual void DumpBaseRegressionData(FILE* out, PRInt32 aIndent); + virtual void DumpBaseRegressionData(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent); nsresult MakeFrameName(const char* aKind, nsString& aResult) const; @@ -373,13 +373,6 @@ protected: nsIFrame* mNextSibling; // singly linked list of frames nsFrameState mState; - - // Selection data is valid only from the Mouse Press to the Mouse Release - /////////////////////////////////// - - -private: - nsIView* mView; // must use accessor member functions protected: NS_IMETHOD_(nsrefcnt) AddRef(void); NS_IMETHOD_(nsrefcnt) Release(void); diff --git a/mozilla/layout/html/base/src/nsSplittableFrame.cpp b/mozilla/layout/html/base/src/nsSplittableFrame.cpp index 63a44600f53..17d487f71c8 100644 --- a/mozilla/layout/html/base/src/nsSplittableFrame.cpp +++ b/mozilla/layout/html/base/src/nsSplittableFrame.cpp @@ -155,9 +155,9 @@ nsIFrame * nsSplittableFrame::GetNextInFlow() } void -nsSplittableFrame::DumpBaseRegressionData(FILE* out, PRInt32 aIndent) +nsSplittableFrame::DumpBaseRegressionData(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) { - nsFrame::DumpBaseRegressionData(out, aIndent); + nsFrame::DumpBaseRegressionData(aPresContext, out, aIndent); if (nsnull != mNextInFlow) { IndentBy(out, aIndent); fprintf(out, "\n", PRUptrdiff(mNextInFlow)); diff --git a/mozilla/layout/html/base/src/nsSplittableFrame.h b/mozilla/layout/html/base/src/nsSplittableFrame.h index 4e76734c9ec..0f31de11b8a 100644 --- a/mozilla/layout/html/base/src/nsSplittableFrame.h +++ b/mozilla/layout/html/base/src/nsSplittableFrame.h @@ -62,7 +62,7 @@ public: nsIFrame* GetNextInFlow(); protected: - virtual void DumpBaseRegressionData(FILE* out, PRInt32 aIndent); + virtual void DumpBaseRegressionData(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent); nsIFrame* mPrevInFlow; nsIFrame* mNextInFlow; diff --git a/mozilla/webshell/tests/viewer/nsWebCrawler.cpp b/mozilla/webshell/tests/viewer/nsWebCrawler.cpp index 183ce84e15d..27df677c92a 100644 --- a/mozilla/webshell/tests/viewer/nsWebCrawler.cpp +++ b/mozilla/webshell/tests/viewer/nsWebCrawler.cpp @@ -243,12 +243,15 @@ nsWebCrawler::OnEndDocumentLoad(nsIDocumentLoader* loader, nsIFrame* root; shell->GetRootFrame(&root); if (nsnull != root) { + nsCOMPtr presContext; + shell->GetPresContext(getter_AddRefs(presContext)); + if (mOutputDir.Length() > 0) { nsAutoString regressionFileName; FILE *fp = GetOutputFile(aURL, regressionFileName); if (fp) { - root->DumpRegressionData(fp, 0); + root->DumpRegressionData(presContext, fp, 0); fclose(fp); if (mRegressing) { PerformRegressionTest(regressionFileName); @@ -266,7 +269,7 @@ nsWebCrawler::OnEndDocumentLoad(nsIDocumentLoader* loader, } } else - root->DumpRegressionData(stdout, 0); + root->DumpRegressionData(presContext, stdout, 0); } }