Bug 1090398 - Use EventRegions objects instead of nsIntRegions for tracking APZ hit-test areas. r=botond

This simply swaps out the existing nsIntRegion used in APZ hit-testing for
an EventRegion object. The dispatch-to-content region inside the EventRegions
is kept empty, and there are no functional changes here.
This commit is contained in:
Kartikaya Gupta 2014-11-14 07:40:14 -05:00
parent 7bce9566dd
commit 52279ea3ee
3 changed files with 29 additions and 13 deletions

View File

@ -162,6 +162,15 @@ struct EventRegions {
nsIntRegion mHitRegion;
nsIntRegion mDispatchToContentHitRegion;
EventRegions()
{
}
explicit EventRegions(nsIntRegion aHitRegion)
: mHitRegion(aHitRegion)
{
}
bool operator==(const EventRegions& aRegions) const
{
return mHitRegion == aRegions.mHitRegion &&
@ -172,6 +181,12 @@ struct EventRegions {
return !(*this == aRegions);
}
void OrWith(const EventRegions& aOther)
{
mHitRegion.OrWith(aOther.mHitRegion);
mDispatchToContentHitRegion.OrWith(aOther.mDispatchToContentHitRegion);
}
nsCString ToString() const
{
nsCString result = mHitRegion.ToString();

View File

@ -327,7 +327,7 @@ APZCTreeManager::PrepareAPZCForLayer(const LayerMetricsWrapper& aLayer,
aState.mIsFirstPaint && (aLayersId == aState.mOriginatingLayersId));
nsIntRegion unobscured = ComputeTouchSensitiveRegion(state->mController, aMetrics, aObscured);
apzc->SetLayerHitTestData(unobscured, aAncestorTransform);
apzc->SetLayerHitTestData(EventRegions(unobscured), aAncestorTransform);
APZCTM_LOG("Setting region %s as visible region for APZC %p\n",
Stringify(unobscured).c_str(), apzc);
@ -391,7 +391,7 @@ APZCTreeManager::PrepareAPZCForLayer(const LayerMetricsWrapper& aLayer,
// on top of B. Fixing this doesn't appear to be very easy so I'm leaving it for
// now in the hopes that we won't run into this problem a lot.
nsIntRegion unobscured = ComputeTouchSensitiveRegion(state->mController, aMetrics, aObscured);
apzc->AddHitTestRegion(unobscured);
apzc->AddHitTestRegions(EventRegions(unobscured));
APZCTM_LOG("Adding region %s to visible region of APZC %p\n", Stringify(unobscured).c_str(), apzc);
}
@ -1225,7 +1225,7 @@ APZCTreeManager::GetAPZCAtPoint(AsyncPanZoomController* aApzc,
}
}
if (!result && hitTestPointForThisLayer.HasPositiveWCoord() &&
aApzc->VisibleRegionContains(ParentLayerPoint::FromUnknownPoint(hitTestPointForThisLayer.As2DPoint()))) {
aApzc->HitRegionContains(ParentLayerPoint::FromUnknownPoint(hitTestPointForThisLayer.As2DPoint()))) {
APZCTM_LOG("Successfully matched untransformed point %f %f to visible region for APZC %p\n",
hitTestPointForThisLayer.x, hitTestPointForThisLayer.y, aApzc);
result = aApzc;

View File

@ -20,6 +20,7 @@
#include "InputData.h"
#include "Axis.h"
#include "InputQueue.h"
#include "LayersTypes.h"
#include "TaskThrottler.h"
#include "mozilla/gfx/Matrix.h"
#include "nsRegion.h"
@ -997,22 +998,22 @@ private:
* hit-testing to see which APZC instance should handle touch events.
*/
public:
void SetLayerHitTestData(const nsIntRegion& aRegion, const Matrix4x4& aTransformToLayer) {
mVisibleRegion = aRegion;
void SetLayerHitTestData(const EventRegions& aRegions, const Matrix4x4& aTransformToLayer) {
mEventRegions = aRegions;
mAncestorTransform = aTransformToLayer;
}
void AddHitTestRegion(const nsIntRegion& aRegion) {
mVisibleRegion.OrWith(aRegion);
void AddHitTestRegions(const EventRegions& aRegions) {
mEventRegions.OrWith(aRegions);
}
Matrix4x4 GetAncestorTransform() const {
return mAncestorTransform;
}
bool VisibleRegionContains(const ParentLayerPoint& aPoint) const {
bool HitRegionContains(const ParentLayerPoint& aPoint) const {
ParentLayerIntPoint point = RoundedToInt(aPoint);
return mVisibleRegion.Contains(point.x, point.y);
return mEventRegions.mHitRegion.Contains(point.x, point.y);
}
bool IsOverscrolled() const {
@ -1020,11 +1021,11 @@ public:
}
private:
/* This is the union of the visible regions of the layers that this APZC
* corresponds to, in the screen pixels of those layers. (This is the same
* coordinate system in which this APZC receives events in
/* This is the union of the hit regions of the layers that this APZC
* corresponds to, in the local screen pixels of those layers. (This is the
* same coordinate system in which this APZC receives events in
* ReceiveInputEvent()). */
nsIntRegion mVisibleRegion;
EventRegions mEventRegions;
/* This is the cumulative CSS transform for all the layers from (and including)
* the parent APZC down to (but excluding) this one. */
Matrix4x4 mAncestorTransform;