Bug 1309868 part 2 - Use const nsIContent pointer in some layout utils. r?heycam draft
authorXidorn Quan <me@upsuper.org>
Fri, 14 Oct 2016 00:07:04 +1100
changeset 424778 3401c9c51c78c2ab5a9933206492ac5a32200ad4
parent 424777 4279a4cf097bc4f433b2cea42721b6fc20ded1ea
child 424779 408ec47f7427e5850a4cabe2d2086019f3ae2075
push id32246
push userxquan@mozilla.com
push dateThu, 13 Oct 2016 13:37:33 +0000
reviewersheycam
bugs1309868
milestone52.0a1
Bug 1309868 part 2 - Use const nsIContent pointer in some layout utils. r?heycam MozReview-Commit-ID: 5GMave4FS48
layout/base/ServoRestyleManager.cpp
layout/base/ServoRestyleManager.h
layout/base/nsLayoutUtils.cpp
layout/base/nsLayoutUtils.h
layout/generic/nsIFrame.h
layout/style/nsCSSRuleProcessor.cpp
layout/style/nsCSSRuleProcessor.h
--- a/layout/base/ServoRestyleManager.cpp
+++ b/layout/base/ServoRestyleManager.cpp
@@ -218,17 +218,17 @@ MarkChildrenAsDirtyForServo(nsIContent* 
   }
 
   if (hadChildren) {
     aContent->SetHasDirtyDescendantsForServo();
   }
 }
 
 /* static */ nsIFrame*
-ServoRestyleManager::FrameForPseudoElement(nsIContent* aContent,
+ServoRestyleManager::FrameForPseudoElement(const nsIContent* aContent,
                                            nsIAtom* aPseudoTagOrNull)
 {
   MOZ_ASSERT_IF(aPseudoTagOrNull, aContent->IsElement());
   nsIFrame* primaryFrame = aContent->GetPrimaryFrame();
 
   if (!aPseudoTagOrNull) {
     return primaryFrame;
   }
--- a/layout/base/ServoRestyleManager.h
+++ b/layout/base/ServoRestyleManager.h
@@ -88,17 +88,17 @@ public:
 
 
   /**
    * Gets the appropriate frame given a content and a pseudo-element tag.
    *
    * Right now only supports a null tag, before or after. If the pseudo-element
    * is not null, the content needs to be an element.
    */
-  static nsIFrame* FrameForPseudoElement(nsIContent* aContent,
+  static nsIFrame* FrameForPseudoElement(const nsIContent* aContent,
                                          nsIAtom* aPseudoTagOrNull);
 
 protected:
   ~ServoRestyleManager() {}
 
 private:
   ServoElementSnapshot* SnapshotForElement(Element* aElement);
 
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -1472,17 +1472,17 @@ nsLayoutUtils::GetChildListNameFor(nsIFr
   }
 #endif
 
   return id;
 }
 
 /*static*/ nsIFrame*
 nsLayoutUtils::GetBeforeFrameForContent(nsIFrame* aFrame,
-                                        nsIContent* aContent)
+                                        const nsIContent* aContent)
 {
   // We need to call GetGenConPseudos() on the first continuation/ib-split.
   // Find it, for symmetry with GetAfterFrameForContent.
   nsContainerFrame* genConParentFrame =
     FirstContinuationOrIBSplitSibling(aFrame)->GetContentInsertionFrame();
   if (!genConParentFrame) {
     return nullptr;
   }
@@ -1511,17 +1511,17 @@ nsLayoutUtils::GetBeforeFrameForContent(
 /*static*/ nsIFrame*
 nsLayoutUtils::GetBeforeFrame(nsIFrame* aFrame)
 {
   return GetBeforeFrameForContent(aFrame, aFrame->GetContent());
 }
 
 /*static*/ nsIFrame*
 nsLayoutUtils::GetAfterFrameForContent(nsIFrame* aFrame,
-                                       nsIContent* aContent)
+                                       const nsIContent* aContent)
 {
   // We need to call GetGenConPseudos() on the first continuation,
   // but callers are likely to pass the last.
   nsContainerFrame* genConParentFrame =
     FirstContinuationOrIBSplitSibling(aFrame)->GetContentInsertionFrame();
   if (!genConParentFrame) {
     return nullptr;
   }
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -276,17 +276,17 @@ public:
    * one exists.  This is typically O(1).  The frame passed in must be
    * the first-in-flow.
    *
    * @param aGenConParentFrame an ancestor of the ::before frame
    * @param aContent the content whose ::before is wanted
    * @return the ::before frame or nullptr if there isn't one
    */
   static nsIFrame* GetBeforeFrameForContent(nsIFrame* aGenConParentFrame,
-                                            nsIContent* aContent);
+                                            const nsIContent* aContent);
 
   /**
    * GetBeforeFrame returns the outermost ::before frame of the given frame, if
    * one exists.  This is typically O(1).  The frame passed in must be
    * the first-in-flow.
    *
    * @param aFrame the frame whose ::before is wanted
    * @return the :before frame or nullptr if there isn't one
@@ -299,17 +299,17 @@ public:
    * last-in-flow if needed.  This function is typically O(N) in the number
    * of child frames, following in-flows, etc.
    *
    * @param aGenConParentFrame an ancestor of the ::after frame
    * @param aContent the content whose ::after is wanted
    * @return the ::after frame or nullptr if there isn't one
    */
   static nsIFrame* GetAfterFrameForContent(nsIFrame* aGenConParentFrame,
-                                           nsIContent* aContent);
+                                           const nsIContent* aContent);
 
   /**
    * GetAfterFrame returns the outermost ::after frame of the given frame, if one
    * exists.  This will walk the in-flow chain to the last-in-flow if
    * needed.  This function is typically O(N) in the number of child
    * frames, following in-flows, etc.
    *
    * @param aFrame the frame whose ::after is wanted
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -2935,17 +2935,17 @@ public:
   /**
    * IsPseudoFrame returns whether a frame is a pseudo frame (eg an
    * anonymous table-row frame created for a CSS table-cell without an
    * enclosing table-row.
    *
    * @param aParentContent the content node corresponding to the parent frame
    * @return whether the frame is a pseudo frame
    */   
-  bool IsPseudoFrame(nsIContent* aParentContent) {
+  bool IsPseudoFrame(const nsIContent* aParentContent) {
     return mContent == aParentContent;
   }
 
   FrameProperties Properties() const {
     return FrameProperties(PresContext()->PropertyTable(), this);
   }
 
   /**
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -1252,17 +1252,17 @@ nsCSSRuleProcessor::GetContentState(Elem
     state &= ~NS_EVENT_STATE_VISITED;
     state |= NS_EVENT_STATE_UNVISITED;
   }
   return state;
 }
 
 /* static */
 bool
-nsCSSRuleProcessor::IsLink(Element* aElement)
+nsCSSRuleProcessor::IsLink(const Element* aElement)
 {
   EventStates state = aElement->StyleState();
   return state.HasAtLeastOneOfStates(NS_EVENT_STATE_VISITED | NS_EVENT_STATE_UNVISITED);
 }
 
 /* static */
 EventStates
 nsCSSRuleProcessor::GetContentStateForVisitedHandling(
--- a/layout/style/nsCSSRuleProcessor.h
+++ b/layout/style/nsCSSRuleProcessor.h
@@ -111,17 +111,17 @@ public:
              mozilla::dom::Element* aElement,
              const TreeMatchContext& aTreeMatchContext,
              nsRuleWalker::VisitedHandlingType aVisitedHandling,
              bool aIsRelevantLink);
 
   /*
    * Helper to test whether a node is a link
    */
-  static bool IsLink(mozilla::dom::Element* aElement);
+  static bool IsLink(const mozilla::dom::Element* aElement);
 
   /**
    * Returns true if the given aElement matches aSelector.
    * Like nsCSSRuleProcessor.cpp's SelectorMatches (and unlike
    * SelectorMatchesTree), this does not check an entire selector list
    * separated by combinators.
    *
    * :visited and :link will match both visited and non-visited links,