| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Joseph Pecoraro | 3 * Copyright (C) 2009 Joseph Pecoraro |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 2870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2881 * @param {boolean=} force | 2881 * @param {boolean=} force |
| 2882 * @return {!Promise<!UI.SuggestBox.Suggestions>} | 2882 * @return {!Promise<!UI.SuggestBox.Suggestions>} |
| 2883 */ | 2883 */ |
| 2884 _buildPropertyCompletions(expression, query, force) { | 2884 _buildPropertyCompletions(expression, query, force) { |
| 2885 var lowerQuery = query.toLowerCase(); | 2885 var lowerQuery = query.toLowerCase(); |
| 2886 if (!query && !force && (this._isEditingName || expression)) | 2886 if (!query && !force && (this._isEditingName || expression)) |
| 2887 return Promise.resolve([]); | 2887 return Promise.resolve([]); |
| 2888 | 2888 |
| 2889 var prefixResults = []; | 2889 var prefixResults = []; |
| 2890 var anywhereResults = []; | 2890 var anywhereResults = []; |
| 2891 this._cssCompletions.forEach(filterCompletions); | 2891 this._cssCompletions.forEach(filterCompletions.bind(this)); |
| 2892 var results = prefixResults.concat(anywhereResults); | 2892 var results = prefixResults.concat(anywhereResults); |
| 2893 | 2893 |
| 2894 if (!this._isEditingName && !results.length && query.length > 1 && '!importa
nt'.startsWith(lowerQuery)) | 2894 if (!this._isEditingName && !results.length && query.length > 1 && '!importa
nt'.startsWith(lowerQuery)) |
| 2895 results.push({title: '!important'}); | 2895 results.push({title: '!important'}); |
| 2896 var userEnteredText = query.replace('-', ''); | 2896 var userEnteredText = query.replace('-', ''); |
| 2897 if (userEnteredText && (userEnteredText === userEnteredText.toUpperCase()))
{ | 2897 if (userEnteredText && (userEnteredText === userEnteredText.toUpperCase()))
{ |
| 2898 for (var i = 0; i < results.length; ++i) | 2898 for (var i = 0; i < results.length; ++i) |
| 2899 results[i].title = results[i].title.toUpperCase(); | 2899 results[i].title = results[i].title.toUpperCase(); |
| 2900 } | 2900 } |
| 2901 return Promise.resolve(results); | 2901 return Promise.resolve(results); |
| 2902 | 2902 |
| 2903 /** | 2903 /** |
| 2904 * @param {string} completion | 2904 * @param {string} completion |
| 2905 * @this {Elements.StylesSidebarPane.CSSPropertyPrompt} |
| 2905 */ | 2906 */ |
| 2906 function filterCompletions(completion) { | 2907 function filterCompletions(completion) { |
| 2907 var index = completion.indexOf(lowerQuery); | 2908 var index = completion.indexOf(lowerQuery); |
| 2908 if (index === 0) | 2909 if (index === 0) { |
| 2909 prefixResults.push({title: completion, priority: SDK.cssMetadata().prope
rtyUsageWeight(completion)}); | 2910 var priority = this._isEditingName ? SDK.cssMetadata().propertyUsageWeig
ht(completion) : 1; |
| 2910 else if (index > -1) | 2911 prefixResults.push({title: completion, priority: priority}); |
| 2912 } else if (index > -1) { |
| 2911 anywhereResults.push({title: completion}); | 2913 anywhereResults.push({title: completion}); |
| 2914 } |
| 2912 } | 2915 } |
| 2913 } | 2916 } |
| 2914 }; | 2917 }; |
| 2915 | 2918 |
| 2916 /** | 2919 /** |
| 2917 * @unrestricted | 2920 * @unrestricted |
| 2918 */ | 2921 */ |
| 2919 Elements.StylesSidebarPropertyRenderer = class { | 2922 Elements.StylesSidebarPropertyRenderer = class { |
| 2920 /** | 2923 /** |
| 2921 * @param {?SDK.CSSRule} rule | 2924 * @param {?SDK.CSSRule} rule |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3059 } | 3062 } |
| 3060 | 3063 |
| 3061 /** | 3064 /** |
| 3062 * @override | 3065 * @override |
| 3063 * @return {!UI.ToolbarItem} | 3066 * @return {!UI.ToolbarItem} |
| 3064 */ | 3067 */ |
| 3065 item() { | 3068 item() { |
| 3066 return this._button; | 3069 return this._button; |
| 3067 } | 3070 } |
| 3068 }; | 3071 }; |
| OLD | NEW |