Bug 1163572 - Modify UpdateSubFrame to automatically figure out the nsIContent from the scrollId. r=botond

This commit is contained in:
Kartikaya Gupta 2015-06-15 14:39:06 -04:00
parent 8cd41536e9
commit 7699230ac7
4 changed files with 18 additions and 25 deletions

View File

@ -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<nsIContent> 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;
}

View File

@ -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<nsIPresShell> shell = GetPresShell(aContent)) {
SetDisplayPortMargins(shell, aContent, aMetrics);
ScrollFrame(content, aMetrics);
if (nsCOMPtr<nsIPresShell> shell = GetPresShell(content)) {
SetDisplayPortMargins(shell, content, aMetrics);
}
}

View File

@ -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.

View File

@ -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<nsIContent> targetContent = nsLayoutUtils::FindContentFor(aFrameMetrics.GetScrollId());
if (targetContent) {
APZCCallbackHelper::UpdateSubFrame(targetContent, metrics);
}
APZCCallbackHelper::UpdateSubFrame(metrics);
}
}