Changeset 85324 in webkit


Ignore:
Timestamp:
Apr 29, 2011 8:35:14 AM (13 years ago)
Author:
pfeldman@chromium.org
Message:

2011-04-29 Pavel Feldman <pfeldman@google.com>

Reviewed by Yury Semikhatsky.

Web Inspector: CSS editing breaks when entering "color: rgb(1"
https://bugs.webkit.org/show_bug.cgi?id=59789

  • inspector/styles/styles-add-invalid-property-expected.txt: Added.
  • inspector/styles/styles-add-invalid-property.html: Added.
  • inspector/styles/styles-cancel-editing-expected.txt: Added.
  • inspector/styles/styles-cancel-editing.html: Added.
  • inspector/styles/styles-commit-editing-expected.txt: Added.
  • inspector/styles/styles-commit-editing.html: Added.

2011-04-29 Pavel Feldman <pfeldman@google.com>

Reviewed by Yury Semikhatsky.

Web Inspector: CSS editing breaks when entering "color: rgb(1"
https://bugs.webkit.org/show_bug.cgi?id=59789

Tests: inspector/styles/styles-add-invalid-property.html

inspector/styles/styles-cancel-editing.html
inspector/styles/styles-commit-editing.html

  • inspector/front-end/CSSStyleModel.js: (WebInspector.CSSProperty.prototype.setText.callback): (WebInspector.CSSProperty.prototype.setText):
  • inspector/front-end/StylesSidebarPane.js: (WebInspector.StylePropertyTreeElement.prototype.selectElement): (WebInspector.StylePropertyTreeElement.prototype): (WebInspector.StylePropertyTreeElement.prototype.styleText.updateInterface.majorChange.isRevert.originalPropertyText):
  • inspector/front-end/inspector.js: (WebInspector.startEditing.defaultFinishHandler): (WebInspector.startEditing.keyDownEventListener): (WebInspector.startEditing):
Location:
trunk
Files:
6 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r85321 r85324  
     12011-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
    1152011-04-29  Pavel Podivilov  <podivilov@chromium.org>
    216
  • trunk/Source/WebCore/ChangeLog

    r85323 r85324  
     12011-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
    1242011-04-29  Tor Arne Vestbø  <tor.arne.vestbo@nokia.com>
    225
  • trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js

    r84909 r85324  
    533533                WebInspector.cssModel._fireStyleSheetChanged(style.id.styleSheetId, majorChange, userCallback ? userCallback.bind(this, style) : null);
    534534            } else {
    535                 console.error(JSON.stringify(error));
    536535                if (userCallback)
    537536                    userCallback(null);
  • trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js

    r85034 r85324  
    16421642                event.preventDefault();
    16431643                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")
    16451645                return "cancel";
    16461646            else if (!isEditingName && this._newProperty && event.keyCode === WebInspector.KeyboardShortcut.Keys.Backspace.code) {
     
    16801680        }
    16811681
     1682        delete this.originalPropertyText;
    16821683        WebInspector.panels.elements.startEditingStyle();
    16831684        WebInspector.startEditing(selectElement, {
     
    17031704    },
    17041705
    1705     _applyFreeFlowStyleTextEdit: function()
     1706    _applyFreeFlowStyleTextEdit: function(now)
    17061707    {
    17071708        if (this._applyFreeFlowStyleTextEditTimer)
     
    17121713            this.applyStyleText(this.nameElement.textContent + ": " + this.valueElement.textContent);
    17131714        }
    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);
    17151724    },
    17161725
     
    17691778            event.handled = true;
    17701779            event.preventDefault();
    1771 
    1772             if (!("originalPropertyText" in this)) {
    1773                 // Remember the rule's original CSS text on [Page](Up|Down), so it can be restored
    1774                 // if the editing is canceled.
    1775                 this.originalPropertyText = this.property.propertyText;
    1776             }
    17771780
    17781781            // Synthesize property text disregarding any comments, custom whitespace etc.
     
    17961799            editedElement.parentElement.removeStyleClass("child-editing");
    17971800
    1798         delete this.originalPropertyText;
    17991801        WebInspector.panels.elements.endEditingStyle();
    18001802    },
     
    18031805    {
    18041806        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 {
    18081818            if (this._newProperty)
    18091819                this.treeOutline.removeChild(this);
     
    18111821                this.updateTitle();
    18121822        }
    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    },
    18171824
    18181825    editingCommitted: function(element, userInput, previousContent, context, moveDirection)
     
    18571864                    propertyText = this.nameElement.textContent + ": " + userInput;
    18581865            }
    1859             this.applyStyleText(propertyText, true);
     1866            this.applyStyleText(propertyText, true, true);
    18601867        } else {
    18611868            if (!isDataPasted && !this._newProperty)
     
    19281935    },
    19291936
    1930     _hasBeenAppliedToPageViaUpDown: function()
     1937    _hasBeenModifiedIncrementally: function()
    19311938    {
    19321939        // New properties applied via up/down have an originalPropertyText and will be deleted later
    19331940        // 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
    19391953        var section = this.treeOutline.section;
    19401954        var elementsPanel = WebInspector.panels.elements;
    19411955        styleText = styleText.replace(/\s/g, " ").trim(); // Replace &nbsp; with whitespace.
    19421956        var styleTextLength = styleText.length;
    1943         if (!styleTextLength && updateInterface && this._newProperty && !this._hasBeenAppliedToPageViaUpDown()) {
     1957        if (!styleTextLength && updateInterface && !isRevert && this._newProperty && !this._hasBeenModifiedIncrementally()) {
    19441958            // The user deleted everything and never applied a new property value via Up/Down scrolling, so remove the tree element and update.
    19451959            this.parent.removeChild(this);
     
    19481962        }
    19491963
    1950         function callback(newStyle)
     1964        function callback(originalPropertyText, newStyle)
    19511965        {
    19521966            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);
    19591970                }
    1960                 if (updateInterface)
    1961                     this.updateTitle();
    19621971                return;
    19631972            }
     
    19781987        if (styleText.length && !/;\s*$/.test(styleText))
    19791988            styleText += ";";
    1980         this.property.setText(styleText, updateInterface, callback.bind(this));
     1989        this.property.setText(styleText, majorChange, callback.bind(this, this.originalPropertyText));
    19811990    }
    19821991}
  • trunk/Source/WebCore/inspector/front-end/inspector.js

    r85312 r85324  
    15201520        if (isEnterKey(event) && (event.isMetaOrCtrlForTest || !config.multiline || isMetaOrCtrl))
    15211521            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")
    15231523            return "cancel";
    15241524        else if (event.keyIdentifier === "U+0009") // Tab key
Note: See TracChangeset for help on using the changeset viewer.