Bug 1464060: Remove some unused templating and arguments. r?xidorn draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 24 May 2018 15:30:30 +0200
changeset 800036 f45c68fefaa86056ac315413657884aea392131c
parent 800035 6801f794b87735a993e8d49dbbf99529ce023eb2
child 800037 ab2a5d22c8c579660ba1780c75707faa2117a074
push id111238
push userbmo:emilio@crisal.io
push dateFri, 25 May 2018 19:10:29 +0000
reviewersxidorn
bugs1464060
milestone62.0a1
Bug 1464060: Remove some unused templating and arguments. r?xidorn Also don't rely on 'using namespace mozilla' in the cpp files that include nsStyleStructInlines.h. MozReview-Commit-ID: DLZiMpSzIFn
layout/style/ComputedStyle.cpp
layout/style/nsStyleStruct.h
layout/style/nsStyleStructInlines.h
--- a/layout/style/ComputedStyle.cpp
+++ b/layout/style/ComputedStyle.cpp
@@ -88,25 +88,25 @@ ComputedStyle::ComputedStyle(nsPresConte
                 "NS_STYLE_INHERIT_MASK must be bigger, and other bits shifted");
 #undef eStyleStruct_LastItem
 }
 
 nsChangeHint
 ComputedStyle::CalcStyleDifference(ComputedStyle* aNewContext,
                                    uint32_t* aEqualStructs)
 {
+  MOZ_ASSERT(aNewContext);
   AUTO_PROFILER_LABEL("ComputedStyle::CalcStyleDifference", CSS);
 
   static_assert(nsStyleStructID_Length <= 32,
                 "aEqualStructs is not big enough");
 
   *aEqualStructs = 0;
 
   nsChangeHint hint = nsChangeHint(0);
-  NS_ENSURE_TRUE(aNewContext, hint);
   // We must always ensure that we populate the structs on the new style
   // context that are filled in on the old context, so that if we get
   // two style changes in succession, the second of which causes a real
   // style change, the PeekStyleData doesn't return null (implying that
   // nobody ever looked at that struct's data).  In other words, we
   // can't skip later structs if we get a big change up front, because
   // we could later get a small change in one of those structs that we
   // don't want to miss.
@@ -265,22 +265,22 @@ ComputedStyle::CalcStyleDifference(Compu
 
     // This depends on data in nsStyleDisplay, nsStyleEffects and
     // nsStyleSVGReset, so we do it here.
 
     // Note that it's perhaps good for this test to be last because it
     // doesn't use Peek* functions to get the structs on the old
     // context.  But this isn't a big concern because these struct
     // getters should be called during frame construction anyway.
-    if (ThreadsafeStyleDisplay()->IsAbsPosContainingBlockForAppropriateFrame(this) ==
+    if (ThreadsafeStyleDisplay()->IsAbsPosContainingBlockForAppropriateFrame(*this) ==
         aNewContext->ThreadsafeStyleDisplay()->
-          IsAbsPosContainingBlockForAppropriateFrame(aNewContext) &&
-        ThreadsafeStyleDisplay()->IsFixedPosContainingBlockForAppropriateFrame(this) ==
+          IsAbsPosContainingBlockForAppropriateFrame(*aNewContext) &&
+        ThreadsafeStyleDisplay()->IsFixedPosContainingBlockForAppropriateFrame(*this) ==
         aNewContext->ThreadsafeStyleDisplay()->
-          IsFixedPosContainingBlockForAppropriateFrame(aNewContext)) {
+          IsFixedPosContainingBlockForAppropriateFrame(*aNewContext)) {
       // While some styles that cause the frame to be a containing block
       // has changed, the overall result hasn't.
       hint &= ~nsChangeHint_UpdateContainingBlock;
     }
   }
 
   MOZ_ASSERT(NS_IsHintSubset(hint, nsChangeHint_AllHints),
              "Added a new hint without bumping AllHints?");
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -2467,22 +2467,18 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
    * aContextFrame is the frame for which this is the nsStyleDisplay.
    */
   inline bool IsAbsPosContainingBlock(const nsIFrame* aContextFrame) const;
 
   /**
    * The same as IsAbsPosContainingBlock, except skipping the tests that
    * are based on the frame rather than the ComputedStyle (thus
    * potentially returning a false positive).
-   *
-   * FIXME(stylo-everywhere): Pretty sure the template can go here.
    */
-  template<class ComputedStyleLike>
-  inline bool IsAbsPosContainingBlockForAppropriateFrame(
-                ComputedStyleLike* aComputedStyle) const;
+  inline bool IsAbsPosContainingBlockForAppropriateFrame(mozilla::ComputedStyle&) const;
 
   /**
    * Returns true when the element has the transform property
    * or a related property, and supports CSS transforms.
    * aContextFrame is the frame for which this is the nsStyleDisplay.
    */
   inline bool HasTransform(const nsIFrame* aContextFrame) const;
 
@@ -2499,46 +2495,36 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
    * aContextFrame is the frame for which this is the nsStyleDisplay.
    */
   inline bool IsFixedPosContainingBlock(const nsIFrame* aContextFrame) const;
 
   /**
    * The same as IsFixedPosContainingBlock, except skipping the tests that
    * are based on the frame rather than the ComputedStyle (thus
    * potentially returning a false positive).
-   *
-   * FIXME(stylo-everywhere): Pretty sure the template can go here.
    */
-  template<class ComputedStyleLike>
-  inline bool IsFixedPosContainingBlockForAppropriateFrame(
-                ComputedStyleLike* aComputedStyle) const;
+  inline bool IsFixedPosContainingBlockForAppropriateFrame(mozilla::ComputedStyle&) const;
 
   /**
    * Returns the final combined transform.
    **/
   already_AddRefed<nsCSSValueSharedList> GetCombinedTransform() const {
     if (mCombinedTransform) {
       return do_AddRef(mCombinedTransform);
     }
 
     // backward compatible to gecko-backed style system.
     return mSpecifiedTransform ? do_AddRef(mSpecifiedTransform) : nullptr;
   }
 
 private:
   // Helpers for above functions, which do some but not all of the tests
   // for them (since transform must be tested separately for each).
-  //
-  // FIXME(stylo-everywhere): Pretty sure the template can go here.
-  template<class ComputedStyleLike>
-  inline bool HasAbsPosContainingBlockStyleInternal(
-                ComputedStyleLike* aComputedStyle) const;
-  template<class ComputedStyleLike>
-  inline bool HasFixedPosContainingBlockStyleInternal(
-                ComputedStyleLike* aComputedStyle) const;
+  inline bool HasAbsPosContainingBlockStyleInternal() const;
+  inline bool HasFixedPosContainingBlockStyleInternal(mozilla::ComputedStyle&) const;
   void GenerateCombinedTransform();
 public:
   // Return the 'float' and 'clear' properties, with inline-{start,end} values
   // resolved to {left,right} according to the given writing mode. These are
   // defined in WritingModes.h.
   inline mozilla::StyleFloat PhysicalFloats(mozilla::WritingMode aWM) const;
   inline mozilla::StyleClear PhysicalBreakType(mozilla::WritingMode aWM) const;
 };
--- a/layout/style/nsStyleStructInlines.h
+++ b/layout/style/nsStyleStructInlines.h
@@ -148,92 +148,81 @@ nsStyleDisplay::HasTransform(const nsIFr
 
 bool
 nsStyleDisplay::HasPerspective(const nsIFrame* aContextFrame) const
 {
   MOZ_ASSERT(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame");
   return HasPerspectiveStyle() && aContextFrame->IsFrameOfType(nsIFrame::eSupportsCSSTransforms);
 }
 
-template<class ComputedStyleLike>
 bool
-nsStyleDisplay::HasFixedPosContainingBlockStyleInternal(
-                  ComputedStyleLike* aComputedStyle) const
+nsStyleDisplay::HasFixedPosContainingBlockStyleInternal(mozilla::ComputedStyle& aStyle) const
 {
   // NOTE: Any CSS properties that influence the output of this function
   // should have the FIXPOS_CB flag set on them.
-  NS_ASSERTION(aComputedStyle->ThreadsafeStyleDisplay() == this,
-               "unexpected aComputedStyle");
+  NS_ASSERTION(aStyle.ThreadsafeStyleDisplay() == this, "unexpected aStyle");
 
   if (IsContainPaint()) {
     return true;
   }
 
   if (mWillChangeBitField & NS_STYLE_WILL_CHANGE_FIXPOS_CB) {
     return true;
   }
 
-  return aComputedStyle->ThreadsafeStyleEffects()->HasFilters();
+  return aStyle.ThreadsafeStyleEffects()->HasFilters();
 }
 
-template<class ComputedStyleLike>
 bool
-nsStyleDisplay::IsFixedPosContainingBlockForAppropriateFrame(
-                  ComputedStyleLike* aComputedStyle) const
+nsStyleDisplay::IsFixedPosContainingBlockForAppropriateFrame(mozilla::ComputedStyle& aStyle) const
 {
   // NOTE: Any CSS properties that influence the output of this function
   // should have the FIXPOS_CB flag set on them.
-  return HasFixedPosContainingBlockStyleInternal(aComputedStyle) ||
+  return HasFixedPosContainingBlockStyleInternal(aStyle) ||
          HasTransformStyle() || HasPerspectiveStyle();
 }
 
 bool
 nsStyleDisplay::IsFixedPosContainingBlock(const nsIFrame* aContextFrame) const
 {
   // NOTE: Any CSS properties that influence the output of this function
   // should have the FIXPOS_CB flag set on them.
-  if (!HasFixedPosContainingBlockStyleInternal(aContextFrame->Style()) &&
+  if (!HasFixedPosContainingBlockStyleInternal(*aContextFrame->Style()) &&
       !HasTransform(aContextFrame) && !HasPerspective(aContextFrame)) {
     return false;
   }
   return !nsSVGUtils::IsInSVGTextSubtree(aContextFrame);
 }
 
-template<class ComputedStyleLike>
 bool
-nsStyleDisplay::HasAbsPosContainingBlockStyleInternal(
-                  ComputedStyleLike* aComputedStyle) const
+nsStyleDisplay::HasAbsPosContainingBlockStyleInternal() const
 {
   // NOTE: Any CSS properties that influence the output of this function
   // should have the ABSPOS_CB set on them.
-  NS_ASSERTION(aComputedStyle->ThreadsafeStyleDisplay() == this,
-               "unexpected aComputedStyle");
   return IsAbsolutelyPositionedStyle() ||
          IsRelativelyPositionedStyle() ||
          (mWillChangeBitField & NS_STYLE_WILL_CHANGE_ABSPOS_CB);
 }
 
-template<class ComputedStyleLike>
 bool
-nsStyleDisplay::IsAbsPosContainingBlockForAppropriateFrame(ComputedStyleLike* aComputedStyle) const
+nsStyleDisplay::IsAbsPosContainingBlockForAppropriateFrame(mozilla::ComputedStyle& aStyle) const
 {
   // NOTE: Any CSS properties that influence the output of this function
   // should have the ABSPOS_CB set on them.
-  return HasAbsPosContainingBlockStyleInternal(aComputedStyle) ||
-         IsFixedPosContainingBlockForAppropriateFrame(aComputedStyle);
+  return HasAbsPosContainingBlockStyleInternal() ||
+         IsFixedPosContainingBlockForAppropriateFrame(aStyle);
 }
 
 bool
 nsStyleDisplay::IsAbsPosContainingBlock(const nsIFrame* aContextFrame) const
 {
   // NOTE: Any CSS properties that influence the output of this function
   // should have the ABSPOS_CB set on them.
-  mozilla::ComputedStyle* sc = aContextFrame->Style();
-  if (!HasAbsPosContainingBlockStyleInternal(sc) &&
-      !HasFixedPosContainingBlockStyleInternal(sc) &&
+  if (!HasAbsPosContainingBlockStyleInternal() &&
+      !HasFixedPosContainingBlockStyleInternal(*aContextFrame->Style()) &&
       !HasTransform(aContextFrame) &&
       !HasPerspective(aContextFrame)) {
     return false;
   }
   return !nsSVGUtils::IsInSVGTextSubtree(aContextFrame);
 }
 
 bool