Bug 959198 - Have APZ hit testing respect mozpasspointerevents. r=kats

--HG--
extra : rebase_source : aafa0b5bf9839f583b84151afc4a3c805fabee0a
This commit is contained in:
Botond Ballo 2014-01-16 15:19:59 -05:00
parent f6f99623dd
commit 484926d2ef
3 changed files with 55 additions and 6 deletions

View File

@ -203,7 +203,17 @@ APZCTreeManager::UpdatePanZoomControllerTree(CompositorParent* aCompositor,
apzc->NotifyLayersUpdated(container->GetFrameMetrics(),
aIsFirstPaint && (aLayersId == aFirstPaintLayersId));
// Use the composition bounds as the hit test region.
// Optionally, the GeckoContentController can provide a touch-sensitive
// region that constrains all frames associated with the controller.
// In this case we intersect the composition bounds with that region.
ScreenRect visible(container->GetFrameMetrics().mCompositionBounds);
CSSRect touchSensitiveRegion;
if (state->mController->GetTouchSensitiveRegion(&touchSensitiveRegion)) {
visible = visible.Intersect(touchSensitiveRegion
* container->GetFrameMetrics().LayersPixelsPerCSSPixel()
* LayerToScreenScale(1.0));
}
apzc->SetLayerHitTestData(visible, aTransform, aLayer->GetTransform());
APZC_LOG("Setting rect(%f %f %f %f) as visible region for APZC %p\n", visible.x, visible.y,
visible.width, visible.height,

View File

@ -81,6 +81,22 @@ public:
return false;
}
/**
* APZ uses |FrameMetrics::mCompositionBounds| for hit testing. Sometimes,
* widget code has knowledge of a touch-sensitive region that should
* additionally constrain hit testing for all frames associated with the
* controller. This method allows APZ to query the controller for such a
* region. A return value of true indicates that the controller has such a
* region, and it is returned in |aOutRegion|.
* TODO: once bug 928833 is implemented, this should be removed, as
* APZ can then get the correct touch-sensitive region for each frame
* directly from the layer.
*/
virtual bool GetTouchSensitiveRegion(CSSRect* aOutRegion)
{
return false;
}
/**
* General tranformation notices for consumers. These fire any time
* the apzc is modifying the view, including panning, zooming, and

View File

@ -610,12 +610,6 @@ public:
MessageLoop::current()->PostDelayedTask(FROM_HERE, aTask, aDelayMs);
}
void SaveZoomConstraints(const ZoomConstraints& aConstraints)
{
mHaveZoomConstraints = true;
mZoomConstraints = aConstraints;
}
virtual bool GetRootZoomConstraints(ZoomConstraints* aOutConstraints)
{
if (mHaveZoomConstraints && aOutConstraints) {
@ -624,6 +618,15 @@ public:
return mHaveZoomConstraints;
}
virtual bool GetTouchSensitiveRegion(CSSRect* aOutRegion)
{
if (mTouchSensitiveRegion.IsEmpty())
return false;
*aOutRegion = CSSRect::FromAppUnits(mTouchSensitiveRegion.GetBounds());
return true;
}
virtual void NotifyTransformBegin(const ScrollableLayerGuid& aGuid)
{
if (MessageLoop::current() != mUILoop) {
@ -654,6 +657,18 @@ public:
}
}
// Methods used by RenderFrameParent to set fields stored here.
void SaveZoomConstraints(const ZoomConstraints& aConstraints)
{
mHaveZoomConstraints = true;
mZoomConstraints = aConstraints;
}
void SetTouchSensitiveRegion(const nsRegion& aRegion)
{
mTouchSensitiveRegion = aRegion;
}
private:
void DoRequestContentRepaint(const FrameMetrics& aFrameMetrics)
{
@ -668,6 +683,7 @@ private:
bool mHaveZoomConstraints;
ZoomConstraints mZoomConstraints;
nsRegion mTouchSensitiveRegion;
};
RenderFrameParent::RenderFrameParent()
@ -941,6 +957,13 @@ bool
RenderFrameParent::RecvUpdateHitRegion(const nsRegion& aRegion)
{
mTouchRegion = aRegion;
if (mContentController) {
// Tell the content controller about the touch-sensitive region, so
// that it can provide it to APZ. This is required for APZ to do
// correct hit testing for a remote 'mozpasspointerevents' iframe
// until bug 928833 is fixed.
mContentController->SetTouchSensitiveRegion(aRegion);
}
return true;
}