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 @@
#include "public/web/WebPerformance.h"
#include "public/web/WebPlugin.h"
#include "public/web/WebPrintParams.h"
#include "public/web/WebPrintPresetOptions.h"
#include "public/web/WebRange.h"
#include "public/web/WebScriptSource.h"
#include "public/web/WebSecurityOrigin.h"
......@@ -1341,14 +1342,14 @@ bool WebLocalFrameImpl::isPrintScalingDisabledForPlugin(const WebNode& node)
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());
if (!pluginContainer || !pluginContainer->supportsPaginatedPrint())
return 1;
return false;
return pluginContainer->getCopiesToPrint();
return pluginContainer->getPrintPresetOptionsFromDocument(presetOptions);
}
bool WebLocalFrameImpl::hasCustomPageSizeStyle(int pageIndex)
......
......@@ -180,7 +180,7 @@ public:
virtual float getPrintPageShrink(int page) override;
virtual void printEnd() 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 isPageBoxVisible(int pageIndex) override;
virtual void pageSizeAndMarginsInPixels(
......
......@@ -85,6 +85,7 @@
#include "public/web/WebInputEvent.h"
#include "public/web/WebPlugin.h"
#include "public/web/WebPrintParams.h"
#include "public/web/WebPrintPresetOptions.h"
#include "public/web/WebViewClient.h"
#include "web/ChromeClientImpl.h"
#include "web/ScrollbarGroup.h"
......@@ -322,9 +323,9 @@ bool WebPluginContainerImpl::isPrintScalingDisabled() const
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
......
......@@ -60,6 +60,7 @@ class WebPluginLoadObserver;
class WheelEvent;
class Widget;
struct WebPrintParams;
struct WebPrintPresetOptions;
class WebPluginContainerImpl final : public PluginView, public WebPluginContainer, public FrameDestructionObserver {
WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(WebPluginContainerImpl);
......@@ -131,8 +132,8 @@ public:
// If the plugin content should not be scaled to the printable area of
// the page, then this method should return true.
bool isPrintScalingDisabled() const;
// Returns number of copies to be printed.
int getCopiesToPrint() const;
// Returns true on success and sets the out parameter to the print preset options for the document.
bool getPrintPresetOptionsFromDocument(WebPrintPresetOptions*) const;
// Sets up printing at the specified WebPrintParams. Returns the number of pages to be printed at these settings.
int printBegin(const WebPrintParams&) const;
// Prints the page specified by pageNumber (0-based index) into the supplied canvas.
......
......@@ -643,12 +643,6 @@ bool WebRemoteFrameImpl::isPrintScalingDisabledForPlugin(const WebNode&)
return false;
}
int WebRemoteFrameImpl::getPrintCopiesForPlugin(const WebNode&)
{
ASSERT_NOT_REACHED();
return 1;
}
bool WebRemoteFrameImpl::hasCustomPageSizeStyle(int pageIndex)
{
ASSERT_NOT_REACHED();
......
......@@ -145,7 +145,6 @@ public:
virtual float getPrintPageShrink(int page) override;
virtual void printEnd() override;
virtual bool isPrintScalingDisabledForPlugin(const WebNode&) override;
virtual int getPrintCopiesForPlugin(const WebNode&) override;
virtual bool hasCustomPageSizeStyle(int pageIndex) override;
virtual bool isPageBoxVisible(int pageIndex) override;
virtual void pageSizeAndMarginsInPixels(
......
......@@ -496,9 +496,6 @@ public:
// return true, otherwise return false.
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 ----------------------------------------------------
// Returns true if page box (margin boxes and page borders) is visible.
......
......@@ -10,6 +10,7 @@
namespace blink {
class WebScriptExecutionCallback;
struct WebPrintPresetOptions;
// Interface for interacting with in process frames. This contains methods that
// require interacting with a frame's document.
......@@ -68,6 +69,12 @@ public:
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 --------------------------------------------------------------
// Executes script in the context of the current page and returns the value
// that the script evaluated to with callback. Script execution can be
......
......@@ -54,6 +54,7 @@ struct WebCompositionUnderline;
struct WebCursorInfo;
struct WebPluginParams;
struct WebPrintParams;
struct WebPrintPresetOptions;
struct WebPoint;
struct WebRect;
struct WebTextInputInfo;
......@@ -121,8 +122,8 @@ public:
// Returns true if the printed content should not be scaled to
// the printer's printable area.
virtual bool isPrintScalingDisabled() { return false; }
// Returns number of copies to be printed.
virtual int getCopiesToPrint() { return 1; }
// Returns true on success and sets the out parameter to the print preset options for the document.
virtual bool getPrintPresetOptionsFromDocument(WebPrintPresetOptions*) { return false; }
// Sets up printing with the specified printParams. Returns the number of
// 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