Bug 1324591 - Disable partial pre-render for frames in position:sticky subtree. r?botond draft
authorHiroyuki Ikezoe <hikezoe.birchill@mozilla.com>
Tue, 02 Jun 2020 14:19:26 +0900
changeset 3000253 6de43392a6da3e7799c161d0c62de2651e958f29
parent 3000252 5ef4f7b10ed87dd765a42f79946817c91c3c9f73
child 3000254 bb059ebb3e19963a5472db1acbe2ed4996a263d3
push id558657
push userhikezoe.birchill@mozilla.com
push dateWed, 24 Jun 2020 01:19:11 +0000
treeherdertry@bb059ebb3e19 [default view] [failures only]
reviewersbotond
bugs1324591
milestone79.0a1
Bug 1324591 - Disable partial pre-render for frames in position:sticky subtree. r?botond Differential Revision: https://phabricator.services.mozilla.com/D77774
layout/painting/nsDisplayList.cpp
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -7625,16 +7625,32 @@ bool nsDisplayTransform::CanUseAsyncAnim
   return mPrerenderDecision != PrerenderDecision::No;
 }
 
 bool nsDisplayBackgroundColor::CanUseAsyncAnimations(
     nsDisplayListBuilder* aBuilder) {
   return StaticPrefs::gfx_omta_background_color();
 }
 
+static bool IsInStickyPositionedSubtree(const nsIFrame* aFrame) {
+  for (const nsIFrame* frame = aFrame; frame;
+       frame = nsLayoutUtils::GetCrossDocParentFrame(frame)) {
+    if (frame->IsStickyPositioned()) {
+      return true;
+    }
+  }
+  return false;
+}
+
+static bool ShouldUsePartialPrerender(const nsIFrame* aFrame) {
+  return StaticPrefs::layout_animation_prerender_partial() &&
+         // Bug 1642547: Support partial prerender for position:sticky elements.
+         !IsInStickyPositionedSubtree(aFrame);
+}
+
 /* static */
 auto nsDisplayTransform::ShouldPrerenderTransformedContent(
     nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, nsRect* aDirtyRect)
     -> PrerenderInfo {
   PrerenderInfo result;
   // If we are in a preserve-3d tree, and we've disallowed async animations, we
   // return No prerender decision directly.
   if ((aFrame->Extend3DContext() ||
@@ -7737,17 +7753,17 @@ auto nsDisplayTransform::ShouldPrerender
   uint64_t maxLimitArea = uint64_t(maxSize.width) * maxSize.height;
   uint64_t frameArea = uint64_t(frameSize.width) * frameSize.height;
   if (frameArea <= maxLimitArea && frameSize <= absoluteLimit) {
     *aDirtyRect = overflow;
     result.mDecision = PrerenderDecision::Full;
     return result;
   }
 
-  if (StaticPrefs::layout_animation_prerender_partial()) {
+  if (ShouldUsePartialPrerender(aFrame)) {
     *aDirtyRect = nsLayoutUtils::ComputePartialPrerenderArea(
         aFrame, untransformedDirtyRect, overflow, maxSize);
     result.mDecision = PrerenderDecision::Partial;
     return result;
   }
 
   if (frameArea > maxLimitArea) {
     uint64_t appUnitsPerPixel = AppUnitsPerCSSPixel();