Bug 1263347 - When checking if displayport changes should schedule a paint, make sure to use the proper displayport. r?mstange
MozReview-Commit-ID: IVcNSbEiESa
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -1213,25 +1213,25 @@ nsLayoutUtils::SetDisplayPortMargins(nsI
DisplayPortMarginsPropertyData* currentData =
static_cast<DisplayPortMarginsPropertyData*>(aContent->GetProperty(nsGkAtoms::DisplayPortMargins));
if (currentData && currentData->mPriority > aPriority) {
return false;
}
nsRect oldDisplayPort;
- bool hadDisplayPort = GetDisplayPort(aContent, &oldDisplayPort);
+ bool hadDisplayPort = GetHighResolutionDisplayPort(aContent, &oldDisplayPort);
aContent->SetProperty(nsGkAtoms::DisplayPortMargins,
new DisplayPortMarginsPropertyData(
aMargins, aPriority),
nsINode::DeleteProperty<DisplayPortMarginsPropertyData>);
nsRect newDisplayPort;
- DebugOnly<bool> hasDisplayPort = GetDisplayPort(aContent, &newDisplayPort);
+ DebugOnly<bool> hasDisplayPort = GetHighResolutionDisplayPort(aContent, &newDisplayPort);
MOZ_ASSERT(hasDisplayPort);
bool changed = !hadDisplayPort ||
!oldDisplayPort.IsEqualEdges(newDisplayPort);
if (gfxPrefs::LayoutUseContainersForRootFrames()) {
nsIFrame* rootScrollFrame = aPresShell->GetRootScrollFrame();
if (rootScrollFrame &&
@@ -1319,16 +1319,25 @@ nsLayoutUtils::GetCriticalDisplayPort(ns
}
bool
nsLayoutUtils::HasCriticalDisplayPort(nsIContent* aContent)
{
return GetCriticalDisplayPort(aContent, nullptr);
}
+bool
+nsLayoutUtils::GetHighResolutionDisplayPort(nsIContent* aContent, nsRect* aResult)
+{
+ if (gfxPrefs::UseLowPrecisionBuffer()) {
+ return GetCriticalDisplayPort(aContent, aResult);
+ }
+ return GetDisplayPort(aContent, aResult);
+}
+
void
nsLayoutUtils::RemoveDisplayPort(nsIContent* aContent)
{
aContent->DeleteProperty(nsGkAtoms::DisplayPort);
aContent->DeleteProperty(nsGkAtoms::DisplayPortMargins);
}
nsContainerFrame*
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -249,16 +249,22 @@ public:
static bool GetCriticalDisplayPort(nsIContent* aContent, nsRect* aResult);
/**
* Check whether the given element has a critical display port.
*/
static bool HasCriticalDisplayPort(nsIContent* aContent);
/**
+ * If low-precision painting is turned on, delegates to GetCriticalDisplayPort.
+ * Otherwise, delegates to GetDisplayPort.
+ */
+ static bool GetHighResolutionDisplayPort(nsIContent* aContent, nsRect* aResult);
+
+ /**
* Remove the displayport for the given element.
*/
static void RemoveDisplayPort(nsIContent* aContent);
/**
* Use heuristics to figure out the child list that
* aChildFrame is currently in.
*/
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -2704,17 +2704,17 @@ ScrollFrameHelper::ScrollToImpl(nsPoint
// notify the listeners.
for (uint32_t i = 0; i < mListeners.Length(); i++) {
mListeners[i]->ScrollPositionWillChange(pt.x, pt.y);
}
nsRect oldDisplayPort;
nsIContent* content = mOuter->GetContent();
- nsLayoutUtils::GetDisplayPort(content, &oldDisplayPort);
+ nsLayoutUtils::GetHighResolutionDisplayPort(content, &oldDisplayPort);
oldDisplayPort.MoveBy(-mScrolledFrame->GetPosition());
// Update frame position for scrolling
mScrolledFrame->SetPosition(mScrollPort.TopLeft() - pt);
mLastScrollOrigin = aOrigin;
mLastSmoothScrollOrigin = nullptr;
mScrollGeneration = ++sScrollGenerationCounter;
@@ -2730,17 +2730,17 @@ ScrollFrameHelper::ScrollToImpl(nsPoint
// APZ to update the scroll position. Again we make this conditional on
// the tile-aligned displayport being unchanged.
// We do the displayport check first since it's common to all scenarios,
// and then if the displayport is unchanged, we check if APZ triggered,
// or can handle, this scroll. If so, we set schedulePaint to false and
// skip the paint.
nsRect displayPort;
bool usingDisplayPort =
- nsLayoutUtils::GetDisplayPort(content, &displayPort);
+ nsLayoutUtils::GetHighResolutionDisplayPort(content, &displayPort);
displayPort.MoveBy(-mScrolledFrame->GetPosition());
PAINT_SKIP_LOG("New scrollpos %s usingDP %d dpEqual %d scrollableByApz %d plugins %d sle %d\n",
Stringify(CSSPoint::FromAppUnits(GetScrollPosition())).c_str(),
usingDisplayPort, displayPort.IsEqualEdges(oldDisplayPort),
mScrollableByAPZ, HasPluginFrames(),
content->GetComposedDoc()->HasScrollLinkedEffect());
if (usingDisplayPort && displayPort.IsEqualEdges(oldDisplayPort)) {