Changeset 258133 in webkit


Ignore:
Timestamp:
Mar 9, 2020 2:50:20 AM (4 years ago)
Author:
Carlos Garcia Campos
Message:

Merge r258131 - [GTK][WPE] Surrounding text for input methods should not be limited to the current paragraph
https://bugs.webkit.org/show_bug.cgi?id=208706

Reviewed by Žan Doberšek.

Source/WebKit:

It should include all the text around the cursor position.

  • Shared/EditorState.cpp:

(WebKit::EditorState::PostLayoutData::encode const): Rename paragraphContext* as surroundingContext*.
(WebKit::EditorState::PostLayoutData::decode): Ditto.

  • Shared/EditorState.h:
  • UIProcess/API/gtk/WebKitWebViewBase.cpp:

(webkitWebViewBaseUpdateTextInputState): Ditto.

  • UIProcess/API/wpe/WPEView.cpp:

(WKWPE::View::selectionDidChange): Ditto.

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::deleteSurrounding): Use content editable text as context instead of just paragraph.

  • WebProcess/WebPage/glib/WebPageGLib.cpp:

(WebKit::WebPage::platformEditorState const): Ditto.

Tools:

Add test case to check surrounding text in multiline context.

  • TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp:

(testWebKitInputMethodContextSurrounding):

Location:
releases/WebKitGTK/webkit-2.28
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • releases/WebKitGTK/webkit-2.28/Source/WebKit/ChangeLog

    r258132 r258133  
     12020-03-09  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK][WPE] Surrounding text for input methods should not be limited to the current paragraph
     4        https://bugs.webkit.org/show_bug.cgi?id=208706
     5
     6        Reviewed by Žan Doberšek.
     7
     8        It should include all the text around the cursor position.
     9
     10        * Shared/EditorState.cpp:
     11        (WebKit::EditorState::PostLayoutData::encode const): Rename paragraphContext* as surroundingContext*.
     12        (WebKit::EditorState::PostLayoutData::decode): Ditto.
     13        * Shared/EditorState.h:
     14        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
     15        (webkitWebViewBaseUpdateTextInputState): Ditto.
     16        * UIProcess/API/wpe/WPEView.cpp:
     17        (WKWPE::View::selectionDidChange): Ditto.
     18        * WebProcess/WebPage/WebPage.cpp:
     19        (WebKit::WebPage::deleteSurrounding): Use content editable text as context instead of just paragraph.
     20        * WebProcess/WebPage/glib/WebPageGLib.cpp:
     21        (WebKit::WebPage::platformEditorState const): Ditto.
     22
    1232020-03-08  Konstantin Tokarev  <annulen@yandex.ru>
    224
  • releases/WebKitGTK/webkit-2.28/Source/WebKit/Shared/EditorState.cpp

    r254822 r258133  
    144144#endif
    145145#if PLATFORM(GTK) || PLATFORM(WPE)
    146     encoder << paragraphContext;
    147     encoder << paragraphContextCursorPosition;
    148     encoder << paragraphContextSelectionPosition;
     146    encoder << surroundingContext;
     147    encoder << surroundingContextCursorPosition;
     148    encoder << surroundingContextSelectionPosition;
    149149#endif
    150150    encoder << fontAttributes;
     
    221221#endif
    222222#if PLATFORM(GTK) || PLATFORM(WPE)
    223     if (!decoder.decode(result.paragraphContext))
    224         return false;
    225     if (!decoder.decode(result.paragraphContextCursorPosition))
    226         return false;
    227     if (!decoder.decode(result.paragraphContextSelectionPosition))
     223    if (!decoder.decode(result.surroundingContext))
     224        return false;
     225    if (!decoder.decode(result.surroundingContextCursorPosition))
     226        return false;
     227    if (!decoder.decode(result.surroundingContextSelectionPosition))
    228228        return false;
    229229#endif
  • releases/WebKitGTK/webkit-2.28/Source/WebKit/Shared/EditorState.h

    r254822 r258133  
    122122#endif
    123123#if PLATFORM(GTK) || PLATFORM(WPE)
    124         String paragraphContext;
    125         uint64_t paragraphContextCursorPosition { 0 };
    126         uint64_t paragraphContextSelectionPosition { 0 };
     124        String surroundingContext;
     125        uint64_t surroundingContextCursorPosition { 0 };
     126        uint64_t surroundingContextSelectionPosition { 0 };
    127127#endif
    128128
  • releases/WebKitGTK/webkit-2.28/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp

    r255343 r258133  
    16801680    if (!editorState.isMissingPostLayoutData) {
    16811681        webkitWebViewBase->priv->inputMethodFilter.notifyCursorRect(editorState.postLayoutData().caretRectAtStart);
    1682         webkitWebViewBase->priv->inputMethodFilter.notifySurrounding(editorState.postLayoutData().paragraphContext, editorState.postLayoutData().paragraphContextCursorPosition,
    1683             editorState.postLayoutData().paragraphContextSelectionPosition);
     1682        webkitWebViewBase->priv->inputMethodFilter.notifySurrounding(editorState.postLayoutData().surroundingContext, editorState.postLayoutData().surroundingContextCursorPosition,
     1683            editorState.postLayoutData().surroundingContextSelectionPosition);
    16841684    }
    16851685}
  • releases/WebKitGTK/webkit-2.28/Source/WebKit/UIProcess/API/wpe/WPEView.cpp

    r255488 r258133  
    259259    if (!editorState.isMissingPostLayoutData) {
    260260        m_inputMethodFilter.notifyCursorRect(editorState.postLayoutData().caretRectAtStart);
    261         m_inputMethodFilter.notifySurrounding(editorState.postLayoutData().paragraphContext, editorState.postLayoutData().paragraphContextCursorPosition,
    262             editorState.postLayoutData().paragraphContextSelectionPosition);
     261        m_inputMethodFilter.notifySurrounding(editorState.postLayoutData().surroundingContext, editorState.postLayoutData().surroundingContextCursorPosition,
     262            editorState.postLayoutData().surroundingContextSelectionPosition);
    263263    }
    264264}
  • releases/WebKitGTK/webkit-2.28/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r257434 r258133  
    54185418
    54195419    auto selectionStart = selection.visibleStart();
    5420     auto paragraphRange = makeRange(startOfParagraph(selectionStart), selectionStart);
    5421     auto cursorPosition = TextIterator::rangeLength(paragraphRange.get());
    5422     auto& rootNode = paragraphRange->startContainer().treeScope().rootNode();
     5420    auto surroundingRange = makeRange(startOfEditableContent(selectionStart), selectionStart);
     5421    auto cursorPosition = TextIterator::rangeLength(surroundingRange.get());
     5422    auto& rootNode = surroundingRange->startContainer().treeScope().rootNode();
    54235423    auto selectionRange = TextIterator::rangeFromLocationAndLength(&rootNode, cursorPosition + offset, characterCount);
    54245424    if (!selectionRange)
  • releases/WebKitGTK/webkit-2.28/Source/WebKit/WebProcess/WebPage/glib/WebPageGLib.cpp

    r254822 r258133  
    108108    if (selection.isContentEditable()) {
    109109        auto selectionStart = selection.visibleStart();
    110         auto paragraphStart = startOfParagraph(selectionStart);
    111         auto paragraphEnd = endOfParagraph(selectionStart);
    112         auto paragraphRange = makeRange(paragraphStart, paragraphEnd);
     110        auto surroundingStart = startOfEditableContent(selectionStart);
     111        auto surroundingEnd = endOfEditableContent(selectionStart);
     112        auto surroundingRange = makeRange(surroundingStart, surroundingEnd);
    113113        auto compositionRange = frame.editor().compositionRange();
    114         if (compositionRange && paragraphRange->contains(*compositionRange)) {
    115             auto clonedRange = paragraphRange->cloneRange();
    116             paragraphRange->setEnd(compositionRange->startPosition());
     114        if (compositionRange && surroundingRange->contains(*compositionRange)) {
     115            auto clonedRange = surroundingRange->cloneRange();
     116            surroundingRange->setEnd(compositionRange->startPosition());
    117117            clonedRange->setStart(compositionRange->endPosition());
    118             postLayoutData.paragraphContext = plainText(paragraphRange.get()) + plainText(clonedRange.ptr());
    119             postLayoutData.paragraphContextCursorPosition = TextIterator::rangeLength(paragraphRange.get());
    120             postLayoutData.paragraphContextSelectionPosition = postLayoutData.paragraphContextCursorPosition;
     118            postLayoutData.surroundingContext = plainText(surroundingRange.get()) + plainText(clonedRange.ptr());
     119            postLayoutData.surroundingContextCursorPosition = TextIterator::rangeLength(surroundingRange.get());
     120            postLayoutData.surroundingContextSelectionPosition = postLayoutData.surroundingContextCursorPosition;
    121121        } else {
    122             postLayoutData.paragraphContext = plainText(paragraphRange.get());
    123             postLayoutData.paragraphContextCursorPosition = TextIterator::rangeLength(makeRange(paragraphStart, selectionStart).get());
    124             postLayoutData.paragraphContextSelectionPosition = TextIterator::rangeLength(makeRange(paragraphStart, selection.visibleEnd()).get());
     122            postLayoutData.surroundingContext = plainText(surroundingRange.get());
     123            postLayoutData.surroundingContextCursorPosition = TextIterator::rangeLength(makeRange(surroundingStart, selectionStart).get());
     124            postLayoutData.surroundingContextSelectionPosition = TextIterator::rangeLength(makeRange(surroundingStart, selection.visibleEnd()).get());
    125125        }
    126126    }
  • releases/WebKitGTK/webkit-2.28/Tools/ChangeLog

    r257993 r258133  
     12020-03-09  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK][WPE] Surrounding text for input methods should not be limited to the current paragraph
     4        https://bugs.webkit.org/show_bug.cgi?id=208706
     5
     6        Reviewed by Žan Doberšek.
     7
     8        Add test case to check surrounding text in multiline context.
     9
     10        * TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp:
     11        (testWebKitInputMethodContextSurrounding):
     12
    1132020-03-06  Lauro Moura <lmoura@igalia.com>
    214
  • releases/WebKitGTK/webkit-2.28/Tools/TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp

    r254822 r258133  
    5353G_DEFINE_TYPE(WebKitInputMethodContextMock, webkit_input_method_context_mock, WEBKIT_TYPE_INPUT_METHOD_CONTEXT)
    5454
    55 static const char* testHTML = "<html><body><input id='editable' contenteditable onkeydown='logKeyDown()' onkeyup='logKeyUp()' onkeypress='logKeyPress()'></input><script>"
     55static const char* testHTML = "<html><body><textarea id='editable' rows='3', cols='50' onkeydown='logKeyDown()' onkeyup='logKeyUp()' onkeypress='logKeyPress()'></textarea><script>"
    5656    "var input = document.getElementById('editable');"
    5757    "input.addEventListener('compositionstart', logCompositionEvent);"
     
    861861    g_assert_cmpuint(test->surroundingCursorIndex(), ==, 37);
    862862    g_assert_cmpuint(test->surroundingSelectionIndex(), ==, test->surroundingCursorIndex());
     863    test->m_events.clear();
     864
     865    // Check multiline context.
     866    test->keyStrokeAndWaitForEvents(KEY(Return), 3);
     867    test->keyStrokeAndWaitForEvents(KEY(a), 6);
     868    test->waitForSurroundingText("WebKitGTKWPEWebKitabcWebKitGTK😀️\na");
     869    g_assert_cmpstr(test->surroundingText(), ==, "WebKitGTKWPEWebKitabcWebKitGTK😀️\na");
     870    g_assert_cmpuint(test->surroundingCursorIndex(), ==, 39);
     871    g_assert_cmpuint(test->surroundingSelectionIndex(), ==, test->surroundingCursorIndex());
     872    test->m_events.clear();
    863873}
    864874
Note: See TracChangeset for help on using the changeset viewer.