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 "components/printing/renderer/print_web_view_helper.h" | 5 #include "components/printing/renderer/print_web_view_helper.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
752 web_print_params_.print_content_area.height); | 752 web_print_params_.print_content_area.height); |
753 print_layout_size.set_height( | 753 print_layout_size.set_height( |
754 ScaleAndRound(print_layout_size.height(), kPrintingMinimumShrinkFactor)); | 754 ScaleAndRound(print_layout_size.height(), kPrintingMinimumShrinkFactor)); |
755 | 755 |
756 if (!frame()) | 756 if (!frame()) |
757 return; | 757 return; |
758 | 758 |
759 // Backup size and offset if it's a local frame. | 759 // Backup size and offset if it's a local frame. |
760 blink::WebView* web_view = frame_.view(); | 760 blink::WebView* web_view = frame_.view(); |
761 if (blink::WebFrame* web_frame = web_view->MainFrame()) { | 761 if (blink::WebFrame* web_frame = web_view->MainFrame()) { |
762 if (web_frame->IsWebLocalFrame()) | 762 if (web_frame->IsWebLocalFrame()) |
dcheng
2017/06/16 23:52:20
I wonder about this code. Isn't it always the case
Łukasz Anforowicz
2017/06/19 23:58:08
Agreed that |frame_| is always a local frame. I t
| |
763 prev_scroll_offset_ = web_frame->GetScrollOffset(); | 763 prev_scroll_offset_ = web_frame->ToWebLocalFrame()->GetScrollOffset(); |
764 } | 764 } |
765 prev_view_size_ = web_view->Size(); | 765 prev_view_size_ = web_view->Size(); |
766 | 766 |
767 web_view->Resize(print_layout_size); | 767 web_view->Resize(print_layout_size); |
768 } | 768 } |
769 | 769 |
770 void PrepareFrameAndViewForPrint::StartPrinting() { | 770 void PrepareFrameAndViewForPrint::StartPrinting() { |
771 blink::WebView* web_view = frame_.view(); | 771 blink::WebView* web_view = frame_.view(); |
772 web_view->GetSettings()->SetShouldPrintBackgrounds(should_print_backgrounds_); | 772 web_view->GetSettings()->SetShouldPrintBackgrounds(should_print_backgrounds_); |
773 expected_pages_count_ = | 773 expected_pages_count_ = |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
855 } | 855 } |
856 | 856 |
857 void PrepareFrameAndViewForPrint::RestoreSize() { | 857 void PrepareFrameAndViewForPrint::RestoreSize() { |
858 if (!frame()) | 858 if (!frame()) |
859 return; | 859 return; |
860 | 860 |
861 blink::WebView* web_view = frame_.GetFrame()->View(); | 861 blink::WebView* web_view = frame_.GetFrame()->View(); |
862 web_view->Resize(prev_view_size_); | 862 web_view->Resize(prev_view_size_); |
863 if (blink::WebFrame* web_frame = web_view->MainFrame()) { | 863 if (blink::WebFrame* web_frame = web_view->MainFrame()) { |
864 if (web_frame->IsWebLocalFrame()) | 864 if (web_frame->IsWebLocalFrame()) |
865 web_frame->SetScrollOffset(prev_scroll_offset_); | 865 web_frame->ToWebLocalFrame()->SetScrollOffset(prev_scroll_offset_); |
dcheng
2017/06/16 23:52:20
Ditto: maybe I am misunderstanding this code?
| |
866 } | 866 } |
867 } | 867 } |
868 | 868 |
869 void PrepareFrameAndViewForPrint::FinishPrinting() { | 869 void PrepareFrameAndViewForPrint::FinishPrinting() { |
870 blink::WebLocalFrame* frame = frame_.GetFrame(); | 870 blink::WebLocalFrame* frame = frame_.GetFrame(); |
871 if (frame) { | 871 if (frame) { |
872 blink::WebView* web_view = frame->View(); | 872 blink::WebView* web_view = frame->View(); |
873 if (is_printing_started_) { | 873 if (is_printing_started_) { |
874 is_printing_started_ = false; | 874 is_printing_started_ = false; |
875 if (!owns_web_view_) { | 875 if (!owns_web_view_) { |
(...skipping 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2379 blink::WebConsoleMessage::kLevelWarning, message)); | 2379 blink::WebConsoleMessage::kLevelWarning, message)); |
2380 return false; | 2380 return false; |
2381 } | 2381 } |
2382 | 2382 |
2383 void PrintWebViewHelper::ScriptingThrottler::Reset() { | 2383 void PrintWebViewHelper::ScriptingThrottler::Reset() { |
2384 // Reset counter on successful print. | 2384 // Reset counter on successful print. |
2385 count_ = 0; | 2385 count_ = 0; |
2386 } | 2386 } |
2387 | 2387 |
2388 } // namespace printing | 2388 } // namespace printing |
OLD | NEW |