Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: webkit/plugins/ppapi/ppapi_plugin_instance.cc

Issue 7719014: PrintPreview: Printing preview of a PDF on Mac with Skia only previews the last page of the PDF (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 RectToPPRect(printable_area, &print_settings.printable_area); 840 RectToPPRect(printable_area, &print_settings.printable_area);
841 print_settings.dpi = printer_dpi; 841 print_settings.dpi = printer_dpi;
842 print_settings.orientation = PP_PRINTORIENTATION_NORMAL; 842 print_settings.orientation = PP_PRINTORIENTATION_NORMAL;
843 print_settings.grayscale = PP_FALSE; 843 print_settings.grayscale = PP_FALSE;
844 print_settings.format = format; 844 print_settings.format = format;
845 num_pages = plugin_print_interface_->Begin(pp_instance(), 845 num_pages = plugin_print_interface_->Begin(pp_instance(),
846 &print_settings); 846 &print_settings);
847 if (!num_pages) 847 if (!num_pages)
848 return 0; 848 return 0;
849 current_print_settings_ = print_settings; 849 current_print_settings_ = print_settings;
850 #if defined(OS_LINUX) || defined(OS_WIN) 850 #if defined(USE_SKIA)
851 canvas_ = NULL; 851 canvas_ = NULL;
852 ranges_.clear(); 852 ranges_.clear();
853 #endif // OS_LINUX || OS_WIN 853 #endif // USE_SKIA
854 return num_pages; 854 return num_pages;
855 } 855 }
856 856
857 bool PluginInstance::PrintPage(int page_number, WebKit::WebCanvas* canvas) { 857 bool PluginInstance::PrintPage(int page_number, WebKit::WebCanvas* canvas) {
858 DCHECK(plugin_print_interface_); 858 DCHECK(plugin_print_interface_);
859 PP_PrintPageNumberRange_Dev page_range; 859 PP_PrintPageNumberRange_Dev page_range;
860 page_range.first_page_number = page_range.last_page_number = page_number; 860 page_range.first_page_number = page_range.last_page_number = page_number;
861 #if defined(OS_LINUX) || defined(OS_WIN) 861 #if defined(USE_SKIA)
862 // The canvas only has a metafile on it for print preview. 862 // Note: The canvas only has a metafile on it for print preview.
vandebo (ex-Chrome) 2011/09/27 16:49:00 nit: "Note" is redundant.
kmadhusu 2011/09/27 18:15:01 Done.
863 if (printing::MetafileSkiaWrapper::GetMetafileFromCanvas(canvas)) { 863 bool save_for_later =
864 (printing::MetafileSkiaWrapper::GetMetafileFromCanvas(canvas) != NULL);
865 #if defined(OS_MACOSX) || defined(OS_WIN)
866 save_for_later = save_for_later && skia::IsPreviewMetafile(canvas);
867 #endif
868 if (save_for_later) {
864 ranges_.push_back(page_range); 869 ranges_.push_back(page_range);
865 canvas_ = canvas; 870 canvas_ = canvas;
866 return true; 871 return true;
867 } else 872 } else
868 #endif // OS_LINUX || OS_WIN 873 #endif // USE_SKIA
869 { 874 {
870 return PrintPageHelper(&page_range, 1, canvas); 875 return PrintPageHelper(&page_range, 1, canvas);
871 } 876 }
872 } 877 }
873 878
874 bool PluginInstance::PrintPageHelper(PP_PrintPageNumberRange_Dev* page_ranges, 879 bool PluginInstance::PrintPageHelper(PP_PrintPageNumberRange_Dev* page_ranges,
875 int num_ranges, 880 int num_ranges,
876 WebKit::WebCanvas* canvas) { 881 WebKit::WebCanvas* canvas) {
877 // Keep a reference on the stack. See NOTE above. 882 // Keep a reference on the stack. See NOTE above.
878 scoped_refptr<PluginInstance> ref(this); 883 scoped_refptr<PluginInstance> ref(this);
(...skipping 11 matching lines...) Expand all
890 895
891 // Now we need to release the print output resource. 896 // Now we need to release the print output resource.
892 PluginModule::GetCore()->ReleaseResource(print_output); 897 PluginModule::GetCore()->ReleaseResource(print_output);
893 898
894 return ret; 899 return ret;
895 } 900 }
896 901
897 void PluginInstance::PrintEnd() { 902 void PluginInstance::PrintEnd() {
898 // Keep a reference on the stack. See NOTE above. 903 // Keep a reference on the stack. See NOTE above.
899 scoped_refptr<PluginInstance> ref(this); 904 scoped_refptr<PluginInstance> ref(this);
900 #if defined(OS_LINUX) || defined(OS_WIN) 905 #if defined(USE_SKIA)
901 if (!ranges_.empty()) 906 if (!ranges_.empty())
902 PrintPageHelper(&(ranges_.front()), ranges_.size(), canvas_.get()); 907 PrintPageHelper(&(ranges_.front()), ranges_.size(), canvas_.get());
903 canvas_ = NULL; 908 canvas_ = NULL;
904 ranges_.clear(); 909 ranges_.clear();
905 #endif // OS_LINUX || OS_WIN 910 #endif // USE_SKIA
906 911
907 DCHECK(plugin_print_interface_); 912 DCHECK(plugin_print_interface_);
908 if (plugin_print_interface_) 913 if (plugin_print_interface_)
909 plugin_print_interface_->End(pp_instance()); 914 plugin_print_interface_->End(pp_instance());
910 915
911 memset(&current_print_settings_, 0, sizeof(current_print_settings_)); 916 memset(&current_print_settings_, 0, sizeof(current_print_settings_));
912 #if defined(OS_MACOSX) 917 #if defined(OS_MACOSX)
913 last_printed_page_ = NULL; 918 last_printed_page_ = NULL;
914 #endif // defined(OS_MACOSX) 919 #endif // defined(OS_MACOSX)
915 } 920 }
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
1600 } 1605 }
1601 1606
1602 void PluginInstance::DoSetCursor(WebCursorInfo* cursor) { 1607 void PluginInstance::DoSetCursor(WebCursorInfo* cursor) {
1603 cursor_.reset(cursor); 1608 cursor_.reset(cursor);
1604 if (fullscreen_container_) 1609 if (fullscreen_container_)
1605 fullscreen_container_->DidChangeCursor(*cursor); 1610 fullscreen_container_->DidChangeCursor(*cursor);
1606 } 1611 }
1607 1612
1608 } // namespace ppapi 1613 } // namespace ppapi
1609 } // namespace webkit 1614 } // namespace webkit
OLDNEW
« skia/ext/platform_device.cc ('K') | « webkit/plugins/ppapi/ppapi_plugin_instance.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698