Bug 526394. Part 4: Obsolete nsIScrollableViewProvider by adding nsIFrame::GetScrollTargetFrame. r=mats,sr=dbaron

This commit is contained in:
Robert O'Callahan 2009-09-01 23:22:31 +12:00
Родитель 1035bd73ed
Коммит d5b09287dc
8 изменённых файлов: 72 добавлений и 4 удалений

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

@ -65,6 +65,7 @@
#include "nsCSSFrameConstructor.h" #include "nsCSSFrameConstructor.h"
#include "nsIScrollableViewProvider.h" #include "nsIScrollableViewProvider.h"
#include "nsIStatefulFrame.h" #include "nsIStatefulFrame.h"
#include "nsIScrollableFrame.h"
#include "nsIDOMMouseListener.h" #include "nsIDOMMouseListener.h"
#include "nsThreadUtils.h" #include "nsThreadUtils.h"
@ -137,6 +138,10 @@ public:
~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock)); ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock));
} }
virtual nsIScrollableFrame* GetScrollTargetFrame() {
return do_QueryFrame(mDropdownFrame);
}
#ifdef NS_DEBUG #ifdef NS_DEBUG
NS_IMETHOD GetFrameName(nsAString& aResult) const; NS_IMETHOD GetFrameName(nsAString& aResult) const;
#endif #endif

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

@ -50,6 +50,7 @@
#include "nsIScrollableViewProvider.h" #include "nsIScrollableViewProvider.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "nsDisplayList.h" #include "nsDisplayList.h"
#include "nsIScrollableFrame.h"
class nsIEditor; class nsIEditor;
class nsISelectionController; class nsISelectionController;
@ -76,6 +77,12 @@ public:
virtual void DestroyFrom(nsIFrame* aDestructRoot); virtual void DestroyFrom(nsIFrame* aDestructRoot);
virtual nsIScrollableFrame* GetScrollTargetFrame() {
if (!IsScrollable())
return nsnull;
return do_QueryFrame(GetFirstChild(nsnull));
}
virtual nscoord GetMinWidth(nsIRenderingContext* aRenderingContext); virtual nscoord GetMinWidth(nsIRenderingContext* aRenderingContext);
virtual nsSize ComputeAutoSize(nsIRenderingContext *aRenderingContext, virtual nsSize ComputeAutoSize(nsIRenderingContext *aRenderingContext,
nsSize aCBSize, nscoord aAvailableWidth, nsSize aCBSize, nscoord aAvailableWidth,

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

@ -346,9 +346,14 @@ public:
virtual void DestroyFrom(nsIFrame* aDestructRoot); virtual void DestroyFrom(nsIFrame* aDestructRoot);
NS_IMETHOD RemoveFrame(nsIAtom* aListName, NS_IMETHOD RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame); nsIFrame* aOldFrame);
virtual nsIScrollableFrame* GetScrollTargetFrame() {
return this;
}
virtual nsIView* GetParentViewForChildFrame(nsIFrame* aFrame) const { virtual nsIView* GetParentViewForChildFrame(nsIFrame* aFrame) const {
return mInner.GetParentViewForChildFrame(aFrame); return mInner.GetParentViewForChildFrame(aFrame);
} }
@ -551,6 +556,10 @@ public:
NS_IMETHOD RemoveFrame(nsIAtom* aListName, NS_IMETHOD RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame); nsIFrame* aOldFrame);
virtual nsIScrollableFrame* GetScrollTargetFrame() {
return this;
}
virtual nsIView* GetParentViewForChildFrame(nsIFrame* aFrame) const { virtual nsIView* GetParentViewForChildFrame(nsIFrame* aFrame) const {
return mInner.GetParentViewForChildFrame(aFrame); return mInner.GetParentViewForChildFrame(aFrame);
} }

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

@ -108,10 +108,6 @@ struct CharacterDataChangeInfo;
typedef class nsIFrame nsIBox; typedef class nsIFrame nsIBox;
#define NS_IFRAME_IID \
{ 0x8bee3c3f, 0x0b4a, 0x4453, \
{ 0xa6, 0x77, 0xf3, 0xd2, 0x56, 0xd1, 0x0e, 0xdc } }
/** /**
* Indication of how the frame can be split. This is used when doing runaround * Indication of how the frame can be split. This is used when doing runaround
* of floats, and when pulling up child frames from a next-in-flow. * of floats, and when pulling up child frames from a next-in-flow.
@ -633,6 +629,15 @@ public:
*/ */
virtual nsIFrame* GetContentInsertionFrame() { return this; } virtual nsIFrame* GetContentInsertionFrame() { return this; }
/**
* Get the frame that should be scrolled if the content associated
* with this frame is targeted for scrolling. For frames implementing
* nsIScrollableFrame this will return the frame itself. For frames
* like nsTextControlFrame that contain a scrollframe, will return
* that scrollframe.
*/
virtual nsIScrollableFrame* GetScrollTargetFrame() { return nsnull; }
/** /**
* Get the offsets of the frame. most will be 0,0 * Get the offsets of the frame. most will be 0,0
* *

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

@ -1345,6 +1345,16 @@ nsIScrollableView* nsMenuFrame::GetScrollableView()
return nsnull; return nsnull;
} }
nsIScrollableFrame* nsMenuFrame::GetScrollTargetFrame()
{
if (!mPopupFrame)
return nsnull;
nsIFrame* childFrame = mPopupFrame->GetFirstChild(nsnull);
if (childFrame)
return mPopupFrame->GetScrollFrame(childFrame);
return nsnull;
}
// nsMenuTimerMediator implementation. // nsMenuTimerMediator implementation.
NS_IMPL_ISUPPORTS1(nsMenuTimerMediator, nsITimerCallback) NS_IMPL_ISUPPORTS1(nsMenuTimerMediator, nsITimerCallback)

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

@ -161,6 +161,8 @@ public:
NS_IMETHOD SelectMenu(PRBool aActivateFlag); NS_IMETHOD SelectMenu(PRBool aActivateFlag);
virtual nsIScrollableFrame* GetScrollTargetFrame();
/** /**
* NOTE: OpenMenu will open the menu asynchronously. * NOTE: OpenMenu will open the menu asynchronously.
*/ */

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

@ -1252,6 +1252,35 @@ nsIScrollableView* nsMenuPopupFrame::GetScrollableView(nsIFrame* aStart)
return nsnull; return nsnull;
} }
// XXXroc this is megalame. Fossicking around for a frame of the right
// type is a recipe for disaster in the long term.
nsIScrollableFrame* nsMenuPopupFrame::GetScrollFrame(nsIFrame* aStart)
{
if (!aStart)
return nsnull;
// try start frame and siblings
nsIFrame* currFrame = aStart;
do {
nsIScrollableFrame* sf = do_QueryFrame(currFrame);
if (sf)
return sf;
currFrame = currFrame->GetNextSibling();
} while (currFrame);
// try children
currFrame = aStart;
do {
nsIFrame* childFrame = currFrame->GetFirstChild(nsnull);
nsIScrollableFrame* sf = GetScrollFrame(childFrame);
if (sf)
return sf;
currFrame = currFrame->GetNextSibling();
} while (currFrame);
return nsnull;
}
void nsMenuPopupFrame::EnsureMenuItemIsVisible(nsMenuFrame* aMenuItem) void nsMenuPopupFrame::EnsureMenuItemIsVisible(nsMenuFrame* aMenuItem)
{ {
if (aMenuItem) { if (aMenuItem) {

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

@ -286,6 +286,7 @@ public:
void SetConsumeRollupEvent(PRUint32 aConsumeMode); void SetConsumeRollupEvent(PRUint32 aConsumeMode);
nsIScrollableView* GetScrollableView(nsIFrame* aStart); nsIScrollableView* GetScrollableView(nsIFrame* aStart);
nsIScrollableFrame* GetScrollFrame(nsIFrame* aStart);
// same as SetBounds except the preferred size mPrefSize is also set. // same as SetBounds except the preferred size mPrefSize is also set.
void SetPreferredBounds(nsBoxLayoutState& aState, const nsRect& aRect); void SetPreferredBounds(nsBoxLayoutState& aState, const nsRect& aRect);