2012-07-31 04:42:26 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* 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/. */
|
|
|
|
|
|
|
|
#ifndef GFX_FRAMEMETRICS_H
|
|
|
|
#define GFX_FRAMEMETRICS_H
|
|
|
|
|
2013-08-12 03:17:23 +04:00
|
|
|
#include <stdint.h> // for uint32_t, uint64_t
|
|
|
|
#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
|
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"
|
2016-03-19 03:07:27 +03:00
|
|
|
#include "nsStyleCoord.h" // for nsStyleCoord
|
2012-07-31 04:42:26 +04:00
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2012-07-31 04:42:26 +04:00
|
|
|
/**
|
|
|
|
* The viewport and displayport metrics for the painted frame at the
|
|
|
|
* time of a layer-tree transaction. These metrics are especially
|
|
|
|
* useful for shadow layers, because the metrics values are updated
|
|
|
|
* atomically with new pixels.
|
|
|
|
*/
|
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
|
|
|
public:
|
|
|
|
// We use IDs to identify frames across processes.
|
2012-08-22 19:56:38 +04:00
|
|
|
typedef uint64_t ViewID;
|
2012-07-31 04:42:26 +04:00
|
|
|
static const ViewID NULL_SCROLL_ID; // This container layer does not scroll.
|
2013-11-22 23:45:50 +04:00
|
|
|
static const ViewID START_SCROLL_ID = 2; // This is the ID that scrolling subframes
|
2012-07-31 04:42:26 +04:00
|
|
|
// will begin at.
|
|
|
|
|
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.
|
|
|
|
ePending, // The scroll offset was updated on the main thread, but not
|
|
|
|
// painted, so the layer texture data is still at the old
|
|
|
|
// offset.
|
|
|
|
eUserAction, // In an APZ repaint request, this means the APZ generated
|
|
|
|
// the scroll position based on user action (the alternative
|
|
|
|
// is eNone which means it's just request a repaint because
|
|
|
|
// it got a scroll update from the main thread).
|
|
|
|
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.
|
|
|
|
));
|
2016-04-13 17:21:13 +03:00
|
|
|
|
2012-07-31 04:42:26 +04:00
|
|
|
FrameMetrics()
|
2016-01-07 04:50:01 +03:00
|
|
|
: mScrollId(NULL_SCROLL_ID)
|
|
|
|
, 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)
|
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)
|
2014-08-23 07:18:56 +04:00
|
|
|
, mViewport(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)
|
2016-01-07 04:50:01 +03:00
|
|
|
, mIsRootContent(false)
|
|
|
|
, mDoSmoothScroll(false)
|
|
|
|
, mUseDisplayPortMargins(false)
|
2015-12-21 17:36:36 +03:00
|
|
|
, mIsScrollInfoLayer(false)
|
2014-08-29 16:23:25 +04:00
|
|
|
{
|
|
|
|
}
|
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 &&
|
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 &&
|
|
|
|
mViewport.IsEqualEdges(aOther.mViewport) &&
|
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 &&
|
2016-01-07 04:50:01 +03:00
|
|
|
mIsRootContent == aOther.mIsRootContent &&
|
|
|
|
mDoSmoothScroll == aOther.mDoSmoothScroll &&
|
|
|
|
mUseDisplayPortMargins == aOther.mUseDisplayPortMargins &&
|
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
|
|
|
|
{
|
|
|
|
return mScrollId != NULL_SCROLL_ID;
|
|
|
|
}
|
|
|
|
|
2015-03-06 21:54:10 +03:00
|
|
|
CSSToScreenScale2D DisplayportPixelsPerCSSPixel() const
|
2014-10-24 23:49:38 +04:00
|
|
|
{
|
2014-11-10 22:35:11 +03:00
|
|
|
// Note: use 'mZoom * ParentLayerToLayerScale(1.0f)' as the CSS-to-Layer scale
|
2014-10-24 23:49:38 +04:00
|
|
|
// 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
|
2012-09-29 06:16:34 +04:00
|
|
|
{
|
2015-03-06 21:54:10 +03:00
|
|
|
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
|
2012-09-29 06:16:34 +04:00
|
|
|
{
|
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();
|
|
|
|
if (scrollableRect.width < compSize.width) {
|
2013-12-13 21:23:47 +04:00
|
|
|
scrollableRect.x = std::max(0.f,
|
2014-03-28 18:36:47 +04:00
|
|
|
scrollableRect.x - (compSize.width - scrollableRect.width));
|
|
|
|
scrollableRect.width = compSize.width;
|
2013-12-13 21:23:47 +04:00
|
|
|
}
|
|
|
|
|
2014-03-28 18:36:47 +04:00
|
|
|
if (scrollableRect.height < compSize.height) {
|
2013-12-13 21:23:47 +04:00
|
|
|
scrollableRect.y = std::max(0.f,
|
2014-03-28 18:36:47 +04:00
|
|
|
scrollableRect.y - (compSize.height - scrollableRect.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
|
2013-06-26 17:54:49 +04:00
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
|
|
CSSRect CalculateCompositedRectInCssPixels() const
|
|
|
|
{
|
2016-06-07 01:16:06 +03:00
|
|
|
if (GetZoom() == CSSToParentLayerScale2D(0, 0)) {
|
|
|
|
return CSSRect(); // avoid division by zero
|
|
|
|
}
|
2014-11-10 22:35:11 +03:00
|
|
|
return mCompositionBounds / GetZoom();
|
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;
|
|
|
|
scrollRange.width = std::max(scrollRange.width - scrollPortSize.width, 0.0f);
|
|
|
|
scrollRange.height = std::max(scrollRange.height - scrollPortSize.height, 0.0f);
|
|
|
|
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)
|
2014-03-12 20:46:57 +04:00
|
|
|
{
|
2015-03-06 21:54:10 +03:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2014-03-28 16:21:19 +04:00
|
|
|
void CopyScrollInfoFrom(const FrameMetrics& aOther)
|
|
|
|
{
|
|
|
|
mScrollOffset = aOther.mScrollOffset;
|
|
|
|
mScrollGeneration = aOther.mScrollGeneration;
|
|
|
|
}
|
|
|
|
|
2014-07-10 22:52:40 +04:00
|
|
|
void CopySmoothScrollInfoFrom(const FrameMetrics& aOther)
|
|
|
|
{
|
|
|
|
mSmoothScrollOffset = aOther.mSmoothScrollOffset;
|
|
|
|
mScrollGeneration = aOther.mScrollGeneration;
|
|
|
|
mDoSmoothScroll = aOther.mDoSmoothScroll;
|
|
|
|
}
|
|
|
|
|
2016-04-13 17:21:13 +03:00
|
|
|
void UpdatePendingScrollInfo(const ScrollUpdateInfo& aInfo)
|
|
|
|
{
|
|
|
|
mScrollOffset = aInfo.mScrollOffset;
|
|
|
|
mScrollGeneration = aInfo.mScrollGeneration;
|
|
|
|
mScrollUpdateType = ePending;
|
|
|
|
}
|
|
|
|
|
2016-08-19 00:00:42 +03:00
|
|
|
void SetRepaintDrivenByUserAction(bool aUserAction)
|
|
|
|
{
|
|
|
|
mScrollUpdateType = aUserAction ? eUserAction : eNone;
|
|
|
|
}
|
|
|
|
|
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
|
2014-12-23 18:35:58 +03:00
|
|
|
{
|
|
|
|
return mDisplayPort;
|
|
|
|
}
|
|
|
|
|
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
|
2014-12-30 22:07:57 +03:00
|
|
|
{
|
|
|
|
return mCriticalDisplayPort;
|
|
|
|
}
|
|
|
|
|
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)
|
2014-08-24 03:09:10 +04:00
|
|
|
{
|
2015-06-08 23:01:26 +03:00
|
|
|
mIsRootContent = aIsRootContent;
|
2014-08-24 03:09:10 +04:00
|
|
|
}
|
|
|
|
|
2015-06-08 23:01:26 +03:00
|
|
|
bool IsRootContent() const
|
2014-08-24 03:09:10 +04:00
|
|
|
{
|
2015-06-08 23:01:26 +03:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
const CSSPoint& GetScrollOffset() const
|
|
|
|
{
|
|
|
|
return mScrollOffset;
|
|
|
|
}
|
|
|
|
|
2014-07-10 22:52:40 +04:00
|
|
|
void SetSmoothScrollOffset(const CSSPoint& aSmoothScrollDestination)
|
|
|
|
{
|
|
|
|
mSmoothScrollOffset = aSmoothScrollDestination;
|
|
|
|
}
|
|
|
|
|
|
|
|
const CSSPoint& GetSmoothScrollOffset() const
|
|
|
|
{
|
|
|
|
return mSmoothScrollOffset;
|
|
|
|
}
|
|
|
|
|
2015-03-06 21:54:10 +03:00
|
|
|
void SetZoom(const CSSToParentLayerScale2D& aZoom)
|
2014-03-12 20:46:57 +04:00
|
|
|
{
|
|
|
|
mZoom = aZoom;
|
|
|
|
}
|
|
|
|
|
2015-05-07 21:44:03 +03:00
|
|
|
const CSSToParentLayerScale2D& GetZoom() const
|
2014-03-12 20:46:57 +04:00
|
|
|
{
|
|
|
|
return mZoom;
|
|
|
|
}
|
|
|
|
|
2014-02-06 02:43:20 +04:00
|
|
|
void SetScrollOffsetUpdated(uint32_t aScrollGeneration)
|
|
|
|
{
|
2016-04-13 17:21:13 +03:00
|
|
|
mScrollUpdateType = eMainThread;
|
2014-02-06 02:43:20 +04:00
|
|
|
mScrollGeneration = aScrollGeneration;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
void SetScrollOffsetRestored(uint32_t aScrollGeneration)
|
|
|
|
{
|
|
|
|
mScrollUpdateType = eRestore;
|
|
|
|
mScrollGeneration = aScrollGeneration;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
{
|
2016-04-13 17:21:13 +03:00
|
|
|
return mScrollUpdateType != eNone;
|
2014-02-06 02:43:20 +04:00
|
|
|
}
|
|
|
|
|
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)
|
2014-03-22 01:48:08 +04:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-01-07 04:50:01 +03:00
|
|
|
void SetUseDisplayPortMargins(bool aValue)
|
2014-03-27 05:46:24 +04:00
|
|
|
{
|
2016-01-07 04:50:01 +03:00
|
|
|
mUseDisplayPortMargins = aValue;
|
2014-03-27 05:46:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool GetUseDisplayPortMargins() const
|
|
|
|
{
|
|
|
|
return mUseDisplayPortMargins;
|
|
|
|
}
|
|
|
|
|
2014-05-17 03:00:50 +04:00
|
|
|
uint32_t GetPresShellId() const
|
|
|
|
{
|
|
|
|
return mPresShellId;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetPresShellId(uint32_t aPresShellId)
|
|
|
|
{
|
|
|
|
mPresShellId = aPresShellId;
|
|
|
|
}
|
|
|
|
|
2014-08-23 07:18:56 +04:00
|
|
|
void SetViewport(const CSSRect& aViewport)
|
|
|
|
{
|
|
|
|
mViewport = aViewport;
|
|
|
|
}
|
|
|
|
|
|
|
|
const CSSRect& GetViewport() const
|
|
|
|
{
|
|
|
|
return mViewport;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2014-01-21 21:33:52 +04:00
|
|
|
private:
|
2016-01-07 04:50:01 +03:00
|
|
|
// A unique ID assigned to each scrollable frame.
|
|
|
|
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
|
|
|
|
// is just the root content document's root scroll frame (mIsRoot = true).
|
|
|
|
// 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
|
|
|
|
// same coordinate space as the reference frame for the scrolled frame.
|
|
|
|
//
|
|
|
|
// This is useful because, on mobile, the viewport and composition dimensions
|
|
|
|
// are not always the same. In this case, we calculate the displayport using
|
|
|
|
// an area bigger than the region we're compositing to. If we used the
|
|
|
|
// viewport dimensions to calculate the displayport, we'd run into situations
|
|
|
|
// where we're prerendering the wrong regions and the content may be clipped,
|
|
|
|
// or too much of it prerendered. If the composition dimensions are the same
|
|
|
|
// as the viewport dimensions, there is no need for this and we can just use
|
|
|
|
// the viewport instead.
|
|
|
|
//
|
|
|
|
// This value is valid for nested scrollable layers as well, and is still
|
|
|
|
// relative to the layer tree origin. This value is provided by Gecko at
|
|
|
|
// layout/paint time.
|
|
|
|
ParentLayerRect mCompositionBounds;
|
|
|
|
|
2014-12-23 18:35:58 +03:00
|
|
|
// The area of a frame's contents that has been painted, relative to
|
|
|
|
// mCompositionBounds.
|
|
|
|
//
|
|
|
|
// Note that this is structured in such a way that it doesn't depend on the
|
|
|
|
// method layout uses to scroll content.
|
|
|
|
//
|
|
|
|
// May be larger or smaller than |mScrollableRect|.
|
|
|
|
//
|
|
|
|
// To pre-render a margin of 100 CSS pixels around the window,
|
|
|
|
// { x = -100, y = - 100,
|
|
|
|
// width = window.innerWidth + 200, height = window.innerHeight + 200 }
|
|
|
|
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
|
|
|
|
// coordinate space than |mViewport| and |mDisplayPort|. Note also that this
|
|
|
|
// coordinate system is understood by window.scrollTo().
|
2014-12-27 20:48:27 +03:00
|
|
|
//
|
|
|
|
// This is valid on any layer unless it has no content.
|
|
|
|
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
|
|
|
|
// for subframes (mIsRoot = false). (The same applies to other scales that
|
|
|
|
// "inherit" the 2D-ness of this one, such as mZoom.)
|
|
|
|
LayoutDeviceToLayerScale2D mCumulativeResolution;
|
2014-12-19 03:33:18 +03:00
|
|
|
|
2014-01-21 21:33:52 +04:00
|
|
|
// New fields from now on should be made private and old fields should
|
|
|
|
// be refactored to be private.
|
|
|
|
|
2014-12-18 01:14:05 +03:00
|
|
|
// The conversion factor between CSS pixels and device pixels for this frame.
|
|
|
|
// This can vary based on a variety of things, such as reflowing-zoom. The
|
|
|
|
// conversion factor for device pixels to layers pixels is just the
|
|
|
|
// resolution.
|
|
|
|
CSSToLayoutDeviceScale mDevPixelsPerCSSPixel;
|
|
|
|
|
2014-03-13 10:34:34 +04:00
|
|
|
// The position of the top-left of the CSS viewport, relative to the document
|
|
|
|
// (or the document relative to the viewport, if that helps understand it).
|
|
|
|
//
|
|
|
|
// Thus it is relative to the document. It is in the same coordinate space as
|
|
|
|
// |mScrollableRect|, but a different coordinate space than |mViewport| and
|
|
|
|
// |mDisplayPort|.
|
|
|
|
//
|
|
|
|
// It is required that the rect:
|
|
|
|
// { x = mScrollOffset.x, y = mScrollOffset.y,
|
|
|
|
// width = mCompositionBounds.x / mResolution.scale,
|
|
|
|
// height = mCompositionBounds.y / mResolution.scale }
|
|
|
|
// Be within |mScrollableRect|.
|
|
|
|
//
|
|
|
|
// This is valid for any layer, but is always relative to this frame and
|
|
|
|
// not any parents, regardless of parent transforms.
|
|
|
|
CSSPoint mScrollOffset;
|
|
|
|
|
2014-03-12 20:46:57 +04:00
|
|
|
// The "user zoom". Content is painted by gecko at mResolution * 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
|
|
|
|
|
|
|
// The CSS viewport, which is the dimensions we're using to constrain the
|
|
|
|
// <html> element of this frame, relative to the top-left of the layer. Note
|
|
|
|
// that its offset is structured in such a way that it doesn't depend on the
|
|
|
|
// method layout uses to scroll content.
|
|
|
|
//
|
|
|
|
// This is mainly useful on the root layer, however nested iframes can have
|
|
|
|
// their own viewport, which will just be the size of the window of the
|
|
|
|
// iframe. For layers that don't correspond to a document, this metric is
|
|
|
|
// meaningless and invalid.
|
|
|
|
CSSRect mViewport;
|
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
|
|
|
|
2016-01-16 00:19:59 +03:00
|
|
|
// The time at which the APZC last requested a repaint for this scrollframe.
|
|
|
|
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;
|
|
|
|
|
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
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
// If this is true then we use the display port margins on this metrics,
|
|
|
|
// otherwise use the display port rect.
|
2016-01-07 04:50:01 +03:00
|
|
|
bool mUseDisplayPortMargins:1;
|
2016-01-07 04:50:01 +03:00
|
|
|
|
2015-12-21 17:36:36 +03:00
|
|
|
// Whether or not this frame has a "scroll info layer" to capture events.
|
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
|
|
|
|
// The ParamTraits specialization in GfxMessageUtils.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 {
|
|
|
|
ScrollSnapInfo()
|
|
|
|
: mScrollSnapTypeX(NS_STYLE_SCROLL_SNAP_TYPE_NONE)
|
|
|
|
, mScrollSnapTypeY(NS_STYLE_SCROLL_SNAP_TYPE_NONE)
|
|
|
|
{}
|
|
|
|
|
2016-04-26 03:58:11 +03:00
|
|
|
bool operator==(const ScrollSnapInfo& aOther) const
|
|
|
|
{
|
|
|
|
return mScrollSnapTypeX == aOther.mScrollSnapTypeX &&
|
|
|
|
mScrollSnapTypeY == aOther.mScrollSnapTypeY &&
|
|
|
|
mScrollSnapIntervalX == aOther.mScrollSnapIntervalX &&
|
|
|
|
mScrollSnapIntervalY == aOther.mScrollSnapIntervalY &&
|
|
|
|
mScrollSnapDestination == aOther.mScrollSnapDestination &&
|
|
|
|
mScrollSnapCoordinates == aOther.mScrollSnapCoordinates;
|
|
|
|
}
|
|
|
|
|
2017-06-15 10:52:34 +03:00
|
|
|
bool HasScrollSnapping() const
|
|
|
|
{
|
|
|
|
return mScrollSnapTypeY != NS_STYLE_SCROLL_SNAP_TYPE_NONE ||
|
|
|
|
mScrollSnapTypeX != NS_STYLE_SCROLL_SNAP_TYPE_NONE;
|
|
|
|
}
|
|
|
|
|
2016-03-19 03:07:27 +03:00
|
|
|
// The scroll frame's scroll-snap-type.
|
|
|
|
// One of NS_STYLE_SCROLL_SNAP_{NONE, MANDATORY, PROXIMITY}.
|
|
|
|
uint8_t mScrollSnapTypeX;
|
|
|
|
uint8_t mScrollSnapTypeY;
|
|
|
|
|
|
|
|
// 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
|
|
|
|
// shipping the raw nsStyleCoord::CalcValue over IPC).
|
|
|
|
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;
|
|
|
|
};
|
2016-03-29 02:14:52 +03:00
|
|
|
|
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
|
|
|
/**
|
|
|
|
* Metadata about a scroll frame that's stored in the layer tree for use by
|
|
|
|
* the compositor (including APZ). 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. sent
|
|
|
|
* over IPC for every repaint request for every active scroll frame).
|
|
|
|
*/
|
|
|
|
struct ScrollMetadata {
|
|
|
|
friend struct IPC::ParamTraits<mozilla::layers::ScrollMetadata>;
|
2016-04-27 23:06:34 +03:00
|
|
|
|
|
|
|
typedef FrameMetrics::ViewID ViewID;
|
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()
|
2016-04-27 23:06:34 +03:00
|
|
|
, mScrollParentId(FrameMetrics::NULL_SCROLL_ID)
|
|
|
|
, 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)
|
|
|
|
, mAllowVerticalScrollWithWheel(false)
|
|
|
|
, mIsLayersIdRoot(false)
|
|
|
|
, mUsesContainerScrolling(false)
|
|
|
|
, mForceDisableApz(false)
|
2016-03-29 02:14:52 +03:00
|
|
|
{}
|
|
|
|
|
|
|
|
bool operator==(const ScrollMetadata& aOther) const
|
|
|
|
{
|
|
|
|
return mMetrics == aOther.mMetrics &&
|
2016-04-26 03:58:11 +03:00
|
|
|
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 &&
|
|
|
|
mAllowVerticalScrollWithWheel == aOther.mAllowVerticalScrollWithWheel &&
|
|
|
|
mIsLayersIdRoot == aOther.mIsLayersIdRoot &&
|
|
|
|
mUsesContainerScrolling == aOther.mUsesContainerScrolling &&
|
|
|
|
mForceDisableApz == aOther.mForceDisableApz;
|
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) {
|
|
|
|
mSnapInfo = Move(aSnapInfo);
|
|
|
|
}
|
|
|
|
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;
|
2016-03-29 02:14:52 +03:00
|
|
|
}
|
2016-04-29 23:14:21 +03:00
|
|
|
bool HasScrollClip() const {
|
|
|
|
return mScrollClip.isSome();
|
2016-03-29 02:14:52 +03:00
|
|
|
}
|
2016-04-29 23:14:21 +03:00
|
|
|
const LayerClip& ScrollClip() const {
|
|
|
|
return mScrollClip.ref();
|
|
|
|
}
|
|
|
|
LayerClip& ScrollClip() {
|
|
|
|
return mScrollClip.ref();
|
2016-03-29 02:14:52 +03:00
|
|
|
}
|
2016-04-29 23:14:21 +03:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
bool AllowVerticalScrollWithWheel() const {
|
|
|
|
return mAllowVerticalScrollWithWheel;
|
|
|
|
}
|
|
|
|
void SetAllowVerticalScrollWithWheel(bool aValue) {
|
|
|
|
mAllowVerticalScrollWithWheel = aValue;
|
|
|
|
}
|
|
|
|
void SetIsLayersIdRoot(bool aValue) {
|
|
|
|
mIsLayersIdRoot = aValue;
|
|
|
|
}
|
|
|
|
bool IsLayersIdRoot() const {
|
|
|
|
return mIsLayersIdRoot;
|
|
|
|
}
|
|
|
|
// Implemented out of line because the implementation needs gfxPrefs.h
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
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 or not the frame can be vertically scrolled with a mouse wheel.
|
|
|
|
bool mAllowVerticalScrollWithWheel: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;
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
|
|
|
// WARNING!!!!
|
|
|
|
//
|
|
|
|
// When adding new fields to ScrollMetadata, the following places should be
|
|
|
|
// updated to include them (as needed):
|
|
|
|
// ScrollMetadata::operator ==
|
|
|
|
// AsyncPanZoomController::NotifyLayersUpdated
|
|
|
|
// The ParamTraits specialization in GfxMessageUtils.h
|
|
|
|
//
|
|
|
|
// Please add new fields above this comment.
|
2016-03-29 02:14:52 +03:00
|
|
|
};
|
|
|
|
|
2013-11-13 22:20:31 +04:00
|
|
|
/**
|
|
|
|
* This class allows us to uniquely identify a scrollable layer. The
|
|
|
|
* mLayersId identifies the layer tree (corresponding to a child process
|
|
|
|
* and/or tab) that the scrollable layer belongs to. The mPresShellId
|
|
|
|
* is a temporal identifier (corresponding to the document loaded that
|
|
|
|
* contains the scrollable layer, which may change over time). The
|
|
|
|
* mScrollId corresponds to the actual frame that is scrollable.
|
|
|
|
*/
|
|
|
|
struct ScrollableLayerGuid {
|
|
|
|
uint64_t mLayersId;
|
|
|
|
uint32_t mPresShellId;
|
|
|
|
FrameMetrics::ViewID mScrollId;
|
|
|
|
|
|
|
|
ScrollableLayerGuid()
|
|
|
|
: mLayersId(0)
|
|
|
|
, mPresShellId(0)
|
|
|
|
, mScrollId(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ScrollableLayerGuid(uint64_t aLayersId, uint32_t aPresShellId,
|
|
|
|
FrameMetrics::ViewID aScrollId)
|
|
|
|
: mLayersId(aLayersId)
|
|
|
|
, mPresShellId(aPresShellId)
|
|
|
|
, mScrollId(aScrollId)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ScrollableLayerGuid(uint64_t aLayersId, const FrameMetrics& aMetrics)
|
|
|
|
: mLayersId(aLayersId)
|
2014-05-17 03:00:50 +04:00
|
|
|
, mPresShellId(aMetrics.GetPresShellId())
|
2014-03-22 01:48:08 +04:00
|
|
|
, mScrollId(aMetrics.GetScrollId())
|
2013-11-13 22:20:31 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-08-11 21:32:51 +04:00
|
|
|
ScrollableLayerGuid(const ScrollableLayerGuid& other)
|
|
|
|
: mLayersId(other.mLayersId)
|
|
|
|
, mPresShellId(other.mPresShellId)
|
|
|
|
, mScrollId(other.mScrollId)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-11-13 22:20:31 +04:00
|
|
|
~ScrollableLayerGuid()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const ScrollableLayerGuid& other) const
|
|
|
|
{
|
|
|
|
return mLayersId == other.mLayersId
|
|
|
|
&& mPresShellId == other.mPresShellId
|
|
|
|
&& mScrollId == other.mScrollId;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=(const ScrollableLayerGuid& other) const
|
|
|
|
{
|
|
|
|
return !(*this == other);
|
|
|
|
}
|
2014-08-20 05:17:08 +04:00
|
|
|
|
|
|
|
bool operator<(const ScrollableLayerGuid& other) const
|
|
|
|
{
|
|
|
|
if (mLayersId < other.mLayersId) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (mLayersId == other.mLayersId) {
|
|
|
|
if (mPresShellId < other.mPresShellId) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (mPresShellId == other.mPresShellId) {
|
|
|
|
return mScrollId < other.mScrollId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2016-03-19 04:38:57 +03:00
|
|
|
|
2017-07-04 07:56:47 +03:00
|
|
|
PLDHashNumber Hash() const
|
2016-03-19 04:38:57 +03:00
|
|
|
{
|
|
|
|
return HashGeneric(mLayersId, mPresShellId, mScrollId);
|
|
|
|
}
|
2013-11-13 22:20:31 +04:00
|
|
|
};
|
|
|
|
|
2014-01-23 03:44:59 +04:00
|
|
|
template <int LogLevel>
|
|
|
|
gfx::Log<LogLevel>& operator<<(gfx::Log<LogLevel>& log, const ScrollableLayerGuid& aGuid) {
|
|
|
|
return log << '(' << aGuid.mLayersId << ',' << aGuid.mPresShellId << ',' << aGuid.mScrollId << ')';
|
|
|
|
}
|
|
|
|
|
2014-01-06 22:26:44 +04:00
|
|
|
struct ZoomConstraints {
|
|
|
|
bool mAllowZoom;
|
2014-02-25 04:22:45 +04:00
|
|
|
bool mAllowDoubleTapZoom;
|
2014-11-10 22:35:11 +03:00
|
|
|
CSSToParentLayerScale mMinZoom;
|
|
|
|
CSSToParentLayerScale mMaxZoom;
|
2014-01-06 22:26:44 +04:00
|
|
|
|
|
|
|
ZoomConstraints()
|
|
|
|
: mAllowZoom(true)
|
2014-02-25 04:22:45 +04:00
|
|
|
, mAllowDoubleTapZoom(true)
|
2014-01-06 22:26:44 +04:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(ZoomConstraints);
|
|
|
|
}
|
|
|
|
|
|
|
|
ZoomConstraints(bool aAllowZoom,
|
2014-02-25 04:22:45 +04:00
|
|
|
bool aAllowDoubleTapZoom,
|
2014-11-10 22:35:11 +03:00
|
|
|
const CSSToParentLayerScale& aMinZoom,
|
|
|
|
const CSSToParentLayerScale& aMaxZoom)
|
2014-01-06 22:26:44 +04:00
|
|
|
: mAllowZoom(aAllowZoom)
|
2014-02-25 04:22:45 +04:00
|
|
|
, mAllowDoubleTapZoom(aAllowDoubleTapZoom)
|
2014-01-06 22:26:44 +04:00
|
|
|
, mMinZoom(aMinZoom)
|
|
|
|
, mMaxZoom(aMaxZoom)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(ZoomConstraints);
|
|
|
|
}
|
|
|
|
|
2014-08-11 20:35:17 +04:00
|
|
|
ZoomConstraints(const ZoomConstraints& other)
|
|
|
|
: mAllowZoom(other.mAllowZoom)
|
|
|
|
, mAllowDoubleTapZoom(other.mAllowDoubleTapZoom)
|
|
|
|
, mMinZoom(other.mMinZoom)
|
|
|
|
, mMaxZoom(other.mMaxZoom)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(ZoomConstraints);
|
|
|
|
}
|
|
|
|
|
2014-01-06 22:26:44 +04:00
|
|
|
~ZoomConstraints()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(ZoomConstraints);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const ZoomConstraints& other) const
|
|
|
|
{
|
|
|
|
return mAllowZoom == other.mAllowZoom
|
2014-02-25 04:22:45 +04:00
|
|
|
&& mAllowDoubleTapZoom == other.mAllowDoubleTapZoom
|
2014-01-06 22:26:44 +04:00
|
|
|
&& mMinZoom == other.mMinZoom
|
|
|
|
&& mMaxZoom == other.mMaxZoom;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=(const ZoomConstraints& other) const
|
|
|
|
{
|
|
|
|
return !(*this == other);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-05-27 02:41:13 +03:00
|
|
|
struct ScrollableLayerGuidHash
|
|
|
|
{
|
|
|
|
std::size_t operator()(const ScrollableLayerGuid& Guid) const
|
|
|
|
{
|
|
|
|
return Guid.Hash();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-06-17 19:32:41 +03:00
|
|
|
typedef Maybe<ZoomConstraints> MaybeZoomConstraints;
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|
2012-07-31 04:42:26 +04:00
|
|
|
|
|
|
|
#endif /* GFX_FRAMEMETRICS_H */
|