| 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 2326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2337 text = this.value || text; | 2337 text = this.value || text; |
| 2338 this._editingCommitted(text, context, moveDirection); | 2338 this._editingCommitted(text, context, moveDirection); |
| 2339 } | 2339 } |
| 2340 | 2340 |
| 2341 this._originalPropertyText = this.property.propertyText; | 2341 this._originalPropertyText = this.property.propertyText; |
| 2342 | 2342 |
| 2343 this._parentPane.setEditingStyle(true); | 2343 this._parentPane.setEditingStyle(true); |
| 2344 if (selectElement.parentElement) | 2344 if (selectElement.parentElement) |
| 2345 selectElement.parentElement.scrollIntoViewIfNeeded(false); | 2345 selectElement.parentElement.scrollIntoViewIfNeeded(false); |
| 2346 | 2346 |
| 2347 var applyItemCallback = !isEditingName ? this._applyFreeFlowStyleTextEdit.bi
nd(this) : undefined; | |
| 2348 var cssCompletions = []; | 2347 var cssCompletions = []; |
| 2349 if (isEditingName) { | 2348 if (isEditingName) { |
| 2350 cssCompletions = SDK.cssMetadata().allProperties(); | 2349 cssCompletions = SDK.cssMetadata().allProperties(); |
| 2351 cssCompletions = | 2350 cssCompletions = |
| 2352 cssCompletions.filter(property => SDK.cssMetadata().isSVGProperty(prop
erty) === this.node().isSVGNode()); | 2351 cssCompletions.filter(property => SDK.cssMetadata().isSVGProperty(prop
erty) === this.node().isSVGNode()); |
| 2353 } else { | 2352 } else { |
| 2354 cssCompletions = SDK.cssMetadata().propertyValues(this.nameElement.textCon
tent); | 2353 cssCompletions = SDK.cssMetadata().propertyValues(this.nameElement.textCon
tent); |
| 2355 } | 2354 } |
| 2356 var cssVariables = this._matchedStyles.cssVariables().sort(String.naturalOrd
erComparator); | 2355 var cssVariables = this._matchedStyles.cssVariables().sort(String.naturalOrd
erComparator); |
| 2357 | 2356 |
| 2358 this._prompt = new Elements.StylesSidebarPane.CSSPropertyPrompt(cssCompletio
ns, cssVariables, this, isEditingName); | 2357 this._prompt = new Elements.StylesSidebarPane.CSSPropertyPrompt(cssCompletio
ns, cssVariables, this, isEditingName); |
| 2359 this._prompt.setAutocompletionTimeout(0); | 2358 this._prompt.setAutocompletionTimeout(0); |
| 2360 if (applyItemCallback) { | 2359 |
| 2361 this._prompt.addEventListener(UI.TextPrompt.Events.ItemApplied, applyItemC
allback, this); | 2360 // Do not live-edit "content" property of pseudo elements. crbug.com/433889 |
| 2362 this._prompt.addEventListener(UI.TextPrompt.Events.ItemAccepted, applyItem
Callback, this); | 2361 if (!isEditingName && (!this._parentPane.node().pseudoType() || this.name !=
= 'content')) |
| 2363 } | 2362 this._prompt.on(UI.TextPrompt.TextChangedEvent, this._applyFreeFlowStyleTe
xtEdit.bind(this)); |
| 2363 |
| 2364 var proxyElement = this._prompt.attachAndStartEditing(selectElement, blurLis
tener.bind(this, context)); | 2364 var proxyElement = this._prompt.attachAndStartEditing(selectElement, blurLis
tener.bind(this, context)); |
| 2365 this._navigateToSource(selectElement, true); | 2365 this._navigateToSource(selectElement, true); |
| 2366 | 2366 |
| 2367 proxyElement.addEventListener('keydown', this._editingNameValueKeyDown.bind(
this, context), false); | 2367 proxyElement.addEventListener('keydown', this._editingNameValueKeyDown.bind(
this, context), false); |
| 2368 proxyElement.addEventListener('keypress', this._editingNameValueKeyPress.bin
d(this, context), false); | 2368 proxyElement.addEventListener('keypress', this._editingNameValueKeyPress.bin
d(this, context), false); |
| 2369 proxyElement.addEventListener('input', this._editingNameValueInput.bind(this
, context), false); | |
| 2370 if (isEditingName) | 2369 if (isEditingName) |
| 2371 proxyElement.addEventListener('paste', pasteHandler.bind(this, context), f
alse); | 2370 proxyElement.addEventListener('paste', pasteHandler.bind(this, context), f
alse); |
| 2372 | 2371 |
| 2373 selectElement.getComponentSelection().setBaseAndExtent(selectElement, 0, sel
ectElement, 1); | 2372 selectElement.getComponentSelection().setBaseAndExtent(selectElement, 0, sel
ectElement, 1); |
| 2374 } | 2373 } |
| 2375 | 2374 |
| 2376 /** | 2375 /** |
| 2377 * @param {!Elements.StylePropertyTreeElement.Context} context | 2376 * @param {!Elements.StylePropertyTreeElement.Context} context |
| 2378 * @param {!Event} event | 2377 * @param {!Event} event |
| 2379 */ | 2378 */ |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2448 keyChar === ';' && | 2447 keyChar === ';' && |
| 2449 shouldCommitValueSemicolon(event.target.textContent, event.targ
et.selectionLeftOffset())); | 2448 shouldCommitValueSemicolon(event.target.textContent, event.targ
et.selectionLeftOffset())); |
| 2450 if (isFieldInputTerminated) { | 2449 if (isFieldInputTerminated) { |
| 2451 // Enter or colon (for name)/semicolon outside of string (for value). | 2450 // Enter or colon (for name)/semicolon outside of string (for value). |
| 2452 event.consume(true); | 2451 event.consume(true); |
| 2453 this._editingCommitted(event.target.textContent, context, 'forward'); | 2452 this._editingCommitted(event.target.textContent, context, 'forward'); |
| 2454 return; | 2453 return; |
| 2455 } | 2454 } |
| 2456 } | 2455 } |
| 2457 | 2456 |
| 2458 /** | |
| 2459 * @param {!Elements.StylePropertyTreeElement.Context} context | |
| 2460 * @param {!Event} event | |
| 2461 */ | |
| 2462 _editingNameValueInput(context, event) { | |
| 2463 // Do not live-edit "content" property of pseudo elements. crbug.com/433889 | |
| 2464 if (!context.isEditingName && (!this._parentPane.node().pseudoType() || this
.name !== 'content')) | |
| 2465 this._applyFreeFlowStyleTextEdit(); | |
| 2466 } | |
| 2467 | |
| 2468 _applyFreeFlowStyleTextEdit() { | 2457 _applyFreeFlowStyleTextEdit() { |
| 2469 var valueText = this._prompt.textWithCurrentSuggestion(); | 2458 var valueText = this._prompt.textWithCurrentSuggestion(); |
| 2470 if (valueText.indexOf(';') === -1) | 2459 if (valueText.indexOf(';') === -1) |
| 2471 this.applyStyleText(this.nameElement.textContent + ': ' + valueText, false
); | 2460 this.applyStyleText(this.nameElement.textContent + ': ' + valueText, false
); |
| 2472 } | 2461 } |
| 2473 | 2462 |
| 2474 kickFreeFlowStyleEditForTest() { | 2463 kickFreeFlowStyleEditForTest() { |
| 2475 this._applyFreeFlowStyleTextEdit(); | 2464 this._applyFreeFlowStyleTextEdit(); |
| 2476 } | 2465 } |
| 2477 | 2466 |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3091 } | 3080 } |
| 3092 | 3081 |
| 3093 /** | 3082 /** |
| 3094 * @override | 3083 * @override |
| 3095 * @return {!UI.ToolbarItem} | 3084 * @return {!UI.ToolbarItem} |
| 3096 */ | 3085 */ |
| 3097 item() { | 3086 item() { |
| 3098 return this._button; | 3087 return this._button; |
| 3099 } | 3088 } |
| 3100 }; | 3089 }; |
| OLD | NEW |