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
parent 3c94fecdb3
commit 13ac1c2c83
8 changed files with 72 additions and 4 deletions

View File

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

View File

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

View File

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

View File

@ -108,10 +108,6 @@ struct CharacterDataChangeInfo;
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
* of floats, and when pulling up child frames from a next-in-flow.
@ -633,6 +629,15 @@ public:
*/
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
*

View File

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

View File

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

View File

@ -1252,6 +1252,35 @@ nsIScrollableView* nsMenuPopupFrame::GetScrollableView(nsIFrame* aStart)
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)
{
if (aMenuItem) {

View File

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