WebKit Bugzilla
Attachment 362224 Details for
Bug 194724
: Web Inspector: Move CSS completion logic from SpreadsheetTextField to SpreadsheetStyleProperty
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
patch.txt (text/plain), 6.73 KB, created by
Nikita Vasilyev
on 2019-02-16 18:56:04 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Nikita Vasilyev
Created:
2019-02-16 18:56:04 PST
Size:
6.73 KB
patch
obsolete
>diff --git a/Source/WebInspectorUI/ChangeLog b/Source/WebInspectorUI/ChangeLog >index 0a0319942db..b80a24e88ea 100644 >--- a/Source/WebInspectorUI/ChangeLog >+++ b/Source/WebInspectorUI/ChangeLog >@@ -1,3 +1,25 @@ >+2019-02-16 Nikita Vasilyev <nvasilyev@apple.com> >+ >+ Web Inspector: Move CSS completion logic from SpreadsheetTextField to SpreadsheetStyleProperty >+ https://bugs.webkit.org/show_bug.cgi?id=194724 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Move CSS value completion logic from SpreadsheetTextField, a generic text field, >+ to SpreadsheetStyleProperty. >+ >+ * UserInterface/Views/SpreadsheetStyleProperty.js: >+ (WI.SpreadsheetStyleProperty.prototype._nameCompletionDataProvider): >+ (WI.SpreadsheetStyleProperty.prototype._valueCompletionDataProvider): >+ >+ * UserInterface/Views/SpreadsheetTextField.js: >+ (WI.SpreadsheetTextField): >+ (WI.SpreadsheetTextField.prototype.completionSuggestionsSelectedCompletion): >+ (WI.SpreadsheetTextField.prototype.completionSuggestionsClickedCompletion): >+ (WI.SpreadsheetTextField.prototype._updateCompletions): >+ (WI.SpreadsheetTextField.prototype._showSuggestionsView): >+ (WI.SpreadsheetTextField.prototype._getCompletionPrefix): Deleted. >+ > 2019-02-15 Joseph Pecoraro <pecoraro@apple.com> > > Web Inspector: Logging a native function to the console, such as `alert`, produces unhandled rejection >diff --git a/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js b/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js >index af6c0699d00..d90e5b61064 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js >+++ b/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js >@@ -711,7 +711,7 @@ WI.SpreadsheetStyleProperty = class SpreadsheetStyleProperty extends WI.Object > > _nameCompletionDataProvider(prefix) > { >- return WI.CSSCompletions.cssNameCompletions.startsWith(prefix); >+ return {prefix, completions: WI.CSSCompletions.cssNameCompletions.startsWith(prefix)}; > } > > _handleValueBeforeInput(event) >@@ -747,8 +747,17 @@ WI.SpreadsheetStyleProperty = class SpreadsheetStyleProperty extends WI.Object > > _valueCompletionDataProvider(prefix) > { >+ // For "border: 1px so|", we want to suggest "solid" based on "so" prefix. >+ let match = prefix.match(/[a-z0-9()-]+$/i); >+ if (!match) >+ return {completions: [], prefix: ""}; >+ >+ prefix = match[0]; > let propertyName = this._nameElement.textContent.trim(); >- return WI.CSSKeywordCompletions.forProperty(propertyName).startsWith(prefix); >+ return { >+ prefix, >+ completions: WI.CSSKeywordCompletions.forProperty(propertyName).startsWith(prefix) >+ }; > } > > _setupJumpToSymbol(element) >diff --git a/Source/WebInspectorUI/UserInterface/Views/SpreadsheetTextField.js b/Source/WebInspectorUI/UserInterface/Views/SpreadsheetTextField.js >index 974264e5223..ca5a84a554c 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/SpreadsheetTextField.js >+++ b/Source/WebInspectorUI/UserInterface/Views/SpreadsheetTextField.js >@@ -48,6 +48,7 @@ WI.SpreadsheetTextField = class SpreadsheetTextField > > this._editing = false; > this._valueBeforeEditing = ""; >+ this._completionPrefix = ""; > } > > // Public >@@ -138,10 +139,7 @@ WI.SpreadsheetTextField = class SpreadsheetTextField > > completionSuggestionsSelectedCompletion(suggestionsView, selectedText = "") > { >- let prefix = this.valueWithoutSuggestion(); >- let completionPrefix = this._getCompletionPrefix(prefix); >- >- this.suggestionHint = selectedText.slice(completionPrefix.length); >+ this.suggestionHint = selectedText.slice(this._completionPrefix.length); > > this._reAttachSuggestionHint(); > >@@ -164,8 +162,7 @@ WI.SpreadsheetTextField = class SpreadsheetTextField > // newPrefix: 1px solid > // selectedText: rosybrown > let prefix = this.valueWithoutSuggestion(); >- let completionPrefix = this._getCompletionPrefix(prefix); >- let newPrefix = prefix.slice(0, -completionPrefix.length); >+ let newPrefix = prefix.slice(0, -this._completionPrefix.length); > > this._element.textContent = newPrefix + selectedText; > >@@ -366,9 +363,9 @@ WI.SpreadsheetTextField = class SpreadsheetTextField > if (!this._completionProvider) > return; > >- let prefix = this.valueWithoutSuggestion(); >- let completionPrefix = this._getCompletionPrefix(prefix); >- let completions = this._completionProvider(completionPrefix); >+ let valueWithoutSuggestion = this.valueWithoutSuggestion(); >+ let {completions, prefix} = this._completionProvider(valueWithoutSuggestion); >+ this._completionPrefix = prefix; > > if (!completions.length) { > this.discardCompletion(); >@@ -376,7 +373,7 @@ WI.SpreadsheetTextField = class SpreadsheetTextField > } > > // No need to show the completion popover with only one item that matches the entered value. >- if (completions.length === 1 && completions[0] === prefix) { >+ if (completions.length === 1 && completions[0] === valueWithoutSuggestion) { > this.discardCompletion(); > return; > } >@@ -396,7 +393,7 @@ WI.SpreadsheetTextField = class SpreadsheetTextField > this._showSuggestionsView(); > > this._suggestionsView.selectedIndex = NaN; >- if (completionPrefix) { >+ if (this._completionPrefix) { > // Select first item and call completionSuggestionsSelectedCompletion. > this._suggestionsView.selectNext(); > } else >@@ -406,8 +403,7 @@ WI.SpreadsheetTextField = class SpreadsheetTextField > _showSuggestionsView() > { > let prefix = this.valueWithoutSuggestion(); >- let completionPrefix = this._getCompletionPrefix(prefix); >- let startOffset = prefix.length - completionPrefix.length; >+ let startOffset = prefix.length - this._completionPrefix.length; > let caretRect = this._getCaretRect(startOffset); > > // Hide completion popover when the anchor element is removed from the DOM. >@@ -447,16 +443,6 @@ WI.SpreadsheetTextField = class SpreadsheetTextField > return new WI.Rect(clientRect.left + leftPadding, clientRect.top, clientRect.width, clientRect.height); > } > >- _getCompletionPrefix(prefix) >- { >- // For "border: 1px so|", we want to suggest "solid" based on "so" prefix. >- let match = prefix.match(/[a-z0-9()-]+$/i); >- if (match) >- return match[0]; >- >- return prefix; >- } >- > _applyCompletionHint() > { > if (!this._completionProvider || !this.suggestionHint)
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 194724
:
362166
|
362224
|
362259