Skip to content

Commit

Permalink
squash 'resources/unpacked/devtools' changes from 1cdfbd9..902dfb7
Browse files Browse the repository at this point in the history
902dfb7 DevTools: Distinguish between forced and unforced autocomplete in CMTE
de542eb DevTools: Don't show autocomplete when the user is typing a number
50e0a6e DevTools: [Elements] fix text color of selected HTMLComment nodes
f211c4a DevTools: Don't show an error in npm start when CHROMIUM_PATH is missing
9b14fd7 [Devtools] Renamed network timeline to "Waterfall"
0170a2f [Devtools] Added "wiskers" to new network timeline for colored mode
d0f34e9 DevTools: Fix wrapping bugs in console
f52c0b5 [DevTools] Add backendNodeId to DOM Node protocol object and SDK object
2e4601d [DevTools]: Require explicit connection
4dfd938 [Devtools] Fixed new timeline simplified bars popover hover
7861067 DevTools: Substring autocomplete in Console and StylesSideBar.
0bf43ac [Devtools] Moved new timeline canvas context menu to bottom
e58ba14 - backend code for css rule tracking - 2 new browser protocol functions : "startRuleUsageTracking" and "stopRuleUsageTracking" that also returns the rule usage list.
b9eaf07 DevTools: get rid of linkifier formatters
5998b93 [Devtools] Added constraints to new network timeline
a594ab8 DevTools: Rename prefix to query in the context of autocomplete
4fe9813 DevTools: npm run format
176938a [DevTools] refactor response to arrow key presses into TreeElement
37bdd96 DevTools: fix breakpoints in Node.js

git-subtree-dir: resources/unpacked/devtools
git-subtree-split: 902dfb7
  • Loading branch information
darwin committed Nov 5, 2016
1 parent 3f3cf7f commit 87aed61
Show file tree
Hide file tree
Showing 36 changed files with 996 additions and 361 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ front_end/cm_modes/*
front_end/diff/diff_match_patch.js
front_end/formatter_worker/acorn/acorn.js
front_end/gonzales/*
front_end/terminal/xterm.js
front_end/terminal/xterm.js/**
48 changes: 29 additions & 19 deletions front_end/components/JavaScriptAutocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ WebInspector.JavaScriptAutocomplete.completionsForTextPromptInCurrentContext = f

/**
* @param {string} text
* @param {string} completionsPrefix
* @param {string} query
* @param {boolean=} force
* @return {!Promise<!Array<string>>}
*/
WebInspector.JavaScriptAutocomplete.completionsForTextInCurrentContext = function(text, completionsPrefix, force) {
WebInspector.JavaScriptAutocomplete.completionsForTextInCurrentContext = function(text, query, force) {
var index;
var stopChars = new Set(' =:({;,!+-*/&|^<>`'.split(''));
for (index = text.length - 1; index >= 0; index--) {
Expand All @@ -50,17 +50,17 @@ WebInspector.JavaScriptAutocomplete.completionsForTextInCurrentContext = functio
}
clippedExpression = clippedExpression.substring(index + 1);

return WebInspector.JavaScriptAutocomplete.completionsForExpression(clippedExpression, completionsPrefix, force);
return WebInspector.JavaScriptAutocomplete.completionsForExpression(clippedExpression, query, force);
};


/**
* @param {string} expressionString
* @param {string} prefix
* @param {string} query
* @param {boolean=} force
* @return {!Promise<!Array<string>>}
*/
WebInspector.JavaScriptAutocomplete.completionsForExpression = function(expressionString, prefix, force) {
WebInspector.JavaScriptAutocomplete.completionsForExpression = function(expressionString, query, force) {
var executionContext = WebInspector.context.flavor(WebInspector.ExecutionContext);
if (!executionContext)
return Promise.resolve([]);
Expand All @@ -74,10 +74,10 @@ WebInspector.JavaScriptAutocomplete.completionsForExpression = function(expressi
expressionString = expressionString.substr(0, lastIndex);

// User is entering float value, do not suggest anything.
if (expressionString && !isNaN(expressionString))
if ((expressionString && !isNaN(expressionString)) || (!expressionString && query && !isNaN(query)))
return Promise.resolve([]);

if (!prefix && !expressionString && !force)
if (!query && !expressionString && !force)
return Promise.resolve([]);

var fufill;
Expand Down Expand Up @@ -223,29 +223,27 @@ WebInspector.JavaScriptAutocomplete.completionsForExpression = function(expressi
for (var i = 0; i < commandLineAPI.length; ++i)
propertyNames[commandLineAPI[i]] = true;
}
fufill(WebInspector.JavaScriptAutocomplete._completionsForPrefix(
dotNotation, bracketNotation, expressionString, prefix, Object.keys(propertyNames)));
fufill(WebInspector.JavaScriptAutocomplete._completionsForQuery(
dotNotation, bracketNotation, expressionString, query, Object.keys(propertyNames)));
}
};

/**
* @param {boolean} dotNotation
* @param {boolean} bracketNotation
* @param {string} expressionString
* @param {string} prefix
* @param {string} query
* @param {!Array.<string>} properties
* @return {!Array<string>}
*/
WebInspector.JavaScriptAutocomplete._completionsForPrefix = function(dotNotation, bracketNotation, expressionString, prefix, properties) {
WebInspector.JavaScriptAutocomplete._completionsForQuery = function(dotNotation, bracketNotation, expressionString, query, properties) {
if (bracketNotation) {
if (prefix.length && prefix[0] === '\'')
if (query.length && query[0] === '\'')
var quoteUsed = '\'';
else
var quoteUsed = '"';
}

var results = [];

if (!expressionString) {
const keywords = [
'break', 'case', 'catch', 'continue', 'default', 'delete', 'do', 'else', 'finally',
Expand All @@ -257,6 +255,10 @@ WebInspector.JavaScriptAutocomplete._completionsForPrefix = function(dotNotation

properties.sort();

var caseSensitivePrefix = [];
var caseInsensitivePrefix = [];
var caseSensitiveAnywhere = [];
var caseInsensitiveAnywhere = [];
for (var i = 0; i < properties.length; ++i) {
var property = properties[i];

Expand All @@ -270,13 +272,21 @@ WebInspector.JavaScriptAutocomplete._completionsForPrefix = function(dotNotation
property += ']';
}

if (property.length < prefix.length)
if (property.length < query.length)
continue;
if (prefix.length && !property.startsWith(prefix))
if (query.length && property.toLowerCase().indexOf(query.toLowerCase()) === -1)
continue;

// Substitute actual newlines with newline characters. @see crbug.com/498421
results.push(property.split('\n').join('\\n'));
var prop = property.split('\n').join('\\n');

if (property.startsWith(query))
caseSensitivePrefix.push(prop);
else if (property.toLowerCase().startsWith(query.toLowerCase()))
caseInsensitivePrefix.push(prop);
else if (property.indexOf(query) !== -1)
caseSensitiveAnywhere.push(prop);
else
caseInsensitiveAnywhere.push(prop);
}
return results;
return caseSensitivePrefix.concat(caseInsensitivePrefix).concat(caseSensitiveAnywhere).concat(caseInsensitiveAnywhere);
};
70 changes: 8 additions & 62 deletions front_end/components/Linkifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,17 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @interface
*/
WebInspector.LinkifierFormatter = function() {};

WebInspector.LinkifierFormatter.prototype = {
/**
* @param {!Element} anchor
* @param {!WebInspector.UILocation} uiLocation
* @param {boolean} isBlackboxed
*/
formatLiveAnchor: function(anchor, uiLocation, isBlackboxed) {}
};

/**
* @implements {WebInspector.TargetManager.Observer}
* @unrestricted
*/
WebInspector.Linkifier = class {
/**
* @param {!WebInspector.LinkifierFormatter=} formatter
* @param {number=} maxLengthForDisplayedURLs
*/
constructor(formatter) {
this._formatter =
formatter || new WebInspector.Linkifier.DefaultFormatter(WebInspector.Linkifier.MaxLengthForDisplayedURLs);
constructor(maxLengthForDisplayedURLs) {
this._maxLength = maxLengthForDisplayedURLs || WebInspector.Linkifier.MaxLengthForDisplayedURLs;
/** @type {!Map<!WebInspector.Target, !Array<!Element>>} */
this._anchorsByTarget = new Map();
/** @type {!Map<!WebInspector.Target, !WebInspector.LiveLocationPool>} */
Expand Down Expand Up @@ -350,35 +336,15 @@ WebInspector.Linkifier = class {
if (!uiLocation)
return;
anchor[WebInspector.Linkifier._uiLocationSymbol] = uiLocation;
this._formatter.formatLiveAnchor(anchor, uiLocation, liveLocation.isBlackboxed());
}
};


WebInspector.Linkifier._uiLocationSymbol = Symbol('uiLocation');
WebInspector.Linkifier._fallbackAnchorSymbol = Symbol('fallbackAnchor');
WebInspector.Linkifier._liveLocationSymbol = Symbol('liveLocation');


/**
* @implements {WebInspector.LinkifierFormatter}
* @unrestricted
*/
WebInspector.Linkifier.DefaultFormatter = class {
/**
* @param {number=} maxLength
*/
constructor(maxLength) {
this._maxLength = maxLength;
this._formatLiveAnchor(anchor, uiLocation, liveLocation.isBlackboxed());
}

/**
* @override
* @param {!Element} anchor
* @param {!WebInspector.UILocation} uiLocation
* @param {boolean} isBlackboxed
*/
formatLiveAnchor(anchor, uiLocation, isBlackboxed) {
_formatLiveAnchor(anchor, uiLocation, isBlackboxed) {
var text = uiLocation.linkText();
text = text.replace(/([a-f0-9]{7})[a-f0-9]{13}[a-f0-9]*/g, '$1\u2026');
if (this._maxLength)
Expand All @@ -394,29 +360,9 @@ WebInspector.Linkifier.DefaultFormatter = class {
}
};

/**
* @unrestricted
*/
WebInspector.Linkifier.DefaultCSSFormatter = class extends WebInspector.Linkifier.DefaultFormatter {
constructor() {
super(WebInspector.Linkifier.DefaultCSSFormatter.MaxLengthForDisplayedURLs);
}

/**
* @override
* @param {!Element} anchor
* @param {!WebInspector.UILocation} uiLocation
* @param {boolean} isBlackboxed
*/
formatLiveAnchor(anchor, uiLocation, isBlackboxed) {
super.formatLiveAnchor(anchor, uiLocation, isBlackboxed);
anchor.classList.add('webkit-html-resource-link');
anchor.setAttribute('data-uncopyable', anchor.textContent);
anchor.textContent = '';
}
};

WebInspector.Linkifier.DefaultCSSFormatter.MaxLengthForDisplayedURLs = 30;
WebInspector.Linkifier._uiLocationSymbol = Symbol('uiLocation');
WebInspector.Linkifier._fallbackAnchorSymbol = Symbol('fallbackAnchor');
WebInspector.Linkifier._liveLocationSymbol = Symbol('liveLocation');

/**
* The maximum number of characters to display in a URL.
Expand Down
25 changes: 13 additions & 12 deletions front_end/console/ConsolePrompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ WebInspector.ConsolePrompt = class extends WebInspector.Widget {

this._editor.configureAutocomplete({
substituteRangeCallback: this._substituteRange.bind(this),
suggestionsCallback: this._wordsWithPrefix.bind(this),
suggestionsCallback: this._wordsWithQuery.bind(this),
captureEnter: true
});
this._editor.widget().element.addEventListener('keydown', this._editorKeyDown.bind(this), true);
Expand Down Expand Up @@ -201,10 +201,11 @@ WebInspector.ConsolePrompt = class extends WebInspector.Widget {

/**
* @param {string} prefix
* @param {boolean=} force
* @return {!WebInspector.SuggestBox.Suggestions}
*/
_historyCompletions(prefix) {
if (!this._addCompletionsFromHistory || !this._isCaretAtEndOfPrompt())
_historyCompletions(prefix, force) {
if (!this._addCompletionsFromHistory || !this._isCaretAtEndOfPrompt() || (!prefix && !force))
return [];
var result = [];
var text = this.text();
Expand Down Expand Up @@ -248,22 +249,22 @@ WebInspector.ConsolePrompt = class extends WebInspector.Widget {
}

/**
* @param {!WebInspector.TextRange} prefixRange
* @param {!WebInspector.TextRange} queryRange
* @param {!WebInspector.TextRange} substituteRange
* @param {boolean=} force
* @return {!Promise<!WebInspector.SuggestBox.Suggestions>}
*/
_wordsWithPrefix(prefixRange, substituteRange) {
var prefix = this._editor.text(prefixRange);
var before = this._editor.text(new WebInspector.TextRange(0, 0, prefixRange.startLine, prefixRange.startColumn));
var historyWords = this._historyCompletions(prefix);
return WebInspector.JavaScriptAutocomplete.completionsForTextInCurrentContext(before, prefix, true /* force */)
.then(innerWordsWithPrefix);

_wordsWithQuery(queryRange, substituteRange, force) {
var query = this._editor.text(queryRange);
var before = this._editor.text(new WebInspector.TextRange(0, 0, queryRange.startLine, queryRange.startColumn));
var historyWords = this._historyCompletions(query, force);
return WebInspector.JavaScriptAutocomplete.completionsForTextInCurrentContext(before, query, force)
.then(innerWordsWithQuery);
/**
* @param {!Array<string>} words
* @return {!WebInspector.SuggestBox.Suggestions}
*/
function innerWordsWithPrefix(words) {
function innerWordsWithQuery(words) {
return words.map(item => ({title: item})).concat(historyWords);
}
}
Expand Down
9 changes: 6 additions & 3 deletions front_end/console/ConsoleView.js
Original file line number Diff line number Diff line change
Expand Up @@ -754,8 +754,11 @@ WebInspector.ConsoleView = class extends WebInspector.VBox {
}
section.addAlternateKeys(keys, WebInspector.UIString('Clear console'));

section.addKey(shortcut.makeDescriptor(shortcut.Keys.Tab), WebInspector.UIString('Autocomplete common prefix'));
section.addKey(shortcut.makeDescriptor(shortcut.Keys.Right), WebInspector.UIString('Accept suggestion'));
keys = [
shortcut.makeDescriptor(shortcut.Keys.Tab),
shortcut.makeDescriptor(shortcut.Keys.Right)
];
section.addRelatedKeys(keys, WebInspector.UIString('Accept suggestion'));

var shortcutU = shortcut.makeDescriptor('u', WebInspector.KeyboardShortcut.Modifiers.Ctrl);
this._shortcuts[shortcutU.key] = this._clearPromptBackwards.bind(this);
Expand Down Expand Up @@ -1203,7 +1206,7 @@ WebInspector.ConsoleCommand = class extends WebInspector.ConsoleViewMessage {
this._contentElement = createElementWithClass('div', 'console-user-command');
this._contentElement.message = this;

this._formattedCommand = createElementWithClass('span', 'console-message-text source-code');
this._formattedCommand = createElementWithClass('span', 'source-code');
this._formattedCommand.textContent = this.text.replaceControlCharacters();
this._contentElement.appendChild(this._formattedCommand);

Expand Down
11 changes: 5 additions & 6 deletions front_end/console/ConsoleViewMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ WebInspector.ConsoleViewMessage = class {
_buildTableMessage(consoleMessage) {
var formattedMessage = createElement('span');
WebInspector.appendStyle(formattedMessage, 'components/objectValue.css');
formattedMessage.className = 'console-message-text source-code';
formattedMessage.className = 'source-code';
var anchorElement = this._buildMessageAnchor(consoleMessage);
if (anchorElement)
formattedMessage.appendChild(anchorElement);
Expand Down Expand Up @@ -174,7 +174,7 @@ WebInspector.ConsoleViewMessage = class {
if (flatValues.length) {
this._dataGrid = WebInspector.SortableDataGrid.create(columnNames, flatValues);

var formattedResult = createElement('span');
var formattedResult = createElementWithClass('span', 'console-message-text');
var tableElement = formattedResult.createChild('div', 'console-message-formatted-table');
var dataGridContainer = tableElement.createChild('span');
tableElement.appendChild(this._formatParameter(table, true, false));
Expand Down Expand Up @@ -227,7 +227,7 @@ WebInspector.ConsoleViewMessage = class {
messageElement = createElement('span');
if (consoleMessage.level === WebInspector.ConsoleMessage.MessageLevel.Error ||
consoleMessage.level === WebInspector.ConsoleMessage.MessageLevel.RevokedError) {
messageElement.createTextChildren(consoleMessage.request.requestMethod, ' ');
messageElement.createTextChild(consoleMessage.request.requestMethod + ' ');
messageElement.appendChild(WebInspector.Linkifier.linkifyUsingRevealer(
consoleMessage.request, consoleMessage.request.url, consoleMessage.request.url));
if (consoleMessage.request.failed)
Expand All @@ -247,10 +247,11 @@ WebInspector.ConsoleViewMessage = class {
var args = consoleMessage.parameters || [consoleMessage.messageText];
messageElement = this._format(args);
}
messageElement.classList.add('console-message-text');

var formattedMessage = createElement('span');
WebInspector.appendStyle(formattedMessage, 'components/objectValue.css');
formattedMessage.className = 'console-message-text source-code';
formattedMessage.className = 'source-code';

var anchorElement = this._buildMessageAnchor(consoleMessage);
if (anchorElement)
Expand Down Expand Up @@ -304,7 +305,6 @@ WebInspector.ConsoleViewMessage = class {
*/
_buildMessageWithStackTrace(consoleMessage, target, linkifier) {
var toggleElement = createElementWithClass('div', 'console-message-stack-trace-toggle');
var triangleElement = toggleElement.createChild('div', 'console-message-stack-trace-triangle');
var contentElement = toggleElement.createChild('div', 'console-message-stack-trace-wrapper');

var messageElement = this._buildMessage(consoleMessage);
Expand Down Expand Up @@ -335,7 +335,6 @@ WebInspector.ConsoleViewMessage = class {
}

clickableElement.addEventListener('click', toggleStackTrace, false);
triangleElement.addEventListener('click', toggleStackTrace, false);
if (consoleMessage.type === WebInspector.ConsoleMessage.MessageType.Trace)
expandStackTrace(true);

Expand Down
Loading

0 comments on commit 87aed61

Please sign in to comment.