Bug 685236 - Workaround Skia file path issue. r=jwatt
MozReview-Commit-ID: 7y3tNuOtWCv
--- 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();