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

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

Issue 1335573004: Introduce Range::dispose() for prompt detachment from owner Document. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: replace use of selectNodeContents() also 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 | « Source/core/editing/spellcheck/SpellCheckRequester.cpp ('k') | 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 RefPtrWillBeRawPtr<Range> range(document->createRange());
yosin_UTC9 2015/09/11 07:07:19 Thus, we don't need to use |Range|. We may want to
sof 2015/09/11 07:11:42 I'm sorry, spaced out completely - we clearly don'
259 TrackExceptionState exceptionState; 259 ScopedDisposal<Range> disposeScope(range.get());
260 range->selectNodeContents(document->body(), exceptionState);
261 260
262 if (!exceptionState.hadException()) { 261 if (document->body()) {
262 const EphemeralRange range = EphemeralRange::rangeOfContents(*document-> body());
263
263 // The text iterator will walk nodes giving us text. This is similar to 264 // 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 265 // 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 266 // size and also copy the results directly into a wstring, avoiding the
266 // string conversion. 267 // string conversion.
267 for (TextIterator it(range->startPosition(), range->endPosition()); !it. atEnd(); it.advance()) { 268 for (TextIterator it(range.startPosition(), range.endPosition()); !it.at End(); it.advance()) {
268 it.text().appendTextToStringBuilder(output, 0, maxChars - output.len gth()); 269 it.text().appendTextToStringBuilder(output, 0, maxChars - output.len gth());
269 if (output.length() >= maxChars) 270 if (output.length() >= maxChars)
270 return; // Filled up the buffer. 271 return; // Filled up the buffer.
271 } 272 }
272 } 273 }
273 274
274 // The separator between frames when the frames are converted to plain text. 275 // The separator between frames when the frames are converted to plain text.
275 const LChar frameSeparator[] = { '\n', '\n' }; 276 const LChar frameSeparator[] = { '\n', '\n' };
276 const size_t frameSeparatorLength = WTF_ARRAY_LENGTH(frameSeparator); 277 const size_t frameSeparatorLength = WTF_ARRAY_LENGTH(frameSeparator);
277 278
(...skipping 1915 matching lines...) Expand 10 before | Expand all | Expand 10 after
2193 } 2194 }
2194 2195
2195 WebSandboxFlags WebLocalFrameImpl::effectiveSandboxFlags() const 2196 WebSandboxFlags WebLocalFrameImpl::effectiveSandboxFlags() const
2196 { 2197 {
2197 if (!frame()) 2198 if (!frame())
2198 return WebSandboxFlags::None; 2199 return WebSandboxFlags::None;
2199 return static_cast<WebSandboxFlags>(frame()->loader().effectiveSandboxFlags( )); 2200 return static_cast<WebSandboxFlags>(frame()->loader().effectiveSandboxFlags( ));
2200 } 2201 }
2201 2202
2202 } // namespace blink 2203 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/editing/spellcheck/SpellCheckRequester.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698