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

Side by Side Diff: third_party/WebKit/Source/web/WebFrameContentDumper.cpp

Issue 1397713004: Don't bother layout until first navigation is done. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: another attempt to fix tests Created 4 years, 9 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 "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"
(...skipping 10 matching lines...) Expand all
21 static void frameContentAsPlainText(size_t maxChars, LocalFrame* frame, StringBu ilder& output) 21 static void frameContentAsPlainText(size_t maxChars, LocalFrame* frame, StringBu ilder& output)
22 { 22 {
23 Document* document = frame->document(); 23 Document* document = frame->document();
24 if (!document) 24 if (!document)
25 return; 25 return;
26 26
27 if (!frame->view()) 27 if (!frame->view())
28 return; 28 return;
29 29
30 // Select the document body. 30 // Select the document body.
31 if (document->body()) { 31 if (!document->needsLayoutTreeUpdate() && document->body()) {
32 const EphemeralRange range = EphemeralRange::rangeOfContents(*document-> body()); 32 const EphemeralRange range = EphemeralRange::rangeOfContents(*document-> body());
33 33
34 // The text iterator will walk nodes giving us text. This is similar to 34 // The text iterator will walk nodes giving us text. This is similar to
35 // the plainText() function in core/editing/TextIterator.h, but we imple ment the maximum 35 // the plainText() function in core/editing/TextIterator.h, but we imple ment the maximum
36 // size and also copy the results directly into a wstring, avoiding the 36 // size and also copy the results directly into a wstring, avoiding the
37 // string conversion. 37 // string conversion.
38 for (TextIterator it(range.startPosition(), range.endPosition()); !it.at End(); it.advance()) { 38 for (TextIterator it(range.startPosition(), range.endPosition()); !it.at End(); it.advance()) {
39 it.text().appendTextToStringBuilder(output, 0, maxChars - output.len gth()); 39 it.text().appendTextToStringBuilder(output, 0, maxChars - output.len gth());
40 if (output.length() >= maxChars) 40 if (output.length() >= maxChars)
41 return; // Filled up the buffer. 41 return; // Filled up the buffer.
42 } 42 }
43 } 43 }
44 44
45 // The separator between frames when the frames are converted to plain text. 45 // The separator between frames when the frames are converted to plain text.
46 const LChar frameSeparator[] = { '\n', '\n' }; 46 const LChar frameSeparator[] = { '\n', '\n' };
47 const size_t frameSeparatorLength = WTF_ARRAY_LENGTH(frameSeparator); 47 const size_t frameSeparatorLength = WTF_ARRAY_LENGTH(frameSeparator);
48 48
49 // Recursively walk the children. 49 // Recursively walk the children.
50 const FrameTree& frameTree = frame->tree(); 50 const FrameTree& frameTree = frame->tree();
51 for (Frame* curChild = frameTree.firstChild(); curChild; curChild = curChild ->tree().nextSibling()) { 51 for (Frame* curChild = frameTree.firstChild(); curChild; curChild = curChild ->tree().nextSibling()) {
52 if (!curChild->isLocalFrame()) 52 if (!curChild->isLocalFrame())
53 continue; 53 continue;
54 LocalFrame* curLocalChild = toLocalFrame(curChild); 54 LocalFrame* curLocalChild = toLocalFrame(curChild);
55
55 // Ignore the text of non-visible frames. 56 // Ignore the text of non-visible frames.
56 LayoutView* contentLayoutObject = curLocalChild->contentLayoutObject(); 57 LayoutView* contentLayoutObject = curLocalChild->contentLayoutObject();
57 LayoutPart* ownerLayoutObject = curLocalChild->ownerLayoutObject(); 58 LayoutPart* ownerLayoutObject = curLocalChild->ownerLayoutObject();
58 if (!contentLayoutObject || !contentLayoutObject->size().width() || !con tentLayoutObject->size().height() 59 if (!contentLayoutObject || !contentLayoutObject->size().width() || !con tentLayoutObject->size().height()
59 || (contentLayoutObject->location().x() + contentLayoutObject->size( ).width() <= 0) || (contentLayoutObject->location().y() + contentLayoutObject->s ize().height() <= 0) 60 || (contentLayoutObject->location().x() + contentLayoutObject->size( ).width() <= 0) || (contentLayoutObject->location().y() + contentLayoutObject->s ize().height() <= 0)
60 || (ownerLayoutObject && ownerLayoutObject->style() && ownerLayoutOb ject->style()->visibility() != VISIBLE)) { 61 || (ownerLayoutObject && ownerLayoutObject->style() && ownerLayoutOb ject->style()->visibility() != VISIBLE)) {
61 continue; 62 continue;
62 } 63 }
63 64
64 // Make sure the frame separator won't fill up the buffer, and give up i f 65 // Make sure the frame separator won't fill up the buffer, and give up i f
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 104
104 if (toShow & LayoutAsTextDebug) 105 if (toShow & LayoutAsTextDebug)
105 behavior |= LayoutAsTextShowCompositedLayers | LayoutAsTextShowAddresses | LayoutAsTextShowIDAndClass | LayoutAsTextShowLayerNesting; 106 behavior |= LayoutAsTextShowCompositedLayers | LayoutAsTextShowAddresses | LayoutAsTextShowIDAndClass | LayoutAsTextShowLayerNesting;
106 107
107 if (toShow & LayoutAsTextPrinting) 108 if (toShow & LayoutAsTextPrinting)
108 behavior |= LayoutAsTextPrintingMode; 109 behavior |= LayoutAsTextPrintingMode;
109 110
110 return externalRepresentation(toWebLocalFrameImpl(frame)->frame(), behavior) ; 111 return externalRepresentation(toWebLocalFrameImpl(frame)->frame(), behavior) ;
111 } 112 }
112 } 113 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/testing/DummyPageHolder.cpp ('k') | third_party/WebKit/Source/web/WebLocalFrameImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698