| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 // made virtual so that they can be overridden by ChromePluginPrintContext. | 273 // made virtual so that they can be overridden by ChromePluginPrintContext. |
| 274 class ChromePrintContext : public PrintContext { | 274 class ChromePrintContext : public PrintContext { |
| 275 WTF_MAKE_NONCOPYABLE(ChromePrintContext); | 275 WTF_MAKE_NONCOPYABLE(ChromePrintContext); |
| 276 | 276 |
| 277 public: | 277 public: |
| 278 ChromePrintContext(LocalFrame* frame) | 278 ChromePrintContext(LocalFrame* frame) |
| 279 : PrintContext(frame), printed_page_width_(0) {} | 279 : PrintContext(frame), printed_page_width_(0) {} |
| 280 | 280 |
| 281 ~ChromePrintContext() override {} | 281 ~ChromePrintContext() override {} |
| 282 | 282 |
| 283 virtual void begin(float width, float height) { | 283 virtual void BeginPrintMode(float width, float height) { |
| 284 DCHECK(!printed_page_width_); | 284 DCHECK(!printed_page_width_); |
| 285 printed_page_width_ = width; | 285 printed_page_width_ = width; |
| 286 printed_page_height_ = height; | 286 printed_page_height_ = height; |
| 287 PrintContext::begin(printed_page_width_, height); | 287 PrintContext::BeginPrintMode(printed_page_width_, height); |
| 288 } | 288 } |
| 289 | 289 |
| 290 virtual float GetPageShrink(int page_number) const { | 290 virtual float GetPageShrink(int page_number) const { |
| 291 IntRect page_rect = page_rects_[page_number]; | 291 IntRect page_rect = page_rects_[page_number]; |
| 292 return printed_page_width_ / page_rect.Width(); | 292 return printed_page_width_ / page_rect.Width(); |
| 293 } | 293 } |
| 294 | 294 |
| 295 float SpoolSinglePage(WebCanvas* canvas, int page_number) { | 295 float SpoolSinglePage(WebCanvas* canvas, int page_number) { |
| 296 DispatchEventsForPrintingOnAllFrames(); | 296 DispatchEventsForPrintingOnAllFrames(); |
| 297 if (!GetFrame()->GetDocument() || | 297 if (!GetFrame()->GetDocument() || |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 plugin_(plugin), | 448 plugin_(plugin), |
| 449 print_params_(print_params) {} | 449 print_params_(print_params) {} |
| 450 | 450 |
| 451 ~ChromePluginPrintContext() override {} | 451 ~ChromePluginPrintContext() override {} |
| 452 | 452 |
| 453 DEFINE_INLINE_VIRTUAL_TRACE() { | 453 DEFINE_INLINE_VIRTUAL_TRACE() { |
| 454 visitor->Trace(plugin_); | 454 visitor->Trace(plugin_); |
| 455 ChromePrintContext::Trace(visitor); | 455 ChromePrintContext::Trace(visitor); |
| 456 } | 456 } |
| 457 | 457 |
| 458 void begin(float width, float height) override {} | 458 void BeginPrintMode(float width, float height) override {} |
| 459 | 459 |
| 460 void end() override { plugin_->PrintEnd(); } | 460 void EndPrintMode() override { plugin_->PrintEnd(); } |
| 461 | 461 |
| 462 float GetPageShrink(int page_number) const override { | 462 float GetPageShrink(int page_number) const override { |
| 463 // We don't shrink the page (maybe we should ask the widget ??) | 463 // We don't shrink the page (maybe we should ask the widget ??) |
| 464 return 1.0; | 464 return 1.0; |
| 465 } | 465 } |
| 466 | 466 |
| 467 void ComputePageRects(const FloatRect& print_rect, | 467 void ComputePageRects(const FloatRect& print_rect, |
| 468 float header_height, | 468 float header_height, |
| 469 float footer_height, | 469 float footer_height, |
| 470 float user_scale_factor, | 470 float user_scale_factor, |
| (...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1394 | 1394 |
| 1395 if (plugin_container && plugin_container->SupportsPaginatedPrint()) | 1395 if (plugin_container && plugin_container->SupportsPaginatedPrint()) |
| 1396 print_context_ = new ChromePluginPrintContext(GetFrame(), plugin_container, | 1396 print_context_ = new ChromePluginPrintContext(GetFrame(), plugin_container, |
| 1397 print_params); | 1397 print_params); |
| 1398 else | 1398 else |
| 1399 print_context_ = new ChromePrintContext(GetFrame()); | 1399 print_context_ = new ChromePrintContext(GetFrame()); |
| 1400 | 1400 |
| 1401 FloatRect rect(0, 0, | 1401 FloatRect rect(0, 0, |
| 1402 static_cast<float>(print_params.print_content_area.width), | 1402 static_cast<float>(print_params.print_content_area.width), |
| 1403 static_cast<float>(print_params.print_content_area.height)); | 1403 static_cast<float>(print_params.print_content_area.height)); |
| 1404 print_context_->begin(rect.Width(), rect.Height()); | 1404 print_context_->BeginPrintMode(rect.Width(), rect.Height()); |
| 1405 float page_height; | 1405 float page_height; |
| 1406 // We ignore the overlays calculation for now since they are generated in the | 1406 // We ignore the overlays calculation for now since they are generated in the |
| 1407 // browser. pageHeight is actually an output parameter. | 1407 // browser. pageHeight is actually an output parameter. |
| 1408 print_context_->ComputePageRects(rect, 0, 0, 1.0, page_height); | 1408 print_context_->ComputePageRects(rect, 0, 0, 1.0, page_height); |
| 1409 | 1409 |
| 1410 return static_cast<int>(print_context_->PageCount()); | 1410 return static_cast<int>(print_context_->PageCount()); |
| 1411 } | 1411 } |
| 1412 | 1412 |
| 1413 float WebLocalFrameImpl::GetPrintPageShrink(int page) { | 1413 float WebLocalFrameImpl::GetPrintPageShrink(int page) { |
| 1414 DCHECK(print_context_); | 1414 DCHECK(print_context_); |
| 1415 DCHECK_GE(page, 0); | 1415 DCHECK_GE(page, 0); |
| 1416 return print_context_->GetPageShrink(page); | 1416 return print_context_->GetPageShrink(page); |
| 1417 } | 1417 } |
| 1418 | 1418 |
| 1419 float WebLocalFrameImpl::PrintPage(int page, WebCanvas* canvas) { | 1419 float WebLocalFrameImpl::PrintPage(int page, WebCanvas* canvas) { |
| 1420 DCHECK(print_context_); | 1420 DCHECK(print_context_); |
| 1421 DCHECK_GE(page, 0); | 1421 DCHECK_GE(page, 0); |
| 1422 DCHECK(GetFrame()); | 1422 DCHECK(GetFrame()); |
| 1423 DCHECK(GetFrame()->GetDocument()); | 1423 DCHECK(GetFrame()->GetDocument()); |
| 1424 | 1424 |
| 1425 return print_context_->SpoolSinglePage(canvas, page); | 1425 return print_context_->SpoolSinglePage(canvas, page); |
| 1426 } | 1426 } |
| 1427 | 1427 |
| 1428 void WebLocalFrameImpl::PrintEnd() { | 1428 void WebLocalFrameImpl::PrintEnd() { |
| 1429 DCHECK(print_context_); | 1429 DCHECK(print_context_); |
| 1430 print_context_->end(); | 1430 print_context_->EndPrintMode(); |
| 1431 print_context_.Clear(); | 1431 print_context_.Clear(); |
| 1432 } | 1432 } |
| 1433 | 1433 |
| 1434 bool WebLocalFrameImpl::IsPrintScalingDisabledForPlugin(const WebNode& node) { | 1434 bool WebLocalFrameImpl::IsPrintScalingDisabledForPlugin(const WebNode& node) { |
| 1435 WebPluginContainerImpl* plugin_container = | 1435 WebPluginContainerImpl* plugin_container = |
| 1436 node.IsNull() ? PluginContainerFromFrame(GetFrame()) | 1436 node.IsNull() ? PluginContainerFromFrame(GetFrame()) |
| 1437 : ToWebPluginContainerImpl(node.PluginContainer()); | 1437 : ToWebPluginContainerImpl(node.PluginContainer()); |
| 1438 | 1438 |
| 1439 if (!plugin_container || !plugin_container->SupportsPaginatedPrint()) | 1439 if (!plugin_container || !plugin_container->SupportsPaginatedPrint()) |
| 1440 return false; | 1440 return false; |
| (...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2575 TextCheckerClient& WebLocalFrameImpl::GetTextCheckerClient() const { | 2575 TextCheckerClient& WebLocalFrameImpl::GetTextCheckerClient() const { |
| 2576 return *text_checker_client_; | 2576 return *text_checker_client_; |
| 2577 } | 2577 } |
| 2578 | 2578 |
| 2579 void WebLocalFrameImpl::SetTextCheckClient( | 2579 void WebLocalFrameImpl::SetTextCheckClient( |
| 2580 WebTextCheckClient* text_check_client) { | 2580 WebTextCheckClient* text_check_client) { |
| 2581 text_check_client_ = text_check_client; | 2581 text_check_client_ = text_check_client; |
| 2582 } | 2582 } |
| 2583 | 2583 |
| 2584 } // namespace blink | 2584 } // namespace blink |
| OLD | NEW |