Bug 1359205 - Make XUL pseudo values nsICSSAnonBoxPseudo* instead of nsIAtom* and assert that IsTreePseudoElement() got a pseudo tag of the right type. r=bz
authorMats Palmgren <mats@mozilla.com>
Wed, 26 Apr 2017 17:54:43 +0200
changeset 403202 5590452f092c5cbd29054f024094031ae7df4971
parent 403201 8457e1358dda18f6e8d3ab787f306314668e5fb9
child 403203 7ea39575ae0cf1ae5a0958c1bc3de9ac9e3a37e1
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1359205
milestone55.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 1359205 - Make XUL pseudo values nsICSSAnonBoxPseudo* instead of nsIAtom* and assert that IsTreePseudoElement() got a pseudo tag of the right type. r=bz MozReview-Commit-ID: G2WFsNV4Fjz
layout/style/nsCSSAnonBoxes.cpp
layout/style/nsStyleSet.cpp
layout/style/nsStyleSet.h
layout/xul/tree/nsTreeBodyFrame.cpp
layout/xul/tree/nsTreeBodyFrame.h
layout/xul/tree/nsTreeStyleCache.cpp
layout/xul/tree/nsTreeStyleCache.h
--- a/layout/style/nsCSSAnonBoxes.cpp
+++ b/layout/style/nsCSSAnonBoxes.cpp
@@ -51,16 +51,17 @@ bool nsCSSAnonBoxes::IsAnonBox(nsIAtom *
   return nsAtomListUtils::IsMember(aAtom, CSSAnonBoxes_info,
                                    ArrayLength(CSSAnonBoxes_info));
 }
 
 #ifdef MOZ_XUL
 /* static */ bool
 nsCSSAnonBoxes::IsTreePseudoElement(nsIAtom* aPseudo)
 {
+  MOZ_ASSERT(nsCSSAnonBoxes::IsAnonBox(aPseudo));
   return StringBeginsWith(nsDependentAtomString(aPseudo),
                           NS_LITERAL_STRING(":-moz-tree-"));
 }
 #endif
 
 /* static*/ nsCSSAnonBoxes::NonInheriting
 nsCSSAnonBoxes::NonInheritingTypeForPseudoTag(nsIAtom* aPseudo)
 {
--- a/layout/style/nsStyleSet.cpp
+++ b/layout/style/nsStyleSet.cpp
@@ -2167,17 +2167,17 @@ nsStyleSet::ResolveNonInheritingAnonymou
                nullptr, eNoFlags);
   cache = retval;
   return retval.forget();
 }
 
 #ifdef MOZ_XUL
 already_AddRefed<nsStyleContext>
 nsStyleSet::ResolveXULTreePseudoStyle(Element* aParentElement,
-                                      nsIAtom* aPseudoTag,
+                                      nsICSSAnonBoxPseudo* aPseudoTag,
                                       nsStyleContext* aParentContext,
                                       nsICSSPseudoComparator* aComparator)
 {
   NS_ENSURE_FALSE(mInShutdown, nullptr);
 
   NS_ASSERTION(aPseudoTag, "must have pseudo tag");
   NS_ASSERTION(nsCSSAnonBoxes::IsTreePseudoElement(aPseudoTag),
                "Unexpected pseudo");
--- a/layout/style/nsStyleSet.h
+++ b/layout/style/nsStyleSet.h
@@ -293,17 +293,17 @@ class nsStyleSet final
   ResolveNonInheritingAnonymousBoxStyle(nsIAtom* aPseudoTag);
 
 #ifdef MOZ_XUL
   // Get a style context for a XUL tree pseudo.  aPseudoTag is the
   // pseudo-tag to use and must be non-null.  aParentContent must be
   // non-null.  aComparator must be non-null.
   already_AddRefed<nsStyleContext>
   ResolveXULTreePseudoStyle(mozilla::dom::Element* aParentElement,
-                            nsIAtom* aPseudoTag,
+                            nsICSSAnonBoxPseudo* aPseudoTag,
                             nsStyleContext* aParentContext,
                             nsICSSPseudoComparator* aComparator);
 #endif
 
   // Append all the currently-active font face rules to aArray.  Return
   // true for success and false for failure.
   bool AppendFontFaceRules(nsTArray<nsFontFaceRuleContainer>& aArray);
 
--- a/layout/xul/tree/nsTreeBodyFrame.cpp
+++ b/layout/xul/tree/nsTreeBodyFrame.cpp
@@ -1052,17 +1052,17 @@ nsTreeBodyFrame::GetCellAt(int32_t aX, i
 
   // Check if the coordinates are above our visible space.
   if (point.y < 0) {
     *aRow = -1;
     return NS_OK;
   }
 
   nsTreeColumn* col;
-  nsIAtom* child;
+  nsICSSAnonBoxPseudo* child;
   GetCellAt(point.x, point.y, aRow, &col, &child);
 
   if (col) {
     NS_ADDREF(*aCol = col);
     if (child == nsCSSAnonBoxes::moztreecell)
       aChildElt.AssignLiteral("cell");
     else if (child == nsCSSAnonBoxes::moztreetwisty)
       aChildElt.AssignLiteral("twisty");
@@ -1479,17 +1479,17 @@ nsTreeBodyFrame::AdjustForCellText(nsAut
       aTextRect.x += (aTextRect.width - width) / 2;
     }
     break;
   }
 
   aTextRect.width = width;
 }
 
-nsIAtom*
+nsICSSAnonBoxPseudo*
 nsTreeBodyFrame::GetItemWithinCellAt(nscoord aX, const nsRect& aCellRect, 
                                      int32_t aRowIndex,
                                      nsTreeColumn* aColumn)
 {
   NS_PRECONDITION(aColumn && aColumn->GetFrame(), "invalid column passed");
 
   // Obtain the properties for our cell.
   PrefillPropertyArray(aRowIndex, aColumn);
@@ -1629,17 +1629,18 @@ nsTreeBodyFrame::GetItemWithinCellAt(nsc
   if (aX >= textRect.x && aX < textRect.x + textRect.width)
     return nsCSSAnonBoxes::moztreecelltext;
   else
     return nsCSSAnonBoxes::moztreecell;
 }
 
 void
 nsTreeBodyFrame::GetCellAt(nscoord aX, nscoord aY, int32_t* aRow,
-                           nsTreeColumn** aCol, nsIAtom** aChildElt)
+                           nsTreeColumn** aCol,
+                           nsICSSAnonBoxPseudo** aChildElt)
 {
   *aCol = nullptr;
   *aChildElt = nullptr;
 
   *aRow = GetRowAt(aX, aY);
   if (*aRow < 0)
     return;
 
@@ -2523,17 +2524,17 @@ nsTreeBodyFrame::GetCursor(const nsPoint
                            nsIFrame::Cursor& aCursor)
 {
   // Check the GetScriptHandlingObject so we don't end up running code when
   // the document is a zombie.
   bool dummy;
   if (mView && GetContent()->GetComposedDoc()->GetScriptHandlingObject(dummy)) {
     int32_t row;
     nsTreeColumn* col;
-    nsIAtom* child;
+    nsICSSAnonBoxPseudo* child;
     GetCellAt(aPoint.x, aPoint.y, &row, &col, &child);
 
     if (child) {
       // Our scratch array is already prefilled.
       nsStyleContext* childContext = GetPseudoStyleContext(child);
 
       FillCursorInformationFromStyle(childContext->StyleUserInterface(),
                                      aCursor);
@@ -4470,17 +4471,17 @@ nsTreeBodyFrame::ThumbMoved(nsScrollbarF
   }
   if (weakFrame.IsAlive()) {
     UpdateScrollbars(parts);
   }
 }
 
 // The style cache.
 nsStyleContext*
-nsTreeBodyFrame::GetPseudoStyleContext(nsIAtom* aPseudoElement)
+nsTreeBodyFrame::GetPseudoStyleContext(nsICSSAnonBoxPseudo* aPseudoElement)
 {
   return mStyleCache.GetStyleContext(this, PresContext(), mContent,
                                      mStyleContext, aPseudoElement,
                                      mScratchArray);
 }
 
 // Our comparator for resolving our complex pseudos
 bool
--- a/layout/xul/tree/nsTreeBodyFrame.h
+++ b/layout/xul/tree/nsTreeBodyFrame.h
@@ -313,23 +313,25 @@ protected:
   void AdjustForCellText(nsAutoString& aText,
                          int32_t aRowIndex,
                          nsTreeColumn* aColumn,
                          nsRenderingContext& aRenderingContext,
                          nsFontMetrics& aFontMetrics,
                          nsRect& aTextRect);
 
   // A helper used when hit testing.
-  nsIAtom* GetItemWithinCellAt(nscoord aX, const nsRect& aCellRect,
-                               int32_t aRowIndex, nsTreeColumn* aColumn);
+  nsICSSAnonBoxPseudo* GetItemWithinCellAt(nscoord aX,
+                                           const nsRect& aCellRect,
+                                           int32_t aRowIndex,
+                                           nsTreeColumn* aColumn);
 
   // An internal hit test.  aX and aY are expected to be in twips in the
   // coordinate system of this frame.
   void GetCellAt(nscoord aX, nscoord aY, int32_t* aRow, nsTreeColumn** aCol,
-                 nsIAtom** aChildElt);
+                 nsICSSAnonBoxPseudo** aChildElt);
 
   // Retrieve the area for the twisty for a cell.
   nsITheme* GetTwistyRect(int32_t aRowIndex,
                           nsTreeColumn* aColumn,
                           nsRect& aImageRect,
                           nsRect& aTwistyRect,
                           nsPresContext* aPresContext,
                           nsStyleContext* aTwistyContext);
@@ -357,17 +359,17 @@ protected:
   // Calculates our width/height once border and padding have been removed.
   void CalcInnerBox();
 
   // Calculate the total width of our scrollable portion
   nscoord CalcHorzWidth(const ScrollParts& aParts);
 
   // Looks up a style context in the style cache.  On a cache miss we resolve
   // the pseudo-styles passed in and place them into the cache.
-  nsStyleContext* GetPseudoStyleContext(nsIAtom* aPseudoElement);
+  nsStyleContext* GetPseudoStyleContext(nsICSSAnonBoxPseudo* aPseudoElement);
 
   // Retrieves the scrollbars and scrollview relevant to this treebody. We
   // traverse the frame tree under our base element, in frame order, looking
   // for the first relevant vertical scrollbar, horizontal scrollbar, and
   // scrollable frame (with associated content and scrollable view). These
   // are all volatile and should not be retained.
   ScrollParts GetScrollParts();
 
--- a/layout/xul/tree/nsTreeStyleCache.cpp
+++ b/layout/xul/tree/nsTreeStyleCache.cpp
@@ -31,19 +31,21 @@ nsTreeStyleCache::Transition::Hash() con
 
 
 // The style context cache impl
 nsStyleContext*
 nsTreeStyleCache::GetStyleContext(nsICSSPseudoComparator* aComparator,
                                   nsPresContext* aPresContext,
                                   nsIContent* aContent,
                                   nsStyleContext* aContext,
-                                  nsIAtom* aPseudoElement,
+                                  nsICSSAnonBoxPseudo* aPseudoElement,
                                   const AtomArray & aInputWord)
 {
+  MOZ_ASSERT(nsCSSAnonBoxes::IsTreePseudoElement(aPseudoElement));
+
   uint32_t count = aInputWord.Length();
 
   // Go ahead and init the transition table.
   if (!mTransitionTable) {
     // Automatic miss. Build the table
     mTransitionTable = new TransitionTable();
   }
 
--- a/layout/xul/tree/nsTreeStyleCache.h
+++ b/layout/xul/tree/nsTreeStyleCache.h
@@ -35,17 +35,17 @@ public:
     mCache = nullptr;
     mNextState = 0;
   }
 
   nsStyleContext* GetStyleContext(nsICSSPseudoComparator* aComparator,
                                   nsPresContext* aPresContext,
                                   nsIContent* aContent,
                                   nsStyleContext* aContext,
-                                  nsIAtom* aPseudoElement,
+                                  nsICSSAnonBoxPseudo* aPseudoElement,
                                   const AtomArray & aInputWord);
 
 protected:
   typedef uint32_t DFAState;
 
   class Transition final
   {
   public: