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 "public/web/WebFrameContentDumper.h" | 5 #include "public/web/WebFrameContentDumper.h" |
6 | 6 |
7 #include "core/editing/EphemeralRange.h" | 7 #include "core/editing/EphemeralRange.h" |
8 #include "core/editing/iterators/TextIterator.h" | 8 #include "core/editing/iterators/TextIterator.h" |
9 #include "core/editing/serializers/Serialization.h" | 9 #include "core/editing/serializers/Serialization.h" |
10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
11 #include "core/layout/LayoutPart.h" | 11 #include "core/layout/LayoutPart.h" |
12 #include "core/layout/LayoutTreeAsText.h" | 12 #include "core/layout/LayoutTreeAsText.h" |
13 #include "core/layout/LayoutView.h" | 13 #include "core/layout/LayoutView.h" |
14 #include "public/web/WebDocument.h" | 14 #include "public/web/WebDocument.h" |
15 #include "public/web/WebLocalFrame.h" | 15 #include "public/web/WebLocalFrame.h" |
| 16 #include "public/web/WebView.h" |
16 #include "web/WebLocalFrameImpl.h" | 17 #include "web/WebLocalFrameImpl.h" |
17 #include "wtf/text/WTFString.h" | 18 #include "wtf/text/WTFString.h" |
18 | 19 |
19 namespace blink { | 20 namespace blink { |
20 | 21 |
21 static void frameContentAsPlainText(size_t maxChars, LocalFrame* frame, StringBu
ilder& output) | 22 static void frameContentAsPlainText(size_t maxChars, LocalFrame* frame, StringBu
ilder& output) |
22 { | 23 { |
23 Document* document = frame->document(); | 24 Document* document = frame->document(); |
24 if (!document) | 25 if (!document) |
25 return; | 26 return; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 if (output.length() >= maxChars - frameSeparatorLength) | 70 if (output.length() >= maxChars - frameSeparatorLength) |
70 return; | 71 return; |
71 | 72 |
72 output.append(frameSeparator, frameSeparatorLength); | 73 output.append(frameSeparator, frameSeparatorLength); |
73 frameContentAsPlainText(maxChars, curLocalChild, output); | 74 frameContentAsPlainText(maxChars, curLocalChild, output); |
74 if (output.length() >= maxChars) | 75 if (output.length() >= maxChars) |
75 return; // Filled up the buffer. | 76 return; // Filled up the buffer. |
76 } | 77 } |
77 } | 78 } |
78 | 79 |
79 WebString WebFrameContentDumper::dumpFrameTreeAsText(WebLocalFrame* frame, size_
t maxChars) | 80 WebString WebFrameContentDumper::deprecatedDumpFrameTreeAsText(WebLocalFrame* fr
ame, size_t maxChars) |
80 { | 81 { |
81 if (!frame) | 82 if (!frame) |
82 return WebString(); | 83 return WebString(); |
83 StringBuilder text; | 84 StringBuilder text; |
84 frameContentAsPlainText(maxChars, toWebLocalFrameImpl(frame)->frame(), text)
; | 85 frameContentAsPlainText(maxChars, toWebLocalFrameImpl(frame)->frame(), text)
; |
85 return text.toString(); | 86 return text.toString(); |
86 } | 87 } |
87 | 88 |
| 89 WebString WebFrameContentDumper::dumpWebViewAsText(WebView* webView, size_t maxC
hars) |
| 90 { |
| 91 ASSERT(webView); |
| 92 webView->updateAllLifecyclePhases(); |
| 93 return WebFrameContentDumper::deprecatedDumpFrameTreeAsText(webView->mainFra
me()->toWebLocalFrame(), maxChars); |
| 94 } |
| 95 |
88 WebString WebFrameContentDumper::dumpAsMarkup(WebLocalFrame* frame) | 96 WebString WebFrameContentDumper::dumpAsMarkup(WebLocalFrame* frame) |
89 { | 97 { |
90 if (!frame) | 98 if (!frame) |
91 return WebString(); | 99 return WebString(); |
92 return createMarkup(toWebLocalFrameImpl(frame)->frame()->document()); | 100 return createMarkup(toWebLocalFrameImpl(frame)->frame()->document()); |
93 } | 101 } |
94 | 102 |
95 WebString WebFrameContentDumper::dumpLayoutTreeAsText(WebLocalFrame* frame, Layo
utAsTextControls toShow) | 103 WebString WebFrameContentDumper::dumpLayoutTreeAsText(WebLocalFrame* frame, Layo
utAsTextControls toShow) |
96 { | 104 { |
97 if (!frame) | 105 if (!frame) |
98 return WebString(); | 106 return WebString(); |
99 LayoutAsTextBehavior behavior = LayoutAsTextShowAllLayers; | 107 LayoutAsTextBehavior behavior = LayoutAsTextShowAllLayers; |
100 | 108 |
101 if (toShow & LayoutAsTextWithLineTrees) | 109 if (toShow & LayoutAsTextWithLineTrees) |
102 behavior |= LayoutAsTextShowLineTrees; | 110 behavior |= LayoutAsTextShowLineTrees; |
103 | 111 |
104 if (toShow & LayoutAsTextDebug) | 112 if (toShow & LayoutAsTextDebug) |
105 behavior |= LayoutAsTextShowCompositedLayers | LayoutAsTextShowAddresses
| LayoutAsTextShowIDAndClass | LayoutAsTextShowLayerNesting; | 113 behavior |= LayoutAsTextShowCompositedLayers | LayoutAsTextShowAddresses
| LayoutAsTextShowIDAndClass | LayoutAsTextShowLayerNesting; |
106 | 114 |
107 if (toShow & LayoutAsTextPrinting) | 115 if (toShow & LayoutAsTextPrinting) |
108 behavior |= LayoutAsTextPrintingMode; | 116 behavior |= LayoutAsTextPrintingMode; |
109 | 117 |
110 return externalRepresentation(toWebLocalFrameImpl(frame)->frame(), behavior)
; | 118 return externalRepresentation(toWebLocalFrameImpl(frame)->frame(), behavior)
; |
111 } | 119 } |
112 } | 120 } |
OLD | NEW |