Title: [206449] trunk
Revision
206449
Author
[email protected]
Date
2016-09-27 11:31:32 -0700 (Tue, 27 Sep 2016)

Log Message

[iOS] REGRESSION (r182126): Selection highlight and handles aren’t visible with WKSelectionGranularityCharacter
https://bugs.webkit.org/show_bug.cgi?id=162577
<rdar://problem/28481984>

Reviewed by Simon Fraser.

Source/WebKit2:

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _uiTextSelectionRectViews]): Added this method in the WKTesting category, which
  uses UIKit internals to get the views used for the selection highlight.
* UIProcess/API/Cocoa/WKWebViewPrivate.h:

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _selectionClipRect]): When selection is not confined to a form control or
  content-editable element, return the null rect to indicate no clipping, rather than
  clipping to the empty rect at the origin.

Tools:

* DumpRenderTree/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::selectionRangeViewRects): Returns null.

* TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl: Declared new
  selectionRangeViewRects attribute.

* TestRunnerShared/UIScriptContext/UIScriptContext.h:
(WTR::UIScriptContext::jsContext): Added this public accessor.

* TestRunnerShared/UIScriptContext/UIScriptController.cpp:
(WTR::selectionRangeViewRects): Generic implementation that returns null.
* TestRunnerShared/UIScriptContext/UIScriptController.h:

* WebKitTestRunner/TestController.cpp:
(WTR::updateTestOptionsFromTestHeader): Parse the new useCharacterSelectionGranularity
  option.

* WebKitTestRunner/TestOptions.h: Added new useCharacterSelectionGranularity option.

* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::TestController::platformCreateWebView): Set the configuration’s selectionGranularity
  property based on the new option.

* WebKitTestRunner/ios/PlatformWebViewIOS.mm:
(WTR::PlatformWebView::viewSupportsOptions): Compare selection granularity option values.

* WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::selectionRangeViewRects): iOS-specific implementation that calls
  the new -[WKWebView _uiTextSelectionRectViews] and returns an array of view frame
  dictionaries.

LayoutTests:

* TestExpectations:
* editing/selection/character-granularity-rect-expected.txt: Added.
* editing/selection/character-granularity-rect.html: Added.
* platform/ios-simulator-wk2/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (206448 => 206449)


--- trunk/LayoutTests/ChangeLog	2016-09-27 18:10:56 UTC (rev 206448)
+++ trunk/LayoutTests/ChangeLog	2016-09-27 18:31:32 UTC (rev 206449)
@@ -1,3 +1,16 @@
+2016-09-27  Dan Bernstein  <[email protected]>
+
+        [iOS] REGRESSION (r182126): Selection highlight and handles aren’t visible with WKSelectionGranularityCharacter
+        https://bugs.webkit.org/show_bug.cgi?id=162577
+        <rdar://problem/28481984>
+
+        Reviewed by Simon Fraser.
+
+        * TestExpectations:
+        * editing/selection/character-granularity-rect-expected.txt: Added.
+        * editing/selection/character-granularity-rect.html: Added.
+        * platform/ios-simulator-wk2/TestExpectations:
+
 2016-09-27  Jer Noble  <[email protected]>
 
         Remove deprecated ENCRYPTED_MEDIA implementation.

Modified: trunk/LayoutTests/TestExpectations (206448 => 206449)


--- trunk/LayoutTests/TestExpectations	2016-09-27 18:10:56 UTC (rev 206448)
+++ trunk/LayoutTests/TestExpectations	2016-09-27 18:31:32 UTC (rev 206449)
@@ -63,6 +63,9 @@
 # This test only makes sense on iOS
 fast/attachment/attachment-wrapping-action.html
 
+# Only iOS has selection UI drawn by UIKit
+editing/selection/character-granularity-rect.html [ Skip ]
+
 #//////////////////////////////////////////////////////////////////////////////////////////
 # End platform-specific tests.
 #//////////////////////////////////////////////////////////////////////////////////////////

Added: trunk/LayoutTests/editing/selection/character-granularity-rect-expected.txt (0 => 206449)


--- trunk/LayoutTests/editing/selection/character-granularity-rect-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/character-granularity-rect-expected.txt	2016-09-27 18:31:32 UTC (rev 206449)
@@ -0,0 +1 @@
+PASS

Added: trunk/LayoutTests/editing/selection/character-granularity-rect.html (0 => 206449)


--- trunk/LayoutTests/editing/selection/character-granularity-rect.html	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/character-granularity-rect.html	2016-09-27 18:31:32 UTC (rev 206449)
@@ -0,0 +1,56 @@
+<!-- webkit-test-runner [ useCharacterSelectionGranularity=true ] -->
+<meta name=viewport content="width=device-width">
+<style>
+    #target {
+        height: 100px;
+        width: 200px;
+        background-color: silver;
+    }
+</style>
+<div id="target">
+	<p style="font-family: ahem;">PressMe</p>
+    This test requires UIScriptController to run.
+</div>
+<script>
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+    }
+
+    function getUIScript()
+    {
+        return `
+        (function() {
+            uiController.longPressAtPoint(30, 20, function() {
+                uiController.uiScriptComplete(JSON.stringify(uiController.selectionRangeViewRects));
+            });
+        })();`
+    }
+
+    function runTest()
+    {
+        if (!testRunner.runUIScript)
+            return;
+
+        var target = document.getElementById('target');
+        if (testRunner.runUIScript) {
+            testRunner.runUIScript(getUIScript(), function(result) {
+                var selectionRangeViewRects = JSON.parse(result);
+                var output;
+                if (selectionRangeViewRects.length !== 1)
+                    output = 'FAIL: Unexpected number of selection range views: ' + result;
+                else {
+                    var rect = selectionRangeViewRects[0];
+                    if (rect.left != 8 || rect.top != 8 || rect.width != 112 || rect.height != 17 )
+                        output = 'FAIL: Unexpected selection range view frame: ' + result;
+                    else
+                        output = 'PASS';
+                }
+                document.getElementById('target').innerText = output;
+                testRunner.notifyDone();
+            });
+        }
+    }
+
+    runTest();
+</script>

Modified: trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations (206448 => 206449)


--- trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations	2016-09-27 18:10:56 UTC (rev 206448)
+++ trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations	2016-09-27 18:31:32 UTC (rev 206449)
@@ -8,6 +8,7 @@
 
 fast/scrolling/ios [ Pass ]
 fast/viewport/ios [ Pass ]
+editing/selection/character-granularity-rect.html [ Pass ]
 
 #//////////////////////////////////////////////////////////////////////////////////////////
 # End platform-specific directories.

Modified: trunk/Source/WebKit2/ChangeLog (206448 => 206449)


--- trunk/Source/WebKit2/ChangeLog	2016-09-27 18:10:56 UTC (rev 206448)
+++ trunk/Source/WebKit2/ChangeLog	2016-09-27 18:31:32 UTC (rev 206449)
@@ -1,3 +1,21 @@
+2016-09-27  Dan Bernstein  <[email protected]>
+
+        [iOS] REGRESSION (r182126): Selection highlight and handles aren’t visible with WKSelectionGranularityCharacter
+        https://bugs.webkit.org/show_bug.cgi?id=162577
+        <rdar://problem/28481984>
+
+        Reviewed by Simon Fraser.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _uiTextSelectionRectViews]): Added this method in the WKTesting category, which
+          uses UIKit internals to get the views used for the selection highlight.
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _selectionClipRect]): When selection is not confined to a form control or
+          content-editable element, return the null rect to indicate no clipping, rather than
+          clipping to the empty rect at the origin.
+
 2016-09-27  Jer Noble  <[email protected]>
 
         Remove deprecated ENCRYPTED_MEDIA implementation.

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (206448 => 206449)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2016-09-27 18:10:56 UTC (rev 206448)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2016-09-27 18:31:32 UTC (rev 206449)
@@ -4529,6 +4529,11 @@
     // For subclasses to override.
 }
 
+- (NSArray<UIView *> *)_uiTextSelectionRectViews
+{
+    return [_contentView valueForKeyPath:@"interactionAssistant.selectionView.rangeView.m_rectViews"];
+}
+
 #endif // PLATFORM(IOS)
 
 #if PLATFORM(MAC)

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h (206448 => 206449)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h	2016-09-27 18:10:56 UTC (rev 206448)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h	2016-09-27 18:31:32 UTC (rev 206449)
@@ -267,6 +267,8 @@
 - (void)didStartFormControlInteraction WK_API_AVAILABLE(ios(WK_IOS_TBA));
 - (void)didEndFormControlInteraction WK_API_AVAILABLE(ios(WK_IOS_TBA));
 
+@property (nonatomic, readonly) NSArray<UIView *> *_uiTextSelectionRectViews WK_API_AVAILABLE(ios(WK_IOS_TBA));
+
 #endif
 
 #if !TARGET_OS_IPHONE

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (206448 => 206449)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2016-09-27 18:10:56 UTC (rev 206448)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2016-09-27 18:31:32 UTC (rev 206449)
@@ -1127,7 +1127,7 @@
 - (CGRect)_selectionClipRect
 {
     if (_assistedNodeInformation.elementType == InputType::None)
-        return CGRectZero;
+        return CGRectNull;
     return _page->editorState().postLayoutData().selectionClipRect;
 }
 

Modified: trunk/Tools/ChangeLog (206448 => 206449)


--- trunk/Tools/ChangeLog	2016-09-27 18:10:56 UTC (rev 206448)
+++ trunk/Tools/ChangeLog	2016-09-27 18:31:32 UTC (rev 206449)
@@ -1,3 +1,42 @@
+2016-09-27  Dan Bernstein  <[email protected]>
+
+        [iOS] REGRESSION (r182126): Selection highlight and handles aren’t visible with WKSelectionGranularityCharacter
+        https://bugs.webkit.org/show_bug.cgi?id=162577
+        <rdar://problem/28481984>
+
+        Reviewed by Simon Fraser.
+
+        * DumpRenderTree/ios/UIScriptControllerIOS.mm:
+        (WTR::UIScriptController::selectionRangeViewRects): Returns null.
+
+        * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl: Declared new
+          selectionRangeViewRects attribute.
+
+        * TestRunnerShared/UIScriptContext/UIScriptContext.h:
+        (WTR::UIScriptContext::jsContext): Added this public accessor.
+
+        * TestRunnerShared/UIScriptContext/UIScriptController.cpp:
+        (WTR::selectionRangeViewRects): Generic implementation that returns null.
+        * TestRunnerShared/UIScriptContext/UIScriptController.h:
+
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::updateTestOptionsFromTestHeader): Parse the new useCharacterSelectionGranularity
+          option.
+
+        * WebKitTestRunner/TestOptions.h: Added new useCharacterSelectionGranularity option.
+
+        * WebKitTestRunner/cocoa/TestControllerCocoa.mm:
+        (WTR::TestController::platformCreateWebView): Set the configuration’s selectionGranularity
+          property based on the new option.
+
+        * WebKitTestRunner/ios/PlatformWebViewIOS.mm:
+        (WTR::PlatformWebView::viewSupportsOptions): Compare selection granularity option values.
+
+        * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
+        (WTR::UIScriptController::selectionRangeViewRects): iOS-specific implementation that calls
+          the new -[WKWebView _uiTextSelectionRectViews] and returns an array of view frame
+          dictionaries.
+
 2016-09-27  Daniel Bates  <[email protected]>
 
         Cannot run dump-class-layout; dies with "global name 'lldb' is not defined"

Modified: trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm (206448 => 206449)


--- trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm	2016-09-27 18:10:56 UTC (rev 206448)
+++ trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm	2016-09-27 18:31:32 UTC (rev 206449)
@@ -189,6 +189,11 @@
 {
 }
 
+JSObjectRef UIScriptController::selectionRangeViewRects() const
+{
+    return nullptr;
 }
 
+}
+
 #endif // PLATFORM(IOS)

Modified: trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl (206448 => 206449)


--- trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl	2016-09-27 18:10:56 UTC (rev 206448)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl	2016-09-27 18:31:32 UTC (rev 206449)
@@ -79,5 +79,7 @@
 
     readonly attribute object contentVisibleRect; // Returned object has 'left', 'top', 'width', 'height' properties.
 
+    readonly attribute object selectionRangeViewRects; // An array of objects with 'left', 'top', 'width', and 'height' properties.
+
     void uiScriptComplete(DOMString result);
 };

Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptContext.h (206448 => 206449)


--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptContext.h	2016-09-27 18:10:56 UTC (rev 206448)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptContext.h	2016-09-27 18:31:32 UTC (rev 206449)
@@ -82,6 +82,8 @@
 
     JSObjectRef objectFromRect(const WebCore::FloatRect&) const;
 
+    JSGlobalContextRef jsContext() const { return m_context.get(); }
+
 private:
     JSRetainPtr<JSGlobalContextRef> m_context;
     

Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp (206448 => 206449)


--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp	2016-09-27 18:10:56 UTC (rev 206448)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp	2016-09-27 18:31:32 UTC (rev 206449)
@@ -232,6 +232,11 @@
     return nullptr;
 }
 
+JSObjectRef UIScriptController::selectionRangeViewRects() const
+{
+    return nullptr;
+}
+
 void UIScriptController::platformSetDidStartFormControlInteractionCallback()
 {
 }

Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h (206448 => 206449)


--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h	2016-09-27 18:10:56 UTC (rev 206448)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h	2016-09-27 18:31:32 UTC (rev 206449)
@@ -103,6 +103,8 @@
 
     JSObjectRef contentVisibleRect() const;
     
+    JSObjectRef selectionRangeViewRects() const;
+
     void uiScriptComplete(JSStringRef result);
 
 private:

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (206448 => 206449)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2016-09-27 18:10:56 UTC (rev 206448)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2016-09-27 18:31:32 UTC (rev 206449)
@@ -950,6 +950,8 @@
             testOptions.needsSiteSpecificQuirks = parseBooleanTestHeaderValue(value);
         if (key == "ignoresViewportScaleLimits")
             testOptions.ignoresViewportScaleLimits = parseBooleanTestHeaderValue(value);
+        if (key == "useCharacterSelectionGranularity")
+            testOptions.useCharacterSelectionGranularity = parseBooleanTestHeaderValue(value);
         pairStart = pairEnd + 1;
     }
 }

Modified: trunk/Tools/WebKitTestRunner/TestOptions.h (206448 => 206449)


--- trunk/Tools/WebKitTestRunner/TestOptions.h	2016-09-27 18:10:56 UTC (rev 206448)
+++ trunk/Tools/WebKitTestRunner/TestOptions.h	2016-09-27 18:31:32 UTC (rev 206449)
@@ -42,6 +42,7 @@
     bool useMockScrollbars { true };
     bool needsSiteSpecificQuirks { false };
     bool ignoresViewportScaleLimits { false };
+    bool useCharacterSelectionGranularity { false };
 
     float deviceScaleFactor { 1 };
     Vector<String> overrideLanguages;

Modified: trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm (206448 => 206449)


--- trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm	2016-09-27 18:10:56 UTC (rev 206448)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm	2016-09-27 18:31:32 UTC (rev 206449)
@@ -88,6 +88,8 @@
         [copiedConfiguration setDataDetectorTypes:WKDataDetectorTypeAll];
     if (options.ignoresViewportScaleLimits)
         [copiedConfiguration setIgnoresViewportScaleLimits:YES];
+    if (options.useCharacterSelectionGranularity)
+        [copiedConfiguration setSelectionGranularity:WKSelectionGranularityCharacter];
 #endif
 
     m_mainWebView = std::make_unique<PlatformWebView>(copiedConfiguration.get(), options);

Modified: trunk/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm (206448 => 206449)


--- trunk/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm	2016-09-27 18:10:56 UTC (rev 206448)
+++ trunk/Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm	2016-09-27 18:31:32 UTC (rev 206449)
@@ -278,7 +278,7 @@
 
 bool PlatformWebView::viewSupportsOptions(const TestOptions& options) const
 {
-    if (m_options.overrideLanguages != options.overrideLanguages || m_options.needsSiteSpecificQuirks != options.needsSiteSpecificQuirks)
+    if (m_options.overrideLanguages != options.overrideLanguages || m_options.needsSiteSpecificQuirks != options.needsSiteSpecificQuirks || m_options.useCharacterSelectionGranularity != options.useCharacterSelectionGranularity)
         return false;
 
     return true;

Modified: trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm (206448 => 206449)


--- trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm	2016-09-27 18:10:56 UTC (rev 206448)
+++ trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm	2016-09-27 18:31:32 UTC (rev 206449)
@@ -34,6 +34,7 @@
 #import "TestController.h"
 #import "TestRunnerWKWebView.h"
 #import "UIScriptContext.h"
+#import <_javascript_Core/_javascript_Core.h>
 #import <UIKit/UIKit.h>
 #import <WebCore/FloatRect.h>
 #import <WebKit/WKWebViewPrivate.h>
@@ -303,6 +304,24 @@
     return m_context->objectFromRect(rect);
 }
 
+JSObjectRef UIScriptController::selectionRangeViewRects() const
+{
+    NSMutableArray *selectionRects = [[NSMutableArray alloc] init];
+    for (UIView *rectView in TestController::singleton().mainWebView()->platformView()._uiTextSelectionRectViews) {
+        if (rectView.hidden)
+            continue;
+
+        CGRect frame = rectView.frame;
+        [selectionRects addObject:@{
+            @"left": @(frame.origin.x),
+            @"top": @(frame.origin.y),
+            @"width": @(frame.size.width),
+            @"height": @(frame.size.height),
+        }];
+    }
+    return JSValueToObject(m_context->jsContext(), [JSValue valueWithObject:selectionRects inContext:[JSContext contextWithJSGlobalContextRef:m_context->jsContext()]].JSValueRef, nullptr);
+}
+
 void UIScriptController::platformSetDidStartFormControlInteractionCallback()
 {
     TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to