From 7699230ac71eea65cd2513f86aa04143d511d1c9 Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Mon, 15 Jun 2015 14:39:06 -0400 Subject: [PATCH] Bug 1163572 - Modify UpdateSubFrame to automatically figure out the nsIContent from the scrollId. r=botond --- dom/ipc/TabChild.cpp | 10 +++------- gfx/layers/apz/util/APZCCallbackHelper.cpp | 19 ++++++++++++------- gfx/layers/apz/util/APZCCallbackHelper.h | 5 ++--- .../apz/util/ChromeProcessController.cpp | 9 +-------- 4 files changed, 18 insertions(+), 25 deletions(-) diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 6b93a7ef9f3..267804b9ce1 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -562,13 +562,9 @@ TabChildBase::UpdateFrameHandler(const FrameMetrics& aFrameMetrics) } else { // aFrameMetrics.mIsRoot is false, so we are trying to update a subframe. // This requires special handling. - nsCOMPtr content = nsLayoutUtils::FindContentFor( - aFrameMetrics.GetScrollId()); - if (content) { - FrameMetrics newSubFrameMetrics(aFrameMetrics); - APZCCallbackHelper::UpdateSubFrame(content, newSubFrameMetrics); - return true; - } + FrameMetrics newSubFrameMetrics(aFrameMetrics); + APZCCallbackHelper::UpdateSubFrame(newSubFrameMetrics); + return true; } return true; } diff --git a/gfx/layers/apz/util/APZCCallbackHelper.cpp b/gfx/layers/apz/util/APZCCallbackHelper.cpp index 439c7f09759..d12c76a52ef 100644 --- a/gfx/layers/apz/util/APZCCallbackHelper.cpp +++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp @@ -227,18 +227,23 @@ APZCCallbackHelper::UpdateRootFrame(FrameMetrics& aMetrics) } void -APZCCallbackHelper::UpdateSubFrame(nsIContent* aContent, - FrameMetrics& aMetrics) +APZCCallbackHelper::UpdateSubFrame(FrameMetrics& aMetrics) { - // Precondition checks - MOZ_ASSERT(aContent); + if (aMetrics.GetScrollId() == FrameMetrics::NULL_SCROLL_ID) { + return; + } + nsIContent* content = nsLayoutUtils::FindContentFor(aMetrics.GetScrollId()); + if (!content) { + return; + } + MOZ_ASSERT(aMetrics.GetUseDisplayPortMargins()); // We don't currently support zooming for subframes, so nothing extra // needs to be done beyond the tasks common to this and UpdateRootFrame. - ScrollFrame(aContent, aMetrics); - if (nsCOMPtr shell = GetPresShell(aContent)) { - SetDisplayPortMargins(shell, aContent, aMetrics); + ScrollFrame(content, aMetrics); + if (nsCOMPtr shell = GetPresShell(content)) { + SetDisplayPortMargins(shell, content, aMetrics); } } diff --git a/gfx/layers/apz/util/APZCCallbackHelper.h b/gfx/layers/apz/util/APZCCallbackHelper.h index ba9f1a52c95..4eb60a388f3 100644 --- a/gfx/layers/apz/util/APZCCallbackHelper.h +++ b/gfx/layers/apz/util/APZCCallbackHelper.h @@ -50,13 +50,12 @@ public: static void UpdateRootFrame(FrameMetrics& aMetrics); /* Applies the scroll parameters from the given FrameMetrics object to the - subframe corresponding to the given content object. If tiled thebes + subframe corresponding to given metrics' scrollId. If tiled thebes layers are enabled, this will align the displayport to tile boundaries. Setting the scroll position can cause some small adjustments to be made to the actual scroll position. aMetrics' display port and scroll position will be updated with any modifications made. */ - static void UpdateSubFrame(nsIContent* aContent, - FrameMetrics& aMetrics); + static void UpdateSubFrame(FrameMetrics& aMetrics); /* Get the presShellId and view ID for the given content element. * If the view ID does not exist, one is created. diff --git a/gfx/layers/apz/util/ChromeProcessController.cpp b/gfx/layers/apz/util/ChromeProcessController.cpp index 88823e5612e..2231f7b8c3f 100644 --- a/gfx/layers/apz/util/ChromeProcessController.cpp +++ b/gfx/layers/apz/util/ChromeProcessController.cpp @@ -71,18 +71,11 @@ ChromeProcessController::RequestContentRepaint(const FrameMetrics& aFrameMetrics { MOZ_ASSERT(NS_IsMainThread()); - if (aFrameMetrics.GetScrollId() == FrameMetrics::NULL_SCROLL_ID) { - return; - } - FrameMetrics metrics = aFrameMetrics; if (metrics.IsRootContent()) { APZCCallbackHelper::UpdateRootFrame(metrics); } else { - nsCOMPtr targetContent = nsLayoutUtils::FindContentFor(aFrameMetrics.GetScrollId()); - if (targetContent) { - APZCCallbackHelper::UpdateSubFrame(targetContent, metrics); - } + APZCCallbackHelper::UpdateSubFrame(metrics); } }