| 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/FrameView.h" | 10 #include "core/frame/FrameView.h" |
| 11 #include "core/frame/LocalFrame.h" | 11 #include "core/frame/LocalFrame.h" |
| 12 #include "core/frame/WebLocalFrameBase.h" |
| 12 #include "core/layout/LayoutTreeAsText.h" | 13 #include "core/layout/LayoutTreeAsText.h" |
| 13 #include "core/layout/api/LayoutPartItem.h" | 14 #include "core/layout/api/LayoutPartItem.h" |
| 14 #include "core/layout/api/LayoutViewItem.h" | 15 #include "core/layout/api/LayoutViewItem.h" |
| 15 #include "platform/wtf/text/WTFString.h" | 16 #include "platform/wtf/text/WTFString.h" |
| 16 #include "public/web/WebDocument.h" | 17 #include "public/web/WebDocument.h" |
| 17 #include "public/web/WebLocalFrame.h" | 18 #include "public/web/WebLocalFrame.h" |
| 18 #include "public/web/WebView.h" | 19 #include "public/web/WebView.h" |
| 19 #include "web/WebLocalFrameImpl.h" | |
| 20 | 20 |
| 21 namespace blink { | 21 namespace blink { |
| 22 | 22 |
| 23 static void FrameContentAsPlainText(size_t max_chars, | 23 static void FrameContentAsPlainText(size_t max_chars, |
| 24 LocalFrame* frame, | 24 LocalFrame* frame, |
| 25 StringBuilder& output) { | 25 StringBuilder& output) { |
| 26 Document* document = frame->GetDocument(); | 26 Document* document = frame->GetDocument(); |
| 27 if (!document) | 27 if (!document) |
| 28 return; | 28 return; |
| 29 | 29 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 return; // Filled up the buffer. | 92 return; // Filled up the buffer. |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 | 95 |
| 96 WebString WebFrameContentDumper::DeprecatedDumpFrameTreeAsText( | 96 WebString WebFrameContentDumper::DeprecatedDumpFrameTreeAsText( |
| 97 WebLocalFrame* frame, | 97 WebLocalFrame* frame, |
| 98 size_t max_chars) { | 98 size_t max_chars) { |
| 99 if (!frame) | 99 if (!frame) |
| 100 return WebString(); | 100 return WebString(); |
| 101 StringBuilder text; | 101 StringBuilder text; |
| 102 FrameContentAsPlainText(max_chars, ToWebLocalFrameImpl(frame)->GetFrame(), | 102 FrameContentAsPlainText(max_chars, ToWebLocalFrameBase(frame)->GetFrame(), |
| 103 text); | 103 text); |
| 104 return text.ToString(); | 104 return text.ToString(); |
| 105 } | 105 } |
| 106 | 106 |
| 107 WebString WebFrameContentDumper::DumpWebViewAsText(WebView* web_view, | 107 WebString WebFrameContentDumper::DumpWebViewAsText(WebView* web_view, |
| 108 size_t max_chars) { | 108 size_t max_chars) { |
| 109 DCHECK(web_view); | 109 DCHECK(web_view); |
| 110 web_view->UpdateAllLifecyclePhases(); | 110 web_view->UpdateAllLifecyclePhases(); |
| 111 return WebFrameContentDumper::DeprecatedDumpFrameTreeAsText( | 111 return WebFrameContentDumper::DeprecatedDumpFrameTreeAsText( |
| 112 web_view->MainFrame()->ToWebLocalFrame(), max_chars); | 112 web_view->MainFrame()->ToWebLocalFrame(), max_chars); |
| 113 } | 113 } |
| 114 | 114 |
| 115 WebString WebFrameContentDumper::DumpAsMarkup(WebLocalFrame* frame) { | 115 WebString WebFrameContentDumper::DumpAsMarkup(WebLocalFrame* frame) { |
| 116 if (!frame) | 116 if (!frame) |
| 117 return WebString(); | 117 return WebString(); |
| 118 return CreateMarkup(ToWebLocalFrameImpl(frame)->GetFrame()->GetDocument()); | 118 return CreateMarkup(ToWebLocalFrameBase(frame)->GetFrame()->GetDocument()); |
| 119 } | 119 } |
| 120 | 120 |
| 121 WebString WebFrameContentDumper::DumpLayoutTreeAsText( | 121 WebString WebFrameContentDumper::DumpLayoutTreeAsText( |
| 122 WebLocalFrame* frame, | 122 WebLocalFrame* frame, |
| 123 LayoutAsTextControls to_show) { | 123 LayoutAsTextControls to_show) { |
| 124 if (!frame) | 124 if (!frame) |
| 125 return WebString(); | 125 return WebString(); |
| 126 LayoutAsTextBehavior behavior = kLayoutAsTextShowAllLayers; | 126 LayoutAsTextBehavior behavior = kLayoutAsTextShowAllLayers; |
| 127 | 127 |
| 128 if (to_show & kLayoutAsTextWithLineTrees) | 128 if (to_show & kLayoutAsTextWithLineTrees) |
| 129 behavior |= kLayoutAsTextShowLineTrees; | 129 behavior |= kLayoutAsTextShowLineTrees; |
| 130 | 130 |
| 131 if (to_show & kLayoutAsTextDebug) | 131 if (to_show & kLayoutAsTextDebug) |
| 132 behavior |= kLayoutAsTextShowCompositedLayers | kLayoutAsTextShowAddresses | | 132 behavior |= kLayoutAsTextShowCompositedLayers | kLayoutAsTextShowAddresses | |
| 133 kLayoutAsTextShowIDAndClass | kLayoutAsTextShowLayerNesting; | 133 kLayoutAsTextShowIDAndClass | kLayoutAsTextShowLayerNesting; |
| 134 | 134 |
| 135 if (to_show & kLayoutAsTextPrinting) | 135 if (to_show & kLayoutAsTextPrinting) |
| 136 behavior |= kLayoutAsTextPrintingMode; | 136 behavior |= kLayoutAsTextPrintingMode; |
| 137 | 137 |
| 138 return ExternalRepresentation(ToWebLocalFrameImpl(frame)->GetFrame(), | 138 return ExternalRepresentation(ToWebLocalFrameBase(frame)->GetFrame(), |
| 139 behavior); | 139 behavior); |
| 140 } | 140 } |
| 141 } | 141 } |
| OLD | NEW |