mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-14 20:22:00 +00:00
Bug 526394. Part 27: Rewrite EnsureMenuItemIsVisible to use new nsIPresShell API. r=mats
This commit is contained in:
parent
29d6e5186d
commit
46e847c176
@ -66,7 +66,6 @@
|
||||
#include "nsILookAndFeel.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsBoxLayoutState.h"
|
||||
#include "nsIScrollableView.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsIRootBox.h"
|
||||
@ -1211,47 +1210,6 @@ PRBool nsMenuPopupFrame::ConsumeOutsideClicks()
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
static nsIScrollableView* GetScrollableViewForFrame(nsIFrame* aFrame)
|
||||
{
|
||||
nsIScrollableFrame* sf = do_QueryFrame(aFrame);
|
||||
if (!sf)
|
||||
return nsnull;
|
||||
return sf->GetScrollableView();
|
||||
}
|
||||
|
||||
// XXXroc this is megalame. Fossicking around for a view of the right
|
||||
// type is a recipe for disaster in the long term.
|
||||
nsIScrollableView* nsMenuPopupFrame::GetScrollableView(nsIFrame* aStart)
|
||||
{
|
||||
if ( ! aStart )
|
||||
return nsnull;
|
||||
|
||||
nsIFrame* currFrame;
|
||||
nsIScrollableView* scrollableView=nsnull;
|
||||
|
||||
// try start frame and siblings
|
||||
currFrame=aStart;
|
||||
do {
|
||||
scrollableView = GetScrollableViewForFrame(currFrame);
|
||||
if ( scrollableView )
|
||||
return scrollableView;
|
||||
currFrame = currFrame->GetNextSibling();
|
||||
} while ( currFrame );
|
||||
|
||||
// try children
|
||||
nsIFrame* childFrame;
|
||||
currFrame=aStart;
|
||||
do {
|
||||
childFrame = currFrame->GetFirstChild(nsnull);
|
||||
scrollableView=GetScrollableView(childFrame);
|
||||
if ( scrollableView )
|
||||
return scrollableView;
|
||||
currFrame = currFrame->GetNextSibling();
|
||||
} while ( currFrame );
|
||||
|
||||
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)
|
||||
@ -1284,24 +1242,12 @@ nsIScrollableFrame* nsMenuPopupFrame::GetScrollFrame(nsIFrame* aStart)
|
||||
void nsMenuPopupFrame::EnsureMenuItemIsVisible(nsMenuFrame* aMenuItem)
|
||||
{
|
||||
if (aMenuItem) {
|
||||
nsIFrame* childFrame = GetFirstChild(nsnull);
|
||||
nsIScrollableView *scrollableView;
|
||||
scrollableView = GetScrollableView(childFrame);
|
||||
if (scrollableView) {
|
||||
nscoord scrollX, scrollY;
|
||||
|
||||
nsRect viewRect = scrollableView->View()->GetBounds();
|
||||
nsRect itemRect = aMenuItem->GetRect();
|
||||
scrollableView->GetScrollPosition(scrollX, scrollY);
|
||||
|
||||
// scroll down
|
||||
if ( itemRect.y + itemRect.height > scrollY + viewRect.height )
|
||||
scrollableView->ScrollTo(scrollX, itemRect.y + itemRect.height - viewRect.height, 0);
|
||||
|
||||
// scroll up
|
||||
else if ( itemRect.y < scrollY )
|
||||
scrollableView->ScrollTo(scrollX, itemRect.y, 0);
|
||||
}
|
||||
aMenuItem->PresContext()->PresShell()->
|
||||
ScrollFrameRectIntoView(aMenuItem,
|
||||
nsRect(nsPoint(0,0), aMenuItem->GetRect().Size()),
|
||||
NS_PRESSHELL_SCROLL_ANYWHERE,
|
||||
NS_PRESSHELL_SCROLL_ANYWHERE,
|
||||
nsIPresShell::SCROLL_OVERFLOW_HIDDEN);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -285,7 +285,6 @@ public:
|
||||
void SetAutoPosition(PRBool aShouldAutoPosition);
|
||||
void SetConsumeRollupEvent(PRUint32 aConsumeMode);
|
||||
|
||||
nsIScrollableView* GetScrollableView(nsIFrame* aStart);
|
||||
nsIScrollableFrame* GetScrollFrame(nsIFrame* aStart);
|
||||
|
||||
// same as SetBounds except the preferred size mPrefSize is also set.
|
||||
|
Loading…
x
Reference in New Issue
Block a user