Bug 1405210 - Part 1: Add PrintDialogService to windows widget. r?jimm, mshal draft
authorMantaroh Yoshinaga <mantaroh@gmail.com>
Thu, 19 Oct 2017 11:04:13 +0900
changeset 682922 9e0a9e3614520f021efca8070819786b8c7a09d0
parent 681956 f78d5947333422ab09ec23e3dab0d48538c9d6ad
child 682923 389f337fb9c76f097d9177e1aafe29be402f20d3
push id85208
push usermantaroh@gmail.com
push dateThu, 19 Oct 2017 02:07:22 +0000
reviewersjimm, mshal
bugs1405210
milestone58.0a1
Bug 1405210 - Part 1: Add PrintDialogService to windows widget. r?jimm, mshal In order to move print native dialog code to windows widget, this patch will create skeleton of PrintDialogService to windows widget. Toolkit code(i.e. nsIPrintingPrompotService) will call this PrintDialogService. Note that this PrintingDialogService suppose running on main process, so we should call this interface from main process(i.e. nsPrintingPromptService, not nsPrintingProxy). MozReview-Commit-ID: 3P6kac9I9W4
widget/moz.build
widget/windows/moz.build
widget/windows/nsPrintDialogWin.cpp
widget/windows/nsPrintDialogWin.h
widget/windows/nsWidgetFactory.cpp
widget/windows/nsWindowBase.cpp
--- a/widget/moz.build
+++ b/widget/moz.build
@@ -33,18 +33,16 @@ with Files("*WindowSurface*"):
 
 with Files("*FontRange*"):
     BUG_COMPONENT = ("Core", "Widget: Cocoa")
 
 toolkit = CONFIG['MOZ_WIDGET_TOOLKIT']
 
 if toolkit in ('cocoa', 'android', 'uikit'):
     DIRS += [toolkit]
-if toolkit in ('android', 'cocoa', 'gtk2', 'gtk3'):
-    EXPORTS += ['nsIPrintDialogService.h']
 
 if toolkit == 'windows':
     DIRS += ['windows']
 
     XPIDL_SOURCES += [
         'nsIJumpListBuilder.idl',
         'nsIJumpListItem.idl',
         'nsIPrintSettingsWin.idl',
@@ -122,16 +120,17 @@ EXPORTS += [
     'GfxInfoBase.h',
     'GfxInfoCollector.h',
     'InputData.h',
     'nsBaseScreen.h',
     'nsBaseWidget.h',
     'nsIDeviceContextSpec.h',
     'nsIKeyEventInPluginCallback.h',
     'nsIPluginWidget.h',
+    'nsIPrintDialogService.h',
     'nsIRollupListener.h',
     'nsIWidget.h',
     'nsIWidgetListener.h',
     'nsWidgetInitData.h',
     'nsWidgetsCID.h',
     'PuppetWidget.h',
 ]
 
--- a/widget/windows/moz.build
+++ b/widget/windows/moz.build
@@ -90,16 +90,17 @@ SOURCES += [
 if CONFIG['MOZ_CRASHREPORTER']:
     UNIFIED_SOURCES += [
         'LSPAnnotator.cpp',
     ]
 
 if CONFIG['NS_PRINTING']:
     UNIFIED_SOURCES += [
         'nsDeviceContextSpecWin.cpp',
+        'nsPrintDialogWin.cpp',
         'nsPrintOptionsWin.cpp',
         'nsPrintSettingsWin.cpp',
     ]
     if CONFIG['MOZ_ENABLE_SKIA_PDF']:
         DIRS += ['/modules/pdfium']
         UNIFIED_SOURCES += [
             'PDFiumEngineShim.cpp',
             'PDFViaEMFPrintHelper.cpp',
new file mode 100644
--- /dev/null
+++ b/widget/windows/nsPrintDialogWin.cpp
@@ -0,0 +1,43 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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 "nsPrintDialogWin.h"
+
+#include "nsIBaseWindow.h"
+#include "nsIPrintSettings.h"
+#include "nsIWebBrowserChrome.h"
+
+using namespace mozilla;
+
+NS_IMPL_ISUPPORTS(nsPrintDialogServiceWin, nsIPrintDialogService)
+
+nsPrintDialogServiceWin::nsPrintDialogServiceWin()
+{
+}
+
+nsPrintDialogServiceWin::~nsPrintDialogServiceWin()
+{
+}
+
+NS_IMETHODIMP
+nsPrintDialogServiceWin::Init()
+{
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsPrintDialogServiceWin::Show(nsPIDOMWindowOuter *aParent,
+                              nsIPrintSettings *aSettings,
+                              nsIWebBrowserPrint *aWebBrowserPrint)
+{
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsPrintDialogServiceWin::ShowPageSetup(nsPIDOMWindowOuter *aParent,
+                                       nsIPrintSettings *aNSSettings)
+{
+  return NS_OK;
+}
new file mode 100644
--- /dev/null
+++ b/widget/windows/nsPrintDialogWin.h
@@ -0,0 +1,30 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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/. */
+
+#ifndef nsPrintDialog_h__
+#define nsPrintDialog_h__
+
+#include "nsIPrintDialogService.h"
+
+class nsIPrintSettings;
+
+class nsPrintDialogServiceWin : public nsIPrintDialogService
+{
+  virtual ~nsPrintDialogServiceWin();
+
+public:
+  nsPrintDialogServiceWin();
+
+  NS_DECL_ISUPPORTS
+
+  NS_IMETHOD Init() override;
+  NS_IMETHOD Show(nsPIDOMWindowOuter *aParent, nsIPrintSettings *aSettings,
+                  nsIWebBrowserPrint *aWebBrowserPrint) override;
+  NS_IMETHOD ShowPageSetup(nsPIDOMWindowOuter *aParent,
+                           nsIPrintSettings *aSettings) override;
+
+};
+
+#endif
--- a/widget/windows/nsWidgetFactory.cpp
+++ b/widget/windows/nsWidgetFactory.cpp
@@ -44,16 +44,17 @@
 #include "WinTaskbar.h"
 #include "JumpListBuilder.h"
 #include "JumpListItem.h"
 
 #include "WindowsUIUtils.h"
 
 #ifdef NS_PRINTING
 #include "nsDeviceContextSpecWin.h"
+#include "nsPrintDialogWin.h"
 #include "nsPrintOptionsWin.h"
 #include "nsPrintSession.h"
 #endif
 
 using namespace mozilla;
 using namespace mozilla::widget;
 
 static nsresult
@@ -133,16 +134,17 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(JumpListL
 NS_GENERIC_FACTORY_CONSTRUCTOR(JumpListShortcut)
 NS_GENERIC_FACTORY_CONSTRUCTOR(WindowsUIUtils)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard)
 NS_GENERIC_FACTORY_CONSTRUCTOR(TaskbarPreviewCallback)
 #ifdef NS_PRINTING
+NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintDialogServiceWin, Init)
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsWin, Init)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterEnumeratorWin)
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecWin)
 #endif
 
 namespace mozilla {
 namespace widget {
@@ -171,16 +173,17 @@ NS_DEFINE_NAMED_CID(NS_WIN_JUMPLISTITEM_
 NS_DEFINE_NAMED_CID(NS_WIN_JUMPLISTSEPARATOR_CID);
 NS_DEFINE_NAMED_CID(NS_WIN_JUMPLISTLINK_CID);
 NS_DEFINE_NAMED_CID(NS_WIN_JUMPLISTSHORTCUT_CID);
 NS_DEFINE_NAMED_CID(NS_WINDOWS_UIUTILS_CID);
 NS_DEFINE_NAMED_CID(NS_DRAGSERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_BIDIKEYBOARD_CID);
 NS_DEFINE_NAMED_CID(NS_TASKBARPREVIEWCALLBACK_CID);
 #ifdef NS_PRINTING
+NS_DEFINE_NAMED_CID(NS_PRINTDIALOGSERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_PRINTSETTINGSSERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_PRINTER_ENUMERATOR_CID);
 NS_DEFINE_NAMED_CID(NS_PRINTSESSION_CID);
 NS_DEFINE_NAMED_CID(NS_DEVICE_CONTEXT_SPEC_CID);
 #endif
 
 
 static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
@@ -205,16 +208,17 @@ static const mozilla::Module::CIDEntry k
   { &kNS_WIN_JUMPLISTSEPARATOR_CID, false, nullptr, JumpListSeparatorConstructor },
   { &kNS_WIN_JUMPLISTLINK_CID, false, nullptr, JumpListLinkConstructor },
   { &kNS_WIN_JUMPLISTSHORTCUT_CID, false, nullptr, JumpListShortcutConstructor },
   { &kNS_WINDOWS_UIUTILS_CID, false, nullptr, WindowsUIUtilsConstructor },
   { &kNS_DRAGSERVICE_CID, false, nullptr, nsDragServiceConstructor, Module::MAIN_PROCESS_ONLY },
   { &kNS_BIDIKEYBOARD_CID, false, nullptr, nsBidiKeyboardConstructor, Module::MAIN_PROCESS_ONLY },
   { &kNS_TASKBARPREVIEWCALLBACK_CID, false, nullptr, TaskbarPreviewCallbackConstructor },
 #ifdef NS_PRINTING
+  { &kNS_PRINTDIALOGSERVICE_CID, false, nullptr, nsPrintDialogServiceWinConstructor, Module::MAIN_PROCESS_ONLY },
   { &kNS_PRINTSETTINGSSERVICE_CID, false, nullptr, nsPrintOptionsWinConstructor },
   { &kNS_PRINTER_ENUMERATOR_CID, false, nullptr, nsPrinterEnumeratorWinConstructor },
   { &kNS_PRINTSESSION_CID, false, nullptr, nsPrintSessionConstructor },
   { &kNS_DEVICE_CONTEXT_SPEC_CID, false, nullptr, nsDeviceContextSpecWinConstructor },
 #endif
   { nullptr }
 };
 
@@ -239,16 +243,17 @@ static const mozilla::Module::ContractID
   { "@mozilla.org/windows-jumplistseparator;1", &kNS_WIN_JUMPLISTSEPARATOR_CID },
   { "@mozilla.org/windows-jumplistlink;1", &kNS_WIN_JUMPLISTLINK_CID },
   { "@mozilla.org/windows-jumplistshortcut;1", &kNS_WIN_JUMPLISTSHORTCUT_CID },
   { "@mozilla.org/windows-ui-utils;1", &kNS_WINDOWS_UIUTILS_CID },
   { "@mozilla.org/widget/dragservice;1", &kNS_DRAGSERVICE_CID, Module::MAIN_PROCESS_ONLY },
   { "@mozilla.org/widget/bidikeyboard;1", &kNS_BIDIKEYBOARD_CID, Module::MAIN_PROCESS_ONLY },
   { "@mozilla.org/widget/taskbar-preview-callback;1", &kNS_TASKBARPREVIEWCALLBACK_CID },
 #ifdef NS_PRINTING
+  { NS_PRINTDIALOGSERVICE_CONTRACTID, &kNS_PRINTDIALOGSERVICE_CID },
   { "@mozilla.org/gfx/printsettings-service;1", &kNS_PRINTSETTINGSSERVICE_CID },
   { "@mozilla.org/gfx/printerenumerator;1", &kNS_PRINTER_ENUMERATOR_CID },
   { "@mozilla.org/gfx/printsession;1", &kNS_PRINTSESSION_CID },
   { "@mozilla.org/gfx/devicecontextspec;1", &kNS_DEVICE_CONTEXT_SPEC_CID },
 #endif
   { nullptr }
 };
 
--- a/widget/windows/nsWindowBase.cpp
+++ b/widget/windows/nsWindowBase.cpp
@@ -6,16 +6,17 @@
 #include "nsWindowBase.h"
 
 #include "gfxPrefs.h"
 #include "mozilla/MiscEvents.h"
 #include "KeyboardLayout.h"
 #include "WinUtils.h"
 #include "npapi.h"
 #include "nsAutoPtr.h"
+#include "nsIPresShell.h"
 
 using namespace mozilla;
 using namespace mozilla::widget;
 
 static const wchar_t kUser32LibName[] =  L"user32.dll";
 bool nsWindowBase::sTouchInjectInitialized = false;
 InjectTouchInputPtr nsWindowBase::sInjectTouchFuncPtr;