Bug 685236 - Workaround Skia file path issue. r=jwatt draft
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Sun, 17 Dec 2017 00:19:51 +0900
changeset 748091 5799334bd14b096fc434ba198054f639e137413b
parent 748090 7c8da9c7bb641c9ae45eaf514737f38153e9336c
push id97067
push userVYV03354@nifty.ne.jp
push dateSun, 28 Jan 2018 02:40:47 +0000
reviewersjwatt
bugs685236
milestone60.0a1
Bug 685236 - Workaround Skia file path issue. r=jwatt MozReview-Commit-ID: 7y3tNuOtWCv
gfx/thebes/PrintTargetEMF.cpp
--- a/gfx/thebes/PrintTargetEMF.cpp
+++ b/gfx/thebes/PrintTargetEMF.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * 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 "PrintTargetEMF.h"
 #include "nsAnonymousTemporaryFile.h"
 #include "nsIFile.h"
+#include "nsNativeCharsetUtils.h"
 #include "mozilla/widget/PDFiumProcessParent.h"
 #include "mozilla/widget/PDFiumParent.h"
 #include "mozilla/widget/WindowsEMF.h"
 #include "mozilla/ipc/FileDescriptor.h"
 #include "private/pprio.h"
 
 using mozilla::gfx::DrawTarget;
 using mozilla::ipc::FileDescriptor;
@@ -96,17 +97,25 @@ PrintTargetEMF::BeginPage()
 
   // We create a new file for each page so that we can make sure each new
   // mPDFFileForOnePage contains one single page.
   nsresult rv =
    NS_OpenAnonymousTemporaryNsIFile(getter_AddRefs(mPDFFileForOnePage));
   NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
 
   nsAutoCString filePath;
+#ifdef XP_WIN
+  // Unfortunately, SkFILEWStream does not support wide char paths yet.
+  // We have to use the native charset even though it is lossy :(
+  nsAutoString filePathU;
+  mPDFFileForOnePage->GetPath(filePathU);
+  NS_CopyUnicodeToNative(filePathU, filePath);
+#else
   mPDFFileForOnePage->GetNativePath(filePath);
+#endif
   auto  stream = MakeUnique<SkFILEWStream>(filePath.get());
 
   // Creating a new PrintTargetSkPDF for each page so that we can convert each
   // of them into EMF contents individually by the PDFium processes.
   mTargetForCurrentPage = PrintTargetSkPDF::CreateOrNull(Move(stream), mSize);
   mTargetForCurrentPage->BeginPrinting(mTitle, NS_LITERAL_STRING(""), 0, 0);
   mTargetForCurrentPage->BeginPage();