<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[191496] trunk/Source/WebInspectorUI</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/191496">191496</a></dd>
<dt>Author</dt> <dd>nvasilyev@apple.com</dd>
<dt>Date</dt> <dd>2015-10-23 10:11:02 -0700 (Fri, 23 Oct 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Web Inspector: Command-Enter in Debugger should show a popover with evaluation result
https://bugs.webkit.org/show_bug.cgi?id=149195
Currenty, the only way to display the popover is to hover over the text with a mouse cursor.
Provide a way to display it via a keyboard shortcut.
Reviewed by Timothy Hatcher.
* UserInterface/Controllers/CodeMirrorCompletionController.js:
(WebInspector.CodeMirrorCompletionController): Deleted.
(WebInspector.CodeMirrorCompletionController.prototype._generateJavaScriptCompletions): Deleted.
Don't evaluate selected text from Debugger or Sources in the console.
* UserInterface/Controllers/CodeMirrorTokenTrackingController.js:
(WebInspector.CodeMirrorTokenTrackingController):
(WebInspector.CodeMirrorTokenTrackingController.prototype._handleCommandEnterKey):
(WebInspector.CodeMirrorTokenTrackingController.prototype._hidePopover):
Cmd-Enter triggers the popover, Esc hides it.
(WebInspector.CodeMirrorTokenTrackingController.prototype.set mode):
(WebInspector.CodeMirrorTokenTrackingController.prototype.removeHighlightedRange):
Don't use delete.
(WebInspector.CodeMirrorTokenTrackingController.prototype._mouseMovedWithMarkedText):
When a token isn't hovered, hide it only when it was triggered not by the keyboard.
(WebInspector.CodeMirrorTokenTrackingController.prototype._markedTextIsNoLongerHovered):
Don't use delete.
(WebInspector.CodeMirrorTokenTrackingController.prototype._updateHoveredTokenInfo):
(WebInspector.CodeMirrorTokenTrackingController.prototype._getTokenInfoForPosition):
Abstract out a no side effects _getTokenInfoForPosition method, which is also used by _handleCommandEnterKey.
(WebInspector.CodeMirrorTokenTrackingController.prototype._mouseMovedOutOfEditor):
(WebInspector.CodeMirrorTokenTrackingController.prototype._mouseButtonWasReleasedOverEditor):
Don't use delete.
(WebInspector.CodeMirrorTokenTrackingController.prototype._processNewHoveredToken):
(WebInspector.CodeMirrorTokenTrackingController.prototype._processNonSymbolToken):
(WebInspector.CodeMirrorTokenTrackingController.prototype._processJavaScriptExpression):
Pass tokenInfo as an argument to explicitly state that these methods require it.
(WebInspector.CodeMirrorTokenTrackingController.prototype._resetTrackingStates):
Don't use delete.
* UserInterface/Views/SourceCodeTextEditor.js:
(WebInspector.SourceCodeTextEditor.prototype.tokenTrackingControllerHighlightedRangeReleased):
Allow to hide the popover regardless of mouse position. Used when the text cursor moves or
when Esc key is pressed.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceControllersCodeMirrorCompletionControllerjs">trunk/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceControllersCodeMirrorTokenTrackingControllerjs">trunk/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorTokenTrackingController.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsSourceCodeTextEditorjs">trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (191495 => 191496)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog        2015-10-23 14:07:12 UTC (rev 191495)
+++ trunk/Source/WebInspectorUI/ChangeLog        2015-10-23 17:11:02 UTC (rev 191496)
</span><span class="lines">@@ -1,3 +1,55 @@
</span><ins>+2015-10-23 Nikita Vasilyev <nvasilyev@apple.com>
+
+ Web Inspector: Command-Enter in Debugger should show a popover with evaluation result
+ https://bugs.webkit.org/show_bug.cgi?id=149195
+
+ Currenty, the only way to display the popover is to hover over the text with a mouse cursor.
+ Provide a way to display it via a keyboard shortcut.
+
+ Reviewed by Timothy Hatcher.
+
+ * UserInterface/Controllers/CodeMirrorCompletionController.js:
+ (WebInspector.CodeMirrorCompletionController): Deleted.
+ (WebInspector.CodeMirrorCompletionController.prototype._generateJavaScriptCompletions): Deleted.
+ Don't evaluate selected text from Debugger or Sources in the console.
+
+ * UserInterface/Controllers/CodeMirrorTokenTrackingController.js:
+ (WebInspector.CodeMirrorTokenTrackingController):
+ (WebInspector.CodeMirrorTokenTrackingController.prototype._handleCommandEnterKey):
+ (WebInspector.CodeMirrorTokenTrackingController.prototype._hidePopover):
+ Cmd-Enter triggers the popover, Esc hides it.
+
+ (WebInspector.CodeMirrorTokenTrackingController.prototype.set mode):
+ (WebInspector.CodeMirrorTokenTrackingController.prototype.removeHighlightedRange):
+ Don't use delete.
+
+ (WebInspector.CodeMirrorTokenTrackingController.prototype._mouseMovedWithMarkedText):
+ When a token isn't hovered, hide it only when it was triggered not by the keyboard.
+
+ (WebInspector.CodeMirrorTokenTrackingController.prototype._markedTextIsNoLongerHovered):
+ Don't use delete.
+
+ (WebInspector.CodeMirrorTokenTrackingController.prototype._updateHoveredTokenInfo):
+ (WebInspector.CodeMirrorTokenTrackingController.prototype._getTokenInfoForPosition):
+ Abstract out a no side effects _getTokenInfoForPosition method, which is also used by _handleCommandEnterKey.
+
+ (WebInspector.CodeMirrorTokenTrackingController.prototype._mouseMovedOutOfEditor):
+ (WebInspector.CodeMirrorTokenTrackingController.prototype._mouseButtonWasReleasedOverEditor):
+ Don't use delete.
+
+ (WebInspector.CodeMirrorTokenTrackingController.prototype._processNewHoveredToken):
+ (WebInspector.CodeMirrorTokenTrackingController.prototype._processNonSymbolToken):
+ (WebInspector.CodeMirrorTokenTrackingController.prototype._processJavaScriptExpression):
+ Pass tokenInfo as an argument to explicitly state that these methods require it.
+
+ (WebInspector.CodeMirrorTokenTrackingController.prototype._resetTrackingStates):
+ Don't use delete.
+
+ * UserInterface/Views/SourceCodeTextEditor.js:
+ (WebInspector.SourceCodeTextEditor.prototype.tokenTrackingControllerHighlightedRangeReleased):
+ Allow to hide the popover regardless of mouse position. Used when the text cursor moves or
+ when Esc key is pressed.
+
</ins><span class="cx"> 2015-10-23 Devin Rousso <dcrousso+webkit@gmail.com>
</span><span class="cx">
</span><span class="cx"> Web Inspector: Visual sidebar should support multiple backgrounds
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceControllersCodeMirrorCompletionControllerjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js (191495 => 191496)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js        2015-10-23 14:07:12 UTC (rev 191495)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js        2015-10-23 17:11:02 UTC (rev 191496)
</span><span class="lines">@@ -51,7 +51,6 @@
</span><span class="cx"> "Right": this._handleRightOrEnterKey.bind(this),
</span><span class="cx"> "Esc": this._handleEscapeKey.bind(this),
</span><span class="cx"> "Enter": this._handleRightOrEnterKey.bind(this),
</span><del>- "Cmd-Enter": this._handleCommandEnterKey.bind(this),
</del><span class="cx"> "Tab": this._handleTabKey.bind(this),
</span><span class="cx"> "Cmd-A": this._handleHideKey.bind(this),
</span><span class="cx"> "Cmd-Z": this._handleHideKey.bind(this),
</span><span class="lines">@@ -714,19 +713,6 @@
</span><span class="cx"> this._commitCompletionHint();
</span><span class="cx"> }
</span><span class="cx">
</span><del>- _handleCommandEnterKey(codeMirror)
- {
- const modeName = codeMirror.getMode().name;
- if (modeName !== "javascript" && modeName !== "htmlmixed")
- return CodeMirror.Pass;
-
- const selectedText = codeMirror.getSelection();
- if (!selectedText)
- return CodeMirror.Pass;
-
- WebInspector.consoleLogViewController.consolePromptTextCommitted(null, selectedText);
- }
-
</del><span class="cx"> _handleEscapeKey(codeMirror)
</span><span class="cx"> {
</span><span class="cx"> var delegateImplementsShouldAllowEscapeCompletion = this._delegate && typeof this._delegate.completionControllerShouldAllowEscapeCompletion === "function";
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceControllersCodeMirrorTokenTrackingControllerjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorTokenTrackingController.js (191495 => 191496)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorTokenTrackingController.js        2015-10-23 14:07:12 UTC (rev 191495)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorTokenTrackingController.js        2015-10-23 17:11:02 UTC (rev 191496)
</span><span class="lines">@@ -41,8 +41,17 @@
</span><span class="cx">
</span><span class="cx"> this._enabled = false;
</span><span class="cx"> this._tracking = false;
</span><del>- this._hoveredTokenInfo = null;
</del><ins>+ this._previousTokenInfo = null;
</ins><span class="cx"> this._hoveredMarker = null;
</span><ins>+
+ const hidePopover = this._hidePopover.bind(this);
+
+ this._codeMirror.addKeyMap({
+ "Cmd-Enter": this._handleCommandEnterKey.bind(this),
+ "Esc": hidePopover
+ });
+
+ this._codeMirror.on("cursorActivity", hidePopover);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Public
</span><span class="lines">@@ -93,8 +102,8 @@
</span><span class="cx">
</span><span class="cx"> this._mode = mode || WebInspector.CodeMirrorTokenTrackingController.Mode.None;
</span><span class="cx">
</span><del>- if (oldMode !== this._mode && this._tracking && this._hoveredTokenInfo)
- this._processNewHoveredToken();
</del><ins>+ if (oldMode !== this._mode && this._tracking && this._previousTokenInfo)
+ this._processNewHoveredToken(this._previousTokenInfo);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> get mouseOverDelayDuration()
</span><span class="lines">@@ -174,7 +183,7 @@
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> this._codeMirrorMarkedText.clear();
</span><del>- delete this._codeMirrorMarkedText;
</del><ins>+ this._codeMirrorMarkedText = null;
</ins><span class="cx">
</span><span class="cx"> window.removeEventListener("mousemove", this, true);
</span><span class="cx"> }
</span><span class="lines">@@ -249,6 +258,26 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ _handleCommandEnterKey(codeMirror)
+ {
+ const tokenInfo = this._getTokenInfoForPosition(codeMirror.getCursor("head"));
+ tokenInfo.triggeredBy = WebInspector.CodeMirrorTokenTrackingController.TriggeredBy.Keyboard;
+ this._processNewHoveredToken(tokenInfo);
+ }
+
+ _hidePopover()
+ {
+ if (!this._candidate)
+ return CodeMirror.Pass;
+
+ if (this._delegate && typeof this._delegate.tokenTrackingControllerHighlightedRangeReleased === "function") {
+ const forceHidePopover = true;
+ this._delegate.tokenTrackingControllerHighlightedRangeReleased(this, forceHidePopover);
+ }
+
+ this._candidate = null;
+ }
+
</ins><span class="cx"> _mouseEntered(event)
</span><span class="cx"> {
</span><span class="cx"> if (!this._tracking)
</span><span class="lines">@@ -262,6 +291,9 @@
</span><span class="cx">
</span><span class="cx"> _mouseMovedWithMarkedText(event)
</span><span class="cx"> {
</span><ins>+ if (this._candidate && this._candidate.triggeredBy === WebInspector.CodeMirrorTokenTrackingController.TriggeredBy.Keyboard)
+ return;
+
</ins><span class="cx"> var shouldRelease = !event.target.classList.contains(this._classNameForHighlightedRange);
</span><span class="cx"> if (shouldRelease && this._delegate && typeof this._delegate.tokenTrackingControllerCanReleaseHighlightedRange === "function")
</span><span class="cx"> shouldRelease = this._delegate.tokenTrackingControllerCanReleaseHighlightedRange(this, event.target);
</span><span class="lines">@@ -272,15 +304,18 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- clearTimeout(this._markedTextMouseoutTimer);
- delete this._markedTextMouseoutTimer;
</del><ins>+ if (this._markedTextMouseoutTimer)
+ clearTimeout(this._markedTextMouseoutTimer);
+
+ this._markedTextMouseoutTimer = 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> _markedTextIsNoLongerHovered()
</span><span class="cx"> {
</span><span class="cx"> if (this._delegate && typeof this._delegate.tokenTrackingControllerHighlightedRangeReleased === "function")
</span><span class="cx"> this._delegate.tokenTrackingControllerHighlightedRangeReleased(this);
</span><del>- delete this._markedTextMouseoutTimer;
</del><ins>+
+ this._markedTextMouseoutTimer = 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> _mouseMovedOverEditor(event)
</span><span class="lines">@@ -305,35 +340,47 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Stop right here if we're hovering the same token as we were last time.
</span><del>- if (this._hoveredTokenInfo &&
- this._hoveredTokenInfo.position.line === position.line &&
- this._hoveredTokenInfo.token.start === token.start &&
- this._hoveredTokenInfo.token.end === token.end)
</del><ins>+ if (this._previousTokenInfo &&
+ this._previousTokenInfo.position.line === position.line &&
+ this._previousTokenInfo.token.start === token.start &&
+ this._previousTokenInfo.token.end === token.end)
</ins><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> // We have a new hovered token.
</span><ins>+ var tokenInfo = this._previousTokenInfo = this._getTokenInfoForPosition(position);
+
+ if (this._tokenHoverTimer)
+ clearTimeout(this._tokenHoverTimer);
+
+ this._tokenHoverTimer = 0;
+
+ if (this._codeMirrorMarkedText || !this._mouseOverDelayDuration)
+ this._processNewHoveredToken(tokenInfo);
+ else
+ this._tokenHoverTimer = setTimeout(this._processNewHoveredToken.bind(this, tokenInfo), this._mouseOverDelayDuration);
+ }
+
+ _getTokenInfoForPosition(position)
+ {
+ var token = this._codeMirror.getTokenAt(position);
</ins><span class="cx"> var innerMode = CodeMirror.innerMode(this._codeMirror.getMode(), token.state);
</span><span class="cx"> var codeMirrorModeName = innerMode.mode.alternateName || innerMode.mode.name;
</span><del>- this._hoveredTokenInfo = {
</del><ins>+ return {
</ins><span class="cx"> token,
</span><span class="cx"> position,
</span><span class="cx"> innerMode,
</span><span class="cx"> modeName: codeMirrorModeName
</span><span class="cx"> };
</span><del>-
- clearTimeout(this._tokenHoverTimer);
-
- if (this._codeMirrorMarkedText || !this._mouseOverDelayDuration)
- this._processNewHoveredToken();
- else
- this._tokenHoverTimer = setTimeout(this._processNewHoveredToken.bind(this), this._mouseOverDelayDuration);
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> _mouseMovedOutOfEditor(event)
</span><span class="cx"> {
</span><del>- clearTimeout(this._tokenHoverTimer);
- delete this._hoveredTokenInfo;
- delete this._selectionMayBeInProgress;
</del><ins>+ if (this._tokenHoverTimer)
+ clearTimeout(this._tokenHoverTimer);
+
+ this._tokenHoverTimer = 0;
+ this._previousTokenInfo = null;
+ this._selectionMayBeInProgress = false;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> _mouseButtonWasPressedOverEditor(event)
</span><span class="lines">@@ -343,10 +390,10 @@
</span><span class="cx">
</span><span class="cx"> _mouseButtonWasReleasedOverEditor(event)
</span><span class="cx"> {
</span><del>- delete this._selectionMayBeInProgress;
</del><ins>+ this._selectionMayBeInProgress = false;
</ins><span class="cx"> this._mouseMovedOverEditor(event);
</span><span class="cx">
</span><del>- if (this._codeMirrorMarkedText && this._hoveredTokenInfo) {
</del><ins>+ if (this._codeMirrorMarkedText && this._previousTokenInfo) {
</ins><span class="cx"> var position = this._codeMirror.coordsChar({left: event.pageX, top: event.pageY});
</span><span class="cx"> var marks = this._codeMirror.findMarksAt(position);
</span><span class="cx"> for (var i = 0; i < marks.length; ++i) {
</span><span class="lines">@@ -365,9 +412,9 @@
</span><span class="cx"> this._resetTrackingStates();
</span><span class="cx"> }
</span><span class="cx">
</span><del>- _processNewHoveredToken()
</del><ins>+ _processNewHoveredToken(tokenInfo)
</ins><span class="cx"> {
</span><del>- console.assert(this._hoveredTokenInfo);
</del><ins>+ console.assert(tokenInfo);
</ins><span class="cx">
</span><span class="cx"> if (this._selectionMayBeInProgress)
</span><span class="cx"> return;
</span><span class="lines">@@ -376,51 +423,55 @@
</span><span class="cx">
</span><span class="cx"> switch (this._mode) {
</span><span class="cx"> case WebInspector.CodeMirrorTokenTrackingController.Mode.NonSymbolTokens:
</span><del>- this._candidate = this._processNonSymbolToken();
</del><ins>+ this._candidate = this._processNonSymbolToken(tokenInfo);
</ins><span class="cx"> break;
</span><span class="cx"> case WebInspector.CodeMirrorTokenTrackingController.Mode.JavaScriptExpression:
</span><span class="cx"> case WebInspector.CodeMirrorTokenTrackingController.Mode.JavaScriptTypeInformation:
</span><del>- this._candidate = this._processJavaScriptExpression();
</del><ins>+ this._candidate = this._processJavaScriptExpression(tokenInfo);
</ins><span class="cx"> break;
</span><span class="cx"> case WebInspector.CodeMirrorTokenTrackingController.Mode.MarkedTokens:
</span><del>- this._candidate = this._processMarkedToken();
</del><ins>+ this._candidate = this._processMarkedToken(tokenInfo);
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (!this._candidate)
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- clearTimeout(this._markedTextMouseoutTimer);
- delete this._markedTextMouseoutTimer;
</del><ins>+ this._candidate.triggeredBy = tokenInfo.triggeredBy;
</ins><span class="cx">
</span><ins>+ if (this._markedTextMouseoutTimer)
+ clearTimeout(this._markedTextMouseoutTimer);
+
+ this._markedTextMouseoutTimer = 0;
+
</ins><span class="cx"> if (this._delegate && typeof this._delegate.tokenTrackingControllerNewHighlightCandidate === "function")
</span><span class="cx"> this._delegate.tokenTrackingControllerNewHighlightCandidate(this, this._candidate);
</span><span class="cx"> }
</span><span class="cx">
</span><del>- _processNonSymbolToken()
</del><ins>+ _processNonSymbolToken(tokenInfo)
</ins><span class="cx"> {
</span><span class="cx"> // Ignore any symbol tokens.
</span><del>- var type = this._hoveredTokenInfo.token.type;
</del><ins>+ var type = tokenInfo.token.type;
</ins><span class="cx"> if (!type)
</span><span class="cx"> return null;
</span><span class="cx">
</span><del>- var startPosition = {line: this._hoveredTokenInfo.position.line, ch: this._hoveredTokenInfo.token.start};
- var endPosition = {line: this._hoveredTokenInfo.position.line, ch: this._hoveredTokenInfo.token.end};
</del><ins>+ var startPosition = {line: tokenInfo.position.line, ch: tokenInfo.token.start};
+ var endPosition = {line: tokenInfo.position.line, ch: tokenInfo.token.end};
</ins><span class="cx">
</span><span class="cx"> return {
</span><del>- hoveredToken: this._hoveredTokenInfo.token,
</del><ins>+ hoveredToken: tokenInfo.token,
</ins><span class="cx"> hoveredTokenRange: {start: startPosition, end: endPosition},
</span><span class="cx"> };
</span><span class="cx"> }
</span><span class="cx">
</span><del>- _processJavaScriptExpression()
</del><ins>+ _processJavaScriptExpression(tokenInfo)
</ins><span class="cx"> {
</span><span class="cx"> // Only valid within JavaScript.
</span><del>- if (this._hoveredTokenInfo.modeName !== "javascript")
</del><ins>+ if (tokenInfo.modeName !== "javascript")
</ins><span class="cx"> return null;
</span><span class="cx">
</span><del>- var startPosition = {line: this._hoveredTokenInfo.position.line, ch: this._hoveredTokenInfo.token.start};
- var endPosition = {line: this._hoveredTokenInfo.position.line, ch: this._hoveredTokenInfo.token.end};
</del><ins>+ var startPosition = {line: tokenInfo.position.line, ch: tokenInfo.token.start};
+ var endPosition = {line: tokenInfo.position.line, ch: tokenInfo.token.end};
</ins><span class="cx">
</span><span class="cx"> function tokenIsInRange(token, range)
</span><span class="cx"> {
</span><span class="lines">@@ -437,7 +488,7 @@
</span><span class="cx">
</span><span class="cx"> if (tokenIsInRange(startPosition, selectionRange) || tokenIsInRange(endPosition, selectionRange)) {
</span><span class="cx"> return {
</span><del>- hoveredToken: this._hoveredTokenInfo.token,
</del><ins>+ hoveredToken: tokenInfo.token,
</ins><span class="cx"> hoveredTokenRange: selectionRange,
</span><span class="cx"> expression: this._codeMirror.getSelection(),
</span><span class="cx"> expressionRange: selectionRange,
</span><span class="lines">@@ -446,19 +497,19 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // We only handle vars, definitions, properties, and the keyword 'this'.
</span><del>- var type = this._hoveredTokenInfo.token.type;
</del><ins>+ var type = tokenInfo.token.type;
</ins><span class="cx"> var isProperty = type.indexOf("property") !== -1;
</span><span class="cx"> var isKeyword = type.indexOf("keyword") !== -1;
</span><span class="cx"> if (!isProperty && !isKeyword && type.indexOf("variable") === -1 && type.indexOf("def") === -1)
</span><span class="cx"> return null;
</span><span class="cx">
</span><span class="cx"> // Not object literal property names, but yes if an object literal shorthand property, which is a variable.
</span><del>- let state = this._hoveredTokenInfo.innerMode.state;
</del><ins>+ let state = tokenInfo.innerMode.state;
</ins><span class="cx"> if (isProperty && state.lexical && state.lexical.type === "}") {
</span><span class="cx"> // Peek ahead to see if the next token is "}" or ",". If it is, we are a shorthand and therefore a variable.
</span><span class="cx"> let shorthand = false;
</span><del>- let mode = this._hoveredTokenInfo.innerMode.mode;
- let position = {line: this._hoveredTokenInfo.position.line, ch: this._hoveredTokenInfo.token.end};
</del><ins>+ let mode = tokenInfo.innerMode.mode;
+ let position = {line: tokenInfo.position.line, ch: tokenInfo.token.end};
</ins><span class="cx"> WebInspector.walkTokens(this._codeMirror, mode, position, function(tokenType, string) {
</span><span class="cx"> if (tokenType)
</span><span class="cx"> return false;
</span><span class="lines">@@ -474,12 +525,12 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Only the "this" keyword.
</span><del>- if (isKeyword && this._hoveredTokenInfo.token.string !== "this")
</del><ins>+ if (isKeyword && tokenInfo.token.string !== "this")
</ins><span class="cx"> return null;
</span><span class="cx">
</span><span class="cx"> // Work out the full hovered expression.
</span><del>- var expression = this._hoveredTokenInfo.token.string;
- var expressionStartPosition = {line: this._hoveredTokenInfo.position.line, ch: this._hoveredTokenInfo.token.start};
</del><ins>+ var expression = tokenInfo.token.string;
+ var expressionStartPosition = {line: tokenInfo.position.line, ch: tokenInfo.token.start};
</ins><span class="cx"> while (true) {
</span><span class="cx"> var token = this._codeMirror.getTokenAt(expressionStartPosition);
</span><span class="cx"> if (!token)
</span><span class="lines">@@ -501,7 +552,7 @@
</span><span class="cx">
</span><span class="cx"> // Return the candidate for this token and expression.
</span><span class="cx"> return {
</span><del>- hoveredToken: this._hoveredTokenInfo.token,
</del><ins>+ hoveredToken: tokenInfo.token,
</ins><span class="cx"> hoveredTokenRange: {start: startPosition, end: endPosition},
</span><span class="cx"> expression,
</span><span class="cx"> expressionRange: {start: expressionStartPosition, end: endPosition},
</span><span class="lines">@@ -515,9 +566,13 @@
</span><span class="cx">
</span><span class="cx"> _resetTrackingStates()
</span><span class="cx"> {
</span><del>- clearTimeout(this._tokenHoverTimer);
- delete this._selectionMayBeInProgress;
- delete this._hoveredTokenInfo;
</del><ins>+ if (this._tokenHoverTimer)
+ clearTimeout(this._tokenHoverTimer);
+
+ this._tokenHoverTimer = 0;
+
+ this._selectionMayBeInProgress = false;
+ this._previousTokenInfo = null;
</ins><span class="cx"> this.removeHighlightedRange();
</span><span class="cx"> }
</span><span class="cx"> };
</span><span class="lines">@@ -531,3 +586,8 @@
</span><span class="cx"> JavaScriptTypeInformation: "javascript-type-information",
</span><span class="cx"> MarkedTokens: "marked-tokens"
</span><span class="cx"> };
</span><ins>+
+WebInspector.CodeMirrorTokenTrackingController.TriggeredBy = {
+ Keyboard: "keyboard",
+ Hover: "hover"
+};
</ins></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsSourceCodeTextEditorjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js (191495 => 191496)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js        2015-10-23 14:07:12 UTC (rev 191495)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js        2015-10-23 17:11:02 UTC (rev 191496)
</span><span class="lines">@@ -1300,9 +1300,9 @@
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- tokenTrackingControllerHighlightedRangeReleased(tokenTrackingController)
</del><ins>+ tokenTrackingControllerHighlightedRangeReleased(tokenTrackingController, forceHide = false)
</ins><span class="cx"> {
</span><del>- if (!this._mouseIsOverPopover)
</del><ins>+ if (forceHide || !this._mouseIsOverPopover)
</ins><span class="cx"> this._dismissPopover();
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>