Changeset 99407 in webkit
- Timestamp:
- Nov 7, 2011, 4:50:02 AM (15 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
-
ChangeLog (modified) (1 diff)
-
inspector/front-end/ConsoleView.js (modified) (2 diffs)
-
inspector/front-end/StylesSidebarPane.js (modified) (6 diffs)
-
inspector/front-end/TextPrompt.js (modified) (8 diffs)
-
inspector/front-end/inspector.css (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r99405 r99407 1 2011-11-07 Alexander Pavlov <apavlov@chromium.org> 2 3 Web Inspector: autocomplete combobox for Styles sidebar and Console. 4 https://bugs.webkit.org/show_bug.cgi?id=65511 5 6 Reviewed by Pavel Feldman. 7 8 * inspector/front-end/ConsoleView.js: 9 (WebInspector.ConsoleView): 10 * inspector/front-end/StylesSidebarPane.js: 11 (WebInspector.StylePropertyTreeElement.prototype): 12 (): 13 * inspector/front-end/TextPrompt.js: 14 (WebInspector.TextPrompt): 15 (WebInspector.TextPrompt.prototype.setSuggestBoxEnabled): 16 (WebInspector.TextPrompt.prototype._attachInternal): 17 (WebInspector.TextPrompt.prototype.applySuggestion): 18 (WebInspector.TextPrompt.prototype.acceptSuggestion): 19 (WebInspector.TextPromptWithHistory): 20 * inspector/front-end/inspector.css: 21 (.suggest-box.generic-suggest): 22 (.suggest-box.generic-suggest.above-anchor): 23 (.suggest-box.generic-suggest .content): 24 1 25 2011-11-07 Pavel Feldman <pfeldman@chromium.org> 2 26 -
trunk/Source/WebCore/inspector/front-end/ConsoleView.js
r99159 r99407 113 113 114 114 this.prompt = new WebInspector.TextPromptWithHistory(this.completions.bind(this), ExpressionStopCharacters + "."); 115 this.prompt.setSuggestBoxEnabled("generic-suggest"); 115 116 this.prompt.attach(this.promptElement); 116 117 this.prompt.setHistoryData(WebInspector.settings.consoleHistory.get()); … … 353 354 expressionString = expressionString.substr(0, lastIndex); 354 355 355 if (!expressionString && !prefix) { 356 completionsReadyCallback([]); 357 return; 358 } 359 360 if (parseInt(expressionString, 10) == expressionString) { 356 if (expressionString && parseInt(expressionString, 10) == expressionString) { 361 357 // User is entering float value, do not suggest anything. 362 358 completionsReadyCallback([]); -
trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js
r99164 r99407 108 108 } 109 109 110 WebInspector.StylesSidebarPane.StyleValueDelimiters = " \ t\n\"':;,/()";110 WebInspector.StylesSidebarPane.StyleValueDelimiters = " \xA0\t\n\"':;,/()"; 111 111 112 112 … … 1873 1873 selectElement.parentElement.scrollIntoViewIfNeeded(false); 1874 1874 1875 var applyItemCallback = !isEditingName ? this._applyFreeFlowStyleTextEdit.bind(this, true) : undefined; 1875 1876 this._prompt = new WebInspector.StylesSidebarPane.CSSPropertyPrompt(isEditingName ? WebInspector.CSSCompletions.cssNameCompletions : WebInspector.CSSKeywordCompletions.forProperty(this.nameElement.textContent), this, isEditingName); 1877 if (applyItemCallback) { 1878 this._prompt.addEventListener(WebInspector.TextPrompt.Events.ItemApplied, applyItemCallback, this); 1879 this._prompt.addEventListener(WebInspector.TextPrompt.Events.ItemAccepted, applyItemCallback, this); 1880 } 1876 1881 var proxyElement = this._prompt.attachAndStartEditing(selectElement, blurListener.bind(this, context)); 1877 1882 … … 2200 2205 * @constructor 2201 2206 * @extends {WebInspector.TextPrompt} 2207 * @param {function(*)=} acceptCallback 2202 2208 */ 2203 WebInspector.StylesSidebarPane.CSSPropertyPrompt = function(cssCompletions, sidebarPane, isEditingName )2209 WebInspector.StylesSidebarPane.CSSPropertyPrompt = function(cssCompletions, sidebarPane, isEditingName, acceptCallback) 2204 2210 { 2211 // Use the same callback both for applyItemCallback and acceptItemCallback. 2205 2212 WebInspector.TextPrompt.call(this, this._buildPropertyCompletions.bind(this), WebInspector.StylesSidebarPane.StyleValueDelimiters); 2213 this.setSuggestBoxEnabled("generic-suggest"); 2206 2214 this._cssCompletions = cssCompletions; 2207 2215 this._sidebarPane = sidebarPane; … … 2223 2231 break; 2224 2232 case "U+0009": 2225 this.acceptAutoComplete(); 2226 return; 2233 if (this.isSuggestBoxVisible()) { 2234 this._suggestBox.acceptSuggestion(); 2235 return !this._isEditingName; 2236 } 2237 return this.acceptAutoComplete(); 2227 2238 } 2228 2239 … … 2232 2243 _handleNameOrValueUpDown: function(event) 2233 2244 { 2245 // Handle numeric value increment/decrement only at this point. 2234 2246 if (!this._isEditingName && this._handleUpOrDownValue(event)) 2235 2247 return true; 2236 2248 2237 var reverse = event.keyIdentifier === "Up"; 2238 if (this.autoCompleteElement) 2239 this.complete(false, true, reverse); // Accept the current suggestion, if any. 2240 else { 2241 // Select the word suffix to affect it when computing the subsequent suggestion. 2242 this._selectCurrentWordSuffix(); 2243 } 2244 2245 this.complete(false, true, reverse); // Actually increment/decrement the suggestion. 2246 return true; 2249 return false; 2247 2250 }, 2248 2251 … … 2314 2317 }, 2315 2318 2316 _selectCurrentWordSuffix: function()2317 {2318 var selection = window.getSelection();2319 if (!selection.rangeCount)2320 return;2321 2322 var selectionRange = selection.getRangeAt(0);2323 if (!selectionRange.commonAncestorContainer.isDescendant(this._element))2324 return;2325 var wordSuffixRange = selectionRange.startContainer.rangeOfWord(selectionRange.startOffset, WebInspector.StylesSidebarPane.StyleValueDelimiters, this._element, "forward");2326 if (!wordSuffixRange.toString())2327 return;2328 selection.removeAllRanges();2329 selection.addRange(wordSuffixRange);2330 },2331 2332 2319 _buildPropertyCompletions: function(wordRange, force, completionsReadyCallback) 2333 2320 { -
trunk/Source/WebCore/inspector/front-end/TextPrompt.js
r99159 r99407 30 30 /** 31 31 * @constructor 32 * @extends WebInspector.Object 32 33 * @param {function(Range, boolean, function(*))} completions 33 34 * @param {string} stopCharacters 34 * @param {WebInspector.TextPrompt.SuggestBoxConfig=} suggestBoxConfig35 35 */ 36 WebInspector.TextPrompt = function(completions, stopCharacters , suggestBoxConfig)36 WebInspector.TextPrompt = function(completions, stopCharacters) 37 37 { 38 38 /** … … 42 42 this._loadCompletions = completions; 43 43 this._completionStopCharacters = stopCharacters; 44 this._suggestBoxConfig = suggestBoxConfig;45 44 this._suggestForceable = true; 46 45 } 47 46 47 WebInspector.TextPrompt.Events = { 48 ItemApplied: "text-prompt-item-applied", 49 ItemAccepted: "text-prompt-item-accepted" 50 }; 51 48 52 WebInspector.TextPrompt.prototype = { 49 53 get proxyElement() … … 55 59 { 56 60 this._suggestForceable = x; 61 }, 62 63 setSuggestBoxEnabled: function(className) 64 { 65 this._suggestBoxClassName = className; 57 66 }, 58 67 … … 100 109 this._element.addEventListener("selectstart", this._selectStart.bind(this), false); 101 110 102 if (this._suggestBoxConfig) { 103 this._suggestBox = new WebInspector.TextPrompt.SuggestBox(this, this._element, this._suggestBoxConfig.styleClass); 104 this._applyCallback = this._suggestBoxConfig.applyItemCallback; 105 this._acceptCallback = this._suggestBoxConfig.acceptItemCallback; 106 } 111 if (typeof this._suggestBoxClassName === "string") 112 this._suggestBox = new WebInspector.TextPrompt.SuggestBox(this, this._element, this._suggestBoxClassName); 113 107 114 return this.proxyElement; 108 115 }, … … 483 490 selection.removeAllRanges(); 484 491 selection.addRange(finalSelectionRange); 485 if (isIntermediateSuggestion && this._applyCallback)486 this. _applyCallback();492 if (isIntermediateSuggestion) 493 this.dispatchEventToListeners(WebInspector.TextPrompt.Events.ItemApplied, { itemText: completionText }); 487 494 }, 488 495 … … 492 499 if (this._suggestBox) 493 500 this._suggestBox.hide(); 494 if (this._acceptCallback) 495 this._acceptCallback(); 501 this.dispatchEventToListeners(WebInspector.TextPrompt.Events.ItemAccepted); 496 502 }, 497 503 … … 625 631 } 626 632 627 /** 628 * @constructor 629 * @param {string=} styleClass 630 * @param {function(*)=} applyItemCallback 631 * @param {function(*)=} acceptItemCallback 632 */ 633 WebInspector.TextPrompt.SuggestBoxConfig = function(styleClass, applyItemCallback, acceptItemCallback) 634 { 635 this.styleClass = styleClass; 636 this.applyItemCallback = applyItemCallback; 637 this.acceptItemCallback = acceptItemCallback; 638 } 633 WebInspector.TextPrompt.prototype.__proto__ = WebInspector.Object.prototype; 639 634 640 635 /** … … 643 638 * @param {function(Range, boolean, function(*))} completions 644 639 * @param {string} stopCharacters 645 * @param {WebInspector.TextPrompt.SuggestBoxConfig=} suggestBoxConfig646 640 */ 647 WebInspector.TextPromptWithHistory = function(completions, stopCharacters , suggestBoxConfig)641 WebInspector.TextPromptWithHistory = function(completions, stopCharacters) 648 642 { 649 WebInspector.TextPrompt.call(this, completions, stopCharacters , suggestBoxConfig);643 WebInspector.TextPrompt.call(this, completions, stopCharacters); 650 644 651 645 /** -
trunk/Source/WebCore/inspector/front-end/inspector.css
r99159 r99407 2518 2518 } 2519 2519 2520 /* Generic suggest box style */ 2521 2522 .suggest-box.generic-suggest { 2523 border-radius: 0 5px 5px 5px; 2524 margin-left: -1px; 2525 border-color: rgb(66%, 66%, 66%); 2526 -webkit-box-shadow: 8px 8px 6px rgba(40, 40, 40, 0.40); 2527 } 2528 2529 .suggest-box.generic-suggest.above-anchor { 2530 border-radius: 5px 5px 5px 0; 2531 -webkit-box-shadow: 8px -8px 6px rgba(40, 40, 40, 0.40); 2532 } 2533 2534 .suggest-box.generic-suggest .content { 2535 margin: 3px; 2536 } 2537 2520 2538 /* Custom popup scrollers */ 2521 2539
Note:
See TracChangeset
for help on using the changeset viewer.