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

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

Issue 2466833002: selection.setBaseAndExtent with null should not crash. (Closed)
Patch Set: update Created 4 years 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 | « third_party/WebKit/LayoutTests/editing/selection/set_base_and_extent/set_null.html ('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) 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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 return; 265 return;
266 } 266 }
267 267
268 if (extentOffset < 0) { 268 if (extentOffset < 0) {
269 exceptionState.throwDOMException( 269 exceptionState.throwDOMException(
270 IndexSizeError, 270 IndexSizeError,
271 String::number(extentOffset) + " is not a valid extent offset."); 271 String::number(extentOffset) + " is not a valid extent offset.");
272 return; 272 return;
273 } 273 }
274 274
275 if (!baseNode || !extentNode) 275 // TODO(editing-dev): Behavior on where base or extent is null is still
276 // under discussion: https://github.com/w3c/selection-api/issues/72
277 if (!baseNode) {
276 UseCounter::count(frame(), UseCounter::SelectionSetBaseAndExtentNull); 278 UseCounter::count(frame(), UseCounter::SelectionSetBaseAndExtentNull);
279 frame()->selection().clear();
280 return;
281 }
282 if (!extentNode) {
283 UseCounter::count(frame(), UseCounter::SelectionSetBaseAndExtentNull);
284 extentOffset = 0;
285 }
277 286
278 if (!isValidForPosition(baseNode) || !isValidForPosition(extentNode)) 287 if (!isValidForPosition(baseNode) || !isValidForPosition(extentNode))
279 return; 288 return;
280 289
281 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets 290 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets
282 // needs to be audited. See http://crbug.com/590369 for more details. 291 // needs to be audited. See http://crbug.com/590369 for more details.
283 // In the long term, we should change FrameSelection::setSelection to take a 292 // In the long term, we should change FrameSelection::setSelection to take a
284 // parameter that does not require clean layout, so that modifying selection 293 // parameter that does not require clean layout, so that modifying selection
285 // no longer performs synchronous layout by itself. 294 // no longer performs synchronous layout by itself.
286 // TODO(editing-dev): Once SVG USE element doesn't modifies DOM tree, we 295 // TODO(editing-dev): Once SVG USE element doesn't modifies DOM tree, we
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 m_treeScope->document().addConsoleMessage( 666 m_treeScope->document().addConsoleMessage(
658 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message)); 667 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message));
659 } 668 }
660 669
661 DEFINE_TRACE(DOMSelection) { 670 DEFINE_TRACE(DOMSelection) {
662 visitor->trace(m_treeScope); 671 visitor->trace(m_treeScope);
663 DOMWindowProperty::trace(visitor); 672 DOMWindowProperty::trace(visitor);
664 } 673 }
665 674
666 } // namespace blink 675 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/editing/selection/set_base_and_extent/set_null.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698