Invalidate items when we change if we need a layer for nsSubDocumentFrame
authorMatt Woodrow <mwoodrow@mozilla.com>
Wed, 20 Sep 2017 23:02:52 +1200
changeset 685649 f1eeeab5ef6d81550470caefbd9969d51b301036
parent 685648 988f3acb9d9809cb2600a4670998da4e2f55c5de
child 685650 c2aa79b719af965e7554304d9ab66ab50e8e86a9
push id86010
push userbmo:ethlin@mozilla.com
push dateWed, 25 Oct 2017 00:44:42 +0000
milestone57.0a1
Invalidate items when we change if we need a layer for nsSubDocumentFrame
layout/generic/nsSubDocumentFrame.cpp
layout/generic/nsSubDocumentFrame.h
--- a/layout/generic/nsSubDocumentFrame.cpp
+++ b/layout/generic/nsSubDocumentFrame.cpp
@@ -451,16 +451,27 @@ nsSubDocumentFrame::BuildDisplayList(nsD
 
   if (!needsOwnLayer && aBuilder->IsBuildingLayerEventRegions() &&
       nsLayoutUtils::HasDocumentLevelListenersForApzAwareEvents(presShell))
   {
     needsOwnLayer = true;
   }
 
   if (aBuilder->IsRetainingDisplayList()) {
+    // The value of needsOwnLayer can change between builds without
+    // an invalidation recorded for this frame. If this happens,
+    // then we need to notify the builder so that merging can
+    // happen correctly.
+    if (!mPreviouslyNeededLayer ||
+        mPreviouslyNeededLayer.value() != needsOwnLayer) {
+      dirty = visible;
+      aBuilder->MarkFrameModifiedDuringBuilding(this);
+    }
+    mPreviouslyNeededLayer = Some(needsOwnLayer);
+
     // Caret frame changed, rebuild the entire subdoc.
     // We could just invalidate the old and new frame
     // areas and save some work here.
     if (mPreviousCaret != aBuilder->GetCaretFrame()) {
       dirty = visible;
       aBuilder->MarkFrameModifiedDuringBuilding(this);
     }
     mPreviousCaret = aBuilder->GetCaretFrame();
--- a/layout/generic/nsSubDocumentFrame.h
+++ b/layout/generic/nsSubDocumentFrame.h
@@ -162,16 +162,17 @@ protected:
   nsIFrame* ObtainIntrinsicSizeFrame();
 
   nsView* GetViewInternal() const override { return mOuterView; }
   void SetViewInternal(nsView* aView) override { mOuterView = aView; }
 
   RefPtr<nsFrameLoader> mFrameLoader;
   nsView* mOuterView;
   nsView* mInnerView;
+  Maybe<bool> mPreviouslyNeededLayer;
   bool mIsInline;
   bool mPostedReflowCallback;
   bool mDidCreateDoc;
   bool mCallingShow;
   WeakFrame mPreviousCaret;
 };
 
 #endif /* NSSUBDOCUMENTFRAME_H_ */