2017-10-28 02:10:06 +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: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2012-07-31 04:42:26 +04:00
|
|
|
* 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/. */
|
|
|
|
|
|
|
|
#ifndef GFX_FRAMEMETRICS_H
|
|
|
|
#define GFX_FRAMEMETRICS_H
|
|
|
|
|
2018-02-22 21:40:44 +03:00
|
|
|
#include <stdint.h> // for uint8_t, uint32_t, uint64_t
|
2018-05-12 04:18:22 +03:00
|
|
|
#include <map>
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "Units.h" // for CSSRect, CSSPixel, etc
|
2017-07-01 04:18:55 +03:00
|
|
|
#include "mozilla/DefineEnum.h" // for MOZ_DEFINE_ENUM
|
2016-03-19 04:38:57 +03:00
|
|
|
#include "mozilla/HashFunctions.h" // for HashGeneric
|
2015-05-26 22:40:24 +03:00
|
|
|
#include "mozilla/Maybe.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/gfx/BasePoint.h" // for BasePoint
|
|
|
|
#include "mozilla/gfx/Rect.h" // for RoundedIn
|
|
|
|
#include "mozilla/gfx/ScaleFactor.h" // for ScaleFactor
|
2014-01-23 03:44:59 +04:00
|
|
|
#include "mozilla/gfx/Logging.h" // for Log
|
2018-02-22 21:40:44 +03:00
|
|
|
#include "mozilla/layers/LayersTypes.h" // for ScrollDirection
|
2018-11-01 23:15:46 +03:00
|
|
|
#include "mozilla/layers/ScrollableLayerGuid.h" // for ScrollableLayerGuid
|
2016-03-31 00:04:10 +03:00
|
|
|
#include "mozilla/StaticPtr.h" // for StaticAutoPtr
|
2016-01-16 00:19:59 +03:00
|
|
|
#include "mozilla/TimeStamp.h" // for TimeStamp
|
2014-08-29 16:23:25 +04:00
|
|
|
#include "nsString.h"
|
2019-06-28 12:46:26 +03:00
|
|
|
#include "mozilla/ServoStyleConsts.h"
|
2018-03-09 22:52:02 +03:00
|
|
|
#include "PLDHashTable.h" // for PLDHashNumber
|
2012-07-31 04:42:26 +04:00
|
|
|
|
2019-04-23 04:16:02 +03:00
|
|
|
struct nsStyleDisplay;
|
|
|
|
namespace mozilla {
|
|
|
|
class WritingMode;
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2014-01-21 21:33:52 +04:00
|
|
|
namespace IPC {
|
|
|
|
template <typename T>
|
|
|
|
struct ParamTraits;
|
|
|
|
} // namespace IPC
|
|
|
|
|
2012-07-31 04:42:26 +04:00
|
|
|
namespace mozilla {
|
2014-03-11 01:56:59 +04:00
|
|
|
namespace layers {
|
|
|
|
|
2016-04-13 17:21:13 +03:00
|
|
|
/**
|
|
|
|
* Helper struct to hold a couple of fields that can be updated as part of
|
|
|
|
* an empty transaction.
|
|
|
|
*/
|
|
|
|
struct ScrollUpdateInfo {
|
|
|
|
uint32_t mScrollGeneration;
|
|
|
|
CSSPoint mScrollOffset;
|
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
|
|
|
CSSPoint mBaseScrollOffset;
|
|
|
|
bool mIsRelative;
|
2016-04-13 17:21:13 +03:00
|
|
|
};
|
|
|
|
|
2012-07-31 04:42:26 +04:00
|
|
|
/**
|
2019-01-09 18:27:53 +03:00
|
|
|
* Metrics about a scroll frame that are sent to the compositor and used
|
|
|
|
* by APZ.
|
|
|
|
*
|
|
|
|
* This is used for two main purposes:
|
|
|
|
*
|
|
|
|
* (1) Sending information about a scroll frame to the compositor and APZ
|
|
|
|
* as part of a layers or WebRender transaction.
|
|
|
|
* (2) Storing information about a scroll frame in APZ that persists
|
|
|
|
* between transactions.
|
|
|
|
*
|
|
|
|
* TODO: Separate these two uses into two distinct structures.
|
|
|
|
*
|
|
|
|
* A related class, RepaintRequest, is used for sending information about a
|
|
|
|
* scroll frame back from the compositor to the main thread when requesting
|
|
|
|
* a repaint of the scroll frame's contents.
|
2012-07-31 04:42:26 +04:00
|
|
|
*/
|
2013-05-30 01:59:24 +04:00
|
|
|
struct FrameMetrics {
|
2014-01-21 21:33:52 +04:00
|
|
|
friend struct IPC::ParamTraits<mozilla::layers::FrameMetrics>;
|
2012-07-31 04:42:26 +04:00
|
|
|
|
2018-11-01 23:15:46 +03:00
|
|
|
typedef ScrollableLayerGuid::ViewID ViewID;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-11-01 23:15:46 +03:00
|
|
|
public:
|
2018-11-28 12:14:19 +03:00
|
|
|
// clang-format off
|
2017-07-01 04:18:55 +03:00
|
|
|
MOZ_DEFINE_ENUM_WITH_BASE_AT_CLASS_SCOPE(
|
|
|
|
ScrollOffsetUpdateType, uint8_t, (
|
|
|
|
eNone, // The default; the scroll offset was not updated
|
|
|
|
eMainThread, // The scroll offset was updated by the main thread.
|
2018-11-28 12:14:19 +03:00
|
|
|
ePending, // The scroll offset was updated on the main thread, but
|
|
|
|
// not painted, so the layer texture data is still at the
|
|
|
|
// old offset.
|
|
|
|
eRestore // The scroll offset was updated by the main thread, but
|
|
|
|
// as a restore from history or after a frame
|
|
|
|
// reconstruction. In this case, APZ can ignore the
|
|
|
|
// offset change if the user has done an APZ scroll
|
|
|
|
// already.
|
2017-07-01 04:18:55 +03:00
|
|
|
));
|
2018-11-28 12:14:19 +03:00
|
|
|
// clang-format on
|
2016-04-13 17:21:13 +03:00
|
|
|
|
2012-07-31 04:42:26 +04:00
|
|
|
FrameMetrics()
|
2018-11-01 23:15:46 +03:00
|
|
|
: mScrollId(ScrollableLayerGuid::NULL_SCROLL_ID),
|
2016-01-07 04:50:01 +03:00
|
|
|
mPresShellResolution(1),
|
2015-05-07 21:44:03 +03:00
|
|
|
mCompositionBounds(0, 0, 0, 0),
|
2014-12-23 18:35:58 +03:00
|
|
|
mDisplayPort(0, 0, 0, 0),
|
2014-12-30 22:07:57 +03:00
|
|
|
mCriticalDisplayPort(0, 0, 0, 0),
|
2014-12-27 20:48:27 +03:00
|
|
|
mScrollableRect(0, 0, 0, 0),
|
2015-03-06 21:54:10 +03:00
|
|
|
mCumulativeResolution(),
|
2012-09-29 06:16:34 +04:00
|
|
|
mDevPixelsPerCSSPixel(1),
|
2014-03-13 10:34:34 +04:00
|
|
|
mScrollOffset(0, 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
|
|
|
mBaseScrollOffset(0, 0),
|
2015-03-06 21:54:10 +03:00
|
|
|
mZoom(),
|
2014-02-06 02:43:20 +04:00
|
|
|
mScrollGeneration(0),
|
2014-07-10 22:52:40 +04:00
|
|
|
mSmoothScrollOffset(0, 0),
|
2014-03-27 03:24:25 +04:00
|
|
|
mRootCompositionSize(0, 0),
|
2014-03-27 05:46:24 +04:00
|
|
|
mDisplayPortMargins(0, 0, 0, 0),
|
2014-05-17 03:00:50 +04:00
|
|
|
mPresShellId(-1),
|
2019-01-09 18:34:34 +03:00
|
|
|
mLayoutViewport(0, 0, 0, 0),
|
2015-03-06 21:54:10 +03:00
|
|
|
mExtraResolution(),
|
2016-01-16 00:19:59 +03:00
|
|
|
mPaintRequestTime(),
|
2016-04-13 17:21:13 +03:00
|
|
|
mScrollUpdateType(eNone),
|
2019-01-10 23:59:13 +03:00
|
|
|
mVisualViewportOffset(0, 0),
|
|
|
|
mVisualScrollUpdateType(eNone),
|
2016-01-07 04:50:01 +03:00
|
|
|
mIsRootContent(false),
|
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
|
|
|
mIsRelative(false),
|
2016-01-07 04:50:01 +03:00
|
|
|
mDoSmoothScroll(false),
|
2015-12-21 17:36:36 +03:00
|
|
|
mIsScrollInfoLayer(false) {}
|
2012-07-31 04:42:26 +04:00
|
|
|
|
|
|
|
// Default copy ctor and operator= are fine
|
|
|
|
|
|
|
|
bool operator==(const FrameMetrics& aOther) const {
|
2016-01-07 04:50:01 +03:00
|
|
|
// Put mScrollId at the top since it's the most likely one to fail.
|
|
|
|
return mScrollId == aOther.mScrollId &&
|
|
|
|
mPresShellResolution == aOther.mPresShellResolution &&
|
|
|
|
mCompositionBounds.IsEqualEdges(aOther.mCompositionBounds) &&
|
2012-10-04 03:51:38 +04:00
|
|
|
mDisplayPort.IsEqualEdges(aOther.mDisplayPort) &&
|
2012-11-22 02:34:18 +04:00
|
|
|
mCriticalDisplayPort.IsEqualEdges(aOther.mCriticalDisplayPort) &&
|
2012-10-04 03:51:38 +04:00
|
|
|
mScrollableRect.IsEqualEdges(aOther.mScrollableRect) &&
|
2013-09-06 02:26:59 +04:00
|
|
|
mCumulativeResolution == aOther.mCumulativeResolution &&
|
2012-10-04 03:51:38 +04:00
|
|
|
mDevPixelsPerCSSPixel == aOther.mDevPixelsPerCSSPixel &&
|
2014-03-13 10:34:34 +04:00
|
|
|
mScrollOffset == aOther.mScrollOffset &&
|
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
|
|
|
mBaseScrollOffset == aOther.mBaseScrollOffset &&
|
2016-01-07 04:50:01 +03:00
|
|
|
// don't compare mZoom
|
2015-02-16 00:01:00 +03:00
|
|
|
mScrollGeneration == aOther.mScrollGeneration &&
|
2016-01-07 04:50:01 +03:00
|
|
|
mSmoothScrollOffset == aOther.mSmoothScrollOffset &&
|
|
|
|
mRootCompositionSize == aOther.mRootCompositionSize &&
|
|
|
|
mDisplayPortMargins == aOther.mDisplayPortMargins &&
|
|
|
|
mPresShellId == aOther.mPresShellId &&
|
2019-01-09 18:34:34 +03:00
|
|
|
mLayoutViewport.IsEqualEdges(aOther.mLayoutViewport) &&
|
2014-10-24 23:49:38 +04:00
|
|
|
mExtraResolution == aOther.mExtraResolution &&
|
2016-01-16 00:19:59 +03:00
|
|
|
mPaintRequestTime == aOther.mPaintRequestTime &&
|
2016-04-13 17:21:13 +03:00
|
|
|
mScrollUpdateType == aOther.mScrollUpdateType &&
|
2019-01-10 23:59:13 +03:00
|
|
|
mVisualViewportOffset == aOther.mVisualViewportOffset &&
|
|
|
|
mVisualScrollUpdateType == aOther.mVisualScrollUpdateType &&
|
2016-01-07 04:50:01 +03:00
|
|
|
mIsRootContent == aOther.mIsRootContent &&
|
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
|
|
|
mIsRelative == aOther.mIsRelative &&
|
2016-01-07 04:50:01 +03:00
|
|
|
mDoSmoothScroll == aOther.mDoSmoothScroll &&
|
2016-04-27 23:06:34 +03:00
|
|
|
mIsScrollInfoLayer == aOther.mIsScrollInfoLayer;
|
2012-07-31 04:42:26 +04:00
|
|
|
}
|
2016-01-07 04:50:01 +03:00
|
|
|
|
2012-07-31 04:42:26 +04:00
|
|
|
bool operator!=(const FrameMetrics& aOther) const {
|
|
|
|
return !operator==(aOther);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsScrollable() const {
|
2018-11-01 23:15:46 +03:00
|
|
|
return mScrollId != ScrollableLayerGuid::NULL_SCROLL_ID;
|
2012-07-31 04:42:26 +04:00
|
|
|
}
|
|
|
|
|
2015-03-06 21:54:10 +03:00
|
|
|
CSSToScreenScale2D DisplayportPixelsPerCSSPixel() const {
|
2014-11-10 22:35:11 +03:00
|
|
|
// Note: use 'mZoom * ParentLayerToLayerScale(1.0f)' as the CSS-to-Layer
|
2014-10-24 23:49:38 +04:00
|
|
|
// scale instead of LayersPixelsPerCSSPixel(), because displayport
|
|
|
|
// calculations are done in the context of a repaint request, where we ask
|
|
|
|
// Layout to repaint at a new resolution that includes any async zoom. Until
|
|
|
|
// this repaint request is processed, LayersPixelsPerCSSPixel() does not yet
|
|
|
|
// include the async zoom, but it will when the displayport is interpreted
|
|
|
|
// for the repaint.
|
2014-11-10 22:35:11 +03:00
|
|
|
return mZoom * ParentLayerToLayerScale(1.0f) / mExtraResolution;
|
2014-10-24 23:49:38 +04:00
|
|
|
}
|
|
|
|
|
2015-03-06 21:54:10 +03:00
|
|
|
CSSToLayerScale2D LayersPixelsPerCSSPixel() const {
|
|
|
|
return mDevPixelsPerCSSPixel * mCumulativeResolution;
|
2012-09-29 06:16:34 +04:00
|
|
|
}
|
|
|
|
|
2014-10-21 01:12:35 +04:00
|
|
|
// Get the amount by which this frame has been zoomed since the last repaint.
|
2014-11-10 22:35:11 +03:00
|
|
|
LayerToParentLayerScale GetAsyncZoom() const {
|
2015-03-06 21:54:10 +03:00
|
|
|
// The async portion of the zoom should be the same along the x and y
|
|
|
|
// axes.
|
|
|
|
return (mZoom / LayersPixelsPerCSSPixel()).ToScaleFactor();
|
2013-09-06 02:26:59 +04:00
|
|
|
}
|
|
|
|
|
2013-12-13 21:23:47 +04:00
|
|
|
// Ensure the scrollableRect is at least as big as the compositionBounds
|
|
|
|
// because the scrollableRect can be smaller if the content is not large
|
|
|
|
// and the scrollableRect hasn't been updated yet.
|
|
|
|
// We move the scrollableRect up because we don't know if we can move it
|
|
|
|
// down. i.e. we know that scrollableRect can go back as far as zero.
|
|
|
|
// but we don't know how much further ahead it can go.
|
|
|
|
CSSRect GetExpandedScrollableRect() const {
|
|
|
|
CSSRect scrollableRect = mScrollableRect;
|
2014-03-28 18:36:47 +04:00
|
|
|
CSSSize compSize = CalculateCompositedSizeInCssPixels();
|
2017-08-14 15:28:11 +03:00
|
|
|
if (scrollableRect.Width() < compSize.width) {
|
2017-12-19 23:48:39 +03:00
|
|
|
scrollableRect.SetRectX(
|
|
|
|
std::max(0.f, scrollableRect.X() -
|
|
|
|
(compSize.width - scrollableRect.Width())),
|
|
|
|
compSize.width);
|
2013-12-13 21:23:47 +04:00
|
|
|
}
|
|
|
|
|
2017-08-14 15:28:11 +03:00
|
|
|
if (scrollableRect.Height() < compSize.height) {
|
2017-12-19 23:48:39 +03:00
|
|
|
scrollableRect.SetRectY(
|
|
|
|
std::max(0.f, scrollableRect.Y() -
|
|
|
|
(compSize.height - scrollableRect.Height())),
|
|
|
|
compSize.height);
|
2013-12-13 21:23:47 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return scrollableRect;
|
|
|
|
}
|
|
|
|
|
2014-03-28 18:36:47 +04:00
|
|
|
CSSSize CalculateCompositedSizeInCssPixels() const {
|
2016-06-07 01:16:06 +03:00
|
|
|
if (GetZoom() == CSSToParentLayerScale2D(0, 0)) {
|
|
|
|
return CSSSize(); // avoid division by zero
|
|
|
|
}
|
2014-11-10 22:35:11 +03:00
|
|
|
return mCompositionBounds.Size() / GetZoom();
|
2014-03-28 18:36:47 +04:00
|
|
|
}
|
|
|
|
|
2018-06-09 23:33:26 +03:00
|
|
|
/*
|
|
|
|
* Calculate the composition bounds of this frame in the CSS pixels of
|
|
|
|
* the content surrounding the scroll frame. (This can be thought of as
|
|
|
|
* "parent CSS" pixels).
|
|
|
|
* Note that it does not make to ask for the composition bounds in the
|
|
|
|
* CSS pixels of the scrolled content (that is, regular CSS pixels),
|
|
|
|
* because the origin of the composition bounds is not meaningful in that
|
|
|
|
* coordinate space. (The size is, use CalculateCompositedSizeInCssPixels()
|
|
|
|
* for that.)
|
|
|
|
*/
|
|
|
|
CSSRect CalculateCompositionBoundsInCssPixelsOfSurroundingContent() const {
|
2016-06-07 01:16:06 +03:00
|
|
|
if (GetZoom() == CSSToParentLayerScale2D(0, 0)) {
|
|
|
|
return CSSRect(); // avoid division by zero
|
|
|
|
}
|
2018-06-09 23:33:26 +03:00
|
|
|
// The CSS pixels of the scrolled content and the CSS pixels of the
|
|
|
|
// surrounding content only differ if the scrolled content is rendered
|
|
|
|
// at a higher resolution, and the difference is the resolution.
|
|
|
|
return mCompositionBounds / GetZoom() * CSSToCSSScale{mPresShellResolution};
|
2013-06-26 17:54:49 +04:00
|
|
|
}
|
|
|
|
|
2014-05-06 22:29:44 +04:00
|
|
|
CSSSize CalculateBoundedCompositedSizeInCssPixels() const {
|
|
|
|
CSSSize size = CalculateCompositedSizeInCssPixels();
|
|
|
|
size.width = std::min(size.width, mRootCompositionSize.width);
|
|
|
|
size.height = std::min(size.height, mRootCompositionSize.height);
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2016-03-29 01:36:02 +03:00
|
|
|
CSSRect CalculateScrollRange() const {
|
|
|
|
CSSSize scrollPortSize = CalculateCompositedSizeInCssPixels();
|
|
|
|
CSSRect scrollRange = mScrollableRect;
|
2017-08-14 15:28:11 +03:00
|
|
|
scrollRange.SetWidth(
|
|
|
|
std::max(scrollRange.Width() - scrollPortSize.width, 0.0f));
|
|
|
|
scrollRange.SetHeight(
|
|
|
|
std::max(scrollRange.Height() - scrollPortSize.height, 0.0f));
|
2016-03-29 01:36:02 +03:00
|
|
|
return scrollRange;
|
|
|
|
}
|
|
|
|
|
2014-03-13 10:34:34 +04:00
|
|
|
void ScrollBy(const CSSPoint& aPoint) { mScrollOffset += aPoint; }
|
|
|
|
|
2015-03-06 21:54:10 +03:00
|
|
|
void ZoomBy(float aScale) { ZoomBy(gfxSize(aScale, aScale)); }
|
|
|
|
|
|
|
|
void ZoomBy(const gfxSize& aScale) {
|
|
|
|
mZoom.xScale *= aScale.width;
|
|
|
|
mZoom.yScale *= aScale.height;
|
2014-03-12 20:46:57 +04: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
|
|
|
/*
|
|
|
|
* Compares an APZ frame metrics with an incoming content frame metrics
|
|
|
|
* to see if APZ has a scroll offset that has not been incorporated into
|
|
|
|
* the content frame metrics.
|
|
|
|
*/
|
|
|
|
bool HasPendingScroll(const FrameMetrics& aContentFrameMetrics) const {
|
|
|
|
return mScrollOffset != aContentFrameMetrics.mBaseScrollOffset;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ApplyScrollUpdateFrom(const FrameMetrics& aOther) {
|
2014-03-28 16:21:19 +04:00
|
|
|
mScrollOffset = aOther.mScrollOffset;
|
|
|
|
mScrollGeneration = aOther.mScrollGeneration;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
void ApplySmoothScrollUpdateFrom(const FrameMetrics& aOther) {
|
2014-07-10 22:52:40 +04:00
|
|
|
mSmoothScrollOffset = aOther.mSmoothScrollOffset;
|
|
|
|
mScrollGeneration = aOther.mScrollGeneration;
|
|
|
|
mDoSmoothScroll = aOther.mDoSmoothScroll;
|
|
|
|
}
|
|
|
|
|
2018-10-26 01:21:29 +03:00
|
|
|
/**
|
|
|
|
* Applies the relative scroll offset update contained in aOther to the
|
|
|
|
* scroll offset contained in this. The scroll delta is clamped to the
|
|
|
|
* scrollable region.
|
|
|
|
*
|
|
|
|
* @returns The clamped scroll offset delta that was applied
|
|
|
|
*/
|
|
|
|
CSSPoint ApplyRelativeScrollUpdateFrom(const FrameMetrics& aOther) {
|
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
|
|
|
MOZ_ASSERT(aOther.IsRelative());
|
2018-10-26 01:21:29 +03:00
|
|
|
CSSPoint origin = mScrollOffset;
|
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
|
|
|
CSSPoint delta = (aOther.mScrollOffset - aOther.mBaseScrollOffset);
|
|
|
|
ClampAndSetScrollOffset(mScrollOffset + delta);
|
|
|
|
mScrollGeneration = aOther.mScrollGeneration;
|
2018-10-26 01:21:29 +03:00
|
|
|
return mScrollOffset - origin;
|
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
|
|
|
}
|
|
|
|
|
2018-10-26 01:21:29 +03:00
|
|
|
/**
|
|
|
|
* Applies the relative scroll offset update contained in aOther to the
|
|
|
|
* smooth scroll destination offset contained in this. The scroll delta is
|
|
|
|
* clamped to the scrollable region.
|
|
|
|
*/
|
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
|
|
|
void ApplyRelativeSmoothScrollUpdateFrom(const FrameMetrics& aOther) {
|
|
|
|
MOZ_ASSERT(aOther.IsRelative());
|
|
|
|
CSSPoint delta = (aOther.mSmoothScrollOffset - aOther.mBaseScrollOffset);
|
|
|
|
ClampAndSetSmoothScrollOffset(mScrollOffset + delta);
|
|
|
|
mScrollGeneration = aOther.mScrollGeneration;
|
|
|
|
mDoSmoothScroll = aOther.mDoSmoothScroll;
|
|
|
|
}
|
|
|
|
|
2016-04-13 17:21:13 +03:00
|
|
|
void UpdatePendingScrollInfo(const ScrollUpdateInfo& aInfo) {
|
|
|
|
mScrollOffset = aInfo.mScrollOffset;
|
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
|
|
|
mBaseScrollOffset = aInfo.mBaseScrollOffset;
|
2016-04-13 17:21:13 +03:00
|
|
|
mScrollGeneration = aInfo.mScrollGeneration;
|
|
|
|
mScrollUpdateType = ePending;
|
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
|
|
|
mIsRelative = aInfo.mIsRelative;
|
2016-04-13 17:21:13 +03:00
|
|
|
}
|
|
|
|
|
2015-01-17 00:15:52 +03:00
|
|
|
public:
|
2015-03-06 21:54:10 +03:00
|
|
|
void SetPresShellResolution(float aPresShellResolution) {
|
2015-01-17 00:15:52 +03:00
|
|
|
mPresShellResolution = aPresShellResolution;
|
|
|
|
}
|
2012-09-29 06:16:38 +04:00
|
|
|
|
2015-01-17 00:15:52 +03:00
|
|
|
float GetPresShellResolution() const { return mPresShellResolution; }
|
2013-09-06 02:26:59 +04:00
|
|
|
|
2015-05-07 21:44:03 +03:00
|
|
|
void SetCompositionBounds(const ParentLayerRect& aCompositionBounds) {
|
|
|
|
mCompositionBounds = aCompositionBounds;
|
|
|
|
}
|
|
|
|
|
|
|
|
const ParentLayerRect& GetCompositionBounds() const {
|
|
|
|
return mCompositionBounds;
|
|
|
|
}
|
|
|
|
|
2014-12-23 18:35:58 +03:00
|
|
|
void SetDisplayPort(const CSSRect& aDisplayPort) {
|
|
|
|
mDisplayPort = aDisplayPort;
|
|
|
|
}
|
|
|
|
|
2015-05-07 21:44:03 +03:00
|
|
|
const CSSRect& GetDisplayPort() const { return mDisplayPort; }
|
2014-12-23 18:35:58 +03:00
|
|
|
|
2014-12-30 22:07:57 +03:00
|
|
|
void SetCriticalDisplayPort(const CSSRect& aCriticalDisplayPort) {
|
|
|
|
mCriticalDisplayPort = aCriticalDisplayPort;
|
|
|
|
}
|
|
|
|
|
2015-05-07 21:44:03 +03:00
|
|
|
const CSSRect& GetCriticalDisplayPort() const { return mCriticalDisplayPort; }
|
2014-12-30 22:07:57 +03:00
|
|
|
|
2015-03-06 21:54:10 +03:00
|
|
|
void SetCumulativeResolution(
|
|
|
|
const LayoutDeviceToLayerScale2D& aCumulativeResolution) {
|
2014-12-19 03:33:18 +03:00
|
|
|
mCumulativeResolution = aCumulativeResolution;
|
|
|
|
}
|
|
|
|
|
2015-05-07 21:44:03 +03:00
|
|
|
const LayoutDeviceToLayerScale2D& GetCumulativeResolution() const {
|
2014-12-19 03:33:18 +03:00
|
|
|
return mCumulativeResolution;
|
|
|
|
}
|
|
|
|
|
2014-12-18 01:14:05 +03:00
|
|
|
void SetDevPixelsPerCSSPixel(
|
|
|
|
const CSSToLayoutDeviceScale& aDevPixelsPerCSSPixel) {
|
|
|
|
mDevPixelsPerCSSPixel = aDevPixelsPerCSSPixel;
|
|
|
|
}
|
|
|
|
|
2015-05-07 21:44:03 +03:00
|
|
|
const CSSToLayoutDeviceScale& GetDevPixelsPerCSSPixel() const {
|
2014-12-18 01:14:05 +03:00
|
|
|
return mDevPixelsPerCSSPixel;
|
|
|
|
}
|
|
|
|
|
2015-06-08 23:01:26 +03:00
|
|
|
void SetIsRootContent(bool aIsRootContent) {
|
|
|
|
mIsRootContent = aIsRootContent;
|
2014-08-24 03:09:10 +04:00
|
|
|
}
|
|
|
|
|
2015-06-08 23:01:26 +03:00
|
|
|
bool IsRootContent() const { return mIsRootContent; }
|
2014-08-24 03:09:10 +04:00
|
|
|
|
2014-03-13 10:34:34 +04:00
|
|
|
void SetScrollOffset(const CSSPoint& aScrollOffset) {
|
|
|
|
mScrollOffset = aScrollOffset;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
void SetBaseScrollOffset(const CSSPoint& aScrollOffset) {
|
|
|
|
mBaseScrollOffset = aScrollOffset;
|
|
|
|
}
|
|
|
|
|
2017-07-28 21:57:54 +03:00
|
|
|
// Set scroll offset, first clamping to the scroll range.
|
|
|
|
void ClampAndSetScrollOffset(const CSSPoint& aScrollOffset) {
|
|
|
|
SetScrollOffset(CalculateScrollRange().ClampPoint(aScrollOffset));
|
|
|
|
}
|
|
|
|
|
2014-03-13 10:34:34 +04:00
|
|
|
const CSSPoint& GetScrollOffset() const { return mScrollOffset; }
|
|
|
|
|
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
|
|
|
const CSSPoint& GetBaseScrollOffset() const { return mBaseScrollOffset; }
|
|
|
|
|
2014-07-10 22:52:40 +04:00
|
|
|
void SetSmoothScrollOffset(const CSSPoint& aSmoothScrollDestination) {
|
|
|
|
mSmoothScrollOffset = aSmoothScrollDestination;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
void ClampAndSetSmoothScrollOffset(const CSSPoint& aSmoothScrollOffset) {
|
|
|
|
SetSmoothScrollOffset(
|
|
|
|
CalculateScrollRange().ClampPoint(aSmoothScrollOffset));
|
|
|
|
}
|
|
|
|
|
2014-07-10 22:52:40 +04:00
|
|
|
const CSSPoint& GetSmoothScrollOffset() const { return mSmoothScrollOffset; }
|
|
|
|
|
2015-03-06 21:54:10 +03:00
|
|
|
void SetZoom(const CSSToParentLayerScale2D& aZoom) { mZoom = aZoom; }
|
2014-03-12 20:46:57 +04:00
|
|
|
|
2015-05-07 21:44:03 +03:00
|
|
|
const CSSToParentLayerScale2D& GetZoom() const { return mZoom; }
|
2014-03-12 20:46:57 +04: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
|
|
|
void SetScrollGeneration(uint32_t aScrollGeneration) {
|
2014-02-06 02:43:20 +04:00
|
|
|
mScrollGeneration = aScrollGeneration;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
void SetScrollOffsetUpdateType(ScrollOffsetUpdateType aScrollUpdateType) {
|
|
|
|
mScrollUpdateType = aScrollUpdateType;
|
Bug 1292781 - Send scroll-position-restore updates to APZ, but don't allow them to clobber user scrolls. r=tnikkel
Previously we weren't sending scroll position updates with origin nsGkAtoms::restore
over to the APZ at all, on the assumption that they should never clobber an APZ
scroll offset. However, there are scenarios where that is not true.
In particular, during a frame reconstruction, a layers update may be sent to the
compositor between the time a scrollframe has RestoreState() called on it, and
the time the scrollframe has ScrollToRestoredPosition() called on it. The layers
update that happens during this interval (correctly) sends a scroll position of
(0,0), and forces the APZ to scroll to that position. This is necessary to
prevent APZ from remaining at an invalid scroll offset while the frame is still
being rebuilt.
However, once ScrollToRestoredPosition() is called and the old scroll offset is
restored, that restored scroll position needs to get sent to the APZ in order to
have it properly restore to the original scroll position. In order to do this,
the main thread must flag the metrics with a scroll offset update. Since the user
may have scrolled concurrently in the compositor from the (0,0) position, we also
need to check for that case in the APZ code and avoid restoring the scroll
position. This is equivalent to the corresponding main-thread code in
ScrollToRestoredPosition().
MozReview-Commit-ID: LxRapVSrsJ3
2016-08-24 16:15:29 +03:00
|
|
|
}
|
|
|
|
|
2014-07-10 22:52:40 +04:00
|
|
|
void SetSmoothScrollOffsetUpdated(int32_t aScrollGeneration) {
|
|
|
|
mDoSmoothScroll = true;
|
|
|
|
mScrollGeneration = aScrollGeneration;
|
|
|
|
}
|
|
|
|
|
2016-04-13 17:21:13 +03:00
|
|
|
ScrollOffsetUpdateType GetScrollUpdateType() const {
|
|
|
|
return mScrollUpdateType;
|
|
|
|
}
|
|
|
|
|
2014-02-06 02:43:20 +04:00
|
|
|
bool GetScrollOffsetUpdated() const { return mScrollUpdateType != eNone; }
|
|
|
|
|
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
|
|
|
void SetIsRelative(bool aIsRelative) { mIsRelative = aIsRelative; }
|
|
|
|
|
|
|
|
bool IsRelative() const { return mIsRelative; }
|
|
|
|
|
2014-07-10 22:52:40 +04:00
|
|
|
bool GetDoSmoothScroll() const { return mDoSmoothScroll; }
|
|
|
|
|
2014-02-06 02:43:20 +04:00
|
|
|
uint32_t GetScrollGeneration() const { return mScrollGeneration; }
|
|
|
|
|
2014-03-22 01:48:08 +04:00
|
|
|
ViewID GetScrollId() const { return mScrollId; }
|
2014-08-11 21:32:51 +04:00
|
|
|
|
|
|
|
void SetScrollId(ViewID scrollId) { mScrollId = scrollId; }
|
2014-03-27 03:24:25 +04:00
|
|
|
|
|
|
|
void SetRootCompositionSize(const CSSSize& aRootCompositionSize) {
|
|
|
|
mRootCompositionSize = aRootCompositionSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
const CSSSize& GetRootCompositionSize() const { return mRootCompositionSize; }
|
|
|
|
|
2014-10-24 23:49:38 +04:00
|
|
|
void SetDisplayPortMargins(const ScreenMargin& aDisplayPortMargins) {
|
2014-03-27 05:46:24 +04:00
|
|
|
mDisplayPortMargins = aDisplayPortMargins;
|
|
|
|
}
|
|
|
|
|
2014-10-24 23:49:38 +04:00
|
|
|
const ScreenMargin& GetDisplayPortMargins() const {
|
2014-03-27 05:46:24 +04:00
|
|
|
return mDisplayPortMargins;
|
|
|
|
}
|
|
|
|
|
2014-05-17 03:00:50 +04:00
|
|
|
uint32_t GetPresShellId() const { return mPresShellId; }
|
|
|
|
|
|
|
|
void SetPresShellId(uint32_t aPresShellId) { mPresShellId = aPresShellId; }
|
|
|
|
|
2019-01-09 18:34:34 +03:00
|
|
|
void SetLayoutViewport(const CSSRect& aLayoutViewport) {
|
|
|
|
mLayoutViewport = aLayoutViewport;
|
|
|
|
}
|
2014-08-23 07:18:56 +04:00
|
|
|
|
2019-01-09 18:34:34 +03:00
|
|
|
const CSSRect& GetLayoutViewport() const { return mLayoutViewport; }
|
2014-08-23 07:18:56 +04:00
|
|
|
|
2018-06-08 00:01:36 +03:00
|
|
|
CSSRect GetVisualViewport() const {
|
|
|
|
return CSSRect(mScrollOffset, CalculateCompositedSizeInCssPixels());
|
|
|
|
}
|
|
|
|
|
2015-03-06 21:54:10 +03:00
|
|
|
void SetExtraResolution(const ScreenToLayerScale2D& aExtraResolution) {
|
2014-10-24 23:49:38 +04:00
|
|
|
mExtraResolution = aExtraResolution;
|
|
|
|
}
|
|
|
|
|
2015-05-07 21:44:03 +03:00
|
|
|
const ScreenToLayerScale2D& GetExtraResolution() const {
|
2014-10-24 23:49:38 +04:00
|
|
|
return mExtraResolution;
|
|
|
|
}
|
|
|
|
|
2014-12-27 20:48:27 +03:00
|
|
|
const CSSRect& GetScrollableRect() const { return mScrollableRect; }
|
|
|
|
|
|
|
|
void SetScrollableRect(const CSSRect& aScrollableRect) {
|
|
|
|
mScrollableRect = aScrollableRect;
|
|
|
|
}
|
|
|
|
|
2018-03-16 14:23:53 +03:00
|
|
|
// If the frame is in vertical-RTL writing mode(E.g. "writing-mode:
|
|
|
|
// vertical-rl" in CSS), or if it's in horizontal-RTL writing-mode(E.g.
|
|
|
|
// "writing-mode: horizontal-tb; direction: rtl;" in CSS), then this function
|
|
|
|
// returns true. From the representation perspective, frames whose horizontal
|
|
|
|
// contents start at rightside also cause their horizontal scrollbars, if any,
|
|
|
|
// initially start at rightside. So we can also learn about the initial side
|
|
|
|
// of the horizontal scrollbar for the frame by calling this function.
|
2018-07-27 21:58:46 +03:00
|
|
|
bool IsHorizontalContentRightToLeft() const { return mScrollableRect.x < 0; }
|
2018-03-16 14:23:53 +03:00
|
|
|
|
2016-01-16 00:19:59 +03:00
|
|
|
void SetPaintRequestTime(const TimeStamp& aTime) {
|
|
|
|
mPaintRequestTime = aTime;
|
|
|
|
}
|
|
|
|
const TimeStamp& GetPaintRequestTime() const { return mPaintRequestTime; }
|
|
|
|
|
2015-12-21 17:36:36 +03:00
|
|
|
void SetIsScrollInfoLayer(bool aIsScrollInfoLayer) {
|
|
|
|
mIsScrollInfoLayer = aIsScrollInfoLayer;
|
|
|
|
}
|
|
|
|
bool IsScrollInfoLayer() const { return mIsScrollInfoLayer; }
|
|
|
|
|
2019-01-10 23:59:13 +03:00
|
|
|
void SetVisualViewportOffset(const CSSPoint& aVisualViewportOffset) {
|
|
|
|
mVisualViewportOffset = aVisualViewportOffset;
|
|
|
|
}
|
|
|
|
const CSSPoint& GetVisualViewportOffset() const {
|
|
|
|
return mVisualViewportOffset;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetVisualScrollUpdateType(ScrollOffsetUpdateType aUpdateType) {
|
|
|
|
mVisualScrollUpdateType = aUpdateType;
|
|
|
|
}
|
|
|
|
ScrollOffsetUpdateType GetVisualScrollUpdateType() const {
|
|
|
|
return mVisualScrollUpdateType;
|
|
|
|
}
|
|
|
|
|
2018-06-08 00:01:36 +03:00
|
|
|
// Determine if the visual viewport is outside of the layout viewport and
|
2019-01-09 18:34:34 +03:00
|
|
|
// adjust the x,y-offset in mLayoutViewport accordingly. This is necessary to
|
2018-06-08 00:01:36 +03:00
|
|
|
// allow APZ to async-scroll the layout viewport.
|
|
|
|
//
|
|
|
|
// This is a no-op if mIsRootContent is false.
|
2019-01-09 18:34:34 +03:00
|
|
|
void RecalculateLayoutViewportOffset();
|
2018-06-08 00:01:36 +03:00
|
|
|
|
2018-10-11 08:58:13 +03:00
|
|
|
// Helper function for RecalculateViewportOffset(). Exposed so that
|
|
|
|
// APZC can perform the operation on other copies of the layout
|
|
|
|
// and visual viewport rects (e.g. the "effective" ones used to implement
|
|
|
|
// the frame delay).
|
|
|
|
// Modifies |aLayoutViewport| to continue enclosing |aVisualViewport|
|
|
|
|
// if possible.
|
2019-03-30 01:00:36 +03:00
|
|
|
// The layout viewport needs to remain clamped to the scrollable rect,
|
|
|
|
// and we pass in the scrollable rect so this function can maintain that
|
|
|
|
// constraint.
|
2018-10-11 08:58:13 +03:00
|
|
|
static void KeepLayoutViewportEnclosingVisualViewport(
|
2019-03-30 01:00:36 +03:00
|
|
|
const CSSRect& aVisualViewport, const CSSRect& aScrollableRect,
|
|
|
|
CSSRect& aLayoutViewport);
|
2018-10-11 08:58:13 +03:00
|
|
|
|
2014-01-21 21:33:52 +04:00
|
|
|
private:
|
2019-01-09 18:27:53 +03:00
|
|
|
// A ID assigned to each scrollable frame, unique within each LayersId..
|
2016-01-07 04:50:01 +03:00
|
|
|
ViewID mScrollId;
|
|
|
|
|
2015-01-17 00:15:52 +03:00
|
|
|
// The pres-shell resolution that has been induced on the document containing
|
|
|
|
// this scroll frame as a result of zooming this scroll frame (whether via
|
|
|
|
// user action, or choosing an initial zoom level on page load). This can
|
|
|
|
// only be different from 1.0 for frames that are zoomable, which currently
|
2019-01-09 18:27:53 +03:00
|
|
|
// is just the root content document's root scroll frame
|
|
|
|
// (mIsRootContent = true).
|
2015-01-17 00:15:52 +03:00
|
|
|
// This is a plain float rather than a ScaleFactor because in and of itself
|
|
|
|
// it does not convert between any coordinate spaces for which we have names.
|
|
|
|
float mPresShellResolution;
|
|
|
|
|
2015-05-07 21:44:03 +03:00
|
|
|
// This is the area within the widget that we're compositing to. It is in the
|
2019-01-09 18:27:53 +03:00
|
|
|
// layer coordinates of the scrollable content's parent layer.
|
2015-05-07 21:44:03 +03:00
|
|
|
//
|
2019-01-09 18:27:53 +03:00
|
|
|
// The size of the composition bounds corresponds to the size of the scroll
|
|
|
|
// frame's scroll port (but in a coordinate system where the size does not
|
|
|
|
// change during zooming).
|
2015-05-07 21:44:03 +03:00
|
|
|
//
|
2019-01-09 18:27:53 +03:00
|
|
|
// The origin of the composition bounds is relative to the layer tree origin.
|
|
|
|
// Unlike the scroll port's origin, it does not change during scrolling.
|
|
|
|
//
|
|
|
|
// This value is provided by Gecko at layout/paint time.
|
2015-05-07 21:44:03 +03:00
|
|
|
ParentLayerRect mCompositionBounds;
|
|
|
|
|
2019-01-09 18:27:53 +03:00
|
|
|
// The area of a scroll frame's contents that has been painted, relative to
|
|
|
|
// mScrollOffset.
|
2014-12-23 18:35:58 +03:00
|
|
|
//
|
2019-01-09 18:27:53 +03:00
|
|
|
// Should not be larger than GetExpandedScrollableRect().
|
2014-12-23 18:35:58 +03:00
|
|
|
//
|
2019-01-09 18:27:53 +03:00
|
|
|
// To pre-render a margin of 100 CSS pixels around the scroll port,
|
2014-12-23 18:35:58 +03:00
|
|
|
// { x = -100, y = - 100,
|
2019-01-09 18:27:53 +03:00
|
|
|
// width = scrollPort.width + 200, height = scrollPort.height + 200 }
|
|
|
|
// where scrollPort = CalculateCompositedSizeInCssPixels().
|
2014-12-23 18:35:58 +03:00
|
|
|
CSSRect mDisplayPort;
|
|
|
|
|
2014-12-30 22:07:57 +03:00
|
|
|
// If non-empty, the area of a frame's contents that is considered critical
|
|
|
|
// to paint. Area outside of this area (i.e. area inside mDisplayPort, but
|
|
|
|
// outside of mCriticalDisplayPort) is considered low-priority, and may be
|
|
|
|
// painted with lower precision, or not painted at all.
|
|
|
|
//
|
|
|
|
// The same restrictions for mDisplayPort apply here.
|
|
|
|
CSSRect mCriticalDisplayPort;
|
|
|
|
|
2014-12-27 20:48:27 +03:00
|
|
|
// The scrollable bounds of a frame. This is determined by reflow.
|
|
|
|
// Ordinarily the x and y will be 0 and the width and height will be the
|
|
|
|
// size of the element being scrolled. However for RTL pages or elements
|
|
|
|
// the x value may be negative.
|
|
|
|
//
|
2017-06-15 22:35:04 +03:00
|
|
|
// For scrollable frames that are overflow:hidden the x and y are usually
|
|
|
|
// set to the value of the current scroll offset, and the width and height
|
|
|
|
// will match the composition bounds width and height. In effect this reduces
|
|
|
|
// the scrollable range to 0.
|
|
|
|
//
|
|
|
|
// This is in the same coordinate space as |mScrollOffset|, but a different
|
2019-01-09 18:27:53 +03:00
|
|
|
// coordinate space than |mDisplayPort|. Note also that this coordinate
|
|
|
|
// system is understood by window.scrollTo().
|
2014-12-27 20:48:27 +03:00
|
|
|
CSSRect mScrollableRect;
|
|
|
|
|
2014-12-19 03:33:18 +03:00
|
|
|
// The cumulative resolution that the current frame has been painted at.
|
|
|
|
// This is the product of the pres-shell resolutions of the document
|
|
|
|
// containing this scroll frame and its ancestors, and any css-driven
|
|
|
|
// resolution. This information is provided by Gecko at layout/paint time.
|
2015-03-06 21:54:10 +03:00
|
|
|
// Note that this is allowed to have different x- and y-scales, but only
|
2019-01-09 18:27:53 +03:00
|
|
|
// for subframes (mIsRootContent = false). (The same applies to other scales
|
|
|
|
// that "inherit" the 2D-ness of this one, such as mZoom.)
|
2015-03-06 21:54:10 +03:00
|
|
|
LayoutDeviceToLayerScale2D mCumulativeResolution;
|
2014-12-19 03:33:18 +03:00
|
|
|
|
2014-12-18 01:14:05 +03:00
|
|
|
// The conversion factor between CSS pixels and device pixels for this frame.
|
2019-01-09 18:27:53 +03:00
|
|
|
// This can vary based on a variety of things, such as reflowing-zoom.
|
2014-12-18 01:14:05 +03:00
|
|
|
CSSToLayoutDeviceScale mDevPixelsPerCSSPixel;
|
|
|
|
|
2019-01-09 18:27:53 +03:00
|
|
|
// The position of the top-left of the scroll frame's scroll port, relative
|
|
|
|
// to the scrollable content's origin.
|
2014-03-13 10:34:34 +04:00
|
|
|
//
|
2019-01-09 18:27:53 +03:00
|
|
|
// This is in the same coordinate space as |mScrollableRect|, but a different
|
|
|
|
// coordinate space than |mDisplayPort|.
|
2014-03-13 10:34:34 +04:00
|
|
|
//
|
|
|
|
// It is required that the rect:
|
|
|
|
// { x = mScrollOffset.x, y = mScrollOffset.y,
|
2019-01-09 18:27:53 +03:00
|
|
|
// width = scrollPort.width,
|
|
|
|
// height = scrollPort.height }
|
|
|
|
// (where scrollPort = CalculateCompositedSizeInCssPixels())
|
|
|
|
// be within |mScrollableRect|.
|
2014-03-13 10:34:34 +04:00
|
|
|
CSSPoint mScrollOffset;
|
|
|
|
|
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
|
|
|
// The base scroll offset to use for calculating a relative update to a
|
|
|
|
// scroll offset.
|
|
|
|
CSSPoint mBaseScrollOffset;
|
|
|
|
|
2019-01-09 18:27:53 +03:00
|
|
|
// The "user zoom". Content is painted by gecko at mCumulativeResolution *
|
2014-03-12 20:46:57 +04:00
|
|
|
// mDevPixelsPerCSSPixel, but will be drawn to the screen at mZoom. In the
|
|
|
|
// steady state, the two will be the same, but during an async zoom action the
|
|
|
|
// two may diverge. This information is initialized in Gecko but updated in
|
|
|
|
// the APZC.
|
2015-03-06 21:54:10 +03:00
|
|
|
CSSToParentLayerScale2D mZoom;
|
2014-03-12 20:46:57 +04:00
|
|
|
|
2014-02-06 02:43:20 +04:00
|
|
|
// The scroll generation counter used to acknowledge the scroll offset update.
|
|
|
|
uint32_t mScrollGeneration;
|
2014-01-23 01:37:57 +04:00
|
|
|
|
2016-01-07 04:50:01 +03:00
|
|
|
// If mDoSmoothScroll is true, the scroll offset will be animated smoothly
|
|
|
|
// to this value.
|
2014-07-10 22:52:40 +04:00
|
|
|
CSSPoint mSmoothScrollOffset;
|
|
|
|
|
2014-03-27 03:24:25 +04:00
|
|
|
// The size of the root scrollable's composition bounds, but in local CSS
|
|
|
|
// pixels.
|
|
|
|
CSSSize mRootCompositionSize;
|
2014-03-27 05:46:24 +04:00
|
|
|
|
|
|
|
// A display port expressed as layer margins that apply to the rect of what
|
|
|
|
// is drawn of the scrollable element.
|
2014-10-24 23:49:38 +04:00
|
|
|
ScreenMargin mDisplayPortMargins;
|
2014-03-27 05:46:24 +04:00
|
|
|
|
2014-05-17 03:00:50 +04:00
|
|
|
uint32_t mPresShellId;
|
2014-08-23 07:18:56 +04:00
|
|
|
|
2019-01-09 18:27:53 +03:00
|
|
|
// For a root scroll frame (RSF), the document's layout viewport
|
|
|
|
// (sometimes called "CSS viewport" in older code).
|
|
|
|
//
|
|
|
|
// Its size is the dimensions we're using to constrain the <html> element
|
|
|
|
// of the document (i.e. the initial containing block (ICB) size).
|
|
|
|
//
|
|
|
|
// Its origin is the RSF's layout scroll position, i.e. the scroll position
|
|
|
|
// exposed to web content via window.scrollX/Y.
|
|
|
|
//
|
|
|
|
// Note that only the root content document's RSF has a layout viewport
|
|
|
|
// that's distinct from the visual viewport. For an iframe RSF, the two
|
|
|
|
// are the same.
|
2014-08-23 07:18:56 +04:00
|
|
|
//
|
2019-01-09 18:27:53 +03:00
|
|
|
// For a scroll frame that is not an RSF, this metric is meaningless and
|
|
|
|
// invalid.
|
2019-01-09 18:34:34 +03:00
|
|
|
CSSRect mLayoutViewport;
|
2014-08-29 16:23:25 +04:00
|
|
|
|
2014-10-24 23:49:38 +04:00
|
|
|
// The extra resolution at which content in this scroll frame is drawn beyond
|
|
|
|
// that necessary to draw one Layer pixel per Screen pixel.
|
2015-03-06 21:54:10 +03:00
|
|
|
ScreenToLayerScale2D mExtraResolution;
|
2014-10-24 23:49:38 +04:00
|
|
|
|
2019-01-09 18:27:53 +03:00
|
|
|
// The time at which the APZC last requested a repaint for this scroll frame.
|
2016-01-16 00:19:59 +03:00
|
|
|
TimeStamp mPaintRequestTime;
|
|
|
|
|
2016-04-13 17:21:13 +03:00
|
|
|
// Whether mScrollOffset was updated by something other than the APZ code, and
|
|
|
|
// if the APZC receiving this metrics should update its local copy.
|
|
|
|
ScrollOffsetUpdateType mScrollUpdateType;
|
|
|
|
|
2019-01-10 23:59:13 +03:00
|
|
|
// These fields are used when the main thread wants to set a visual viewport
|
|
|
|
// offset that's distinct from the layout viewport offset.
|
|
|
|
// In this case, mVisualScrollUpdateType is set to eMainThread, and
|
|
|
|
// mVisualViewportOffset is set to desired visual viewport offset (relative
|
|
|
|
// to the document, like mScrollOffset).
|
|
|
|
// TODO: Get rid of mVisualViewportOffset: between mViewport.TopLeft() and
|
|
|
|
// mScrollOffset, we have enough storage for the two scroll offsets.
|
|
|
|
// However, to avoid confusion, that first requires refactoring
|
|
|
|
// existing to consistently use the two fields for those two purposes.
|
|
|
|
CSSPoint mVisualViewportOffset;
|
|
|
|
ScrollOffsetUpdateType mVisualScrollUpdateType;
|
|
|
|
|
2016-01-07 04:50:01 +03:00
|
|
|
// Whether or not this is the root scroll frame for the root content document.
|
2016-01-07 04:50:01 +03:00
|
|
|
bool mIsRootContent : 1;
|
2016-01-07 04:50:01 +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
|
|
|
// When mIsRelative, the scroll offset was updated using a relative API,
|
|
|
|
// such as `ScrollBy`, and can combined with an async scroll.
|
|
|
|
bool mIsRelative : 1;
|
|
|
|
|
2016-01-07 04:50:01 +03:00
|
|
|
// When mDoSmoothScroll, the scroll offset should be animated to
|
|
|
|
// smoothly transition to mScrollOffset rather than be updated instantly.
|
2016-01-07 04:50:01 +03:00
|
|
|
bool mDoSmoothScroll : 1;
|
2016-01-07 04:50:01 +03:00
|
|
|
|
2019-01-09 18:27:53 +03:00
|
|
|
// True if this scroll frame is a scroll info layer. A scroll info layer is
|
|
|
|
// not layerized and its content cannot be truly async-scrolled, but its
|
|
|
|
// metrics are still sent to and updated by the compositor, with the updates
|
|
|
|
// being reflected on the next paint rather than the next composite.
|
2016-01-07 04:50:01 +03:00
|
|
|
bool mIsScrollInfoLayer : 1;
|
2015-12-21 17:36:36 +03:00
|
|
|
|
2015-03-26 04:34:56 +03:00
|
|
|
// WARNING!!!!
|
|
|
|
//
|
2016-04-27 23:06:34 +03:00
|
|
|
// When adding a new field:
|
|
|
|
//
|
|
|
|
// - First, consider whether the field can be added to ScrollMetadata
|
|
|
|
// instead. If so, prefer that.
|
|
|
|
//
|
|
|
|
// - Otherwise, the following places should be updated to include them
|
|
|
|
// (as needed):
|
|
|
|
// FrameMetrics::operator ==
|
|
|
|
// AsyncPanZoomController::NotifyLayersUpdated
|
2019-01-09 18:27:53 +03:00
|
|
|
// The ParamTraits specialization in LayersMessageUtils.h
|
2015-03-26 04:34:56 +03:00
|
|
|
//
|
|
|
|
// Please add new fields above this comment.
|
2016-01-07 04:50:01 +03:00
|
|
|
|
|
|
|
// Private helpers for IPC purposes
|
|
|
|
void SetDoSmoothScroll(bool aValue) { mDoSmoothScroll = aValue; }
|
2012-07-31 04:42:26 +04:00
|
|
|
};
|
|
|
|
|
2016-03-19 03:07:27 +03:00
|
|
|
struct ScrollSnapInfo {
|
2018-12-06 02:04:51 +03:00
|
|
|
ScrollSnapInfo() = default;
|
2016-03-19 03:07:27 +03:00
|
|
|
|
2016-04-26 03:58:11 +03:00
|
|
|
bool operator==(const ScrollSnapInfo& aOther) const {
|
2019-05-22 20:43:34 +03:00
|
|
|
return mScrollSnapStrictnessX == aOther.mScrollSnapStrictnessX &&
|
|
|
|
mScrollSnapStrictnessY == aOther.mScrollSnapStrictnessY &&
|
2016-04-26 03:58:11 +03:00
|
|
|
mScrollSnapIntervalX == aOther.mScrollSnapIntervalX &&
|
|
|
|
mScrollSnapIntervalY == aOther.mScrollSnapIntervalY &&
|
|
|
|
mScrollSnapDestination == aOther.mScrollSnapDestination &&
|
2019-04-11 09:20:36 +03:00
|
|
|
mScrollSnapCoordinates == aOther.mScrollSnapCoordinates &&
|
|
|
|
mSnapPositionX == aOther.mSnapPositionX &&
|
2019-04-11 09:21:11 +03:00
|
|
|
mSnapPositionY == aOther.mSnapPositionY &&
|
|
|
|
mXRangeWiderThanSnapport == aOther.mXRangeWiderThanSnapport &&
|
|
|
|
mYRangeWiderThanSnapport == aOther.mYRangeWiderThanSnapport &&
|
|
|
|
mSnapportSize == aOther.mSnapportSize;
|
2016-04-26 03:58:11 +03:00
|
|
|
}
|
|
|
|
|
2017-06-15 10:52:34 +03:00
|
|
|
bool HasScrollSnapping() const {
|
2019-05-22 20:43:34 +03:00
|
|
|
return mScrollSnapStrictnessY != mozilla::StyleScrollSnapStrictness::None ||
|
|
|
|
mScrollSnapStrictnessX != mozilla::StyleScrollSnapStrictness::None;
|
2017-06-15 10:52:34 +03:00
|
|
|
}
|
|
|
|
|
2019-05-17 23:50:24 +03:00
|
|
|
bool HasSnapPositions() const {
|
|
|
|
return (!mSnapPositionX.IsEmpty() &&
|
2019-05-22 20:43:34 +03:00
|
|
|
mScrollSnapStrictnessX !=
|
|
|
|
mozilla::StyleScrollSnapStrictness::None) ||
|
2019-05-17 23:50:24 +03:00
|
|
|
(!mSnapPositionY.IsEmpty() &&
|
2019-05-22 20:43:34 +03:00
|
|
|
mScrollSnapStrictnessY != mozilla::StyleScrollSnapStrictness::None);
|
2019-05-17 23:50:24 +03:00
|
|
|
}
|
|
|
|
|
2019-05-22 20:43:34 +03:00
|
|
|
void InitializeScrollSnapStrictness(WritingMode aWritingMode,
|
|
|
|
const nsStyleDisplay* aDisplay);
|
2019-04-23 04:16:02 +03:00
|
|
|
|
2016-03-19 03:07:27 +03:00
|
|
|
// The scroll frame's scroll-snap-type.
|
2019-05-22 20:43:34 +03:00
|
|
|
mozilla::StyleScrollSnapStrictness mScrollSnapStrictnessX =
|
2019-04-11 09:19:13 +03:00
|
|
|
mozilla::StyleScrollSnapStrictness::None;
|
2019-05-22 20:43:34 +03:00
|
|
|
mozilla::StyleScrollSnapStrictness mScrollSnapStrictnessY =
|
2019-04-11 09:19:13 +03:00
|
|
|
mozilla::StyleScrollSnapStrictness::None;
|
2016-03-19 03:07:27 +03:00
|
|
|
|
|
|
|
// The intervals derived from the scroll frame's scroll-snap-points.
|
|
|
|
Maybe<nscoord> mScrollSnapIntervalX;
|
|
|
|
Maybe<nscoord> mScrollSnapIntervalY;
|
|
|
|
|
|
|
|
// The scroll frame's scroll-snap-destination, in cooked form (to avoid
|
2019-06-28 12:46:26 +03:00
|
|
|
// shipping the raw style value over IPC).
|
2016-03-19 03:07:27 +03:00
|
|
|
nsPoint mScrollSnapDestination;
|
|
|
|
|
|
|
|
// The scroll-snap-coordinates of any descendant frames of the scroll frame,
|
|
|
|
// relative to the origin of the scrolled frame.
|
|
|
|
nsTArray<nsPoint> mScrollSnapCoordinates;
|
2019-04-11 09:20:36 +03:00
|
|
|
|
|
|
|
// The scroll positions corresponding to scroll-snap-align values.
|
|
|
|
nsTArray<nscoord> mSnapPositionX;
|
|
|
|
nsTArray<nscoord> mSnapPositionY;
|
2019-04-11 09:21:11 +03:00
|
|
|
|
|
|
|
struct ScrollSnapRange {
|
|
|
|
ScrollSnapRange() = default;
|
|
|
|
|
|
|
|
ScrollSnapRange(nscoord aStart, nscoord aEnd)
|
|
|
|
: mStart(aStart), mEnd(aEnd) {}
|
|
|
|
|
|
|
|
nscoord mStart;
|
|
|
|
nscoord mEnd;
|
|
|
|
bool operator==(const ScrollSnapRange& aOther) const {
|
|
|
|
return mStart == aOther.mStart && mEnd == aOther.mEnd;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns true if |aPoint| is a valid snap position in this range.
|
|
|
|
bool IsValid(nscoord aPoint, nscoord aSnapportSize) const {
|
|
|
|
MOZ_ASSERT(mEnd - mStart > aSnapportSize);
|
|
|
|
return mStart <= aPoint && aPoint <= mEnd - aSnapportSize;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
// An array of the range that the target element is larger than the snapport
|
|
|
|
// on the axis.
|
|
|
|
// Snap positions in this range will be valid snap positions in the case where
|
|
|
|
// the distance between the closest snap position and the second closest snap
|
|
|
|
// position is still larger than the snapport size.
|
|
|
|
// See https://drafts.csswg.org/css-scroll-snap-1/#snap-overflow
|
|
|
|
//
|
2019-04-23 06:58:57 +03:00
|
|
|
// Note: This range contains scroll-margin values.
|
2019-04-11 09:21:11 +03:00
|
|
|
nsTArray<ScrollSnapRange> mXRangeWiderThanSnapport;
|
|
|
|
nsTArray<ScrollSnapRange> mYRangeWiderThanSnapport;
|
2019-04-11 09:21:48 +03:00
|
|
|
|
|
|
|
// Note: This snapport size has been already deflated by scroll-padding.
|
2019-04-11 09:21:11 +03:00
|
|
|
nsSize mSnapportSize;
|
2016-03-19 03:07:27 +03:00
|
|
|
};
|
2016-03-29 02:14:52 +03:00
|
|
|
|
2018-11-28 12:14:19 +03:00
|
|
|
// clang-format off
|
2017-10-19 03:13:19 +03:00
|
|
|
MOZ_DEFINE_ENUM_CLASS_WITH_BASE(
|
|
|
|
OverscrollBehavior, uint8_t, (
|
|
|
|
Auto,
|
|
|
|
Contain,
|
|
|
|
None
|
|
|
|
));
|
2018-11-28 12:14:19 +03:00
|
|
|
// clang-format on
|
2017-10-19 03:13:19 +03:00
|
|
|
|
|
|
|
struct OverscrollBehaviorInfo {
|
|
|
|
OverscrollBehaviorInfo()
|
|
|
|
: mBehaviorX(OverscrollBehavior::Auto),
|
|
|
|
mBehaviorY(OverscrollBehavior::Auto) {}
|
|
|
|
|
|
|
|
// Construct from StyleOverscrollBehavior values.
|
|
|
|
static OverscrollBehaviorInfo FromStyleConstants(
|
|
|
|
StyleOverscrollBehavior aBehaviorX, StyleOverscrollBehavior aBehaviorY);
|
|
|
|
|
|
|
|
bool operator==(const OverscrollBehaviorInfo& aOther) const {
|
|
|
|
return mBehaviorX == aOther.mBehaviorX && mBehaviorY == aOther.mBehaviorY;
|
|
|
|
}
|
|
|
|
|
|
|
|
OverscrollBehavior mBehaviorX;
|
|
|
|
OverscrollBehavior mBehaviorY;
|
|
|
|
};
|
|
|
|
|
2016-04-29 23:14:21 +03:00
|
|
|
/**
|
|
|
|
* A clip that applies to a layer, that may be scrolled by some of the
|
|
|
|
* scroll frames associated with the layer.
|
|
|
|
*/
|
|
|
|
struct LayerClip {
|
|
|
|
friend struct IPC::ParamTraits<mozilla::layers::LayerClip>;
|
|
|
|
|
|
|
|
public:
|
|
|
|
LayerClip() : mClipRect(), mMaskLayerIndex() {}
|
|
|
|
|
|
|
|
explicit LayerClip(const ParentLayerIntRect& aClipRect)
|
|
|
|
: mClipRect(aClipRect), mMaskLayerIndex() {}
|
|
|
|
|
|
|
|
bool operator==(const LayerClip& aOther) const {
|
|
|
|
return mClipRect == aOther.mClipRect &&
|
|
|
|
mMaskLayerIndex == aOther.mMaskLayerIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetClipRect(const ParentLayerIntRect& aClipRect) {
|
|
|
|
mClipRect = aClipRect;
|
|
|
|
}
|
|
|
|
const ParentLayerIntRect& GetClipRect() const { return mClipRect; }
|
|
|
|
|
|
|
|
void SetMaskLayerIndex(const Maybe<size_t>& aIndex) {
|
|
|
|
mMaskLayerIndex = aIndex;
|
|
|
|
}
|
|
|
|
const Maybe<size_t>& GetMaskLayerIndex() const { return mMaskLayerIndex; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
ParentLayerIntRect mClipRect;
|
|
|
|
|
|
|
|
// Optionally, specifies a mask layer that's part of the clip.
|
|
|
|
// This is an index into the MetricsMaskLayers array on the Layer.
|
|
|
|
Maybe<size_t> mMaskLayerIndex;
|
|
|
|
};
|
|
|
|
|
2016-04-30 00:32:53 +03:00
|
|
|
typedef Maybe<LayerClip> MaybeLayerClip; // for passing over IPDL
|
|
|
|
|
2016-03-29 02:14:52 +03:00
|
|
|
/**
|
2019-01-09 18:27:53 +03:00
|
|
|
* Metadata about a scroll frame that's sent to the compositor during a layers
|
|
|
|
* or WebRender transaction, and also stored by APZ between transactions.
|
|
|
|
* This includes the scroll frame's FrameMetrics, as well as other metadata.
|
|
|
|
* We don't put the other metadata into FrameMetrics to avoid FrameMetrics
|
|
|
|
* becoming too bloated (as a FrameMetrics is e.g. stored in memory shared
|
|
|
|
* with the content process).
|
2016-03-29 02:14:52 +03:00
|
|
|
*/
|
|
|
|
struct ScrollMetadata {
|
|
|
|
friend struct IPC::ParamTraits<mozilla::layers::ScrollMetadata>;
|
2016-04-27 23:06:34 +03:00
|
|
|
|
2018-11-01 23:15:46 +03:00
|
|
|
typedef ScrollableLayerGuid::ViewID ViewID;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-03-29 02:14:52 +03:00
|
|
|
public:
|
2016-03-31 00:04:10 +03:00
|
|
|
static StaticAutoPtr<const ScrollMetadata>
|
|
|
|
sNullMetadata; // We sometimes need an empty metadata
|
2016-03-29 02:14:52 +03:00
|
|
|
|
|
|
|
ScrollMetadata()
|
|
|
|
: mMetrics(),
|
2016-03-12 06:04:53 +03:00
|
|
|
mSnapInfo(),
|
2018-11-01 23:15:46 +03:00
|
|
|
mScrollParentId(ScrollableLayerGuid::NULL_SCROLL_ID),
|
2016-04-27 23:06:34 +03:00
|
|
|
mBackgroundColor(),
|
|
|
|
mContentDescription(),
|
|
|
|
mLineScrollAmount(0, 0),
|
|
|
|
mPageScrollAmount(0, 0),
|
2016-04-29 23:14:21 +03:00
|
|
|
mScrollClip(),
|
2016-04-27 23:06:34 +03:00
|
|
|
mHasScrollgrab(false),
|
|
|
|
mIsLayersIdRoot(false),
|
2018-03-16 16:20:39 +03:00
|
|
|
mIsAutoDirRootContentRTL(false),
|
2016-04-27 23:06:34 +03:00
|
|
|
mUsesContainerScrolling(false),
|
|
|
|
mForceDisableApz(false),
|
2018-12-05 19:29:18 +03:00
|
|
|
mResolutionUpdated(false),
|
2017-10-19 03:13:19 +03:00
|
|
|
mOverscrollBehavior() {}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-03-29 02:14:52 +03:00
|
|
|
bool operator==(const ScrollMetadata& aOther) const {
|
|
|
|
return mMetrics == aOther.mMetrics && mSnapInfo == aOther.mSnapInfo &&
|
2016-04-27 23:06:34 +03:00
|
|
|
mScrollParentId == aOther.mScrollParentId &&
|
|
|
|
mBackgroundColor == aOther.mBackgroundColor &&
|
|
|
|
// don't compare mContentDescription
|
|
|
|
mLineScrollAmount == aOther.mLineScrollAmount &&
|
|
|
|
mPageScrollAmount == aOther.mPageScrollAmount &&
|
2016-04-29 23:14:21 +03:00
|
|
|
mScrollClip == aOther.mScrollClip &&
|
2016-04-27 23:06:34 +03:00
|
|
|
mHasScrollgrab == aOther.mHasScrollgrab &&
|
|
|
|
mIsLayersIdRoot == aOther.mIsLayersIdRoot &&
|
2018-03-16 16:20:39 +03:00
|
|
|
mIsAutoDirRootContentRTL == aOther.mIsAutoDirRootContentRTL &&
|
2016-04-27 23:06:34 +03:00
|
|
|
mUsesContainerScrolling == aOther.mUsesContainerScrolling &&
|
2017-10-19 03:13:19 +03:00
|
|
|
mForceDisableApz == aOther.mForceDisableApz &&
|
2018-12-05 19:29:18 +03:00
|
|
|
mResolutionUpdated == aOther.mResolutionUpdated &&
|
2018-02-22 21:40:44 +03:00
|
|
|
mDisregardedDirection == aOther.mDisregardedDirection &&
|
2017-10-19 03:13:19 +03:00
|
|
|
mOverscrollBehavior == aOther.mOverscrollBehavior;
|
2016-03-29 02:14:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=(const ScrollMetadata& aOther) const {
|
|
|
|
return !operator==(aOther);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsDefault() const {
|
|
|
|
ScrollMetadata def;
|
|
|
|
|
|
|
|
def.mMetrics.SetPresShellId(mMetrics.GetPresShellId());
|
|
|
|
return (def == *this);
|
|
|
|
}
|
|
|
|
|
|
|
|
FrameMetrics& GetMetrics() { return mMetrics; }
|
|
|
|
const FrameMetrics& GetMetrics() const { return mMetrics; }
|
|
|
|
|
2016-03-12 06:04:53 +03:00
|
|
|
void SetSnapInfo(ScrollSnapInfo&& aSnapInfo) {
|
2018-05-30 22:15:35 +03:00
|
|
|
mSnapInfo = std::move(aSnapInfo);
|
2016-03-12 06:04:53 +03:00
|
|
|
}
|
|
|
|
const ScrollSnapInfo& GetSnapInfo() const { return mSnapInfo; }
|
|
|
|
|
2016-04-27 23:06:34 +03:00
|
|
|
ViewID GetScrollParentId() const { return mScrollParentId; }
|
|
|
|
|
|
|
|
void SetScrollParentId(ViewID aParentId) { mScrollParentId = aParentId; }
|
|
|
|
const gfx::Color& GetBackgroundColor() const { return mBackgroundColor; }
|
|
|
|
void SetBackgroundColor(const gfx::Color& aBackgroundColor) {
|
|
|
|
mBackgroundColor = aBackgroundColor;
|
|
|
|
}
|
|
|
|
const nsCString& GetContentDescription() const { return mContentDescription; }
|
|
|
|
void SetContentDescription(const nsCString& aContentDescription) {
|
|
|
|
mContentDescription = aContentDescription;
|
|
|
|
}
|
|
|
|
const LayoutDeviceIntSize& GetLineScrollAmount() const {
|
|
|
|
return mLineScrollAmount;
|
|
|
|
}
|
|
|
|
void SetLineScrollAmount(const LayoutDeviceIntSize& size) {
|
|
|
|
mLineScrollAmount = size;
|
|
|
|
}
|
|
|
|
const LayoutDeviceIntSize& GetPageScrollAmount() const {
|
|
|
|
return mPageScrollAmount;
|
|
|
|
}
|
|
|
|
void SetPageScrollAmount(const LayoutDeviceIntSize& size) {
|
|
|
|
mPageScrollAmount = size;
|
|
|
|
}
|
2016-04-29 23:14:21 +03:00
|
|
|
|
|
|
|
void SetScrollClip(const Maybe<LayerClip>& aScrollClip) {
|
|
|
|
mScrollClip = aScrollClip;
|
2016-03-29 02:14:52 +03:00
|
|
|
}
|
2016-04-29 23:14:21 +03:00
|
|
|
const Maybe<LayerClip>& GetScrollClip() const { return mScrollClip; }
|
|
|
|
bool HasScrollClip() const { return mScrollClip.isSome(); }
|
|
|
|
const LayerClip& ScrollClip() const { return mScrollClip.ref(); }
|
|
|
|
LayerClip& ScrollClip() { return mScrollClip.ref(); }
|
|
|
|
|
|
|
|
bool HasMaskLayer() const {
|
|
|
|
return HasScrollClip() && ScrollClip().GetMaskLayerIndex();
|
2016-03-29 02:14:52 +03:00
|
|
|
}
|
2016-04-29 23:14:21 +03:00
|
|
|
Maybe<ParentLayerIntRect> GetClipRect() const {
|
|
|
|
return mScrollClip.isSome() ? Some(mScrollClip->GetClipRect()) : Nothing();
|
2016-03-29 02:14:52 +03:00
|
|
|
}
|
2016-04-27 23:06:34 +03:00
|
|
|
|
|
|
|
void SetHasScrollgrab(bool aHasScrollgrab) {
|
|
|
|
mHasScrollgrab = aHasScrollgrab;
|
|
|
|
}
|
|
|
|
bool GetHasScrollgrab() const { return mHasScrollgrab; }
|
|
|
|
void SetIsLayersIdRoot(bool aValue) { mIsLayersIdRoot = aValue; }
|
|
|
|
bool IsLayersIdRoot() const { return mIsLayersIdRoot; }
|
2018-03-16 16:20:39 +03:00
|
|
|
void SetIsAutoDirRootContentRTL(bool aValue) {
|
|
|
|
mIsAutoDirRootContentRTL = aValue;
|
|
|
|
}
|
|
|
|
bool IsAutoDirRootContentRTL() const { return mIsAutoDirRootContentRTL; }
|
2019-05-26 17:31:53 +03:00
|
|
|
// Implemented out of line because the implementation needs StaticPrefs.h
|
2016-04-27 23:06:34 +03:00
|
|
|
// and we don't want to include that from FrameMetrics.h.
|
|
|
|
void SetUsesContainerScrolling(bool aValue);
|
|
|
|
bool UsesContainerScrolling() const { return mUsesContainerScrolling; }
|
|
|
|
void SetForceDisableApz(bool aForceDisable) {
|
|
|
|
mForceDisableApz = aForceDisable;
|
|
|
|
}
|
|
|
|
bool IsApzForceDisabled() const { return mForceDisableApz; }
|
2018-12-05 19:29:18 +03:00
|
|
|
void SetResolutionUpdated(bool aUpdated) { mResolutionUpdated = aUpdated; }
|
|
|
|
bool IsResolutionUpdated() const { return mResolutionUpdated; }
|
2016-04-27 23:06:34 +03:00
|
|
|
|
2018-02-22 21:40:44 +03:00
|
|
|
// For more details about the concept of a disregarded direction, refer to the
|
|
|
|
// code which defines mDisregardedDirection.
|
|
|
|
Maybe<ScrollDirection> GetDisregardedDirection() const {
|
|
|
|
return mDisregardedDirection;
|
|
|
|
}
|
|
|
|
void SetDisregardedDirection(const Maybe<ScrollDirection>& aValue) {
|
|
|
|
mDisregardedDirection = aValue;
|
|
|
|
}
|
|
|
|
|
2017-10-19 03:13:19 +03:00
|
|
|
void SetOverscrollBehavior(
|
|
|
|
const OverscrollBehaviorInfo& aOverscrollBehavior) {
|
|
|
|
mOverscrollBehavior = aOverscrollBehavior;
|
|
|
|
}
|
|
|
|
const OverscrollBehaviorInfo& GetOverscrollBehavior() const {
|
|
|
|
return mOverscrollBehavior;
|
|
|
|
}
|
|
|
|
|
2016-03-29 02:14:52 +03:00
|
|
|
private:
|
|
|
|
FrameMetrics mMetrics;
|
|
|
|
|
2016-03-12 06:04:53 +03:00
|
|
|
// Information used to determine where to snap to for a given scroll.
|
|
|
|
ScrollSnapInfo mSnapInfo;
|
|
|
|
|
2016-04-27 23:06:34 +03:00
|
|
|
// The ViewID of the scrollable frame to which overscroll should be handed
|
|
|
|
// off.
|
|
|
|
ViewID mScrollParentId;
|
|
|
|
|
|
|
|
// The background color to use when overscrolling.
|
|
|
|
gfx::Color mBackgroundColor;
|
|
|
|
|
|
|
|
// A description of the content element corresponding to this frame.
|
|
|
|
// This is empty unless this is a scrollable layer and the
|
|
|
|
// apz.printtree pref is turned on.
|
|
|
|
nsCString mContentDescription;
|
|
|
|
|
|
|
|
// The value of GetLineScrollAmount(), for scroll frames.
|
|
|
|
LayoutDeviceIntSize mLineScrollAmount;
|
|
|
|
|
|
|
|
// The value of GetPageScrollAmount(), for scroll frames.
|
|
|
|
LayoutDeviceIntSize mPageScrollAmount;
|
|
|
|
|
2016-04-29 23:14:21 +03:00
|
|
|
// A clip to apply when compositing the layer bearing this ScrollMetadata,
|
|
|
|
// after applying any transform arising from scrolling this scroll frame.
|
|
|
|
// Note that, unlike most other fields of ScrollMetadata, this is allowed
|
|
|
|
// to differ between different layers scrolled by the same scroll frame.
|
|
|
|
// TODO: Group the fields of ScrollMetadata into sub-structures to separate
|
|
|
|
// fields with this property better.
|
|
|
|
Maybe<LayerClip> mScrollClip;
|
2016-04-27 23:06:34 +03:00
|
|
|
|
|
|
|
// Whether or not this frame is for an element marked 'scrollgrab'.
|
|
|
|
bool mHasScrollgrab : 1;
|
|
|
|
|
|
|
|
// Whether these framemetrics are for the root scroll frame (root element if
|
|
|
|
// we don't have a root scroll frame) for its layers id.
|
|
|
|
bool mIsLayersIdRoot : 1;
|
|
|
|
|
2018-03-16 16:20:39 +03:00
|
|
|
// The AutoDirRootContent is the <body> element in an HTML document, or the
|
|
|
|
// root scrollframe if there is no body. This member variable indicates
|
|
|
|
// whether this element's content in the horizontal direction starts from
|
|
|
|
// right to left (e.g. it's true either if "writing-mode: vertical-rl", or
|
|
|
|
// "writing-mode: horizontal-tb; direction: rtl" in CSS).
|
|
|
|
// When we do auto-dir scrolling (@see mozilla::WheelDeltaAdjustmentStrategy
|
|
|
|
// or refer to bug 1358017 for details), setting a pref can make the code use
|
|
|
|
// the writing mode of this root element instead of the target scrollframe,
|
|
|
|
// and so we need to know if the writing mode is RTL or not.
|
|
|
|
bool mIsAutoDirRootContentRTL : 1;
|
|
|
|
|
2016-04-27 23:06:34 +03:00
|
|
|
// True if scrolling using containers, false otherwise. This can be removed
|
|
|
|
// when containerful scrolling is eliminated.
|
|
|
|
bool mUsesContainerScrolling : 1;
|
|
|
|
|
|
|
|
// Whether or not the compositor should actually do APZ-scrolling on this
|
|
|
|
// scrollframe.
|
|
|
|
bool mForceDisableApz : 1;
|
|
|
|
|
2018-12-05 19:29:18 +03:00
|
|
|
// Whether the pres shell resolution stored in mMetrics reflects a change
|
|
|
|
// originated by the main thread. Plays a similar role for the resolution as
|
|
|
|
// FrameMetrics::mScrollUpdateType) does for the scroll offset.
|
|
|
|
bool mResolutionUpdated : 1;
|
|
|
|
|
2018-02-22 21:40:44 +03:00
|
|
|
// The disregarded direction means the direction which is disregarded anyway,
|
|
|
|
// even if the scroll frame overflows in that direction and the direction is
|
|
|
|
// specified as scrollable. This could happen in some scenarios, for instance,
|
|
|
|
// a single-line text control frame should disregard wheel scroll in
|
|
|
|
// its block-flow direction even if it overflows in that direction.
|
|
|
|
Maybe<ScrollDirection> mDisregardedDirection;
|
|
|
|
|
2017-10-19 03:13:19 +03:00
|
|
|
// The overscroll behavior for this scroll frame.
|
|
|
|
OverscrollBehaviorInfo mOverscrollBehavior;
|
|
|
|
|
2016-04-27 23:06:34 +03:00
|
|
|
// WARNING!!!!
|
|
|
|
//
|
|
|
|
// When adding new fields to ScrollMetadata, the following places should be
|
|
|
|
// updated to include them (as needed):
|
2018-02-22 21:40:44 +03:00
|
|
|
// 1. ScrollMetadata::operator ==
|
|
|
|
// 2. AsyncPanZoomController::NotifyLayersUpdated
|
2019-01-09 18:27:53 +03:00
|
|
|
// 3. The ParamTraits specialization in LayersMessageUtils.h
|
2016-04-27 23:06:34 +03:00
|
|
|
//
|
|
|
|
// Please add new fields above this comment.
|
2016-03-29 02:14:52 +03:00
|
|
|
};
|
|
|
|
|
2019-07-15 17:47:40 +03:00
|
|
|
typedef std::map<ScrollableLayerGuid::ViewID, ScrollUpdateInfo>
|
2018-11-01 23:15:46 +03:00
|
|
|
ScrollUpdatesMap;
|
2018-05-12 04:18:22 +03:00
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|
2012-07-31 04:42:26 +04:00
|
|
|
|
|
|
|
#endif /* GFX_FRAMEMETRICS_H */
|