2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 18:30:37 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-12-07 06:36:05 +03:00
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1999-12-07 06:36:05 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1999-12-07 06:36:05 +03:00
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-29 00:14:13 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-12-07 06:36:05 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 18:30:37 +04:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-29 00:14:13 +04:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 18:30:37 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 18:30:37 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
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"
|
2005-06-17 06:48:29 +04:00
|
|
|
#include "nsIFrame.h" // to get nsIBox, which is a typedef
|
1999-12-07 06:36:05 +03:00
|
|
|
|
2004-01-09 22:21:20 +03:00
|
|
|
class nsBoxLayoutState;
|
2009-09-01 08:11:11 +04:00
|
|
|
class nsIScrollPositionListener;
|
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.
|
|
|
|
*/
|
|
|
|
virtual PRUint32 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;
|
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.
|
|
|
|
*/
|
|
|
|
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
|
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,
|
|
|
|
nsIntPoint* aOverflow = nsnull) = 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.
|
|
|
|
*/
|
|
|
|
virtual nsIBox* GetScrollbarBox(PRBool aVertical) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
virtual PRBool IsScrollingActive() = 0;
|
1999-12-07 06:36:05 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|