From 89977d9b7c64dc6f4ddfe5f59068b88745321cd4 Mon Sep 17 00:00:00 2001 From: "roc+%cs.cmu.edu" Date: Thu, 7 Apr 2005 23:54:28 +0000 Subject: [PATCH] Bug 288949. Don't try to use view reparenting to handle scrolled child views. Also, fix regression so that listboxes don't always have widgets. r+sr=dbaron,a=asa. git-svn-id: svn://10.0.0.236/trunk@171875 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/base/nsCSSFrameConstructor.cpp | 13 +++---------- mozilla/layout/generic/nsFrame.cpp | 6 ++++++ mozilla/layout/generic/nsGfxScrollFrame.cpp | 14 +++++++++++++- mozilla/layout/generic/nsGfxScrollFrame.h | 10 ++++++++++ mozilla/layout/generic/nsHTMLContainerFrame.cpp | 6 +----- mozilla/layout/generic/nsIFrame.h | 7 +++++++ 6 files changed, 40 insertions(+), 16 deletions(-) diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index 996d0af78ae..6955d08f759 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -6346,20 +6346,13 @@ nsCSSFrameConstructor::FinishBuildingScrollFrame(nsIFrame* aScrollFrame, { aScrollFrame->AppendFrames(nsnull, aScrolledFrame); - // force the scrolled frame to have a view + // force the scrolled frame to have a view. The view will be parented to + // the correct anonymous inner view because the scrollframes override + // nsIFrame::GetParentViewForChildFrame. nsHTMLContainerFrame::CreateViewForFrame(aScrolledFrame, nsnull, PR_TRUE); nsIView* view = aScrolledFrame->GetView(); if (!view) return; - - // reparent the view from the scrollframe's view to its inner scrolling view - nsIScrollableFrame* scrollable; - CallQueryInterface(aScrollFrame, &scrollable); - if (scrollable) { - nsIViewManager* vm = view->GetViewManager(); - vm->RemoveChild(view); - vm->InsertChild(scrollable->GetScrollableView()->View(), view, nsnull, PR_TRUE); - } } diff --git a/mozilla/layout/generic/nsFrame.cpp b/mozilla/layout/generic/nsFrame.cpp index 72260d45f9f..89f4626cc11 100644 --- a/mozilla/layout/generic/nsFrame.cpp +++ b/mozilla/layout/generic/nsFrame.cpp @@ -2257,6 +2257,12 @@ NS_IMETHODIMP nsFrame::SetNextInFlow(nsIFrame*) return NS_ERROR_NOT_IMPLEMENTED; } +nsIView* +nsIFrame::GetParentViewForChildFrame(nsIFrame* aFrame) const +{ + return GetClosestView(); +} + // Associated view object nsIView* nsIFrame::GetView() const diff --git a/mozilla/layout/generic/nsGfxScrollFrame.cpp b/mozilla/layout/generic/nsGfxScrollFrame.cpp index 630ae652098..2f03d5bbb30 100644 --- a/mozilla/layout/generic/nsGfxScrollFrame.cpp +++ b/mozilla/layout/generic/nsGfxScrollFrame.cpp @@ -1076,7 +1076,7 @@ nsGfxScrollFrameInner::NeedsClipWidget() const { // Scrollports contained in form controls (e.g., listboxes) don't get // widgets. - for (nsIFrame* parentFrame = mOuter->GetParent(); parentFrame; + for (nsIFrame* parentFrame = mOuter; parentFrame; parentFrame = parentFrame->GetParent()) { nsIFormControlFrame* fcFrame; if ((NS_SUCCEEDED(parentFrame->QueryInterface(NS_GET_IID(nsIFormControlFrame), (void**)&fcFrame)))) { @@ -1157,6 +1157,18 @@ static void HandleScrollPref(nsIScrollable *aScrollable, PRInt32 aOrientation, } } +nsIView* +nsGfxScrollFrameInner::GetParentViewForChildFrame(nsIFrame* aFrame) const +{ + if (aFrame->GetContent() == mOuter->GetContent()) { + NS_ASSERTION(mScrollableView, "Scrollable view should have been created by now"); + // scrolled frame, put it under our anonymous view + return mScrollableView->View(); + } + // scrollbars and stuff; put them under our regular view + return mOuter->GetView(); +} + nsGfxScrollFrameInner::ScrollbarStyles nsGfxScrollFrameInner::GetScrollbarStylesFromFrame() const { diff --git a/mozilla/layout/generic/nsGfxScrollFrame.h b/mozilla/layout/generic/nsGfxScrollFrame.h index 857fe8554f9..7aa3a5ca9ed 100644 --- a/mozilla/layout/generic/nsGfxScrollFrame.h +++ b/mozilla/layout/generic/nsGfxScrollFrame.h @@ -123,6 +123,8 @@ public: nsIScrollableView* GetScrollableView() const { return mScrollableView; } + nsIView* GetParentViewForChildFrame(nsIFrame* aFrame) const; + void ScrollToRestoredPosition(); nsPresState* SaveState(); @@ -225,6 +227,10 @@ public: aContentOffsetEnd, aBeginFrameContent); } + virtual nsIView* GetParentViewForChildFrame(nsIFrame* aFrame) const { + return mInner.GetParentViewForChildFrame(aFrame); + } + virtual nsIFrame* GetContentInsertionFrame() { return mInner.GetScrolledFrame()->GetContentInsertionFrame(); } @@ -373,6 +379,10 @@ public: aContentOffsetEnd, aBeginFrameContent); } + virtual nsIView* GetParentViewForChildFrame(nsIFrame* aFrame) const { + return mInner.GetParentViewForChildFrame(aFrame); + } + virtual nsIFrame* GetContentInsertionFrame() { return mInner.GetScrolledFrame()->GetContentInsertionFrame(); } diff --git a/mozilla/layout/generic/nsHTMLContainerFrame.cpp b/mozilla/layout/generic/nsHTMLContainerFrame.cpp index bb7e7319d94..57b6e983cd6 100644 --- a/mozilla/layout/generic/nsHTMLContainerFrame.cpp +++ b/mozilla/layout/generic/nsHTMLContainerFrame.cpp @@ -537,11 +537,7 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIFrame* aFrame, return NS_OK; } - // Create a view - nsIFrame* parent = aFrame->GetAncestorWithView(); - NS_ASSERTION(parent, "GetParentWithView failed"); - - nsIView* parentView = parent->GetView(); + nsIView* parentView = aFrame->GetParent()->GetParentViewForChildFrame(aFrame); NS_ASSERTION(parentView, "no parent with view"); nsIViewManager* viewManager = parentView->GetViewManager(); diff --git a/mozilla/layout/generic/nsIFrame.h b/mozilla/layout/generic/nsIFrame.h index 8b3f07a6909..aaf81a6d5f2 100644 --- a/mozilla/layout/generic/nsIFrame.h +++ b/mozilla/layout/generic/nsIFrame.h @@ -986,6 +986,13 @@ public: virtual nsIView* GetViewExternal() const; nsresult SetView(nsIView* aView); + /** + * This view will be used to parent the views of any children. + * This allows us to insert an anonymous inner view to parent + * some children. + */ + virtual nsIView* GetParentViewForChildFrame(nsIFrame* aFrame) const; + /** * Find the closest view (on |this| or an ancestor). * If aOffset is non-null, it will be set to the offset of |this|