Bug 1492011 change ProcessArguments from instance method to nonmember function with internal linkage r=baku
authorKarl Tomlinson <karlt+@karlt.net>
Tue, 24 Mar 2020 09:55:41 +0000
changeset 520318 84ab47891f808b84ac86426f0beb08c833864637
parent 520317 bdbad2a40ec28c445c57a22e0adeb4b60f5db80e
child 520319 6427a6469f454ae46170a448b03b9edf7886a23c
push id37247
push userbtara@mozilla.com
push dateWed, 25 Mar 2020 09:34:57 +0000
treeherdermozilla-central@2abd352490a4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1492011
milestone76.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 1492011 change ProcessArguments from instance method to nonmember function with internal linkage r=baku Depends on D67994 Differential Revision: https://phabricator.services.mozilla.com/D67995
dom/console/Console.cpp
dom/console/Console.h
--- a/dom/console/Console.cpp
+++ b/dom/console/Console.cpp
@@ -78,16 +78,20 @@ struct ConsoleStructuredCloneData {
 };
 
 static void ComposeAndStoreGroupName(JSContext* aCx,
                                      const Sequence<JS::Value>& aData,
                                      nsAString& aName,
                                      nsTArray<nsString>* aGroupStack);
 static bool UnstoreGroupName(nsAString& aName, nsTArray<nsString>* aGroupStack);
 
+static bool ProcessArguments(JSContext* aCx, const Sequence<JS::Value>& aData,
+                             Sequence<JS::Value>& aSequence,
+                             Sequence<nsString>& aStyles);
+
 /**
  * Console API in workers uses the Structured Clone Algorithm to move any value
  * from the worker thread to the main-thread. Some object cannot be moved and,
  * in these cases, we convert them to strings.
  * It's not the best, but at least we are able to show something.
  */
 
 class ConsoleCallData final {
@@ -1743,19 +1747,52 @@ bool FlushOutput(JSContext* aCx, Sequenc
     aOutput.Truncate();
   }
 
   return true;
 }
 
 }  // namespace
 
-bool Console::ProcessArguments(JSContext* aCx, const Sequence<JS::Value>& aData,
-                               Sequence<JS::Value>& aSequence,
-                               Sequence<nsString>& aStyles) const {
+static void MakeFormatString(nsCString& aFormat, int32_t aInteger,
+                             int32_t aMantissa, char aCh) {
+  aFormat.Append('%');
+  if (aInteger >= 0) {
+    aFormat.AppendInt(aInteger);
+  }
+
+  if (aMantissa >= 0) {
+    aFormat.Append('.');
+    aFormat.AppendInt(aMantissa);
+  }
+
+  aFormat.Append(aCh);
+}
+
+// If the first JS::Value of the array is a string, this method uses it to
+// format a string. The supported sequences are:
+//   %s    - string
+//   %d,%i - integer
+//   %f    - double
+//   %o,%O - a JS object.
+//   %c    - style string.
+// The output is an array where any object is a separated item, the rest is
+// unified in a format string.
+// Example if the input is:
+//   "string: %s, integer: %d, object: %o, double: %d", 's', 1, window, 0.9
+// The output will be:
+//   [ "string: s, integer: 1, object: ", window, ", double: 0.9" ]
+//
+// The aStyles array is populated with the style strings that the function
+// finds based the format string. The index of the styles matches the indexes
+// of elements that need the custom styling from aSequence. For elements with
+// no custom styling the array is padded with null elements.
+static bool ProcessArguments(JSContext* aCx, const Sequence<JS::Value>& aData,
+                             Sequence<JS::Value>& aSequence,
+                             Sequence<nsString>& aStyles) {
   // This method processes the arguments as format strings (%d, %i, %s...)
   // only if the first element of them is a valid and not-empty string.
 
   if (aData.IsEmpty()) {
     return true;
   }
 
   if (aData.Length() == 1 || !aData[0].isString()) {
@@ -1989,31 +2026,16 @@ bool Console::ProcessArguments(JSContext
     if (NS_WARN_IF(!aSequence.AppendElement(aData[index], fallible))) {
       return false;
     }
   }
 
   return true;
 }
 
-void Console::MakeFormatString(nsCString& aFormat, int32_t aInteger,
-                               int32_t aMantissa, char aCh) const {
-  aFormat.Append('%');
-  if (aInteger >= 0) {
-    aFormat.AppendInt(aInteger);
-  }
-
-  if (aMantissa >= 0) {
-    aFormat.Append('.');
-    aFormat.AppendInt(aMantissa);
-  }
-
-  aFormat.Append(aCh);
-}
-
 // Stringify and Concat all the JS::Value in a single string using ' ' as
 // separator. The new group name will be stored in aGroupStack array.
 static void ComposeAndStoreGroupName(JSContext* aCx,
                                      const Sequence<JS::Value>& aData,
                                      nsAString& aName,
                                      nsTArray<nsString>* aGroupStack) {
   for (uint32_t i = 0; i < aData.Length(); ++i) {
     if (i != 0) {
--- a/dom/console/Console.h
+++ b/dom/console/Console.h
@@ -248,41 +248,16 @@ class Console final : public nsIObserver
   //   handler about a new ConsoleEvent.
   // - It can be the global from the JSContext when RetrieveConsoleEvents is
   //   called.
   bool PopulateConsoleNotificationInTheTargetScope(
       JSContext* aCx, const Sequence<JS::Value>& aArguments,
       JS::Handle<JSObject*> aTargetScope, JS::MutableHandle<JS::Value> aValue,
       ConsoleCallData* aData, nsTArray<nsString>* aGroupStack);
 
-  // If the first JS::Value of the array is a string, this method uses it to
-  // format a string. The supported sequences are:
-  //   %s    - string
-  //   %d,%i - integer
-  //   %f    - double
-  //   %o,%O - a JS object.
-  //   %c    - style string.
-  // The output is an array where any object is a separated item, the rest is
-  // unified in a format string.
-  // Example if the input is:
-  //   "string: %s, integer: %d, object: %o, double: %d", 's', 1, window, 0.9
-  // The output will be:
-  //   [ "string: s, integer: 1, object: ", window, ", double: 0.9" ]
-  //
-  // The aStyles array is populated with the style strings that the function
-  // finds based the format string. The index of the styles matches the indexes
-  // of elements that need the custom styling from aSequence. For elements with
-  // no custom styling the array is padded with null elements.
-  bool ProcessArguments(JSContext* aCx, const Sequence<JS::Value>& aData,
-                        Sequence<JS::Value>& aSequence,
-                        Sequence<nsString>& aStyles) const;
-
-  void MakeFormatString(nsCString& aFormat, int32_t aInteger, int32_t aMantissa,
-                        char aCh) const;
-
   enum TimerStatus {
     eTimerUnknown,
     eTimerDone,
     eTimerAlreadyExists,
     eTimerDoesntExist,
     eTimerJSException,
     eTimerMaxReached,
   };