From 96a17b8b423aba4010cdbb50bce5954f751eac6e Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Tue, 12 Jan 2010 10:45:19 +1300 Subject: [PATCH] Bug 526394. Part 32: Remove code that only existed so that scrollframes could have views. r=mats --- layout/base/nsCSSFrameConstructor.cpp | 10 --------- layout/generic/nsContainerFrame.cpp | 18 ---------------- layout/generic/nsContainerFrame.h | 3 --- layout/generic/nsFrame.cpp | 6 ------ layout/generic/nsHTMLContainerFrame.cpp | 22 +++++++------------ layout/generic/nsIFrame.h | 9 +------- layout/xul/base/src/nsBoxFrame.cpp | 16 ++++---------- view/public/nsIView.h | 28 ------------------------- view/src/nsView.cpp | 25 +++------------------- 9 files changed, 15 insertions(+), 122 deletions(-) diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index d1a35fe0f13c..f05d5d3fae2a 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -4258,16 +4258,6 @@ nsCSSFrameConstructor::FinishBuildingScrollFrame(nsIFrame* aScrollFrame, { nsFrameList scrolled(aScrolledFrame, aScrolledFrame); aScrollFrame->AppendFrames(nsnull, scrolled); - - // 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, PR_TRUE); - - // XXXbz what's the point of the code after this in this method? - nsIView* view = aScrolledFrame->GetView(); - if (!view) - return; } diff --git a/layout/generic/nsContainerFrame.cpp b/layout/generic/nsContainerFrame.cpp index c18d21f4d031..630a46b7ff9b 100644 --- a/layout/generic/nsContainerFrame.cpp +++ b/layout/generic/nsContainerFrame.cpp @@ -570,12 +570,6 @@ nsContainerFrame::SyncFrameViewProperties(nsPresContext* aPresContext, nsIViewManager* vm = aView->GetViewManager(); - /* If this frame has a -moz-transform property, tell it to invalidate on a scroll - * rather than doing a BitBlt. - */ - if (aFrame->GetStyleDisplay()->HasTransform()) - aView->SetInvalidateFrameOnScroll(); - if (nsnull == aStyleContext) { aStyleContext = aFrame->GetStyleContext(); } @@ -612,18 +606,6 @@ nsContainerFrame::SyncFrameViewProperties(nsPresContext* aPresContext, vm->SetViewZIndex(aView, autoZIndex, zIndex, isPositioned); } -PRBool -nsContainerFrame::FrameNeedsView(nsIFrame* aFrame) -{ - // XXX Check needed because frame construction can't properly figure out when - // a frame is the child of a scrollframe - if (aFrame->GetStyleContext()->GetPseudo() == - nsCSSAnonBoxes::scrolledContent) { - return PR_TRUE; - } - return aFrame->NeedsView() || aFrame->GetStyleDisplay()->HasTransform(); -} - static nscoord GetCoord(const nsStyleCoord& aCoord, nscoord aIfNotCoord) { return aCoord.GetUnit() == eStyleUnit_Coord diff --git a/layout/generic/nsContainerFrame.h b/layout/generic/nsContainerFrame.h index cb41061b8d89..cc09893a9b90 100644 --- a/layout/generic/nsContainerFrame.h +++ b/layout/generic/nsContainerFrame.h @@ -149,9 +149,6 @@ public: nsIView* aView, PRUint32 aFlags = 0); - // Returns PR_TRUE if the frame requires a view - static PRBool FrameNeedsView(nsIFrame* aFrame); - // Used by both nsInlineFrame and nsFirstLetterFrame. void DoInlineIntrinsicWidth(nsIRenderingContext *aRenderingContext, InlineIntrinsicWidthData *aData, diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 1fb3d03bfe65..348da352916a 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -3424,12 +3424,6 @@ nsIFrame* nsIFrame::GetTailContinuation() return frame; } -nsIView* -nsIFrame::GetParentViewForChildFrame(nsIFrame* aFrame) const -{ - return GetClosestView(); -} - // Associated view object nsIView* nsIFrame::GetView() const diff --git a/layout/generic/nsHTMLContainerFrame.cpp b/layout/generic/nsHTMLContainerFrame.cpp index 7d8f7e0b12ce..8a713b3d6072 100644 --- a/layout/generic/nsHTMLContainerFrame.cpp +++ b/layout/generic/nsHTMLContainerFrame.cpp @@ -58,7 +58,6 @@ #include "nsIView.h" #include "nsIViewManager.h" #include "nsIDOMEvent.h" -#include "nsIScrollableView.h" #include "nsWidgetsCID.h" #include "nsCOMPtr.h" #include "nsIDeviceContext.h" @@ -756,12 +755,12 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIFrame* aFrame, } // If we don't yet have a view, see if we need a view - if (!(aForce || FrameNeedsView(aFrame))) { + if (!aForce && !aFrame->NeedsView()) { // don't need a view return NS_OK; } - nsIView* parentView = aFrame->GetParent()->GetParentViewForChildFrame(aFrame); + nsIView* parentView = aFrame->GetParent()->GetClosestView(); NS_ASSERTION(parentView, "no parent with view"); nsIViewManager* viewManager = parentView->GetViewManager(); @@ -774,18 +773,11 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIFrame* aFrame, SyncFrameViewProperties(aFrame->PresContext(), aFrame, nsnull, view); - // Insert the view into the view hierarchy. If the parent view is a - // scrolling view we need to do this differently - nsIScrollableView* scrollingView = parentView->ToScrollableView(); - if (scrollingView) { - scrollingView->SetScrolledView(view); - } else { - nsIView* insertBefore = nsLayoutUtils::FindSiblingViewFor(parentView, aFrame); - // we insert this view 'above' the insertBefore view, unless insertBefore is null, - // in which case we want to call with aAbove == PR_FALSE to insert at the beginning - // in document order - viewManager->InsertChild(parentView, view, insertBefore, insertBefore != nsnull); - } + nsIView* insertBefore = nsLayoutUtils::FindSiblingViewFor(parentView, aFrame); + // we insert this view 'above' the insertBefore view, unless insertBefore is null, + // in which case we want to call with aAbove == PR_FALSE to insert at the beginning + // in document order + viewManager->InsertChild(parentView, view, insertBefore, insertBefore != nsnull); // REVIEW: Don't create a widget for fixed-pos elements anymore. // ComputeRepaintRegionForCopy will calculate the right area to repaint diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index f111db1a57fe..e16d721c1e4f 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -1015,7 +1015,7 @@ public: PRUint32 aFlags = 0); /** - * Does this frame type always need a view? + * Does this frame need a view? */ virtual PRBool NeedsView() { return PR_FALSE; } @@ -1585,13 +1585,6 @@ 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| diff --git a/layout/xul/base/src/nsBoxFrame.cpp b/layout/xul/base/src/nsBoxFrame.cpp index 754d1ffa51a2..c8fa8fb5f9d1 100644 --- a/layout/xul/base/src/nsBoxFrame.cpp +++ b/layout/xul/base/src/nsBoxFrame.cpp @@ -84,7 +84,6 @@ #include "nsIScrollableFrame.h" #include "nsWidgetsCID.h" #include "nsCSSAnonBoxes.h" -#include "nsIScrollableView.h" #include "nsHTMLContainerFrame.h" #include "nsIEventStateManager.h" #include "nsIDOMDocument.h" @@ -1834,7 +1833,7 @@ nsBoxFrame::CreateViewForFrame(nsPresContext* aPresContext, zIndex = PR_INT32_MAX; } else { - parentView = aFrame->GetParent()->GetParentViewForChildFrame(aFrame); + parentView = aFrame->GetParent()->GetClosestView(); } NS_ASSERTION(parentView, "no parent view"); @@ -1842,16 +1841,9 @@ nsBoxFrame::CreateViewForFrame(nsPresContext* aPresContext, // Create a view nsIView *view = viewManager->CreateView(aFrame->GetRect(), parentView, visibility); if (view) { - // Insert the view into the view hierarchy. If the parent view is a - // scrolling view we need to do this differently - nsIScrollableView* scrollingView = parentView->ToScrollableView(); - if (scrollingView) { - scrollingView->SetScrolledView(view); - } else { - viewManager->SetViewZIndex(view, autoZIndex, zIndex); - // XXX put view last in document order until we can do better - viewManager->InsertChild(parentView, view, nsnull, PR_TRUE); - } + viewManager->SetViewZIndex(view, autoZIndex, zIndex); + // XXX put view last in document order until we can do better + viewManager->InsertChild(parentView, view, nsnull, PR_TRUE); } // Remember our view diff --git a/view/public/nsIView.h b/view/public/nsIView.h index cbc47be97b3a..a84f030b62ed 100644 --- a/view/public/nsIView.h +++ b/view/public/nsIView.h @@ -47,7 +47,6 @@ #include "nsWidgetInitData.h" class nsIViewManager; -class nsIScrollableView; class nsViewManager; class nsView; class nsWeakView; @@ -86,11 +85,6 @@ enum nsViewVisibility { // is z-index:auto also #define NS_VIEW_FLAG_TOPMOST 0x0010 -// If set, the view should always invalidate its frame -// during a scroll instead of doing a BitBlt. This bit -// is propagated down to children. -#define NS_VIEW_FLAG_INVALIDATE_ON_SCROLL 0x0020 - struct nsViewZIndex { PRBool mIsAuto; PRInt32 mZIndex; @@ -120,12 +114,6 @@ class nsIView public: NS_DECLARE_STATIC_IID_ACCESSOR(NS_IVIEW_IID) - /** - * See if this view is scrollable. - * @result an nsIScrollableView* if the view is scrollable, or nsnull if not. - */ - virtual nsIScrollableView* ToScrollableView() { return nsnull; } - /** * Find the view for the given widget, if there is one. * @return the view the widget belongs to, or null if the widget doesn't @@ -328,22 +316,6 @@ public: */ void DetachWidgetEventHandler(nsIWidget* aWidget); - /** - * If called, will make the view invalidate its frame instead of BitBlitting - * it when there's a scroll. - */ - void SetInvalidateFrameOnScroll() - { - mVFlags |= NS_VIEW_FLAG_INVALIDATE_ON_SCROLL; - } - - /** - * Returns whether or not we should automatically fail to BitBlt when scrolling. - * This is true if either we're marked to have invalidate on scroll or if some - * ancestor does. - */ - PRBool NeedsInvalidateFrameOnScroll() const; - #ifdef DEBUG /** * Output debug info to FILE diff --git a/view/src/nsView.cpp b/view/src/nsView.cpp index 2d8b53b9671e..501408a10553 100644 --- a/view/src/nsView.cpp +++ b/view/src/nsView.cpp @@ -41,7 +41,6 @@ #include "nsGUIEvent.h" #include "nsIDeviceContext.h" #include "nsIComponentManager.h" -#include "nsIScrollableView.h" #include "nsGfxCIID.h" #include "nsIRegion.h" #include "nsIInterfaceRequestor.h" @@ -53,10 +52,9 @@ static nsEventStatus HandleEvent(nsGUIEvent *aEvent); //#define SHOW_VIEW_BORDERS -// {34297A07-A8FD-d811-87C6-000244212BCB} #define VIEW_WRAPPER_IID \ -{ 0x34297a07, 0xa8fd, 0xd811, { 0x87, 0xc6, 0x0, 0x2, 0x44, 0x21, 0x2b, 0xcb } } - + { 0xbf4e1841, 0xe9ec, 0x47f2, \ + { 0xb4, 0x77, 0x0f, 0xf6, 0x0f, 0x5a, 0xac, 0xbd } } /** * nsISupports-derived helper class that allows to store and get a view @@ -87,8 +85,7 @@ NS_IMETHODIMP ViewWrapper::QueryInterface(REFNSIID aIID, void** aInstancePtr) { NS_ENSURE_ARG_POINTER(aInstancePtr); - NS_ASSERTION(!aIID.Equals(NS_GET_IID(nsIView)) && - !aIID.Equals(NS_GET_IID(nsIScrollableView)), + NS_ASSERTION(!aIID.Equals(NS_GET_IID(nsIView)), "Someone expects a viewwrapper to be a view!"); *aInstancePtr = nsnull; @@ -115,10 +112,6 @@ NS_IMETHODIMP ViewWrapper::QueryInterface(REFNSIID aIID, void** aInstancePtr) NS_IMETHODIMP ViewWrapper::GetInterface(REFNSIID aIID, void** aInstancePtr) { - if (aIID.Equals(NS_GET_IID(nsIScrollableView))) { - *aInstancePtr = mView->ToScrollableView(); - return NS_OK; - } if (aIID.Equals(NS_GET_IID(nsIView))) { *aInstancePtr = mView; return NS_OK; @@ -881,15 +874,3 @@ nsIView::SetDeletionObserver(nsWeakView* aDeletionObserver) } mDeletionObserver = aDeletionObserver; } - -/* We invalidate the frame on a scroll iff this frame is marked as such or if - * some parent is. - */ -PRBool nsIView::NeedsInvalidateFrameOnScroll() const -{ - for (const nsIView *currView = this; currView != nsnull; currView = currView->GetParent()) - if (currView->mVFlags & NS_VIEW_FLAG_INVALIDATE_ON_SCROLL) - return PR_TRUE; - - return PR_FALSE; -}