Bug 526394. Part 3: Add all necessary new APIs to nsIScrollableFrame. r=mats,sr=dbaron

This commit is contained in:
Robert O'Callahan 2009-09-01 16:11:11 +12:00
parent 90d248d976
commit 3c94fecdb3
8 changed files with 345 additions and 191 deletions

View File

@ -419,7 +419,7 @@ nsCoreUtils::ScrollFrameToPoint(nsIFrame *aScrollableFrame,
nsPoint scrollPoint = scrollableFrame->GetScrollPosition();
scrollPoint -= deltaPoint;
scrollableFrame->ScrollTo(scrollPoint);
scrollableFrame->ScrollTo(scrollPoint, nsIScrollableFrame::INSTANT);
}
void

View File

@ -99,54 +99,6 @@ nsHTMLScrollFrame::nsHTMLScrollFrame(nsIPresShell* aShell, nsStyleContext* aCont
{
}
/**
* Get the view that we are scrolling within the scrolling view.
* @result child view
*/
nsIFrame* nsHTMLScrollFrame::GetScrolledFrame() const
{
return mInner.GetScrolledFrame();
}
nsIScrollableView* nsHTMLScrollFrame::GetScrollableView()
{
return mInner.GetScrollableView();
}
nsPoint nsHTMLScrollFrame::GetScrollPosition() const
{
nsIScrollableView* s = mInner.GetScrollableView();
nsPoint scrollPosition;
s->GetScrollPosition(scrollPosition.x, scrollPosition.y);
return scrollPosition;
}
void nsHTMLScrollFrame::ScrollTo(nsPoint aScrollPosition, PRUint32 aFlags)
{
nsIScrollableView* s = mInner.GetScrollableView();
s->ScrollTo(aScrollPosition.x, aScrollPosition.y, aFlags);
}
nsGfxScrollFrameInner::ScrollbarStyles
nsHTMLScrollFrame::GetScrollbarStyles() const {
return mInner.GetScrollbarStylesFromFrame();
}
nsMargin nsHTMLScrollFrame::GetDesiredScrollbarSizes(nsBoxLayoutState* aState) {
return mInner.GetDesiredScrollbarSizes(aState);
}
void nsHTMLScrollFrame::SetScrollbarVisibility(PRBool aVerticalVisible, PRBool aHorizontalVisible)
{
mInner.mNeverHasVerticalScrollbar = !aVerticalVisible;
mInner.mNeverHasHorizontalScrollbar = !aHorizontalVisible;
}
nsIBox* nsHTMLScrollFrame::GetScrollbarBox(PRBool aVertical)
{
return aVertical ? mInner.mVScrollbarBox : mInner.mHScrollbarBox;
}
nsresult
nsHTMLScrollFrame::CreateAnonymousContent(nsTArray<nsIContent*>& aElements)
{
@ -935,13 +887,6 @@ NS_IMETHODIMP nsHTMLScrollFrame::GetAccessible(nsIAccessible** aAccessible)
}
#endif
void
nsHTMLScrollFrame::CurPosAttributeChanged(nsIContent* aChild,
PRInt32 aModType)
{
mInner.CurPosAttributeChanged(aChild);
}
NS_IMETHODIMP
nsHTMLScrollFrame::PostScrolledAreaEventForCurrentArea()
{
@ -975,43 +920,6 @@ nsXULScrollFrame::nsXULScrollFrame(nsIPresShell* aShell, nsStyleContext* aContex
SetLayoutManager(nsnull);
}
/**
* Get the view that we are scrolling within the scrolling view.
* @result child view
*/
nsIFrame* nsXULScrollFrame::GetScrolledFrame() const
{
return mInner.GetScrolledFrame();
}
nsIScrollableView* nsXULScrollFrame::GetScrollableView()
{
return mInner.GetScrollableView();
}
nsPoint nsXULScrollFrame::GetScrollPosition() const
{
nsIScrollableView* s = mInner.GetScrollableView();
nsPoint scrollPosition;
s->GetScrollPosition(scrollPosition.x, scrollPosition.y);
return scrollPosition;
}
void nsXULScrollFrame::ScrollTo(nsPoint aScrollPosition, PRUint32 aFlags)
{
nsIScrollableView* s = mInner.GetScrollableView();
s->ScrollTo(aScrollPosition.x, aScrollPosition.y, aFlags);
}
nsGfxScrollFrameInner::ScrollbarStyles
nsXULScrollFrame::GetScrollbarStyles() const {
return mInner.GetScrollbarStylesFromFrame();
}
nsMargin nsXULScrollFrame::GetDesiredScrollbarSizes(nsBoxLayoutState* aState) {
return mInner.GetDesiredScrollbarSizes(aState);
}
nsMargin nsGfxScrollFrameInner::GetDesiredScrollbarSizes(nsBoxLayoutState* aState) {
NS_ASSERTION(aState && aState->GetRenderingContext(),
"Must have rendering context in layout state for size "
@ -1039,17 +947,6 @@ nsMargin nsGfxScrollFrameInner::GetDesiredScrollbarSizes(nsBoxLayoutState* aStat
return result;
}
void nsXULScrollFrame::SetScrollbarVisibility(PRBool aVerticalVisible, PRBool aHorizontalVisible)
{
mInner.mNeverHasVerticalScrollbar = !aVerticalVisible;
mInner.mNeverHasHorizontalScrollbar = !aHorizontalVisible;
}
nsIBox* nsXULScrollFrame::GetScrollbarBox(PRBool aVertical)
{
return aVertical ? mInner.mVScrollbarBox : mInner.mHScrollbarBox;
}
nsresult
nsXULScrollFrame::CreateAnonymousContent(nsTArray<nsIContent*>& aElements)
{
@ -1277,11 +1174,6 @@ nsXULScrollFrame::GetFrameName(nsAString& aResult) const
}
#endif
void nsXULScrollFrame::CurPosAttributeChanged(nsIContent* aChild, PRInt32 aModType)
{
mInner.CurPosAttributeChanged(aChild);
}
NS_IMETHODIMP
nsXULScrollFrame::DoLayout(nsBoxLayoutState& aState)
{
@ -1488,6 +1380,104 @@ nsGfxScrollFrameInner::GetScrollbarStylesFromFrame() const
return result;
}
static nscoord
AlignToDevPixelRoundingToZero(nscoord aVal, PRInt32 aAppUnitsPerDevPixel)
{
return (aVal/aAppUnitsPerDevPixel)*aAppUnitsPerDevPixel;
}
nsRect
nsGfxScrollFrameInner::GetScrollRange() const
{
nsSize scrollPortSize = GetScrollPortSize();
nsRect range = GetScrolledRect(scrollPortSize);
range.width -= scrollPortSize.width;
range.height -= scrollPortSize.height;
nsPresContext* presContext = mOuter->PresContext();
PRInt32 appUnitsPerDevPixel = presContext->AppUnitsPerDevPixel();
range.width =
AlignToDevPixelRoundingToZero(range.XMost(), appUnitsPerDevPixel) - range.x;
range.height =
AlignToDevPixelRoundingToZero(range.YMost(), appUnitsPerDevPixel) - range.y;
range.x = AlignToDevPixelRoundingToZero(range.x, appUnitsPerDevPixel);
range.y = AlignToDevPixelRoundingToZero(range.y, appUnitsPerDevPixel);
return range;
}
void
nsGfxScrollFrameInner::ScrollTo(nsPoint aScrollPosition,
nsIScrollableFrame::ScrollMode aMode)
{
mScrollableView->ScrollTo(aScrollPosition.x, aScrollPosition.y,
aMode == nsIScrollableFrame::SMOOTH ? NS_VMREFRESH_SMOOTHSCROLL : 0);
}
static void
AdjustForWholeDelta(PRInt32 aDelta, nscoord* aCoord)
{
if (aDelta < 0) {
*aCoord = nscoord_MIN;
} else if (aDelta > 0) {
*aCoord = nscoord_MAX;
}
}
void
nsGfxScrollFrameInner::ScrollBy(nsIntPoint aDelta,
nsIScrollableFrame::ScrollUnit aUnit,
nsIScrollableFrame::ScrollMode aMode,
nsIntPoint* aOverflow)
{
PRUint32 flags =
aMode == nsIScrollableFrame::SMOOTH ? NS_VMREFRESH_SMOOTHSCROLL : 0;
nsIntPoint overflow;
switch (aUnit) {
case nsIScrollableFrame::DEVICE_PIXELS: {
mScrollableView->ScrollByPixels(aDelta.x, aDelta.y,
overflow.x, overflow.y, flags);
break;
}
case nsIScrollableFrame::LINES: {
mScrollableView->ScrollByLinesWithOverflow(aDelta.x, aDelta.y,
overflow.x, overflow.y,
flags);
break;
}
case nsIScrollableFrame::PAGES: {
mScrollableView->ScrollByPages(aDelta.x, aDelta.y, flags);
break;
}
case nsIScrollableFrame::WHOLE: {
nsPoint pos = GetScrollPosition();
AdjustForWholeDelta(aDelta.x, &pos.x);
AdjustForWholeDelta(aDelta.y, &pos.y);
ScrollTo(pos, aMode);
break;
}
}
if (aOverflow) {
*aOverflow = overflow;
}
}
nsSize
nsGfxScrollFrameInner::GetLineScrollAmount() const
{
nscoord lineHeight;
mScrollableView->GetLineHeight(&lineHeight);
return nsSize(lineHeight, lineHeight);
}
nsSize
nsGfxScrollFrameInner::GetPageScrollAmount() const
{
nsSize distances;
mScrollableView->GetPageScrollDistances(&distances);
return nsSize(distances.width, distances.height);
}
/**
* this code is resposible for restoring the scroll position back to some
* saved position. if the user has not moved the scroll position manually
@ -2676,6 +2666,10 @@ nsGfxScrollFrameInner::GetScrolledRect(const nsSize& aScrollPortSize) const
x2 += extraWidth;
}
NS_ASSERTION(x2 - x1 >= aScrollPortSize.width,
"Scrolled rect smaller than scrollport?");
NS_ASSERTION(y2 - y1 >= aScrollPortSize.height,
"Scrolled rect smaller than scrollport?");
return nsRect(x1, y1, x2 - x1, y2 - y1);
}

View File

@ -142,10 +142,24 @@ public:
void InternalScrollPositionDidChange(nscoord aX, nscoord aY);
nsIScrollableView* GetScrollableView() const { return mScrollableView; }
nsRect GetScrollPortRect() const {
return mScrollableView->View()->GetBounds();
}
nsPoint GetScrollPosition() const {
nsPoint scrollPosition;
mScrollableView->GetScrollPosition(scrollPosition.x, scrollPosition.y);
return scrollPosition;
}
nsRect GetScrollRange() const;
nsIView* GetParentViewForChildFrame(nsIFrame* aFrame) const;
void ScrollTo(nsPoint aScrollPosition, nsIScrollableFrame::ScrollMode aMode);
void ScrollBy(nsIntPoint aDelta, nsIScrollableFrame::ScrollUnit aUnit,
nsIScrollableFrame::ScrollMode aMode, nsIntPoint* aOverflow);
void ScrollToRestoredPosition();
nsSize GetLineScrollAmount() const;
nsSize GetPageScrollAmount() const;
nsPresState* SaveState(nsIStatefulFrame::SpecialStateID aStateID);
void RestoreState(nsPresState* aState);
@ -153,6 +167,16 @@ public:
nsresult GetVScrollbarHintFromGlobalHistory(PRBool* aVScrollbarNeeded);
nsIFrame* GetScrolledFrame() const { return mScrolledFrame; }
nsIBox* GetScrollbarBox(PRBool aVertical) const {
return aVertical ? mVScrollbarBox : mHScrollbarBox;
}
void AddScrollPositionListener(nsIScrollPositionListener* aListener) {
mScrollableView->AddScrollPositionListener(aListener);
}
void RemoveScrollPositionListener(nsIScrollPositionListener* aListener) {
mScrollableView->RemoveScrollPositionListener(aListener);
}
void ScrollbarChanged(nsPresContext* aPresContext, nscoord aX, nscoord aY, PRUint32 aFlags);
@ -351,17 +375,63 @@ public:
virtual nsresult CreateAnonymousContent(nsTArray<nsIContent*>& aElements);
// nsIScrollableFrame
virtual nsIFrame* GetScrolledFrame() const;
virtual nsIScrollableView* GetScrollableView();
virtual nsPoint GetScrollPosition() const;
virtual void ScrollTo(nsPoint aScrollPosition, PRUint32 aFlags);
virtual void SetScrollbarVisibility(PRBool aVerticalVisible, PRBool aHorizontalVisible);
virtual nsIBox* GetScrollbarBox(PRBool aVertical);
virtual void CurPosAttributeChanged(nsIContent* aChild, PRInt32 aModType);
virtual nsIFrame* GetScrolledFrame() const {
return mInner.GetScrolledFrame();
}
virtual nsGfxScrollFrameInner::ScrollbarStyles GetScrollbarStyles() const {
return mInner.GetScrollbarStylesFromFrame();
}
virtual nsMargin GetActualScrollbarSizes() const {
return mInner.GetActualScrollbarSizes();
}
virtual nsMargin GetDesiredScrollbarSizes(nsBoxLayoutState* aState) {
return mInner.GetDesiredScrollbarSizes(aState);
}
virtual nsMargin GetDesiredScrollbarSizes(nsPresContext* aPresContext,
nsIRenderingContext* aRC) {
nsBoxLayoutState bls(aPresContext, aRC, 0);
return GetDesiredScrollbarSizes(&bls);
}
virtual nsRect GetScrollPortRect() const {
return mInner.GetScrollPortRect();
}
virtual nsPoint GetScrollPosition() const {
return mInner.GetScrollPosition();
}
virtual nsRect GetScrollRange() const {
return mInner.GetScrollRange();
}
virtual nsSize GetLineScrollAmount() const {
return mInner.GetLineScrollAmount();
}
virtual nsSize GetPageScrollAmount() const {
return mInner.GetPageScrollAmount();
}
virtual void ScrollTo(nsPoint aScrollPosition, ScrollMode aMode) {
mInner.ScrollTo(aScrollPosition, aMode);
}
virtual void ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit, ScrollMode aMode,
nsIntPoint* aOverflow) {
mInner.ScrollBy(aDelta, aUnit, aMode, aOverflow);
}
virtual void ScrollToRestoredPosition() {
mInner.ScrollToRestoredPosition();
}
virtual void AddScrollPositionListener(nsIScrollPositionListener* aListener) {
mInner.AddScrollPositionListener(aListener);
}
virtual void RemoveScrollPositionListener(nsIScrollPositionListener* aListener) {
mInner.RemoveScrollPositionListener(aListener);
}
virtual nsIBox* GetScrollbarBox(PRBool aVertical) {
return mInner.GetScrollbarBox(aVertical);
}
virtual void CurPosAttributeChanged(nsIContent* aChild) {
mInner.CurPosAttributeChanged(aChild);
}
virtual nsIScrollableView* GetScrollableView() {
return mInner.GetScrollableView();
}
// nsIStatefulFrame
NS_IMETHOD SaveState(SpecialStateID aStateID, nsPresState** aState) {
@ -375,21 +445,6 @@ public:
return NS_OK;
}
virtual void ScrollToRestoredPosition() {
mInner.ScrollToRestoredPosition();
}
virtual nsMargin GetActualScrollbarSizes() const {
return mInner.GetActualScrollbarSizes();
}
virtual nsMargin GetDesiredScrollbarSizes(nsBoxLayoutState* aState);
virtual nsMargin GetDesiredScrollbarSizes(nsPresContext* aPresContext,
nsIRenderingContext* aRC) {
nsBoxLayoutState bls(aPresContext, aRC, 0);
return GetDesiredScrollbarSizes(&bls);
}
virtual nsGfxScrollFrameInner::ScrollbarStyles GetScrollbarStyles() const;
/**
* Get the "type" of the frame
*
@ -554,17 +609,63 @@ public:
static void AdjustReflowStateBack(nsBoxLayoutState& aState, PRBool aSetBack);
// nsIScrollableFrame
virtual nsIFrame* GetScrolledFrame() const;
virtual nsIScrollableView* GetScrollableView();
virtual nsPoint GetScrollPosition() const;
virtual void ScrollTo(nsPoint aScrollPosition, PRUint32 aFlags);
virtual void SetScrollbarVisibility(PRBool aVerticalVisible, PRBool aHorizontalVisible);
virtual nsIBox* GetScrollbarBox(PRBool aVertical);
virtual void CurPosAttributeChanged(nsIContent* aChild, PRInt32 aModType);
virtual nsIFrame* GetScrolledFrame() const {
return mInner.GetScrolledFrame();
}
virtual nsGfxScrollFrameInner::ScrollbarStyles GetScrollbarStyles() const {
return mInner.GetScrollbarStylesFromFrame();
}
virtual nsMargin GetActualScrollbarSizes() const {
return mInner.GetActualScrollbarSizes();
}
virtual nsMargin GetDesiredScrollbarSizes(nsBoxLayoutState* aState) {
return mInner.GetDesiredScrollbarSizes(aState);
}
virtual nsMargin GetDesiredScrollbarSizes(nsPresContext* aPresContext,
nsIRenderingContext* aRC) {
nsBoxLayoutState bls(aPresContext, aRC, 0);
return GetDesiredScrollbarSizes(&bls);
}
virtual nsRect GetScrollPortRect() const {
return mInner.GetScrollPortRect();
}
virtual nsPoint GetScrollPosition() const {
return mInner.GetScrollPosition();
}
virtual nsRect GetScrollRange() const {
return mInner.GetScrollRange();
}
virtual nsSize GetLineScrollAmount() const {
return mInner.GetLineScrollAmount();
}
virtual nsSize GetPageScrollAmount() const {
return mInner.GetPageScrollAmount();
}
virtual void ScrollTo(nsPoint aScrollPosition, ScrollMode aMode) {
mInner.ScrollTo(aScrollPosition, aMode);
}
virtual void ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit, ScrollMode aMode,
nsIntPoint* aOverflow) {
mInner.ScrollBy(aDelta, aUnit, aMode, aOverflow);
}
virtual void ScrollToRestoredPosition() {
mInner.ScrollToRestoredPosition();
}
virtual void AddScrollPositionListener(nsIScrollPositionListener* aListener) {
mInner.AddScrollPositionListener(aListener);
}
virtual void RemoveScrollPositionListener(nsIScrollPositionListener* aListener) {
mInner.RemoveScrollPositionListener(aListener);
}
virtual nsIBox* GetScrollbarBox(PRBool aVertical) {
return mInner.GetScrollbarBox(aVertical);
}
virtual void CurPosAttributeChanged(nsIContent* aChild) {
mInner.CurPosAttributeChanged(aChild);
}
virtual nsIScrollableView* GetScrollableView() {
return mInner.GetScrollableView();
}
// nsIStatefulFrame
NS_IMETHOD SaveState(SpecialStateID aStateID, nsPresState** aState) {
@ -578,21 +679,6 @@ public:
return NS_OK;
}
virtual void ScrollToRestoredPosition() {
mInner.ScrollToRestoredPosition();
}
virtual nsMargin GetActualScrollbarSizes() const {
return mInner.GetActualScrollbarSizes();
}
virtual nsMargin GetDesiredScrollbarSizes(nsBoxLayoutState* aState);
virtual nsMargin GetDesiredScrollbarSizes(nsPresContext* aPresContext,
nsIRenderingContext* aRC) {
nsBoxLayoutState bls(aPresContext, aRC, 0);
return GetDesiredScrollbarSizes(&bls);
}
virtual nsGfxScrollFrameInner::ScrollbarStyles GetScrollbarStyles() const;
/**
* Get the "type" of the frame
*

View File

@ -36,8 +36,7 @@
* ***** END LICENSE BLOCK ***** */
/*
* interface for rendering objects that wrap rendering objects that should
* be scrollable
* interface that provides scroll APIs implemented by scrollable frames
*/
#ifndef nsIScrollFrame_h___
@ -51,20 +50,30 @@
#include "nsIFrame.h" // to get nsIBox, which is a typedef
class nsBoxLayoutState;
class nsIScrollPositionListener;
/**
* Interface for frames that are scrollable. This interface exposes
* APIs for examining scroll state, observing changes to scroll state,
* and triggering scrolling.
*/
class nsIScrollableFrame : public nsIScrollableViewProvider {
public:
NS_DECL_QUERYFRAME_TARGET(nsIScrollableFrame)
/**
* Get the frame that we are scrolling within the scrollable frame.
* @result child frame
* Get the frame for the content that we are scrolling within
* this scrollable frame.
*/
virtual nsIFrame* GetScrolledFrame() const = 0;
typedef nsPresContext::ScrollbarStyles ScrollbarStyles;
/**
* Get the styles (NS_STYLE_OVERFLOW_SCROLL, NS_STYLE_OVERFLOW_HIDDEN,
* or NS_STYLE_OVERFLOW_AUTO) governing the horizontal and vertical
* scrollbars for this frame.
*/
virtual ScrollbarStyles GetScrollbarStyles() const = 0;
/**
@ -74,58 +83,122 @@ public:
* accurate.
*/
virtual nsMargin GetActualScrollbarSizes() const = 0;
/**
* Return the sizes of all scrollbars assuming that any scrollbars that could
* be visible due to overflowing content, are.
*/
virtual nsMargin GetDesiredScrollbarSizes(nsBoxLayoutState* aState) = 0;
/**
* Return the sizes of all scrollbars assuming that any scrollbars that could
* be visible due to overflowing content, are.
*/
virtual nsMargin GetDesiredScrollbarSizes(nsPresContext* aPresContext,
nsIRenderingContext* aRC) = 0;
/**
* Get the position of the scrolled view.
* Get the area of the scrollport relative to the origin of this frame's
* border-box.
* This is the area of this frame minus border and scrollbars.
*/
virtual nsRect GetScrollPortRect() const = 0;
/**
* Get the offset of the scrollport origin relative to the scrolled
* frame origin. Typically the position will be non-negative.
* This will always be a multiple of device pixels.
*/
virtual nsPoint GetScrollPosition() const = 0;
/**
* Get the area that must contain the scroll position. Typically
* (but not always, e.g. for RTL content) x and y will be 0, and
* width or height will be nonzero if the content can be scrolled in
* that direction. Since scroll positions must be a multiple of
* device pixels, the range extrema will also be a multiple of
* device pixels.
*/
virtual nsRect GetScrollRange() const = 0;
/**
* Scroll the view to the given x,y, update's the scrollbar's thumb
* positions and the view's offset. Clamps the values to be
* legal. Updates the display based on aUpdateFlags.
* @param aX left edge to scroll to
* @param aY top edge to scroll to
* @param aUpdateFlags indicate smooth or async scrolling
* @return error status
* Return how much we would try to scroll by in each direction if
* asked to scroll by one "line" vertically and horizontally.
*/
virtual void ScrollTo(nsPoint aScrollPosition, PRUint32 aFlags = 0)=0;
virtual nsIScrollableView* GetScrollableView() = 0;
virtual nsSize GetLineScrollAmount() const = 0;
/**
* Return how much we would try to scroll by in each direction if
* asked to scroll by one "page" vertically and horizontally.
*/
virtual nsSize GetPageScrollAmount() const = 0;
/**
* Set information about whether the vertical and horizontal scrollbars
* are currently visible
* When a scroll operation is requested, we ask for either instant
* scrolling or smooth scrolling. SMOOTH will only be smooth if
* smooth scrolling is actually enabled. If an INSTANT request
* happens while a smooth scroll is already in progress, the smooth
* scroll is interrupted and we instantly scroll to the destination.
*/
virtual void SetScrollbarVisibility(PRBool aVerticalVisible, PRBool aHorizontalVisible) = 0;
virtual nsIBox* GetScrollbarBox(PRBool aVertical) = 0;
virtual void CurPosAttributeChanged(nsIContent* aChild, PRInt32 aModType) = 0;
enum ScrollMode { INSTANT, SMOOTH };
/**
* Clamps aScrollPosition to GetScrollRange and sets the scroll position
* to that value.
*/
virtual void ScrollTo(nsPoint aScrollPosition, ScrollMode aMode) = 0;
/**
* When scrolling by a relative amount, we can choose various units.
*/
enum ScrollUnit { DEVICE_PIXELS, LINES, PAGES, WHOLE };
/**
* Modifies the current scroll position by aDelta units given by aUnit,
* clamping it to GetScrollRange. If WHOLE is specified as the unit,
* content is scrolled all the way in the direction(s) given by aDelta.
* @param aOverflow if non-null, returns the amount that scrolling
* was clamped by in each direction (how far we moved the scroll position
to bring it back into the legal range). This is never negative. This
* is only supported for LINES and DEVICE_PIXELS. The values are in
* device pixels.
*/
virtual void ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit, ScrollMode aMode,
nsIntPoint* aOverflow = nsnull) = 0;
/**
* This tells the scroll frame to try scrolling to the scroll
* position that was restored from the history. This must be called
* at least once after state has been restored. It is called by the
* scrolled frame itself during reflow, but sometimes state can be
* restored after reflows are done...
* XXX should we take an aMode parameter here? Currently it's instant.
*/
virtual void ScrollToRestoredPosition() = 0;
/**
* Add a scroll position listener. This listener must be removed
* before it is destroyed.
*/
virtual void AddScrollPositionListener(nsIScrollPositionListener* aListener) = 0;
/**
* Remove a scroll position listener.
*/
virtual void RemoveScrollPositionListener(nsIScrollPositionListener* aListener) = 0;
/**
* Obtain the XUL box for the horizontal or vertical scrollbar, or null
* if there is no such box. Avoid using this, but may be useful for
* setting up a scrollbar mediator if you want to redirect scrollbar
* input.
*/
virtual nsIBox* GetScrollbarBox(PRBool aVertical) = 0;
/**
* Internal method used by scrollbars to notify their scrolling
* container of changes.
*/
virtual void CurPosAttributeChanged(nsIContent* aChild) = 0;
/**
* Allows the docshell to request that the scroll frame post an event
* after being restored from history.
*/
NS_IMETHOD PostScrolledAreaEventForCurrentArea() = 0;
// OBSOLETE, will remove
virtual nsIScrollableView* GetScrollableView() = 0;
};
#endif

View File

@ -997,7 +997,8 @@ nsListBoxBodyFrame::VerticalScroll(PRInt32 aPosition)
nsPoint scrollPosition = scrollFrame->GetScrollPosition();
scrollFrame->ScrollTo(nsPoint(scrollPosition.x, aPosition));
scrollFrame->ScrollTo(nsPoint(scrollPosition.x, aPosition),
nsIScrollableFrame::INSTANT);
mYPosition = aPosition;
}

View File

@ -386,7 +386,7 @@ nsMenuPopupFrame::AdjustView()
nsIBox* child = GetChildBox();
nsIScrollableFrame *scrollframe = do_QueryFrame(child);
if (scrollframe)
scrollframe->ScrollTo(nsPoint(0,0));
scrollframe->ScrollTo(nsPoint(0,0), nsIScrollableFrame::INSTANT);
}
nsIView* view = GetView();

View File

@ -137,7 +137,7 @@ nsScrollbarFrame::AttributeChanged(PRInt32 aNameSpaceID,
if (!scrollable)
return rv;
scrollable->CurPosAttributeChanged(mContent, aModType);
scrollable->CurPosAttributeChanged(mContent);
return rv;
}

View File

@ -28,7 +28,7 @@
overflow: auto;
display: block;
width: 100px;
height: 100px;
height: 100.5px;
font-size: 16px;
}
</style>