Changeset 85324 in webkit
- Timestamp:
- Apr 29, 2011 8:35:14 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r85321 r85324 1 2011-04-29 Pavel Feldman <pfeldman@google.com> 2 3 Reviewed by Yury Semikhatsky. 4 5 Web Inspector: CSS editing breaks when entering "color: rgb(1" 6 https://bugs.webkit.org/show_bug.cgi?id=59789 7 8 * inspector/styles/styles-add-invalid-property-expected.txt: Added. 9 * inspector/styles/styles-add-invalid-property.html: Added. 10 * inspector/styles/styles-cancel-editing-expected.txt: Added. 11 * inspector/styles/styles-cancel-editing.html: Added. 12 * inspector/styles/styles-commit-editing-expected.txt: Added. 13 * inspector/styles/styles-commit-editing.html: Added. 14 1 15 2011-04-29 Pavel Podivilov <podivilov@chromium.org> 2 16 -
trunk/Source/WebCore/ChangeLog
r85323 r85324 1 2011-04-29 Pavel Feldman <pfeldman@google.com> 2 3 Reviewed by Yury Semikhatsky. 4 5 Web Inspector: CSS editing breaks when entering "color: rgb(1" 6 https://bugs.webkit.org/show_bug.cgi?id=59789 7 8 Tests: inspector/styles/styles-add-invalid-property.html 9 inspector/styles/styles-cancel-editing.html 10 inspector/styles/styles-commit-editing.html 11 12 * inspector/front-end/CSSStyleModel.js: 13 (WebInspector.CSSProperty.prototype.setText.callback): 14 (WebInspector.CSSProperty.prototype.setText): 15 * inspector/front-end/StylesSidebarPane.js: 16 (WebInspector.StylePropertyTreeElement.prototype.selectElement): 17 (WebInspector.StylePropertyTreeElement.prototype): 18 (WebInspector.StylePropertyTreeElement.prototype.styleText.updateInterface.majorChange.isRevert.originalPropertyText): 19 * inspector/front-end/inspector.js: 20 (WebInspector.startEditing.defaultFinishHandler): 21 (WebInspector.startEditing.keyDownEventListener): 22 (WebInspector.startEditing): 23 1 24 2011-04-29 Tor Arne Vestbø <tor.arne.vestbo@nokia.com> 2 25 -
trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js
r84909 r85324 533 533 WebInspector.cssModel._fireStyleSheetChanged(style.id.styleSheetId, majorChange, userCallback ? userCallback.bind(this, style) : null); 534 534 } else { 535 console.error(JSON.stringify(error));536 535 if (userCallback) 537 536 userCallback(null); -
trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js
r85034 r85324 1642 1642 event.preventDefault(); 1643 1643 return "move-forward"; 1644 } else if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Esc.code )1644 } else if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Esc.code || event.keyIdentifier === "U+001B") 1645 1645 return "cancel"; 1646 1646 else if (!isEditingName && this._newProperty && event.keyCode === WebInspector.KeyboardShortcut.Keys.Backspace.code) { … … 1680 1680 } 1681 1681 1682 delete this.originalPropertyText; 1682 1683 WebInspector.panels.elements.startEditingStyle(); 1683 1684 WebInspector.startEditing(selectElement, { … … 1703 1704 }, 1704 1705 1705 _applyFreeFlowStyleTextEdit: function( )1706 _applyFreeFlowStyleTextEdit: function(now) 1706 1707 { 1707 1708 if (this._applyFreeFlowStyleTextEditTimer) … … 1712 1713 this.applyStyleText(this.nameElement.textContent + ": " + this.valueElement.textContent); 1713 1714 } 1714 this._applyFreeFlowStyleTextEditTimer = setTimeout(apply.bind(this), 100); 1715 if (now) 1716 apply.call(this); 1717 else 1718 this._applyFreeFlowStyleTextEditTimer = setTimeout(apply.bind(this), 100); 1719 }, 1720 1721 kickFreeFlowStyleEditForTest: function() 1722 { 1723 this._applyFreeFlowStyleTextEdit(true); 1715 1724 }, 1716 1725 … … 1769 1778 event.handled = true; 1770 1779 event.preventDefault(); 1771 1772 if (!("originalPropertyText" in this)) {1773 // Remember the rule's original CSS text on [Page](Up|Down), so it can be restored1774 // if the editing is canceled.1775 this.originalPropertyText = this.property.propertyText;1776 }1777 1780 1778 1781 // Synthesize property text disregarding any comments, custom whitespace etc. … … 1796 1799 editedElement.parentElement.removeStyleClass("child-editing"); 1797 1800 1798 delete this.originalPropertyText;1799 1801 WebInspector.panels.elements.endEditingStyle(); 1800 1802 }, … … 1803 1805 { 1804 1806 this._removePrompt(); 1805 if ("originalPropertyText" in this) 1806 this.applyStyleText(this.originalPropertyText, true); 1807 else { 1807 this._revertStyleUponEditingCanceled(this.originalPropertyText); 1808 // This should happen last, as it clears the info necessary to restore the property value after [Page]Up/Down changes. 1809 this.editingEnded(context); 1810 }, 1811 1812 _revertStyleUponEditingCanceled: function(originalPropertyText) 1813 { 1814 if (typeof originalPropertyText === "string") { 1815 delete this.originalPropertyText; 1816 this.applyStyleText(originalPropertyText, true, false, true); 1817 } else { 1808 1818 if (this._newProperty) 1809 1819 this.treeOutline.removeChild(this); … … 1811 1821 this.updateTitle(); 1812 1822 } 1813 1814 // This should happen last, as it clears the info necessary to restore the property value after [Page]Up/Down changes. 1815 this.editingEnded(context); 1816 }, 1823 }, 1817 1824 1818 1825 editingCommitted: function(element, userInput, previousContent, context, moveDirection) … … 1857 1864 propertyText = this.nameElement.textContent + ": " + userInput; 1858 1865 } 1859 this.applyStyleText(propertyText, true );1866 this.applyStyleText(propertyText, true, true); 1860 1867 } else { 1861 1868 if (!isDataPasted && !this._newProperty) … … 1928 1935 }, 1929 1936 1930 _hasBeen AppliedToPageViaUpDown: function()1937 _hasBeenModifiedIncrementally: function() 1931 1938 { 1932 1939 // New properties applied via up/down have an originalPropertyText and will be deleted later 1933 1940 // on, if cancelled, when the empty string gets applied as their style text. 1934 return ("originalPropertyText" in this); 1935 }, 1936 1937 applyStyleText: function(styleText, updateInterface) 1938 { 1941 return typeof this.originalPropertyText === "string"; 1942 }, 1943 1944 applyStyleText: function(styleText, updateInterface, majorChange, isRevert) 1945 { 1946 // Leave a way to cancel editing after incremental changes. 1947 if (!isRevert && !updateInterface && !this._hasBeenModifiedIncrementally()) { 1948 // Remember the rule's original CSS text on [Page](Up|Down), so it can be restored 1949 // if the editing is canceled. 1950 this.originalPropertyText = this.property.propertyText; 1951 } 1952 1939 1953 var section = this.treeOutline.section; 1940 1954 var elementsPanel = WebInspector.panels.elements; 1941 1955 styleText = styleText.replace(/\s/g, " ").trim(); // Replace with whitespace. 1942 1956 var styleTextLength = styleText.length; 1943 if (!styleTextLength && updateInterface && this._newProperty && !this._hasBeenAppliedToPageViaUpDown()) {1957 if (!styleTextLength && updateInterface && !isRevert && this._newProperty && !this._hasBeenModifiedIncrementally()) { 1944 1958 // The user deleted everything and never applied a new property value via Up/Down scrolling, so remove the tree element and update. 1945 1959 this.parent.removeChild(this); … … 1948 1962 } 1949 1963 1950 function callback( newStyle)1964 function callback(originalPropertyText, newStyle) 1951 1965 { 1952 1966 if (!newStyle) { 1953 // The user typed something, but it didn't parse. Just abort and restore 1954 // the original title for this property. If this was a new attribute and 1955 // we couldn't parse, then just remove it. 1956 if (this._newProperty) { 1957 this.parent.removeChild(this); 1958 return; 1967 if (updateInterface) { 1968 // It did not apply, cancel editing. 1969 this._revertStyleUponEditingCanceled(originalPropertyText); 1959 1970 } 1960 if (updateInterface)1961 this.updateTitle();1962 1971 return; 1963 1972 } … … 1978 1987 if (styleText.length && !/;\s*$/.test(styleText)) 1979 1988 styleText += ";"; 1980 this.property.setText(styleText, updateInterface, callback.bind(this));1989 this.property.setText(styleText, majorChange, callback.bind(this, this.originalPropertyText)); 1981 1990 } 1982 1991 } -
trunk/Source/WebCore/inspector/front-end/inspector.js
r85312 r85324 1520 1520 if (isEnterKey(event) && (event.isMetaOrCtrlForTest || !config.multiline || isMetaOrCtrl)) 1521 1521 return "commit"; 1522 else if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Esc.code )1522 else if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Esc.code || event.keyIdentifier === "U+001B") 1523 1523 return "cancel"; 1524 1524 else if (event.keyIdentifier === "U+0009") // Tab key
Note: See TracChangeset
for help on using the changeset viewer.