OLD | NEW |
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" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 return result; | 51 return result; |
52 } | 52 } |
53 | 53 |
54 } // namespace | 54 } // namespace |
55 | 55 |
56 std::string DumpLayout(WebLocalFrame* frame, const LayoutDumpFlags& flags) { | 56 std::string DumpLayout(WebLocalFrame* frame, const LayoutDumpFlags& flags) { |
57 DCHECK(frame); | 57 DCHECK(frame); |
58 std::string result; | 58 std::string result; |
59 | 59 |
60 switch (flags.main_dump_mode) { | 60 if (flags.dump_as_text) { |
61 case LayoutDumpMode::DUMP_AS_TEXT: | 61 result = DumpFrameHeaderIfNeeded(frame); |
62 result = DumpFrameHeaderIfNeeded(frame); | 62 if (flags.is_printing && frame->document().isHTMLDocument()) { |
63 if (flags.dump_as_printed && frame->document().isHTMLDocument()) { | 63 result += WebFrameContentDumper::dumpLayoutTreeAsText( |
64 result += WebFrameContentDumper::dumpLayoutTreeAsText( | 64 frame, WebFrameContentDumper::LayoutAsTextPrinting) |
65 frame, WebFrameContentDumper::LayoutAsTextPrinting) | 65 .utf8(); |
66 .utf8(); | 66 } else { |
67 } else { | 67 result += frame->document().contentAsTextForTesting().utf8(); |
68 result += frame->document().contentAsTextForTesting().utf8(); | 68 } |
69 } | 69 result += "\n"; |
70 result += "\n"; | 70 } else if (flags.dump_as_markup) { |
71 break; | 71 DCHECK(!flags.is_printing); |
72 case LayoutDumpMode::DUMP_AS_MARKUP: | 72 result = DumpFrameHeaderIfNeeded(frame); |
73 DCHECK(!flags.dump_as_printed); | 73 result += WebFrameContentDumper::dumpAsMarkup(frame).utf8(); |
74 result = DumpFrameHeaderIfNeeded(frame); | 74 result += "\n"; |
75 result += WebFrameContentDumper::dumpAsMarkup(frame).utf8(); | 75 } else { |
76 result += "\n"; | 76 if (frame->parent() == nullptr) { |
77 break; | 77 WebFrameContentDumper::LayoutAsTextControls layout_text_behavior = |
78 case LayoutDumpMode::DUMP_SCROLL_POSITIONS: | 78 WebFrameContentDumper::LayoutAsTextNormal; |
79 if (frame->parent() == nullptr) { | 79 if (flags.is_printing) |
80 WebFrameContentDumper::LayoutAsTextControls layout_text_behavior = | 80 layout_text_behavior |= WebFrameContentDumper::LayoutAsTextPrinting; |
81 WebFrameContentDumper::LayoutAsTextNormal; | 81 if (flags.debug_render_tree) |
82 if (flags.dump_as_printed) | 82 layout_text_behavior |= WebFrameContentDumper::LayoutAsTextDebug; |
83 layout_text_behavior |= WebFrameContentDumper::LayoutAsTextPrinting; | 83 if (flags.dump_line_box_trees) |
84 if (flags.debug_render_tree) | 84 layout_text_behavior |= |
85 layout_text_behavior |= WebFrameContentDumper::LayoutAsTextDebug; | 85 WebFrameContentDumper::LayoutAsTextWithLineTrees; |
86 if (flags.dump_line_box_trees) | 86 result = WebFrameContentDumper::dumpLayoutTreeAsText(frame, |
87 layout_text_behavior |= | 87 layout_text_behavior) |
88 WebFrameContentDumper::LayoutAsTextWithLineTrees; | 88 .utf8(); |
89 result = WebFrameContentDumper::dumpLayoutTreeAsText( | 89 } |
90 frame, layout_text_behavior) | 90 result += DumpFrameScrollPosition(frame); |
91 .utf8(); | |
92 } | |
93 result += DumpFrameScrollPosition(frame); | |
94 break; | |
95 default: | |
96 DCHECK(false) << static_cast<int>(flags.main_dump_mode); | |
97 result = ""; | |
98 break; | |
99 } | 91 } |
100 | 92 |
101 return result; | 93 return result; |
102 } | 94 } |
103 | 95 |
104 } // namespace test_runner | 96 } // namespace test_runner |
OLD | NEW |