| 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 2409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2420 context.originalName = this.nameElement.textContent; | 2420 context.originalName = this.nameElement.textContent; |
| 2421 context.originalValue = this.valueElement.textContent; | 2421 context.originalValue = this.valueElement.textContent; |
| 2422 } | 2422 } |
| 2423 this.property.name = name; | 2423 this.property.name = name; |
| 2424 this.property.value = value; | 2424 this.property.value = value; |
| 2425 this.nameElement.textContent = name; | 2425 this.nameElement.textContent = name; |
| 2426 this.valueElement.textContent = value; | 2426 this.valueElement.textContent = value; |
| 2427 this.nameElement.normalize(); | 2427 this.nameElement.normalize(); |
| 2428 this.valueElement.normalize(); | 2428 this.valueElement.normalize(); |
| 2429 | 2429 |
| 2430 this.editingCommitted(event.target.textContent, context, "forward"); | 2430 this._editingCommitted(event.target.textContent, context, "forward")
; |
| 2431 } | 2431 } |
| 2432 | 2432 |
| 2433 /** | 2433 /** |
| 2434 * @param {!WebInspector.StylePropertyTreeElement.Context} context | 2434 * @param {!WebInspector.StylePropertyTreeElement.Context} context |
| 2435 * @param {!Event} event | 2435 * @param {!Event} event |
| 2436 * @this {WebInspector.StylePropertyTreeElement} | 2436 * @this {WebInspector.StylePropertyTreeElement} |
| 2437 */ | 2437 */ |
| 2438 function blurListener(context, event) | 2438 function blurListener(context, event) |
| 2439 { | 2439 { |
| 2440 var treeElement = this._parentPane._mouseDownTreeElement; | 2440 var treeElement = this._parentPane._mouseDownTreeElement; |
| 2441 var moveDirection = ""; | 2441 var moveDirection = ""; |
| 2442 if (treeElement === this) { | 2442 if (treeElement === this) { |
| 2443 if (isEditingName && this._parentPane._mouseDownTreeElementIsVal
ue) | 2443 if (isEditingName && this._parentPane._mouseDownTreeElementIsVal
ue) |
| 2444 moveDirection = "forward"; | 2444 moveDirection = "forward"; |
| 2445 if (!isEditingName && this._parentPane._mouseDownTreeElementIsNa
me) | 2445 if (!isEditingName && this._parentPane._mouseDownTreeElementIsNa
me) |
| 2446 moveDirection = "backward"; | 2446 moveDirection = "backward"; |
| 2447 } | 2447 } |
| 2448 var text = event.target.textContent; | 2448 var text = event.target.textContent; |
| 2449 if (!context.isEditingName) | 2449 if (!context.isEditingName) |
| 2450 text = this.value || text; | 2450 text = this.value || text; |
| 2451 this.editingCommitted(text, context, moveDirection); | 2451 this._editingCommitted(text, context, moveDirection); |
| 2452 } | 2452 } |
| 2453 | 2453 |
| 2454 this._originalPropertyText = this.property.propertyText; | 2454 this._originalPropertyText = this.property.propertyText; |
| 2455 | 2455 |
| 2456 this._parentPane.setEditingStyle(true); | 2456 this._parentPane.setEditingStyle(true); |
| 2457 if (selectElement.parentElement) | 2457 if (selectElement.parentElement) |
| 2458 selectElement.parentElement.scrollIntoViewIfNeeded(false); | 2458 selectElement.parentElement.scrollIntoViewIfNeeded(false); |
| 2459 | 2459 |
| 2460 var applyItemCallback = !isEditingName ? this._applyFreeFlowStyleTextEdi
t.bind(this) : undefined; | 2460 var applyItemCallback = !isEditingName ? this._applyFreeFlowStyleTextEdi
t.bind(this) : undefined; |
| 2461 var cssCompletions = isEditingName ? WebInspector.cssMetadata().allPrope
rties() : WebInspector.cssMetadata().propertyValues(this.nameElement.textContent
); | 2461 var cssCompletions = isEditingName ? WebInspector.cssMetadata().allPrope
rties() : WebInspector.cssMetadata().propertyValues(this.nameElement.textContent
); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2505 event.preventDefault(); | 2505 event.preventDefault(); |
| 2506 } | 2506 } |
| 2507 | 2507 |
| 2508 if (result) { | 2508 if (result) { |
| 2509 switch (result) { | 2509 switch (result) { |
| 2510 case "cancel": | 2510 case "cancel": |
| 2511 this.editingCancelled(null, context); | 2511 this.editingCancelled(null, context); |
| 2512 break; | 2512 break; |
| 2513 case "forward": | 2513 case "forward": |
| 2514 case "backward": | 2514 case "backward": |
| 2515 this.editingCommitted(event.target.textContent, context, result)
; | 2515 this._editingCommitted(event.target.textContent, context, result
); |
| 2516 break; | 2516 break; |
| 2517 } | 2517 } |
| 2518 | 2518 |
| 2519 event.consume(); | 2519 event.consume(); |
| 2520 return; | 2520 return; |
| 2521 } | 2521 } |
| 2522 }, | 2522 }, |
| 2523 | 2523 |
| 2524 /** | 2524 /** |
| 2525 * @param {!WebInspector.StylePropertyTreeElement.Context} context | 2525 * @param {!WebInspector.StylePropertyTreeElement.Context} context |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2546 openQuote = ""; | 2546 openQuote = ""; |
| 2547 } | 2547 } |
| 2548 return !openQuote; | 2548 return !openQuote; |
| 2549 } | 2549 } |
| 2550 | 2550 |
| 2551 var keyChar = String.fromCharCode(event.charCode); | 2551 var keyChar = String.fromCharCode(event.charCode); |
| 2552 var isFieldInputTerminated = (context.isEditingName ? keyChar === ":" :
keyChar === ";" && shouldCommitValueSemicolon(event.target.textContent, event.ta
rget.selectionLeftOffset())); | 2552 var isFieldInputTerminated = (context.isEditingName ? keyChar === ":" :
keyChar === ";" && shouldCommitValueSemicolon(event.target.textContent, event.ta
rget.selectionLeftOffset())); |
| 2553 if (isFieldInputTerminated) { | 2553 if (isFieldInputTerminated) { |
| 2554 // Enter or colon (for name)/semicolon outside of string (for value)
. | 2554 // Enter or colon (for name)/semicolon outside of string (for value)
. |
| 2555 event.consume(true); | 2555 event.consume(true); |
| 2556 this.editingCommitted(event.target.textContent, context, "forward"); | 2556 this._editingCommitted(event.target.textContent, context, "forward")
; |
| 2557 return; | 2557 return; |
| 2558 } | 2558 } |
| 2559 }, | 2559 }, |
| 2560 | 2560 |
| 2561 /** | 2561 /** |
| 2562 * @param {!WebInspector.StylePropertyTreeElement.Context} context | 2562 * @param {!WebInspector.StylePropertyTreeElement.Context} context |
| 2563 * @param {!Event} event | 2563 * @param {!Event} event |
| 2564 */ | 2564 */ |
| 2565 _editingNameValueInput: function(context, event) | 2565 _editingNameValueInput: function(context, event) |
| 2566 { | 2566 { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2635 } while (target && target.inherited()); | 2635 } while (target && target.inherited()); |
| 2636 | 2636 |
| 2637 return target; | 2637 return target; |
| 2638 }, | 2638 }, |
| 2639 | 2639 |
| 2640 /** | 2640 /** |
| 2641 * @param {string} userInput | 2641 * @param {string} userInput |
| 2642 * @param {!WebInspector.StylePropertyTreeElement.Context} context | 2642 * @param {!WebInspector.StylePropertyTreeElement.Context} context |
| 2643 * @param {string} moveDirection | 2643 * @param {string} moveDirection |
| 2644 */ | 2644 */ |
| 2645 editingCommitted: function(userInput, context, moveDirection) | 2645 _editingCommitted: function(userInput, context, moveDirection) |
| 2646 { | 2646 { |
| 2647 this._removePrompt(); | 2647 this._removePrompt(); |
| 2648 this.editingEnded(context); | 2648 this.editingEnded(context); |
| 2649 var isEditingName = context.isEditingName; | 2649 var isEditingName = context.isEditingName; |
| 2650 | 2650 |
| 2651 // Determine where to move to before making changes | 2651 // Determine where to move to before making changes |
| 2652 var createNewProperty, moveToPropertyName, moveToSelector; | 2652 var createNewProperty, moveToPropertyName, moveToSelector; |
| 2653 var isDataPasted = "originalName" in context; | 2653 var isDataPasted = "originalName" in context; |
| 2654 var isDirtyViaPaste = isDataPasted && (this.nameElement.textContent !==
context.originalName || this.valueElement.textContent !== context.originalValue)
; | 2654 var isDirtyViaPaste = isDataPasted && (this.nameElement.textContent !==
context.originalName || this.valueElement.textContent !== context.originalValue)
; |
| 2655 var isPropertySplitPaste = isDataPasted && isEditingName && this.valueEl
ement.textContent !== context.originalValue; | 2655 var isPropertySplitPaste = isDataPasted && isEditingName && this.valueEl
ement.textContent !== context.originalValue; |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3186 | 3186 |
| 3187 /** | 3187 /** |
| 3188 * @override | 3188 * @override |
| 3189 * @return {!WebInspector.ToolbarItem} | 3189 * @return {!WebInspector.ToolbarItem} |
| 3190 */ | 3190 */ |
| 3191 item: function() | 3191 item: function() |
| 3192 { | 3192 { |
| 3193 return this._button; | 3193 return this._button; |
| 3194 } | 3194 } |
| 3195 } | 3195 } |
| OLD | NEW |