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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/DOMSelection.cpp
diff --git a/third_party/WebKit/Source/core/editing/DOMSelection.cpp b/third_party/WebKit/Source/core/editing/DOMSelection.cpp
index 91d8dbedd404b282866de9c7e0d5c0719ca87a62..e7c2c90f96b4e024411441a5976e81793204f542 100644
--- a/third_party/WebKit/Source/core/editing/DOMSelection.cpp
+++ b/third_party/WebKit/Source/core/editing/DOMSelection.cpp
@@ -272,8 +272,17 @@ void DOMSelection::setBaseAndExtent(Node* baseNode,
return;
}
- if (!baseNode || !extentNode)
+ // TODO(editing-dev): Behavior on where base or extent is null is still
+ // under discussion: https://github.com/w3c/selection-api/issues/72
+ if (!baseNode) {
UseCounter::count(frame(), UseCounter::SelectionSetBaseAndExtentNull);
+ frame()->selection().clear();
+ return;
+ }
+ if (!extentNode) {
+ UseCounter::count(frame(), UseCounter::SelectionSetBaseAndExtentNull);
+ extentOffset = 0;
+ }
if (!isValidForPosition(baseNode) || !isValidForPosition(extentNode))
return;
« 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