| OLD | NEW |
| 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 "chrome/renderer/print_web_view_helper.h" | 5 #include "chrome/renderer/print_web_view_helper.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/process_util.h" | 8 #include "base/process_util.h" |
| 9 #include "chrome/common/render_messages.h" | 9 #include "chrome/common/render_messages.h" |
| 10 #include "chrome/common/render_messages_params.h" | 10 #include "chrome/common/render_messages_params.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 page_params.page_size = params.params.page_size; | 101 page_params.page_size = params.params.page_size; |
| 102 page_params.content_area = gfx::Rect(params.params.margin_left, | 102 page_params.content_area = gfx::Rect(params.params.margin_left, |
| 103 params.params.margin_top, params.params.printable_size.width(), | 103 params.params.margin_top, params.params.printable_size.width(), |
| 104 params.params.printable_size.height()); | 104 params.params.printable_size.height()); |
| 105 page_params.has_visible_overlays = frame->isPageBoxVisible(page_number); | 105 page_params.has_visible_overlays = frame->isPageBoxVisible(page_number); |
| 106 | 106 |
| 107 if (!CopyMetafileDataToSharedMem(metafile.get(), | 107 if (!CopyMetafileDataToSharedMem(metafile.get(), |
| 108 &(page_params.metafile_data_handle))) { | 108 &(page_params.metafile_data_handle))) { |
| 109 page_params.data_size = 0; | 109 page_params.data_size = 0; |
| 110 } | 110 } |
| 111 metafile->CloseEmf(); | 111 metafile->Close(); |
| 112 if (!Send(new ViewHostMsg_DuplicateSection( | 112 if (!Send(new ViewHostMsg_DuplicateSection( |
| 113 routing_id(), | 113 routing_id(), |
| 114 page_params.metafile_data_handle, | 114 page_params.metafile_data_handle, |
| 115 &page_params.metafile_data_handle))) { | 115 &page_params.metafile_data_handle))) { |
| 116 NOTREACHED() << "Send message failed."; | 116 NOTREACHED() << "Send message failed."; |
| 117 } | 117 } |
| 118 Send(new ViewHostMsg_DidPrintPage(routing_id(), page_params)); | 118 Send(new ViewHostMsg_DidPrintPage(routing_id(), page_params)); |
| 119 } | 119 } |
| 120 | 120 |
| 121 void PrintWebViewHelper::CreatePreviewDocument( | 121 void PrintWebViewHelper::CreatePreviewDocument( |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 preview_params.document_cookie = params.params.document_cookie; | 173 preview_params.document_cookie = params.params.document_cookie; |
| 174 preview_params.data_size = buf_size; | 174 preview_params.data_size = buf_size; |
| 175 preview_params.metafile_data_handle = NULL; | 175 preview_params.metafile_data_handle = NULL; |
| 176 preview_params.expected_pages_count = page_count; | 176 preview_params.expected_pages_count = page_count; |
| 177 | 177 |
| 178 if (!CopyMetafileDataToSharedMem(metafile.get(), | 178 if (!CopyMetafileDataToSharedMem(metafile.get(), |
| 179 &(preview_params.metafile_data_handle))) { | 179 &(preview_params.metafile_data_handle))) { |
| 180 preview_params.data_size = 0; | 180 preview_params.data_size = 0; |
| 181 preview_params.expected_pages_count = 0; | 181 preview_params.expected_pages_count = 0; |
| 182 } | 182 } |
| 183 metafile->CloseEmf(); | 183 metafile->Close(); |
| 184 if (!Send(new ViewHostMsg_DuplicateSection( | 184 if (!Send(new ViewHostMsg_DuplicateSection( |
| 185 routing_id(), | 185 routing_id(), |
| 186 preview_params.metafile_data_handle, | 186 preview_params.metafile_data_handle, |
| 187 &preview_params.metafile_data_handle))) { | 187 &preview_params.metafile_data_handle))) { |
| 188 NOTREACHED() << "Send message failed."; | 188 NOTREACHED() << "Send message failed."; |
| 189 } | 189 } |
| 190 Send(new ViewHostMsg_PagesReadyForPreview(routing_id(), preview_params)); | 190 Send(new ViewHostMsg_PagesReadyForPreview(routing_id(), preview_params)); |
| 191 } | 191 } |
| 192 | 192 |
| 193 void PrintWebViewHelper::RenderPage( | 193 void PrintWebViewHelper::RenderPage( |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 HGDIOBJ old_bitmap = SelectObject(bitmap_dc, hbitmap); | 280 HGDIOBJ old_bitmap = SelectObject(bitmap_dc, hbitmap); |
| 281 RECT rect = {0, 0, width, height }; | 281 RECT rect = {0, 0, width, height }; |
| 282 HBRUSH whiteBrush = static_cast<HBRUSH>(GetStockObject(WHITE_BRUSH)); | 282 HBRUSH whiteBrush = static_cast<HBRUSH>(GetStockObject(WHITE_BRUSH)); |
| 283 FillRect(bitmap_dc, &rect, whiteBrush); | 283 FillRect(bitmap_dc, &rect, whiteBrush); |
| 284 | 284 |
| 285 metafile2->CreateDc(NULL, NULL); | 285 metafile2->CreateDc(NULL, NULL); |
| 286 HDC hdc = metafile2->hdc(); | 286 HDC hdc = metafile2->hdc(); |
| 287 DCHECK(hdc); | 287 DCHECK(hdc); |
| 288 skia::PlatformDevice::InitializeDC(hdc); | 288 skia::PlatformDevice::InitializeDC(hdc); |
| 289 | 289 |
| 290 RECT metafile_bounds = (*metafile)->GetBounds().ToRECT(); | 290 RECT metafile_bounds = (*metafile)->GetPageBounds(1).ToRECT(); |
| 291 // Process the old metafile, placing all non-AlphaBlend calls into the | 291 // Process the old metafile, placing all non-AlphaBlend calls into the |
| 292 // new metafile, and copying the results of all the AlphaBlend calls | 292 // new metafile, and copying the results of all the AlphaBlend calls |
| 293 // from the bitmap DC. | 293 // from the bitmap DC. |
| 294 EnumEnhMetaFile(hdc, | 294 EnumEnhMetaFile(hdc, |
| 295 (*metafile)->emf(), | 295 (*metafile)->emf(), |
| 296 EnhMetaFileProc, | 296 EnhMetaFileProc, |
| 297 &bitmap_dc, | 297 &bitmap_dc, |
| 298 &metafile_bounds); | 298 &metafile_bounds); |
| 299 | 299 |
| 300 SelectObject(bitmap_dc, old_bitmap); | 300 SelectObject(bitmap_dc, old_bitmap); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 325 // Copy the bits into shared memory. | 325 // Copy the bits into shared memory. |
| 326 if (!metafile->GetData(shared_buf.memory(), buf_size)) { | 326 if (!metafile->GetData(shared_buf.memory(), buf_size)) { |
| 327 NOTREACHED() << "GetData() failed"; | 327 NOTREACHED() << "GetData() failed"; |
| 328 shared_buf.Unmap(); | 328 shared_buf.Unmap(); |
| 329 return false; | 329 return false; |
| 330 } | 330 } |
| 331 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), shared_mem_handle); | 331 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), shared_mem_handle); |
| 332 shared_buf.Unmap(); | 332 shared_buf.Unmap(); |
| 333 return true; | 333 return true; |
| 334 } | 334 } |
| OLD | NEW |