Commit 2499df59 authored by n.bansal@samsung.com's avatar n.bansal@samsung.com

Support print preset options for pdf document

Blink changes to add support for print preset options
for pdf documents. When pdf document has print preset options
set, then print preview mode should use those options.

This patch adds changes required to get print preset options
from plugin. Also, this patch removes getPrintCopiesForPlugin() 
that was added initially and is no longer required.

BUG=169120

Review URL: https://codereview.chromium.org/591053002

git-svn-id: svn://svn.chromium.org/blink/trunk@185276 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 50ebd898
...@@ -189,6 +189,7 @@ ...@@ -189,6 +189,7 @@
#include "public/web/WebPerformance.h" #include "public/web/WebPerformance.h"
#include "public/web/WebPlugin.h" #include "public/web/WebPlugin.h"
#include "public/web/WebPrintParams.h" #include "public/web/WebPrintParams.h"
#include "public/web/WebPrintPresetOptions.h"
#include "public/web/WebRange.h" #include "public/web/WebRange.h"
#include "public/web/WebScriptSource.h" #include "public/web/WebScriptSource.h"
#include "public/web/WebSecurityOrigin.h" #include "public/web/WebSecurityOrigin.h"
...@@ -1341,14 +1342,14 @@ bool WebLocalFrameImpl::isPrintScalingDisabledForPlugin(const WebNode& node) ...@@ -1341,14 +1342,14 @@ bool WebLocalFrameImpl::isPrintScalingDisabledForPlugin(const WebNode& node)
return pluginContainer->isPrintScalingDisabled(); return pluginContainer->isPrintScalingDisabled();
} }
int WebLocalFrameImpl::getPrintCopiesForPlugin(const WebNode& node) bool WebLocalFrameImpl::getPrintPresetOptionsForPlugin(const WebNode& node, WebPrintPresetOptions* presetOptions)
{ {
WebPluginContainerImpl* pluginContainer = node.isNull() ? pluginContainerFromFrame(frame()) : toWebPluginContainerImpl(node.pluginContainer()); WebPluginContainerImpl* pluginContainer = node.isNull() ? pluginContainerFromFrame(frame()) : toWebPluginContainerImpl(node.pluginContainer());
if (!pluginContainer || !pluginContainer->supportsPaginatedPrint()) if (!pluginContainer || !pluginContainer->supportsPaginatedPrint())
return 1; return false;
return pluginContainer->getCopiesToPrint(); return pluginContainer->getPrintPresetOptionsFromDocument(presetOptions);
} }
bool WebLocalFrameImpl::hasCustomPageSizeStyle(int pageIndex) bool WebLocalFrameImpl::hasCustomPageSizeStyle(int pageIndex)
......
...@@ -180,7 +180,7 @@ public: ...@@ -180,7 +180,7 @@ public:
virtual float getPrintPageShrink(int page) override; virtual float getPrintPageShrink(int page) override;
virtual void printEnd() override; virtual void printEnd() override;
virtual bool isPrintScalingDisabledForPlugin(const WebNode&) override; virtual bool isPrintScalingDisabledForPlugin(const WebNode&) override;
virtual int getPrintCopiesForPlugin(const WebNode&) override; virtual bool getPrintPresetOptionsForPlugin(const WebNode&, WebPrintPresetOptions*) override;
virtual bool hasCustomPageSizeStyle(int pageIndex) override; virtual bool hasCustomPageSizeStyle(int pageIndex) override;
virtual bool isPageBoxVisible(int pageIndex) override; virtual bool isPageBoxVisible(int pageIndex) override;
virtual void pageSizeAndMarginsInPixels( virtual void pageSizeAndMarginsInPixels(
......
...@@ -85,6 +85,7 @@ ...@@ -85,6 +85,7 @@
#include "public/web/WebInputEvent.h" #include "public/web/WebInputEvent.h"
#include "public/web/WebPlugin.h" #include "public/web/WebPlugin.h"
#include "public/web/WebPrintParams.h" #include "public/web/WebPrintParams.h"
#include "public/web/WebPrintPresetOptions.h"
#include "public/web/WebViewClient.h" #include "public/web/WebViewClient.h"
#include "web/ChromeClientImpl.h" #include "web/ChromeClientImpl.h"
#include "web/ScrollbarGroup.h" #include "web/ScrollbarGroup.h"
...@@ -322,9 +323,9 @@ bool WebPluginContainerImpl::isPrintScalingDisabled() const ...@@ -322,9 +323,9 @@ bool WebPluginContainerImpl::isPrintScalingDisabled() const
return m_webPlugin->isPrintScalingDisabled(); return m_webPlugin->isPrintScalingDisabled();
} }
int WebPluginContainerImpl::getCopiesToPrint() const bool WebPluginContainerImpl::getPrintPresetOptionsFromDocument(WebPrintPresetOptions* presetOptions) const
{ {
return m_webPlugin->getCopiesToPrint(); return m_webPlugin->getPrintPresetOptionsFromDocument(presetOptions);
} }
int WebPluginContainerImpl::printBegin(const WebPrintParams& printParams) const int WebPluginContainerImpl::printBegin(const WebPrintParams& printParams) const
......
...@@ -60,6 +60,7 @@ class WebPluginLoadObserver; ...@@ -60,6 +60,7 @@ class WebPluginLoadObserver;
class WheelEvent; class WheelEvent;
class Widget; class Widget;
struct WebPrintParams; struct WebPrintParams;
struct WebPrintPresetOptions;
class WebPluginContainerImpl final : public PluginView, public WebPluginContainer, public FrameDestructionObserver { class WebPluginContainerImpl final : public PluginView, public WebPluginContainer, public FrameDestructionObserver {
WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(WebPluginContainerImpl); WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(WebPluginContainerImpl);
...@@ -131,8 +132,8 @@ public: ...@@ -131,8 +132,8 @@ public:
// If the plugin content should not be scaled to the printable area of // If the plugin content should not be scaled to the printable area of
// the page, then this method should return true. // the page, then this method should return true.
bool isPrintScalingDisabled() const; bool isPrintScalingDisabled() const;
// Returns number of copies to be printed. // Returns true on success and sets the out parameter to the print preset options for the document.
int getCopiesToPrint() const; bool getPrintPresetOptionsFromDocument(WebPrintPresetOptions*) const;
// Sets up printing at the specified WebPrintParams. Returns the number of pages to be printed at these settings. // Sets up printing at the specified WebPrintParams. Returns the number of pages to be printed at these settings.
int printBegin(const WebPrintParams&) const; int printBegin(const WebPrintParams&) const;
// Prints the page specified by pageNumber (0-based index) into the supplied canvas. // Prints the page specified by pageNumber (0-based index) into the supplied canvas.
......
...@@ -643,12 +643,6 @@ bool WebRemoteFrameImpl::isPrintScalingDisabledForPlugin(const WebNode&) ...@@ -643,12 +643,6 @@ bool WebRemoteFrameImpl::isPrintScalingDisabledForPlugin(const WebNode&)
return false; return false;
} }
int WebRemoteFrameImpl::getPrintCopiesForPlugin(const WebNode&)
{
ASSERT_NOT_REACHED();
return 1;
}
bool WebRemoteFrameImpl::hasCustomPageSizeStyle(int pageIndex) bool WebRemoteFrameImpl::hasCustomPageSizeStyle(int pageIndex)
{ {
ASSERT_NOT_REACHED(); ASSERT_NOT_REACHED();
......
...@@ -145,7 +145,6 @@ public: ...@@ -145,7 +145,6 @@ public:
virtual float getPrintPageShrink(int page) override; virtual float getPrintPageShrink(int page) override;
virtual void printEnd() override; virtual void printEnd() override;
virtual bool isPrintScalingDisabledForPlugin(const WebNode&) override; virtual bool isPrintScalingDisabledForPlugin(const WebNode&) override;
virtual int getPrintCopiesForPlugin(const WebNode&) override;
virtual bool hasCustomPageSizeStyle(int pageIndex) override; virtual bool hasCustomPageSizeStyle(int pageIndex) override;
virtual bool isPageBoxVisible(int pageIndex) override; virtual bool isPageBoxVisible(int pageIndex) override;
virtual void pageSizeAndMarginsInPixels( virtual void pageSizeAndMarginsInPixels(
......
...@@ -496,9 +496,6 @@ public: ...@@ -496,9 +496,6 @@ public:
// return true, otherwise return false. // return true, otherwise return false.
virtual bool isPrintScalingDisabledForPlugin(const WebNode& = WebNode()) = 0; virtual bool isPrintScalingDisabledForPlugin(const WebNode& = WebNode()) = 0;
// Returns the number of copies to be printed.
virtual int getPrintCopiesForPlugin(const WebNode& = WebNode()) = 0;
// CSS3 Paged Media ---------------------------------------------------- // CSS3 Paged Media ----------------------------------------------------
// Returns true if page box (margin boxes and page borders) is visible. // Returns true if page box (margin boxes and page borders) is visible.
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
namespace blink { namespace blink {
class WebScriptExecutionCallback; class WebScriptExecutionCallback;
struct WebPrintPresetOptions;
// Interface for interacting with in process frames. This contains methods that // Interface for interacting with in process frames. This contains methods that
// require interacting with a frame's document. // require interacting with a frame's document.
...@@ -68,6 +69,12 @@ public: ...@@ -68,6 +69,12 @@ public:
virtual void sendOrientationChangeEvent() = 0; virtual void sendOrientationChangeEvent() = 0;
// Printing ------------------------------------------------------------
// Returns true on success and sets the out parameter to the print preset options for the document.
virtual bool getPrintPresetOptionsForPlugin(const WebNode&, WebPrintPresetOptions*) = 0;
// Scripting -------------------------------------------------------------- // Scripting --------------------------------------------------------------
// Executes script in the context of the current page and returns the value // Executes script in the context of the current page and returns the value
// that the script evaluated to with callback. Script execution can be // that the script evaluated to with callback. Script execution can be
......
...@@ -54,6 +54,7 @@ struct WebCompositionUnderline; ...@@ -54,6 +54,7 @@ struct WebCompositionUnderline;
struct WebCursorInfo; struct WebCursorInfo;
struct WebPluginParams; struct WebPluginParams;
struct WebPrintParams; struct WebPrintParams;
struct WebPrintPresetOptions;
struct WebPoint; struct WebPoint;
struct WebRect; struct WebRect;
struct WebTextInputInfo; struct WebTextInputInfo;
...@@ -121,8 +122,8 @@ public: ...@@ -121,8 +122,8 @@ public:
// Returns true if the printed content should not be scaled to // Returns true if the printed content should not be scaled to
// the printer's printable area. // the printer's printable area.
virtual bool isPrintScalingDisabled() { return false; } virtual bool isPrintScalingDisabled() { return false; }
// Returns number of copies to be printed. // Returns true on success and sets the out parameter to the print preset options for the document.
virtual int getCopiesToPrint() { return 1; } virtual bool getPrintPresetOptionsFromDocument(WebPrintPresetOptions*) { return false; }
// Sets up printing with the specified printParams. Returns the number of // Sets up printing with the specified printParams. Returns the number of
// pages to be printed at these settings. // pages to be printed at these settings.
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WebPrintPresetOptions_h
#define WebPrintPresetOptions_h
#include <vector>
namespace blink {
struct WebPageRange;
typedef std::vector<WebPageRange> WebPageRanges;
enum WebDuplexMode {
WebUnknownDuplexMode = -1,
WebSimplex,
WebLongEdge,
WebShortEdge
};
struct WebPageRange {
int from;
int to;
};
struct WebPrintPresetOptions {
WebPrintPresetOptions()
: isScalingDisabled(false)
, copies(0)
, duplexMode(WebUnknownDuplexMode) { }
// Specifies whether scaling is disabled.
bool isScalingDisabled;
// Specifies the number of copies to be printed.
int copies;
// Specifies duplex mode to be used for printing.
WebDuplexMode duplexMode;
// Specifies page range to be used for printing.
WebPageRanges pageRanges;
};
} // namespace blink
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment