⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 288498 in webkit


Ignore:
Timestamp:
Jan 24, 2022, 5:54:51 PM (5 years ago)
Author:
Russell Epstein
Message:

Cherry-pick r287934. rdar://problem/86578732

Web Inspector: Unhandled exception when moving cursor mid-token after receiving CSS property name completions
​https://bugs.webkit.org/show_bug.cgi?id=234393
<rdar://problem/86578732>

Reviewed by Patrick Angle.

Source/WebInspectorUI:

A faulty check for mid-token completions in WI.CSSKeywordCompletions.forPartialPropertyName(), which are still
unsupported, prevented an early return and completions were provided unexpectedly. This had knock-on effects in
WI.SpreadsheetTextField which is not set up to handle cases where the caret is placed within the completion query.
Calculating the adjusted caret position could return a negative index and throw an unhandled exception.

Web Inspector does not currently explicitly support mid-token completions. See ​https://webkit.org/b/227157

The implementation of fuzzy matching for CSS completions in ​https://webkit.org/b/234092
means that, unhindered, the completion provider for CSS property names _can_ return mid-token completions.
Typing a query like margin, then moving the caret to the beginning and correcting to s|margin will return
completions like [s]croll-[margin]. Accepting the completion results in a malformed SpreadsheetTextField.value
by concatenation within the prefix itself. As the user types mid-token, the prefix becomes ambiguous.

Fixing the condition in WI.CSSKeywordCompletions.forPartialPropertyName() now inhibits unintentional
mid-token completions when fuzzy matching is enabled.

  • UserInterface/Models/CSSKeywordCompletions.js: (WI.CSSKeywordCompletions.forPartialPropertyName):
  • UserInterface/Views/SpreadsheetTextField.js: (WI.SpreadsheetTextField.prototype._showSuggestionsView):

LayoutTests:

  • inspector/unit-tests/css-keyword-completions-expected.txt:
  • inspector/unit-tests/css-keyword-completions.html:

git-svn-id: ​https://svn.webkit.org/repository/webkit/trunk@287934 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-613-branch
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-613-branch/LayoutTests/ChangeLog

    r288497 r288498  
     12022-01-24  Alan Coon  <alancoon@apple.com>
     2
     3        Cherry-pick r287934. rdar://problem/86578732
     4
     5    Web Inspector: Unhandled exception when moving cursor mid-token after receiving CSS property name completions
     6    https://bugs.webkit.org/show_bug.cgi?id=234393
     7    <rdar://problem/86578732>
     8   
     9    Reviewed by Patrick Angle.
     10   
     11    Source/WebInspectorUI:
     12   
     13    A faulty check for mid-token completions in `WI.CSSKeywordCompletions.forPartialPropertyName()`, which are still
     14    unsupported, prevented an early return and completions were provided unexpectedly. This had knock-on effects in
     15    `WI.SpreadsheetTextField` which is not set up to handle cases where the caret is placed within the completion query.
     16    Calculating the adjusted caret position could return a negative index and throw an unhandled exception.
     17   
     18    Web Inspector does not currently explicitly support mid-token completions. See https://webkit.org/b/227157
     19   
     20    The implementation of fuzzy matching for CSS completions in https://webkit.org/b/234092
     21    means that, unhindered, the completion provider for CSS property names _can_ return mid-token completions.
     22    Typing a query like `margin`, then moving the caret to the beginning and correcting to `s|margin` will return
     23    completions like `[s]croll-[margin]`. Accepting the completion results in a malformed `SpreadsheetTextField.value`
     24    by concatenation within the prefix itself. As the user types mid-token, the prefix becomes ambiguous.
     25   
     26    Fixing the condition in `WI.CSSKeywordCompletions.forPartialPropertyName()` now inhibits unintentional
     27    mid-token completions when fuzzy matching is enabled.
     28   
     29    * UserInterface/Models/CSSKeywordCompletions.js:
     30    (WI.CSSKeywordCompletions.forPartialPropertyName):
     31    * UserInterface/Views/SpreadsheetTextField.js:
     32    (WI.SpreadsheetTextField.prototype._showSuggestionsView):
     33   
     34    LayoutTests:
     35   
     36    * inspector/unit-tests/css-keyword-completions-expected.txt:
     37    * inspector/unit-tests/css-keyword-completions.html:
     38   
     39   
     40    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@287934 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     41
     42    2022-01-12  Razvan Caliman  <rcaliman@apple.com>
     43
     44            Web Inspector: Unhandled exception when moving cursor mid-token after receiving CSS property name completions
     45            https://bugs.webkit.org/show_bug.cgi?id=234393
     46            <rdar://problem/86578732>
     47
     48            Reviewed by Patrick Angle.
     49
     50            * inspector/unit-tests/css-keyword-completions-expected.txt:
     51            * inspector/unit-tests/css-keyword-completions.html:
     52
    1532022-01-24  Alan Coon  <alancoon@apple.com>
    254
  • branches/safari-613-branch/LayoutTests/inspector/unit-tests/css-keyword-completions-expected.txt

    r286611 r288498  
    1414
    1515-- Running test case: WI.CSSKeywordCompletions.forPartialPropertyName.multipleCharacterMatches
     16PASS: All expected completions were present.
     17
     18-- Running test case: WI.CSSKeywordCompletions.forPartialPropertyName.midTokenNoCompletions
     19PASS: Expected exactly 0 completion results.
    1620PASS: All expected completions were present.
    1721
  • branches/safari-613-branch/LayoutTests/inspector/unit-tests/css-keyword-completions.html

    r286611 r288498  
    88    let suite = InspectorTest.createSyncSuite("WI.CSSKeywordCompletions");
    99
    10     function addTestForPartialPropertyName({name, description, text, allowEmptyPrefix, expectedCompletions, expectedCompletionCount}) {
     10    function addTestForPartialPropertyName({name, description, text, caretPosition, allowEmptyPrefix, expectedCompletions, expectedCompletionCount}) {
    1111        suite.addTestCase({
    1212            name,
    … …  
    1818
    1919                // FIXME: <webkit.org/b/227157> Styles: Support completions mid-token.
    20                 let caretPosition = text.length;
     20                caretPosition ??= text.length;
    2121                let completionResults = WI.CSSKeywordCompletions.forPartialPropertyName(text, {caretPosition, allowEmptyPrefix});
    2222
    … …  
    6767    });
    6868
     69    // FIXME: This test will fail after addressing <webkit.org/b/227157> Styles: Support completions mid-token.
     70    addTestForPartialPropertyName({
     71        name: "WI.CSSKeywordCompletions.forPartialPropertyName.midTokenNoCompletions",
     72        description: "Test that completions are not provided when the caret is positioned within the token.",
     73        text: "margin",
     74        caretPosition: 1,
     75        expectedCompletionCount: 0,
     76    });
     77
    6978    function addTestForPartialPropertyValue({name, description, propertyName, text, caretPosition, expectedPrefix, expectedCompletions, expectedCompletionCount, additionalFunctionValueCompletionsProvider}) {
    7079        suite.addTestCase({
  • branches/safari-613-branch/Source/WebInspectorUI/ChangeLog

    r288495 r288498  
     12022-01-24  Alan Coon  <alancoon@apple.com>
     2
     3        Cherry-pick r287934. rdar://problem/86578732
     4
     5    Web Inspector: Unhandled exception when moving cursor mid-token after receiving CSS property name completions
     6    https://bugs.webkit.org/show_bug.cgi?id=234393
     7    <rdar://problem/86578732>
     8   
     9    Reviewed by Patrick Angle.
     10   
     11    Source/WebInspectorUI:
     12   
     13    A faulty check for mid-token completions in `WI.CSSKeywordCompletions.forPartialPropertyName()`, which are still
     14    unsupported, prevented an early return and completions were provided unexpectedly. This had knock-on effects in
     15    `WI.SpreadsheetTextField` which is not set up to handle cases where the caret is placed within the completion query.
     16    Calculating the adjusted caret position could return a negative index and throw an unhandled exception.
     17   
     18    Web Inspector does not currently explicitly support mid-token completions. See https://webkit.org/b/227157
     19   
     20    The implementation of fuzzy matching for CSS completions in https://webkit.org/b/234092
     21    means that, unhindered, the completion provider for CSS property names _can_ return mid-token completions.
     22    Typing a query like `margin`, then moving the caret to the beginning and correcting to `s|margin` will return
     23    completions like `[s]croll-[margin]`. Accepting the completion results in a malformed `SpreadsheetTextField.value`
     24    by concatenation within the prefix itself. As the user types mid-token, the prefix becomes ambiguous.
     25   
     26    Fixing the condition in `WI.CSSKeywordCompletions.forPartialPropertyName()` now inhibits unintentional
     27    mid-token completions when fuzzy matching is enabled.
     28   
     29    * UserInterface/Models/CSSKeywordCompletions.js:
     30    (WI.CSSKeywordCompletions.forPartialPropertyName):
     31    * UserInterface/Views/SpreadsheetTextField.js:
     32    (WI.SpreadsheetTextField.prototype._showSuggestionsView):
     33   
     34    LayoutTests:
     35   
     36    * inspector/unit-tests/css-keyword-completions-expected.txt:
     37    * inspector/unit-tests/css-keyword-completions.html:
     38   
     39   
     40    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@287934 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     41
     42    2022-01-12  Razvan Caliman  <rcaliman@apple.com>
     43
     44            Web Inspector: Unhandled exception when moving cursor mid-token after receiving CSS property name completions
     45            https://bugs.webkit.org/show_bug.cgi?id=234393
     46            <rdar://problem/86578732>
     47
     48            Reviewed by Patrick Angle.
     49
     50            A faulty check for mid-token completions in `WI.CSSKeywordCompletions.forPartialPropertyName()`, which are still
     51            unsupported, prevented an early return and completions were provided unexpectedly. This had knock-on effects in
     52            `WI.SpreadsheetTextField` which is not set up to handle cases where the caret is placed within the completion query.
     53            Calculating the adjusted caret position could return a negative index and throw an unhandled exception.
     54
     55            Web Inspector does not currently explicitly support mid-token completions. See https://webkit.org/b/227157
     56
     57            The implementation of fuzzy matching for CSS completions in https://webkit.org/b/234092
     58            means that, unhindered, the completion provider for CSS property names _can_ return mid-token completions.
     59            Typing a query like `margin`, then moving the caret to the beginning and correcting to `s|margin` will return
     60            completions like `[s]croll-[margin]`. Accepting the completion results in a malformed `SpreadsheetTextField.value`
     61            by concatenation within the prefix itself. As the user types mid-token, the prefix becomes ambiguous.
     62
     63            Fixing the condition in `WI.CSSKeywordCompletions.forPartialPropertyName()` now inhibits unintentional
     64            mid-token completions when fuzzy matching is enabled.
     65
     66            * UserInterface/Models/CSSKeywordCompletions.js:
     67            (WI.CSSKeywordCompletions.forPartialPropertyName):
     68            * UserInterface/Views/SpreadsheetTextField.js:
     69            (WI.SpreadsheetTextField.prototype._showSuggestionsView):
     70
    1712022-01-24  Alan Coon  <alancoon@apple.com>
    272
  • branches/safari-613-branch/Source/WebInspectorUI/UserInterface/Models/CSSKeywordCompletions.js

    r287712 r288498  
    3434WI.CSSKeywordCompletions.forPartialPropertyName = function(text, {caretPosition, allowEmptyPrefix, useFuzzyMatching} = {})
    3535{
    36     caretPosition ??= text.length;
    3736    allowEmptyPrefix ??= false;
    3837
    3938    // FIXME: <webkit.org/b/227157> Styles: Support completions mid-token.
    40     if (caretPosition !== caretPosition)
    41         return {prefix: text, completions: []};
     39    if (caretPosition !== text.length)
     40        return {prefix: "", completions: []};
    4241
    4342    if (!text.length && allowEmptyPrefix)
  • branches/safari-613-branch/Source/WebInspectorUI/UserInterface/Views/SpreadsheetTextField.js

    r286611 r288498  
    479479        //                   rosybrown
    480480        //                   royalblue
     481        //
     482        // FIXME: Account for the caret being within the token when fixing <webkit.org/b/227157> Styles: Support completions mid-token.
    481483        let adjustedCaretPosition = this._getCaretPosition() - this._completionPrefix.length;
    482484        let caretRect = this._getCaretRect(adjustedCaretPosition);
Note: See TracChangeset for help on using the changeset viewer.