Bug 1480695 - Add telemetry to record how frequently we encounter a cross-origin <iframe> within a filter. r=mstange,Nika
authorMatt Woodrow <mwoodrow@mozilla.com>
Thu, 09 Aug 2018 16:30:39 +1200
changeset 430747 a45929e06aa9cd2ce23a6c5440d4d70a5d388f1e
parent 430746 d448684096cd16f67fcc842f43e2111aeb56332b
child 430748 c1f51ec5d90540643ae3bcfbf881afb3b0c80274
push id34410
push usertoros@mozilla.com
push dateThu, 09 Aug 2018 10:02:47 +0000
treeherdermozilla-central@f650c0df72f9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange, Nika
bugs1480695
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1480695 - Add telemetry to record how frequently we encounter a cross-origin <iframe> within a filter. r=mstange,Nika
dom/base/UseCounters.conf
layout/generic/nsFrame.cpp
layout/generic/nsSubDocumentFrame.cpp
layout/painting/nsDisplayList.cpp
layout/painting/nsDisplayList.h
--- a/dom/base/UseCounters.conf
+++ b/dom/base/UseCounters.conf
@@ -119,8 +119,10 @@ method console.timeEnd
 method console.exception
 method console.timeStamp
 method console.profile
 method console.profileEnd
 
 // document.open information
 custom DocumentOpen calls document.open in a way that creates a new Window object
 custom DocumentOpenReplace calls document.open in a way that creates a new Window object and replaces the old history entry.
+
+custom FilteredCrossOriginIFrame cross-origin <iframe> within a CSS/SVG filter
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -3038,17 +3038,17 @@ nsIFrame::BuildDisplayListForStackingCon
     clipForMask = ComputeClipForMaskItem(aBuilder, this, !useOpacity);
   }
 
   nsDisplayListCollection set(aBuilder);
   {
     DisplayListClipState::AutoSaveRestore nestedClipState(aBuilder);
     nsDisplayListBuilder::AutoInTransformSetter
       inTransformSetter(aBuilder, inTransform);
-    nsDisplayListBuilder::AutoFilterASRSetter
+    nsDisplayListBuilder::AutoEnterFilter
       filterASRSetter(aBuilder, usingFilter);
 
     CheckForApzAwareEventHandlers(aBuilder, this);
 
     Maybe<nsRect> contentClip =
       GetClipPropClipRect(disp, effects, GetSize());
 
     if (usingMask) {
--- a/layout/generic/nsSubDocumentFrame.cpp
+++ b/layout/generic/nsSubDocumentFrame.cpp
@@ -374,16 +374,26 @@ nsSubDocumentFrame::BuildDisplayList(nsD
   nsCOMPtr<nsIPresShell> presShell =
     GetSubdocumentPresShellForPainting(
       aBuilder->IsIgnoringPaintSuppression() ? IGNORE_PAINT_SUPPRESSION : 0);
 
   if (!presShell) {
     return;
   }
 
+  if (aBuilder->IsInFilter()) {
+    nsIDocument* outerDoc = PresShell()->GetDocument();
+    nsIDocument* innerDoc = presShell->GetDocument();
+    if (outerDoc && innerDoc) {
+      if (!outerDoc->NodePrincipal()->Equals(innerDoc->NodePrincipal())) {
+        outerDoc->SetDocumentAndPageUseCounter(eUseCounter_custom_FilteredCrossOriginIFrame);
+      }
+    }
+  }
+
   nsIFrame* subdocRootFrame = presShell->GetRootFrame();
 
   nsPresContext* presContext = presShell->GetPresContext();
 
   int32_t parentAPD = PresContext()->AppUnitsPerDevPixel();
   int32_t subdocAPD = presContext->AppUnitsPerDevPixel();
 
   nsRect visible;
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -1004,16 +1004,17 @@ nsDisplayListBuilder::nsDisplayListBuild
       mIgnoreSuppression(false),
       mIsAtRootOfPseudoStackingContext(false),
       mIncludeAllOutOfFlows(false),
       mDescendIntoSubdocuments(true),
       mSelectedFramesOnly(false),
       mAllowMergingAndFlattening(true),
       mWillComputePluginGeometry(false),
       mInTransform(false),
+      mInFilter(false),
       mInPageSequence(false),
       mIsInChromePresContext(false),
       mSyncDecodeImages(false),
       mIsPaintingToWindow(false),
       mIsCompositingCheap(false),
       mContainsPluginItem(false),
       mAncestorHasApzAwareEventHandler(false),
       mHaveScrollableDisplayPort(false),
@@ -1053,16 +1054,17 @@ nsDisplayListBuilder::BeginFrame()
 {
   nsCSSRendering::BeginFrameTreesLocked();
   mCurrentAGR = mRootAGR;
   mFrameToAnimatedGeometryRootMap.Put(mReferenceFrame, mRootAGR);
 
   mIsPaintingToWindow = false;
   mIgnoreSuppression = false;
   mInTransform = false;
+  mInFilter = false;
   mSyncDecodeImages = false;
 }
 
 void
 nsDisplayListBuilder::EndFrame()
 {
   NS_ASSERTION(!mInInvalidSubtree, "Someone forgot to cleanup mInInvalidSubtree!");
   mFrameToAnimatedGeometryRootMap.Clear();
--- a/layout/painting/nsDisplayList.h
+++ b/layout/painting/nsDisplayList.h
@@ -830,16 +830,22 @@ public:
    */
   bool IsInTransform() const { return mInTransform; }
   /**
    * Indicate whether or not we're directly or indirectly under and
    * nsDisplayTransform or SVG foreignObject.
    */
   void SetInTransform(bool aInTransform) { mInTransform = aInTransform; }
 
+  /**
+   * Returns true if we're currently building a display list that's
+   * under an nsDisplayFilter.
+   */
+  bool IsInFilter() const { return mInFilter; }
+
   bool IsInPageSequence() const { return mInPageSequence; }
   void SetInPageSequence(bool aInPage) { mInPageSequence = aInPage; }
 
   /**
    * Return true if we're currently building a display list for a
    * nested presshell.
    */
   bool IsInSubdocument() { return mPresShellStates.Length() > 1; }
@@ -1165,33 +1171,39 @@ public:
       mBuilder->mInTransform = mOldValue;
     }
   private:
     nsDisplayListBuilder* mBuilder;
     bool                  mOldValue;
   };
 
   /**
-   * A helper class to temporarily set the value of mFilterASR.
-   */
-  class AutoFilterASRSetter {
+   * A helper class to temporarily set the value of mFilterASR and
+   * mInFilter.
+   */
+  class AutoEnterFilter {
   public:
-    AutoFilterASRSetter(nsDisplayListBuilder* aBuilder, bool aUsingFilter)
-      : mBuilder(aBuilder), mOldValue(aBuilder->mFilterASR)
+    AutoEnterFilter(nsDisplayListBuilder* aBuilder, bool aUsingFilter)
+      : mBuilder(aBuilder)
+      , mOldValue(aBuilder->mFilterASR)
+      , mOldInFilter(aBuilder->mInFilter)
     {
       if (!aBuilder->mFilterASR && aUsingFilter) {
         aBuilder->mFilterASR = aBuilder->CurrentActiveScrolledRoot();
+        aBuilder->mInFilter = true;
       }
     }
-    ~AutoFilterASRSetter() {
+    ~AutoEnterFilter() {
       mBuilder->mFilterASR = mOldValue;
+      mBuilder->mInFilter = mOldInFilter;
     }
   private:
     nsDisplayListBuilder* mBuilder;
     const ActiveScrolledRoot* mOldValue;
+    bool mOldInFilter;
   };
 
   /**
    * A helper class to temporarily set the value of mCurrentScrollParentId.
    */
   class AutoCurrentScrollParentIdSetter {
   public:
     AutoCurrentScrollParentIdSetter(nsDisplayListBuilder* aBuilder, ViewID aScrollId)
@@ -1943,16 +1955,17 @@ private:
   bool                           mIncludeAllOutOfFlows;
   bool                           mDescendIntoSubdocuments;
   bool                           mSelectedFramesOnly;
   bool                           mAllowMergingAndFlattening;
   bool                           mWillComputePluginGeometry;
   // True when we're building a display list that's directly or indirectly
   // under an nsDisplayTransform
   bool                           mInTransform;
+  bool                           mInFilter;
   bool                           mInPageSequence;
   bool                           mIsInChromePresContext;
   bool                           mSyncDecodeImages;
   bool                           mIsPaintingToWindow;
   bool                           mIsCompositingCheap;
   bool                           mContainsPluginItem;
   bool                           mAncestorHasApzAwareEventHandler;
   // True when the first async-scrollable scroll frame for which we build a