Bug 1407624 - Make nsEscape.cpp build in non-unified mode. r?froydnj draft
authorChris Pearce <cpearce@mozilla.com>
Wed, 11 Oct 2017 16:32:23 +0200
changeset 678528 713ed2428ff68f6a7373e8d15865f9ecf2a9df8f
parent 677305 74d3a8b20c4be92d6a04908e90b9b9b652d81895
child 735351 0328b9018442c1a5ea705632b0e44b8b32f62cb7
push id83949
push userbmo:cpearce@mozilla.com
push dateWed, 11 Oct 2017 14:33:28 +0000
reviewersfroydnj
bugs1407624
milestone58.0a1
Bug 1407624 - Make nsEscape.cpp build in non-unified mode. r?froydnj nsEscape.cpp doesn't build in non-unified mode, as it uses mozilla::fallible, mozilla::CheckedInt and mozilla::ASCIIMask::IsMasked without prefixing them with the mozilla namespace. I suspect this file is usually included in unified_cpp file which includes a "using namespace mozilla" directive. MozReview-Commit-ID: GwlsK8kytLj
xpcom/io/nsEscape.cpp
--- a/xpcom/io/nsEscape.cpp
+++ b/xpcom/io/nsEscape.cpp
@@ -211,17 +211,17 @@ nsUnescapeCount(char* aStr)
 } /* NET_UnEscapeCnt */
 
 void
 nsAppendEscapedHTML(const nsACString& aSrc, nsACString& aDst)
 {
   // Preparation: aDst's length will increase by at least aSrc's length. If the
   // addition overflows, we skip this, which is fine, and we'll likely abort
   // while (infallibly) appending due to aDst becoming too large.
-  CheckedInt<nsACString::size_type> newCapacity = aDst.Length();
+  mozilla::CheckedInt<nsACString::size_type> newCapacity = aDst.Length();
   newCapacity += aSrc.Length();
   if (newCapacity.isValid()) {
     aDst.SetCapacity(newCapacity.value());
   }
 
   for (auto cur = aSrc.BeginReading(); cur != aSrc.EndReading(); cur++) {
     if (*cur == '<') {
       aDst.AppendLiteral("&lt;");
@@ -323,19 +323,19 @@ T_EscapeURL(const typename T::char_type*
 
   bool previousIsNonASCII = false;
   for (size_t i = 0; i < aPartLen; ++i) {
     unsigned_char_type c = *src++;
 
     // If there is a filter, we wish to skip any characters which match it.
     // This is needed so we don't perform an extra pass just to extract the
     // filtered characters.
-    if (aFilterMask && ASCIIMask::IsMasked(*aFilterMask, c)) {
+    if (aFilterMask && mozilla::ASCIIMask::IsMasked(*aFilterMask, c)) {
       if (!writing) {
-        if (!aResult.Append(aPart, i, fallible)) {
+        if (!aResult.Append(aPart, i, mozilla::fallible)) {
           return NS_ERROR_OUT_OF_MEMORY;
         }
         writing = true;
       }
       continue;
     }
 
     // if the char has not to be escaped or whatever follows % is
@@ -359,39 +359,39 @@ T_EscapeURL(const typename T::char_type*
          || (c > 0x20 && c < 0x7f && ignoreAscii))
         && !(c == ':' && colon)
         && !(previousIsNonASCII && c == '|' && !ignoreNonAscii)) {
       if (writing) {
         tempBuffer[tempBufferPos++] = c;
       }
     } else { /* do the escape magic */
       if (!writing) {
-        if (!aResult.Append(aPart, i, fallible)) {
+        if (!aResult.Append(aPart, i, mozilla::fallible)) {
           return NS_ERROR_OUT_OF_MEMORY;
         }
         writing = true;
       }
       uint32_t len = ::AppendPercentHex(tempBuffer + tempBufferPos, c);
       tempBufferPos += len;
       MOZ_ASSERT(len <= ENCODE_MAX_LEN, "potential buffer overflow");
     }
 
     // Flush the temp buffer if it doesnt't have room for another encoded char.
     if (tempBufferPos >= mozilla::ArrayLength(tempBuffer) - ENCODE_MAX_LEN) {
       NS_ASSERTION(writing, "should be writing");
-      if (!aResult.Append(tempBuffer, tempBufferPos, fallible)) {
+      if (!aResult.Append(tempBuffer, tempBufferPos, mozilla::fallible)) {
         return NS_ERROR_OUT_OF_MEMORY;
       }
       tempBufferPos = 0;
     }
 
     previousIsNonASCII = (c > 0x7f);
   }
   if (writing) {
-    if (!aResult.Append(tempBuffer, tempBufferPos, fallible)) {
+    if (!aResult.Append(tempBuffer, tempBufferPos, mozilla::fallible)) {
       return NS_ERROR_OUT_OF_MEMORY;
     }
   }
   aDidAppend = writing;
   return NS_OK;
 }
 
 bool