Changeset 287891 in webkit
- Timestamp:
- Jan 11, 2022, 10:53:40 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/inspector/css/modify-css-property-expected.txt (modified) (1 diff)
-
LayoutTests/inspector/css/modify-css-property.html (modified) (2 diffs)
-
LayoutTests/inspector/css/resources/modify-css-property.css (modified) (1 diff)
-
Source/WebInspectorUI/ChangeLog (modified) (1 diff)
-
Source/WebInspectorUI/UserInterface/Models/CSSProperty.js (modified) (1 diff)
-
Source/WebInspectorUI/UserInterface/Models/CSSStyleDeclaration.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r287882 r287891 1 2022-01-11 Nikita Vasilyev <nvasilyev@apple.com> 2 3 REGRESSION (r283723): Web Inspector: CSS declarations unexpectedly removed when editing property value 4 https://bugs.webkit.org/show_bug.cgi?id=233195 5 6 Reviewed by Devin Rousso. 7 8 Test removing CSS property name. 9 10 * inspector/css/modify-css-property-expected.txt: 11 * inspector/css/modify-css-property.html: 12 * inspector/css/resources/modify-css-property.css: 13 (.rule-e): 14 1 15 2022-01-11 Rob Buis <rbuis@igalia.com> 2 16 -
trunk/LayoutTests/inspector/css/modify-css-property-expected.txt
r283723 r287891 42 42 PASS: Uncommented property should be enabled. 43 43 44 -- Running test case: ModifyCSSProperty.ReplacePropertyName 45 PASS: Style declaration text should be empty. 46 PASS: Style declaration text should have new property name. 47 -
trunk/LayoutTests/inspector/css/modify-css-property.html
r283723 r287891 314 314 315 315 resolve(); 316 } 317 }); 318 319 suite.addTestCase({ 320 name: "ModifyCSSProperty.ReplacePropertyName", 321 async test() { 322 let getMatchedStyleDeclaration = () => { 323 for (let rule of nodeStyles.matchedRules) { 324 if (rule.selectorText === ".rule-e") 325 return rule.style; 326 } 327 throw "No declaration found."; 328 }; 329 let getProperty = (propertyName) => { 330 let styleDeclaration = getMatchedStyleDeclaration(); 331 for (let property of styleDeclaration.properties) { 332 if (property.name === propertyName) 333 return property; 334 } 335 throw "No property found."; 336 }; 337 let styleDeclaration = getMatchedStyleDeclaration(); 338 339 let cssProperty = getProperty("color"); 340 cssProperty.name = ""; 341 InspectorTest.expectEqual(styleDeclaration.text, "", "Style declaration text should be empty."); 342 343 cssProperty.name = "border-color"; 344 InspectorTest.expectEqual(styleDeclaration.text, `\n border-color: darkseagreen;\n`, "Style declaration text should have new property name."); 316 345 } 317 346 }); … … 340 369 <body onload="runTest()"> 341 370 <p>Testing that CSSStyleDeclaration update immediately after modifying its properties when it is not locked.</p> 342 <div id="x" class="test-node rule-a rule-b rule-c rule-d " style="width: 100px"></div>371 <div id="x" class="test-node rule-a rule-b rule-c rule-d rule-e" style="width: 100px"></div> 343 372 </body> 344 373 </html> -
trunk/LayoutTests/inspector/css/resources/modify-css-property.css
r283723 r287891 14 14 } 15 15 .rule-d {/*font-size: 13px;*//*border: 2px solid brown*/} 16 .rule-e { 17 color: darkseagreen; 18 } -
trunk/Source/WebInspectorUI/ChangeLog
r287870 r287891 1 2022-01-11 Nikita Vasilyev <nvasilyev@apple.com> 2 3 REGRESSION (r283723): Web Inspector: CSS declarations unexpectedly removed when editing property value 4 https://bugs.webkit.org/show_bug.cgi?id=233195 5 6 Reviewed by Devin Rousso. 7 8 Re-attach CSS property if it was detached while editing. 9 10 CSSProperty is detached when focusing on property name and deleting it. Consequent edits of the detached 11 CSSProperty were not saved. This patch re-attaches detached property at the previous position. 12 13 * UserInterface/Models/CSSProperty.js: 14 (WI.CSSProperty.prototype.set name): 15 * UserInterface/Models/CSSStyleDeclaration.js: 16 (WI.CSSStyleDeclaration.prototype.newBlankProperty): 17 (WI.CSSStyleDeclaration.prototype.insertProperty): 18 Introduce this method since the logic is used in two different places now. 19 1 20 2022-01-10 Nikita Vasilyev <nvasilyev@apple.com> 2 21 -
trunk/Source/WebInspectorUI/UserInterface/Models/CSSProperty.js
r283899 r287891 257 257 return; 258 258 259 if (!name) { 260 // Deleting property name causes CSSProperty to be detached from CSSStyleDeclaration. 261 console.assert(!isNaN(this._index), this); 262 this._indexBeforeDetached = this._index; 263 } else if (!isNaN(this._indexBeforeDetached) && isNaN(this._index)) { 264 // Reattach CSSProperty. 265 console.assert(!this._ownerStyle.properties.includes(this), this); 266 this._ownerStyle.insertProperty(this, this._indexBeforeDetached); 267 this._indexBeforeDetached = NaN; 268 } 269 259 270 this._markModified(); 260 271 this._name = name; -
trunk/Source/WebInspectorUI/UserInterface/Models/CSSStyleDeclaration.js
r286558 r287891 391 391 this.markModified(); 392 392 let property = new WI.CSSProperty(propertyIndex, text, name, value, priority, enabled, overridden, implicit, anonymous, valid, styleSheetTextRange); 393 394 this._properties.insertAtIndex(property, propertyIndex); 395 for (let index = propertyIndex + 1; index < this._properties.length; index++) 396 this._properties[index].index = index; 397 393 this.insertProperty(property, propertyIndex); 398 394 this.update(this._text, this._properties, this._styleSheetTextRange, {dontFireEvents: true, forceUpdate: true}); 399 395 … … 423 419 } 424 420 421 insertProperty(cssProperty, propertyIndex) 422 { 423 this._properties.insertAtIndex(cssProperty, propertyIndex); 424 for (let index = propertyIndex + 1; index < this._properties.length; index++) 425 this._properties[index].index = index; 426 427 // Invalidate cached properties. 428 this._enabledProperties = null; 429 this._visibleProperties = null; 430 } 431 425 432 removeProperty(cssProperty) 426 433 {
Note:
See TracChangeset
for help on using the changeset viewer.