Changeset 228030 in webkit
- Timestamp:
- Feb 2, 2018 2:52:56 PM (6 years ago)
- Location:
- trunk/Source/WebInspectorUI
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebInspectorUI/ChangeLog
r228024 r228030 1 2018-02-02 Devin Rousso <webkit@devinrousso.com> 2 3 Web Inspector: Styles Redesign: Pasting multiple properties should create properties instead of a bad property 4 https://bugs.webkit.org/show_bug.cgi?id=179622 5 <rdar://problem/35511170> 6 7 Reviewed by Matt Baker. 8 9 * UserInterface/Views/SpreadsheetStyleProperty.js: 10 (WI.SpreadsheetStyleProperty.prototype._remove): 11 (WI.SpreadsheetStyleProperty.prototype._update): 12 (WI.SpreadsheetStyleProperty.prototype.spreadsheetTextFieldDidCommit): 13 (WI.SpreadsheetStyleProperty.prototype._handleNamePaste): 14 When the user pastes into the name field, parse the text for a list of name-value pairs and 15 replace the property being edited with the text of those pairs. 16 17 * UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.js: 18 (WI.SpreadsheetCSSStyleDeclarationEditor): 19 (WI.SpreadsheetCSSStyleDeclarationEditor.prototype.layout): 20 (WI.SpreadsheetCSSStyleDeclarationEditor.prototype.addBlankProperty): 21 (WI.SpreadsheetCSSStyleDeclarationEditor.prototype.spreadsheetStylePropertyFocusMoved): 22 (WI.SpreadsheetCSSStyleDeclarationEditor.prototype.spreadsheetStylePropertyAddBlankPropertySoon): 23 (WI.SpreadsheetCSSStyleDeclarationEditor.prototype.spreadsheetStylePropertyRemoved): 24 (WI.SpreadsheetCSSStyleDeclarationEditor.prototype._propertiesChanged): 25 (WI.SpreadsheetCSSStyleDeclarationEditor.prototype.spreadsheetCSSStyleDeclarationEditorFocusMoved): Deleted. 26 Calling `addBlankProperty` will trigger a layout on the next frame, but that might be before 27 the CSSAgent has had a chance to finish refreshing, so we need a way to defer the creation 28 of a new property until after we have finished the next layout (which is after the refresh). 29 Drive-by: fix naming of some delegate functions. 30 31 * UserInterface/Models/CSSProperty.js: 32 (WI.CSSProperty.prototype.replaceWithText): 33 Provide a way for replacing the property with new text. 34 1 35 2018-02-02 Matt Baker <mattbaker@apple.com> 2 36 -
trunk/Source/WebInspectorUI/UserInterface/Models/CSSProperty.js
r227370 r228030 132 132 } 133 133 134 replaceWithText(text) 135 { 136 this._updateOwnerStyleText(this._text, text, true); 137 } 138 134 139 commentOut(disabled) 135 140 { -
trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.js
r227585 r228030 40 40 41 41 this._propertyPendingStartEditing = null; 42 this._pendingAddBlankPropertyIndexOffset = NaN; 42 43 this._filterText = null; 43 44 } … … 91 92 if (this._filterText) 92 93 this.applyFilter(this._filterText); 94 95 if (!isNaN(this._pendingAddBlankPropertyIndexOffset)) 96 this.addBlankProperty(this._propertyViews.length - 1 - this._pendingAddBlankPropertyIndexOffset); 93 97 } 94 98 … … 205 209 addBlankProperty(index) 206 210 { 211 this._pendingAddBlankPropertyIndexOffset = NaN; 212 207 213 if (index === -1) { 208 214 // Append to the end. … … 214 220 } 215 221 216 spreadsheet CSSStyleDeclarationEditorFocusMoved({direction, movedFromProperty, willRemoveProperty})217 { 218 let movedFromIndex = this._propertyViews.indexOf( movedFromProperty);222 spreadsheetStylePropertyFocusMoved(propertyView, {direction, willRemoveProperty}) 223 { 224 let movedFromIndex = this._propertyViews.indexOf(propertyView); 219 225 console.assert(movedFromIndex !== -1, "Property doesn't exist, focusing on a selector as a fallback."); 220 226 if (movedFromIndex === -1) { … … 255 261 // SpreadsheetStyleProperty delegate 256 262 263 spreadsheetStylePropertyAddBlankPropertySoon(propertyView, {index}) 264 { 265 if (isNaN(index)) 266 index = this._propertyViews.length; 267 this._pendingAddBlankPropertyIndexOffset = this._propertyViews.length - index; 268 } 269 257 270 spreadsheetStylePropertyRemoved(propertyView) 258 271 { … … 261 274 for (let index = 0; index < this._propertyViews.length; index++) 262 275 this._propertyViews[index].index = index; 276 277 this._focused = false; 263 278 } 264 279 … … 323 338 _propertiesChanged(event) 324 339 { 325 if (this.editing ) {340 if (this.editing && isNaN(this._pendingAddBlankPropertyIndexOffset)) { 326 341 for (let propertyView of this._propertyViews) 327 342 propertyView.updateStatus(); -
trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js
r227585 r228030 149 149 // Private 150 150 151 _remove( )151 _remove(replacement = "") 152 152 { 153 153 this.element.remove(); 154 this._property.remove(); 154 155 if (replacement) 156 this._property.replaceWithText(replacement); 157 else 158 this._property.remove(); 159 155 160 this.detached(); 156 161 … … 197 202 this._nameElement.tabIndex = 0; 198 203 this._nameElement.addEventListener("beforeinput", this._handleNameBeforeInput.bind(this)); 204 this._nameElement.addEventListener("paste", this._handleNamePaste.bind(this)); 199 205 200 206 this._nameTextField = new WI.SpreadsheetTextField(this, this._nameElement, this._nameCompletionDataProvider.bind(this)); … … 266 272 } 267 273 268 if (typeof this._delegate.spreadsheet CSSStyleDeclarationEditorFocusMoved === "function") {274 if (typeof this._delegate.spreadsheetStylePropertyFocusMoved === "function") { 269 275 // Move focus away from the current property, to the next or previous one, if exists, or to the next or previous rule, if exists. 270 this._delegate.spreadsheet CSSStyleDeclarationEditorFocusMoved({direction, willRemoveProperty, movedFromProperty: this});276 this._delegate.spreadsheetStylePropertyFocusMoved(this, {direction, willRemoveProperty}); 271 277 } 272 278 … … 563 569 } 564 570 571 _handleNamePaste(event) 572 { 573 let text = event.clipboardData.getData("text/plain"); 574 if (!text || !text.includes(":")) 575 return; 576 577 event.preventDefault(); 578 579 this._remove(text); 580 581 if (this._delegate.spreadsheetStylePropertyAddBlankPropertySoon) { 582 this._delegate.spreadsheetStylePropertyAddBlankPropertySoon(this, { 583 index: parseInt(this._element.dataset.propertyIndex) + 1, 584 }); 585 } 586 } 587 565 588 _nameCompletionDataProvider(prefix) 566 589 {
Note: See TracChangeset
for help on using the changeset viewer.