зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1267438 - Group ScrollMetadata's optional clip rect and mask layer index into a LayerClip structure. r=mstange
MozReview-Commit-ID: 6W0GZYkioov --HG-- extra : rebase_source : c46d0d27145df9b268e70ab5aed67c8c64df9433 extra : histedit_source : 016fe1d78bde06feeb483446fdfb508448573d72
This commit is contained in:
Родитель
f9b1e198bb
Коммит
8699c362f8
|
@ -789,6 +789,24 @@ struct ParamTraits<mozilla::layers::ScrollSnapInfo>
|
|||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::layers::LayerClip>
|
||||
{
|
||||
typedef mozilla::layers::LayerClip paramType;
|
||||
|
||||
static void Write(Message* aMsg, const paramType& aParam)
|
||||
{
|
||||
WriteParam(aMsg, aParam.mClipRect);
|
||||
WriteParam(aMsg, aParam.mMaskLayerIndex);
|
||||
}
|
||||
|
||||
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
|
||||
{
|
||||
return (ReadParam(aMsg, aIter, &aResult->mClipRect) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mMaskLayerIndex));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::layers::ScrollMetadata>
|
||||
: BitfieldHelper<mozilla::layers::ScrollMetadata>
|
||||
|
@ -804,8 +822,7 @@ struct ParamTraits<mozilla::layers::ScrollMetadata>
|
|||
WriteParam(aMsg, aParam.GetContentDescription());
|
||||
WriteParam(aMsg, aParam.mLineScrollAmount);
|
||||
WriteParam(aMsg, aParam.mPageScrollAmount);
|
||||
WriteParam(aMsg, aParam.mMaskLayerIndex);
|
||||
WriteParam(aMsg, aParam.mClipRect);
|
||||
WriteParam(aMsg, aParam.mScrollClip);
|
||||
WriteParam(aMsg, aParam.mHasScrollgrab);
|
||||
WriteParam(aMsg, aParam.mAllowVerticalScrollWithWheel);
|
||||
WriteParam(aMsg, aParam.mIsLayersIdRoot);
|
||||
|
@ -832,8 +849,7 @@ struct ParamTraits<mozilla::layers::ScrollMetadata>
|
|||
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->mScrollClip) &&
|
||||
ReadBoolForBitfield(aMsg, aIter, aResult, ¶mType::SetHasScrollgrab) &&
|
||||
ReadBoolForBitfield(aMsg, aIter, aResult, ¶mType::SetAllowVerticalScrollWithWheel) &&
|
||||
ReadBoolForBitfield(aMsg, aIter, aResult, ¶mType::SetIsLayersIdRoot) &&
|
||||
|
|
|
@ -679,6 +679,52 @@ struct ScrollSnapInfo {
|
|||
nsTArray<nsPoint> mScrollSnapCoordinates;
|
||||
};
|
||||
|
||||
/**
|
||||
* 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;
|
||||
};
|
||||
|
||||
/**
|
||||
* 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,
|
||||
|
@ -701,8 +747,7 @@ public:
|
|||
, mContentDescription()
|
||||
, mLineScrollAmount(0, 0)
|
||||
, mPageScrollAmount(0, 0)
|
||||
, mMaskLayerIndex()
|
||||
, mClipRect()
|
||||
, mScrollClip()
|
||||
, mHasScrollgrab(false)
|
||||
, mAllowVerticalScrollWithWheel(false)
|
||||
, mIsLayersIdRoot(false)
|
||||
|
@ -719,8 +764,7 @@ public:
|
|||
// don't compare mContentDescription
|
||||
mLineScrollAmount == aOther.mLineScrollAmount &&
|
||||
mPageScrollAmount == aOther.mPageScrollAmount &&
|
||||
mMaskLayerIndex == aOther.mMaskLayerIndex &&
|
||||
mClipRect == aOther.mClipRect &&
|
||||
mScrollClip == aOther.mScrollClip &&
|
||||
mHasScrollgrab == aOther.mHasScrollgrab &&
|
||||
mAllowVerticalScrollWithWheel == aOther.mAllowVerticalScrollWithWheel &&
|
||||
mIsLayersIdRoot == aOther.mIsLayersIdRoot &&
|
||||
|
@ -780,26 +824,28 @@ public:
|
|||
void SetPageScrollAmount(const LayoutDeviceIntSize& size) {
|
||||
mPageScrollAmount = size;
|
||||
}
|
||||
void SetMaskLayerIndex(const Maybe<size_t>& aIndex) {
|
||||
mMaskLayerIndex = aIndex;
|
||||
|
||||
void SetScrollClip(const Maybe<LayerClip>& aScrollClip) {
|
||||
mScrollClip = aScrollClip;
|
||||
}
|
||||
const Maybe<size_t>& GetMaskLayerIndex() const {
|
||||
return mMaskLayerIndex;
|
||||
const Maybe<LayerClip>& GetScrollClip() const {
|
||||
return mScrollClip;
|
||||
}
|
||||
bool HasScrollClip() const {
|
||||
return mScrollClip.isSome();
|
||||
}
|
||||
const LayerClip& ScrollClip() const {
|
||||
return mScrollClip.ref();
|
||||
}
|
||||
LayerClip& ScrollClip() {
|
||||
return mScrollClip.ref();
|
||||
}
|
||||
|
||||
void SetClipRect(const Maybe<ParentLayerIntRect>& aClipRect)
|
||||
{
|
||||
mClipRect = aClipRect;
|
||||
bool HasMaskLayer() const {
|
||||
return HasScrollClip() && ScrollClip().GetMaskLayerIndex();
|
||||
}
|
||||
const Maybe<ParentLayerIntRect>& GetClipRect() const
|
||||
{
|
||||
return mClipRect;
|
||||
}
|
||||
bool HasClipRect() const {
|
||||
return mClipRect.isSome();
|
||||
}
|
||||
const ParentLayerIntRect& ClipRect() const {
|
||||
return mClipRect.ref();
|
||||
Maybe<ParentLayerIntRect> GetClipRect() const {
|
||||
return mScrollClip.isSome() ? Some(mScrollClip->GetClipRect()) : Nothing();
|
||||
}
|
||||
|
||||
void SetHasScrollgrab(bool aHasScrollgrab) {
|
||||
|
@ -856,13 +902,13 @@ private:
|
|||
// 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;
|
||||
// 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;
|
||||
|
||||
// Whether or not this frame is for an element marked 'scrollgrab'.
|
||||
bool mHasScrollgrab:1;
|
||||
|
|
|
@ -154,8 +154,8 @@ AppendToString(std::stringstream& aStream, const ScrollMetadata& m,
|
|||
if (m.GetScrollParentId() != FrameMetrics::NULL_SCROLL_ID) {
|
||||
AppendToString(aStream, m.GetScrollParentId(), "] [scrollParent=");
|
||||
}
|
||||
if (m.HasClipRect()) {
|
||||
AppendToString(aStream, m.ClipRect(), "] [clip=");
|
||||
if (m.HasScrollClip()) {
|
||||
AppendToString(aStream, m.ScrollClip().GetClipRect(), "] [clip=");
|
||||
}
|
||||
aStream << "] }" << sfx;
|
||||
}
|
||||
|
|
|
@ -3521,8 +3521,7 @@ void AsyncPanZoomController::NotifyLayersUpdated(const ScrollMetadata& aScrollMe
|
|||
mScrollMetadata.SetLineScrollAmount(aScrollMetadata.GetLineScrollAmount());
|
||||
mScrollMetadata.SetPageScrollAmount(aScrollMetadata.GetPageScrollAmount());
|
||||
mScrollMetadata.SetSnapInfo(ScrollSnapInfo(aScrollMetadata.GetSnapInfo()));
|
||||
mScrollMetadata.SetClipRect(aScrollMetadata.GetClipRect());
|
||||
mScrollMetadata.SetMaskLayerIndex(aScrollMetadata.GetMaskLayerIndex());
|
||||
mScrollMetadata.SetScrollClip(aScrollMetadata.GetScrollClip());
|
||||
mScrollMetadata.SetIsLayersIdRoot(aScrollMetadata.IsLayersIdRoot());
|
||||
mScrollMetadata.SetUsesContainerScrolling(aScrollMetadata.UsesContainerScrolling());
|
||||
mFrameMetrics.SetIsScrollInfoLayer(aLayerMetrics.IsScrollInfoLayer());
|
||||
|
|
|
@ -560,7 +560,7 @@ TEST_F(APZHitTestingTester, HitTestingRespectsScrollClip_Bug1257288) {
|
|||
ScrollMetadata subframeMetadata = BuildScrollMetadata(
|
||||
FrameMetrics::START_SCROLL_ID + 1, CSSRect(0,0,200,200),
|
||||
ParentLayerRect(0,0,200,100));
|
||||
subframeMetadata.SetClipRect(Some(ParentLayerIntRect(0,0,200,100)));
|
||||
subframeMetadata.SetScrollClip(Some(LayerClip(ParentLayerIntRect(0,0,200,100))));
|
||||
layers[2]->SetScrollMetadata({subframeMetadata, rootMetadata});
|
||||
layers[2]->SetClipRect(Some(ParentLayerIntRect(0,0,200,200)));
|
||||
SetEventRegionsBasedOnBottommostMetrics(layers[2]);
|
||||
|
|
|
@ -932,8 +932,8 @@ AsyncCompositionManager::ApplyAsyncContentTransformToTree(Layer *aLayer,
|
|||
// Combine the local clip with the ancestor scrollframe clip. This is not
|
||||
// included in the async transform above, since the ancestor clip should not
|
||||
// move with this APZC.
|
||||
if (scrollMetadata.HasClipRect()) {
|
||||
ParentLayerIntRect clip = scrollMetadata.ClipRect();
|
||||
if (scrollMetadata.HasScrollClip()) {
|
||||
ParentLayerIntRect clip = scrollMetadata.ScrollClip().GetClipRect();
|
||||
if (aLayer->GetParent() && aLayer->GetParent()->GetTransformIsPerspective()) {
|
||||
// If our parent layer has a perspective transform, we want to apply
|
||||
// our scroll clip to it instead of to this layer (see bug 1168263).
|
||||
|
@ -961,10 +961,13 @@ AsyncCompositionManager::ApplyAsyncContentTransformToTree(Layer *aLayer,
|
|||
}
|
||||
|
||||
// Append the ancestor mask layer for this scroll frame to ancestorMaskLayers.
|
||||
if (scrollMetadata.GetMaskLayerIndex()) {
|
||||
size_t maskLayerIndex = scrollMetadata.GetMaskLayerIndex().value();
|
||||
Layer* ancestorMaskLayer = aLayer->GetAncestorMaskLayerAt(maskLayerIndex);
|
||||
ancestorMaskLayers.AppendElement(ancestorMaskLayer);
|
||||
if (scrollMetadata.HasScrollClip()) {
|
||||
const LayerClip& scrollClip = scrollMetadata.ScrollClip();
|
||||
if (scrollClip.GetMaskLayerIndex()) {
|
||||
size_t maskLayerIndex = scrollClip.GetMaskLayerIndex().value();
|
||||
Layer* ancestorMaskLayer = aLayer->GetAncestorMaskLayerAt(maskLayerIndex);
|
||||
ancestorMaskLayers.AppendElement(ancestorMaskLayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4623,7 +4623,7 @@ ContainerState::SetupScrollingMetadata(NewLayerEntry* aEntry)
|
|||
|
||||
// The base FrameMetrics was not computed by the nsIScrollableframe, so it
|
||||
// should not have a mask layer.
|
||||
MOZ_ASSERT(!aEntry->mBaseScrollMetadata->GetMaskLayerIndex());
|
||||
MOZ_ASSERT(!aEntry->mBaseScrollMetadata->HasMaskLayer());
|
||||
}
|
||||
|
||||
// Any extra mask layers we need to attach to FrameMetrics.
|
||||
|
@ -4660,7 +4660,8 @@ ContainerState::SetupScrollingMetadata(NewLayerEntry* aEntry)
|
|||
RefPtr<Layer> maskLayer =
|
||||
CreateMaskLayer(aEntry->mLayer, *clip, nextIndex, clip->GetRoundedRectCount());
|
||||
if (maskLayer) {
|
||||
metadata->SetMaskLayerIndex(nextIndex);
|
||||
MOZ_ASSERT(metadata->HasScrollClip());
|
||||
metadata->ScrollClip().SetMaskLayerIndex(nextIndex);
|
||||
maskLayers.AppendElement(maskLayer);
|
||||
}
|
||||
}
|
||||
|
@ -4673,7 +4674,7 @@ ContainerState::SetupScrollingMetadata(NewLayerEntry* aEntry)
|
|||
aEntry->mLayer->SetAncestorMaskLayers(maskLayers);
|
||||
}
|
||||
|
||||
static inline const Maybe<ParentLayerIntRect>&
|
||||
static inline Maybe<ParentLayerIntRect>
|
||||
GetStationaryClipInContainer(Layer* aLayer)
|
||||
{
|
||||
if (size_t metricsCount = aLayer->GetScrollMetadataCount()) {
|
||||
|
@ -4707,7 +4708,7 @@ ContainerState::PostprocessRetainedLayers(nsIntRegion* aOpaqueRegionForContainer
|
|||
if (hideAll) {
|
||||
e->mVisibleRegion.SetEmpty();
|
||||
} else if (!e->mLayer->IsScrollbarContainer()) {
|
||||
const Maybe<ParentLayerIntRect>& clipRect = GetStationaryClipInContainer(e->mLayer);
|
||||
Maybe<ParentLayerIntRect> clipRect = GetStationaryClipInContainer(e->mLayer);
|
||||
if (clipRect && opaqueRegionForContainer >= 0 &&
|
||||
opaqueRegions[opaqueRegionForContainer].mOpaqueRegion.Contains(clipRect->ToUnknownRect())) {
|
||||
e->mVisibleRegion.SetEmpty();
|
||||
|
|
|
@ -8899,7 +8899,7 @@ nsLayoutUtils::ComputeScrollMetadata(nsIFrame* aForFrame,
|
|||
ParentLayerRect rect = LayoutDeviceRect::FromAppUnits(*aClipRect, auPerDevPixel)
|
||||
* metrics.GetCumulativeResolution()
|
||||
* layerToParentLayerScale;
|
||||
metadata.SetClipRect(Some(RoundedToInt(rect)));
|
||||
metadata.SetScrollClip(Some(LayerClip(RoundedToInt(rect))));
|
||||
}
|
||||
|
||||
// For the root scroll frame of the root content document (RCD-RSF), the above calculation
|
||||
|
|
Загрузка…
Ссылка в новой задаче