2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
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 "nsCoord.h"
|
2015-09-10 02:08:03 +03:00
|
|
|
#include "DisplayItemClip.h"
|
2015-05-26 22:39:29 +03:00
|
|
|
#include "mozilla/Maybe.h"
|
2018-08-01 09:14:26 +03:00
|
|
|
#include "mozilla/ScrollStyles.h"
|
2019-03-26 02:17:20 +03:00
|
|
|
#include "mozilla/ScrollTypes.h"
|
2012-11-23 05:25:23 +04:00
|
|
|
#include "mozilla/gfx/Point.h"
|
2014-02-05 05:33:18 +04:00
|
|
|
#include "nsIScrollbarMediator.h"
|
2013-05-31 05:30:13 +04:00
|
|
|
#include "Units.h"
|
2014-08-31 07:29:24 +04:00
|
|
|
#include "FrameMetrics.h"
|
1999-12-07 06:36:05 +03:00
|
|
|
|
2012-10-29 09:44:31 +04:00
|
|
|
#define NS_DEFAULT_VERTICAL_SCROLL_DISTANCE 3
|
|
|
|
#define NS_DEFAULT_HORIZONTAL_SCROLL_DISTANCE 5
|
2012-02-20 20:24:36 +04:00
|
|
|
|
2017-06-09 22:14:53 +03:00
|
|
|
class gfxContext;
|
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;
|
2013-08-24 00:20:07 +04:00
|
|
|
class nsPresContext;
|
|
|
|
class nsIContent;
|
2017-10-03 01:05:19 +03:00
|
|
|
class nsAtom;
|
2014-10-22 05:54:06 +04:00
|
|
|
class nsDisplayListBuilder;
|
1999-12-07 06:36:05 +03:00
|
|
|
|
2014-08-31 07:29:24 +04:00
|
|
|
namespace mozilla {
|
|
|
|
struct ContainerLayerParameters;
|
|
|
|
namespace layers {
|
2018-11-01 23:15:46 +03:00
|
|
|
struct ScrollMetadata;
|
2014-08-31 07:29:24 +04:00
|
|
|
class Layer;
|
2017-10-25 20:22:04 +03:00
|
|
|
class LayerManager;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace layers
|
2018-11-28 00:18:03 +03:00
|
|
|
namespace layout {
|
|
|
|
class ScrollAnchorContainer;
|
|
|
|
} // namespace layout
|
2015-06-21 19:27:31 +03:00
|
|
|
} // namespace mozilla
|
2014-08-31 07:29:24 +04: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.
|
|
|
|
*/
|
2014-02-14 10:40:53 +04:00
|
|
|
class nsIScrollableFrame : public nsIScrollbarMediator {
|
1999-12-07 06:36:05 +03:00
|
|
|
public:
|
2013-07-10 13:58:13 +04:00
|
|
|
typedef mozilla::CSSIntPoint CSSIntPoint;
|
2014-08-31 07:29:24 +04:00
|
|
|
typedef mozilla::ContainerLayerParameters ContainerLayerParameters;
|
2016-03-12 06:04:53 +03:00
|
|
|
typedef mozilla::layers::ScrollSnapInfo ScrollSnapInfo;
|
2018-11-28 00:18:03 +03:00
|
|
|
typedef mozilla::layout::ScrollAnchorContainer ScrollAnchorContainer;
|
2019-03-26 02:17:20 +03:00
|
|
|
typedef mozilla::ScrollMode ScrollMode;
|
2013-07-10 13:58:13 +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
|
|
|
|
2009-09-01 08:11:11 +04:00
|
|
|
/**
|
2018-12-11 03:50:32 +03:00
|
|
|
* Get the styles (StyleOverflow::Scroll, StyleOverflow::Hidden,
|
|
|
|
* or StyleOverflow::Auto) governing the horizontal and vertical
|
2009-09-01 08:11:11 +04:00
|
|
|
* scrollbars for this frame.
|
|
|
|
*/
|
2018-08-01 09:14:26 +03:00
|
|
|
virtual mozilla::ScrollStyles GetScrollStyles() const = 0;
|
2004-06-18 06:08:19 +04:00
|
|
|
|
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;
|
2012-09-24 08:30:33 +04:00
|
|
|
/**
|
2019-07-25 01:33:57 +03:00
|
|
|
* Returns the directions in which scrolling is allowed (if the scroll range
|
|
|
|
* is at least one device pixel in that direction).
|
2012-09-24 08:30:33 +04:00
|
|
|
*/
|
2019-07-25 01:33:57 +03:00
|
|
|
uint32_t GetAvailableScrollingDirections() const;
|
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
|
2005-10-18 09:00:24 +04:00
|
|
|
* visible. 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,
|
2017-06-09 22:14:53 +03:00
|
|
|
gfxContext* aRC) = 0;
|
2013-05-27 02:05:10 +04:00
|
|
|
/**
|
|
|
|
* Return the width for non-disappearing scrollbars.
|
|
|
|
*/
|
2015-07-27 18:52:12 +03:00
|
|
|
virtual nscoord GetNondisappearingScrollbarWidth(
|
|
|
|
nsPresContext* aPresContext, gfxContext* aRC,
|
|
|
|
mozilla::WritingMode aWM) = 0;
|
2019-02-14 02:47:32 +03:00
|
|
|
/**
|
|
|
|
* Get the layout size of this frame.
|
|
|
|
* Note that this is a value which is not expanded by the minimum scale size.
|
|
|
|
* For scroll frames other than the root content document's scroll frame, this
|
|
|
|
* value will be the same as GetScrollPortRect().Size().
|
|
|
|
*
|
|
|
|
* This value is used for Element.clientWidth and clientHeight.
|
|
|
|
*/
|
|
|
|
virtual nsSize GetLayoutSize() const = 0;
|
2013-07-23 17:22:58 +04:00
|
|
|
/**
|
|
|
|
* GetScrolledRect is designed to encapsulate deciding which
|
|
|
|
* directions of overflow should be reachable by scrolling and which
|
|
|
|
* should not. Callers should NOT depend on it having any particular
|
|
|
|
* behavior (although nsXULScrollFrame currently does).
|
|
|
|
*
|
|
|
|
* This should only be called when the scrolled frame has been
|
|
|
|
* reflowed with the scroll port size given in mScrollPort.
|
|
|
|
*
|
|
|
|
* Currently it allows scrolling down and to the right for
|
|
|
|
* nsHTMLScrollFrames with LTR directionality and for all
|
|
|
|
* nsXULScrollFrames, and allows scrolling down and to the left for
|
|
|
|
* nsHTMLScrollFrames with RTL directionality.
|
|
|
|
*/
|
|
|
|
virtual nsRect GetScrolledRect() const = 0;
|
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;
|
2012-12-12 01:12:43 +04:00
|
|
|
/**
|
2017-07-06 15:00:35 +03:00
|
|
|
* As GetScrollPosition(), but uses the top-right as origin for RTL frames.
|
2012-12-12 01:12:43 +04:00
|
|
|
*/
|
|
|
|
virtual nsPoint GetLogicalScrollPosition() const = 0;
|
Bug 1453425 - Add relative scroll offset updates using nsGkAtoms::relative. r=botond
This commit adds a scroll origin, nsGkAtoms::relative, which can be used to
mark main thread scrolling that can be combined with a concurrent APZ scroll.
The behavior of this is controlled by a pref, apz.relative-update. This pref
is initially activated and is intended as an aid to narrowing down causes
of regressions for users in bug reports.
Relative scroll updates work by tracking the last sent or accepted APZ
scroll offset. This is sent along with every FrameMetrics. Additionally,
a flag is added to FrameMetrics, mIsRelative, indicating whether the
scroll offset can be combined with a potential APZ scroll. When this
flag is set, AsyncPanZoomController will apply the delta between the sent
base scroll offset, and sent new scroll offset.
This flag is controlled by the last scroll origin on nsGfxScrollFrame. The
new origin, `relative`, is marked as being able to clobber APZ updates,
but can only be set if all scrolls since the last repaint request or
layers transaction have been relative.
Differential Revision: https://phabricator.services.mozilla.com/D8234
--HG--
extra : rebase_source : 51351a84c9cda228a0975e22eda3fd3bd8d261c4
extra : histedit_source : 4b564c19b16fe2bd26adc671b62b7cb6106e8163
2018-10-10 07:24:28 +03:00
|
|
|
/**
|
|
|
|
* Get the latest scroll position that the main thread has sent or received
|
|
|
|
* from APZ.
|
|
|
|
*/
|
|
|
|
virtual nsPoint GetApzScrollPosition() 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
|
|
|
/**
|
2018-07-22 22:49:38 +03:00
|
|
|
* Get the size of the view port to use when clamping the scroll
|
2012-06-11 03:44:50 +04:00
|
|
|
* position.
|
|
|
|
*/
|
2018-07-22 22:49:38 +03:00
|
|
|
virtual nsSize GetVisualViewportSize() const = 0;
|
2018-09-21 22:01:13 +03:00
|
|
|
/**
|
|
|
|
* Returns the offset of the visual viewport relative to
|
|
|
|
* the origin of the scrolled content. Note that only the RCD-RSF
|
|
|
|
* has a distinct visual viewport; for other scroll frames, the
|
|
|
|
* visual viewport always coincides with the layout viewport, and
|
|
|
|
* consequently the offset this function returns is equal to
|
|
|
|
* GetScrollPosition().
|
|
|
|
*/
|
|
|
|
virtual nsPoint GetVisualViewportOffset() 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
|
|
|
|
Bug 1534070 - Factor scroll-padding into the position calculation where nsIPresShell::ScrollContentIntoView() is going to scroll if necessary. r=botond
In the case where scroll-snap-type is specified for the scroll container, the
scroll-padding is also factored into in ScrollFrameHelper::ComputeScrollSnapInfo
which is called via ScrollFrameHelper::ScrollToWithOrigin. It doesn't double
the scroll-padding value, but it's actually redundant, we should avoid it.
We could separate the functionality of ScrollToWithOrigin, one is to scroll
to a given element, the other is to scroll to a given position. The former will
be used for Element.scrollIntoElement and relevant stuff, the latter will be
used for Element.scrollTo and relevant stuff. That's being said, as of now, we
have still the old scroll snap implementation, so the separation will introduce
complexity, the separation should be done once after the old implementation
removed.
There are 9 call sites of nsIPresShell::ScrollContentIntoView:
nsIPresShell::GoToAnchor
nsIPresShell::ScrollToAnchor
Element::ScrollIntoView
We definitely needs scroll-padding and scroll-margin for these functions.
nsCoreUtils::ScrollTo
This is used for Accesible::ScrollTo which scrolls to a given accesible node,
probably we should behave as what Element::ScrollIntoView does.
Accessible::DispatchClickEvent
Similar to the above, similated various mouse events on a given target node.
PresShell::EventHandler::PrepareToUseCaretPosition
PresShell::EventHandler::GetCurrentItemAndPositionForElement
Both are for context menu, we shouldn't consider scroll-padding and
scroll-margin.
nsFormFillController::SetPopupOpen
This is used for autocompletion popup, we shouldn't consider scroll-padding
and scroll-margin.
nsFocusManager::ScrollIntoView
This is bit unfortunate, we should use scroll-padding and scroll-margin
depending on call site of this function. Bug 1535232 is for this case.
cssom-view/scrollIntoView-scrollPadding.html which has some tests that is
actually testing scroll-padding with scrollIntoView passes with this change.
The reftest in this change is a test case that the browser navigates to an
element with specifying the anchor to the element.
Differential Revision: https://phabricator.services.mozilla.com/D23084
--HG--
extra : moz-landing-system : lando
2019-04-11 09:22:14 +03:00
|
|
|
/**
|
|
|
|
* Return scroll-padding value of this frame.
|
|
|
|
*/
|
|
|
|
virtual nsMargin GetScrollPadding() const = 0;
|
2014-02-04 05:54:22 +04:00
|
|
|
/**
|
|
|
|
* Some platforms (OSX) may generate additional scrolling events even
|
|
|
|
* after the user has stopped scrolling, simulating a momentum scrolling
|
|
|
|
* effect resulting from fling gestures.
|
|
|
|
* SYNTHESIZED_MOMENTUM_EVENT indicates that the scrolling is being requested
|
|
|
|
* by such a synthesized event and may be ignored if another scroll has
|
|
|
|
* been started since the last actual user input.
|
|
|
|
*/
|
|
|
|
enum ScrollMomentum { NOT_MOMENTUM, SYNTHESIZED_MOMENTUM_EVENT };
|
2009-09-01 08:11:11 +04:00
|
|
|
/**
|
2013-08-09 02:04:59 +04:00
|
|
|
* @note This method might destroy the frame, pres shell and other objects.
|
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,
|
2015-02-20 02:53:30 +03:00
|
|
|
const nsRect* aRange = nullptr,
|
2015-03-25 21:40:31 +03:00
|
|
|
nsIScrollbarMediator::ScrollSnapMode aSnap =
|
|
|
|
nsIScrollbarMediator::DISABLE_SNAP) = 0;
|
2012-05-15 09:58:09 +04:00
|
|
|
/**
|
2013-08-09 02:04:59 +04:00
|
|
|
* @note This method might destroy the frame, pres shell and other objects.
|
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.
|
2014-07-09 21:02:31 +04:00
|
|
|
*
|
|
|
|
* When aMode is SMOOTH, INSTANT, or NORMAL, GetScrollPositionCSSPixels (the
|
|
|
|
* scroll position after rounding to CSS pixels) will be exactly
|
|
|
|
* aScrollPosition at the end of the scroll animation.
|
|
|
|
*
|
|
|
|
* When aMode is SMOOTH_MSD, intermediate animation frames may be outside the
|
|
|
|
* range and / or moving in any direction; GetScrollPositionCSSPixels will be
|
|
|
|
* exactly aScrollPosition at the end of the scroll animation unless the
|
|
|
|
* SMOOTH_MSD animation is interrupted.
|
2019-04-11 09:20:04 +03:00
|
|
|
*
|
|
|
|
* FIXME: Drop |aSnap| argument once after we finished the migration to the
|
|
|
|
* Scroll Snap Module v1. We should alway use ENABLE_SNAP.
|
2012-05-15 09:58:09 +04:00
|
|
|
*/
|
2019-03-26 02:17:20 +03:00
|
|
|
virtual void ScrollToCSSPixels(const CSSIntPoint& aScrollPosition,
|
2019-04-26 02:03:04 +03:00
|
|
|
ScrollMode aMode = ScrollMode::Instant,
|
2019-04-11 09:20:04 +03:00
|
|
|
nsIScrollbarMediator::ScrollSnapMode aSnap =
|
|
|
|
nsIScrollbarMediator::DEFAULT,
|
2019-03-26 02:17:20 +03:00
|
|
|
nsAtom* aOrigin = nullptr) = 0;
|
2012-11-23 05:25:23 +04:00
|
|
|
/**
|
2013-08-09 02:04:59 +04:00
|
|
|
* @note This method might destroy the frame, pres shell and other objects.
|
2012-11-23 05:25:23 +04:00
|
|
|
* Scrolls to a particular position in float CSS pixels.
|
|
|
|
* This does not guarantee that GetScrollPositionCSSPixels equals
|
|
|
|
* aScrollPosition afterward. It tries to scroll as close to
|
|
|
|
* aScrollPosition as possible while scrolling by an integer
|
|
|
|
* number of layer pixels (so the operation is fast and looks clean).
|
|
|
|
*/
|
2013-12-16 21:04:45 +04:00
|
|
|
virtual void ScrollToCSSPixelsApproximate(
|
|
|
|
const mozilla::CSSPoint& aScrollPosition, nsAtom* aOrigin = nullptr) = 0;
|
2013-05-31 05:30:13 +04:00
|
|
|
|
2012-08-10 15:17:06 +04:00
|
|
|
/**
|
|
|
|
* Returns the scroll position in integer CSS pixels, rounded to the nearest
|
|
|
|
* pixel.
|
|
|
|
*/
|
2013-07-10 13:58:13 +04:00
|
|
|
virtual CSSIntPoint 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 };
|
|
|
|
/**
|
2013-08-09 02:04:59 +04:00
|
|
|
* @note This method might destroy the frame, pres shell and other objects.
|
2009-09-01 08:11:11 +04:00
|
|
|
* 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,
|
2014-07-15 18:13:00 +04:00
|
|
|
nsIntPoint* aOverflow = nullptr,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* aOrigin = nullptr,
|
2015-02-20 02:53:30 +03:00
|
|
|
ScrollMomentum aMomentum = NOT_MOMENTUM,
|
2015-03-25 21:40:31 +03:00
|
|
|
nsIScrollbarMediator::ScrollSnapMode aSnap =
|
|
|
|
nsIScrollbarMediator::DISABLE_SNAP) = 0;
|
2015-02-20 02:53:30 +03:00
|
|
|
|
2019-04-11 09:20:04 +03:00
|
|
|
/**
|
|
|
|
* FIXME: Drop |aSnap| argument once after we finished the migration to the
|
|
|
|
* Scroll Snap Module v1. We should alway use ENABLE_SNAP.
|
|
|
|
*/
|
2019-03-26 02:17:20 +03:00
|
|
|
virtual void ScrollByCSSPixels(const CSSIntPoint& aDelta,
|
2019-04-26 02:03:04 +03:00
|
|
|
ScrollMode aMode = ScrollMode::Instant,
|
2019-04-11 09:20:04 +03:00
|
|
|
nsAtom* aOrigin = nullptr,
|
|
|
|
nsIScrollbarMediator::ScrollSnapMode aSnap =
|
|
|
|
nsIScrollbarMediator::DEFAULT) = 0;
|
2018-10-06 03:06:40 +03:00
|
|
|
|
2015-02-20 02:53:30 +03:00
|
|
|
/**
|
|
|
|
* Perform scroll snapping, possibly resulting in a smooth scroll to
|
|
|
|
* maintain the scroll snap position constraints. Velocity sampled from
|
|
|
|
* main thread scrolling is used to determine best matching snap point
|
|
|
|
* when called after a fling gesture on a trackpad or mouse wheel.
|
|
|
|
*/
|
|
|
|
virtual void ScrollSnap() = 0;
|
|
|
|
|
2004-07-24 01:39:47 +04:00
|
|
|
/**
|
2013-08-09 02:04:59 +04:00
|
|
|
* @note This method might destroy the frame, pres shell and other objects.
|
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;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2014-10-22 05:54:06 +04:00
|
|
|
virtual bool IsScrollingActive(nsDisplayListBuilder* aBuilder) = 0;
|
2017-09-27 02:24:42 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if this scroll frame might be scrolled
|
|
|
|
* asynchronously by the compositor.
|
|
|
|
*/
|
2018-01-29 15:24:04 +03:00
|
|
|
virtual bool IsMaybeAsynchronouslyScrolled() = 0;
|
2017-09-27 02:24:42 +03:00
|
|
|
|
2017-05-20 01:04:19 +03:00
|
|
|
/**
|
|
|
|
* Same as the above except doesn't take into account will-change budget,
|
|
|
|
* which means that it can be called during display list building.
|
|
|
|
*/
|
|
|
|
virtual bool IsMaybeScrollingActive() const = 0;
|
2014-01-29 02:54:59 +04:00
|
|
|
/**
|
|
|
|
* Returns true if the scrollframe is currently processing an async
|
|
|
|
* or smooth scroll.
|
|
|
|
*/
|
|
|
|
virtual bool IsProcessingAsyncScroll() = 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;
|
2013-03-05 16:26:41 +04:00
|
|
|
/**
|
|
|
|
* Was the current presentation state for this frame restored from history?
|
|
|
|
*/
|
2014-05-06 01:29:20 +04:00
|
|
|
virtual bool DidHistoryRestore() const = 0;
|
2013-03-16 02:32:35 +04:00
|
|
|
/**
|
|
|
|
* Clear the flag so that DidHistoryRestore() returns false until the next
|
|
|
|
* RestoreState call.
|
|
|
|
* @see nsIStatefulFrame::RestoreState
|
|
|
|
*/
|
|
|
|
virtual void ClearDidHistoryRestore() = 0;
|
2019-01-11 22:50:24 +03:00
|
|
|
/**
|
|
|
|
* Mark the frame as having been scrolled at least once, so that it remains
|
|
|
|
* active and we can also start storing its scroll position when saving state.
|
|
|
|
*/
|
|
|
|
virtual void MarkEverScrolled() = 0;
|
2013-09-15 04:05:04 +04:00
|
|
|
/**
|
2016-03-26 00:49:43 +03:00
|
|
|
* Determine if the passed in rect is nearly visible according to the frame
|
2013-09-15 04:05:04 +04:00
|
|
|
* visibility heuristics for how close it is to the visible scrollport.
|
|
|
|
*/
|
|
|
|
virtual bool IsRectNearlyVisible(const nsRect& aRect) = 0;
|
2014-06-07 06:23:20 +04:00
|
|
|
/**
|
|
|
|
* Expand the given rect taking into account which directions we can scroll
|
2016-03-26 00:49:43 +03:00
|
|
|
* and how far we want to expand for frame visibility purposes.
|
2014-06-07 06:23:20 +04:00
|
|
|
*/
|
2014-06-07 06:23:22 +04:00
|
|
|
virtual nsRect ExpandRectToNearlyVisible(const nsRect& aRect) const = 0;
|
2013-12-16 21:04:45 +04:00
|
|
|
/**
|
2014-07-10 22:52:40 +04:00
|
|
|
* Returns the origin that triggered the last instant scroll. Will equal
|
|
|
|
* nsGkAtoms::apz when the compositor's replica frame metrics includes the
|
|
|
|
* latest instant scroll.
|
|
|
|
*/
|
2017-10-03 01:05:19 +03:00
|
|
|
virtual nsAtom* LastScrollOrigin() = 0;
|
2014-07-10 22:52:40 +04:00
|
|
|
/**
|
|
|
|
* Returns the origin that triggered the last smooth scroll.
|
|
|
|
* Will equal nsGkAtoms::apz when the compositor's replica frame
|
|
|
|
* metrics includes the latest smooth scroll. The compositor will always
|
|
|
|
* perform an instant scroll prior to instantiating any smooth scrolls
|
|
|
|
* if LastScrollOrigin and LastSmoothScrollOrigin indicate that
|
|
|
|
* an instant scroll and a smooth scroll have occurred since the last
|
|
|
|
* replication of the frame metrics.
|
|
|
|
*
|
|
|
|
* This is set to nullptr to when the compositor thread acknowledges that
|
|
|
|
* the smooth scroll has been started. If the smooth scroll has been stomped
|
|
|
|
* by an instant scroll before the smooth scroll could be started by the
|
|
|
|
* compositor, this is set to nullptr to clear the smooth scroll.
|
2013-12-16 21:04:45 +04:00
|
|
|
*/
|
2017-10-03 01:05:19 +03:00
|
|
|
virtual nsAtom* LastSmoothScrollOrigin() = 0;
|
2013-12-16 21:04:45 +04:00
|
|
|
/**
|
2014-02-06 02:43:20 +04:00
|
|
|
* Returns the current generation counter for the scroll. This counter
|
|
|
|
* increments every time the scroll position is set.
|
2013-12-16 21:04:45 +04:00
|
|
|
*/
|
2014-02-06 02:43:20 +04:00
|
|
|
virtual uint32_t CurrentScrollGeneration() = 0;
|
2014-07-10 22:52:40 +04:00
|
|
|
/**
|
|
|
|
* LastScrollDestination returns the destination of the most recently
|
|
|
|
* requested smooth scroll animation.
|
|
|
|
*/
|
|
|
|
virtual nsPoint LastScrollDestination() = 0;
|
2014-02-06 02:43:20 +04:00
|
|
|
/**
|
|
|
|
* Clears the "origin of last scroll" property stored in this frame, if
|
|
|
|
* the generation counter passed in matches the current scroll generation
|
|
|
|
* counter.
|
|
|
|
*/
|
2014-07-10 22:52:40 +04:00
|
|
|
virtual void ResetScrollInfoIfGeneration(uint32_t aGeneration) = 0;
|
2014-03-13 00:20:26 +04:00
|
|
|
/**
|
|
|
|
* Determine whether it is desirable to be able to asynchronously scroll this
|
|
|
|
* scroll frame.
|
|
|
|
*/
|
|
|
|
virtual bool WantAsyncScroll() const = 0;
|
2014-08-31 07:29:24 +04:00
|
|
|
/**
|
2018-04-19 16:48:04 +03:00
|
|
|
* Returns the ScrollMetadata contributed by this frame, if there is one.
|
2014-08-31 07:29:24 +04:00
|
|
|
*/
|
2016-03-29 02:14:52 +03:00
|
|
|
virtual mozilla::Maybe<mozilla::layers::ScrollMetadata> ComputeScrollMetadata(
|
2017-10-25 20:22:04 +03:00
|
|
|
mozilla::layers::LayerManager* aLayerManager,
|
2017-07-20 19:33:09 +03:00
|
|
|
const nsIFrame* aContainerReferenceFrame,
|
2018-10-19 17:24:50 +03:00
|
|
|
const mozilla::Maybe<ContainerLayerParameters>& aParameters,
|
2015-12-22 18:54:19 +03:00
|
|
|
const mozilla::DisplayItemClip* aClip) const = 0;
|
2018-04-19 16:48:04 +03:00
|
|
|
/**
|
|
|
|
* Ensure's aLayer is clipped to the display port.
|
|
|
|
*/
|
|
|
|
virtual void ClipLayerToDisplayPort(
|
|
|
|
mozilla::layers::Layer* aLayer, const mozilla::DisplayItemClip* aClip,
|
|
|
|
const ContainerLayerParameters& aParameters) const = 0;
|
2014-09-23 17:44:00 +04:00
|
|
|
|
2014-10-09 06:56:38 +04:00
|
|
|
/**
|
|
|
|
* Mark the scrollbar frames for reflow.
|
|
|
|
*/
|
|
|
|
virtual void MarkScrollbarsDirtyForReflow() const = 0;
|
2015-02-25 17:32:09 +03:00
|
|
|
|
|
|
|
virtual void SetTransformingByAPZ(bool aTransforming) = 0;
|
|
|
|
virtual bool IsTransformingByAPZ() const = 0;
|
2015-06-03 02:34:46 +03:00
|
|
|
|
2016-03-10 06:57:14 +03:00
|
|
|
/**
|
|
|
|
* Notify this scroll frame that it can be scrolled by APZ. In particular,
|
|
|
|
* this is called *after* the APZ code has created an APZC for this scroll
|
|
|
|
* frame and verified that it is not a scrollinfo layer. Therefore, setting an
|
|
|
|
* async transform on it is actually user visible.
|
|
|
|
*/
|
|
|
|
virtual void SetScrollableByAPZ(bool aScrollable) = 0;
|
|
|
|
|
2015-09-12 04:58:16 +03:00
|
|
|
/**
|
|
|
|
* Notify this scroll frame that it can be zoomed by APZ.
|
|
|
|
*/
|
|
|
|
virtual void SetZoomableByAPZ(bool aZoomable) = 0;
|
|
|
|
|
2017-11-28 00:45:29 +03:00
|
|
|
/**
|
|
|
|
* Mark this scroll frame as having out-of-flow content inside a CSS filter.
|
|
|
|
* Such content will move incorrectly during async-scrolling; to mitigate
|
|
|
|
* this, paint skipping is disabled for such scroll frames.
|
|
|
|
*/
|
|
|
|
virtual void SetHasOutOfFlowContentInsideFilter() = 0;
|
|
|
|
|
2015-10-12 23:21:49 +03:00
|
|
|
/**
|
|
|
|
* Determine if we should build a scrollable layer for this scroll frame and
|
|
|
|
* return the result. It will also record this result on the scroll frame.
|
2017-10-04 04:28:38 +03:00
|
|
|
* Pass the visible rect in aVisibleRect. On return it will be set to the
|
|
|
|
* displayport if there is one.
|
2015-10-12 23:21:49 +03:00
|
|
|
* Pass the dirty rect in aDirtyRect. On return it will be set to the
|
2017-10-04 04:28:38 +03:00
|
|
|
* dirty rect inside the displayport (ie the dirty rect that should be used).
|
2017-10-03 00:00:16 +03:00
|
|
|
* This function will set the display port base rect if aSetBase is true.
|
|
|
|
* aSetBase is only allowed to be false if there has been a call with it
|
|
|
|
* set to true before on the same paint.
|
2015-10-12 23:21:49 +03:00
|
|
|
*/
|
|
|
|
virtual bool DecideScrollableLayer(nsDisplayListBuilder* aBuilder,
|
2017-10-04 04:28:38 +03:00
|
|
|
nsRect* aVisibleRect, nsRect* aDirtyRect,
|
2017-10-03 00:00:16 +03:00
|
|
|
bool aSetBase) = 0;
|
2016-01-22 04:09:04 +03:00
|
|
|
|
Bug 1453425 - Add relative scroll offset updates using nsGkAtoms::relative. r=botond
This commit adds a scroll origin, nsGkAtoms::relative, which can be used to
mark main thread scrolling that can be combined with a concurrent APZ scroll.
The behavior of this is controlled by a pref, apz.relative-update. This pref
is initially activated and is intended as an aid to narrowing down causes
of regressions for users in bug reports.
Relative scroll updates work by tracking the last sent or accepted APZ
scroll offset. This is sent along with every FrameMetrics. Additionally,
a flag is added to FrameMetrics, mIsRelative, indicating whether the
scroll offset can be combined with a potential APZ scroll. When this
flag is set, AsyncPanZoomController will apply the delta between the sent
base scroll offset, and sent new scroll offset.
This flag is controlled by the last scroll origin on nsGfxScrollFrame. The
new origin, `relative`, is marked as being able to clobber APZ updates,
but can only be set if all scrolls since the last repaint request or
layers transaction have been relative.
Differential Revision: https://phabricator.services.mozilla.com/D8234
--HG--
extra : rebase_source : 51351a84c9cda228a0975e22eda3fd3bd8d261c4
extra : histedit_source : 4b564c19b16fe2bd26adc671b62b7cb6106e8163
2018-10-10 07:24:28 +03:00
|
|
|
/**
|
|
|
|
* Notify the scrollframe that the current scroll offset and origin have been
|
|
|
|
* sent over in a layers transaction.
|
|
|
|
*
|
|
|
|
* This sets a flag on the scrollframe that indicates subsequent changes
|
|
|
|
* to the scroll position by "weaker" origins are permitted to overwrite the
|
|
|
|
* the scroll origin. Scroll origins that
|
|
|
|
* nsLayoutUtils::CanScrollOriginClobberApz returns false for are considered
|
|
|
|
* "weaker" than scroll origins for which that function returns true.
|
|
|
|
*
|
|
|
|
* This function must be called for a scrollframe after all calls to
|
|
|
|
* ComputeScrollMetadata in a layers transaction have been completed.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
virtual void NotifyApzTransaction() = 0;
|
|
|
|
|
2016-01-22 04:09:04 +03:00
|
|
|
/**
|
2016-03-26 00:49:43 +03:00
|
|
|
* Notification that this scroll frame is getting its frame visibility
|
2017-04-05 08:18:11 +03:00
|
|
|
* updated. aIgnoreDisplayPort indicates that the display port was ignored
|
|
|
|
* (because there was no suitable base rect)
|
2016-01-22 04:09:04 +03:00
|
|
|
*/
|
2017-04-05 08:18:11 +03:00
|
|
|
virtual void NotifyApproximateFrameVisibilityUpdate(
|
|
|
|
bool aIgnoreDisplayPort) = 0;
|
2016-01-22 09:29:17 +03:00
|
|
|
|
|
|
|
/**
|
2016-03-26 00:49:43 +03:00
|
|
|
* Returns true if this scroll frame had a display port at the last frame
|
2016-01-22 09:29:17 +03:00
|
|
|
* visibility update and fills in aDisplayPort with that displayport. Returns
|
|
|
|
* false otherwise, and doesn't touch aDisplayPort.
|
|
|
|
*/
|
2016-03-26 00:49:43 +03:00
|
|
|
virtual bool GetDisplayPortAtLastApproximateFrameVisibilityUpdate(
|
|
|
|
nsRect* aDisplayPort) = 0;
|
2016-02-04 03:13:35 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This is called when a descendant scrollframe's has its displayport expired.
|
|
|
|
* This function will check to see if this scrollframe may safely expire its
|
|
|
|
* own displayport and schedule a timer to do that if it is safe.
|
|
|
|
*/
|
|
|
|
virtual void TriggerDisplayPortExpiration() = 0;
|
2016-03-12 06:04:53 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns information required to determine where to snap to after a scroll.
|
|
|
|
*/
|
|
|
|
virtual ScrollSnapInfo GetScrollSnapInfo() const = 0;
|
2016-07-13 23:05:53 +03:00
|
|
|
|
2016-12-20 21:39:30 +03:00
|
|
|
/**
|
|
|
|
* Given the drag event aEvent, determine whether the mouse is near the edge
|
|
|
|
* of the scrollable area, and scroll the view in the direction of that edge
|
|
|
|
* if so. If scrolling occurred, true is returned. When false is returned, the
|
|
|
|
* caller should look for an ancestor to scroll.
|
|
|
|
*/
|
|
|
|
virtual bool DragScroll(mozilla::WidgetEvent* aEvent) = 0;
|
2017-01-28 02:02:22 +03:00
|
|
|
|
2018-11-22 21:00:49 +03:00
|
|
|
virtual void AsyncScrollbarDragInitiated(
|
|
|
|
uint64_t aDragBlockId, mozilla::layers::ScrollDirection aDirection) = 0;
|
2017-01-28 02:02:22 +03:00
|
|
|
virtual void AsyncScrollbarDragRejected() = 0;
|
2017-03-11 10:00:46 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether this scroll frame is the root scroll frame of the document
|
|
|
|
* that it is in. Note that some documents don't have root scroll frames at
|
|
|
|
* all (ie XUL documents) even though they may contain other scroll frames.
|
|
|
|
*/
|
|
|
|
virtual bool IsRootScrollFrameOfDocument() const = 0;
|
2018-11-28 00:18:03 +03:00
|
|
|
|
|
|
|
/**
|
2019-02-15 04:25:55 +03:00
|
|
|
* Returns the scroll anchor associated with this scrollable frame. This is
|
|
|
|
* never null.
|
2018-11-28 00:18:03 +03:00
|
|
|
*/
|
2019-02-15 04:25:55 +03:00
|
|
|
virtual const ScrollAnchorContainer* Anchor() const = 0;
|
|
|
|
virtual ScrollAnchorContainer* Anchor() = 0;
|
2019-03-23 23:23:35 +03:00
|
|
|
|
|
|
|
virtual bool SmoothScrollVisual(
|
|
|
|
const nsPoint& aVisualViewportOffset,
|
|
|
|
mozilla::layers::FrameMetrics::ScrollOffsetUpdateType aUpdateType) = 0;
|
2019-06-26 23:59:01 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if this scroll frame should perform smooth scroll with the
|
|
|
|
* given |aBehavior|.
|
|
|
|
*/
|
|
|
|
virtual bool IsSmoothScroll(mozilla::dom::ScrollBehavior aBehavior =
|
|
|
|
mozilla::dom::ScrollBehavior::Auto) const = 0;
|
1999-12-07 06:36:05 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|