Bug 1187432 - Avoid scheduling main-thread paints for scrolls handled by apz. r=tn

This commit is contained in:
Matt Woodrow 2015-08-07 15:37:56 -04:00
parent 3fb76d3147
commit cd8614201c
4 changed files with 33 additions and 7 deletions

View File

@ -1077,6 +1077,10 @@ nsLayoutUtils::SetDisplayPortMargins(nsIContent* aContent,
return false;
}
if (currentData && currentData->mMargins == aMargins) {
return true;
}
aContent->SetProperty(nsGkAtoms::DisplayPortMargins,
new DisplayPortMarginsPropertyData(
aMargins, aPriority),

View File

@ -2226,7 +2226,7 @@ void ScrollFrameHelper::MarkRecentlyScrolled()
}
}
void ScrollFrameHelper::ScrollVisual(nsPoint aOldScrolledFramePos)
void ScrollFrameHelper::ScrollVisual()
{
// Mark this frame as having been scrolled. If this is the root
// scroll frame of a content document, then IsAlwaysActive()
@ -2245,7 +2245,6 @@ void ScrollFrameHelper::ScrollVisual(nsPoint aOldScrolledFramePos)
MarkRecentlyScrolled();
}
mOuter->SchedulePaint();
}
/**
@ -2419,15 +2418,35 @@ ScrollFrameHelper::ScrollToImpl(nsPoint aPt, const nsRect& aRange, nsIAtom* aOri
mListeners[i]->ScrollPositionWillChange(pt.x, pt.y);
}
nsPoint oldScrollFramePos = mScrolledFrame->GetPosition();
nsRect oldDisplayPort;
nsLayoutUtils::GetDisplayPort(mOuter->GetContent(), &oldDisplayPort);
oldDisplayPort.MoveBy(-mScrolledFrame->GetPosition());
// Update frame position for scrolling
mScrolledFrame->SetPosition(mScrollPort.TopLeft() - pt);
mLastScrollOrigin = aOrigin;
mLastSmoothScrollOrigin = nullptr;
mScrollGeneration = ++sScrollGenerationCounter;
// We pass in the amount to move visually
ScrollVisual(oldScrollFramePos);
ScrollVisual();
if (LastScrollOrigin() == nsGkAtoms::apz) {
// If this was an apz scroll and the displayport (relative to the
// scrolled frame) hasn't changed, then this won't trigger
// any painting, so no need to schedule one.
nsRect displayPort;
DebugOnly<bool> usingDisplayPort =
nsLayoutUtils::GetDisplayPort(mOuter->GetContent(), &displayPort);
NS_ASSERTION(usingDisplayPort, "Must have a displayport for apz scrolls!");
displayPort.MoveBy(-mScrolledFrame->GetPosition());
if (!displayPort.IsEqualEdges(oldDisplayPort)) {
mOuter->SchedulePaint();
}
} else {
mOuter->SchedulePaint();
}
if (mOuter->ChildrenHavePerspective()) {
// The overflow areas of descendants may depend on the scroll position,

View File

@ -222,7 +222,7 @@ public:
* @note This method might destroy the frame, pres shell and other objects.
*/
void ScrollToImpl(nsPoint aScrollPosition, const nsRect& aRange, nsIAtom* aOrigin = nullptr);
void ScrollVisual(nsPoint aOldScrolledFramePosition);
void ScrollVisual();
/**
* @note This method might destroy the frame, pres shell and other objects.
*/

View File

@ -740,7 +740,10 @@ nsSliderFrame::CurrentPositionChanged()
thumbFrame->SetRect(newThumbRect);
// Request a repaint of the scrollbar
SchedulePaint();
nsIScrollableFrame* scrollableFrame = do_QueryFrame(GetScrollbar()->GetParent());
if (!scrollableFrame || scrollableFrame->LastScrollOrigin() != nsGkAtoms::apz) {
SchedulePaint();
}
mCurPos = curPos;