Bug 1410288 - Change nsIPrintProgressParams' attributes from wstring to AString. r=bobowen.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 19 Oct 2017 11:32:37 +1100
changeset 387566 7e391c3586f9a6b2e5496915c0c1357eb93e30ad
parent 387565 b9207815554a5be47a45c2cbe9c1f910ff89803f
child 387567 d10766b6ea6040f33c774a8087f36de0cc9d6074
push id96454
push usernnethercote@mozilla.com
push dateMon, 23 Oct 2017 02:40:48 +0000
treeherdermozilla-inbound@7e391c3586f9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbobowen
bugs1410288
milestone58.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 1410288 - Change nsIPrintProgressParams' attributes from wstring to AString. r=bobowen. It makes the C++ code nicer.
layout/printing/nsIPrintProgressParams.idl
layout/printing/nsPrintEngine.cpp
toolkit/components/printingui/ipc/PrintProgressDialogChild.cpp
toolkit/components/printingui/ipc/PrintProgressDialogParent.cpp
toolkit/components/printingui/unixshared/nsPrintProgressParams.cpp
toolkit/components/printingui/win/nsPrintProgressParams.cpp
--- a/layout/printing/nsIPrintProgressParams.idl
+++ b/layout/printing/nsIPrintProgressParams.idl
@@ -1,14 +1,14 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
 #include "nsISupports.idl"
 
 [scriptable, uuid(CA89B55B-6FAF-4051-9645-1C03EF5108F8)]
-interface nsIPrintProgressParams: nsISupports {
-
-  /* message subject */
-  attribute wstring docTitle;
-  attribute wstring docURL;
-  
+interface nsIPrintProgressParams: nsISupports
+{
+  attribute AString docTitle;
+  attribute AString docURL;
 };
--- a/layout/printing/nsPrintEngine.cpp
+++ b/layout/printing/nsPrintEngine.cpp
@@ -2678,18 +2678,18 @@ nsPrintEngine::SetDocAndURLIntoProgress(
   nsAutoString docTitleStr;
   nsAutoString docURLStr;
   GetDisplayTitleAndURL(aPO, docTitleStr, docURLStr, eDocTitleDefURLDoc);
 
   // Make sure the Titles & URLS don't get too long for the progress dialog
   EllipseLongString(docTitleStr, kTitleLength, false);
   EllipseLongString(docURLStr, kTitleLength, true);
 
-  aParams->SetDocTitle(docTitleStr.get());
-  aParams->SetDocURL(docURLStr.get());
+  aParams->SetDocTitle(docTitleStr);
+  aParams->SetDocURL(docURLStr);
 }
 
 //---------------------------------------------------------------------
 void
 nsPrintEngine::EllipseLongString(nsAString& aStr, const uint32_t aLen, bool aDoFront)
 {
   // Make sure the URLS don't get too long for the progress dialog
   if (aLen >= 3 && aStr.Length() > aLen) {
--- a/toolkit/components/printingui/ipc/PrintProgressDialogChild.cpp
+++ b/toolkit/components/printingui/ipc/PrintProgressDialogChild.cpp
@@ -91,40 +91,40 @@ PrintProgressDialogChild::OnSecurityChan
                                            nsIRequest* aRequest,
                                            uint32_t aState)
 {
   return NS_OK;
 }
 
 // nsIPrintProgressParams
 
-NS_IMETHODIMP PrintProgressDialogChild::GetDocTitle(char16_t* *aDocTitle)
+NS_IMETHODIMP
+PrintProgressDialogChild::GetDocTitle(nsAString& aDocTitle)
 {
-  NS_ENSURE_ARG(aDocTitle);
-
-  *aDocTitle = ToNewUnicode(mDocTitle);
+  aDocTitle = mDocTitle;
   return NS_OK;
 }
 
-NS_IMETHODIMP PrintProgressDialogChild::SetDocTitle(const char16_t* aDocTitle)
+NS_IMETHODIMP
+PrintProgressDialogChild::SetDocTitle(const nsAString& aDocTitle)
 {
   mDocTitle = aDocTitle;
-  Unused << SendDocTitleChange(nsString(aDocTitle));
+  Unused << SendDocTitleChange(PromiseFlatString(aDocTitle));
   return NS_OK;
 }
 
-NS_IMETHODIMP PrintProgressDialogChild::GetDocURL(char16_t **aDocURL)
+NS_IMETHODIMP
+PrintProgressDialogChild::GetDocURL(nsAString& aDocURL)
 {
-  NS_ENSURE_ARG(aDocURL);
-
-  *aDocURL = ToNewUnicode(mDocURL);
+  aDocURL = mDocURL;
   return NS_OK;
 }
 
-NS_IMETHODIMP PrintProgressDialogChild::SetDocURL(const char16_t* aDocURL)
+NS_IMETHODIMP
+PrintProgressDialogChild::SetDocURL(const nsAString& aDocURL)
 {
   mDocURL = aDocURL;
-  Unused << SendDocURLChange(nsString(aDocURL));
+  Unused << SendDocURLChange(PromiseFlatString(aDocURL));
   return NS_OK;
 }
 
 } // namespace embedding
 } // namespace mozilla
--- a/toolkit/components/printingui/ipc/PrintProgressDialogParent.cpp
+++ b/toolkit/components/printingui/ipc/PrintProgressDialogParent.cpp
@@ -58,26 +58,26 @@ PrintProgressDialogParent::RecvProgressC
   }
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 PrintProgressDialogParent::RecvDocTitleChange(const nsString& newTitle)
 {
   if (mPrintProgressParams) {
-    mPrintProgressParams->SetDocTitle(newTitle.get());
+    mPrintProgressParams->SetDocTitle(newTitle);
   }
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 PrintProgressDialogParent::RecvDocURLChange(const nsString& newURL)
 {
   if (mPrintProgressParams) {
-    mPrintProgressParams->SetDocURL(newURL.get());
+    mPrintProgressParams->SetDocURL(newURL);
   }
   return IPC_OK();
 }
 
 void
 PrintProgressDialogParent::ActorDestroy(ActorDestroyReason aWhy)
 {
 }
--- a/toolkit/components/printingui/unixshared/nsPrintProgressParams.cpp
+++ b/toolkit/components/printingui/unixshared/nsPrintProgressParams.cpp
@@ -12,36 +12,36 @@ NS_IMPL_ISUPPORTS(nsPrintProgressParams,
 nsPrintProgressParams::nsPrintProgressParams()
 {
 }
 
 nsPrintProgressParams::~nsPrintProgressParams()
 {
 }
 
-NS_IMETHODIMP nsPrintProgressParams::GetDocTitle(char16_t * *aDocTitle)
+NS_IMETHODIMP
+nsPrintProgressParams::GetDocTitle(nsAString& aDocTitle)
 {
-  NS_ENSURE_ARG(aDocTitle);
-
-  *aDocTitle = ToNewUnicode(mDocTitle);
+  aDocTitle = mDocTitle;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsPrintProgressParams::SetDocTitle(const char16_t * aDocTitle)
+NS_IMETHODIMP
+nsPrintProgressParams::SetDocTitle(const nsAString& aDocTitle)
 {
   mDocTitle = aDocTitle;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsPrintProgressParams::GetDocURL(char16_t * *aDocURL)
+NS_IMETHODIMP
+nsPrintProgressParams::GetDocURL(nsAString& aDocURL)
 {
-  NS_ENSURE_ARG(aDocURL);
-
-  *aDocURL = ToNewUnicode(mDocURL);
+  aDocURL = mDocURL;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsPrintProgressParams::SetDocURL(const char16_t * aDocURL)
+NS_IMETHODIMP
+nsPrintProgressParams::SetDocURL(const nsAString& aDocURL)
 {
   mDocURL = aDocURL;
   return NS_OK;
 }
 
--- a/toolkit/components/printingui/win/nsPrintProgressParams.cpp
+++ b/toolkit/components/printingui/win/nsPrintProgressParams.cpp
@@ -12,36 +12,36 @@ NS_IMPL_ISUPPORTS(nsPrintProgressParams,
 nsPrintProgressParams::nsPrintProgressParams()
 {
 }
 
 nsPrintProgressParams::~nsPrintProgressParams()
 {
 }
 
-NS_IMETHODIMP nsPrintProgressParams::GetDocTitle(char16_t * *aDocTitle)
+NS_IMETHODIMP
+nsPrintProgressParams::GetDocTitle(nsAString& aDocTitle)
 {
-  NS_ENSURE_ARG(aDocTitle);
-
-  *aDocTitle = ToNewUnicode(mDocTitle);
+  aDocTitle = mDocTitle;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsPrintProgressParams::SetDocTitle(const char16_t * aDocTitle)
+NS_IMETHODIMP
+nsPrintProgressParams::SetDocTitle(const nsAString& aDocTitle)
 {
   mDocTitle = aDocTitle;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsPrintProgressParams::GetDocURL(char16_t * *aDocURL)
+NS_IMETHODIMP
+nsPrintProgressParams::GetDocURL(nsAString& aDocURL)
 {
-  NS_ENSURE_ARG(aDocURL);
-
-  *aDocURL = ToNewUnicode(mDocURL);
+  aDocURL = mDocURL;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsPrintProgressParams::SetDocURL(const char16_t * aDocURL)
+NS_IMETHODIMP
+nsPrintProgressParams::SetDocURL(const nsAString& aDocURL)
 {
   mDocURL = aDocURL;
   return NS_OK;
 }