OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" | 53 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" |
54 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPrintParams.h" | 54 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPrintParams.h" |
55 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPrintScalingOption
.h" | 55 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPrintScalingOption
.h" |
56 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScopedUserGesture.
h" | 56 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScopedUserGesture.
h" |
57 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | 57 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
58 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 58 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
59 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" | 59 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" |
60 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques
t.h" | 60 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques
t.h" |
61 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 61 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
62 #include "ui/base/range/range.h" | 62 #include "ui/base/range/range.h" |
| 63 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
63 #include "webkit/plugins/plugin_constants.h" | 64 #include "webkit/plugins/plugin_constants.h" |
64 #include "webkit/plugins/ppapi/common.h" | 65 #include "webkit/plugins/ppapi/common.h" |
65 #include "webkit/plugins/ppapi/event_conversion.h" | 66 #include "webkit/plugins/ppapi/event_conversion.h" |
66 #include "webkit/plugins/ppapi/fullscreen_container.h" | 67 #include "webkit/plugins/ppapi/fullscreen_container.h" |
67 #include "webkit/plugins/ppapi/gfx_conversion.h" | 68 #include "webkit/plugins/ppapi/gfx_conversion.h" |
68 #include "webkit/plugins/ppapi/host_globals.h" | 69 #include "webkit/plugins/ppapi/host_globals.h" |
69 #include "webkit/plugins/ppapi/message_channel.h" | 70 #include "webkit/plugins/ppapi/message_channel.h" |
70 #include "webkit/plugins/ppapi/npapi_glue.h" | 71 #include "webkit/plugins/ppapi/npapi_glue.h" |
71 #include "webkit/plugins/ppapi/plugin_module.h" | 72 #include "webkit/plugins/ppapi/plugin_module.h" |
72 #include "webkit/plugins/ppapi/plugin_object.h" | 73 #include "webkit/plugins/ppapi/plugin_object.h" |
(...skipping 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1613 printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas); | 1614 printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas); |
1614 DCHECK(metafile != NULL); | 1615 DCHECK(metafile != NULL); |
1615 if (metafile) | 1616 if (metafile) |
1616 ret = metafile->InitFromData(mapper.data(), mapper.size()); | 1617 ret = metafile->InitFromData(mapper.data(), mapper.size()); |
1617 #elif defined(OS_MACOSX) | 1618 #elif defined(OS_MACOSX) |
1618 printing::NativeMetafile metafile; | 1619 printing::NativeMetafile metafile; |
1619 // Create a PDF metafile and render from there into the passed in context. | 1620 // Create a PDF metafile and render from there into the passed in context. |
1620 if (metafile.InitFromData(mapper.data(), mapper.size())) { | 1621 if (metafile.InitFromData(mapper.data(), mapper.size())) { |
1621 // Flip the transform. | 1622 // Flip the transform. |
1622 CGContextRef cgContext = canvas; | 1623 CGContextRef cgContext = canvas; |
1623 CGContextSaveGState(cgContext); | 1624 gfx::ScopedCGContextSaveGState save_gstate(cgContext) |
1624 CGContextTranslateCTM(cgContext, 0, | 1625 CGContextTranslateCTM(cgContext, 0, |
1625 current_print_settings_.printable_area.size.height); | 1626 current_print_settings_.printable_area.size.height); |
1626 CGContextScaleCTM(cgContext, 1.0, -1.0); | 1627 CGContextScaleCTM(cgContext, 1.0, -1.0); |
1627 CGRect page_rect; | 1628 CGRect page_rect; |
1628 page_rect.origin.x = current_print_settings_.printable_area.point.x; | 1629 page_rect.origin.x = current_print_settings_.printable_area.point.x; |
1629 page_rect.origin.y = current_print_settings_.printable_area.point.y; | 1630 page_rect.origin.y = current_print_settings_.printable_area.point.y; |
1630 page_rect.size.width = current_print_settings_.printable_area.size.width; | 1631 page_rect.size.width = current_print_settings_.printable_area.size.width; |
1631 page_rect.size.height = current_print_settings_.printable_area.size.height; | 1632 page_rect.size.height = current_print_settings_.printable_area.size.height; |
1632 | 1633 |
1633 ret = metafile.RenderPage(1, cgContext, page_rect, true, false, true, true); | 1634 ret = metafile.RenderPage(1, cgContext, page_rect, true, false, true, true); |
1634 CGContextRestoreGState(cgContext); | |
1635 } | 1635 } |
1636 #elif defined(OS_WIN) | 1636 #elif defined(OS_WIN) |
1637 printing::Metafile* metafile = | 1637 printing::Metafile* metafile = |
1638 printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas); | 1638 printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas); |
1639 if (metafile) { | 1639 if (metafile) { |
1640 // We only have a metafile when doing print preview, so we just want to | 1640 // We only have a metafile when doing print preview, so we just want to |
1641 // pass the PDF off to preview. | 1641 // pass the PDF off to preview. |
1642 ret = metafile->InitFromData(mapper.data(), mapper.size()); | 1642 ret = metafile->InitFromData(mapper.data(), mapper.size()); |
1643 } else { | 1643 } else { |
1644 // On Windows, we now need to render the PDF to the DC that backs the | 1644 // On Windows, we now need to render the PDF to the DC that backs the |
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2424 screen_size_for_fullscreen_ = gfx::Size(); | 2424 screen_size_for_fullscreen_ = gfx::Size(); |
2425 WebElement element = container_->element(); | 2425 WebElement element = container_->element(); |
2426 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 2426 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
2427 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 2427 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
2428 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 2428 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
2429 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 2429 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
2430 } | 2430 } |
2431 | 2431 |
2432 } // namespace ppapi | 2432 } // namespace ppapi |
2433 } // namespace webkit | 2433 } // namespace webkit |
OLD | NEW |