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

Unified Diff: third_party/WebKit/Source/devtools/front_end/ui/TextPrompt.js

Issue 1879163003: DevTools: cleanup occurences of selection.getRangeAt to avoid NPE (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@selection-exception
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/ui/TextPrompt.js
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/TextPrompt.js b/third_party/WebKit/Source/devtools/front_end/ui/TextPrompt.js
index 4b7917c1613d328f0a1f99a3bc7ee7fca05644b9..ce58e04b879885d37f0d35f446785dac353412c6 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui/TextPrompt.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui/TextPrompt.js
@@ -392,10 +392,10 @@ WebInspector.TextPrompt.prototype = {
{
this.clearAutoComplete(true);
var selection = this._element.getComponentSelection();
- if (!selection.rangeCount)
+ var selectionRange = selection && selection.rangeCount ? selection.getRangeAt(0) : null;
+ if (!selectionRange)
return;
- var selectionRange = selection.getRangeAt(0);
var shouldExit;
if (!force && !this.isCaretAtEndOfPrompt() && !this.isSuggestBoxVisible())
@@ -684,10 +684,10 @@ WebInspector.TextPrompt.prototype = {
isCaretAtEndOfPrompt: function()
{
var selection = this._element.getComponentSelection();
- if (!selection.rangeCount || !selection.isCollapsed)
+ var selectionRange = selection && selection.rangeCount ? selection.getRangeAt(0) : null;
+ if (!selectionRange || !selection.isCollapsed)
return false;
- var selectionRange = selection.getRangeAt(0);
var node = selectionRange.startContainer;
if (!node.isSelfOrDescendant(this._element))
return false;

Powered by Google App Engine
This is Rietveld 408576698