Bug 575870 - Enable the firefox button on xp themed, classic, and aero basic. r=dao...
[mozilla-central.git] / layout / generic / nsIScrollableFrame.h
blobfdbf6c6be9e6c7f884276ae1ab3baa95503efdc6
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
39 * interface that provides scroll APIs implemented by scrollable frames
42 #ifndef nsIScrollFrame_h___
43 #define nsIScrollFrame_h___
45 #include "nsISupports.h"
46 #include "nsCoord.h"
47 #include "nsPresContext.h"
48 #include "nsIFrame.h" // to get nsIBox, which is a typedef
50 class nsBoxLayoutState;
51 class nsIScrollPositionListener;
53 /**
54 * Interface for frames that are scrollable. This interface exposes
55 * APIs for examining scroll state, observing changes to scroll state,
56 * and triggering scrolling.
58 class nsIScrollableFrame : public nsQueryFrame {
59 public:
61 NS_DECL_QUERYFRAME_TARGET(nsIScrollableFrame)
63 /**
64 * Get the frame for the content that we are scrolling within
65 * this scrollable frame.
67 virtual nsIFrame* GetScrolledFrame() const = 0;
69 typedef nsPresContext::ScrollbarStyles ScrollbarStyles;
70 /**
71 * Get the styles (NS_STYLE_OVERFLOW_SCROLL, NS_STYLE_OVERFLOW_HIDDEN,
72 * or NS_STYLE_OVERFLOW_AUTO) governing the horizontal and vertical
73 * scrollbars for this frame.
75 virtual ScrollbarStyles GetScrollbarStyles() const = 0;
77 enum { HORIZONTAL = 0x01, VERTICAL = 0x02 };
78 /**
79 * Return the scrollbars which are visible. It's OK to call this during reflow
80 * of the scrolled contents, in which case it will reflect the current
81 * assumptions about scrollbar visibility.
83 virtual PRUint32 GetScrollbarVisibility() const = 0;
84 /**
85 * Return the actual sizes of all possible scrollbars. Returns 0 for scrollbar
86 * positions that don't have a scrollbar or where the scrollbar is not visible.
87 * Do not call this while this frame's descendants are being reflowed, it won't be
88 * accurate.
90 virtual nsMargin GetActualScrollbarSizes() const = 0;
91 /**
92 * Return the sizes of all scrollbars assuming that any scrollbars that could
93 * be visible due to overflowing content, are. This can be called during reflow
94 * of the scrolled contents.
96 virtual nsMargin GetDesiredScrollbarSizes(nsBoxLayoutState* aState) = 0;
97 /**
98 * Return the sizes of all scrollbars assuming that any scrollbars that could
99 * be visible due to overflowing content, are. This can be called during reflow
100 * of the scrolled contents.
102 virtual nsMargin GetDesiredScrollbarSizes(nsPresContext* aPresContext,
103 nsIRenderingContext* aRC) = 0;
106 * Get the area of the scrollport relative to the origin of this frame's
107 * border-box.
108 * This is the area of this frame minus border and scrollbars.
110 virtual nsRect GetScrollPortRect() const = 0;
112 * Get the offset of the scrollport origin relative to the scrolled
113 * frame origin. Typically the position will be non-negative.
114 * This will always be a multiple of device pixels.
116 virtual nsPoint GetScrollPosition() const = 0;
118 * Get the area that must contain the scroll position. Typically
119 * (but not always, e.g. for RTL content) x and y will be 0, and
120 * width or height will be nonzero if the content can be scrolled in
121 * that direction. Since scroll positions must be a multiple of
122 * device pixels, the range extrema will also be a multiple of
123 * device pixels.
125 virtual nsRect GetScrollRange() const = 0;
128 * Return how much we would try to scroll by in each direction if
129 * asked to scroll by one "line" vertically and horizontally.
131 virtual nsSize GetLineScrollAmount() const = 0;
133 * Return how much we would try to scroll by in each direction if
134 * asked to scroll by one "page" vertically and horizontally.
136 virtual nsSize GetPageScrollAmount() const = 0;
139 * When a scroll operation is requested, we ask for either instant
140 * scrolling or smooth scrolling. SMOOTH will only be smooth if
141 * smooth scrolling is actually enabled. If an INSTANT request
142 * happens while a smooth scroll is already in progress, the smooth
143 * scroll is interrupted and we instantly scroll to the destination.
145 enum ScrollMode { INSTANT, SMOOTH };
147 * Clamps aScrollPosition to GetScrollRange and sets the scroll position
148 * to that value.
150 virtual void ScrollTo(nsPoint aScrollPosition, ScrollMode aMode) = 0;
152 * When scrolling by a relative amount, we can choose various units.
154 enum ScrollUnit { DEVICE_PIXELS, LINES, PAGES, WHOLE };
156 * Modifies the current scroll position by aDelta units given by aUnit,
157 * clamping it to GetScrollRange. If WHOLE is specified as the unit,
158 * content is scrolled all the way in the direction(s) given by aDelta.
159 * @param aOverflow if non-null, returns the amount that scrolling
160 * was clamped by in each direction (how far we moved the scroll position
161 * to bring it back into the legal range). This is never negative. The
162 * values are in device pixels.
164 virtual void ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit, ScrollMode aMode,
165 nsIntPoint* aOverflow = nsnull) = 0;
167 * This tells the scroll frame to try scrolling to the scroll
168 * position that was restored from the history. This must be called
169 * at least once after state has been restored. It is called by the
170 * scrolled frame itself during reflow, but sometimes state can be
171 * restored after reflows are done...
172 * XXX should we take an aMode parameter here? Currently it's instant.
174 virtual void ScrollToRestoredPosition() = 0;
177 * Add a scroll position listener. This listener must be removed
178 * before it is destroyed.
180 virtual void AddScrollPositionListener(nsIScrollPositionListener* aListener) = 0;
182 * Remove a scroll position listener.
184 virtual void RemoveScrollPositionListener(nsIScrollPositionListener* aListener) = 0;
187 * Obtain the XUL box for the horizontal or vertical scrollbar, or null
188 * if there is no such box. Avoid using this, but may be useful for
189 * setting up a scrollbar mediator if you want to redirect scrollbar
190 * input.
192 virtual nsIBox* GetScrollbarBox(PRBool aVertical) = 0;
195 * Internal method used by scrollbars to notify their scrolling
196 * container of changes.
198 virtual void CurPosAttributeChanged(nsIContent* aChild) = 0;
201 * Allows the docshell to request that the scroll frame post an event
202 * after being restored from history.
204 NS_IMETHOD PostScrolledAreaEventForCurrentArea() = 0;
207 * Returns true if this scrollframe is being "actively scrolled".
208 * This basically means that we should allocate resources in the
209 * expectation that scrolling is going to happen.
211 virtual PRBool IsScrollingActive() = 0;
214 #endif