Bug 1192910 - Stop triggering repaints when the displayport margins change without the displayport changing. r=kats, a=ritu
MozReview-Commit-ID: K1g6sNlZdRk
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -1146,62 +1146,64 @@ nsLayoutUtils::SetDisplayPortMargins(nsI
MOZ_ASSERT(aContent->GetComposedDoc() == aPresShell->GetDocument());
DisplayPortMarginsPropertyData* currentData =
static_cast<DisplayPortMarginsPropertyData*>(aContent->GetProperty(nsGkAtoms::DisplayPortMargins));
if (currentData && currentData->mPriority > aPriority) {
return false;
}
- if (currentData && currentData->mMargins == aMargins) {
- return true;
- }
+ nsRect oldDisplayPort;
+ bool hadDisplayPort = GetDisplayPort(aContent, &oldDisplayPort);
aContent->SetProperty(nsGkAtoms::DisplayPortMargins,
new DisplayPortMarginsPropertyData(
aMargins, aPriority),
nsINode::DeleteProperty<DisplayPortMarginsPropertyData>);
+ nsRect newDisplayPort;
+ DebugOnly<bool> hasDisplayPort = GetDisplayPort(aContent, &newDisplayPort);
+ MOZ_ASSERT(hasDisplayPort);
+
+ bool changed = !hadDisplayPort ||
+ !oldDisplayPort.IsEqualEdges(newDisplayPort);
+
if (gfxPrefs::LayoutUseContainersForRootFrames()) {
nsIFrame* rootScrollFrame = aPresShell->GetRootScrollFrame();
if (rootScrollFrame &&
aContent == rootScrollFrame->GetContent() &&
nsLayoutUtils::UsesAsyncScrolling(rootScrollFrame))
{
// We are setting a root displayport for a document.
// If we have APZ, then set a special flag on the pres shell so
// that we don't get scrollbars drawn.
aPresShell->SetIgnoreViewportScrolling(true);
}
}
- if (aRepaintMode == RepaintMode::Repaint) {
+ if (changed && aRepaintMode == RepaintMode::Repaint) {
nsIFrame* frame = aContent->GetPrimaryFrame();
if (frame) {
frame->SchedulePaint();
}
}
nsIFrame* frame = GetScrollFrameFromContent(aContent);
nsIScrollableFrame* scrollableFrame = frame ? frame->GetScrollTargetFrame() : nullptr;
if (!scrollableFrame) {
return true;
}
scrollableFrame->TriggerDisplayPortExpiration();
// Display port margins changing means that the set of visible images may
// have drastically changed. Check if we should schedule an update.
- nsRect oldDisplayPort;
- bool hadDisplayPort =
+ hadDisplayPort =
scrollableFrame->GetDisplayPortAtLastImageVisibilityUpdate(&oldDisplayPort);
- nsRect newDisplayPort;
- Unused << GetDisplayPort(aContent, &newDisplayPort);
-
bool needImageVisibilityUpdate = !hadDisplayPort;
// Check if the total size has changed by a large factor.
if (!needImageVisibilityUpdate) {
if ((newDisplayPort.width > 2 * oldDisplayPort.width) ||
(oldDisplayPort.width > 2 * newDisplayPort.width) ||
(newDisplayPort.height > 2 * oldDisplayPort.height) ||
(oldDisplayPort.height > 2 * newDisplayPort.height)) {
needImageVisibilityUpdate = true;