Bug 1374629 - Add mozilla::NotNull to mozilla::Encoding constant declarations. r=hsivonen draft
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Tue, 20 Jun 2017 22:04:18 +0900
changeset 598371 be305b3e804fb2e91a2e19fdad93e755c1f81de0
parent 598370 037fd8822eaf2940eabf88b8a5e7fb33d2479a50
child 598372 fd17954b906237b54277caff3ddd7744563ac326
push id65180
push userVYV03354@nifty.ne.jp
push dateWed, 21 Jun 2017 16:48:08 +0000
reviewershsivonen
bugs1374629
milestone56.0a1
Bug 1374629 - Add mozilla::NotNull to mozilla::Encoding constant declarations. r=hsivonen MozReview-Commit-ID: s1sYrq6tqm
dom/base/FormData.cpp
dom/html/HTMLFormSubmission.cpp
intl/Encoding.h
--- a/dom/base/FormData.cpp
+++ b/dom/base/FormData.cpp
@@ -13,17 +13,17 @@
 #include "mozilla/Encoding.h"
 
 #include "MultipartBlobImpl.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 FormData::FormData(nsISupports* aOwner)
-  : HTMLFormSubmission(WrapNotNull(UTF_8_ENCODING), nullptr)
+  : HTMLFormSubmission(UTF_8_ENCODING, nullptr)
   , mOwner(aOwner)
 {
 }
 
 namespace {
 
 already_AddRefed<File>
 GetOrCreateFileCalledBlob(Blob& aBlob, ErrorResult& aRv)
@@ -397,17 +397,17 @@ FormData::Constructor(const GlobalObject
 
 // -------------------------------------------------------------------------
 // nsIXHRSendable
 
 NS_IMETHODIMP
 FormData::GetSendInfo(nsIInputStream** aBody, uint64_t* aContentLength,
                       nsACString& aContentTypeWithCharset, nsACString& aCharset)
 {
-  FSMultipartFormData fs(WrapNotNull(UTF_8_ENCODING), nullptr);
+  FSMultipartFormData fs(UTF_8_ENCODING, nullptr);
 
   for (uint32_t i = 0; i < mFormData.Length(); ++i) {
     if (mFormData[i].wasNullBlob) {
       MOZ_ASSERT(mFormData[i].value.IsUSVString());
       fs.AddNameBlobOrNullPair(mFormData[i].name, nullptr);
     } else if (mFormData[i].value.IsUSVString()) {
       fs.AddNameValuePair(mFormData[i].name,
                           mFormData[i].value.GetAsUSVString());
--- a/dom/html/HTMLFormSubmission.cpp
+++ b/dom/html/HTMLFormSubmission.cpp
@@ -884,17 +884,17 @@ GetSubmitEncoding(nsGenericHTMLElement* 
     } while (spPos != -1);
   }
   // if there are no accept-charset or all the charset are not supported
   // Get the charset from document
   nsIDocument* doc = aForm->GetComposedDoc();
   if (doc) {
     return Encoding::ForName(doc->GetDocumentCharacterSet());
   }
-  return WrapNotNull(UTF_8_ENCODING);
+  return UTF_8_ENCODING;
 }
 
 void
 GetEnumAttr(nsGenericHTMLElement* aContent,
             nsIAtom* atom, int32_t* aValue)
 {
   const nsAttrValue* value = aContent->GetParsedAttr(atom);
   if (value && value->Type() == nsAttrValue::eEnum) {
--- a/intl/Encoding.h
+++ b/intl/Encoding.h
@@ -14,24 +14,26 @@
 #ifndef mozilla_Encoding_h
 #define mozilla_Encoding_h
 
 #include "mozilla/CheckedInt.h"
 #include "mozilla/NotNull.h"
 #include "mozilla/Span.h"
 #include "mozilla/Tuple.h"
 #include "nsString.h"
+#include <type_traits>
 
 namespace mozilla {
 class Encoding;
 class Decoder;
 class Encoder;
 }; // namespace mozilla
 
 #define ENCODING_RS_ENCODING mozilla::Encoding
+#define ENCODING_RS_NOT_NULL_CONST_ENCODING_PTR mozilla::NotNull<const mozilla::Encoding*>
 #define ENCODING_RS_ENCODER mozilla::Encoder
 #define ENCODING_RS_DECODER mozilla::Decoder
 
 #include "encoding_rs.h"
 
 extern "C" {
 
 nsresult
@@ -796,16 +798,21 @@ public:
 private:
   Encoding() = delete;
   Encoding(const Encoding&) = delete;
   Encoding& operator=(const Encoding&) = delete;
   ~Encoding() = delete;
 
 };
 
+static_assert(std::is_trivially_copyable<NotNull<const Encoding*>>::value,
+              "NotNull<const Encoding*> must be trivially copyable.");
+static_assert(std::is_standard_layout<NotNull<const Encoding*>>::value,
+              "NotNull<const Encoding*> must be a standard layout type.");
+
 /**
  * A converter that decodes a byte stream into Unicode according to a
  * character encoding in a streaming (incremental) manner.
  *
  * The various `Decode*` methods take an input buffer (`aSrc`) and an output
  * buffer `aDst` both of which are caller-allocated. There are variants for
  * both UTF-8 and UTF-16 output buffers.
  *