Bug 1168630. Part 1. Add layers id to hit test node. r=botond

When the ancestors of a hit testing node do not have an APZC we will need the layers id of the layer that was hit in order to find the root APZC for that layers id.
This commit is contained in:
Timothy Nikkel 2015-05-31 14:44:40 -05:00
parent b7b83c6e85
commit fb6ffd1418
6 changed files with 32 additions and 13 deletions

View File

@ -213,7 +213,7 @@ AppendToString(std::stringstream& aStream, const ScrollableLayerGuid& s,
const char* pfx, const char* sfx)
{
aStream << pfx
<< nsPrintfCString("{ l=%llu, p=%u, v=%llu }", s.mLayersId, s.mPresShellId, s.mScrollId).get()
<< nsPrintfCString("{ l=%" PRIu64 ", p=%u, v=%" PRIu64 " }", s.mLayersId, s.mPresShellId, s.mScrollId).get()
<< sfx;
}

View File

@ -280,7 +280,8 @@ GetEventRegions(const LayerMetricsWrapper& aLayer)
already_AddRefed<HitTestingTreeNode>
APZCTreeManager::RecycleOrCreateNode(TreeBuildingState& aState,
AsyncPanZoomController* aApzc)
AsyncPanZoomController* aApzc,
uint64_t aLayersId)
{
// Find a node without an APZC and return it. Note that unless the layer tree
// actually changes, this loop should generally do an early-return on the
@ -289,11 +290,11 @@ APZCTreeManager::RecycleOrCreateNode(TreeBuildingState& aState,
nsRefPtr<HitTestingTreeNode> node = aState.mNodesToDestroy[i];
if (!node->IsPrimaryHolder()) {
aState.mNodesToDestroy.RemoveElement(node);
node->RecycleWith(aApzc);
node->RecycleWith(aApzc, aLayersId);
return node.forget();
}
}
nsRefPtr<HitTestingTreeNode> node = new HitTestingTreeNode(aApzc, false);
nsRefPtr<HitTestingTreeNode> node = new HitTestingTreeNode(aApzc, false, aLayersId);
return node.forget();
}
@ -333,7 +334,7 @@ APZCTreeManager::PrepareNodeForLayer(const LayerMetricsWrapper& aLayer,
nsRefPtr<HitTestingTreeNode> node = nullptr;
if (!needsApzc) {
node = RecycleOrCreateNode(aState, nullptr);
node = RecycleOrCreateNode(aState, nullptr, aLayersId);
AttachNodeToTree(node, aParent, aNextSibling);
node->SetHitTestData(GetEventRegions(aLayer), aLayer.GetTransform(),
aLayer.GetClipRect() ? Some(ParentLayerIntRegion(*aLayer.GetClipRect())) : Nothing(),
@ -413,7 +414,7 @@ APZCTreeManager::PrepareNodeForLayer(const LayerMetricsWrapper& aLayer,
apzc->ShareFrameMetricsAcrossProcesses();
}
MOZ_ASSERT(node == nullptr);
node = new HitTestingTreeNode(apzc, true);
node = new HitTestingTreeNode(apzc, true, aLayersId);
} else {
// If we are re-using a node for this layer clear the tree pointers
// so that it doesn't continue pointing to nodes that might no longer
@ -487,7 +488,7 @@ APZCTreeManager::PrepareNodeForLayer(const LayerMetricsWrapper& aLayer,
// now that will also be using that APZC. The hit-test region on the APZC needs
// to be updated to deal with the new layer's hit region.
node = RecycleOrCreateNode(aState, apzc);
node = RecycleOrCreateNode(aState, apzc, aLayersId);
AttachNodeToTree(node, aParent, aNextSibling);
// Even though different layers associated with a given APZC may be at

View File

@ -433,7 +433,8 @@ private:
void FlushRepaintsRecursively(HitTestingTreeNode* aNode);
already_AddRefed<HitTestingTreeNode> RecycleOrCreateNode(TreeBuildingState& aState,
AsyncPanZoomController* aApzc);
AsyncPanZoomController* aApzc,
uint64_t aLayersId);
HitTestingTreeNode* PrepareNodeForLayer(const LayerMetricsWrapper& aLayer,
const FrameMetrics& aMetrics,
uint64_t aLayersId,

View File

@ -1087,6 +1087,11 @@ public:
return mAsyncTransformAppliedToContent;
}
uint64_t GetLayersId() const
{
return mLayersId;
}
private:
// Extra offset to add in SampleContentTransformForFrame for testing
CSSPoint mTestAsyncScrollOffset;

View File

@ -18,22 +18,28 @@ namespace mozilla {
namespace layers {
HitTestingTreeNode::HitTestingTreeNode(AsyncPanZoomController* aApzc,
bool aIsPrimaryHolder)
bool aIsPrimaryHolder,
uint64_t aLayersId)
: mApzc(aApzc)
, mIsPrimaryApzcHolder(aIsPrimaryHolder)
, mLayersId(aLayersId)
, mOverride(EventRegionsOverride::NoOverride)
{
if (mIsPrimaryApzcHolder) {
MOZ_ASSERT(mApzc);
}
MOZ_ASSERT(!mApzc || mApzc->GetLayersId() == mLayersId);
}
void
HitTestingTreeNode::RecycleWith(AsyncPanZoomController* aApzc)
HitTestingTreeNode::RecycleWith(AsyncPanZoomController* aApzc,
uint64_t aLayersId)
{
MOZ_ASSERT(!mIsPrimaryApzcHolder);
Destroy(); // clear out tree pointers
mApzc = aApzc;
mLayersId = aLayersId;
MOZ_ASSERT(!mApzc || mApzc->GetLayersId() == mLayersId);
// The caller is expected to call SetHitTestData to repopulate the hit-test
// fields.
}
@ -57,6 +63,8 @@ HitTestingTreeNode::Destroy()
}
mApzc = nullptr;
}
mLayersId = 0;
}
void
@ -229,7 +237,8 @@ HitTestingTreeNode::Dump(const char* aPrefix) const
mPrevSibling->Dump(aPrefix);
}
printf_stderr("%sHitTestingTreeNode (%p) APZC (%p) g=(%s) %s%sr=(%s) t=(%s) c=(%s)\n",
aPrefix, this, mApzc.get(), mApzc ? Stringify(mApzc->GetGuid()).c_str() : "",
aPrefix, this, mApzc.get(),
mApzc ? Stringify(mApzc->GetGuid()).c_str() : nsPrintfCString("l=%" PRIu64, mLayersId).get(),
(mOverride & EventRegionsOverride::ForceDispatchToContent) ? "fdtc " : "",
(mOverride & EventRegionsOverride::ForceEmptyHitRegion) ? "fehr " : "",
Stringify(mEventRegions).c_str(), Stringify(mTransform).c_str(),

View File

@ -53,8 +53,9 @@ class HitTestingTreeNode {
private:
~HitTestingTreeNode();
public:
HitTestingTreeNode(AsyncPanZoomController* aApzc, bool aIsPrimaryHolder);
void RecycleWith(AsyncPanZoomController* aApzc);
HitTestingTreeNode(AsyncPanZoomController* aApzc, bool aIsPrimaryHolder,
uint64_t aLayersId);
void RecycleWith(AsyncPanZoomController* aApzc, uint64_t aLayersId);
void Destroy();
/* Tree construction methods */
@ -106,6 +107,8 @@ private:
nsRefPtr<AsyncPanZoomController> mApzc;
bool mIsPrimaryApzcHolder;
uint64_t mLayersId;
/* Let {L,M} be the {layer, scrollable metrics} pair that this node
* corresponds to in the layer tree. mEventRegions contains the event regions
* from L, in the case where event-regions are enabled. If event-regions are