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

Side by Side Diff: components/test_runner/layout_dump.cc

Issue 1672073003: Shunt string-dumping functions from WebFrame to a side class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added/updated TODOs. Created 4 years, 10 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 "components/test_runner/layout_dump.h" 5 #include "components/test_runner/layout_dump.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "third_party/WebKit/public/platform/WebSize.h" 9 #include "third_party/WebKit/public/platform/WebSize.h"
10 #include "third_party/WebKit/public/platform/WebString.h" 10 #include "third_party/WebKit/public/platform/WebString.h"
11 #include "third_party/WebKit/public/web/WebDocument.h" 11 #include "third_party/WebKit/public/web/WebDocument.h"
12 #include "third_party/WebKit/public/web/WebElement.h" 12 #include "third_party/WebKit/public/web/WebElement.h"
13 #include "third_party/WebKit/public/web/WebFrame.h" 13 #include "third_party/WebKit/public/web/WebFrame.h"
14 #include "third_party/WebKit/public/web/WebFrameContentDumper.h"
14 #include "third_party/WebKit/public/web/WebLocalFrame.h" 15 #include "third_party/WebKit/public/web/WebLocalFrame.h"
15 16
16 namespace test_runner { 17 namespace test_runner {
17 18
18 using blink::WebFrame; 19 using blink::WebFrame;
20 using blink::WebFrameContentDumper;
19 using blink::WebLocalFrame; 21 using blink::WebLocalFrame;
20 using blink::WebSize; 22 using blink::WebSize;
21 23
22 namespace { 24 namespace {
23 25
24 std::string DumpFrameHeaderIfNeeded(WebFrame* frame) { 26 std::string DumpFrameHeaderIfNeeded(WebFrame* frame) {
25 std::string result; 27 std::string result;
26 28
27 // Add header for all but the main frame. Skip empty frames. 29 // Add header for all but the main frame. Skip empty frames.
28 if (frame->parent() && !frame->document().documentElement().isNull()) { 30 if (frame->parent() && !frame->document().documentElement().isNull()) {
(...skipping 23 matching lines...) Expand all
52 } // namespace 54 } // namespace
53 55
54 std::string DumpLayout(WebLocalFrame* frame, const LayoutDumpFlags& flags) { 56 std::string DumpLayout(WebLocalFrame* frame, const LayoutDumpFlags& flags) {
55 DCHECK(frame); 57 DCHECK(frame);
56 std::string result; 58 std::string result;
57 59
58 switch (flags.main_dump_mode) { 60 switch (flags.main_dump_mode) {
59 case LayoutDumpMode::DUMP_AS_TEXT: 61 case LayoutDumpMode::DUMP_AS_TEXT:
60 result = DumpFrameHeaderIfNeeded(frame); 62 result = DumpFrameHeaderIfNeeded(frame);
61 if (flags.dump_as_printed && frame->document().isHTMLDocument()) { 63 if (flags.dump_as_printed && frame->document().isHTMLDocument()) {
62 result += 64 result += WebFrameContentDumper::dumpLayoutTreeAsText(
63 frame->layoutTreeAsText(WebFrame::LayoutAsTextPrinting).utf8(); 65 frame, WebFrameContentDumper::LayoutAsTextPrinting)
66 .utf8();
64 } else { 67 } else {
65 result += frame->document().contentAsTextForTesting().utf8(); 68 result += frame->document().contentAsTextForTesting().utf8();
66 } 69 }
67 result += "\n"; 70 result += "\n";
68 break; 71 break;
69 case LayoutDumpMode::DUMP_AS_MARKUP: 72 case LayoutDumpMode::DUMP_AS_MARKUP:
70 DCHECK(!flags.dump_as_printed); 73 DCHECK(!flags.dump_as_printed);
71 result = DumpFrameHeaderIfNeeded(frame); 74 result = DumpFrameHeaderIfNeeded(frame);
72 result += frame->contentAsMarkup().utf8(); 75 result += WebFrameContentDumper::dumpAsMarkup(frame).utf8();
73 result += "\n"; 76 result += "\n";
74 break; 77 break;
75 case LayoutDumpMode::DUMP_SCROLL_POSITIONS: 78 case LayoutDumpMode::DUMP_SCROLL_POSITIONS:
76 if (frame->parent() == nullptr) { 79 if (frame->parent() == nullptr) {
77 WebFrame::LayoutAsTextControls layout_text_behavior = 80 WebFrameContentDumper::LayoutAsTextControls layout_text_behavior =
78 WebFrame::LayoutAsTextNormal; 81 WebFrameContentDumper::LayoutAsTextNormal;
79 if (flags.dump_as_printed) 82 if (flags.dump_as_printed)
80 layout_text_behavior |= WebFrame::LayoutAsTextPrinting; 83 layout_text_behavior |= WebFrameContentDumper::LayoutAsTextPrinting;
81 if (flags.debug_render_tree) 84 if (flags.debug_render_tree)
82 layout_text_behavior |= WebFrame::LayoutAsTextDebug; 85 layout_text_behavior |= WebFrameContentDumper::LayoutAsTextDebug;
83 if (flags.dump_line_box_trees) 86 if (flags.dump_line_box_trees)
84 layout_text_behavior |= WebFrame::LayoutAsTextWithLineTrees; 87 layout_text_behavior |=
85 result = frame->layoutTreeAsText(layout_text_behavior).utf8(); 88 WebFrameContentDumper::LayoutAsTextWithLineTrees;
89 result = WebFrameContentDumper::dumpLayoutTreeAsText(
90 frame, layout_text_behavior)
91 .utf8();
86 } 92 }
87 result += DumpFrameScrollPosition(frame); 93 result += DumpFrameScrollPosition(frame);
88 break; 94 break;
89 default: 95 default:
90 DCHECK(false) << static_cast<int>(flags.main_dump_mode); 96 DCHECK(false) << static_cast<int>(flags.main_dump_mode);
91 result = ""; 97 result = "";
92 break; 98 break;
93 } 99 }
94 100
95 return result; 101 return result;
96 } 102 }
97 103
98 } // namespace test_runner 104 } // namespace test_runner
OLDNEW
« no previous file with comments | « chrome/renderer/chrome_render_frame_observer.cc ('k') | content/renderer/render_view_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698