Bug 1367209 part 1 - Fix some indentation and code style issues. r=jfkthame
authorMats Palmgren <mats@mozilla.com>
Sun, 04 Jun 2017 16:45:15 +0200
changeset 412714 1005b7702f1e6ba7679d73365407aa20fe10e08c
parent 412713 e429006e7579931f2f70768e0c1f016b1d270e2e
child 412715 fbfa99d9a737838a1b0811b46d3656643f71dbf4
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1367209
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 1367209 part 1 - Fix some indentation and code style issues. r=jfkthame MozReview-Commit-ID: GrmWUb0XvBL
layout/base/nsCounterManager.cpp
--- a/layout/base/nsCounterManager.cpp
+++ b/layout/base/nsCounterManager.cpp
@@ -13,21 +13,22 @@
 #include "nsContentUtils.h"
 #include "nsIContent.h"
 #include "nsTArray.h"
 
 using namespace mozilla;
 
 bool
 nsCounterUseNode::InitTextFrame(nsGenConList* aList,
-        nsIFrame* aPseudoFrame, nsIFrame* aTextFrame)
+                                nsIFrame* aPseudoFrame,
+                                nsIFrame* aTextFrame)
 {
   nsCounterNode::InitTextFrame(aList, aPseudoFrame, aTextFrame);
 
-  nsCounterList *counterList = static_cast<nsCounterList*>(aList);
+  nsCounterList* counterList = static_cast<nsCounterList*>(aList);
   counterList->Insert(this);
   bool dirty = counterList->IsDirty();
   if (!dirty) {
     if (counterList->IsLast(this)) {
       Calc(counterList);
       nsAutoString contentString;
       GetText(contentString);
       aTextFrame->GetContent()->SetText(contentString, false);
@@ -40,136 +41,140 @@ nsCounterUseNode::InitTextFrame(nsGenCon
     }
   }
 
   return false;
 }
 
 // assign the correct |mValueAfter| value to a node that has been inserted
 // Should be called immediately after calling |Insert|.
-void nsCounterUseNode::Calc(nsCounterList *aList)
+void
+nsCounterUseNode::Calc(nsCounterList* aList)
 {
-    NS_ASSERTION(!aList->IsDirty(),
-                 "Why are we calculating with a dirty list?");
-    mValueAfter = aList->ValueBefore(this);
+  NS_ASSERTION(!aList->IsDirty(),
+               "Why are we calculating with a dirty list?");
+  mValueAfter = aList->ValueBefore(this);
 }
 
 // assign the correct |mValueAfter| value to a node that has been inserted
 // Should be called immediately after calling |Insert|.
-void nsCounterChangeNode::Calc(nsCounterList *aList)
+void
+nsCounterChangeNode::Calc(nsCounterList* aList)
 {
-    NS_ASSERTION(!aList->IsDirty(),
-                 "Why are we calculating with a dirty list?");
-    if (mType == RESET) {
-        mValueAfter = mChangeValue;
-    } else {
-        NS_ASSERTION(mType == INCREMENT, "invalid type");
-        mValueAfter = nsCounterManager::IncrementCounter(aList->ValueBefore(this),
-                                                         mChangeValue);
-    }
+  NS_ASSERTION(!aList->IsDirty(), "Why are we calculating with a dirty list?");
+  if (mType == RESET) {
+    mValueAfter = mChangeValue;
+  } else {
+    NS_ASSERTION(mType == INCREMENT, "invalid type");
+    mValueAfter = nsCounterManager::IncrementCounter(aList->ValueBefore(this),
+                                                     mChangeValue);
+  }
 }
 
 // The text that should be displayed for this counter.
 void
 nsCounterUseNode::GetText(nsString& aResult)
 {
-    aResult.Truncate();
+  aResult.Truncate();
+
+  AutoTArray<nsCounterNode*, 8> stack;
+  stack.AppendElement(static_cast<nsCounterNode*>(this));
 
-    AutoTArray<nsCounterNode*, 8> stack;
-    stack.AppendElement(static_cast<nsCounterNode*>(this));
-
-    if (mAllCounters && mScopeStart)
-        for (nsCounterNode *n = mScopeStart; n->mScopePrev; n = n->mScopeStart)
-            stack.AppendElement(n->mScopePrev);
+  if (mAllCounters && mScopeStart) {
+    for (nsCounterNode* n = mScopeStart; n->mScopePrev; n = n->mScopeStart) {
+      stack.AppendElement(n->mScopePrev);
+    }
+  }
 
-    WritingMode wm = mPseudoFrame ?
-        mPseudoFrame->GetWritingMode() : WritingMode();
-    for (uint32_t i = stack.Length() - 1;; --i) {
-        nsCounterNode *n = stack[i];
-        nsAutoString text;
-        bool isTextRTL;
-        mCounterStyle->GetCounterText(n->mValueAfter, wm, text, isTextRTL);
-        aResult.Append(text);
-        if (i == 0)
-            break;
-        aResult.Append(mSeparator);
+  WritingMode wm = mPseudoFrame ?
+    mPseudoFrame->GetWritingMode() : WritingMode();
+  for (uint32_t i = stack.Length() - 1;; --i) {
+    nsCounterNode* n = stack[i];
+    nsAutoString text;
+    bool isTextRTL;
+    mCounterStyle->GetCounterText(n->mValueAfter, wm, text, isTextRTL);
+    aResult.Append(text);
+    if (i == 0) {
+      break;
     }
+    aResult.Append(mSeparator);
+  }
 }
 
 void
-nsCounterList::SetScope(nsCounterNode *aNode)
+nsCounterList::SetScope(nsCounterNode* aNode)
 {
-    // This function is responsible for setting |mScopeStart| and
-    // |mScopePrev| (whose purpose is described in nsCounterManager.h).
-    // We do this by starting from the node immediately preceding
-    // |aNode| in content tree order, which is reasonably likely to be
-    // the previous element in our scope (or, for a reset, the previous
-    // element in the containing scope, which is what we want).  If
-    // we're not in the same scope that it is, then it's too deep in the
-    // frame tree, so we walk up parent scopes until we find something
-    // appropriate.
+  // This function is responsible for setting |mScopeStart| and
+  // |mScopePrev| (whose purpose is described in nsCounterManager.h).
+  // We do this by starting from the node immediately preceding
+  // |aNode| in content tree order, which is reasonably likely to be
+  // the previous element in our scope (or, for a reset, the previous
+  // element in the containing scope, which is what we want).  If
+  // we're not in the same scope that it is, then it's too deep in the
+  // frame tree, so we walk up parent scopes until we find something
+  // appropriate.
 
-    if (aNode == First()) {
-        aNode->mScopeStart = nullptr;
-        aNode->mScopePrev = nullptr;
-        return;
-    }
+  if (aNode == First()) {
+    aNode->mScopeStart = nullptr;
+    aNode->mScopePrev = nullptr;
+    return;
+  }
 
-    // Get the content node for aNode's rendering object's *parent*,
-    // since scope includes siblings, so we want a descendant check on
-    // parents.
-    nsIContent *nodeContent = aNode->mPseudoFrame->GetContent()->GetParent();
+  // Get the content node for aNode's rendering object's *parent*,
+  // since scope includes siblings, so we want a descendant check on
+  // parents.
+  nsIContent* nodeContent = aNode->mPseudoFrame->GetContent()->GetParent();
 
-    for (nsCounterNode *prev = Prev(aNode), *start;
-         prev; prev = start->mScopePrev) {
-        // If |prev| starts a scope (because it's a real or implied
-        // reset), we want it as the scope start rather than the start
-        // of its enclosing scope.  Otherwise, there's no enclosing
-        // scope, so the next thing in prev's scope shares its scope
-        // start.
-        start = (prev->mType == nsCounterNode::RESET || !prev->mScopeStart)
-                  ? prev : prev->mScopeStart;
+  for (nsCounterNode* prev = Prev(aNode), *start;
+       prev; prev = start->mScopePrev) {
+    // If |prev| starts a scope (because it's a real or implied
+    // reset), we want it as the scope start rather than the start
+    // of its enclosing scope.  Otherwise, there's no enclosing
+    // scope, so the next thing in prev's scope shares its scope
+    // start.
+    start = (prev->mType == nsCounterNode::RESET || !prev->mScopeStart)
+      ? prev : prev->mScopeStart;
 
-        // |startContent| is analogous to |nodeContent| (see above).
-        nsIContent *startContent = start->mPseudoFrame->GetContent()->GetParent();
-        NS_ASSERTION(nodeContent || !startContent,
-                     "null check on startContent should be sufficient to "
-                     "null check nodeContent as well, since if nodeContent "
-                     "is for the root, startContent (which is before it) "
-                     "must be too");
+    // |startContent| is analogous to |nodeContent| (see above).
+    nsIContent* startContent = start->mPseudoFrame->GetContent()->GetParent();
+    NS_ASSERTION(nodeContent || !startContent,
+                 "null check on startContent should be sufficient to "
+                 "null check nodeContent as well, since if nodeContent "
+                 "is for the root, startContent (which is before it) "
+                 "must be too");
 
-             // A reset's outer scope can't be a scope created by a sibling.
-        if (!(aNode->mType == nsCounterNode::RESET &&
-              nodeContent == startContent) &&
-              // everything is inside the root (except the case above,
-              // a second reset on the root)
-            (!startContent ||
-             nsContentUtils::ContentIsDescendantOf(nodeContent,
-                                                   startContent))) {
-            aNode->mScopeStart = start;
-            aNode->mScopePrev  = prev;
-            return;
-        }
+    // A reset's outer scope can't be a scope created by a sibling.
+    if (!(aNode->mType == nsCounterNode::RESET &&
+          nodeContent == startContent) &&
+        // everything is inside the root (except the case above,
+        // a second reset on the root)
+        (!startContent ||
+         nsContentUtils::ContentIsDescendantOf(nodeContent,
+                                               startContent))) {
+      aNode->mScopeStart = start;
+      aNode->mScopePrev  = prev;
+      return;
     }
+  }
 
-    aNode->mScopeStart = nullptr;
-    aNode->mScopePrev  = nullptr;
+  aNode->mScopeStart = nullptr;
+  aNode->mScopePrev  = nullptr;
 }
 
 void
 nsCounterList::RecalcAll()
 {
   mDirty = false;
 
   for (nsCounterNode* node = First(); node; node = Next(node)) {
     SetScope(node);
     node->Calc(this);
 
     if (node->mType == nsCounterNode::USE) {
-      nsCounterUseNode *useNode = node->UseNode();
+      nsCounterUseNode* useNode = node->UseNode();
       // Null-check mText, since if the frame constructor isn't
       // batching, we could end up here while the node is being
       // constructed.
       if (useNode->mText) {
         nsAutoString text;
         useNode->GetText(text);
         useNode->mText->SetData(text);
       }
@@ -178,47 +183,48 @@ nsCounterList::RecalcAll()
 }
 
 nsCounterManager::nsCounterManager()
     : mNames()
 {
 }
 
 bool
-nsCounterManager::AddCounterResetsAndIncrements(nsIFrame *aFrame)
+nsCounterManager::AddCounterResetsAndIncrements(nsIFrame* aFrame)
 {
-    const nsStyleContent *styleContent = aFrame->StyleContent();
-    if (!styleContent->CounterIncrementCount() &&
-        !styleContent->CounterResetCount())
-        return false;
+  const nsStyleContent* styleContent = aFrame->StyleContent();
+  if (!styleContent->CounterIncrementCount() &&
+      !styleContent->CounterResetCount()) {
+    return false;
+  }
 
-    // Add in order, resets first, so all the comparisons will be optimized
-    // for addition at the end of the list.
-    int32_t i, i_end;
-    bool dirty = false;
-    for (i = 0, i_end = styleContent->CounterResetCount(); i != i_end; ++i)
-      dirty |= AddResetOrIncrement(aFrame, i, styleContent->CounterResetAt(i),
-                                   nsCounterChangeNode::RESET);
-    for (i = 0, i_end = styleContent->CounterIncrementCount(); i != i_end; ++i)
-      dirty |=
-        AddResetOrIncrement(aFrame, i, styleContent->CounterIncrementAt(i),
-                            nsCounterChangeNode::INCREMENT);
-    return dirty;
+  // Add in order, resets first, so all the comparisons will be optimized
+  // for addition at the end of the list.
+  int32_t i, i_end;
+  bool dirty = false;
+  for (i = 0, i_end = styleContent->CounterResetCount(); i != i_end; ++i) {
+    dirty |= AddResetOrIncrement(aFrame, i, styleContent->CounterResetAt(i),
+                                 nsCounterChangeNode::RESET);
+  }
+  for (i = 0, i_end = styleContent->CounterIncrementCount(); i != i_end; ++i) {
+    dirty |= AddResetOrIncrement(aFrame, i, styleContent->CounterIncrementAt(i),
+                                 nsCounterChangeNode::INCREMENT);
+  }
+  return dirty;
 }
 
 bool
 nsCounterManager::AddResetOrIncrement(nsIFrame* aFrame, int32_t aIndex,
                                       const nsStyleCounterData& aCounterData,
                                       nsCounterNode::Type aType)
 {
   nsCounterChangeNode* node =
     new nsCounterChangeNode(aFrame, aType, aCounterData.mValue, aIndex);
 
   nsCounterList* counterList = CounterListFor(aCounterData.mCounter);
-
   counterList->Insert(node);
   if (!counterList->IsLast(node)) {
     // Tell the caller it's responsible for recalculating the entire
     // list.
     counterList->SetDirty();
     return true;
   }
 
@@ -228,47 +234,47 @@ nsCounterManager::AddResetOrIncrement(ns
     node->Calc(counterList);
   }
   return false;
 }
 
 nsCounterList*
 nsCounterManager::CounterListFor(const nsSubstring& aCounterName)
 {
-    // XXX Why doesn't nsTHashtable provide an API that allows us to use
-    // get/put in one hashtable lookup?
-    nsCounterList *counterList;
-    if (!mNames.Get(aCounterName, &counterList)) {
-        counterList = new nsCounterList();
-        mNames.Put(aCounterName, counterList);
-    }
-    return counterList;
+  // XXX Why doesn't nsTHashtable provide an API that allows us to use
+  // get/put in one hashtable lookup?
+  nsCounterList* counterList;
+  if (!mNames.Get(aCounterName, &counterList)) {
+    counterList = new nsCounterList();
+    mNames.Put(aCounterName, counterList);
+  }
+  return counterList;
 }
 
 void
 nsCounterManager::RecalcAll()
 {
-    for (auto iter = mNames.Iter(); !iter.Done(); iter.Next()) {
-        nsCounterList* list = iter.UserData();
-        if (list->IsDirty()) {
-            list->RecalcAll();
-        }
+  for (auto iter = mNames.Iter(); !iter.Done(); iter.Next()) {
+    nsCounterList* list = iter.UserData();
+    if (list->IsDirty()) {
+      list->RecalcAll();
     }
+  }
 }
 
 void
 nsCounterManager::SetAllDirty()
 {
   for (auto iter = mNames.Iter(); !iter.Done(); iter.Next()) {
     iter.UserData()->SetDirty();
   }
 }
 
 bool
-nsCounterManager::DestroyNodesFor(nsIFrame *aFrame)
+nsCounterManager::DestroyNodesFor(nsIFrame* aFrame)
 {
   bool destroyedAny = false;
   for (auto iter = mNames.Iter(); !iter.Done(); iter.Next()) {
     nsCounterList* list = iter.UserData();
     if (list->DestroyNodesFor(aFrame)) {
       destroyedAny = true;
       list->SetDirty();
     }