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

Side by Side Diff: third_party/WebKit/Source/core/editing/DOMSelection.cpp

Issue 2760273002: Dispose temporary Range in Selection::collapse (Closed)
Patch Set: Created 3 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
« 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) 2007, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Google Inc. All rights reserved. 3 * Copyright (C) 2012 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 // 3. If node's root is not the document associated with the context object, 251 // 3. If node's root is not the document associated with the context object,
252 // abort these steps. 252 // abort these steps.
253 if (!isValidForPosition(node)) 253 if (!isValidForPosition(node))
254 return; 254 return;
255 255
256 // 4. Otherwise, let newRange be a new range. 256 // 4. Otherwise, let newRange be a new range.
257 Range* newRange = Range::create(*frame()->document()); 257 Range* newRange = Range::create(*frame()->document());
258 258
259 // 5. Set ([DOM4]) the start and the end of newRange to (node, offset). 259 // 5. Set ([DOM4]) the start and the end of newRange to (node, offset).
260 newRange->setStart(node, offset, exceptionState); 260 newRange->setStart(node, offset, exceptionState);
261 if (exceptionState.hadException()) 261 if (exceptionState.hadException()) {
262 newRange->dispose();
262 return; 263 return;
264 }
263 newRange->setEnd(node, offset, exceptionState); 265 newRange->setEnd(node, offset, exceptionState);
264 if (exceptionState.hadException()) 266 if (exceptionState.hadException()) {
267 newRange->dispose();
265 return; 268 return;
269 }
266 270
267 // 6. Set the context object's range to newRange. 271 // 6. Set the context object's range to newRange.
268 updateFrameSelection( 272 updateFrameSelection(
269 SelectionInDOMTree::Builder() 273 SelectionInDOMTree::Builder()
270 .collapse(Position(node, offset)) 274 .collapse(Position(node, offset))
271 .setIsDirectional(frame()->selection().isDirectional()) 275 .setIsDirectional(frame()->selection().isDirectional())
272 .build(), 276 .build(),
273 newRange); 277 newRange);
274 } 278 }
275 279
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 m_treeScope->document().addConsoleMessage( 818 m_treeScope->document().addConsoleMessage(
815 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message)); 819 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message));
816 } 820 }
817 821
818 DEFINE_TRACE(DOMSelection) { 822 DEFINE_TRACE(DOMSelection) {
819 visitor->trace(m_treeScope); 823 visitor->trace(m_treeScope);
820 ContextClient::trace(visitor); 824 ContextClient::trace(visitor);
821 } 825 }
822 826
823 } // namespace blink 827 } // 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