| 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 var index = completion.indexOf(query); |
| 2917 if (index === 0) |
| 2918 prefixResults.push(completion); |
| 2919 else if (index > -1) |
| 2920 anywhereResults.push(completion); |
| 2921 } |
| 2907 } | 2922 } |
| 2908 }; | 2923 }; |
| 2909 | 2924 |
| 2910 /** | 2925 /** |
| 2911 * @unrestricted | 2926 * @unrestricted |
| 2912 */ | 2927 */ |
| 2913 WebInspector.StylesSidebarPropertyRenderer = class { | 2928 WebInspector.StylesSidebarPropertyRenderer = class { |
| 2914 /** | 2929 /** |
| 2915 * @param {?WebInspector.CSSRule} rule | 2930 * @param {?WebInspector.CSSRule} rule |
| 2916 * @param {?WebInspector.DOMNode} node | 2931 * @param {?WebInspector.DOMNode} node |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3053 } | 3068 } |
| 3054 | 3069 |
| 3055 /** | 3070 /** |
| 3056 * @override | 3071 * @override |
| 3057 * @return {!WebInspector.ToolbarItem} | 3072 * @return {!WebInspector.ToolbarItem} |
| 3058 */ | 3073 */ |
| 3059 item() { | 3074 item() { |
| 3060 return this._button; | 3075 return this._button; |
| 3061 } | 3076 } |
| 3062 }; | 3077 }; |
| OLD | NEW |