void APZCCallbackHelper::SendSetTargetAPZCNotification(nsIWidget* aWidget, nsIDocument* aDocument, const WidgetGUIEvent& aEvent, const ScrollableLayerGuid& aGuid, uint64_t aInputBlockId) { if (!aWidget || !aDocument) { return; } if (aInputBlockId == sLastTargetAPZCNotificationInputBlock) { // We have already confirmed the target APZC for a previous event of this // input block. If we activated a scroll frame for this input block, // sending another target APZC confirmation would be harmful, as it might // race the original confirmation (which needs to go through a layers // transaction). APZCCH_LOG("Not resending target APZC confirmation for input block %" PRIu64 "\n", aInputBlockId); return; } sLastTargetAPZCNotificationInputBlock = aInputBlockId; if (nsIPresShell* shell = aDocument->GetShell()) { if (nsIFrame* rootFrame = shell->GetRootFrame()) { bool waitForRefresh = false; nsTArray<ScrollableLayerGuid> targets; if (const WidgetTouchEvent* touchEvent = aEvent.AsTouchEvent()) { for (size_t i = 0; i < touchEvent->touches.Length(); i++) { waitForRefresh |= PrepareForSetTargetAPZCNotification(aWidget, aGuid, rootFrame, touchEvent->touches[i]->mRefPoint, &targets); } } else if (const WidgetWheelEvent* wheelEvent = aEvent.AsWheelEvent()) { waitForRefresh = PrepareForSetTargetAPZCNotification(aWidget, aGuid, rootFrame, wheelEvent->refPoint, &targets); } // TODO: Do other types of events need to be handled? if (!targets.IsEmpty()) { SendSetTargetAPZCNotificationHelper( aWidget, shell, aInputBlockId, targets, waitForRefresh); } } } }
void APZCCallbackHelper::SendSetTargetAPZCNotification(nsIWidget* aWidget, nsIDocument* aDocument, const WidgetGUIEvent& aEvent, const ScrollableLayerGuid& aGuid, uint64_t aInputBlockId) { if (!aWidget || !aDocument) { return; } if (nsIPresShell* shell = aDocument->GetShell()) { if (nsIFrame* rootFrame = shell->GetRootFrame()) { bool waitForRefresh = false; nsTArray<ScrollableLayerGuid> targets; if (const WidgetTouchEvent* touchEvent = aEvent.AsTouchEvent()) { for (size_t i = 0; i < touchEvent->touches.Length(); i++) { waitForRefresh |= PrepareForSetTargetAPZCNotification(aWidget, aGuid, rootFrame, touchEvent->touches[i]->mRefPoint, &targets); } } else if (const WidgetWheelEvent* wheelEvent = aEvent.AsWheelEvent()) { waitForRefresh = PrepareForSetTargetAPZCNotification(aWidget, aGuid, rootFrame, wheelEvent->refPoint, &targets); } // TODO: Do other types of events need to be handled? if (!targets.IsEmpty()) { SendSetTargetAPZCNotificationHelper( aWidget, shell, aInputBlockId, targets, waitForRefresh); } } } }