Title: [265209] trunk
Revision
265209
Author
[email protected]
Date
2020-08-03 11:31:59 -0700 (Mon, 03 Aug 2020)

Log Message

should be able to request an editing context for a given region of a given input
https://bugs.webkit.org/show_bug.cgi?id=215042
<rdar://problem/65561491>

Reviewed by Wenson Hsieh.

Source/WebKit:

Right now, it's only possible to request an editing context for either an entire input
element or a particular rect of the page.  It should be possible to request an editing
context for a particular rect within a given input element as well (e.g. get one paragraph
or the currently selected text in a `<textarea>` instead of the entire thing).

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::requestDocumentEditingContext):

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm:
(TEST.DocumentEditingContext.SpatialRequest_RectEncompassingInput): Added.
(TEST.DocumentEditingContext.SpatialRequest_RectBeforeInput): Added.
(TEST.DocumentEditingContext.SpatialRequest_RectInsideInput): Added.
(TEST.DocumentEditingContext.SpatialRequest_RectAfterInput): Added.
(TEST.DocumentEditingContext.SpatialAndCurrentSelectionRequest_RectEncompassingInputWithSelection): Added.
(TEST.DocumentEditingContext.SpatialAndCurrentSelectionRequest_RectBeforeInputWithSelection): Added.
(TEST.DocumentEditingContext.SpatialAndCurrentSelectionRequest_RectBeforeSelectionInInput): Added.
(TEST.DocumentEditingContext.SpatialAndCurrentSelectionRequest_RectAfterSelectionInInput): Added.
(TEST.DocumentEditingContext.SpatialAndCurrentSelectionRequest_RectAfterInputWithSelection): Added.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (265208 => 265209)


--- trunk/Source/WebKit/ChangeLog	2020-08-03 18:19:06 UTC (rev 265208)
+++ trunk/Source/WebKit/ChangeLog	2020-08-03 18:31:59 UTC (rev 265209)
@@ -1,3 +1,19 @@
+2020-08-03  Devin Rousso  <[email protected]>
+
+        should be able to request an editing context for a given region of a given input
+        https://bugs.webkit.org/show_bug.cgi?id=215042
+        <rdar://problem/65561491>
+
+        Reviewed by Wenson Hsieh.
+
+        Right now, it's only possible to request an editing context for either an entire input
+        element or a particular rect of the page.  It should be possible to request an editing
+        context for a particular rect within a given input element as well (e.g. get one paragraph
+        or the currently selected text in a `<textarea>` instead of the entire thing).
+
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::requestDocumentEditingContext):
+
 2020-08-03  Kate Cheney  <[email protected]>
 
         doesParentProcessHaveITPEnabled() check should match behavior in determineITPStateInternal() check

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (265208 => 265209)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2020-08-03 18:19:06 UTC (rev 265208)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2020-08-03 18:31:59 UTC (rev 265209)
@@ -4131,7 +4131,11 @@
             completionHandler({ });
             return;
         }
-        if (is<HTMLTextFormControlElement>(element)) {
+
+        if (!request.rect.isEmpty()) {
+            rangeOfInterestStart = closestEditablePositionInElementForAbsolutePoint(*element, roundedIntPoint(request.rect.minXMinYCorner()));
+            rangeOfInterestEnd = closestEditablePositionInElementForAbsolutePoint(*element, roundedIntPoint(request.rect.maxXMaxYCorner()));
+        } else if (is<HTMLTextFormControlElement>(element)) {
             auto& textFormControlElement = downcast<HTMLTextFormControlElement>(*element);
             rangeOfInterestStart = textFormControlElement.visiblePositionForIndex(0);
             rangeOfInterestEnd = textFormControlElement.visiblePositionForIndex(textFormControlElement.value().length());
@@ -4143,19 +4147,21 @@
         // FIXME: We might need to be a bit more careful that we get something useful (test the other corners?).
         rangeOfInterestStart = visiblePositionForPointInRootViewCoordinates(frame.get(), request.rect.minXMinYCorner());
         rangeOfInterestEnd = visiblePositionForPointInRootViewCoordinates(frame.get(), request.rect.maxXMaxYCorner());
-        if (rangeOfInterestEnd < rangeOfInterestStart)
-            std::exchange(rangeOfInterestStart, rangeOfInterestEnd);
-        if (request.options.contains(DocumentEditingContextRequest::Options::SpatialAndCurrentSelection)) {
-            if (selectionStart < rangeOfInterestStart)
-                rangeOfInterestStart = selectionStart;
-            if (selectionEnd > rangeOfInterestEnd)
-                rangeOfInterestEnd = selectionEnd;
-        }
     } else if (!selection.isNone()) {
         rangeOfInterestStart = selectionStart;
         rangeOfInterestEnd = selectionEnd;
     }
 
+    if (rangeOfInterestEnd < rangeOfInterestStart)
+        std::exchange(rangeOfInterestStart, rangeOfInterestEnd);
+
+    if (request.options.contains(DocumentEditingContextRequest::Options::SpatialAndCurrentSelection)) {
+        if (selectionStart < rangeOfInterestStart)
+            rangeOfInterestStart = selectionStart;
+        if (selectionEnd > rangeOfInterestEnd)
+            rangeOfInterestEnd = selectionEnd;
+    }
+
     if (rangeOfInterestStart.isNull() || rangeOfInterestStart.isOrphan() || rangeOfInterestEnd.isNull() || rangeOfInterestEnd.isOrphan()) {
         completionHandler({ });
         return;

Modified: trunk/Tools/ChangeLog (265208 => 265209)


--- trunk/Tools/ChangeLog	2020-08-03 18:19:06 UTC (rev 265208)
+++ trunk/Tools/ChangeLog	2020-08-03 18:31:59 UTC (rev 265209)
@@ -1,3 +1,22 @@
+2020-08-03  Devin Rousso  <[email protected]>
+
+        should be able to request an editing context for a given region of a given input
+        https://bugs.webkit.org/show_bug.cgi?id=215042
+        <rdar://problem/65561491>
+
+        Reviewed by Wenson Hsieh.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm:
+        (TEST.DocumentEditingContext.SpatialRequest_RectEncompassingInput): Added.
+        (TEST.DocumentEditingContext.SpatialRequest_RectBeforeInput): Added.
+        (TEST.DocumentEditingContext.SpatialRequest_RectInsideInput): Added.
+        (TEST.DocumentEditingContext.SpatialRequest_RectAfterInput): Added.
+        (TEST.DocumentEditingContext.SpatialAndCurrentSelectionRequest_RectEncompassingInputWithSelection): Added.
+        (TEST.DocumentEditingContext.SpatialAndCurrentSelectionRequest_RectBeforeInputWithSelection): Added.
+        (TEST.DocumentEditingContext.SpatialAndCurrentSelectionRequest_RectBeforeSelectionInInput): Added.
+        (TEST.DocumentEditingContext.SpatialAndCurrentSelectionRequest_RectAfterSelectionInInput): Added.
+        (TEST.DocumentEditingContext.SpatialAndCurrentSelectionRequest_RectAfterInputWithSelection): Added.
+
 2020-08-03  Zhifei Fang  <[email protected]>
 
         run-jsc-stress-test: Set DYLD_FRAMEWORK_PATH to "$(cd ../.vm; pwd)" because it escape shell words

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm (265208 => 265209)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm	2020-08-03 18:19:06 UTC (rev 265208)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm	2020-08-03 18:31:59 UTC (rev 265209)
@@ -487,6 +487,88 @@
     return CGRectMake([domRect[@"left"] floatValue], [domRect[@"top"] floatValue], [domRect[@"width"] floatValue], [domRect[@"height"] floatValue]);
 }
 
+TEST(DocumentEditingContext, SpatialRequest_RectEncompassingInput)
+{
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 980, 600)]);
+
+    // Use "padding: 0" as the default user-agent stylesheet can effect text wrapping.
+    [webView synchronouslyLoadHTMLString:applyAhemStyle(@"before <textarea id='test' style='width: 26em; margin: 200px 0 0 200px; padding: 0;'>The quick brown fox jumps over the lazy dog.</textarea> after")]; // Word wraps "over" onto next line
+
+    NSArray<_WKTextInputContext *> *textInputContexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
+    EXPECT_EQ(1UL, textInputContexts.count);
+
+    UIWKDocumentContext *context = [webView synchronouslyRequestDocumentContext:makeRequest(UIWKDocumentRequestText | UIWKDocumentRequestSpatial, UITextGranularityWord, 200, [webView frame], textInputContexts[0])];
+    EXPECT_NSSTRING_EQ("The quick brown fox ", context.contextBefore);
+    EXPECT_NULL(context.selectedText);
+    EXPECT_NSSTRING_EQ("jumps over the lazy dog.", context.contextAfter);
+}
+
+TEST(DocumentEditingContext, SpatialRequest_RectBeforeInput)
+{
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 980, 600)]);
+
+    // Use "padding: 0" as the default user-agent stylesheet can effect text wrapping.
+    [webView synchronouslyLoadHTMLString:applyAhemStyle(@"before <textarea id='test' style='width: 26em; margin: 200px 0 0 200px; padding: 0;'>The quick brown fox jumps over the lazy dog.</textarea> after")]; // Word wraps "over" onto next line
+
+    NSArray<_WKTextInputContext *> *textInputContexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
+    EXPECT_EQ(1UL, textInputContexts.count);
+
+    auto documentRect = CGRectFromJSONEncodedDOMRectJSValue([webView objectByEvaluatingJavaScript:@"test.getBoundingClientRect().toJSON()"]);
+    documentRect.origin.x -= glyphWidth * 2;
+    documentRect.origin.y -= glyphWidth * 2;
+    documentRect.size.width = glyphWidth;
+    documentRect.size.height = glyphWidth;
+
+    UIWKDocumentContext *context = [webView synchronouslyRequestDocumentContext:makeRequest(UIWKDocumentRequestText | UIWKDocumentRequestSpatial, UITextGranularityWord, 200, documentRect, textInputContexts[0])];
+    EXPECT_NULL(context.contextBefore);
+    EXPECT_NULL(context.selectedText);
+    EXPECT_NSSTRING_EQ("The quick brown fox jumps over the lazy dog.", context.contextAfter);
+}
+
+TEST(DocumentEditingContext, SpatialRequest_RectInsideInput)
+{
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 980, 600)]);
+
+    // Use "padding: 0" as the default user-agent stylesheet can effect text wrapping.
+    [webView synchronouslyLoadHTMLString:applyAhemStyle(@"before <textarea id='test' style='width: 26em; margin: 200px 0 0 200px; padding: 0;'>The quick brown fox jumps over the lazy dog.</textarea> after")]; // Word wraps "over" onto next line
+
+    NSArray<_WKTextInputContext *> *textInputContexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
+    EXPECT_EQ(1UL, textInputContexts.count);
+
+    auto documentRect = CGRectFromJSONEncodedDOMRectJSValue([webView objectByEvaluatingJavaScript:@"test.getBoundingClientRect().toJSON()"]);
+    documentRect.origin.x += (documentRect.size.width / 2) - (glyphWidth * 2);
+    documentRect.origin.y += (documentRect.size.height / 2) - (glyphWidth * 2);
+    documentRect.size.width = glyphWidth;
+    documentRect.size.height = glyphWidth;
+
+    UIWKDocumentContext *context = [webView synchronouslyRequestDocumentContext:makeRequest(UIWKDocumentRequestText | UIWKDocumentRequestSpatial, UITextGranularityWord, 200, documentRect, textInputContexts[0])];
+    EXPECT_NSSTRING_EQ("The quick b", context.contextBefore);
+    EXPECT_NULL(context.selectedText);
+    EXPECT_NSSTRING_EQ("rown fox jumps over the lazy dog.", context.contextAfter);
+}
+
+TEST(DocumentEditingContext, SpatialRequest_RectAfterInput)
+{
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 980, 600)]);
+
+    // Use "padding: 0" as the default user-agent stylesheet can effect text wrapping.
+    [webView synchronouslyLoadHTMLString:applyAhemStyle(@"before <textarea id='test' style='width: 26em; margin: 200px 0 0 200px; padding: 0;'>The quick brown fox jumps over the lazy dog.</textarea> after")]; // Word wraps "over" onto next line
+
+    NSArray<_WKTextInputContext *> *textInputContexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
+    EXPECT_EQ(1UL, textInputContexts.count);
+
+    auto documentRect = CGRectFromJSONEncodedDOMRectJSValue([webView objectByEvaluatingJavaScript:@"test.getBoundingClientRect().toJSON()"]);
+    documentRect.origin.x += documentRect.size.width + glyphWidth;
+    documentRect.origin.y += documentRect.size.height + glyphWidth;
+    documentRect.size.width = glyphWidth;
+    documentRect.size.height = glyphWidth;
+
+    UIWKDocumentContext *context = [webView synchronouslyRequestDocumentContext:makeRequest(UIWKDocumentRequestText | UIWKDocumentRequestSpatial, UITextGranularityWord, 200, documentRect, textInputContexts[0])];
+    EXPECT_NSSTRING_EQ("The quick brown fox jumps over the lazy dog.", context.contextBefore);
+    EXPECT_NULL(context.selectedText);
+    EXPECT_NULL(context.contextAfter);
+}
+
 TEST(DocumentEditingContext, SpatialAndCurrentSelectionRequest_RectBeforeRangeSelection)
 {
     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 980, 600)]);
@@ -601,6 +683,119 @@
     EXPECT_NSSTRING_EQ("jumps over the", context.contextAfter);
 }
 
+TEST(DocumentEditingContext, SpatialAndCurrentSelectionRequest_RectEncompassingInputWithSelection)
+{
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 980, 600)]);
+
+    // Use "padding: 0" as the default user-agent stylesheet can effect text wrapping.
+    [webView synchronouslyLoadHTMLString:applyAhemStyle(@"before <span contenteditable id='test' style='display: inline-block; width: 26em; margin: 200px 0 0 200px;'>The quick brown <span id='fox_jumps_over'>fox jumps over</span> the lazy dog.</span> after")]; // Word wraps "over" onto next line
+    [webView stringByEvaluatingJavaScript:@"getSelection().setBaseAndExtent(fox_jumps_over, 0, fox_jumps_over, 1)"];
+
+    NSArray<_WKTextInputContext *> *textInputContexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
+    EXPECT_EQ(1UL, textInputContexts.count);
+
+    UIWKDocumentContext *context = [webView synchronouslyRequestDocumentContext:makeRequest(UIWKDocumentRequestText | UIWKDocumentRequestSpatialAndCurrentSelection, UITextGranularityWord, 200, [webView frame], textInputContexts[0])];
+    EXPECT_NSSTRING_EQ("The quick brown ", context.contextBefore);
+    EXPECT_NSSTRING_EQ("fox jumps over", context.selectedText);
+    EXPECT_NSSTRING_EQ(" the lazy dog.", context.contextAfter);
+}
+
+TEST(DocumentEditingContext, SpatialAndCurrentSelectionRequest_RectBeforeInputWithSelection)
+{
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 980, 600)]);
+
+    // Use "padding: 0" as the default user-agent stylesheet can effect text wrapping.
+    [webView synchronouslyLoadHTMLString:applyAhemStyle(@"before <span contenteditable id='test' style='display: inline-block; width: 26em; margin: 200px 0 0 200px;'>The quick brown <span id='fox_jumps_over'>fox jumps over</span> the lazy dog.</span> after")]; // Word wraps "over" onto next line
+    [webView stringByEvaluatingJavaScript:@"getSelection().setBaseAndExtent(fox_jumps_over, 0, fox_jumps_over, 1)"];
+
+    NSArray<_WKTextInputContext *> *textInputContexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
+    EXPECT_EQ(1UL, textInputContexts.count);
+
+    auto documentRect = CGRectFromJSONEncodedDOMRectJSValue([webView objectByEvaluatingJavaScript:@"test.getBoundingClientRect().toJSON()"]);
+    documentRect.origin.x -= glyphWidth * 2;
+    documentRect.origin.y -= glyphWidth * 2;
+    documentRect.size.width = glyphWidth;
+    documentRect.size.height = glyphWidth;
+
+    UIWKDocumentContext *context = [webView synchronouslyRequestDocumentContext:makeRequest(UIWKDocumentRequestText | UIWKDocumentRequestSpatialAndCurrentSelection, UITextGranularityWord, 200, documentRect, textInputContexts[0])];
+    EXPECT_NSSTRING_EQ("The quick brown ", context.contextBefore);
+    EXPECT_NSSTRING_EQ("fox jumps over", context.selectedText);
+    EXPECT_NSSTRING_EQ(" the lazy dog.", context.contextAfter);
+}
+
+TEST(DocumentEditingContext, SpatialAndCurrentSelectionRequest_RectBeforeSelectionInInput)
+{
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 980, 600)]);
+
+    // Use "padding: 0" as the default user-agent stylesheet can effect text wrapping.
+    [webView synchronouslyLoadHTMLString:applyAhemStyle(@"before <span contenteditable id='test' style='display: inline-block; width: 26em; margin: 200px 0 0 200px;'>The quick brown <span id='fox_jumps_over'>fox jumps over</span> the lazy dog.</span> after")]; // Word wraps "over" onto next line
+    [webView stringByEvaluatingJavaScript:@"getSelection().setBaseAndExtent(fox_jumps_over, 0, fox_jumps_over, 1)"];
+
+    NSArray<_WKTextInputContext *> *textInputContexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
+    EXPECT_EQ(1UL, textInputContexts.count);
+
+    auto selectionBoxRect = CGRectFromJSONEncodedDOMRectJSValue([webView objectByEvaluatingJavaScript:@"fox_jumps_over.getBoundingClientRect().toJSON()"]);
+
+    auto documentRect = CGRectFromJSONEncodedDOMRectJSValue([webView objectByEvaluatingJavaScript:@"test.getBoundingClientRect().toJSON()"]);
+    documentRect.origin.x = ((documentRect.origin.x + selectionBoxRect.origin.x) / 2) - (glyphWidth * 2);
+    documentRect.origin.y = ((documentRect.origin.y + selectionBoxRect.origin.y) / 2) - (glyphWidth * 2);
+    documentRect.size.width = glyphWidth;
+    documentRect.size.height = glyphWidth;
+
+    UIWKDocumentContext *context = [webView synchronouslyRequestDocumentContext:makeRequest(UIWKDocumentRequestText | UIWKDocumentRequestSpatialAndCurrentSelection, UITextGranularityWord, 200, documentRect, textInputContexts[0])];
+    EXPECT_NSSTRING_EQ("The quick brown ", context.contextBefore);
+    EXPECT_NSSTRING_EQ("fox jumps over", context.selectedText);
+    EXPECT_NSSTRING_EQ(" the lazy dog.", context.contextAfter);
+}
+
+TEST(DocumentEditingContext, SpatialAndCurrentSelectionRequest_RectAfterSelectionInInput)
+{
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 980, 600)]);
+
+    // Use "padding: 0" as the default user-agent stylesheet can effect text wrapping.
+    [webView synchronouslyLoadHTMLString:applyAhemStyle(@"before <span contenteditable id='test' style='display: inline-block; width: 26em; margin: 200px 0 0 200px;'>The quick brown <span id='fox_jumps_over'>fox jumps over</span> the lazy dog.</span> after")]; // Word wraps "over" onto next line
+    [webView stringByEvaluatingJavaScript:@"getSelection().setBaseAndExtent(fox_jumps_over, 0, fox_jumps_over, 1)"];
+
+    NSArray<_WKTextInputContext *> *textInputContexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
+    EXPECT_EQ(1UL, textInputContexts.count);
+
+    auto selectionBoxRect = CGRectFromJSONEncodedDOMRectJSValue([webView objectByEvaluatingJavaScript:@"fox_jumps_over.getBoundingClientRect().toJSON()"]);
+
+    auto documentRect = CGRectFromJSONEncodedDOMRectJSValue([webView objectByEvaluatingJavaScript:@"test.getBoundingClientRect().toJSON()"]);
+    documentRect.origin.x = ((documentRect.origin.x + documentRect.size.width + selectionBoxRect.origin.x + selectionBoxRect.size.width) / 2) + glyphWidth;
+    documentRect.origin.y = ((documentRect.origin.y + documentRect.size.height + selectionBoxRect.origin.y + selectionBoxRect.size.height) / 2) + glyphWidth;
+    documentRect.size.width = glyphWidth;
+    documentRect.size.height = glyphWidth;
+
+    UIWKDocumentContext *context = [webView synchronouslyRequestDocumentContext:makeRequest(UIWKDocumentRequestText | UIWKDocumentRequestSpatialAndCurrentSelection, UITextGranularityWord, 200, documentRect, textInputContexts[0])];
+    EXPECT_NSSTRING_EQ("The quick brown ", context.contextBefore);
+    EXPECT_NSSTRING_EQ("fox jumps over", context.selectedText);
+    EXPECT_NSSTRING_EQ(" the lazy dog.", context.contextAfter);
+}
+
+TEST(DocumentEditingContext, SpatialAndCurrentSelectionRequest_RectAfterInputWithSelection)
+{
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 980, 600)]);
+
+    // Use "padding: 0" as the default user-agent stylesheet can effect text wrapping.
+    [webView synchronouslyLoadHTMLString:applyAhemStyle(@"before <span contenteditable id='test' style='display: inline-block; width: 26em; margin: 200px 0 0 200px;'>The quick brown <span id='fox_jumps_over'>fox jumps over</span> the lazy dog.</span> after")]; // Word wraps "over" onto next line
+    [webView stringByEvaluatingJavaScript:@"getSelection().setBaseAndExtent(fox_jumps_over, 0, fox_jumps_over, 1)"];
+
+    NSArray<_WKTextInputContext *> *textInputContexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
+    EXPECT_EQ(1UL, textInputContexts.count);
+
+    auto documentRect = CGRectFromJSONEncodedDOMRectJSValue([webView objectByEvaluatingJavaScript:@"test.getBoundingClientRect().toJSON()"]);
+    documentRect.origin.x += documentRect.size.width + (glyphWidth * 2);
+    documentRect.origin.y += documentRect.size.height + (glyphWidth * 2);
+    documentRect.size.width = glyphWidth;
+    documentRect.size.height = glyphWidth;
+
+    UIWKDocumentContext *context = [webView synchronouslyRequestDocumentContext:makeRequest(UIWKDocumentRequestText | UIWKDocumentRequestSpatialAndCurrentSelection, UITextGranularityWord, 200, documentRect, textInputContexts[0])];
+    EXPECT_NSSTRING_EQ("The quick brown ", context.contextBefore);
+    EXPECT_NSSTRING_EQ("fox jumps over", context.selectedText);
+    EXPECT_NSSTRING_EQ(" the lazy dog.", context.contextAfter);
+}
+
 TEST(DocumentEditingContext, RequestRectsInTextAreaAcrossWordWrappedLine)
 {
     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to