Diff
Modified: trunk/Source/WebKit/ChangeLog (258130 => 258131)
--- trunk/Source/WebKit/ChangeLog 2020-03-09 06:44:10 UTC (rev 258130)
+++ trunk/Source/WebKit/ChangeLog 2020-03-09 08:39:44 UTC (rev 258131)
@@ -1,3 +1,25 @@
+2020-03-09 Carlos Garcia Campos <cgar...@igalia.com>
+
+ [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.
+
+ 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.
+
2020-03-07 Darin Adler <da...@apple.com>
Begin moving off of live ranges for WebKit internals
Modified: trunk/Source/WebKit/Shared/EditorState.cpp (258130 => 258131)
--- trunk/Source/WebKit/Shared/EditorState.cpp 2020-03-09 06:44:10 UTC (rev 258130)
+++ trunk/Source/WebKit/Shared/EditorState.cpp 2020-03-09 08:39:44 UTC (rev 258131)
@@ -143,9 +143,9 @@
encoder << stringForCandidateRequest;
#endif
#if PLATFORM(GTK) || PLATFORM(WPE)
- encoder << paragraphContext;
- encoder << paragraphContextCursorPosition;
- encoder << paragraphContextSelectionPosition;
+ encoder << surroundingContext;
+ encoder << surroundingContextCursorPosition;
+ encoder << surroundingContextSelectionPosition;
#endif
encoder << fontAttributes;
encoder << canCut;
@@ -220,11 +220,11 @@
return false;
#endif
#if PLATFORM(GTK) || PLATFORM(WPE)
- if (!decoder.decode(result.paragraphContext))
+ if (!decoder.decode(result.surroundingContext))
return false;
- if (!decoder.decode(result.paragraphContextCursorPosition))
+ if (!decoder.decode(result.surroundingContextCursorPosition))
return false;
- if (!decoder.decode(result.paragraphContextSelectionPosition))
+ if (!decoder.decode(result.surroundingContextSelectionPosition))
return false;
#endif
Modified: trunk/Source/WebKit/Shared/EditorState.h (258130 => 258131)
--- trunk/Source/WebKit/Shared/EditorState.h 2020-03-09 06:44:10 UTC (rev 258130)
+++ trunk/Source/WebKit/Shared/EditorState.h 2020-03-09 08:39:44 UTC (rev 258131)
@@ -121,9 +121,9 @@
String stringForCandidateRequest;
#endif
#if PLATFORM(GTK) || PLATFORM(WPE)
- String paragraphContext;
- uint64_t paragraphContextCursorPosition { 0 };
- uint64_t paragraphContextSelectionPosition { 0 };
+ String surroundingContext;
+ uint64_t surroundingContextCursorPosition { 0 };
+ uint64_t surroundingContextSelectionPosition { 0 };
#endif
Optional<WebCore::FontAttributes> fontAttributes;
Modified: trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp (258130 => 258131)
--- trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp 2020-03-09 06:44:10 UTC (rev 258130)
+++ trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp 2020-03-09 08:39:44 UTC (rev 258131)
@@ -1679,8 +1679,8 @@
const auto& editorState = webkitWebViewBase->priv->pageProxy->editorState();
if (!editorState.isMissingPostLayoutData) {
webkitWebViewBase->priv->inputMethodFilter.notifyCursorRect(editorState.postLayoutData().caretRectAtStart);
- webkitWebViewBase->priv->inputMethodFilter.notifySurrounding(editorState.postLayoutData().paragraphContext, editorState.postLayoutData().paragraphContextCursorPosition,
- editorState.postLayoutData().paragraphContextSelectionPosition);
+ webkitWebViewBase->priv->inputMethodFilter.notifySurrounding(editorState.postLayoutData().surroundingContext, editorState.postLayoutData().surroundingContextCursorPosition,
+ editorState.postLayoutData().surroundingContextSelectionPosition);
}
}
Modified: trunk/Source/WebKit/UIProcess/API/wpe/WPEView.cpp (258130 => 258131)
--- trunk/Source/WebKit/UIProcess/API/wpe/WPEView.cpp 2020-03-09 06:44:10 UTC (rev 258130)
+++ trunk/Source/WebKit/UIProcess/API/wpe/WPEView.cpp 2020-03-09 08:39:44 UTC (rev 258131)
@@ -258,8 +258,8 @@
const auto& editorState = m_pageProxy->editorState();
if (!editorState.isMissingPostLayoutData) {
m_inputMethodFilter.notifyCursorRect(editorState.postLayoutData().caretRectAtStart);
- m_inputMethodFilter.notifySurrounding(editorState.postLayoutData().paragraphContext, editorState.postLayoutData().paragraphContextCursorPosition,
- editorState.postLayoutData().paragraphContextSelectionPosition);
+ m_inputMethodFilter.notifySurrounding(editorState.postLayoutData().surroundingContext, editorState.postLayoutData().surroundingContextCursorPosition,
+ editorState.postLayoutData().surroundingContextSelectionPosition);
}
}
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (258130 => 258131)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2020-03-09 06:44:10 UTC (rev 258130)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2020-03-09 08:39:44 UTC (rev 258131)
@@ -5485,9 +5485,9 @@
return;
auto selectionStart = selection.visibleStart();
- auto paragraphRange = makeRange(startOfParagraph(selectionStart), selectionStart);
- auto cursorPosition = TextIterator::rangeLength(paragraphRange.get());
- auto& rootNode = paragraphRange->startContainer().treeScope().rootNode();
+ auto surroundingRange = makeRange(startOfEditableContent(selectionStart), selectionStart);
+ auto cursorPosition = TextIterator::rangeLength(surroundingRange.get());
+ auto& rootNode = surroundingRange->startContainer().treeScope().rootNode();
auto selectionRange = TextIterator::rangeFromLocationAndLength(&rootNode, cursorPosition + offset, characterCount);
if (!selectionRange)
return;
Modified: trunk/Source/WebKit/WebProcess/WebPage/glib/WebPageGLib.cpp (258130 => 258131)
--- trunk/Source/WebKit/WebProcess/WebPage/glib/WebPageGLib.cpp 2020-03-09 06:44:10 UTC (rev 258130)
+++ trunk/Source/WebKit/WebProcess/WebPage/glib/WebPageGLib.cpp 2020-03-09 08:39:44 UTC (rev 258131)
@@ -107,21 +107,21 @@
if (selection.isContentEditable()) {
auto selectionStart = selection.visibleStart();
- auto paragraphStart = startOfParagraph(selectionStart);
- auto paragraphEnd = endOfParagraph(selectionStart);
- auto paragraphRange = makeRange(paragraphStart, paragraphEnd);
+ auto surroundingStart = startOfEditableContent(selectionStart);
+ auto surroundingEnd = endOfEditableContent(selectionStart);
+ auto surroundingRange = makeRange(surroundingStart, surroundingEnd);
auto compositionRange = frame.editor().compositionRange();
- if (compositionRange && paragraphRange->contains(*compositionRange)) {
- auto clonedRange = paragraphRange->cloneRange();
- paragraphRange->setEnd(compositionRange->startPosition());
+ if (compositionRange && surroundingRange->contains(*compositionRange)) {
+ auto clonedRange = surroundingRange->cloneRange();
+ surroundingRange->setEnd(compositionRange->startPosition());
clonedRange->setStart(compositionRange->endPosition());
- postLayoutData.paragraphContext = plainText(paragraphRange.get()) + plainText(clonedRange.ptr());
- postLayoutData.paragraphContextCursorPosition = TextIterator::rangeLength(paragraphRange.get());
- postLayoutData.paragraphContextSelectionPosition = postLayoutData.paragraphContextCursorPosition;
+ postLayoutData.surroundingContext = plainText(surroundingRange.get()) + plainText(clonedRange.ptr());
+ postLayoutData.surroundingContextCursorPosition = TextIterator::rangeLength(surroundingRange.get());
+ postLayoutData.surroundingContextSelectionPosition = postLayoutData.surroundingContextCursorPosition;
} else {
- postLayoutData.paragraphContext = plainText(paragraphRange.get());
- postLayoutData.paragraphContextCursorPosition = TextIterator::rangeLength(makeRange(paragraphStart, selectionStart).get());
- postLayoutData.paragraphContextSelectionPosition = TextIterator::rangeLength(makeRange(paragraphStart, selection.visibleEnd()).get());
+ postLayoutData.surroundingContext = plainText(surroundingRange.get());
+ postLayoutData.surroundingContextCursorPosition = TextIterator::rangeLength(makeRange(surroundingStart, selectionStart).get());
+ postLayoutData.surroundingContextSelectionPosition = TextIterator::rangeLength(makeRange(surroundingStart, selection.visibleEnd()).get());
}
}
}
Modified: trunk/Tools/ChangeLog (258130 => 258131)
--- trunk/Tools/ChangeLog 2020-03-09 06:44:10 UTC (rev 258130)
+++ trunk/Tools/ChangeLog 2020-03-09 08:39:44 UTC (rev 258131)
@@ -1,3 +1,15 @@
+2020-03-09 Carlos Garcia Campos <cgar...@igalia.com>
+
+ [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.
+
+ Add test case to check surrounding text in multiline context.
+
+ * TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp:
+ (testWebKitInputMethodContextSurrounding):
+
2020-03-08 Per Arne Vollan <pvol...@apple.com>
[iOS] Mapping to UTI from tag and tag class should be performed in the UI process
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp (258130 => 258131)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp 2020-03-09 06:44:10 UTC (rev 258130)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp 2020-03-09 08:39:44 UTC (rev 258131)
@@ -52,7 +52,7 @@
G_DEFINE_TYPE(WebKitInputMethodContextMock, webkit_input_method_context_mock, WEBKIT_TYPE_INPUT_METHOD_CONTEXT)
-static const char* testHTML = "<html><body><input id='editable' contenteditable _onkeydown_='logKeyDown()' _onkeyup_='logKeyUp()' _onkeypress_='logKeyPress()'></input><script>"
+static const char* testHTML = "<html><body><textarea id='editable' rows='3', cols='50' _onkeydown_='logKeyDown()' _onkeyup_='logKeyUp()' _onkeypress_='logKeyPress()'></textarea><script>"
"var input = document.getElementById('editable');"
"input.addEventListener('compositionstart', logCompositionEvent);"
"input.addEventListener('compositionupdate', logCompositionEvent);"
@@ -860,6 +860,16 @@
g_assert_cmpstr(test->surroundingText(), ==, "WebKitGTKWPEWebKitabcWebKitGTK😀️");
g_assert_cmpuint(test->surroundingCursorIndex(), ==, 37);
g_assert_cmpuint(test->surroundingSelectionIndex(), ==, test->surroundingCursorIndex());
+ test->m_events.clear();
+
+ // Check multiline context.
+ test->keyStrokeAndWaitForEvents(KEY(Return), 3);
+ test->keyStrokeAndWaitForEvents(KEY(a), 6);
+ test->waitForSurroundingText("WebKitGTKWPEWebKitabcWebKitGTK😀️\na");
+ g_assert_cmpstr(test->surroundingText(), ==, "WebKitGTKWPEWebKitabcWebKitGTK😀️\na");
+ g_assert_cmpuint(test->surroundingCursorIndex(), ==, 39);
+ g_assert_cmpuint(test->surroundingSelectionIndex(), ==, test->surroundingCursorIndex());
+ test->m_events.clear();
}
static void testWebKitInputMethodContextReset(InputMethodTest* test, gconstpointer)