| 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" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 DCHECK(!frame->view()->needsLayout()); | 33 DCHECK(!frame->view()->needsLayout()); |
| 34 DCHECK(!document->needsLayoutTreeUpdate()); | 34 DCHECK(!document->needsLayoutTreeUpdate()); |
| 35 | 35 |
| 36 // Select the document body. | 36 // Select the document body. |
| 37 if (document->body()) { | 37 if (document->body()) { |
| 38 const EphemeralRange range = | 38 const EphemeralRange range = |
| 39 EphemeralRange::rangeOfContents(*document->body()); | 39 EphemeralRange::rangeOfContents(*document->body()); |
| 40 | 40 |
| 41 // The text iterator will walk nodes giving us text. This is similar to | 41 // The text iterator will walk nodes giving us text. This is similar to |
| 42 // the plainText() function in core/editing/TextIterator.h, but we implement
the maximum | 42 // the plainText() function in core/editing/TextIterator.h, but we |
| 43 // size and also copy the results directly into a wstring, avoiding the | 43 // implement the maximum size and also copy the results directly into a |
| 44 // string conversion. | 44 // wstring, avoiding the string conversion. |
| 45 for (TextIterator it(range.startPosition(), range.endPosition()); | 45 for (TextIterator it(range.startPosition(), range.endPosition()); |
| 46 !it.atEnd(); it.advance()) { | 46 !it.atEnd(); it.advance()) { |
| 47 it.text().appendTextToStringBuilder(output, 0, | 47 it.text().appendTextToStringBuilder(output, 0, |
| 48 maxChars - output.length()); | 48 maxChars - output.length()); |
| 49 if (output.length() >= maxChars) | 49 if (output.length() >= maxChars) |
| 50 return; // Filled up the buffer. | 50 return; // Filled up the buffer. |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 | 53 |
| 54 // The separator between frames when the frames are converted to plain text. | 54 // The separator between frames when the frames are converted to plain text. |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 if (toShow & LayoutAsTextDebug) | 128 if (toShow & LayoutAsTextDebug) |
| 129 behavior |= LayoutAsTextShowCompositedLayers | LayoutAsTextShowAddresses | | 129 behavior |= LayoutAsTextShowCompositedLayers | LayoutAsTextShowAddresses | |
| 130 LayoutAsTextShowIDAndClass | LayoutAsTextShowLayerNesting; | 130 LayoutAsTextShowIDAndClass | LayoutAsTextShowLayerNesting; |
| 131 | 131 |
| 132 if (toShow & LayoutAsTextPrinting) | 132 if (toShow & LayoutAsTextPrinting) |
| 133 behavior |= LayoutAsTextPrintingMode; | 133 behavior |= LayoutAsTextPrintingMode; |
| 134 | 134 |
| 135 return externalRepresentation(toWebLocalFrameImpl(frame)->frame(), behavior); | 135 return externalRepresentation(toWebLocalFrameImpl(frame)->frame(), behavior); |
| 136 } | 136 } |
| 137 } | 137 } |
| OLD | NEW |