2012-07-31 00:42:26 +00: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-11 23:17:23 +00:00
|
|
|
#include <stdint.h> // for uint32_t, uint64_t
|
|
|
|
#include "Units.h" // for CSSRect, CSSPixel, etc
|
|
|
|
#include "mozilla/gfx/BasePoint.h" // for BasePoint
|
|
|
|
#include "mozilla/gfx/Rect.h" // for RoundedIn
|
|
|
|
#include "mozilla/gfx/ScaleFactor.h" // for ScaleFactor
|
2014-01-22 23:44:59 +00:00
|
|
|
#include "mozilla/gfx/Logging.h" // for Log
|
2012-07-31 00:42:26 +00:00
|
|
|
|
2014-01-21 17:33:52 +00:00
|
|
|
namespace IPC {
|
|
|
|
template <typename T> struct ParamTraits;
|
|
|
|
} // namespace IPC
|
|
|
|
|
2012-07-31 00:42:26 +00:00
|
|
|
namespace mozilla {
|
|
|
|
|
2014-03-10 21:56:59 +00:00
|
|
|
// The layer coordinates of the parent layer.
|
|
|
|
// This can be arrived at in two ways:
|
|
|
|
// - Start with the CSS coordinates of the parent layer (note: NOT the
|
|
|
|
// CSS coordinates of the current layer, that will give you the wrong
|
|
|
|
// answer), multiply by the device scale and the resolutions of all
|
|
|
|
// layers from the root down to and including the parent.
|
|
|
|
// - Start with global screen coordinates and unapply all CSS and async
|
|
|
|
// transforms from the root down to and including the parent.
|
|
|
|
// It's helpful to look at https://wiki.mozilla.org/Platform/GFX/APZ#Coordinate_systems
|
|
|
|
// to get a picture of how the various coordinate systems relate to each other.
|
2013-09-05 22:26:59 +00:00
|
|
|
struct ParentLayerPixel {};
|
|
|
|
|
2014-06-10 16:43:52 +00:00
|
|
|
template<> struct IsPixel<ParentLayerPixel> : TrueType {};
|
|
|
|
|
2014-07-04 12:12:41 +00:00
|
|
|
typedef gfx::MarginTyped<ParentLayerPixel> ParentLayerMargin;
|
2014-03-10 21:56:59 +00:00
|
|
|
typedef gfx::PointTyped<ParentLayerPixel> ParentLayerPoint;
|
|
|
|
typedef gfx::RectTyped<ParentLayerPixel> ParentLayerRect;
|
|
|
|
typedef gfx::SizeTyped<ParentLayerPixel> ParentLayerSize;
|
|
|
|
|
|
|
|
typedef gfx::IntMarginTyped<ParentLayerPixel> ParentLayerIntMargin;
|
|
|
|
typedef gfx::IntPointTyped<ParentLayerPixel> ParentLayerIntPoint;
|
|
|
|
typedef gfx::IntRectTyped<ParentLayerPixel> ParentLayerIntRect;
|
|
|
|
typedef gfx::IntSizeTyped<ParentLayerPixel> ParentLayerIntSize;
|
|
|
|
|
|
|
|
typedef gfx::ScaleFactor<CSSPixel, ParentLayerPixel> CSSToParentLayerScale;
|
2013-09-05 22:26:59 +00:00
|
|
|
typedef gfx::ScaleFactor<LayoutDevicePixel, ParentLayerPixel> LayoutDeviceToParentLayerScale;
|
2014-03-10 21:56:59 +00:00
|
|
|
typedef gfx::ScaleFactor<ScreenPixel, ParentLayerPixel> ScreenToParentLayerScale;
|
2013-09-05 22:26:59 +00:00
|
|
|
|
2014-03-10 21:56:59 +00:00
|
|
|
typedef gfx::ScaleFactor<ParentLayerPixel, LayerPixel> ParentLayerToLayerScale;
|
2013-09-05 22:26:59 +00:00
|
|
|
typedef gfx::ScaleFactor<ParentLayerPixel, ScreenPixel> ParentLayerToScreenScale;
|
|
|
|
|
2014-03-10 21:56:59 +00:00
|
|
|
|
|
|
|
namespace layers {
|
|
|
|
|
2012-07-31 00:42:26 +00: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.
|
2014-05-24 01:08:51 +00:00
|
|
|
*
|
|
|
|
* Note that the FrameMetrics struct is sometimes stored in shared
|
|
|
|
* memory and shared across processes, so it should be a "Plain Old
|
|
|
|
* Data (POD)" type with no members that use dynamic memory.
|
2012-07-31 00:42:26 +00:00
|
|
|
*/
|
2013-05-29 21:59:24 +00:00
|
|
|
struct FrameMetrics {
|
2014-01-21 17:33:52 +00:00
|
|
|
friend struct IPC::ParamTraits<mozilla::layers::FrameMetrics>;
|
2012-07-31 00:42:26 +00:00
|
|
|
public:
|
|
|
|
// We use IDs to identify frames across processes.
|
2012-08-22 15:56:38 +00:00
|
|
|
typedef uint64_t ViewID;
|
2012-07-31 00:42:26 +00:00
|
|
|
static const ViewID NULL_SCROLL_ID; // This container layer does not scroll.
|
2013-11-22 19:45:50 +00:00
|
|
|
static const ViewID START_SCROLL_ID = 2; // This is the ID that scrolling subframes
|
2012-07-31 00:42:26 +00:00
|
|
|
// will begin at.
|
|
|
|
|
|
|
|
FrameMetrics()
|
2012-09-29 02:16:34 +00:00
|
|
|
: mCompositionBounds(0, 0, 0, 0)
|
|
|
|
, mDisplayPort(0, 0, 0, 0)
|
2012-11-21 22:34:18 +00:00
|
|
|
, mCriticalDisplayPort(0, 0, 0, 0)
|
2012-09-29 02:16:34 +00:00
|
|
|
, mScrollableRect(0, 0, 0, 0)
|
2013-06-21 21:03:56 +00:00
|
|
|
, mResolution(1)
|
2013-09-05 22:26:59 +00:00
|
|
|
, mCumulativeResolution(1)
|
2014-03-10 21:56:59 +00:00
|
|
|
, mTransformScale(1)
|
2012-09-29 02:16:34 +00:00
|
|
|
, mDevPixelsPerCSSPixel(1)
|
2014-01-21 17:33:52 +00:00
|
|
|
, mMayHaveTouchListeners(false)
|
2014-06-03 07:08:54 +00:00
|
|
|
, mMayHaveTouchCaret(false)
|
2013-11-09 00:07:00 +00:00
|
|
|
, mIsRoot(false)
|
2013-09-23 19:09:48 +00:00
|
|
|
, mHasScrollgrab(false)
|
2014-03-21 21:48:08 +00:00
|
|
|
, mScrollId(NULL_SCROLL_ID)
|
2014-03-13 06:34:34 +00:00
|
|
|
, mScrollOffset(0, 0)
|
2014-03-12 16:46:57 +00:00
|
|
|
, mZoom(1)
|
2014-02-05 22:43:20 +00:00
|
|
|
, mUpdateScrollOffset(false)
|
|
|
|
, mScrollGeneration(0)
|
2014-03-26 23:24:25 +00:00
|
|
|
, mRootCompositionSize(0, 0)
|
2014-03-27 01:46:24 +00:00
|
|
|
, mDisplayPortMargins(0, 0, 0, 0)
|
|
|
|
, mUseDisplayPortMargins(false)
|
2014-05-16 23:00:50 +00:00
|
|
|
, mPresShellId(-1)
|
2014-08-23 03:18:56 +00:00
|
|
|
, mViewport(0, 0, 0, 0)
|
2012-07-31 00:42:26 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
// Default copy ctor and operator= are fine
|
|
|
|
|
|
|
|
bool operator==(const FrameMetrics& aOther) const
|
|
|
|
{
|
2012-10-03 23:51:38 +00:00
|
|
|
return mCompositionBounds.IsEqualEdges(aOther.mCompositionBounds) &&
|
2014-03-26 23:24:25 +00:00
|
|
|
mRootCompositionSize == aOther.mRootCompositionSize &&
|
2012-10-03 23:51:38 +00:00
|
|
|
mDisplayPort.IsEqualEdges(aOther.mDisplayPort) &&
|
2014-03-27 01:46:24 +00:00
|
|
|
mDisplayPortMargins == aOther.mDisplayPortMargins &&
|
|
|
|
mUseDisplayPortMargins == aOther.mUseDisplayPortMargins &&
|
2012-11-21 22:34:18 +00:00
|
|
|
mCriticalDisplayPort.IsEqualEdges(aOther.mCriticalDisplayPort) &&
|
2012-10-03 23:51:38 +00:00
|
|
|
mViewport.IsEqualEdges(aOther.mViewport) &&
|
|
|
|
mScrollableRect.IsEqualEdges(aOther.mScrollableRect) &&
|
|
|
|
mResolution == aOther.mResolution &&
|
2013-09-05 22:26:59 +00:00
|
|
|
mCumulativeResolution == aOther.mCumulativeResolution &&
|
2012-10-03 23:51:38 +00:00
|
|
|
mDevPixelsPerCSSPixel == aOther.mDevPixelsPerCSSPixel &&
|
2013-05-24 01:43:36 +00:00
|
|
|
mMayHaveTouchListeners == aOther.mMayHaveTouchListeners &&
|
2014-06-03 07:08:54 +00:00
|
|
|
mMayHaveTouchCaret == aOther.mMayHaveTouchCaret &&
|
2013-11-09 00:07:00 +00:00
|
|
|
mPresShellId == aOther.mPresShellId &&
|
2013-12-16 17:04:45 +00:00
|
|
|
mIsRoot == aOther.mIsRoot &&
|
2014-03-21 21:48:08 +00:00
|
|
|
mScrollId == aOther.mScrollId &&
|
2014-03-13 06:34:34 +00:00
|
|
|
mScrollOffset == aOther.mScrollOffset &&
|
2014-01-21 17:33:52 +00:00
|
|
|
mHasScrollgrab == aOther.mHasScrollgrab &&
|
2013-12-16 17:04:45 +00:00
|
|
|
mUpdateScrollOffset == aOther.mUpdateScrollOffset;
|
2012-07-31 00:42:26 +00:00
|
|
|
}
|
|
|
|
bool operator!=(const FrameMetrics& aOther) const
|
|
|
|
{
|
|
|
|
return !operator==(aOther);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsDefault() const
|
|
|
|
{
|
2013-05-24 01:43:36 +00:00
|
|
|
FrameMetrics def;
|
|
|
|
|
|
|
|
def.mPresShellId = mPresShellId;
|
|
|
|
return (def == *this);
|
2012-07-31 00:42:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool IsRootScrollable() const
|
|
|
|
{
|
2013-11-09 00:07:00 +00:00
|
|
|
return mIsRoot;
|
2012-07-31 00:42:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool IsScrollable() const
|
|
|
|
{
|
|
|
|
return mScrollId != NULL_SCROLL_ID;
|
|
|
|
}
|
|
|
|
|
2013-06-21 21:03:56 +00:00
|
|
|
CSSToLayerScale LayersPixelsPerCSSPixel() const
|
2012-09-29 02:16:34 +00:00
|
|
|
{
|
2013-09-05 22:26:59 +00:00
|
|
|
return mCumulativeResolution * mDevPixelsPerCSSPixel;
|
2012-09-29 02:16:34 +00:00
|
|
|
}
|
|
|
|
|
2013-06-21 21:03:56 +00:00
|
|
|
LayerPoint GetScrollOffsetInLayerPixels() const
|
2012-09-29 02:16:34 +00:00
|
|
|
{
|
2014-03-13 06:34:34 +00:00
|
|
|
return GetScrollOffset() * LayersPixelsPerCSSPixel();
|
2012-09-29 02:16:34 +00:00
|
|
|
}
|
|
|
|
|
2013-09-05 22:26:59 +00:00
|
|
|
LayoutDeviceToParentLayerScale GetParentResolution() const
|
|
|
|
{
|
|
|
|
return mCumulativeResolution / mResolution;
|
|
|
|
}
|
|
|
|
|
2013-12-13 17:23:47 +00: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 14:36:47 +00:00
|
|
|
CSSSize compSize = CalculateCompositedSizeInCssPixels();
|
|
|
|
if (scrollableRect.width < compSize.width) {
|
2013-12-13 17:23:47 +00:00
|
|
|
scrollableRect.x = std::max(0.f,
|
2014-03-28 14:36:47 +00:00
|
|
|
scrollableRect.x - (compSize.width - scrollableRect.width));
|
|
|
|
scrollableRect.width = compSize.width;
|
2013-12-13 17:23:47 +00:00
|
|
|
}
|
|
|
|
|
2014-03-28 14:36:47 +00:00
|
|
|
if (scrollableRect.height < compSize.height) {
|
2013-12-13 17:23:47 +00:00
|
|
|
scrollableRect.y = std::max(0.f,
|
2014-03-28 14:36:47 +00:00
|
|
|
scrollableRect.y - (compSize.height - scrollableRect.height));
|
|
|
|
scrollableRect.height = compSize.height;
|
2013-12-13 17:23:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return scrollableRect;
|
|
|
|
}
|
|
|
|
|
2014-03-10 21:56:59 +00:00
|
|
|
// Return the scale factor needed to fit the viewport
|
|
|
|
// into its composition bounds.
|
2013-06-26 13:53:51 +00:00
|
|
|
CSSToScreenScale CalculateIntrinsicScale() const
|
|
|
|
{
|
2014-05-29 17:20:02 +00:00
|
|
|
return CSSToScreenScale(
|
2014-07-04 12:12:41 +00:00
|
|
|
std::max(mCompositionBounds.width / mViewport.width,
|
|
|
|
mCompositionBounds.height / mViewport.height));
|
2013-06-26 13:53:51 +00:00
|
|
|
}
|
|
|
|
|
2014-03-10 21:56:59 +00:00
|
|
|
// Return the scale factor for converting from CSS pixels (for this layer)
|
|
|
|
// to layer pixels of our parent layer. Much as mZoom is used to interface
|
|
|
|
// between inputs we get in screen pixels and quantities in CSS pixels,
|
|
|
|
// this is used to interface between mCompositionBounds and quantities
|
|
|
|
// in CSS pixels.
|
|
|
|
CSSToParentLayerScale GetZoomToParent() const
|
|
|
|
{
|
|
|
|
return mZoom * mTransformScale;
|
|
|
|
}
|
|
|
|
|
2014-03-28 14:36:47 +00:00
|
|
|
CSSSize CalculateCompositedSizeInCssPixels() const
|
2013-06-26 13:54:49 +00:00
|
|
|
{
|
2014-03-28 14:36:47 +00:00
|
|
|
return mCompositionBounds.Size() / GetZoomToParent();
|
|
|
|
}
|
|
|
|
|
|
|
|
CSSRect CalculateCompositedRectInCssPixels() const
|
|
|
|
{
|
|
|
|
return mCompositionBounds / GetZoomToParent();
|
2013-06-26 13:54:49 +00:00
|
|
|
}
|
|
|
|
|
2014-05-06 18:29:44 +00: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;
|
|
|
|
}
|
|
|
|
|
2014-03-13 06:34:34 +00:00
|
|
|
void ScrollBy(const CSSPoint& aPoint)
|
|
|
|
{
|
|
|
|
mScrollOffset += aPoint;
|
|
|
|
}
|
|
|
|
|
2014-03-12 16:46:57 +00:00
|
|
|
void ZoomBy(float aFactor)
|
|
|
|
{
|
|
|
|
mZoom.scale *= aFactor;
|
|
|
|
}
|
|
|
|
|
2014-03-28 12:21:19 +00:00
|
|
|
void CopyScrollInfoFrom(const FrameMetrics& aOther)
|
|
|
|
{
|
|
|
|
mScrollOffset = aOther.mScrollOffset;
|
|
|
|
mScrollGeneration = aOther.mScrollGeneration;
|
|
|
|
}
|
|
|
|
|
2012-09-29 02:16:34 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// The following metrics are all in widget space/device pixels.
|
|
|
|
//
|
|
|
|
|
2013-10-08 21:13:11 +00:00
|
|
|
// This is the area within the widget that we're compositing to. It is relative
|
|
|
|
// to the layer tree origin.
|
2012-09-29 02:16:34 +00:00
|
|
|
//
|
|
|
|
// 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,
|
2013-10-08 21:13:11 +00:00
|
|
|
// 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
|
2012-09-29 02:16:34 +00:00
|
|
|
// instead.
|
|
|
|
//
|
2013-10-08 21:13:11 +00:00
|
|
|
// This value is valid for nested scrollable layers as well, and is still
|
2013-11-08 16:23:47 +00:00
|
|
|
// relative to the layer tree origin. This value is provided by Gecko at
|
|
|
|
// layout/paint time.
|
2014-07-04 12:12:41 +00:00
|
|
|
ParentLayerRect mCompositionBounds;
|
2012-09-29 02:16:34 +00:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// The following metrics are all in CSS pixels. They are not in any uniform
|
|
|
|
// space, so each is explained separately.
|
|
|
|
//
|
|
|
|
|
|
|
|
// The area of a frame's contents that has been painted, relative to the
|
|
|
|
// viewport. It is in the same coordinate space as |mViewport|. For example,
|
|
|
|
// if it is at 0,0, then it's at the same place at the viewport, which is at
|
|
|
|
// the top-left in the layer, and at the same place as the scroll offset of
|
|
|
|
// the document.
|
|
|
|
//
|
|
|
|
// 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,
|
2013-07-03 13:04:10 +00:00
|
|
|
// width = window.innerWidth + 200, height = window.innerHeight + 200 }
|
2013-06-10 13:05:42 +00:00
|
|
|
CSSRect mDisplayPort;
|
2012-09-29 02:16:34 +00:00
|
|
|
|
2012-11-21 22:34:18 +00: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.
|
2013-06-10 13:05:42 +00:00
|
|
|
CSSRect mCriticalDisplayPort;
|
2012-11-21 22:34:18 +00:00
|
|
|
|
2012-09-29 02:16:34 +00:00
|
|
|
// The scrollable bounds of a frame. This is determined by reflow.
|
2013-08-21 11:46:05 +00:00
|
|
|
// 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.
|
2012-09-29 02:16:34 +00:00
|
|
|
//
|
|
|
|
// This is relative to the document. It 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().
|
|
|
|
//
|
|
|
|
// This is valid on any layer unless it has no content.
|
2013-06-10 13:05:43 +00:00
|
|
|
CSSRect mScrollableRect;
|
2012-07-31 00:42:26 +00:00
|
|
|
|
2012-09-29 02:16:38 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// The following metrics are dimensionless.
|
|
|
|
//
|
|
|
|
|
2013-11-08 16:23:46 +00:00
|
|
|
// The incremental resolution that the current frame has been painted at
|
|
|
|
// relative to the parent frame's resolution. This information is provided
|
|
|
|
// by Gecko at layout/paint time.
|
2013-09-05 22:26:59 +00:00
|
|
|
ParentLayerToLayerScale mResolution;
|
|
|
|
|
|
|
|
// The cumulative resolution that the current frame has been painted at.
|
|
|
|
// This is the product of our mResolution and the mResolutions of our parent frames.
|
2013-11-08 16:23:46 +00:00
|
|
|
// This information is provided by Gecko at layout/paint time.
|
2013-09-05 22:26:59 +00:00
|
|
|
LayoutDeviceToLayerScale mCumulativeResolution;
|
2012-08-22 04:37:06 +00:00
|
|
|
|
2014-03-10 21:56:59 +00:00
|
|
|
// The conversion factor between local screen pixels (the coordinate
|
|
|
|
// system in which APZCs receive input events) and our parent layer's
|
|
|
|
// layer pixels (the coordinate system of mCompositionBounds).
|
|
|
|
// This consists of the scale of the local CSS transform and the
|
|
|
|
// nontransient async transform.
|
|
|
|
// TODO: APZ does not currently work well if there is a CSS transform
|
|
|
|
// on the layer being scrolled that's not just a scale that's
|
|
|
|
// the same in both directions. When we fix this, mTransformScale
|
|
|
|
// will probably need to turn into a matrix.
|
|
|
|
ScreenToParentLayerScale mTransformScale;
|
|
|
|
|
2012-09-29 02:16:34 +00: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.
|
2013-06-21 21:03:56 +00:00
|
|
|
CSSToLayoutDeviceScale mDevPixelsPerCSSPixel;
|
2012-09-29 02:16:34 +00:00
|
|
|
|
2012-08-22 04:37:06 +00:00
|
|
|
// Whether or not this frame may have touch listeners.
|
|
|
|
bool mMayHaveTouchListeners;
|
2013-05-24 01:43:36 +00:00
|
|
|
|
2014-06-03 07:08:54 +00:00
|
|
|
// Whether or not this frame may have touch caret.
|
|
|
|
bool mMayHaveTouchCaret;
|
|
|
|
|
2014-01-21 17:33:52 +00:00
|
|
|
public:
|
2014-08-23 23:09:10 +00:00
|
|
|
void SetIsRoot(bool aIsRoot)
|
|
|
|
{
|
|
|
|
mIsRoot = aIsRoot;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GetIsRoot() const
|
|
|
|
{
|
|
|
|
return mIsRoot;
|
|
|
|
}
|
|
|
|
|
2014-06-25 23:16:27 +00:00
|
|
|
void SetHasScrollgrab(bool aHasScrollgrab)
|
|
|
|
{
|
|
|
|
mHasScrollgrab = aHasScrollgrab;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GetHasScrollgrab() const
|
|
|
|
{
|
|
|
|
return mHasScrollgrab;
|
|
|
|
}
|
|
|
|
|
2014-03-13 06:34:34 +00:00
|
|
|
void SetScrollOffset(const CSSPoint& aScrollOffset)
|
|
|
|
{
|
|
|
|
mScrollOffset = aScrollOffset;
|
|
|
|
}
|
|
|
|
|
|
|
|
const CSSPoint& GetScrollOffset() const
|
|
|
|
{
|
|
|
|
return mScrollOffset;
|
|
|
|
}
|
|
|
|
|
2014-03-12 16:46:57 +00:00
|
|
|
void SetZoom(const CSSToScreenScale& aZoom)
|
|
|
|
{
|
|
|
|
mZoom = aZoom;
|
|
|
|
}
|
|
|
|
|
|
|
|
CSSToScreenScale GetZoom() const
|
|
|
|
{
|
|
|
|
return mZoom;
|
|
|
|
}
|
|
|
|
|
2014-02-05 22:43:20 +00:00
|
|
|
void SetScrollOffsetUpdated(uint32_t aScrollGeneration)
|
|
|
|
{
|
|
|
|
mUpdateScrollOffset = true;
|
|
|
|
mScrollGeneration = aScrollGeneration;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GetScrollOffsetUpdated() const
|
|
|
|
{
|
|
|
|
return mUpdateScrollOffset;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t GetScrollGeneration() const
|
|
|
|
{
|
|
|
|
return mScrollGeneration;
|
|
|
|
}
|
|
|
|
|
2014-03-21 21:48:08 +00:00
|
|
|
ViewID GetScrollId() const
|
|
|
|
{
|
|
|
|
return mScrollId;
|
|
|
|
}
|
2014-08-11 17:32:51 +00:00
|
|
|
|
|
|
|
void SetScrollId(ViewID scrollId)
|
2014-03-21 21:48:08 +00:00
|
|
|
{
|
|
|
|
mScrollId = scrollId;
|
|
|
|
}
|
2014-03-26 23:24:25 +00:00
|
|
|
|
|
|
|
void SetRootCompositionSize(const CSSSize& aRootCompositionSize)
|
|
|
|
{
|
|
|
|
mRootCompositionSize = aRootCompositionSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
const CSSSize& GetRootCompositionSize() const
|
|
|
|
{
|
|
|
|
return mRootCompositionSize;
|
|
|
|
}
|
|
|
|
|
2014-03-27 01:46:24 +00:00
|
|
|
void SetDisplayPortMargins(const LayerMargin& aDisplayPortMargins)
|
|
|
|
{
|
|
|
|
mDisplayPortMargins = aDisplayPortMargins;
|
|
|
|
}
|
|
|
|
|
|
|
|
const LayerMargin& GetDisplayPortMargins() const
|
|
|
|
{
|
|
|
|
return mDisplayPortMargins;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetUseDisplayPortMargins()
|
|
|
|
{
|
|
|
|
mUseDisplayPortMargins = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GetUseDisplayPortMargins() const
|
|
|
|
{
|
|
|
|
return mUseDisplayPortMargins;
|
|
|
|
}
|
|
|
|
|
2014-05-16 23:00:50 +00:00
|
|
|
uint32_t GetPresShellId() const
|
|
|
|
{
|
|
|
|
return mPresShellId;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetPresShellId(uint32_t aPresShellId)
|
|
|
|
{
|
|
|
|
mPresShellId = aPresShellId;
|
|
|
|
}
|
|
|
|
|
2014-08-23 03:18:56 +00:00
|
|
|
void SetViewport(const CSSRect& aViewport)
|
|
|
|
{
|
|
|
|
mViewport = aViewport;
|
|
|
|
}
|
|
|
|
|
|
|
|
const CSSRect& GetViewport() const
|
|
|
|
{
|
|
|
|
return mViewport;
|
|
|
|
}
|
|
|
|
|
2014-01-21 17:33:52 +00:00
|
|
|
private:
|
|
|
|
// New fields from now on should be made private and old fields should
|
|
|
|
// be refactored to be private.
|
|
|
|
|
2014-08-23 23:09:10 +00:00
|
|
|
// Whether or not this is the root scroll frame for the root content document.
|
|
|
|
bool mIsRoot;
|
|
|
|
|
2014-06-25 23:16:27 +00:00
|
|
|
// Whether or not this frame is for an element marked 'scrollgrab'.
|
|
|
|
bool mHasScrollgrab;
|
|
|
|
|
2014-03-21 21:48:08 +00:00
|
|
|
// A unique ID assigned to each scrollable frame.
|
|
|
|
ViewID mScrollId;
|
|
|
|
|
2014-03-13 06:34:34 +00: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 16:46:57 +00: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.
|
|
|
|
CSSToScreenScale mZoom;
|
|
|
|
|
2014-02-05 22:43:20 +00:00
|
|
|
// Whether mScrollOffset was updated by something other than the APZ code, and
|
|
|
|
// if the APZC receiving this metrics should update its local copy.
|
|
|
|
bool mUpdateScrollOffset;
|
|
|
|
// The scroll generation counter used to acknowledge the scroll offset update.
|
|
|
|
uint32_t mScrollGeneration;
|
2014-01-22 21:37:57 +00:00
|
|
|
|
2014-03-26 23:24:25 +00:00
|
|
|
// The size of the root scrollable's composition bounds, but in local CSS pixels.
|
|
|
|
CSSSize mRootCompositionSize;
|
2014-03-27 01:46:24 +00:00
|
|
|
|
|
|
|
// A display port expressed as layer margins that apply to the rect of what
|
|
|
|
// is drawn of the scrollable element.
|
|
|
|
LayerMargin mDisplayPortMargins;
|
|
|
|
|
|
|
|
// If this is true then we use the display port margins on this metrics,
|
|
|
|
// otherwise use the display port rect.
|
|
|
|
bool mUseDisplayPortMargins;
|
2014-05-16 23:00:50 +00:00
|
|
|
|
|
|
|
uint32_t mPresShellId;
|
2014-08-23 03:18:56 +00: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;
|
2012-07-31 00:42:26 +00:00
|
|
|
};
|
|
|
|
|
2013-11-13 18:20:31 +00: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)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(ScrollableLayerGuid);
|
|
|
|
}
|
|
|
|
|
|
|
|
ScrollableLayerGuid(uint64_t aLayersId, uint32_t aPresShellId,
|
|
|
|
FrameMetrics::ViewID aScrollId)
|
|
|
|
: mLayersId(aLayersId)
|
|
|
|
, mPresShellId(aPresShellId)
|
|
|
|
, mScrollId(aScrollId)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(ScrollableLayerGuid);
|
|
|
|
}
|
|
|
|
|
|
|
|
ScrollableLayerGuid(uint64_t aLayersId, const FrameMetrics& aMetrics)
|
|
|
|
: mLayersId(aLayersId)
|
2014-05-16 23:00:50 +00:00
|
|
|
, mPresShellId(aMetrics.GetPresShellId())
|
2014-03-21 21:48:08 +00:00
|
|
|
, mScrollId(aMetrics.GetScrollId())
|
2013-11-13 18:20:31 +00:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(ScrollableLayerGuid);
|
|
|
|
}
|
|
|
|
|
2014-08-11 17:32:51 +00:00
|
|
|
ScrollableLayerGuid(const ScrollableLayerGuid& other)
|
|
|
|
: mLayersId(other.mLayersId)
|
|
|
|
, mPresShellId(other.mPresShellId)
|
|
|
|
, mScrollId(other.mScrollId)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(ScrollableLayerGuid);
|
|
|
|
}
|
|
|
|
|
2013-11-13 18:20:31 +00:00
|
|
|
~ScrollableLayerGuid()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(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 01:17:08 +00: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;
|
|
|
|
}
|
2013-11-13 18:20:31 +00:00
|
|
|
};
|
|
|
|
|
2014-01-22 23:44:59 +00: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 18:26:44 +00:00
|
|
|
struct ZoomConstraints {
|
|
|
|
bool mAllowZoom;
|
2014-02-25 00:22:45 +00:00
|
|
|
bool mAllowDoubleTapZoom;
|
2014-01-06 18:26:44 +00:00
|
|
|
CSSToScreenScale mMinZoom;
|
|
|
|
CSSToScreenScale mMaxZoom;
|
|
|
|
|
|
|
|
ZoomConstraints()
|
|
|
|
: mAllowZoom(true)
|
2014-02-25 00:22:45 +00:00
|
|
|
, mAllowDoubleTapZoom(true)
|
2014-01-06 18:26:44 +00:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(ZoomConstraints);
|
|
|
|
}
|
|
|
|
|
|
|
|
ZoomConstraints(bool aAllowZoom,
|
2014-02-25 00:22:45 +00:00
|
|
|
bool aAllowDoubleTapZoom,
|
2014-01-06 18:26:44 +00:00
|
|
|
const CSSToScreenScale& aMinZoom,
|
|
|
|
const CSSToScreenScale& aMaxZoom)
|
|
|
|
: mAllowZoom(aAllowZoom)
|
2014-02-25 00:22:45 +00:00
|
|
|
, mAllowDoubleTapZoom(aAllowDoubleTapZoom)
|
2014-01-06 18:26:44 +00:00
|
|
|
, mMinZoom(aMinZoom)
|
|
|
|
, mMaxZoom(aMaxZoom)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(ZoomConstraints);
|
|
|
|
}
|
|
|
|
|
2014-08-11 16:35:17 +00:00
|
|
|
ZoomConstraints(const ZoomConstraints& other)
|
|
|
|
: mAllowZoom(other.mAllowZoom)
|
|
|
|
, mAllowDoubleTapZoom(other.mAllowDoubleTapZoom)
|
|
|
|
, mMinZoom(other.mMinZoom)
|
|
|
|
, mMaxZoom(other.mMaxZoom)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(ZoomConstraints);
|
|
|
|
}
|
|
|
|
|
2014-01-06 18:26:44 +00:00
|
|
|
~ZoomConstraints()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(ZoomConstraints);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const ZoomConstraints& other) const
|
|
|
|
{
|
|
|
|
return mAllowZoom == other.mAllowZoom
|
2014-02-25 00:22:45 +00:00
|
|
|
&& mAllowDoubleTapZoom == other.mAllowDoubleTapZoom
|
2014-01-06 18:26:44 +00:00
|
|
|
&& mMinZoom == other.mMinZoom
|
|
|
|
&& mMaxZoom == other.mMaxZoom;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=(const ZoomConstraints& other) const
|
|
|
|
{
|
|
|
|
return !(*this == other);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-07-31 00:42:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* GFX_FRAMEMETRICS_H */
|