2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-12-07 06:36:05 +03:00
|
|
|
|
2006-03-29 22:29:03 +04:00
|
|
|
/*
|
2009-09-01 08:11:11 +04:00
|
|
|
* interface that provides scroll APIs implemented by scrollable frames
|
2006-03-29 22:29:03 +04:00
|
|
|
*/
|
|
|
|
|
1999-12-07 06:36:05 +03:00
|
|
|
#ifndef nsIScrollFrame_h___
|
|
|
|
#define nsIScrollFrame_h___
|
|
|
|
|
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsCoord.h"
|
2004-09-05 04:04:04 +04:00
|
|
|
#include "nsPresContext.h"
|
1999-12-07 06:36:05 +03:00
|
|
|
|
2012-02-20 20:24:36 +04:00
|
|
|
#define NS_DEFAULT_VERTICAL_SCROLL_DISTANCE 3
|
|
|
|
|
2004-01-09 22:21:20 +03:00
|
|
|
class nsBoxLayoutState;
|
2009-09-01 08:11:11 +04:00
|
|
|
class nsIScrollPositionListener;
|
2012-08-06 07:00:57 +04:00
|
|
|
class nsIFrame;
|
1999-12-07 06:36:05 +03:00
|
|
|
|
2009-09-01 08:11:11 +04:00
|
|
|
/**
|
|
|
|
* Interface for frames that are scrollable. This interface exposes
|
|
|
|
* APIs for examining scroll state, observing changes to scroll state,
|
|
|
|
* and triggering scrolling.
|
|
|
|
*/
|
2009-09-09 09:40:01 +04:00
|
|
|
class nsIScrollableFrame : public nsQueryFrame {
|
1999-12-07 06:36:05 +03:00
|
|
|
public:
|
2000-05-15 08:12:31 +04:00
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_DECL_QUERYFRAME_TARGET(nsIScrollableFrame)
|
1999-12-07 06:36:05 +03:00
|
|
|
|
|
|
|
/**
|
2009-09-01 08:11:11 +04:00
|
|
|
* Get the frame for the content that we are scrolling within
|
|
|
|
* this scrollable frame.
|
1999-12-07 06:36:05 +03:00
|
|
|
*/
|
2004-09-06 06:44:43 +04:00
|
|
|
virtual nsIFrame* GetScrolledFrame() const = 0;
|
1999-12-07 06:36:05 +03:00
|
|
|
|
2004-09-05 04:04:04 +04:00
|
|
|
typedef nsPresContext::ScrollbarStyles ScrollbarStyles;
|
2009-09-01 08:11:11 +04:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2004-06-18 06:08:19 +04:00
|
|
|
virtual ScrollbarStyles GetScrollbarStyles() const = 0;
|
|
|
|
|
2010-01-14 16:00:00 +03:00
|
|
|
enum { HORIZONTAL = 0x01, VERTICAL = 0x02 };
|
|
|
|
/**
|
|
|
|
* Return the scrollbars which are visible. It's OK to call this during reflow
|
|
|
|
* of the scrolled contents, in which case it will reflect the current
|
|
|
|
* assumptions about scrollbar visibility.
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual uint32_t GetScrollbarVisibility() const = 0;
|
2004-01-09 22:21:20 +03:00
|
|
|
/**
|
|
|
|
* Return the actual sizes of all possible scrollbars. Returns 0 for scrollbar
|
|
|
|
* positions that don't have a scrollbar or where the scrollbar is not visible.
|
2005-10-18 09:00:24 +04:00
|
|
|
* Do not call this while this frame's descendants are being reflowed, it won't be
|
|
|
|
* accurate.
|
2004-01-09 22:21:20 +03:00
|
|
|
*/
|
|
|
|
virtual nsMargin GetActualScrollbarSizes() const = 0;
|
|
|
|
/**
|
|
|
|
* Return the sizes of all scrollbars assuming that any scrollbars that could
|
2010-01-14 16:00:00 +03:00
|
|
|
* be visible due to overflowing content, are. This can be called during reflow
|
|
|
|
* of the scrolled contents.
|
2004-01-09 22:21:20 +03:00
|
|
|
*/
|
|
|
|
virtual nsMargin GetDesiredScrollbarSizes(nsBoxLayoutState* aState) = 0;
|
2009-09-01 08:11:11 +04:00
|
|
|
/**
|
|
|
|
* Return the sizes of all scrollbars assuming that any scrollbars that could
|
2010-01-14 16:00:00 +03:00
|
|
|
* be visible due to overflowing content, are. This can be called during reflow
|
|
|
|
* of the scrolled contents.
|
2009-09-01 08:11:11 +04:00
|
|
|
*/
|
2008-04-10 08:39:41 +04:00
|
|
|
virtual nsMargin GetDesiredScrollbarSizes(nsPresContext* aPresContext,
|
2011-04-08 05:04:40 +04:00
|
|
|
nsRenderingContext* aRC) = 0;
|
2009-09-01 08:11:11 +04:00
|
|
|
|
2000-05-15 08:12:31 +04:00
|
|
|
/**
|
2009-09-01 08:11:11 +04:00
|
|
|
* 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.
|
2000-05-15 08:12:31 +04:00
|
|
|
*/
|
2004-09-06 06:44:43 +04:00
|
|
|
virtual nsPoint GetScrollPosition() const = 0;
|
2000-05-15 08:12:31 +04:00
|
|
|
/**
|
2009-09-01 08:11:11 +04:00
|
|
|
* 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.
|
2000-05-15 08:12:31 +04:00
|
|
|
*/
|
2009-09-01 08:11:11 +04:00
|
|
|
virtual nsRect GetScrollRange() const = 0;
|
2012-06-11 03:44:50 +04:00
|
|
|
/**
|
|
|
|
* Get the size of the scroll port to use when clamping the scroll
|
|
|
|
* position.
|
|
|
|
*/
|
|
|
|
virtual nsSize GetScrollPositionClampingScrollPortSize() const = 0;
|
2004-09-04 07:17:18 +04:00
|
|
|
|
|
|
|
/**
|
2009-09-01 08:11:11 +04:00
|
|
|
* Return how much we would try to scroll by in each direction if
|
|
|
|
* asked to scroll by one "line" vertically and horizontally.
|
2004-09-04 07:17:18 +04:00
|
|
|
*/
|
2009-09-01 08:11:11 +04:00
|
|
|
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;
|
2004-07-24 01:39:47 +04:00
|
|
|
|
2009-09-01 08:11:11 +04:00
|
|
|
/**
|
2011-02-04 11:00:06 +03:00
|
|
|
* When a scroll operation is requested, we ask for instant, smooth or normal
|
|
|
|
* scrolling. SMOOTH will only be smooth if smooth scrolling is actually
|
|
|
|
* enabled. INSTANT is always synchronous, NORMAL can be asynchronous.
|
|
|
|
* If an INSTANT request happens while a smooth or async scroll is already in
|
|
|
|
* progress, the async scroll is interrupted and we instantly scroll to the
|
|
|
|
* destination.
|
2009-09-01 08:11:11 +04:00
|
|
|
*/
|
2011-02-04 11:00:06 +03:00
|
|
|
enum ScrollMode { INSTANT, SMOOTH, NORMAL };
|
2009-09-01 08:11:11 +04:00
|
|
|
/**
|
|
|
|
* Clamps aScrollPosition to GetScrollRange and sets the scroll position
|
|
|
|
* to that value.
|
2012-02-08 04:53:18 +04:00
|
|
|
* @param aRange If non-null, specifies area which contains aScrollPosition
|
|
|
|
* and can be used for choosing a performance-optimized scroll position.
|
|
|
|
* Any point within this area can be chosen.
|
|
|
|
* The choosen point will be as close as possible to aScrollPosition.
|
2009-09-01 08:11:11 +04:00
|
|
|
*/
|
2012-02-08 04:53:18 +04:00
|
|
|
virtual void ScrollTo(nsPoint aScrollPosition, ScrollMode aMode,
|
2012-07-30 18:20:58 +04:00
|
|
|
const nsRect* aRange = nullptr) = 0;
|
2012-05-15 09:58:09 +04:00
|
|
|
/**
|
|
|
|
* Scrolls to a particular position in integer CSS pixels.
|
|
|
|
* Keeps the exact current horizontal or vertical position if the current
|
|
|
|
* position, rounded to CSS pixels, matches aScrollPosition. If
|
|
|
|
* aScrollPosition.x/y is different from the current CSS pixel position,
|
|
|
|
* makes sure we only move in the direction given by the difference.
|
|
|
|
* The scroll mode is INSTANT.
|
|
|
|
*/
|
|
|
|
virtual void ScrollToCSSPixels(nsIntPoint aScrollPosition) = 0;
|
2012-08-10 15:17:06 +04:00
|
|
|
/**
|
|
|
|
* Returns the scroll position in integer CSS pixels, rounded to the nearest
|
|
|
|
* pixel.
|
|
|
|
*/
|
|
|
|
virtual nsIntPoint GetScrollPositionCSSPixels() = 0;
|
2009-09-01 08:11:11 +04:00
|
|
|
/**
|
|
|
|
* 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
|
2009-10-08 07:01:15 +04:00
|
|
|
* to bring it back into the legal range). This is never negative. The
|
|
|
|
* values are in device pixels.
|
2009-09-01 08:11:11 +04:00
|
|
|
*/
|
|
|
|
virtual void ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit, ScrollMode aMode,
|
2012-07-30 18:20:58 +04:00
|
|
|
nsIntPoint* aOverflow = nullptr, nsIAtom *aOrigin = nullptr) = 0;
|
2004-07-24 01:39:47 +04:00
|
|
|
/**
|
|
|
|
* 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...
|
2009-09-01 08:11:11 +04:00
|
|
|
* XXX should we take an aMode parameter here? Currently it's instant.
|
2004-07-24 01:39:47 +04:00
|
|
|
*/
|
|
|
|
virtual void ScrollToRestoredPosition() = 0;
|
2009-10-25 10:04:18 +03:00
|
|
|
|
2009-09-01 08:11:11 +04:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2012-08-06 07:00:57 +04:00
|
|
|
virtual nsIFrame* GetScrollbarBox(bool aVertical) = 0;
|
2009-09-01 08:11:11 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal method used by scrollbars to notify their scrolling
|
|
|
|
* container of changes.
|
|
|
|
*/
|
|
|
|
virtual void CurPosAttributeChanged(nsIContent* aChild) = 0;
|
|
|
|
|
2009-10-25 10:04:18 +03:00
|
|
|
/**
|
|
|
|
* Allows the docshell to request that the scroll frame post an event
|
|
|
|
* after being restored from history.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD PostScrolledAreaEventForCurrentArea() = 0;
|
2010-07-16 01:08:02 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if this scrollframe is being "actively scrolled".
|
|
|
|
* This basically means that we should allocate resources in the
|
|
|
|
* expectation that scrolling is going to happen.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
virtual bool IsScrollingActive() = 0;
|
2012-08-17 03:40:10 +04:00
|
|
|
/**
|
|
|
|
* Call this when the layer(s) induced by active scrolling are being
|
|
|
|
* completely redrawn.
|
|
|
|
*/
|
|
|
|
virtual void ResetScrollPositionForLayerPixelAlignment() = 0;
|
1999-12-07 06:36:05 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|