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

Side by Side Diff: Source/web/WebLocalFrameImpl.cpp

Issue 1337923002: Replace use Range::selectNodeContents() with EphemeralRange counterpart. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 static void frameContentAsPlainText(size_t maxChars, LocalFrame* frame, StringBu ilder& output) 248 static void frameContentAsPlainText(size_t maxChars, LocalFrame* frame, StringBu ilder& output)
249 { 249 {
250 Document* document = frame->document(); 250 Document* document = frame->document();
251 if (!document) 251 if (!document)
252 return; 252 return;
253 253
254 if (!frame->view()) 254 if (!frame->view())
255 return; 255 return;
256 256
257 // Select the document body. 257 // Select the document body.
258 RefPtrWillBeRawPtr<Range> range(document->createRange()); 258 if (document->body()) {
259 TrackExceptionState exceptionState; 259 const EphemeralRange range = EphemeralRange::rangeOfContents(*document-> body());
260 range->selectNodeContents(document->body(), exceptionState);
261 260
262 if (!exceptionState.hadException()) {
263 // The text iterator will walk nodes giving us text. This is similar to 261 // The text iterator will walk nodes giving us text. This is similar to
264 // the plainText() function in core/editing/TextIterator.h, but we imple ment the maximum 262 // the plainText() function in core/editing/TextIterator.h, but we imple ment the maximum
265 // size and also copy the results directly into a wstring, avoiding the 263 // size and also copy the results directly into a wstring, avoiding the
266 // string conversion. 264 // string conversion.
267 for (TextIterator it(range->startPosition(), range->endPosition()); !it. atEnd(); it.advance()) { 265 for (TextIterator it(range.startPosition(), range.endPosition()); !it.at End(); it.advance()) {
268 it.text().appendTextToStringBuilder(output, 0, maxChars - output.len gth()); 266 it.text().appendTextToStringBuilder(output, 0, maxChars - output.len gth());
269 if (output.length() >= maxChars) 267 if (output.length() >= maxChars)
270 return; // Filled up the buffer. 268 return; // Filled up the buffer.
271 } 269 }
272 } 270 }
273 271
274 // The separator between frames when the frames are converted to plain text. 272 // The separator between frames when the frames are converted to plain text.
275 const LChar frameSeparator[] = { '\n', '\n' }; 273 const LChar frameSeparator[] = { '\n', '\n' };
276 const size_t frameSeparatorLength = WTF_ARRAY_LENGTH(frameSeparator); 274 const size_t frameSeparatorLength = WTF_ARRAY_LENGTH(frameSeparator);
277 275
(...skipping 1915 matching lines...) Expand 10 before | Expand all | Expand 10 after
2193 } 2191 }
2194 2192
2195 WebSandboxFlags WebLocalFrameImpl::effectiveSandboxFlags() const 2193 WebSandboxFlags WebLocalFrameImpl::effectiveSandboxFlags() const
2196 { 2194 {
2197 if (!frame()) 2195 if (!frame())
2198 return WebSandboxFlags::None; 2196 return WebSandboxFlags::None;
2199 return static_cast<WebSandboxFlags>(frame()->loader().effectiveSandboxFlags( )); 2197 return static_cast<WebSandboxFlags>(frame()->loader().effectiveSandboxFlags( ));
2200 } 2198 }
2201 2199
2202 } // namespace blink 2200 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698