зеркало из https://github.com/mozilla/gecko-dev.git
Bug 900742 - Fix APZC hit testing problem introduced by bug 866232. r=BenWa
This commit is contained in:
Родитель
85e4bb71e5
Коммит
405d81dc18
|
@ -67,7 +67,7 @@ APZCTreeManager::UpdatePanZoomControllerTree(CompositorParent* aCompositor, Laye
|
||||||
aRoot,
|
aRoot,
|
||||||
// aCompositor is null in gtest scenarios
|
// aCompositor is null in gtest scenarios
|
||||||
aCompositor ? aCompositor->RootLayerTreeId() : 0,
|
aCompositor ? aCompositor->RootLayerTreeId() : 0,
|
||||||
nullptr, nullptr,
|
gfx3DMatrix(), nullptr, nullptr,
|
||||||
aIsFirstPaint, aFirstPaintLayersId,
|
aIsFirstPaint, aFirstPaintLayersId,
|
||||||
&apzcsToDestroy);
|
&apzcsToDestroy);
|
||||||
}
|
}
|
||||||
|
@ -81,11 +81,15 @@ APZCTreeManager::UpdatePanZoomControllerTree(CompositorParent* aCompositor, Laye
|
||||||
AsyncPanZoomController*
|
AsyncPanZoomController*
|
||||||
APZCTreeManager::UpdatePanZoomControllerTree(CompositorParent* aCompositor,
|
APZCTreeManager::UpdatePanZoomControllerTree(CompositorParent* aCompositor,
|
||||||
Layer* aLayer, uint64_t aLayersId,
|
Layer* aLayer, uint64_t aLayersId,
|
||||||
|
gfx3DMatrix aTransform,
|
||||||
AsyncPanZoomController* aParent,
|
AsyncPanZoomController* aParent,
|
||||||
AsyncPanZoomController* aNextSibling,
|
AsyncPanZoomController* aNextSibling,
|
||||||
bool aIsFirstPaint, uint64_t aFirstPaintLayersId,
|
bool aIsFirstPaint, uint64_t aFirstPaintLayersId,
|
||||||
nsTArray< nsRefPtr<AsyncPanZoomController> >* aApzcsToDestroy)
|
nsTArray< nsRefPtr<AsyncPanZoomController> >* aApzcsToDestroy)
|
||||||
{
|
{
|
||||||
|
// Accumulate the CSS transform between layers that have an APZC
|
||||||
|
aTransform = aTransform * aLayer->GetTransform();
|
||||||
|
|
||||||
ContainerLayer* container = aLayer->AsContainerLayer();
|
ContainerLayer* container = aLayer->AsContainerLayer();
|
||||||
AsyncPanZoomController* controller = nullptr;
|
AsyncPanZoomController* controller = nullptr;
|
||||||
if (container) {
|
if (container) {
|
||||||
|
@ -116,13 +120,13 @@ APZCTreeManager::UpdatePanZoomControllerTree(CompositorParent* aCompositor,
|
||||||
controller->NotifyLayersUpdated(container->GetFrameMetrics(),
|
controller->NotifyLayersUpdated(container->GetFrameMetrics(),
|
||||||
aIsFirstPaint && (aLayersId == aFirstPaintLayersId));
|
aIsFirstPaint && (aLayersId == aFirstPaintLayersId));
|
||||||
|
|
||||||
gfx3DMatrix transform = container->GetEffectiveTransform();
|
|
||||||
LayerRect visible = container->GetFrameMetrics().mViewport * container->GetFrameMetrics().LayersPixelsPerCSSPixel();
|
LayerRect visible = container->GetFrameMetrics().mViewport * container->GetFrameMetrics().LayersPixelsPerCSSPixel();
|
||||||
gfxRect transformed = transform.TransformBounds(gfxRect(visible.x, visible.y, visible.width, visible.height));
|
controller->SetLayerHitTestData(visible, aTransform);
|
||||||
controller->SetVisibleRegion(transformed);
|
// Reset the accumulated transform once we hit a layer with an APZC
|
||||||
APZC_LOG("Setting rect(%f %f %f %f) as visible region for %p\n", transformed.x, transformed.y,
|
aTransform = gfx3DMatrix();
|
||||||
transformed.width, transformed.height,
|
APZC_LOG("Setting rect(%f %f %f %f) as visible region for APZC %p\n", visible.x, visible.y,
|
||||||
controller);
|
visible.width, visible.height,
|
||||||
|
controller);
|
||||||
|
|
||||||
// Bind the APZC instance into the tree of APZCs
|
// Bind the APZC instance into the tree of APZCs
|
||||||
if (aNextSibling) {
|
if (aNextSibling) {
|
||||||
|
@ -144,7 +148,7 @@ APZCTreeManager::UpdatePanZoomControllerTree(CompositorParent* aCompositor,
|
||||||
uint64_t childLayersId = (aLayer->AsRefLayer() ? aLayer->AsRefLayer()->GetReferentId() : aLayersId);
|
uint64_t childLayersId = (aLayer->AsRefLayer() ? aLayer->AsRefLayer()->GetReferentId() : aLayersId);
|
||||||
AsyncPanZoomController* next = nullptr;
|
AsyncPanZoomController* next = nullptr;
|
||||||
for (Layer* child = aLayer->GetLastChild(); child; child = child->GetPrevSibling()) {
|
for (Layer* child = aLayer->GetLastChild(); child; child = child->GetPrevSibling()) {
|
||||||
next = UpdatePanZoomControllerTree(aCompositor, child, childLayersId, aParent, next,
|
next = UpdatePanZoomControllerTree(aCompositor, child, childLayersId, aTransform, aParent, next,
|
||||||
aIsFirstPaint, aFirstPaintLayersId, aApzcsToDestroy);
|
aIsFirstPaint, aFirstPaintLayersId, aApzcsToDestroy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,17 +370,19 @@ APZCTreeManager::FindTargetAPZC(AsyncPanZoomController* aApzc, const ScrollableL
|
||||||
AsyncPanZoomController*
|
AsyncPanZoomController*
|
||||||
APZCTreeManager::GetAPZCAtPoint(AsyncPanZoomController* aApzc, gfxPoint aHitTestPoint)
|
APZCTreeManager::GetAPZCAtPoint(AsyncPanZoomController* aApzc, gfxPoint aHitTestPoint)
|
||||||
{
|
{
|
||||||
|
gfx3DMatrix transform = gfx3DMatrix(aApzc->GetCurrentAsyncTransform()) * aApzc->GetCSSTransform();
|
||||||
|
gfx3DMatrix untransform = transform.Inverse();
|
||||||
|
gfxPoint untransformed = untransform.ProjectPoint(aHitTestPoint);
|
||||||
|
|
||||||
// This walks the tree in depth-first, reverse order, so that it encounters
|
// This walks the tree in depth-first, reverse order, so that it encounters
|
||||||
// APZCs front-to-back on the screen.
|
// APZCs front-to-back on the screen.
|
||||||
ViewTransform apzcTransform = aApzc->GetCurrentAsyncTransform();
|
|
||||||
gfxPoint untransformed = gfx3DMatrix(apzcTransform).Inverse().ProjectPoint(aHitTestPoint);
|
|
||||||
for (AsyncPanZoomController* child = aApzc->GetLastChild(); child; child = child->GetPrevSibling()) {
|
for (AsyncPanZoomController* child = aApzc->GetLastChild(); child; child = child->GetPrevSibling()) {
|
||||||
AsyncPanZoomController* match = GetAPZCAtPoint(child, untransformed);
|
AsyncPanZoomController* match = GetAPZCAtPoint(child, untransformed);
|
||||||
if (match) {
|
if (match) {
|
||||||
return match;
|
return match;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (aApzc->VisibleRegionContains(untransformed)) {
|
if (aApzc->VisibleRegionContains(LayerPoint(untransformed.x, untransformed.y))) {
|
||||||
return aApzc;
|
return aApzc;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -253,6 +253,7 @@ private:
|
||||||
*/
|
*/
|
||||||
AsyncPanZoomController* UpdatePanZoomControllerTree(CompositorParent* aCompositor,
|
AsyncPanZoomController* UpdatePanZoomControllerTree(CompositorParent* aCompositor,
|
||||||
Layer* aLayer, uint64_t aLayersId,
|
Layer* aLayer, uint64_t aLayersId,
|
||||||
|
gfx3DMatrix aTransform,
|
||||||
AsyncPanZoomController* aParent,
|
AsyncPanZoomController* aParent,
|
||||||
AsyncPanZoomController* aNextSibling,
|
AsyncPanZoomController* aNextSibling,
|
||||||
bool aIsFirstPaint,
|
bool aIsFirstPaint,
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "Axis.h"
|
#include "Axis.h"
|
||||||
#include "TaskThrottler.h"
|
#include "TaskThrottler.h"
|
||||||
#include "mozilla/layers/APZCTreeManager.h"
|
#include "mozilla/layers/APZCTreeManager.h"
|
||||||
|
#include "gfx3DMatrix.h"
|
||||||
|
|
||||||
#include "base/message_loop.h"
|
#include "base/message_loop.h"
|
||||||
|
|
||||||
|
@ -641,17 +642,28 @@ private:
|
||||||
* hit-testing to see which APZC instance should handle touch events.
|
* hit-testing to see which APZC instance should handle touch events.
|
||||||
*/
|
*/
|
||||||
public:
|
public:
|
||||||
void SetVisibleRegion(gfxRect rect) { mVisibleRegion = rect; }
|
void SetLayerHitTestData(const LayerRect& aRect, const gfx3DMatrix& aTransform) {
|
||||||
|
mVisibleRect = aRect;
|
||||||
|
mCSSTransform = aTransform;
|
||||||
|
}
|
||||||
|
|
||||||
bool VisibleRegionContains(const gfxPoint& aPoint) const {
|
gfx3DMatrix GetCSSTransform() const {
|
||||||
return mVisibleRegion.Contains(aPoint.x, aPoint.y);
|
return mCSSTransform;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VisibleRegionContains(const LayerPoint& aPoint) const {
|
||||||
|
return mVisibleRect.Contains(aPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* This is the viewport of the layer that this APZC corresponds to, but
|
/* This is the viewport of the layer that this APZC corresponds to, in
|
||||||
* post-transform. In other words, it is in the coordinate space of its
|
* layer pixels. It position here does not account for any transformations
|
||||||
* parent layer. */
|
* applied to any layers, whether they are CSS transforms or async
|
||||||
gfxRect mVisibleRegion;
|
* transforms. */
|
||||||
|
LayerRect mVisibleRect;
|
||||||
|
/* This is the cumulative layer transform from the parent APZC down to this
|
||||||
|
* one. */
|
||||||
|
gfx3DMatrix mCSSTransform;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче