diff --git a/gfx/layers/composite/APZCTreeManager.cpp b/gfx/layers/composite/APZCTreeManager.cpp index 0b2158c98dd7..d87f16d750ff 100644 --- a/gfx/layers/composite/APZCTreeManager.cpp +++ b/gfx/layers/composite/APZCTreeManager.cpp @@ -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, diff --git a/gfx/layers/ipc/GeckoContentController.h b/gfx/layers/ipc/GeckoContentController.h index a441fe242584..3f0d4577506b 100644 --- a/gfx/layers/ipc/GeckoContentController.h +++ b/gfx/layers/ipc/GeckoContentController.h @@ -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 diff --git a/layout/ipc/RenderFrameParent.cpp b/layout/ipc/RenderFrameParent.cpp index 5a11edfeee73..3356b95bfe75 100644 --- a/layout/ipc/RenderFrameParent.cpp +++ b/layout/ipc/RenderFrameParent.cpp @@ -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; }