Changeset 239251 in webkit
- Timestamp:
- Dec 15, 2018 2:03:19 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r239243 r239251 1 2018-12-15 Nikita Vasilyev <nvasilyev@apple.com> 2 3 Web Inspector: Styles: toggling selected properties may cause data corruption 4 https://bugs.webkit.org/show_bug.cgi?id=192396 5 <rdar://problem/46478383> 6 7 Reviewed by Devin Rousso. 8 9 * inspector/css/add-css-property-expected.txt: Added. 10 * inspector/css/add-css-property.html: Added. 11 Test adding new properties. 12 13 * inspector/css/modify-css-property-expected.txt: 14 * inspector/css/modify-css-property.html: 15 Test commenting out and uncommenting CSS properties. 16 1 17 2018-12-14 Youenn Fablet <youenn@apple.com> 2 18 -
trunk/LayoutTests/inspector/css/modify-css-property-expected.txt
r227370 r239251 17 17 PASS: Inline style declaration text should update when not locked. 18 18 19 -- Running test case: ModifyCSSProperty.CommentOutAndUncommentPropertyWithNewlines 20 PASS: Commented out property should be disabled. 21 PASS: Style declaration text should update immediately with uncommented property. 22 PASS: Uncommented property should be enabled. 23 PASS: Style declaration text should update immediately with commented out property. 24 PASS: Commented out property should be disabled. 25 26 -- Running test case: ModifyCSSProperty.CommentOutAndUncommentPropertyWithoutNewlines 27 PASS: Commented out property should be disabled. 28 PASS: Style declaration text should update immediately with uncommented property. 29 PASS: Uncommented property should be enabled. 30 PASS: Commented out property should be disabled. 31 PASS: Style declaration text should update immediately with commented out property. 32 PASS: Uncommented property should be enabled. 33 -
trunk/LayoutTests/inspector/css/modify-css-property.html
r236766 r239251 24 24 return rule.style; 25 25 } 26 InspectorTest.fail("No declaration found."); 27 resolve(); 26 28 }; 27 29 … … 32 34 return property; 33 35 } 36 InspectorTest.fail("No property found."); 37 resolve(); 34 38 }; 35 39 … … 55 59 return rule.style; 56 60 } 61 InspectorTest.fail("No declaration found."); 62 resolve(); 57 63 }; 58 64 … … 63 69 return property; 64 70 } 71 InspectorTest.fail("No property found."); 72 resolve(); 65 73 }; 66 74 … … 94 102 return styleDeclaration; 95 103 } 104 InspectorTest.fail("No declaration found."); 105 resolve(); 96 106 }; 97 107 … … 102 112 return property; 103 113 } 114 InspectorTest.fail("No property found."); 115 resolve(); 104 116 }; 105 117 … … 125 137 126 138 InspectorTest.evaluateInPage(`makeWide()`); 139 } 140 }); 141 142 suite.addTestCase({ 143 name: "ModifyCSSProperty.CommentOutAndUncommentPropertyWithNewlines", 144 test(resolve, reject) { 145 let getMatchedStyleDeclaration = () => { 146 for (let rule of nodeStyles.matchedRules) { 147 if (rule.selectorText === ".rule-c") 148 return rule.style; 149 } 150 InspectorTest.fail("No declaration found."); 151 resolve(); 152 }; 153 154 let getProperty = (propertyName) => { 155 let styleDeclaration = getMatchedStyleDeclaration(); 156 for (let property of styleDeclaration.allProperties) { 157 if (property.name === propertyName) 158 return property; 159 } 160 InspectorTest.fail("No property found."); 161 resolve(); 162 }; 163 164 let styleDeclaration = getMatchedStyleDeclaration(); 165 styleDeclaration.locked = true; 166 167 InspectorTest.expectThat(!getProperty("padding-right").enabled, `Commented out property should be disabled.`); 168 169 let disabled = false; 170 getProperty("padding-right").commentOut(disabled); 171 172 let expectedStyleText = `\n /* padding-left: 2em; */\n padding-right: 0px;\n `; 173 InspectorTest.expectEqual(styleDeclaration.text, expectedStyleText, `Style declaration text should update immediately with uncommented property.`); 174 175 InspectorTest.expectThat(getProperty("padding-right").enabled, `Uncommented property should be enabled.`); 176 177 disabled = true; 178 getProperty("padding-right").commentOut(disabled); 179 180 expectedStyleText = `\n /* padding-left: 2em; */\n /* padding-right: 0px; */\n `; 181 InspectorTest.expectEqual(styleDeclaration.text, expectedStyleText, `Style declaration text should update immediately with commented out property.`); 182 183 InspectorTest.expectThat(!getProperty("padding-right").enabled, `Commented out property should be disabled.`); 184 185 resolve(); 186 } 187 }); 188 189 suite.addTestCase({ 190 name: "ModifyCSSProperty.CommentOutAndUncommentPropertyWithoutNewlines", 191 test(resolve, reject) { 192 let getMatchedStyleDeclaration = () => { 193 for (let rule of nodeStyles.matchedRules) { 194 if (rule.selectorText === ".rule-d") 195 return rule.style; 196 } 197 InspectorTest.fail("No declaration found."); 198 resolve(); 199 }; 200 201 let getProperty = (propertyName) => { 202 let styleDeclaration = getMatchedStyleDeclaration(); 203 for (let property of styleDeclaration.allProperties) { 204 if (property.name === propertyName) 205 return property; 206 } 207 InspectorTest.fail("No property found."); 208 resolve(); 209 }; 210 211 let styleDeclaration = getMatchedStyleDeclaration(); 212 styleDeclaration.locked = true; 213 214 InspectorTest.expectThat(!getProperty("font-size").enabled, `Commented out property should be disabled.`); 215 216 let disabled = false; 217 getProperty("font-size").commentOut(disabled); 218 219 let expectedStyleText = `font-size: 13px;/*border: 2px solid brown*/`; 220 InspectorTest.expectEqual(styleDeclaration.text, expectedStyleText, `Style declaration text should update immediately with uncommented property.`); 221 222 InspectorTest.expectThat(getProperty("font-size").enabled, `Uncommented property should be enabled.`); 223 InspectorTest.expectThat(!getProperty("border").enabled, `Commented out property should be disabled.`); 224 225 disabled = false; 226 getProperty("border").commentOut(disabled); 227 228 expectedStyleText = `font-size: 13px;border: 2px solid brown`; 229 InspectorTest.expectEqual(styleDeclaration.text, expectedStyleText, `Style declaration text should update immediately with commented out property.`); 230 231 InspectorTest.expectThat(getProperty("border").enabled, `Uncommented property should be enabled.`); 232 233 resolve(); 127 234 } 128 235 }); … … 161 268 } 162 269 .rule-b {font-size: 12px; color: antiquewhite} 270 .rule-c { 271 /* padding-left: 2em; */ 272 /* padding-right: 0px; */ 273 } 274 .rule-d {/*font-size: 13px;*//*border: 2px solid brown*/} 163 275 </style> 164 <div id="x" class="test-node rule-a rule-b " style="width: 100px"></div>276 <div id="x" class="test-node rule-a rule-b rule-c rule-d" style="width: 100px"></div> 165 277 </body> 166 278 </html> -
trunk/Source/WebInspectorUI/ChangeLog
r239246 r239251 1 2018-12-15 Nikita Vasilyev <nvasilyev@apple.com> 2 3 Web Inspector: Styles: toggling selected properties may cause data corruption 4 https://bugs.webkit.org/show_bug.cgi?id=192396 5 <rdar://problem/46478383> 6 7 Reviewed by Devin Rousso. 8 9 Uncommenting a property after a commented out property used to insert an unnecessary semicolon, 10 and not updating ranges of the following properties. 11 12 For example: 13 14 /* color: red; */ 15 /* font-size: 12px */ 16 17 Uncommenting `font-size` would result in something like this: 18 19 /* color: red; */; font-size: 12px 20 ^ 21 unnecessary semicolon 22 23 Now the semicolon doesn't get inserted and the white space is preserved better: 24 25 /* color: red; */ 26 font-size: 12px 27 28 * UserInterface/Models/CSSProperty.js: 29 (WI.CSSProperty.prototype._updateOwnerStyleText): 30 (WI.CSSProperty.prototype._appendSemicolonIfNeeded): Removed. 31 (WI.CSSProperty.prototype._prependSemicolonIfNeeded): Added. 32 33 * UserInterface/Views/SpreadsheetStyleProperty.js: 34 (WI.SpreadsheetStyleProperty.prototype.remove): 35 (WI.SpreadsheetStyleProperty.prototype.update): 36 (WI.SpreadsheetStyleProperty.prototype._handleNameChange): 37 (WI.SpreadsheetStyleProperty.prototype._handleValueChange): 38 Style declaration should be locked while editing. Add asserts to ensure this. 39 1 40 2018-12-14 Matt Baker <mattbaker@apple.com> 2 41 -
trunk/Source/WebInspectorUI/UserInterface/Models/CSSProperty.js
r238882 r239251 359 359 } 360 360 361 this._prependSemicolonIfNeeded(); 362 361 363 let styleText = this._ownerStyle.text || ""; 362 364 … … 376 378 } 377 379 378 let newStyleText = this._appendSemicolonIfNeeded(styleText.slice(0, range.startOffset)) + newText + styleText.slice(range.endOffset);380 let newStyleText = styleText.slice(0, range.startOffset) + newText + styleText.slice(range.endOffset); 379 381 380 382 let lineDelta = newText.lineCount - oldText.lineCount; … … 388 390 } 389 391 390 _appendSemicolonIfNeeded(styleText) 391 { 392 if (/[^;\s]\s*$/.test(styleText)) 393 return styleText.trimRight() + "; "; 394 395 return styleText; 392 _prependSemicolonIfNeeded() 393 { 394 for (let i = this.index - 1; i >= 0; --i) { 395 let property = this._ownerStyle.allProperties[i]; 396 if (!property.enabled) 397 continue; 398 399 let match = property.text.match(/[^;\s](\s*)$/); 400 if (match) 401 property.text = property.text.trimRight() + ";" + match[1]; 402 403 break; 404 } 396 405 } 397 406 }; -
trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js
r238813 r239251 130 130 remove(replacement = null) 131 131 { 132 console.assert(this._property.ownerStyle.locked, `Removed property was unlocked (${this._property.name})`); 132 133 this.element.remove(); 133 134 … … 154 155 this._checkboxElement.tabIndex = -1; 155 156 this._checkboxElement.addEventListener("click", (event) => { 157 console.assert(this._property.ownerStyle.locked, `Toggled property was unlocked (${this._property.name})`); 156 158 event.stopPropagation(); 157 159 let disabled = !this._checkboxElement.checked; … … 652 654 _handleNameChange() 653 655 { 656 console.assert(this._property.ownerStyle.locked, `Modified property was unlocked (${this._property.name})`); 657 654 658 this._property.name = this._nameElement.textContent.trim(); 655 659 } … … 657 661 _handleValueChange() 658 662 { 663 console.assert(this._property.ownerStyle.locked, `Modified property was unlocked (${this._property.name})`); 664 659 665 this._property.rawValue = this._valueElement.textContent.trim(); 660 666 }
Note: See TracChangeset
for help on using the changeset viewer.