Bug 1269321 - Part 1: Add a way to check if the current clip has rounded corners. r=mstange, a=gchang
authorMatt Woodrow <mwoodrow@mozilla.com>
Thu, 30 Jun 2016 18:08:35 +0200
changeset 340069 40828084d17fecf280f6b1e1caba38be40a369ed
parent 340068 d1475df3d7295b385f8b7d2c2b8aa458e9982661
child 340070 fcc625aa1c29be64e88138a3bcd81d6e7c653e27
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange, gchang
bugs1269321
milestone49.0a2
Bug 1269321 - Part 1: Add a way to check if the current clip has rounded corners. r=mstange, a=gchang
layout/base/DisplayItemScrollClip.cpp
layout/base/DisplayItemScrollClip.h
layout/base/DisplayListClipState.h
--- a/layout/base/DisplayItemScrollClip.cpp
+++ b/layout/base/DisplayItemScrollClip.cpp
@@ -22,16 +22,28 @@ DisplayItemScrollClip::IsAncestor(const 
     if (sc == aAncestor) {
       return true;
     }
   }
 
   return false;
 }
 
+bool
+DisplayItemScrollClip::HasRoundedCorners() const
+{
+  for (const DisplayItemScrollClip* scrollClip = this;
+       scrollClip; scrollClip = scrollClip->mParent) {
+    if (scrollClip->mClip->GetRoundedRectCount() > 0) {
+      return true;
+    }
+  }
+  return false;
+}
+
 /* static */ nsCString
 DisplayItemScrollClip::ToString(const DisplayItemScrollClip* aScrollClip)
 {
   nsAutoCString str;
   for (const DisplayItemScrollClip* scrollClip = aScrollClip;
        scrollClip; scrollClip = scrollClip->mParent) {
     str.AppendPrintf("<%s>%s", scrollClip->mClip ? scrollClip->mClip->ToString().get() : "null",
                      scrollClip->mIsAsyncScrollable ? " [async-scrollable]" : "");
--- a/layout/base/DisplayItemScrollClip.h
+++ b/layout/base/DisplayItemScrollClip.h
@@ -85,16 +85,18 @@ public:
                          const DisplayItemScrollClip* aDescendant);
 
   /**
    * Return a string which contains the list of stringified clips for this
    * scroll clip and its ancestors. aScrollClip can be null.
    */
   static nsCString ToString(const DisplayItemScrollClip* aScrollClip);
 
+  bool HasRoundedCorners() const;
+
   /**
    * The previous (outer) scroll clip, or null.
    */
   const DisplayItemScrollClip* mParent;
 
   /**
    * The scrollable frame that this scroll clip is for. Always non-null.
    */
--- a/layout/base/DisplayListClipState.h
+++ b/layout/base/DisplayListClipState.h
@@ -267,16 +267,34 @@ public:
       //      contents" will be set to that scroll clip.
       //  (2) If one of our direct child items is a container item for which
       //      (1) or (2) happened.
       *aOutContainerSC = mState.CurrentAncestorScrollClipForStackingContextContents();
     }
     Restore();
   }
 
+  bool SavedStateHasRoundedCorners()
+  {
+    const DisplayItemScrollClip* scrollClip = mSavedState.GetCurrentInnermostScrollClip();
+    if (scrollClip && scrollClip->HasRoundedCorners()) {
+      return true;
+    }
+    const DisplayItemClip* clip = mSavedState.GetClipForContainingBlockDescendants();
+    if (clip && clip->GetRoundedRectCount() > 0) {
+      return true;
+    }
+
+    clip = mSavedState.GetClipForContentDescendants();
+    if (clip && clip->GetRoundedRectCount() > 0) {
+      return true;
+    }
+    return false;
+  }
+
   void TurnClipIntoScrollClipForContentDescendants(nsDisplayListBuilder* aBuilder, nsIScrollableFrame* aScrollableFrame)
   {
     NS_ASSERTION(!mRestored, "Already restored!");
     mState.TurnClipIntoScrollClipForContentDescendants(aBuilder, aScrollableFrame);
 #ifdef DEBUG
     mClipUsed = true;
 #endif
   }