Update printing code
This commit is contained in:
parent
326908cebb
commit
6da696b6f2
7 changed files with 23 additions and 21 deletions
|
@ -14,6 +14,7 @@
|
|||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/threading/sequenced_worker_pool.h"
|
||||
#include "base/threading/thread_restrictions.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "base/threading/worker_pool.h"
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
#include <vector>
|
||||
|
||||
#include "base/lazy_instance.h"
|
||||
#include "base/metrics/histogram.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/metrics/histogram_macros.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "content/public/renderer/pepper_plugin_instance.h"
|
||||
#include "content/public/renderer/render_thread.h"
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "base/json/json_writer.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/metrics/histogram.h"
|
||||
#include "base/metrics/histogram_macros.h"
|
||||
#include "base/process/process_handle.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
|
@ -32,6 +32,7 @@
|
|||
#include "third_party/WebKit/public/web/WebDocument.h"
|
||||
#include "third_party/WebKit/public/web/WebElement.h"
|
||||
#include "third_party/WebKit/public/web/WebFrameClient.h"
|
||||
#include "third_party/WebKit/public/web/WebFrameWidget.h"
|
||||
#include "third_party/WebKit/public/web/WebLocalFrame.h"
|
||||
#include "third_party/WebKit/public/web/WebPlugin.h"
|
||||
#include "third_party/WebKit/public/web/WebPluginDocument.h"
|
||||
|
@ -484,12 +485,9 @@ void PrepareFrameAndViewForPrint::ResizeForPrinting() {
|
|||
|
||||
// Backup size and offset if it's a local frame.
|
||||
blink::WebView* web_view = frame_.view();
|
||||
// Backup size and offset.
|
||||
if (blink::WebFrame* web_frame = web_view->mainFrame())
|
||||
prev_scroll_offset_ = web_frame->scrollOffset();
|
||||
if (blink::WebFrame* web_frame = web_view->mainFrame()) {
|
||||
if (web_frame->isWebLocalFrame())
|
||||
prev_scroll_offset_ = web_frame->scrollOffset();
|
||||
prev_scroll_offset_ = web_frame->getScrollOffset();
|
||||
}
|
||||
prev_view_size_ = web_view->size();
|
||||
|
||||
|
@ -535,8 +533,10 @@ void PrepareFrameAndViewForPrint::CopySelection(
|
|||
blink::WebView::create(this, blink::WebPageVisibilityStateVisible);
|
||||
owns_web_view_ = true;
|
||||
content::RenderView::ApplyWebPreferences(prefs, web_view);
|
||||
web_view->setMainFrame(
|
||||
blink::WebLocalFrame::create(blink::WebTreeScopeType::Document, this));
|
||||
blink::WebLocalFrame* main_frame = blink::WebLocalFrame::create(
|
||||
blink::WebTreeScopeType::Document, this, nullptr, nullptr);
|
||||
web_view->setMainFrame(main_frame);
|
||||
blink::WebFrameWidget::create(this, web_view, main_frame);
|
||||
frame_.Reset(web_view->mainFrame()->toWebLocalFrame());
|
||||
node_to_print_.reset();
|
||||
|
||||
|
@ -565,7 +565,8 @@ blink::WebLocalFrame* PrepareFrameAndViewForPrint::createChildFrame(
|
|||
const blink::WebString& unique_name,
|
||||
blink::WebSandboxFlags sandbox_flags,
|
||||
const blink::WebFrameOwnerProperties& frame_owner_properties) {
|
||||
blink::WebLocalFrame* frame = blink::WebLocalFrame::create(scope, this);
|
||||
blink::WebLocalFrame* frame = blink::WebLocalFrame::create(
|
||||
scope, this, nullptr, nullptr);
|
||||
parent->appendChild(frame);
|
||||
return frame;
|
||||
}
|
||||
|
|
|
@ -126,12 +126,12 @@ void PrintWebViewHelper::PrintPageInternal(
|
|||
&content_area);
|
||||
gfx::Rect canvas_area = content_area;
|
||||
|
||||
SkCanvas* canvas = metafile->GetVectorCanvasForNewPage(
|
||||
page_size, canvas_area, scale_factor);
|
||||
cc::PaintCanvas* canvas =
|
||||
metafile->GetVectorCanvasForNewPage(page_size, canvas_area, scale_factor);
|
||||
if (!canvas)
|
||||
return;
|
||||
|
||||
MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile);
|
||||
MetafileSkiaWrapper::SetMetafileOnCanvas(canvas, metafile);
|
||||
|
||||
RenderPageContent(frame, params.page_number, canvas_area, content_area,
|
||||
scale_factor, canvas);
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include "printing/page_size_margins.h"
|
||||
#include "third_party/WebKit/public/platform/WebCanvas.h"
|
||||
#include "third_party/WebKit/public/web/WebLocalFrame.h"
|
||||
#include "third_party/skia/include/core/SkCanvas.h"
|
||||
|
||||
namespace printing {
|
||||
|
||||
|
@ -112,13 +111,13 @@ void PrintWebViewHelper::RenderPage(const PrintMsg_Print_Params& params,
|
|||
gfx::Rect canvas_area = content_area;
|
||||
|
||||
{
|
||||
SkCanvas* canvas = metafile->GetVectorCanvasForNewPage(
|
||||
cc::PaintCanvas* canvas = metafile->GetVectorCanvasForNewPage(
|
||||
*page_size, canvas_area, scale_factor);
|
||||
if (!canvas)
|
||||
return;
|
||||
|
||||
MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile);
|
||||
skia::SetIsPreviewMetafile(*canvas, is_preview);
|
||||
MetafileSkiaWrapper::SetMetafileOnCanvas(canvas, metafile);
|
||||
cc::SetIsPreviewMetafile(canvas, is_preview);
|
||||
RenderPageContent(frame, page_number, canvas_area, content_area,
|
||||
scale_factor, static_cast<blink::WebCanvas*>(canvas));
|
||||
}
|
||||
|
|
|
@ -161,12 +161,12 @@ void PrintWebViewHelper::PrintPageInternal(
|
|||
frame->getPrintPageShrink(params.page_number);
|
||||
float scale_factor = css_scale_factor * webkit_page_shrink_factor;
|
||||
|
||||
SkCanvas* canvas = metafile->GetVectorCanvasForNewPage(
|
||||
page_size, canvas_area, scale_factor);
|
||||
cc::PaintCanvas* canvas =
|
||||
metafile->GetVectorCanvasForNewPage(page_size, canvas_area, scale_factor);
|
||||
if (!canvas)
|
||||
return;
|
||||
|
||||
MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile);
|
||||
MetafileSkiaWrapper::SetMetafileOnCanvas(canvas, metafile);
|
||||
|
||||
#if 0
|
||||
if (params.params.display_header_footer) {
|
||||
|
|
|
@ -47,7 +47,7 @@ int32_t PepperPDFHost::OnHostMsgDidStartLoading(
|
|||
if (!render_frame)
|
||||
return PP_ERROR_FAILED;
|
||||
|
||||
render_frame->DidStartLoading();
|
||||
render_frame->PluginDidStartLoading();
|
||||
return PP_OK;
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ int32_t PepperPDFHost::OnHostMsgDidStopLoading(
|
|||
if (!render_frame)
|
||||
return PP_ERROR_FAILED;
|
||||
|
||||
render_frame->DidStopLoading();
|
||||
render_frame->PluginDidStopLoading();
|
||||
return PP_OK;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue