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

Side by Side Diff: content/shell/test_runner/pixel_dump.cc

Issue 2928033002: Move GetDocument method from WebFrame to WebLocalFrame. (Closed)
Patch Set: Split a DCHECK in two as suggested by boliu@. Created 3 years, 6 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "content/shell/test_runner/pixel_dump.h" 5 #include "content/shell/test_runner/pixel_dump.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 gfx::Point popup_position_; 68 gfx::Point popup_position_;
69 }; 69 };
70 70
71 void DrawSelectionRect(const PixelsDumpRequest& dump_request, 71 void DrawSelectionRect(const PixelsDumpRequest& dump_request,
72 cc::PaintCanvas* canvas) { 72 cc::PaintCanvas* canvas) {
73 // See if we need to draw the selection bounds rect. Selection bounds 73 // See if we need to draw the selection bounds rect. Selection bounds
74 // rect is the rect enclosing the (possibly transformed) selection. 74 // rect is the rect enclosing the (possibly transformed) selection.
75 // The rect should be drawn after everything is laid out and painted. 75 // The rect should be drawn after everything is laid out and painted.
76 if (!dump_request.layout_test_runtime_flags.dump_selection_rect()) 76 if (!dump_request.layout_test_runtime_flags.dump_selection_rect())
77 return; 77 return;
78 // If there is a selection rect - draw a red 1px border enclosing rect 78
79 // TODO(lukasza): https://crbug.com/667551: Support OOPIFs in pixel dumps.
79 CHECK(dump_request.web_view->MainFrame()->IsWebLocalFrame()) 80 CHECK(dump_request.web_view->MainFrame()->IsWebLocalFrame())
80 << "This function cannot be called if the main frame is not a " 81 << "This function cannot be called if the main frame is not a "
81 "local frame."; 82 "local frame.";
83
84 // If there is a selection rect - draw a red 1px border enclosing rect
82 blink::WebRect wr = dump_request.web_view->MainFrame() 85 blink::WebRect wr = dump_request.web_view->MainFrame()
83 ->ToWebLocalFrame() 86 ->ToWebLocalFrame()
84 ->GetSelectionBoundsRectForTesting(); 87 ->GetSelectionBoundsRectForTesting();
85 if (wr.IsEmpty()) 88 if (wr.IsEmpty())
86 return; 89 return;
87 // Render a red rectangle bounding selection rect 90 // Render a red rectangle bounding selection rect
88 cc::PaintFlags flags; 91 cc::PaintFlags flags;
89 flags.setColor(0xFFFF0000); // Fully opaque red 92 flags.setColor(0xFFFF0000); // Fully opaque red
90 flags.setStyle(cc::PaintFlags::kStroke_Style); 93 flags.setStyle(cc::PaintFlags::kStroke_Style);
91 flags.setAntiAlias(true); 94 flags.setAntiAlias(true);
92 flags.setStrokeWidth(1.0f); 95 flags.setStrokeWidth(1.0f);
93 SkIRect rect; // Bounding rect 96 SkIRect rect; // Bounding rect
94 rect.set(wr.x, wr.y, wr.x + wr.width, wr.y + wr.height); 97 rect.set(wr.x, wr.y, wr.x + wr.width, wr.y + wr.height);
95 canvas->drawIRect(rect, flags); 98 canvas->drawIRect(rect, flags);
96 } 99 }
97 100
98 void CapturePixelsForPrinting(std::unique_ptr<PixelsDumpRequest> dump_request) { 101 void CapturePixelsForPrinting(std::unique_ptr<PixelsDumpRequest> dump_request) {
99 dump_request->web_view->UpdateAllLifecyclePhases(); 102 dump_request->web_view->UpdateAllLifecyclePhases();
100 103
101 blink::WebSize page_size_in_pixels = dump_request->web_view->Size(); 104 blink::WebSize page_size_in_pixels = dump_request->web_view->Size();
102 105
106 // TODO(lukasza): https://crbug.com/667551: Support OOPIFs in pixel dumps.
103 CHECK(dump_request->web_view->MainFrame()->IsWebLocalFrame()) 107 CHECK(dump_request->web_view->MainFrame()->IsWebLocalFrame())
104 << "This function cannot be called if the main frame is not a " 108 << "This function cannot be called if the main frame is not a "
105 "local frame."; 109 "local frame.";
106 blink::WebLocalFrame* web_frame = 110 blink::WebLocalFrame* web_frame =
107 dump_request->web_view->MainFrame()->ToWebLocalFrame(); 111 dump_request->web_view->MainFrame()->ToWebLocalFrame();
108 112
109 int page_count = web_frame->PrintBegin(page_size_in_pixels); 113 int page_count = web_frame->PrintBegin(page_size_in_pixels);
110 int totalHeight = page_count * (page_size_in_pixels.height + 1) - 1; 114 int totalHeight = page_count * (page_size_in_pixels.height + 1) - 1;
111 115
112 bool is_opaque = false; 116 bool is_opaque = false;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 return; 220 return;
217 } 221 }
218 222
219 blink::WebImage image = static_cast<blink::WebMockClipboard*>( 223 blink::WebImage image = static_cast<blink::WebMockClipboard*>(
220 blink::Platform::Current()->Clipboard()) 224 blink::Platform::Current()->Clipboard())
221 ->ReadRawImage(blink::WebClipboard::Buffer()); 225 ->ReadRawImage(blink::WebClipboard::Buffer());
222 callback.Run(image.GetSkBitmap()); 226 callback.Run(image.GetSkBitmap());
223 } 227 }
224 228
225 } // namespace test_runner 229 } // namespace test_runner
OLDNEW
« no previous file with comments | « content/shell/test_runner/accessibility_controller.cc ('k') | content/shell/test_runner/test_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698