WebKit Bugzilla
Attachment 373170 Details for
Bug 199341
: Web Inspector: Styles: Command-X should cut selected properties
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
patch.txt (text/plain), 8.56 KB, created by
Nikita Vasilyev
on 2019-06-28 18:15:17 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Nikita Vasilyev
Created:
2019-06-28 18:15:17 PDT
Size:
8.56 KB
patch
obsolete
>diff --git a/Source/WebInspectorUI/ChangeLog b/Source/WebInspectorUI/ChangeLog >index 915cc2e7361..573a62a1fa3 100644 >--- a/Source/WebInspectorUI/ChangeLog >+++ b/Source/WebInspectorUI/ChangeLog >@@ -1,3 +1,29 @@ >+2019-06-28 Nikita Vasilyev <nvasilyev@apple.com> >+ >+ Web Inspector: Styles: Command-X should cut selected properties >+ https://bugs.webkit.org/show_bug.cgi?id=199341 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Implement cutting, and unify cutting and copying logic wherever possible. >+ >+ * UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.js: >+ (WI.SpreadsheetCSSStyleDeclarationEditor.prototype.initialLayout): >+ (WI.SpreadsheetCSSStyleDeclarationEditor.prototype.placeTextCaretInFocusedProperty): Added. >+ (WI.SpreadsheetCSSStyleDeclarationEditor.prototype.spreadsheetStylePropertyCopy): Removed. >+ (WI.SpreadsheetCSSStyleDeclarationEditor.prototype._handleKeyDown): >+ >+ (WI.SpreadsheetCSSStyleDeclarationEditor.prototype._copySelectedProperties): Added. >+ Introduce this method to use when copying and cutting CSS properties. >+ >+ (WI.SpreadsheetCSSStyleDeclarationEditor.prototype._removeSelectedProperties): Added. >+ Introduce this method to use when cutting and removing CSS properties (by pressing Delete). >+ >+ * UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js: >+ (WI.SpreadsheetCSSStyleDeclarationSection.prototype._stopSelection): >+ * UserInterface/Views/SpreadsheetStyleProperty.js: >+ Remove old copying logic. >+ > 2019-06-27 Beth Dakin <bdakin@apple.com> > > Upstream use of MACCATALYST >diff --git a/Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.js b/Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.js >index cb93cae59f3..bf8467978ca 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.js >+++ b/Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.js >@@ -69,6 +69,8 @@ WI.SpreadsheetCSSStyleDeclarationEditor = class SpreadsheetCSSStyleDeclarationEd > }, true); > > this.element.addEventListener("keydown", this._handleKeyDown.bind(this)); >+ this.element.addEventListener("cut", this._handleCut.bind(this)); >+ this.element.addEventListener("copy", this._handleCopy.bind(this)); > } > > layout() >@@ -368,6 +370,17 @@ WI.SpreadsheetCSSStyleDeclarationEditor = class SpreadsheetCSSStyleDeclarationEd > this._focusIndex = NaN; > } > >+ placeTextCaretInFocusedProperty() >+ { >+ if (isNaN(this._focusIndex)) >+ return; >+ >+ let focusedProperty = this._propertyViews[this._focusIndex]; >+ let selection = window.getSelection(); >+ selection.removeAllRanges(); >+ selection.setBaseAndExtent(focusedProperty.element, 0, focusedProperty.element, 0); >+ } >+ > applyFilter(filterText) > { > this._filterText = filterText; >@@ -471,22 +484,6 @@ WI.SpreadsheetCSSStyleDeclarationEditor = class SpreadsheetCSSStyleDeclarationEd > this._pendingAddBlankPropertyIndexOffset = this._propertyViews.length - index; > } > >- spreadsheetStylePropertyCopy(event) >- { >- if (!this.hasSelectedProperties()) >- return; >- >- let formattedProperties = []; >- let [startIndex, endIndex] = this.selectionRange; >- for (let i = startIndex; i <= endIndex; ++i) { >- let propertyView = this._propertyViews[i]; >- formattedProperties.push(propertyView.property.formattedText); >- } >- >- event.clipboardData.setData("text/plain", formattedProperties.join("\n")); >- event.stop(); >- } >- > spreadsheetStylePropertyWillRemove(propertyView) > { > this._propertyViews.remove(propertyView); >@@ -550,26 +547,9 @@ WI.SpreadsheetCSSStyleDeclarationEditor = class SpreadsheetCSSStyleDeclarationEd > property.startEditingName(); > } > } else if (event.key === "Backspace" || event.key === "Delete") { >- if (!this.style.editable) >- return; >- >- let [startIndex, endIndex] = this.selectionRange; >- >- let propertyIndexToSelect = NaN; >- if (endIndex + 1 !== this._propertyViews.length) >- propertyIndexToSelect = startIndex; >- else if (startIndex > 0) >- propertyIndexToSelect = startIndex - 1; >- >- this.deselectProperties(); >- >- for (let i = endIndex; i >= startIndex; i--) >- this._propertyViews[i].remove(); >- >- if (!isNaN(propertyIndexToSelect)) >- this.selectProperties(propertyIndexToSelect, propertyIndexToSelect); >- >- event.stop(); >+ let removed = this.removeSelectedProperties(); >+ if (removed) >+ event.stop(); > > } else if ((event.code === "Space" && !event.shiftKey && !event.metaKey && !event.ctrlKey) || (event.key === "/" && event.commandOrControlKey && !event.shiftKey)) { > if (!this.style.editable) >@@ -597,6 +577,60 @@ WI.SpreadsheetCSSStyleDeclarationEditor = class SpreadsheetCSSStyleDeclarationEd > this.deselectProperties(); > } > >+ _handleCopy(event) >+ { >+ if (!this.hasSelectedProperties()) >+ return; >+ >+ this._copySelectedProperties(event); >+ } >+ >+ _handleCut(event) >+ { >+ if (!this.hasSelectedProperties()) >+ return; >+ >+ this._copySelectedProperties(event); >+ this._removeSelectedProperties(); >+ } >+ >+ _copySelectedProperties(event) >+ { >+ let formattedProperties = []; >+ let [startIndex, endIndex] = this.selectionRange; >+ for (let i = startIndex; i <= endIndex; ++i) { >+ let propertyView = this._propertyViews[i]; >+ formattedProperties.push(propertyView.property.formattedText); >+ } >+ >+ event.clipboardData.setData("text/plain", formattedProperties.join("\n")); >+ event.stop(); >+ } >+ >+ _removeSelectedProperties() >+ { >+ if (!this.style.editable) >+ return false; >+ >+ let [startIndex, endIndex] = this.selectionRange; >+ >+ let propertyIndexToSelect = NaN; >+ if (endIndex + 1 !== this._propertyViews.length) >+ propertyIndexToSelect = startIndex; >+ else if (startIndex > 0) >+ propertyIndexToSelect = startIndex - 1; >+ >+ this.deselectProperties(); >+ >+ for (let i = endIndex; i >= startIndex; i--) >+ this._propertyViews[i].remove(); >+ >+ if (!isNaN(propertyIndexToSelect)) >+ this.selectProperties(propertyIndexToSelect, propertyIndexToSelect); >+ >+ return true; >+ } >+ > _editablePropertyAfter(propertyIndex) > { > for (let index = propertyIndex + 1; index < this._propertyViews.length; index++) { >diff --git a/Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js b/Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js >index 60f3931b5fb..a803288a25f 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js >+++ b/Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js >@@ -490,6 +490,9 @@ WI.SpreadsheetCSSStyleDeclarationSection = class SpreadsheetCSSStyleDeclarationS > this._mouseDownIndex = NaN; > this._element.classList.remove("selecting"); > >+ // Without this, "copy" and "cut" events wouldn't fire on SpreadsheetCSSStyleDeclarationEditor. >+ this._propertiesEditor.placeTextCaretInFocusedProperty(); >+ > window.removeEventListener("mousemove", this._boundHandleWindowMouseMove); > this._mouseDownPoint = null; > } >diff --git a/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js b/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js >index dd7a0c5f4e2..1806023583f 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js >+++ b/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js >@@ -73,8 +73,6 @@ WI.SpreadsheetStyleProperty = class SpreadsheetStyleProperty extends WI.Object > this._toggle(); > this._select(); > }, this._element); >- >- this._element.copyHandler = this; > } > } > >@@ -336,11 +334,6 @@ WI.SpreadsheetStyleProperty = class SpreadsheetStyleProperty extends WI.Object > return matches; > } > >- handleCopyEvent(event) >- { >- this._delegate.spreadsheetStylePropertyCopy(event, this); >- } >- > // SpreadsheetTextField delegate > > spreadsheetTextFieldWillStartEditing(textField)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
hi
:
review-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 199341
:
373170
|
373172
|
373548
|
373555
|
374532
|
374710
|
374732