Bug 1273766 - part2: purge NS_SubtractHint inline. draft
authorJeremy Chen <jeremychen@mozilla.com>
Mon, 23 May 2016 11:26:03 +0800
changeset 369581 f52ca845fb7f00c30c37a8c182ccc387031f8ec4
parent 369580 153b06d702c272104db5980882652896b390ca57
child 369582 a2103773f4866f1192342bc022f909c7cdbc1d4c
push id18855
push userjichen@mozilla.com
push dateMon, 23 May 2016 03:26:36 +0000
bugs1273766
milestone49.0a1
Bug 1273766 - part2: purge NS_SubtractHint inline. MozReview-Commit-ID: 1UX1wZJNnat
layout/base/RestyleManager.cpp
layout/base/nsChangeHint.h
layout/style/nsStyleContext.cpp
layout/style/nsStyleStruct.cpp
layout/style/nsStyleStruct.h
--- a/layout/base/RestyleManager.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -353,17 +353,17 @@ ApplyRenderingChangeToTree(nsPresContext
   NS_ASSERTION(!(aChange & nsChangeHint_UpdateTransformLayer) ||
                aFrame->IsTransformed() ||
                aFrame->StyleDisplay()->HasTransformStyle(),
                "Unexpected UpdateTransformLayer hint");
 
   nsIPresShell *shell = aPresContext->PresShell();
   if (shell->IsPaintingSuppressed()) {
     // Don't allow synchronous rendering changes when painting is turned off.
-    aChange = NS_SubtractHint(aChange, nsChangeHint_RepaintFrame);
+    aChange &= ~nsChangeHint_RepaintFrame;
     if (!aChange) {
       return;
     }
   }
 
   // Trigger rendering updates by damaging this frame and any
   // continuations of this frame.
 #ifdef DEBUG
@@ -376,17 +376,17 @@ ApplyRenderingChangeToTree(nsPresContext
     nsIFrame* propagatedFrame = aFrame;
     while (!nsCSSRendering::FindBackground(propagatedFrame, &bgSC)) {
       propagatedFrame = propagatedFrame->GetParent();
       NS_ASSERTION(aFrame, "root frame must paint");
     }
 
     if (propagatedFrame != aFrame) {
       DoApplyRenderingChangeToTree(propagatedFrame, nsChangeHint_RepaintFrame);
-      aChange = NS_SubtractHint(aChange, nsChangeHint_RepaintFrame);
+      aChange &= ~nsChangeHint_RepaintFrame;
       if (!aChange) {
         return;
       }
     }
   }
   DoApplyRenderingChangeToTree(aFrame, aChange);
 #ifdef DEBUG
   gInApplyRenderingChangeToTree = false;
@@ -834,27 +834,27 @@ RestyleManager::ProcessRestyledFrames(ns
       FrameConstructor()->RecreateFramesForContent(content, false,
         nsCSSFrameConstructor::REMOVE_FOR_RECONSTRUCTION, nullptr);
     } else {
       NS_ASSERTION(frame, "This shouldn't happen");
 
       if (!frame->FrameMaintainsOverflow()) {
         // frame does not maintain overflow rects, so avoid calling
         // FinishAndStoreOverflow on it:
-        hint = NS_SubtractHint(hint, nsChangeHint_UpdateOverflow |
-                                     nsChangeHint_ChildrenOnlyTransform |
-                                     nsChangeHint_UpdatePostTransformOverflow |
-                                     nsChangeHint_UpdateParentOverflow);
+        hint &= ~(nsChangeHint_UpdateOverflow |
+                  nsChangeHint_ChildrenOnlyTransform |
+                  nsChangeHint_UpdatePostTransformOverflow |
+                  nsChangeHint_UpdateParentOverflow);
       }
 
       if (!(frame->GetStateBits() & NS_FRAME_MAY_BE_TRANSFORMED)) {
         // Frame can not be transformed, and thus a change in transform will
         // have no effect and we should not use the
         // nsChangeHint_UpdatePostTransformOverflow hint.
-        hint = NS_SubtractHint(hint, nsChangeHint_UpdatePostTransformOverflow);
+        hint &= ~nsChangeHint_UpdatePostTransformOverflow;
       }
 
       if (hint & nsChangeHint_UpdateEffects) {
         for (nsIFrame *cont = frame; cont;
              cont = nsLayoutUtils::GetNextContinuationOrIBSplitSibling(cont)) {
           nsSVGEffects::UpdateEffects(cont);
         }
       }
@@ -919,18 +919,18 @@ RestyleManager::ProcessRestyledFrames(ns
                    nsChangeHint_UpdateSubtreeOverflow))) {
         if (hint & nsChangeHint_UpdateSubtreeOverflow) {
           for (nsIFrame *cont = frame; cont; cont =
                  nsLayoutUtils::GetNextContinuationOrIBSplitSibling(cont)) {
             AddSubtreeToOverflowTracker(cont);
           }
           // The work we just did in AddSubtreeToOverflowTracker
           // subsumes some of the other hints:
-          hint = NS_SubtractHint(hint, nsChangeHint_UpdateOverflow |
-                                       nsChangeHint_UpdatePostTransformOverflow);
+          hint &= ~(nsChangeHint_UpdateOverflow |
+                    nsChangeHint_UpdatePostTransformOverflow);
         }
         if (hint & nsChangeHint_ChildrenOnlyTransform) {
           // The overflow areas of the child frames need to be updated:
           nsIFrame* hintFrame = GetFrameForChildrenOnlyTransformHint(frame);
           nsIFrame* childFrame = hintFrame->PrincipalChildList().FirstChild();
           NS_ASSERTION(!nsLayoutUtils::GetNextContinuationOrIBSplitSibling(frame),
                        "SVG frames should not have continuations "
                        "or ib-split siblings");
@@ -2576,18 +2576,18 @@ ElementRestyler::ElementRestyler(nsPresC
                                    aSwappedStructOwners)
   : mPresContext(aPresContext)
   , mFrame(aFrame)
   , mParentContent(nullptr)
     // XXXldb Why does it make sense to use aParentContent?  (See
     // comment above assertion at start of ElementRestyler::Restyle.)
   , mContent(mFrame->GetContent() ? mFrame->GetContent() : mParentContent)
   , mChangeList(aChangeList)
-  , mHintsHandled(NS_SubtractHint(aHintsHandledByAncestors,
-                  NS_HintsNotHandledForDescendantsIn(aHintsHandledByAncestors)))
+  , mHintsHandled(aHintsHandledByAncestors &
+                  ~NS_HintsNotHandledForDescendantsIn(aHintsHandledByAncestors))
   , mParentFrameHintsNotHandledForDescendants(nsChangeHint(0))
   , mHintsNotHandledForDescendants(nsChangeHint(0))
   , mRestyleTracker(aRestyleTracker)
   , mSelectorsForDescendants(aSelectorsForDescendants)
   , mTreeMatchContext(aTreeMatchContext)
   , mResolvedChild(nullptr)
   , mContextsToClear(aContextsToClear)
   , mSwappedStructOwners(aSwappedStructOwners)
@@ -2609,18 +2609,18 @@ ElementRestyler::ElementRestyler(const E
                                  uint32_t aConstructorFlags)
   : mPresContext(aParentRestyler.mPresContext)
   , mFrame(aFrame)
   , mParentContent(aParentRestyler.mContent)
     // XXXldb Why does it make sense to use aParentContent?  (See
     // comment above assertion at start of ElementRestyler::Restyle.)
   , mContent(mFrame->GetContent() ? mFrame->GetContent() : mParentContent)
   , mChangeList(aParentRestyler.mChangeList)
-  , mHintsHandled(NS_SubtractHint(aParentRestyler.mHintsHandled,
-                  NS_HintsNotHandledForDescendantsIn(aParentRestyler.mHintsHandled)))
+  , mHintsHandled(aParentRestyler.mHintsHandled &
+                  ~NS_HintsNotHandledForDescendantsIn(aParentRestyler.mHintsHandled))
   , mParentFrameHintsNotHandledForDescendants(
       aParentRestyler.mHintsNotHandledForDescendants)
   , mHintsNotHandledForDescendants(nsChangeHint(0))
   , mRestyleTracker(aParentRestyler.mRestyleTracker)
   , mSelectorsForDescendants(aParentRestyler.mSelectorsForDescendants)
   , mTreeMatchContext(aParentRestyler.mTreeMatchContext)
   , mResolvedChild(nullptr)
   , mContextsToClear(aParentRestyler.mContextsToClear)
@@ -2642,32 +2642,32 @@ ElementRestyler::ElementRestyler(const E
     // mHintsHandled already includes nsChangeHint_AllReflowHints we
     // don't want to pass that on to the out-of-flow reresolve, since
     // that can lead to the out-of-flow not getting reflowed when it
     // should be (eg a reresolve starting at <body> that involves
     // reflowing the <body> would miss reflowing fixed-pos nodes that
     // also need reflow).  In the cases when the out-of-flow _is_ a
     // geometric descendant of a frame we already have a reflow hint
     // for, reflow coalescing should keep us from doing the work twice.
-    mHintsHandled = NS_SubtractHint(mHintsHandled, nsChangeHint_AllReflowHints);
+    mHintsHandled &= ~nsChangeHint_AllReflowHints;
   }
 }
 
 ElementRestyler::ElementRestyler(ParentContextFromChildFrame,
                                  const ElementRestyler& aParentRestyler,
                                  nsIFrame* aFrame)
   : mPresContext(aParentRestyler.mPresContext)
   , mFrame(aFrame)
   , mParentContent(aParentRestyler.mParentContent)
     // XXXldb Why does it make sense to use aParentContent?  (See
     // comment above assertion at start of ElementRestyler::Restyle.)
   , mContent(mFrame->GetContent() ? mFrame->GetContent() : mParentContent)
   , mChangeList(aParentRestyler.mChangeList)
-  , mHintsHandled(NS_SubtractHint(aParentRestyler.mHintsHandled,
-                  NS_HintsNotHandledForDescendantsIn(aParentRestyler.mHintsHandled)))
+  , mHintsHandled(aParentRestyler.mHintsHandled &
+                  ~NS_HintsNotHandledForDescendantsIn(aParentRestyler.mHintsHandled))
   , mParentFrameHintsNotHandledForDescendants(
       // assume the worst
       nsChangeHint_Hints_NotHandledForDescendants)
   , mHintsNotHandledForDescendants(nsChangeHint(0))
   , mRestyleTracker(aParentRestyler.mRestyleTracker)
   , mSelectorsForDescendants(aParentRestyler.mSelectorsForDescendants)
   , mTreeMatchContext(aParentRestyler.mTreeMatchContext)
   , mResolvedChild(nullptr)
@@ -2698,18 +2698,18 @@ ElementRestyler::ElementRestyler(nsPresC
                                  nsTArray<ContextToClear>& aContextsToClear,
                                  nsTArray<RefPtr<nsStyleContext>>&
                                    aSwappedStructOwners)
   : mPresContext(aPresContext)
   , mFrame(nullptr)
   , mParentContent(nullptr)
   , mContent(aContent)
   , mChangeList(aChangeList)
-  , mHintsHandled(NS_SubtractHint(aHintsHandledByAncestors,
-                  NS_HintsNotHandledForDescendantsIn(aHintsHandledByAncestors)))
+  , mHintsHandled(aHintsHandledByAncestors &
+                  ~NS_HintsNotHandledForDescendantsIn(aHintsHandledByAncestors))
   , mParentFrameHintsNotHandledForDescendants(nsChangeHint(0))
   , mHintsNotHandledForDescendants(nsChangeHint(0))
   , mRestyleTracker(aRestyleTracker)
   , mSelectorsForDescendants(aSelectorsForDescendants)
   , mTreeMatchContext(aTreeMatchContext)
   , mResolvedChild(nullptr)
   , mContextsToClear(aContextsToClear)
   , mSwappedStructOwners(aSwappedStructOwners)
@@ -2787,17 +2787,17 @@ ElementRestyler::CaptureChange(nsStyleCo
               RestyleManager::ChangeHintToString(aChangeToAssume).get());
   LOG_RESTYLE_INDENT();
 
   // nsChangeHint_UpdateEffects is inherited, but it can be set due to changes
   // in inherited properties (fill and stroke).  Avoid propagating it into
   // text nodes.
   if ((ourChange & nsChangeHint_UpdateEffects) &&
       mContent && !mContent->IsElement()) {
-    ourChange = NS_SubtractHint(ourChange, nsChangeHint_UpdateEffects);
+    ourChange &= ~nsChangeHint_UpdateEffects;
   }
 
   NS_UpdateHint(ourChange, aChangeToAssume);
   if (NS_UpdateHint(mHintsHandled, ourChange)) {
     if (!(ourChange & nsChangeHint_ReconstructFrame) || mContent) {
       LOG_RESTYLE("appending change %s",
                   RestyleManager::ChangeHintToString(ourChange).get());
       mChangeList->AppendChange(mFrame, mContent, ourChange);
--- a/layout/base/nsChangeHint.h
+++ b/layout/base/nsChangeHint.h
@@ -215,21 +215,16 @@ inline void operator<(nsChangeHint s1, n
 inline void operator>(nsChangeHint s1, nsChangeHint s2) {}
 inline void operator!=(nsChangeHint s1, nsChangeHint s2) {}
 inline void operator==(nsChangeHint s1, nsChangeHint s2) {}
 inline void operator<=(nsChangeHint s1, nsChangeHint s2) {}
 inline void operator>=(nsChangeHint s1, nsChangeHint s2) {}
 
 // Operators on nsChangeHints
 
-// Merge two hints, taking the union
-inline nsChangeHint NS_SubtractHint(nsChangeHint aH1, nsChangeHint aH2) {
-  return (nsChangeHint)(aH1 & ~aH2);
-}
-
 // Merge the "src" hint into the "dst" hint
 // Returns true iff the destination changed
 inline bool NS_UpdateHint(nsChangeHint& aDest, nsChangeHint aSrc) {
   nsChangeHint r = (nsChangeHint)(aDest | aSrc);
   bool changed = (int)r != (int)aDest;
   aDest = r;
   return changed;
 }
--- a/layout/style/nsStyleContext.cpp
+++ b/layout/style/nsStyleContext.cpp
@@ -929,18 +929,17 @@ nsStyleContext::CalcStyleDifference(nsSt
       nsChangeHint maxDifference = nsStyle##struct_::MaxDifference();         \
       nsChangeHint differenceAlwaysHandledForDescendants =                    \
         nsStyle##struct_::DifferenceAlwaysHandledForDescendants();            \
       if (this##struct_ == other##struct_) {                                  \
         /* The very same struct, so we know that there will be no */          \
         /* differences.                                           */          \
         *aEqualStructs |= NS_STYLE_INHERIT_BIT(struct_);                      \
       } else if (compare ||                                                   \
-                 (NS_SubtractHint(maxDifference,                              \
-                                  differenceAlwaysHandledForDescendants) &    \
+                 ((maxDifference & ~differenceAlwaysHandledForDescendants) &  \
                   aParentHintsNotHandledForDescendants)) {                    \
         nsChangeHint difference =                                             \
           this##struct_->CalcDifference(*other##struct_ EXTRA_DIFF_ARGS);     \
         NS_ASSERTION(NS_IsHintSubset(difference, maxDifference),              \
                      "CalcDifference() returned bigger hint than "            \
                      "MaxDifference()");                                      \
         NS_UpdateHint(hint, difference);                                      \
         if (!difference) {                                                    \
@@ -1171,17 +1170,17 @@ nsStyleContext::CalcStyleDifference(nsSt
       }
     }
 
     if (change) {
       NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
     }
   }
 
-  return NS_SubtractHint(hint, nsChangeHint_NeutralChange);
+  return hint & ~nsChangeHint_NeutralChange;
 }
 
 #ifdef DEBUG
 void nsStyleContext::List(FILE* out, int32_t aIndent, bool aListDescendants)
 {
   nsAutoCString str;
   // Indent
   int32_t ix;
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -314,18 +314,17 @@ nsChangeHint nsStylePadding::CalcDiffere
 {
   if (mPadding == aOther.mPadding) {
     return NS_STYLE_HINT_NONE;
   }
   // Padding differences can't affect descendant intrinsic sizes, but do need
   // to force children to reflow so that we can reposition them, since their
   // offsets are from our frame bounds but our content rect's position within
   // those bounds is moving.
-  return NS_SubtractHint(NS_STYLE_HINT_REFLOW,
-                         nsChangeHint_ClearDescendantIntrinsics);
+  return NS_STYLE_HINT_REFLOW & ~nsChangeHint_ClearDescendantIntrinsics;
 }
 
 nsStyleBorder::nsStyleBorder(StyleStructContext aContext)
   : mBorderColors(nullptr),
     mBorderImageFill(NS_STYLE_BORDER_IMAGE_SLICE_NOFILL),
     mBorderImageRepeatH(NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH),
     mBorderImageRepeatV(NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH),
     mFloatEdge(NS_STYLE_FLOAT_EDGE_CONTENT_BOX),
@@ -1639,19 +1638,19 @@ nsStylePosition::CalcDifference(const ns
           nsChangeHint_UpdateComputedBSize |
           nsChangeHint_ReflowChangesSizeOrPosition);
     }
 
     if (isVertical ? heightChanged : widthChanged) {
       // None of our inline-size differences can affect descendant
       // intrinsic sizes and none of them need to force children to
       // reflow.
-      NS_UpdateHint(hint, NS_SubtractHint(nsChangeHint_AllReflowHints,
-                                          nsChangeHint_ClearDescendantIntrinsics |
-                                          nsChangeHint_NeedDirtyReflow));
+      NS_UpdateHint(hint, nsChangeHint_AllReflowHints &
+                          ~(nsChangeHint_ClearDescendantIntrinsics |
+                            nsChangeHint_NeedDirtyReflow));
     }
   } else {
     if (widthChanged || heightChanged) {
       NS_UpdateHint(hint, nsChangeHint_NeutralChange);
     }
   }
 
   // If any of the offsets have changed, then return the respective hints
@@ -2970,20 +2969,19 @@ nsChangeHint nsStyleDisplay::CalcDiffere
     // values such as 'none'.) We need to reframe since we want to use
     // nsTextControlFrame instead of nsNumberControlFrame if the author
     // specifies 'textfield'.
     return nsChangeHint_ReconstructFrame;
   }
 
   if (mFloats != aOther.mFloats) {
     // Changing which side we float on doesn't affect descendants directly
-    NS_UpdateHint(hint,
-       NS_SubtractHint(nsChangeHint_AllReflowHints,
-                       nsChangeHint_ClearDescendantIntrinsics |
-                       nsChangeHint_NeedDirtyReflow));
+    NS_UpdateHint(hint, nsChangeHint_AllReflowHints &
+                        ~(nsChangeHint_ClearDescendantIntrinsics |
+                          nsChangeHint_NeedDirtyReflow));
   }
 
   if (mVerticalAlign != aOther.mVerticalAlign) {
     // XXX Can this just be AllReflowHints + RepaintFrame, and be included in
     // the block below?
     NS_UpdateHint(hint, NS_STYLE_HINT_REFLOW);
   }
 
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -860,18 +860,17 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
     return aContext->PresShell()->
       AllocateByObjectID(mozilla::eArenaObjectID_nsStylePadding, sz);
   }
   void Destroy(nsPresContext* aContext);
 
   nsChangeHint CalcDifference(const nsStylePadding& aOther) const;
   static nsChangeHint MaxDifference() {
-    return NS_SubtractHint(NS_STYLE_HINT_REFLOW,
-                           nsChangeHint_ClearDescendantIntrinsics);
+    return NS_STYLE_HINT_REFLOW & ~nsChangeHint_ClearDescendantIntrinsics;
   }
   static nsChangeHint DifferenceAlwaysHandledForDescendants() {
     // CalcDifference can return nsChangeHint_ClearAncestorIntrinsics as
     // a hint not handled for descendants.  We could (and perhaps
     // should) return nsChangeHint_NeedReflow and
     // nsChangeHint_ReflowChangesSizeOrPosition as always handled for
     // descendants, but since they're always returned in conjunction
     // with nsChangeHint_ClearAncestorIntrinsics (which is not), it