Chromium Code Reviews| 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 return this._cssCompletions.indexOf(word) !== -1; | 2881 return this._cssCompletions.indexOf(word) !== -1; |
| 2882 } | 2882 } |
| 2883 | 2883 |
| 2884 /** | 2884 /** |
| 2885 * @param {!Element} proxyElement | 2885 * @param {!Element} proxyElement |
| 2886 * @param {!Range} wordRange | 2886 * @param {!Range} wordRange |
| 2887 * @param {boolean} force | 2887 * @param {boolean} force |
| 2888 * @param {function(!Array.<string>, number=)} completionsReadyCallback | 2888 * @param {function(!Array.<string>, number=)} completionsReadyCallback |
| 2889 */ | 2889 */ |
| 2890 _buildPropertyCompletions(proxyElement, wordRange, force, completionsReadyCall back) { | 2890 _buildPropertyCompletions(proxyElement, wordRange, force, completionsReadyCall back) { |
| 2891 var prefix = wordRange.toString().toLowerCase(); | 2891 var query = wordRange.toString().toLowerCase(); |
| 2892 if (!prefix && !force && (this._isEditingName || proxyElement.textContent.le ngth)) { | 2892 if (!query && !force && (this._isEditingName || proxyElement.textContent.len gth)) { |
| 2893 completionsReadyCallback([]); | 2893 completionsReadyCallback([]); |
| 2894 return; | 2894 return; |
| 2895 } | 2895 } |
| 2896 | 2896 |
| 2897 var results = this._cssCompletions.filter(completion => completion.startsWit h(prefix)); | 2897 var prefixResults = []; |
| 2898 if (!this._isEditingName && !results.length && prefix.length > 1 && '!import ant'.startsWith(prefix)) | 2898 var anywhereResults = []; |
| 2899 this._cssCompletions.forEach(filterCompletions); | |
| 2900 var results = prefixResults.concat(anywhereResults); | |
| 2901 | |
| 2902 if (!this._isEditingName && !results.length && query.length > 1 && '!importa nt'.startsWith(query)) | |
| 2899 results.push('!important'); | 2903 results.push('!important'); |
| 2900 var userEnteredText = wordRange.toString().replace('-', ''); | 2904 var userEnteredText = wordRange.toString().replace('-', ''); |
| 2901 if (userEnteredText && (userEnteredText === userEnteredText.toUpperCase())) { | 2905 if (userEnteredText && (userEnteredText === userEnteredText.toUpperCase())) { |
| 2902 for (var i = 0; i < results.length; ++i) | 2906 for (var i = 0; i < results.length; ++i) |
| 2903 results[i] = results[i].toUpperCase(); | 2907 results[i] = results[i].toUpperCase(); |
| 2904 } | 2908 } |
| 2905 var selectedIndex = this._isEditingName ? WebInspector.cssMetadata().mostUse dProperty(results) : 0; | 2909 var selectedIndex = this._isEditingName ? WebInspector.cssMetadata().mostUse dProperty(prefixResults) : 0; |
| 2906 completionsReadyCallback(results, selectedIndex); | 2910 completionsReadyCallback(results, selectedIndex); |
| 2911 | |
| 2912 /** | |
| 2913 * @param {string} completion | |
| 2914 */ | |
| 2915 function filterCompletions(completion) { | |
| 2916 if (completion.startsWith(query)) | |
|
lushnikov
2016/11/03 22:06:51
var index = indexof...
einbinder
2016/11/03 23:12:14
Done.
| |
| 2917 prefixResults.push(completion); | |
| 2918 else if (completion.indexOf(query) !== -1) | |
| 2919 anywhereResults.push(completion); | |
| 2920 } | |
| 2907 } | 2921 } |
| 2908 }; | 2922 }; |
| 2909 | 2923 |
| 2910 /** | 2924 /** |
| 2911 * @unrestricted | 2925 * @unrestricted |
| 2912 */ | 2926 */ |
| 2913 WebInspector.StylesSidebarPropertyRenderer = class { | 2927 WebInspector.StylesSidebarPropertyRenderer = class { |
| 2914 /** | 2928 /** |
| 2915 * @param {?WebInspector.CSSRule} rule | 2929 * @param {?WebInspector.CSSRule} rule |
| 2916 * @param {?WebInspector.DOMNode} node | 2930 * @param {?WebInspector.DOMNode} node |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3053 } | 3067 } |
| 3054 | 3068 |
| 3055 /** | 3069 /** |
| 3056 * @override | 3070 * @override |
| 3057 * @return {!WebInspector.ToolbarItem} | 3071 * @return {!WebInspector.ToolbarItem} |
| 3058 */ | 3072 */ |
| 3059 item() { | 3073 item() { |
| 3060 return this._button; | 3074 return this._button; |
| 3061 } | 3075 } |
| 3062 }; | 3076 }; |
| OLD | NEW |