Web Inspector: Styles: toggling selected properties may cause data corruption
authornvasilyev@apple.com <nvasilyev@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 15 Dec 2018 10:03:19 +0000 (10:03 +0000)
committernvasilyev@apple.com <nvasilyev@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 15 Dec 2018 10:03:19 +0000 (10:03 +0000)
commit6add72e550d0bf87a440c0114ff54e3ca549ef8a
treefe01b6fdd2903e15209210f22fba8cfc37ad0f57
parent5a42f410392f7892b5cf224c3d09d3fee4684485
Web Inspector: Styles: toggling selected properties may cause data corruption
https://bugs.webkit.org/show_bug.cgi?id=192396
<rdar://problem/46478383>

Reviewed by Devin Rousso.

Source/WebInspectorUI:

Uncommenting a property after a commented out property used to insert an unnecessary semicolon,
and not updating ranges of the following properties.

For example:

    /* color: red; */
    /* font-size: 12px */

Uncommenting `font-size` would result in something like this:

    /* color: red; */; font-size: 12px
                     ^
                     unnecessary semicolon

Now the semicolon doesn't get inserted and the white space is preserved better:

    /* color: red; */
    font-size: 12px

* UserInterface/Models/CSSProperty.js:
(WI.CSSProperty.prototype._updateOwnerStyleText):
(WI.CSSProperty.prototype._appendSemicolonIfNeeded): Removed.
(WI.CSSProperty.prototype._prependSemicolonIfNeeded): Added.

* UserInterface/Views/SpreadsheetStyleProperty.js:
(WI.SpreadsheetStyleProperty.prototype.remove):
(WI.SpreadsheetStyleProperty.prototype.update):
(WI.SpreadsheetStyleProperty.prototype._handleNameChange):
(WI.SpreadsheetStyleProperty.prototype._handleValueChange):
Style declaration should be locked while editing. Add asserts to ensure this.

LayoutTests:

* inspector/css/add-css-property-expected.txt: Added.
* inspector/css/add-css-property.html: Added.
Test adding new properties.

* inspector/css/modify-css-property-expected.txt:
* inspector/css/modify-css-property.html:
Test commenting out and uncommenting CSS properties.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239251 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/inspector/css/add-css-property-expected.txt [new file with mode: 0644]
LayoutTests/inspector/css/add-css-property.html [new file with mode: 0644]
LayoutTests/inspector/css/modify-css-property-expected.txt
LayoutTests/inspector/css/modify-css-property.html
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Models/CSSProperty.js
Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js