--- a/gfx/ipc/GfxMessageUtils.h
+++ b/gfx/ipc/GfxMessageUtils.h
@@ -677,117 +677,94 @@ struct ParamTraits<nsRegion>
template<>
struct ParamTraits<mozilla::layers::FrameMetrics::ScrollOffsetUpdateType>
: public ContiguousEnumSerializer<
mozilla::layers::FrameMetrics::ScrollOffsetUpdateType,
mozilla::layers::FrameMetrics::ScrollOffsetUpdateType::eNone,
mozilla::layers::FrameMetrics::ScrollOffsetUpdateType::eSentinel>
{};
+// Helper class for reading bitfields.
+// If T has bitfields members, derive ParamTraits<T> from BitfieldHelper<T>.
+template <typename ParamType>
+struct BitfieldHelper
+{
+ // We need this helper because we can't get the address of a bitfield to
+ // pass directly to ReadParam. So instead we read it into a temporary bool
+ // and set the bitfield using a setter function
+ static bool ReadBoolForBitfield(const Message* aMsg, void** aIter,
+ ParamType* aResult, void (ParamType::*aSetter)(bool))
+ {
+ bool value;
+ if (ReadParam(aMsg, aIter, &value)) {
+ (aResult->*aSetter)(value);
+ return true;
+ }
+ return false;
+ }
+};
+
template <>
struct ParamTraits<mozilla::layers::FrameMetrics>
+ : BitfieldHelper<mozilla::layers::FrameMetrics>
{
typedef mozilla::layers::FrameMetrics paramType;
static void Write(Message* aMsg, const paramType& aParam)
{
WriteParam(aMsg, aParam.mScrollId);
- WriteParam(aMsg, aParam.mScrollParentId);
WriteParam(aMsg, aParam.mPresShellResolution);
WriteParam(aMsg, aParam.mCompositionBounds);
WriteParam(aMsg, aParam.mDisplayPort);
WriteParam(aMsg, aParam.mCriticalDisplayPort);
WriteParam(aMsg, aParam.mScrollableRect);
WriteParam(aMsg, aParam.mCumulativeResolution);
WriteParam(aMsg, aParam.mDevPixelsPerCSSPixel);
WriteParam(aMsg, aParam.mScrollOffset);
WriteParam(aMsg, aParam.mZoom);
WriteParam(aMsg, aParam.mScrollGeneration);
WriteParam(aMsg, aParam.mSmoothScrollOffset);
WriteParam(aMsg, aParam.mRootCompositionSize);
WriteParam(aMsg, aParam.mDisplayPortMargins);
WriteParam(aMsg, aParam.mPresShellId);
WriteParam(aMsg, aParam.mViewport);
WriteParam(aMsg, aParam.mExtraResolution);
- WriteParam(aMsg, aParam.mBackgroundColor);
- WriteParam(aMsg, aParam.GetContentDescription());
- WriteParam(aMsg, aParam.mLineScrollAmount);
- WriteParam(aMsg, aParam.mPageScrollAmount);
WriteParam(aMsg, aParam.mPaintRequestTime);
WriteParam(aMsg, aParam.mScrollUpdateType);
WriteParam(aMsg, aParam.mIsRootContent);
- WriteParam(aMsg, aParam.mHasScrollgrab);
WriteParam(aMsg, aParam.mDoSmoothScroll);
WriteParam(aMsg, aParam.mUseDisplayPortMargins);
- WriteParam(aMsg, aParam.mAllowVerticalScrollWithWheel);
- WriteParam(aMsg, aParam.mIsLayersIdRoot);
- WriteParam(aMsg, aParam.mUsesContainerScrolling);
WriteParam(aMsg, aParam.mIsScrollInfoLayer);
- WriteParam(aMsg, aParam.mForceDisableApz);
- }
-
- static bool ReadContentDescription(const Message* aMsg, void** aIter, paramType* aResult)
- {
- nsCString str;
- if (!ReadParam(aMsg, aIter, &str)) {
- return false;
- }
- aResult->SetContentDescription(str);
- return true;
- }
-
- // We need this helper because we can't get the address of a bitfield to
- // pass directly to ReadParam. So instead we read it into a temporary bool
- // and set the bitfield using a setter function
- static bool ReadBoolForBitfield(const Message* aMsg, void** aIter,
- paramType* aResult, void (paramType::*aSetter)(bool))
- {
- bool value;
- if (ReadParam(aMsg, aIter, &value)) {
- (aResult->*aSetter)(value);
- return true;
- }
- return false;
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
return (ReadParam(aMsg, aIter, &aResult->mScrollId) &&
- ReadParam(aMsg, aIter, &aResult->mScrollParentId) &&
ReadParam(aMsg, aIter, &aResult->mPresShellResolution) &&
ReadParam(aMsg, aIter, &aResult->mCompositionBounds) &&
ReadParam(aMsg, aIter, &aResult->mDisplayPort) &&
ReadParam(aMsg, aIter, &aResult->mCriticalDisplayPort) &&
ReadParam(aMsg, aIter, &aResult->mScrollableRect) &&
ReadParam(aMsg, aIter, &aResult->mCumulativeResolution) &&
ReadParam(aMsg, aIter, &aResult->mDevPixelsPerCSSPixel) &&
ReadParam(aMsg, aIter, &aResult->mScrollOffset) &&
ReadParam(aMsg, aIter, &aResult->mZoom) &&
ReadParam(aMsg, aIter, &aResult->mScrollGeneration) &&
ReadParam(aMsg, aIter, &aResult->mSmoothScrollOffset) &&
ReadParam(aMsg, aIter, &aResult->mRootCompositionSize) &&
ReadParam(aMsg, aIter, &aResult->mDisplayPortMargins) &&
ReadParam(aMsg, aIter, &aResult->mPresShellId) &&
ReadParam(aMsg, aIter, &aResult->mViewport) &&
ReadParam(aMsg, aIter, &aResult->mExtraResolution) &&
- ReadParam(aMsg, aIter, &aResult->mBackgroundColor) &&
- ReadContentDescription(aMsg, aIter, aResult) &&
- ReadParam(aMsg, aIter, &aResult->mLineScrollAmount) &&
- ReadParam(aMsg, aIter, &aResult->mPageScrollAmount) &&
ReadParam(aMsg, aIter, &aResult->mPaintRequestTime) &&
ReadParam(aMsg, aIter, &aResult->mScrollUpdateType) &&
ReadBoolForBitfield(aMsg, aIter, aResult, ¶mType::SetIsRootContent) &&
- ReadBoolForBitfield(aMsg, aIter, aResult, ¶mType::SetHasScrollgrab) &&
ReadBoolForBitfield(aMsg, aIter, aResult, ¶mType::SetDoSmoothScroll) &&
ReadBoolForBitfield(aMsg, aIter, aResult, ¶mType::SetUseDisplayPortMargins) &&
- ReadBoolForBitfield(aMsg, aIter, aResult, ¶mType::SetAllowVerticalScrollWithWheel) &&
- ReadBoolForBitfield(aMsg, aIter, aResult, ¶mType::SetIsLayersIdRoot) &&
- ReadBoolForBitfield(aMsg, aIter, aResult, ¶mType::SetUsesContainerScrolling) &&
- ReadBoolForBitfield(aMsg, aIter, aResult, ¶mType::SetIsScrollInfoLayer) &&
- ReadBoolForBitfield(aMsg, aIter, aResult, ¶mType::SetForceDisableApz));
+ ReadBoolForBitfield(aMsg, aIter, aResult, ¶mType::SetIsScrollInfoLayer));
}
};
template <>
struct ParamTraits<mozilla::layers::ScrollSnapInfo>
{
typedef mozilla::layers::ScrollSnapInfo paramType;
@@ -809,33 +786,64 @@ struct ParamTraits<mozilla::layers::Scro
ReadParam(aMsg, aIter, &aResult->mScrollSnapIntervalY) &&
ReadParam(aMsg, aIter, &aResult->mScrollSnapDestination) &&
ReadParam(aMsg, aIter, &aResult->mScrollSnapCoordinates));
}
};
template <>
struct ParamTraits<mozilla::layers::ScrollMetadata>
+ : BitfieldHelper<mozilla::layers::ScrollMetadata>
{
typedef mozilla::layers::ScrollMetadata paramType;
static void Write(Message* aMsg, const paramType& aParam)
{
WriteParam(aMsg, aParam.mMetrics);
WriteParam(aMsg, aParam.mSnapInfo);
+ WriteParam(aMsg, aParam.mScrollParentId);
+ WriteParam(aMsg, aParam.mBackgroundColor);
+ WriteParam(aMsg, aParam.GetContentDescription());
+ WriteParam(aMsg, aParam.mLineScrollAmount);
+ WriteParam(aMsg, aParam.mPageScrollAmount);
WriteParam(aMsg, aParam.mMaskLayerIndex);
WriteParam(aMsg, aParam.mClipRect);
+ WriteParam(aMsg, aParam.mHasScrollgrab);
+ WriteParam(aMsg, aParam.mAllowVerticalScrollWithWheel);
+ WriteParam(aMsg, aParam.mIsLayersIdRoot);
+ WriteParam(aMsg, aParam.mUsesContainerScrolling);
+ WriteParam(aMsg, aParam.mForceDisableApz);
+ }
+
+ static bool ReadContentDescription(const Message* aMsg, void** aIter, paramType* aResult)
+ {
+ nsCString str;
+ if (!ReadParam(aMsg, aIter, &str)) {
+ return false;
+ }
+ aResult->SetContentDescription(str);
+ return true;
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
return (ReadParam(aMsg, aIter, &aResult->mMetrics) &&
ReadParam(aMsg, aIter, &aResult->mSnapInfo) &&
+ ReadParam(aMsg, aIter, &aResult->mScrollParentId) &&
+ ReadParam(aMsg, aIter, &aResult->mBackgroundColor) &&
+ ReadContentDescription(aMsg, aIter, aResult) &&
+ ReadParam(aMsg, aIter, &aResult->mLineScrollAmount) &&
+ ReadParam(aMsg, aIter, &aResult->mPageScrollAmount) &&
ReadParam(aMsg, aIter, &aResult->mMaskLayerIndex) &&
- ReadParam(aMsg, aIter, &aResult->mClipRect));
+ ReadParam(aMsg, aIter, &aResult->mClipRect) &&
+ ReadBoolForBitfield(aMsg, aIter, aResult, ¶mType::SetHasScrollgrab) &&
+ ReadBoolForBitfield(aMsg, aIter, aResult, ¶mType::SetAllowVerticalScrollWithWheel) &&
+ ReadBoolForBitfield(aMsg, aIter, aResult, ¶mType::SetIsLayersIdRoot) &&
+ ReadBoolForBitfield(aMsg, aIter, aResult, ¶mType::SetUsesContainerScrolling) &&
+ ReadBoolForBitfield(aMsg, aIter, aResult, ¶mType::SetForceDisableApz));
}
};
template<>
struct ParamTraits<mozilla::layers::TextureFactoryIdentifier>
{
typedef mozilla::layers::TextureFactoryIdentifier paramType;
--- a/gfx/layers/FrameMetrics.cpp
+++ b/gfx/layers/FrameMetrics.cpp
@@ -7,17 +7,17 @@
#include "gfxPrefs.h"
namespace mozilla {
namespace layers {
const FrameMetrics::ViewID FrameMetrics::NULL_SCROLL_ID = 0;
void
-FrameMetrics::SetUsesContainerScrolling(bool aValue) {
+ScrollMetadata::SetUsesContainerScrolling(bool aValue) {
MOZ_ASSERT_IF(aValue, gfxPrefs::LayoutUseContainersForRootFrames());
mUsesContainerScrolling = aValue;
}
StaticAutoPtr<const ScrollMetadata> ScrollMetadata::sNullMetadata;
}
}
--- a/gfx/layers/FrameMetrics.h
+++ b/gfx/layers/FrameMetrics.h
@@ -57,89 +57,69 @@ public:
// painted, so the layer texture data is still at the old
// offset.
eSentinel // For IPC use only
};
FrameMetrics()
: mScrollId(NULL_SCROLL_ID)
- , mScrollParentId(NULL_SCROLL_ID)
, mPresShellResolution(1)
, mCompositionBounds(0, 0, 0, 0)
, mDisplayPort(0, 0, 0, 0)
, mCriticalDisplayPort(0, 0, 0, 0)
, mScrollableRect(0, 0, 0, 0)
, mCumulativeResolution()
, mDevPixelsPerCSSPixel(1)
, mScrollOffset(0, 0)
, mZoom()
, mScrollGeneration(0)
, mSmoothScrollOffset(0, 0)
, mRootCompositionSize(0, 0)
, mDisplayPortMargins(0, 0, 0, 0)
, mPresShellId(-1)
, mViewport(0, 0, 0, 0)
, mExtraResolution()
- , mBackgroundColor()
- , mContentDescription()
- , mLineScrollAmount(0, 0)
- , mPageScrollAmount(0, 0)
, mPaintRequestTime()
, mScrollUpdateType(eNone)
, mIsRootContent(false)
- , mHasScrollgrab(false)
, mDoSmoothScroll(false)
, mUseDisplayPortMargins(false)
- , mAllowVerticalScrollWithWheel(false)
- , mIsLayersIdRoot(false)
- , mUsesContainerScrolling(false)
, mIsScrollInfoLayer(false)
- , mForceDisableApz(false)
{
}
// Default copy ctor and operator= are fine
bool operator==(const FrameMetrics& aOther) const
{
// Put mScrollId at the top since it's the most likely one to fail.
return mScrollId == aOther.mScrollId &&
- mScrollParentId == aOther.mScrollParentId &&
mPresShellResolution == aOther.mPresShellResolution &&
mCompositionBounds.IsEqualEdges(aOther.mCompositionBounds) &&
mDisplayPort.IsEqualEdges(aOther.mDisplayPort) &&
mCriticalDisplayPort.IsEqualEdges(aOther.mCriticalDisplayPort) &&
mScrollableRect.IsEqualEdges(aOther.mScrollableRect) &&
mCumulativeResolution == aOther.mCumulativeResolution &&
mDevPixelsPerCSSPixel == aOther.mDevPixelsPerCSSPixel &&
mScrollOffset == aOther.mScrollOffset &&
// don't compare mZoom
mScrollGeneration == aOther.mScrollGeneration &&
mSmoothScrollOffset == aOther.mSmoothScrollOffset &&
mRootCompositionSize == aOther.mRootCompositionSize &&
mDisplayPortMargins == aOther.mDisplayPortMargins &&
mPresShellId == aOther.mPresShellId &&
mViewport.IsEqualEdges(aOther.mViewport) &&
mExtraResolution == aOther.mExtraResolution &&
- mBackgroundColor == aOther.mBackgroundColor &&
- // don't compare mContentDescription
- mLineScrollAmount == aOther.mLineScrollAmount &&
- mPageScrollAmount == aOther.mPageScrollAmount &&
mPaintRequestTime == aOther.mPaintRequestTime &&
mScrollUpdateType == aOther.mScrollUpdateType &&
mIsRootContent == aOther.mIsRootContent &&
- mHasScrollgrab == aOther.mHasScrollgrab &&
mDoSmoothScroll == aOther.mDoSmoothScroll &&
mUseDisplayPortMargins == aOther.mUseDisplayPortMargins &&
- mAllowVerticalScrollWithWheel == aOther.mAllowVerticalScrollWithWheel &&
- mIsLayersIdRoot == aOther.mIsLayersIdRoot &&
- mUsesContainerScrolling == aOther.mUsesContainerScrolling &&
- mIsScrollInfoLayer == aOther.mIsScrollInfoLayer &&
- mForceDisableApz == aOther.mForceDisableApz;
+ mIsScrollInfoLayer == aOther.mIsScrollInfoLayer;
}
bool operator!=(const FrameMetrics& aOther) const
{
return !operator==(aOther);
}
bool IsScrollable() const
@@ -255,26 +235,16 @@ public:
void UpdatePendingScrollInfo(const ScrollUpdateInfo& aInfo)
{
mScrollOffset = aInfo.mScrollOffset;
mScrollGeneration = aInfo.mScrollGeneration;
mScrollUpdateType = ePending;
}
- // Make a copy of this FrameMetrics object which does not have any pointers
- // to heap-allocated memory (i.e. is Plain Old Data, or 'POD'), and is
- // therefore safe to be placed into shared memory.
- FrameMetrics MakePODObject() const
- {
- FrameMetrics copy = *this;
- copy.mContentDescription.Truncate();
- return copy;
- }
-
public:
void SetPresShellResolution(float aPresShellResolution)
{
mPresShellResolution = aPresShellResolution;
}
float GetPresShellResolution() const
{
@@ -336,26 +306,16 @@ public:
mIsRootContent = aIsRootContent;
}
bool IsRootContent() const
{
return mIsRootContent;
}
- void SetHasScrollgrab(bool aHasScrollgrab)
- {
- mHasScrollgrab = aHasScrollgrab;
- }
-
- bool GetHasScrollgrab() const
- {
- return mHasScrollgrab;
- }
-
void SetScrollOffset(const CSSPoint& aScrollOffset)
{
mScrollOffset = aScrollOffset;
}
const CSSPoint& GetScrollOffset() const
{
return mScrollOffset;
@@ -418,26 +378,16 @@ public:
return mScrollId;
}
void SetScrollId(ViewID scrollId)
{
mScrollId = scrollId;
}
- ViewID GetScrollParentId() const
- {
- return mScrollParentId;
- }
-
- void SetScrollParentId(ViewID aParentId)
- {
- mScrollParentId = aParentId;
- }
-
void SetRootCompositionSize(const CSSSize& aRootCompositionSize)
{
mRootCompositionSize = aRootCompositionSize;
}
const CSSSize& GetRootCompositionSize() const
{
return mRootCompositionSize;
@@ -488,118 +438,44 @@ public:
mExtraResolution = aExtraResolution;
}
const ScreenToLayerScale2D& GetExtraResolution() const
{
return mExtraResolution;
}
- 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;
- }
-
const CSSRect& GetScrollableRect() const
{
return mScrollableRect;
}
void SetScrollableRect(const CSSRect& aScrollableRect)
{
mScrollableRect = aScrollableRect;
}
- bool AllowVerticalScrollWithWheel() const
- {
- return mAllowVerticalScrollWithWheel;
- }
-
- void SetAllowVerticalScrollWithWheel(bool aValue)
- {
- mAllowVerticalScrollWithWheel = aValue;
- }
-
void SetPaintRequestTime(const TimeStamp& aTime) {
mPaintRequestTime = aTime;
}
const TimeStamp& GetPaintRequestTime() const {
return mPaintRequestTime;
}
- 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 SetIsScrollInfoLayer(bool aIsScrollInfoLayer) {
mIsScrollInfoLayer = aIsScrollInfoLayer;
}
bool IsScrollInfoLayer() const {
return mIsScrollInfoLayer;
}
- void SetForceDisableApz(bool aForceDisable) {
- mForceDisableApz = aForceDisable;
- }
- bool IsApzForceDisabled() const {
- return mForceDisableApz;
- }
-
private:
// A unique ID assigned to each scrollable frame.
ViewID mScrollId;
- // The ViewID of the scrollable frame to which overscroll should be handed off.
- ViewID mScrollParentId;
-
// 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;
@@ -722,80 +598,52 @@ private:
// iframe. For layers that don't correspond to a document, this metric is
// meaningless and invalid.
CSSRect mViewport;
// The extra resolution at which content in this scroll frame is drawn beyond
// that necessary to draw one Layer pixel per Screen pixel.
ScreenToLayerScale2D mExtraResolution;
- // 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;
-
// The time at which the APZC last requested a repaint for this scrollframe.
TimeStamp mPaintRequestTime;
// 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;
// Whether or not this is the root scroll frame for the root content document.
bool mIsRootContent:1;
- // Whether or not this frame is for an element marked 'scrollgrab'.
- bool mHasScrollgrab:1;
-
// When mDoSmoothScroll, the scroll offset should be animated to
// smoothly transition to mScrollOffset rather than be updated instantly.
bool mDoSmoothScroll:1;
// If this is true then we use the display port margins on this metrics,
// otherwise use the display port rect.
bool mUseDisplayPortMargins: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 this frame has a "scroll info layer" to capture events.
bool mIsScrollInfoLayer:1;
- // Whether or not the compositor should actually do APZ-scrolling on this
- // scrollframe.
- bool mForceDisableApz:1;
-
// WARNING!!!!
//
- // When adding new fields to FrameMetrics, the following places should be
- // updated to include them (as needed):
- // FrameMetrics::operator ==
- // AsyncPanZoomController::NotifyLayersUpdated
- // The ParamTraits specialization in GfxMessageUtils.h
+ // 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
//
// Please add new fields above this comment.
-
// Private helpers for IPC purposes
void SetDoSmoothScroll(bool aValue) {
mDoSmoothScroll = aValue;
}
};
struct ScrollSnapInfo {
ScrollSnapInfo()
@@ -835,32 +683,54 @@ struct ScrollSnapInfo {
* 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>;
+
+ typedef FrameMetrics::ViewID ViewID;
public:
static StaticAutoPtr<const ScrollMetadata> sNullMetadata; // We sometimes need an empty metadata
ScrollMetadata()
: mMetrics()
, mSnapInfo()
+ , mScrollParentId(FrameMetrics::NULL_SCROLL_ID)
+ , mBackgroundColor()
+ , mContentDescription()
+ , mLineScrollAmount(0, 0)
+ , mPageScrollAmount(0, 0)
, mMaskLayerIndex()
, mClipRect()
+ , mHasScrollgrab(false)
+ , mAllowVerticalScrollWithWheel(false)
+ , mIsLayersIdRoot(false)
+ , mUsesContainerScrolling(false)
+ , mForceDisableApz(false)
{}
bool operator==(const ScrollMetadata& aOther) const
{
return mMetrics == aOther.mMetrics &&
mSnapInfo == aOther.mSnapInfo &&
+ mScrollParentId == aOther.mScrollParentId &&
+ mBackgroundColor == aOther.mBackgroundColor &&
+ // don't compare mContentDescription
+ mLineScrollAmount == aOther.mLineScrollAmount &&
+ mPageScrollAmount == aOther.mPageScrollAmount &&
mMaskLayerIndex == aOther.mMaskLayerIndex &&
- mClipRect == aOther.mClipRect;
+ mClipRect == aOther.mClipRect &&
+ mHasScrollgrab == aOther.mHasScrollgrab &&
+ mAllowVerticalScrollWithWheel == aOther.mAllowVerticalScrollWithWheel &&
+ mIsLayersIdRoot == aOther.mIsLayersIdRoot &&
+ mUsesContainerScrolling == aOther.mUsesContainerScrolling &&
+ mForceDisableApz == aOther.mForceDisableApz;
}
bool operator!=(const ScrollMetadata& aOther) const
{
return !operator==(aOther);
}
bool IsDefault() const
@@ -874,16 +744,47 @@ public:
FrameMetrics& GetMetrics() { return mMetrics; }
const FrameMetrics& GetMetrics() const { return mMetrics; }
void SetSnapInfo(ScrollSnapInfo&& aSnapInfo) {
mSnapInfo = Move(aSnapInfo);
}
const ScrollSnapInfo& GetSnapInfo() const { return mSnapInfo; }
+ 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;
+ }
void SetMaskLayerIndex(const Maybe<size_t>& aIndex) {
mMaskLayerIndex = aIndex;
}
const Maybe<size_t>& GetMaskLayerIndex() const {
return mMaskLayerIndex;
}
void SetClipRect(const Maybe<ParentLayerIntRect>& aClipRect)
@@ -895,29 +796,106 @@ public:
return mClipRect;
}
bool HasClipRect() const {
return mClipRect.isSome();
}
const ParentLayerIntRect& ClipRect() const {
return mClipRect.ref();
}
+
+ 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;
+ }
+
private:
FrameMetrics mMetrics;
// Information used to determine where to snap to for a given scroll.
ScrollSnapInfo mSnapInfo;
+ // 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;
+
// An extra clip mask layer to use when compositing a layer with this
// FrameMetrics. This is an index into the MetricsMaskLayers array on
// the Layer.
Maybe<size_t> mMaskLayerIndex;
// The clip rect to use when compositing a layer with this FrameMetrics.
Maybe<ParentLayerIntRect> mClipRect;
+
+ // 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.
};
/**
* 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
--- a/gfx/layers/LayersLogging.cpp
+++ b/gfx/layers/LayersLogging.cpp
@@ -144,42 +144,42 @@ AppendToString(std::stringstream& aStrea
aStream << "}" << sfx;
}
void
AppendToString(std::stringstream& aStream, const ScrollMetadata& m,
const char* pfx, const char* sfx)
{
aStream << pfx;
- AppendToString(aStream, m.GetMetrics(), "{ [metrics=", "]");
+ AppendToString(aStream, m.GetMetrics(), "{ [metrics=");
+ AppendToString(aStream, m.GetBackgroundColor(), "] [color=");
+ if (m.GetScrollParentId() != FrameMetrics::NULL_SCROLL_ID) {
+ AppendToString(aStream, m.GetScrollParentId(), "] [scrollParent=");
+ }
if (m.HasClipRect()) {
- AppendToString(aStream, m.ClipRect(), " [clip=", "]");
+ AppendToString(aStream, m.ClipRect(), "] [clip=");
}
- aStream << "}" << sfx;
+ aStream << "] }" << sfx;
}
void
AppendToString(std::stringstream& aStream, const FrameMetrics& m,
const char* pfx, const char* sfx, bool detailed)
{
aStream << pfx;
AppendToString(aStream, m.GetCompositionBounds(), "{ [cb=");
AppendToString(aStream, m.GetScrollableRect(), "] [sr=");
AppendToString(aStream, m.GetScrollOffset(), "] [s=");
if (m.GetDoSmoothScroll()) {
AppendToString(aStream, m.GetSmoothScrollOffset(), "] [ss=");
}
AppendToString(aStream, m.GetDisplayPort(), "] [dp=");
AppendToString(aStream, m.GetCriticalDisplayPort(), "] [cdp=");
- AppendToString(aStream, m.GetBackgroundColor(), "] [color=");
if (!detailed) {
AppendToString(aStream, m.GetScrollId(), "] [scrollId=");
- if (m.GetScrollParentId() != FrameMetrics::NULL_SCROLL_ID) {
- AppendToString(aStream, m.GetScrollParentId(), "] [scrollParent=");
- }
if (m.IsRootContent()) {
aStream << "] [rcd";
}
AppendToString(aStream, m.GetZoom(), "] [z=", "] }");
} else {
AppendToString(aStream, m.GetDisplayPortMargins(), " [dpm=");
aStream << nsPrintfCString("] um=%d", m.GetUseDisplayPortMargins()).get();
AppendToString(aStream, m.GetRootCompositionSize(), "] [rcs=");
@@ -188,17 +188,16 @@ AppendToString(std::stringstream& aStrea
m.GetDevPixelsPerCSSPixel().scale,
m.GetPresShellResolution()).get();
AppendToString(aStream, m.GetCumulativeResolution(), " cr=");
AppendToString(aStream, m.GetZoom(), " z=");
AppendToString(aStream, m.GetExtraResolution(), " er=");
aStream << nsPrintfCString(")] [u=(%d %d %lu)",
m.GetScrollUpdateType(), m.GetDoSmoothScroll(),
m.GetScrollGeneration()).get();
- AppendToString(aStream, m.GetScrollParentId(), "] [p=");
aStream << nsPrintfCString("] [i=(%ld %lld %d)] }",
m.GetPresShellId(), m.GetScrollId(), m.IsRootContent()).get();
}
aStream << sfx;
}
void
AppendToString(std::stringstream& aStream, const ScrollableLayerGuid& s,
--- a/gfx/layers/apz/src/APZCTreeManager.cpp
+++ b/gfx/layers/apz/src/APZCTreeManager.cpp
@@ -249,17 +249,17 @@ APZCTreeManager::PrintAPZCInfo(const Lay
const AsyncPanZoomController* apzc)
{
const FrameMetrics& metrics = aLayer.Metrics();
mApzcTreeLog << "APZC " << apzc->GetGuid()
<< "\tcb=" << metrics.GetCompositionBounds()
<< "\tsr=" << metrics.GetScrollableRect()
<< (aLayer.IsScrollInfoLayer() ? "\tscrollinfo" : "")
<< (apzc->HasScrollgrab() ? "\tscrollgrab" : "") << "\t"
- << metrics.GetContentDescription().get();
+ << aLayer.Metadata().GetContentDescription().get();
}
void
APZCTreeManager::AttachNodeToTree(HitTestingTreeNode* aNode,
HitTestingTreeNode* aParent,
HitTestingTreeNode* aNextSibling)
{
if (aNextSibling) {
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -883,16 +883,17 @@ AsyncPanZoomController::AsyncPanZoomCont
: mLayersId(aLayersId),
mGeckoContentController(aGeckoContentController),
mRefPtrMonitor("RefPtrMonitor"),
// mTreeManager must be initialized before GetFrameTime() is called
mTreeManager(aTreeManager),
mSharingFrameMetricsAcrossProcesses(false),
mFrameMetrics(mScrollMetadata.GetMetrics()),
mMonitor("AsyncPanZoomController"),
+ mLastContentPaintMetrics(mLastContentPaintMetadata.GetMetrics()),
mX(this),
mY(this),
mPanDirRestricted(false),
mZoomConstraints(false, false, MIN_ZOOM, MAX_ZOOM),
mLastSampleTime(GetFrameTime()),
mLastCheckerboardReport(GetFrameTime()),
mState(NOTHING),
mNotificationBlockers(0),
@@ -1658,18 +1659,18 @@ AsyncPanZoomController::GetScrollWheelDe
{
ParentLayerSize scrollAmount;
ParentLayerSize pageScrollSize;
bool isRootContent = false;
{
// Grab the lock to access the frame metrics.
ReentrantMonitorAutoEnter lock(mMonitor);
- LayoutDeviceIntSize scrollAmountLD = mFrameMetrics.GetLineScrollAmount();
- LayoutDeviceIntSize pageScrollSizeLD = mFrameMetrics.GetPageScrollAmount();
+ LayoutDeviceIntSize scrollAmountLD = mScrollMetadata.GetLineScrollAmount();
+ LayoutDeviceIntSize pageScrollSizeLD = mScrollMetadata.GetPageScrollAmount();
isRootContent = mFrameMetrics.IsRootContent();
scrollAmount = scrollAmountLD /
mFrameMetrics.GetDevPixelsPerCSSPixel() * mFrameMetrics.GetZoom();
pageScrollSize = pageScrollSizeLD /
mFrameMetrics.GetDevPixelsPerCSSPixel() * mFrameMetrics.GetZoom();
}
ParentLayerPoint delta;
@@ -1761,17 +1762,17 @@ AsyncPanZoomController::CanScroll(const
bool
AsyncPanZoomController::CanScrollWithWheel(const ParentLayerPoint& aDelta) const
{
ReentrantMonitorAutoEnter lock(mMonitor);
if (mX.CanScroll(aDelta.x)) {
return true;
}
- if (mY.CanScroll(aDelta.y) && mFrameMetrics.AllowVerticalScrollWithWheel()) {
+ if (mY.CanScroll(aDelta.y) && mScrollMetadata.AllowVerticalScrollWithWheel()) {
return true;
}
return false;
}
bool
AsyncPanZoomController::CanScroll(Layer::ScrollDirection aDirection) const
{
@@ -2445,17 +2446,17 @@ bool AsyncPanZoomController::AttemptScro
}
if (scrollThisApzc) {
ReentrantMonitorAutoEnter lock(mMonitor);
ParentLayerPoint adjustedDisplacement;
bool forceVerticalOverscroll =
(aOverscrollHandoffState.mScrollSource == ScrollSource::Wheel &&
- !mFrameMetrics.AllowVerticalScrollWithWheel());
+ !mScrollMetadata.AllowVerticalScrollWithWheel());
bool yChanged = mY.AdjustDisplacement(displacement.y, adjustedDisplacement.y, overscroll.y,
forceVerticalOverscroll);
bool xChanged = mX.AdjustDisplacement(displacement.x, adjustedDisplacement.x, overscroll.x);
if (xChanged || yChanged) {
ScheduleComposite();
}
@@ -3095,17 +3096,17 @@ bool AsyncPanZoomController::UpdateAnima
return false;
}
AsyncTransformComponentMatrix
AsyncPanZoomController::GetOverscrollTransform(AsyncMode aMode) const
{
ReentrantMonitorAutoEnter lock(mMonitor);
- if (aMode == RESPECT_FORCE_DISABLE && mFrameMetrics.IsApzForceDisabled()) {
+ if (aMode == RESPECT_FORCE_DISABLE && mScrollMetadata.IsApzForceDisabled()) {
return AsyncTransformComponentMatrix();
}
if (!IsOverscrolled()) {
return AsyncTransformComponentMatrix();
}
// The overscroll effect is a uniform stretch along the overscrolled axis,
@@ -3196,30 +3197,30 @@ bool AsyncPanZoomController::AdvanceAnim
return requestAnimationFrame;
}
ParentLayerPoint
AsyncPanZoomController::GetCurrentAsyncScrollOffset(AsyncMode aMode) const
{
ReentrantMonitorAutoEnter lock(mMonitor);
- if (aMode == RESPECT_FORCE_DISABLE && mFrameMetrics.IsApzForceDisabled()) {
+ if (aMode == RESPECT_FORCE_DISABLE && mScrollMetadata.IsApzForceDisabled()) {
return mLastContentPaintMetrics.GetScrollOffset() * mLastContentPaintMetrics.GetZoom();
}
return (mFrameMetrics.GetScrollOffset() + mTestAsyncScrollOffset)
* mFrameMetrics.GetZoom() * mTestAsyncZoom.scale;
}
AsyncTransform
AsyncPanZoomController::GetCurrentAsyncTransform(AsyncMode aMode) const
{
ReentrantMonitorAutoEnter lock(mMonitor);
- if (aMode == RESPECT_FORCE_DISABLE && mFrameMetrics.IsApzForceDisabled()) {
+ if (aMode == RESPECT_FORCE_DISABLE && mScrollMetadata.IsApzForceDisabled()) {
return AsyncTransform();
}
CSSPoint lastPaintScrollOffset;
if (mLastContentPaintMetrics.IsScrollable()) {
lastPaintScrollOffset = mLastContentPaintMetrics.GetScrollOffset();
}
@@ -3370,26 +3371,26 @@ void AsyncPanZoomController::NotifyLayer
{
APZThreadUtils::AssertOnCompositorThread();
ReentrantMonitorAutoEnter lock(mMonitor);
bool isDefault = mScrollMetadata.IsDefault();
const FrameMetrics& aLayerMetrics = aScrollMetadata.GetMetrics();
- if ((aLayerMetrics == mLastContentPaintMetrics) && !isDefault) {
+ if ((aScrollMetadata == mLastContentPaintMetadata) && !isDefault) {
// No new information here, skip it.
APZC_LOG("%p NotifyLayersUpdated short-circuit\n", this);
return;
}
if (aLayerMetrics.GetScrollUpdateType() != FrameMetrics::ScrollOffsetUpdateType::ePending) {
- mLastContentPaintMetrics = aLayerMetrics;
+ mLastContentPaintMetadata = aScrollMetadata;
}
- mFrameMetrics.SetScrollParentId(aLayerMetrics.GetScrollParentId());
+ mScrollMetadata.SetScrollParentId(aScrollMetadata.GetScrollParentId());
APZC_LOG_FM(aLayerMetrics, "%p got a NotifyLayersUpdated with aIsFirstPaint=%d, aThisLayerTreeUpdated=%d",
this, aIsFirstPaint, aThisLayerTreeUpdated);
{ // scope lock
MutexAutoLock lock(mCheckerboardEventLock);
if (mCheckerboardEvent && mCheckerboardEvent->IsRecordingTrace()) {
std::string str;
if (aThisLayerTreeUpdated) {
@@ -3501,26 +3502,26 @@ void AsyncPanZoomController::NotifyLayer
if (!mFrameMetrics.GetScrollableRect().IsEqualEdges(aLayerMetrics.GetScrollableRect())) {
mFrameMetrics.SetScrollableRect(aLayerMetrics.GetScrollableRect());
needContentRepaint = true;
}
mFrameMetrics.SetCompositionBounds(aLayerMetrics.GetCompositionBounds());
mFrameMetrics.SetRootCompositionSize(aLayerMetrics.GetRootCompositionSize());
mFrameMetrics.SetPresShellResolution(aLayerMetrics.GetPresShellResolution());
mFrameMetrics.SetCumulativeResolution(aLayerMetrics.GetCumulativeResolution());
- mFrameMetrics.SetHasScrollgrab(aLayerMetrics.GetHasScrollgrab());
- mFrameMetrics.SetLineScrollAmount(aLayerMetrics.GetLineScrollAmount());
- mFrameMetrics.SetPageScrollAmount(aLayerMetrics.GetPageScrollAmount());
+ mScrollMetadata.SetHasScrollgrab(aScrollMetadata.GetHasScrollgrab());
+ mScrollMetadata.SetLineScrollAmount(aScrollMetadata.GetLineScrollAmount());
+ mScrollMetadata.SetPageScrollAmount(aScrollMetadata.GetPageScrollAmount());
mScrollMetadata.SetSnapInfo(ScrollSnapInfo(aScrollMetadata.GetSnapInfo()));
mScrollMetadata.SetClipRect(aScrollMetadata.GetClipRect());
mScrollMetadata.SetMaskLayerIndex(aScrollMetadata.GetMaskLayerIndex());
- mFrameMetrics.SetIsLayersIdRoot(aLayerMetrics.IsLayersIdRoot());
- mFrameMetrics.SetUsesContainerScrolling(aLayerMetrics.UsesContainerScrolling());
+ mScrollMetadata.SetIsLayersIdRoot(aScrollMetadata.IsLayersIdRoot());
+ mScrollMetadata.SetUsesContainerScrolling(aScrollMetadata.UsesContainerScrolling());
mFrameMetrics.SetIsScrollInfoLayer(aLayerMetrics.IsScrollInfoLayer());
- mFrameMetrics.SetForceDisableApz(aLayerMetrics.IsApzForceDisabled());
+ mScrollMetadata.SetForceDisableApz(aScrollMetadata.IsApzForceDisabled());
if (scrollOffsetUpdated) {
APZC_LOG("%p updating scroll offset from %s to %s\n", this,
ToString(mFrameMetrics.GetScrollOffset()).c_str(),
ToString(aLayerMetrics.GetScrollOffset()).c_str());
// Send an acknowledgement with the new scroll generation so that any
// repaint requests later in this function go through.
@@ -3885,17 +3886,17 @@ void AsyncPanZoomController::UpdateShare
{
mMonitor.AssertCurrentThreadIn();
FrameMetrics* frame = mSharedFrameMetricsBuffer ?
static_cast<FrameMetrics*>(mSharedFrameMetricsBuffer->memory()) : nullptr;
if (frame && mSharedLock && gfxPlatform::GetPlatform()->UseProgressivePaint()) {
mSharedLock->Lock();
- *frame = mFrameMetrics.MakePODObject();
+ *frame = mFrameMetrics;
mSharedLock->Unlock();
}
}
void AsyncPanZoomController::ShareCompositorFrameMetrics() {
PCompositorBridgeParent* compositor = GetSharedFrameMetricsCompositor();
--- a/gfx/layers/apz/src/AsyncPanZoomController.h
+++ b/gfx/layers/apz/src/AsyncPanZoomController.h
@@ -309,17 +309,17 @@ public:
* Clear any overscroll on this APZC.
*/
void ClearOverscroll();
/**
* Returns whether this APZC is for an element marked with the 'scrollgrab'
* attribute.
*/
- bool HasScrollgrab() const { return mFrameMetrics.GetHasScrollgrab(); }
+ bool HasScrollgrab() const { return mScrollMetadata.GetHasScrollgrab(); }
/**
* Returns whether this APZC has room to be panned (in any direction).
*/
bool IsPannable() const;
/**
* Returns true if the APZC has been flung with a velocity greater than the
@@ -655,23 +655,24 @@ protected:
// monitor should be held. When setting |mState|, either the SetState()
// function can be used, or the monitor can be held and then |mState| updated.
// IMPORTANT: See the note about lock ordering at the top of APZCTreeManager.h.
// This is mutable to allow entering it from 'const' methods; doing otherwise
// would significantly limit what methods could be 'const'.
mutable ReentrantMonitor mMonitor;
private:
- // Metrics of the container layer corresponding to this APZC. This is
+ // Metadata of the container layer corresponding to this APZC. This is
// stored here so that it is accessible from the UI/controller thread.
// These are the metrics at last content paint, the most recent
// values we were notified of in NotifyLayersUpdate(). Since it represents
// the Gecko state, it should be used as a basis for untransformation when
// sending messages back to Gecko.
- FrameMetrics mLastContentPaintMetrics;
+ ScrollMetadata mLastContentPaintMetadata;
+ FrameMetrics& mLastContentPaintMetrics; // for convenience, refers to mLastContentPaintMetadata.mMetrics
// The last metrics used for a content repaint request.
FrameMetrics mLastPaintRequestMetrics;
// The metrics that we expect content to have. This is updated when we
// request a content repaint, and when we receive a shadow layers update.
// This allows us to transform events into Gecko's coordinate space.
FrameMetrics mExpectedGeckoMetrics;
AxisX mX;
@@ -914,17 +915,17 @@ public:
* layers id.
*/
bool HasNoParentWithSameLayersId() const {
return !mParent || (mParent->mLayersId != mLayersId);
}
bool IsRootForLayersId() const {
ReentrantMonitorAutoEnter lock(mMonitor);
- return mFrameMetrics.IsLayersIdRoot();
+ return mScrollMetadata.IsLayersIdRoot();
}
bool IsRootContent() const {
ReentrantMonitorAutoEnter lock(mMonitor);
return mFrameMetrics.IsRootContent();
}
private:
@@ -935,17 +936,17 @@ private:
/* ===================================================================
* The functions and members in this section are used for scrolling,
* including handing off scroll to another APZC, and overscrolling.
*/
public:
FrameMetrics::ViewID GetScrollHandoffParentId() const {
- return mFrameMetrics.GetScrollParentId();
+ return mScrollMetadata.GetScrollParentId();
}
/**
* Attempt to scroll in response to a touch-move from |aStartPoint| to
* |aEndPoint|, which are in our (transformed) screen coordinates.
* Due to overscroll handling, there may not actually have been a touch-move
* at these points, but this function will scroll as if there had been.
* If this attempt causes overscroll (i.e. the layer cannot be scrolled
--- a/gfx/layers/apz/src/WheelScrollAnimation.cpp
+++ b/gfx/layers/apz/src/WheelScrollAnimation.cpp
@@ -62,17 +62,17 @@ WheelScrollAnimation::DoSample(FrameMetr
mApzc.mX.SetVelocity(xVelocity);
mApzc.mY.SetVelocity(yVelocity);
}
// Note: we ignore overscroll for wheel animations.
ParentLayerPoint adjustedOffset, overscroll;
mApzc.mX.AdjustDisplacement(displacement.x, adjustedOffset.x, overscroll.x);
mApzc.mY.AdjustDisplacement(displacement.y, adjustedOffset.y, overscroll.y,
- !aFrameMetrics.AllowVerticalScrollWithWheel());
+ !mApzc.mScrollMetadata.AllowVerticalScrollWithWheel());
// If we expected to scroll, but there's no more scroll range on either axis,
// then end the animation early. Note that the initial displacement could be 0
// if the compositor ran very quickly (<1ms) after the animation was created.
// When that happens we want to make sure the animation continues.
if (!IsZero(displacement) && IsZero(adjustedOffset)) {
// Nothing more to do - end the animation.
return false;
--- a/gfx/layers/apz/test/gtest/APZCTreeManagerTester.h
+++ b/gfx/layers/apz/test/gtest/APZCTreeManagerTester.h
@@ -61,24 +61,24 @@ protected:
const CSSRect& aScrollableRect,
const ParentLayerRect& aCompositionBounds)
{
ScrollMetadata metadata;
FrameMetrics& metrics = metadata.GetMetrics();
metrics.SetScrollId(aScrollId);
// By convention in this test file, START_SCROLL_ID is the root, so mark it as such.
if (aScrollId == FrameMetrics::START_SCROLL_ID) {
- metrics.SetIsLayersIdRoot(true);
+ metadata.SetIsLayersIdRoot(true);
}
metrics.SetCompositionBounds(aCompositionBounds);
metrics.SetScrollableRect(aScrollableRect);
metrics.SetScrollOffset(CSSPoint(0, 0));
- metrics.SetPageScrollAmount(LayoutDeviceIntSize(50, 100));
- metrics.SetLineScrollAmount(LayoutDeviceIntSize(5, 10));
- metrics.SetAllowVerticalScrollWithWheel(true);
+ metadata.SetPageScrollAmount(LayoutDeviceIntSize(50, 100));
+ metadata.SetLineScrollAmount(LayoutDeviceIntSize(5, 10));
+ metadata.SetAllowVerticalScrollWithWheel(true);
return metadata;
}
static void SetEventRegionsBasedOnBottommostMetrics(Layer* aLayer)
{
const FrameMetrics& metrics = aLayer->GetScrollMetadata(0).GetMetrics();
CSSRect scrollableRect = metrics.GetScrollableRect();
if (!scrollableRect.IsEqualEdges(CSSRect(-1, -1, -1, -1))) {
@@ -103,17 +103,17 @@ protected:
ParentLayerRect(compositionBounds));
aLayer->SetScrollMetadata(metadata);
aLayer->SetClipRect(Some(compositionBounds));
SetEventRegionsBasedOnBottommostMetrics(aLayer);
}
void SetScrollHandoff(Layer* aChild, Layer* aParent) {
ScrollMetadata metadata = aChild->GetScrollMetadata(0);
- metadata.GetMetrics().SetScrollParentId(aParent->GetFrameMetrics(0).GetScrollId());
+ metadata.SetScrollParentId(aParent->GetFrameMetrics(0).GetScrollId());
aChild->SetScrollMetadata(metadata);
}
static TestAsyncPanZoomController* ApzcOf(Layer* aLayer) {
EXPECT_EQ(1u, aLayer->GetScrollMetadataCount());
return (TestAsyncPanZoomController*)aLayer->GetAsyncPanZoomController(0);
}
--- a/gfx/layers/apz/test/gtest/APZTestCommon.h
+++ b/gfx/layers/apz/test/gtest/APZTestCommon.h
@@ -219,16 +219,21 @@ public:
mFrameMetrics = metrics;
}
FrameMetrics& GetFrameMetrics() {
ReentrantMonitorAutoEnter lock(mMonitor);
return mFrameMetrics;
}
+ ScrollMetadata& GetScrollMetadata() {
+ ReentrantMonitorAutoEnter lock(mMonitor);
+ return mScrollMetadata;
+ }
+
const FrameMetrics& GetFrameMetrics() const {
ReentrantMonitorAutoEnter lock(mMonitor);
return mFrameMetrics;
}
using AsyncPanZoomController::GetVelocityVector;
void AssertStateIsReset() const {
--- a/gfx/layers/apz/test/gtest/TestHitTesting.cpp
+++ b/gfx/layers/apz/test/gtest/TestHitTesting.cpp
@@ -55,17 +55,17 @@ protected:
SetScrollableFrameMetrics(root, FrameMetrics::START_SCROLL_ID, CSSRect(0, 0, 200, 200));
SetScrollableFrameMetrics(layers[1], FrameMetrics::START_SCROLL_ID + 1, CSSRect(0, 0, 80, 80));
SetScrollableFrameMetrics(layers[3], FrameMetrics::START_SCROLL_ID + 2, CSSRect(0, 0, 80, 80));
}
void DisableApzOn(Layer* aLayer) {
ScrollMetadata m = aLayer->GetScrollMetadata(0);
- m.GetMetrics().SetForceDisableApz(true);
+ m.SetForceDisableApz(true);
aLayer->SetScrollMetadata(m);
}
void CreateComplexMultiLayerTree() {
const char* layerTreeSyntax = "c(tc(t)tc(c(t)tt))";
// LayerID 0 12 3 45 6 7 89
nsIntRegion layerVisibleRegion[] = {
nsIntRegion(IntRect(0,0,300,400)), // root(0)
--- a/gfx/layers/apz/test/gtest/TestScrollHandoff.cpp
+++ b/gfx/layers/apz/test/gtest/TestScrollHandoff.cpp
@@ -78,17 +78,17 @@ protected:
root = CreateLayerTree(layerTreeSyntax, layerVisibleRegion, nullptr, lm, layers);
float parentHeight = makeParentScrollable ? 120 : 100;
SetScrollableFrameMetrics(root, FrameMetrics::START_SCROLL_ID, CSSRect(0, 0, 100, parentHeight));
SetScrollableFrameMetrics(layers[1], FrameMetrics::START_SCROLL_ID + 1, CSSRect(0, 0, 100, 200));
SetScrollHandoff(layers[1], root);
registration = MakeUnique<ScopedLayerTreeRegistration>(manager, 0, root, mcc);
manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);
rootApzc = ApzcOf(root);
- rootApzc->GetFrameMetrics().SetHasScrollgrab(true);
+ rootApzc->GetScrollMetadata().SetHasScrollgrab(true);
}
void TestFlingAcceleration() {
// Jack up the fling acceleration multiplier so we can easily determine
// whether acceleration occured.
const float kAcceleration = 100.0f;
SCOPED_GFX_PREF(APZFlingAccelBaseMultiplier, float, kAcceleration);
--- a/gfx/layers/composite/AsyncCompositionManager.cpp
+++ b/gfx/layers/composite/AsyncCompositionManager.cpp
@@ -894,17 +894,17 @@ AsyncCompositionManager::ApplyAsyncConte
// Non-Android platforms still care about this flag being cleared after
// the first call to TransformShadowTree().
mIsFirstPaint = false;
#endif
// Transform the current local clip by this APZC's async transform. If we're
// using containerful scrolling, then the clip is not part of the scrolled
// frame and should not be transformed.
- if (asyncClip && !metrics.UsesContainerScrolling()) {
+ if (asyncClip && !scrollMetadata.UsesContainerScrolling()) {
MOZ_ASSERT(asyncTransform.Is2D());
asyncClip = Some(TransformBy(asyncTransform, *asyncClip));
}
aLayer->AsLayerComposite()->SetShadowClipRect(asyncClip);
combinedAsyncTransform *= asyncTransform;
// For the purpose of aligning fixed and sticky layers, we disregard
--- a/gfx/layers/composite/ContainerLayerComposite.cpp
+++ b/gfx/layers/composite/ContainerLayerComposite.cpp
@@ -57,17 +57,17 @@ static bool
LayerHasCheckerboardingAPZC(Layer* aLayer, Color* aOutColor)
{
for (LayerMetricsWrapper i(aLayer, LayerMetricsWrapper::StartAt::BOTTOM); i; i = i.GetParent()) {
if (!i.Metrics().IsScrollable()) {
continue;
}
if (i.GetApzc() && i.GetApzc()->IsCurrentlyCheckerboarding()) {
if (aOutColor) {
- *aOutColor = i.Metrics().GetBackgroundColor();
+ *aOutColor = i.Metadata().GetBackgroundColor();
}
return true;
}
break;
}
return false;
}
--- a/gfx/layers/composite/TiledContentHost.cpp
+++ b/gfx/layers/composite/TiledContentHost.cpp
@@ -480,17 +480,17 @@ TiledContentHost::Composite(LayerComposi
// we end up changing the expected overall transparency of the content,
// and it just looks wrong.
Color backgroundColor;
if (aOpacity == 1.0f && gfxPrefs::LowPrecisionOpacity() < 1.0f) {
// Background colors are only stored on scrollable layers. Grab
// the one from the nearest scrollable ancestor layer.
for (LayerMetricsWrapper ancestor(GetLayer(), LayerMetricsWrapper::StartAt::BOTTOM); ancestor; ancestor = ancestor.GetParent()) {
if (ancestor.Metrics().IsScrollable()) {
- backgroundColor = ancestor.Metrics().GetBackgroundColor();
+ backgroundColor = ancestor.Metadata().GetBackgroundColor();
break;
}
}
}
float lowPrecisionOpacityReduction =
(aOpacity == 1.0f && backgroundColor.a == 1.0f)
? gfxPrefs::LowPrecisionOpacity() : 1.0f;
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -8785,46 +8785,46 @@ nsLayoutUtils::ComputeScrollMetadata(nsI
nsIAtom* lastSmoothScrollOrigin = scrollableFrame->LastSmoothScrollOrigin();
if (lastSmoothScrollOrigin) {
metrics.SetSmoothScrollOffsetUpdated(scrollableFrame->CurrentScrollGeneration());
}
nsSize lineScrollAmount = scrollableFrame->GetLineScrollAmount();
LayoutDeviceIntSize lineScrollAmountInDevPixels =
LayoutDeviceIntSize::FromAppUnitsRounded(lineScrollAmount, presContext->AppUnitsPerDevPixel());
- metrics.SetLineScrollAmount(lineScrollAmountInDevPixels);
+ metadata.SetLineScrollAmount(lineScrollAmountInDevPixels);
nsSize pageScrollAmount = scrollableFrame->GetPageScrollAmount();
LayoutDeviceIntSize pageScrollAmountInDevPixels =
LayoutDeviceIntSize::FromAppUnitsRounded(pageScrollAmount, presContext->AppUnitsPerDevPixel());
- metrics.SetPageScrollAmount(pageScrollAmountInDevPixels);
+ metadata.SetPageScrollAmount(pageScrollAmountInDevPixels);
if (!aScrollFrame->GetParent() ||
EventStateManager::CanVerticallyScrollFrameWithWheel(aScrollFrame->GetParent()))
{
- metrics.SetAllowVerticalScrollWithWheel(true);
- }
-
- metrics.SetUsesContainerScrolling(scrollableFrame->UsesContainerScrolling());
+ metadata.SetAllowVerticalScrollWithWheel(true);
+ }
+
+ metadata.SetUsesContainerScrolling(scrollableFrame->UsesContainerScrolling());
metadata.SetSnapInfo(scrollableFrame->GetScrollSnapInfo());
}
// If we have the scrollparent being the same as the scroll id, the
// compositor-side code could get into an infinite loop while building the
// overscroll handoff chain.
MOZ_ASSERT(aScrollParentId == FrameMetrics::NULL_SCROLL_ID || scrollId != aScrollParentId);
metrics.SetScrollId(scrollId);
metrics.SetIsRootContent(aIsRootContent);
- metrics.SetScrollParentId(aScrollParentId);
+ metadata.SetScrollParentId(aScrollParentId);
if (scrollId != FrameMetrics::NULL_SCROLL_ID && !presContext->GetParentPresContext()) {
if ((aScrollFrame && (aScrollFrame == presShell->GetRootScrollFrame())) ||
aContent == presShell->GetDocument()->GetDocumentElement()) {
- metrics.SetIsLayersIdRoot(true);
+ metadata.SetIsLayersIdRoot(true);
}
}
// Only the root scrollable frame for a given presShell should pick up
// the presShell's resolution. All the other frames are 1.0.
if (aScrollFrame == presShell->GetRootScrollFrame()) {
metrics.SetPresShellResolution(presShell->GetResolution());
} else {
@@ -8902,48 +8902,48 @@ nsLayoutUtils::ComputeScrollMetadata(nsI
metrics.SetRootCompositionSize(
nsLayoutUtils::CalculateRootCompositionSize(aScrollFrame ? aScrollFrame : aForFrame,
isRootContentDocRootScrollFrame, metrics));
if (gfxPrefs::APZPrintTree() || gfxPrefs::APZTestLoggingEnabled()) {
if (nsIContent* content = frameForCompositionBoundsCalculation->GetContent()) {
nsAutoString contentDescription;
content->Describe(contentDescription);
- metrics.SetContentDescription(NS_LossyConvertUTF16toASCII(contentDescription));
+ metadata.SetContentDescription(NS_LossyConvertUTF16toASCII(contentDescription));
nsLayoutUtils::LogTestDataForPaint(aLayer->Manager(), scrollId, "contentDescription",
- metrics.GetContentDescription().get());
+ metadata.GetContentDescription().get());
}
}
metrics.SetPresShellId(presShell->GetPresShellId());
// If the scroll frame's content is marked 'scrollgrab', record this
// in the FrameMetrics so APZ knows to provide the scroll grabbing
// behaviour.
if (aScrollFrame && nsContentUtils::HasScrollgrab(aScrollFrame->GetContent())) {
- metrics.SetHasScrollgrab(true);
+ metadata.SetHasScrollgrab(true);
}
// Also compute and set the background color.
// This is needed for APZ overscrolling support.
if (aScrollFrame) {
if (isRootScrollFrame) {
- metrics.SetBackgroundColor(Color::FromABGR(
+ metadata.SetBackgroundColor(Color::FromABGR(
presShell->GetCanvasBackground()));
} else {
nsStyleContext* backgroundStyle;
if (nsCSSRendering::FindBackground(aScrollFrame, &backgroundStyle)) {
- metrics.SetBackgroundColor(Color::FromABGR(
+ metadata.SetBackgroundColor(Color::FromABGR(
backgroundStyle->StyleBackground()->mBackgroundColor));
}
}
}
if (ShouldDisableApzForElement(aContent)) {
- metrics.SetForceDisableApz(true);
+ metadata.SetForceDisableApz(true);
}
return metadata;
}
/* static */ bool
nsLayoutUtils::ContainsMetricsWithId(const Layer* aLayer, const ViewID& aScrollId)
{