Bug 937185 - Discard old apzcs if the ScrollableLayerGuid is updated. r=kats

This commit is contained in:
Jim Mathies 2013-11-18 09:14:08 -06:00
parent e902571661
commit 5e6ef74079
3 changed files with 40 additions and 10 deletions

View File

@ -121,6 +121,14 @@ APZCTreeManager::UpdatePanZoomControllerTree(CompositorParent* aCompositor,
apzc = container->GetAsyncPanZoomController();
// If the content represented by the container layer has changed (which may
// be possible because of DLBI heuristics) then we don't want to keep using
// the same old APZC for the new content. Null it out so we run through the
// code to find another one or create one.
if (apzc && !apzc->Matches(ScrollableLayerGuid(aLayersId, container->GetFrameMetrics()))) {
apzc = nullptr;
}
// If the container doesn't have an APZC already, try to find one of our
// pre-existing ones that matches. In particular, if we find an APZC whose
// ScrollableLayerGuid is the same, then we know what happened is that the
@ -159,7 +167,7 @@ APZCTreeManager::UpdatePanZoomControllerTree(CompositorParent* aCompositor,
APZC_LOG("Using APZC %p for layer %p with identifiers %lld %lld\n", apzc, aLayer, aLayersId, container->GetFrameMetrics().mScrollId);
apzc->NotifyLayersUpdated(container->GetFrameMetrics(),
aIsFirstPaint && (aLayersId == aFirstPaintLayersId));
aIsFirstPaint && (aLayersId == aFirstPaintLayersId));
ScreenRect visible(container->GetFrameMetrics().mCompositionBounds);
apzc->SetLayerHitTestData(visible, aTransform, aLayer->GetTransform());

View File

@ -83,19 +83,22 @@ GetDOMTargets(uint64_t aScrollId,
class RequestContentRepaintEvent : public nsRunnable
{
typedef mozilla::layers::FrameMetrics FrameMetrics;
typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid;
public:
RequestContentRepaintEvent(const FrameMetrics& aFrameMetrics,
nsIWidgetListener* aListener,
CSSIntPoint* aLastOffsetOut) :
CSSIntPoint* aLastOffsetOut,
ScrollableLayerGuid* aLastScrollId) :
mFrameMetrics(aFrameMetrics),
mWidgetListener(aListener),
mLastOffsetOut(aLastOffsetOut)
mLastOffsetOut(aLastOffsetOut),
mLastScrollIdOut(aLastScrollId)
{
}
NS_IMETHOD Run() {
// This event shuts down the worker thread and so must be main thread.
// This must be on the gecko thread since we access the dom
MOZ_ASSERT(NS_IsMainThread());
#ifdef DEBUG_CONTROLLER
@ -139,6 +142,10 @@ public:
if (mLastOffsetOut) {
*mLastOffsetOut = actualScrollOffset;
}
if (mLastScrollIdOut) {
mLastScrollIdOut->mScrollId = mFrameMetrics.mScrollId;
mLastScrollIdOut->mPresShellId = mFrameMetrics.mPresShellId;
}
#ifdef DEBUG_CONTROLLER
WinUtils::Log("APZController: %I64d mDisplayPort: %0.2f %0.2f %0.2f %0.2f",
@ -156,6 +163,7 @@ protected:
FrameMetrics mFrameMetrics;
nsIWidgetListener* mWidgetListener;
CSSIntPoint* mLastOffsetOut;
ScrollableLayerGuid* mLastScrollIdOut;
};
void
@ -225,19 +233,19 @@ APZController::ReceiveInputEvent(WidgetInputEvent* aInEvent,
void
APZController::RequestContentRepaint(const FrameMetrics& aFrameMetrics)
{
// Send the result back to the main thread so that it can shutdown
if (!mWidgetListener) {
NS_WARNING("Can't update display port, !mWidgetListener");
return;
}
#ifdef DEBUG_CONTROLLER
WinUtils::Log("APZController::RequestContentRepaint scroll id = %I64d",
WinUtils::Log("APZController::RequestContentRepaint scrollid=%I64d",
aFrameMetrics.mScrollId);
#endif
nsCOMPtr<nsIRunnable> r1 = new RequestContentRepaintEvent(aFrameMetrics,
mWidgetListener,
&mLastScrollOffset);
&mLastScrollOffset,
&mLastScrollLayerGuid);
if (!NS_IsMainThread()) {
NS_DispatchToMainThread(r1);
} else {
@ -253,12 +261,20 @@ APZController::UpdateScrollOffset(const mozilla::layers::ScrollableLayerGuid& aS
CSSIntPoint& aScrollOffset)
{
#ifdef DEBUG_CONTROLLER
WinUtils::Log("APZController::UpdateScrollOffset: %d %d == %d %d",
WinUtils::Log("APZController::UpdateScrollOffset: scrollid:%I64d == %I64d offsets: %d,%d == %d,%d",
aScrollLayerId.mScrollId, aScrollLayerId.mScrollId,
aScrollOffset.x, aScrollOffset.y,
mLastScrollOffset.x, mLastScrollOffset.y);
#endif
if (!sAPZC || mLastScrollOffset == aScrollOffset) {
// Bail if this the same scroll guid the apzc just scrolled and the offsets
// equal the offset the apzc set.
if (!sAPZC || (mLastScrollLayerGuid.mScrollId == aScrollLayerId.mScrollId &&
mLastScrollLayerGuid.mPresShellId == aScrollLayerId.mPresShellId &&
mLastScrollOffset == aScrollOffset)) {
#ifdef DEBUG_CONTROLLER
WinUtils::Log("Skipping UpdateScrollOffset");
#endif
return;
}
sAPZC->UpdateScrollOffset(aScrollLayerId, aScrollOffset);

View File

@ -25,6 +25,11 @@ class APZController :
typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid;
public:
APZController() :
mWidgetListener(nullptr)
{
}
// GeckoContentController interface
virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics);
virtual void HandleDoubleTap(const mozilla::CSSIntPoint& aPoint);
@ -54,6 +59,7 @@ public:
private:
nsIWidgetListener* mWidgetListener;
ScrollableLayerGuid mLastScrollLayerGuid;
CSSIntPoint mLastScrollOffset;
};