Title: [213012] trunk
Revision
213012
Author
[email protected]
Date
2017-02-26 15:06:54 -0800 (Sun, 26 Feb 2017)

Log Message

REGRESSION (r211312): Double-clicking a word selects it along with the space that follows it
https://bugs.webkit.org/show_bug.cgi?id=168821
<rdar://problem/30690431>

Reviewed by Tim Horton.

Source/WebKit2:

Actually encode and decode smartInsertDeleteEnabled when sending WebPageCreationParameters over XPC.

* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode):
(WebKit::WebPageCreationParameters::decode):

Tools:

Adds the ability for TestWKWebView to send a sequence of clicks to its window, and uses this capability to
verify that double clicking to select a word in a WKWebView on Mac selects just the word, and not a trailing
space along with it.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2Cocoa/double-click-does-not-select-trailing-space.html: Added.
* TestWebKitAPI/Tests/mac/WKWebViewSelectionTests.mm: Copied from Tools/TestWebKitAPI/cocoa/TestWKWebView.h.
(TEST):
* TestWebKitAPI/cocoa/TestWKWebView.h:
* TestWebKitAPI/cocoa/TestWKWebView.mm:
(-[TestWKWebViewHostWindow _mouseDownAtPoint:simulatePressure:clickCount:]):
(-[TestWKWebViewHostWindow _mouseUpAtPoint:clickCount:]):
(-[TestWKWebView mouseDownAtPoint:simulatePressure:]):
(-[TestWKWebView mouseUpAtPoint:]):
(-[TestWKWebView sendClicksAtPoint:numberOfClicks:]):
(-[TestWKWebViewHostWindow _mouseDownAtPoint:simulatePressure:]): Deleted.
(-[TestWKWebViewHostWindow _mouseUpAtPoint:]): Deleted.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (213011 => 213012)


--- trunk/Source/WebKit2/ChangeLog	2017-02-26 18:36:30 UTC (rev 213011)
+++ trunk/Source/WebKit2/ChangeLog	2017-02-26 23:06:54 UTC (rev 213012)
@@ -1,3 +1,17 @@
+2017-02-26  Wenson Hsieh  <[email protected]>
+
+        REGRESSION (r211312): Double-clicking a word selects it along with the space that follows it
+        https://bugs.webkit.org/show_bug.cgi?id=168821
+        <rdar://problem/30690431>
+
+        Reviewed by Tim Horton.
+
+        Actually encode and decode smartInsertDeleteEnabled when sending WebPageCreationParameters over XPC.
+
+        * Shared/WebPageCreationParameters.cpp:
+        (WebKit::WebPageCreationParameters::encode):
+        (WebKit::WebPageCreationParameters::decode):
+
 2017-02-26  Chris Dumez  <[email protected]>
 
         HitTestResult's linkSuggestedFilename should sanitize download attribute

Modified: trunk/Source/WebKit2/Shared/WebPageCreationParameters.cpp (213011 => 213012)


--- trunk/Source/WebKit2/Shared/WebPageCreationParameters.cpp	2017-02-26 18:36:30 UTC (rev 213011)
+++ trunk/Source/WebKit2/Shared/WebPageCreationParameters.cpp	2017-02-26 23:06:54 UTC (rev 213012)
@@ -85,6 +85,9 @@
     encoder << textAutosizingWidth;
     encoder << ignoresViewportScaleLimits;
 #endif
+#if PLATFORM(COCOA)
+    encoder << smartInsertDeleteEnabled;
+#endif
     encoder << appleMailPaginationQuirkEnabled;
     encoder << shouldScaleViewToFitDocument;
     encoder.encodeEnum(userInterfaceLayoutDirection);
@@ -199,6 +202,10 @@
     if (!decoder.decode(parameters.ignoresViewportScaleLimits))
         return false;
 #endif
+#if PLATFORM(COCOA)
+    if (!decoder.decode(parameters.smartInsertDeleteEnabled))
+        return false;
+#endif
 
     if (!decoder.decode(parameters.appleMailPaginationQuirkEnabled))
         return false;

Modified: trunk/Tools/ChangeLog (213011 => 213012)


--- trunk/Tools/ChangeLog	2017-02-26 18:36:30 UTC (rev 213011)
+++ trunk/Tools/ChangeLog	2017-02-26 23:06:54 UTC (rev 213012)
@@ -1,3 +1,29 @@
+2017-02-26  Wenson Hsieh  <[email protected]>
+
+        REGRESSION (r211312): Double-clicking a word selects it along with the space that follows it
+        https://bugs.webkit.org/show_bug.cgi?id=168821
+        <rdar://problem/30690431>
+
+        Reviewed by Tim Horton.
+
+        Adds the ability for TestWKWebView to send a sequence of clicks to its window, and uses this capability to
+        verify that double clicking to select a word in a WKWebView on Mac selects just the word, and not a trailing
+        space along with it.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/double-click-does-not-select-trailing-space.html: Added.
+        * TestWebKitAPI/Tests/mac/WKWebViewSelectionTests.mm: Copied from Tools/TestWebKitAPI/cocoa/TestWKWebView.h.
+        (TEST):
+        * TestWebKitAPI/cocoa/TestWKWebView.h:
+        * TestWebKitAPI/cocoa/TestWKWebView.mm:
+        (-[TestWKWebViewHostWindow _mouseDownAtPoint:simulatePressure:clickCount:]):
+        (-[TestWKWebViewHostWindow _mouseUpAtPoint:clickCount:]):
+        (-[TestWKWebView mouseDownAtPoint:simulatePressure:]):
+        (-[TestWKWebView mouseUpAtPoint:]):
+        (-[TestWKWebView sendClicksAtPoint:numberOfClicks:]):
+        (-[TestWKWebViewHostWindow _mouseDownAtPoint:simulatePressure:]): Deleted.
+        (-[TestWKWebViewHostWindow _mouseUpAtPoint:]): Deleted.
+
 2017-02-25  Simon Fraser  <[email protected]>
 
         Make check-webkit-style do some basic validation for CSSProperties.json

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (213011 => 213012)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2017-02-26 18:36:30 UTC (rev 213011)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2017-02-26 23:06:54 UTC (rev 213012)
@@ -567,6 +567,8 @@
 		F4F137921D9B683E002BEC57 /* large-video-test-now-playing.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4F137911D9B6832002BEC57 /* large-video-test-now-playing.html */; };
 		F4F405BC1D4C0D1C007A9707 /* full-size-autoplaying-video-with-audio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4F405BA1D4C0CF8007A9707 /* full-size-autoplaying-video-with-audio.html */; };
 		F4F405BD1D4C0D1C007A9707 /* skinny-autoplaying-video-with-audio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4F405BB1D4C0CF8007A9707 /* skinny-autoplaying-video-with-audio.html */; };
+		F4FA91811E61849B007B8C1D /* WKWebViewSelectionTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4FA917F1E61849B007B8C1D /* WKWebViewSelectionTests.mm */; };
+		F4FA91831E61857B007B8C1D /* double-click-does-not-select-trailing-space.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4FA91821E618566007B8C1D /* double-click-does-not-select-trailing-space.html */; };
 		F660AA1115A5F631003A1243 /* GetInjectedBundleInitializationUserDataCallback_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F660AA0F15A5F624003A1243 /* GetInjectedBundleInitializationUserDataCallback_Bundle.cpp */; };
 		F660AA1515A61ABF003A1243 /* InjectedBundleInitializationUserDataCallbackWins_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F660AA1415A61ABF003A1243 /* InjectedBundleInitializationUserDataCallbackWins_Bundle.cpp */; };
 		F6B7BE9517469212008A3445 /* DidAssociateFormControls_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6B7BE92174691EF008A3445 /* DidAssociateFormControls_Bundle.cpp */; };
@@ -637,6 +639,7 @@
 			dstSubfolderSpec = 7;
 			files = (
 				8361F1781E610B4E00759B25 /* link-with-download-attribute-with-slashes.html in Copy Resources */,
+				F4FA91831E61857B007B8C1D /* double-click-does-not-select-trailing-space.html in Copy Resources */,
 				C25CCA0D1E5141840026CB8A /* AllAhem.svg in Copy Resources */,
 				C25CCA0B1E5140C10026CB8A /* LineBreaking.html in Copy Resources */,
 				C9C60E651E53A9DC006DA181 /* autoplay-check-frame.html in Copy Resources */,
@@ -1398,6 +1401,8 @@
 		F4F137911D9B6832002BEC57 /* large-video-test-now-playing.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-video-test-now-playing.html"; sourceTree = "<group>"; };
 		F4F405BA1D4C0CF8007A9707 /* full-size-autoplaying-video-with-audio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "full-size-autoplaying-video-with-audio.html"; sourceTree = "<group>"; };
 		F4F405BB1D4C0CF8007A9707 /* skinny-autoplaying-video-with-audio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "skinny-autoplaying-video-with-audio.html"; sourceTree = "<group>"; };
+		F4FA917F1E61849B007B8C1D /* WKWebViewSelectionTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewSelectionTests.mm; sourceTree = "<group>"; };
+		F4FA91821E618566007B8C1D /* double-click-does-not-select-trailing-space.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = "double-click-does-not-select-trailing-space.html"; path = "Tests/WebKit2Cocoa/double-click-does-not-select-trailing-space.html"; sourceTree = SOURCE_ROOT; };
 		F660AA0C15A5F061003A1243 /* GetInjectedBundleInitializationUserDataCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GetInjectedBundleInitializationUserDataCallback.cpp; sourceTree = "<group>"; };
 		F660AA0F15A5F624003A1243 /* GetInjectedBundleInitializationUserDataCallback_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GetInjectedBundleInitializationUserDataCallback_Bundle.cpp; sourceTree = "<group>"; };
 		F660AA1215A619C8003A1243 /* InjectedBundleInitializationUserDataCallbackWins.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleInitializationUserDataCallbackWins.cpp; sourceTree = "<group>"; };
@@ -2209,6 +2214,7 @@
 				1A7BFC0A171A0BDB00BC5F64 /* WillSendSubmitEvent.mm */,
 				A5E2027215B2181900C13E14 /* WindowlessWebViewWithMedia.mm */,
 				764322D51B61CCA40024F801 /* WordBoundaryTypingAttributes.mm */,
+				F4FA917F1E61849B007B8C1D /* WKWebViewSelectionTests.mm */,
 			);
 			path = mac;
 			sourceTree = "<group>";
@@ -2216,6 +2222,7 @@
 		C07E6CB013FD737C0038B22B /* Resources */ = {
 			isa = PBXGroup;
 			children = (
+				F4FA91821E618566007B8C1D /* double-click-does-not-select-trailing-space.html */,
 				7AEAD47D1E20114E00416EFE /* CrossPartitionFileSchemeAccess.html */,
 				F42DA5151D8CEFDB00336F40 /* large-input-field-focus-onload.html */,
 				379028B814FABE49007E6B43 /* acceptsFirstMouse.html */,
@@ -2624,6 +2631,7 @@
 				7CCE7EB71A411A7E00447C4C /* CloseNewWindowInNavigationPolicyDelegate.mm in Sources */,
 				7CCE7EE51A411AE600447C4C /* CloseThenTerminate.cpp in Sources */,
 				7C83E0BA1D0A64FB00FEBCF3 /* Coding.mm in Sources */,
+				F4FA91811E61849B007B8C1D /* WKWebViewSelectionTests.mm in Sources */,
 				7C3965061CDD74F90094DBB8 /* Color.cpp in Sources */,
 				7C3DB8E41D12129B00AE8CC3 /* CommandBackForward.mm in Sources */,
 				7CB184C61AA3F2100066EDFD /* ContentExtensions.cpp in Sources */,

Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/double-click-does-not-select-trailing-space.html (0 => 213012)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/double-click-does-not-select-trailing-space.html	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/double-click-does-not-select-trailing-space.html	2017-02-26 23:06:54 UTC (rev 213012)
@@ -0,0 +1,23 @@
+<style>
+body {
+    width: 100%;
+    height: 100%;
+}
+
+#editable {
+    width: 100%;
+    height: 400px;
+    font-size: 400px;
+    white-space: nowrap;
+    border: 1px blue dashed;
+}
+</style>
+<div id="editable" contenteditable>Hello world</div>
+<script>
+document.addEventListener("selectionchange", () => {
+    if (!getSelection().rangeCount || getSelection().isCollapsed)
+        return;
+
+    setTimeout(() => window.webkit.messageHandlers.testHandler.postMessage("selected"), 0);
+});
+</script>

Copied: trunk/Tools/TestWebKitAPI/Tests/mac/WKWebViewSelectionTests.mm (from rev 213011, trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h) (0 => 213012)


--- trunk/Tools/TestWebKitAPI/Tests/mac/WKWebViewSelectionTests.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/WKWebViewSelectionTests.mm	2017-02-26 23:06:54 UTC (rev 213012)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if WK_API_ENABLED && PLATFORM(MAC)
+
+#import "PlatformUtilities.h"
+#import "TestWKWebView.h"
+
+TEST(WKWebViewSelectionTests, DoubleClickDoesNotSelectTrailingSpace)
+{
+    RetainPtr<TestWKWebView> webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 400, 400)]);
+    [webView synchronouslyLoadTestPageNamed:@"double-click-does-not-select-trailing-space"];
+
+    __block bool finishedSelectingText = false;
+    [webView performAfterReceivingMessage:@"selected" action:^() {
+        finishedSelectingText = true;
+    }];
+    [webView sendClicksAtPoint:NSMakePoint(200, 200) numberOfClicks:2];
+    TestWebKitAPI::Util::run(&finishedSelectingText);
+
+    NSString *selectedText = [webView stringByEvaluatingJavaScript:@"getSelection().getRangeAt(0).toString()"];
+    EXPECT_STREQ("Hello", selectedText.UTF8String);
+}
+
+#endif // WK_API_ENABLED && PLATFORM(MAC)

Modified: trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h (213011 => 213012)


--- trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h	2017-02-26 18:36:30 UTC (rev 213011)
+++ trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h	2017-02-26 23:06:54 UTC (rev 213012)
@@ -53,6 +53,7 @@
 // Simulates clicking with a pressure-sensitive device, if possible.
 - (void)mouseDownAtPoint:(NSPoint)point simulatePressure:(BOOL)simulatePressure;
 - (void)mouseUpAtPoint:(NSPoint)point;
+- (void)sendClicksAtPoint:(NSPoint)point numberOfClicks:(NSUInteger)numberOfClicks;
 - (void)typeCharacter:(char)character;
 @end
 #endif

Modified: trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm (213011 => 213012)


--- trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm	2017-02-26 18:36:30 UTC (rev 213011)
+++ trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm	2017-02-26 23:06:54 UTC (rev 213012)
@@ -94,7 +94,7 @@
 }
 #endif
 
-- (void)_mouseDownAtPoint:(NSPoint)point simulatePressure:(BOOL)simulatePressure
+- (void)_mouseDownAtPoint:(NSPoint)point simulatePressure:(BOOL)simulatePressure clickCount:(NSUInteger)clickCount
 {
     NSEventType mouseEventType = NSEventTypeLeftMouseDown;
 
@@ -106,7 +106,7 @@
     simulatePressure = NO;
 #endif
 
-    NSEvent *event = [NSEvent mouseEventWithType:mouseEventType location:point modifierFlags:modifierFlags timestamp:GetCurrentEventTime() windowNumber:self.windowNumber context:[NSGraphicsContext currentContext] eventNumber:++gEventNumber clickCount:1 pressure:simulatePressure];
+    NSEvent *event = [NSEvent mouseEventWithType:mouseEventType location:point modifierFlags:modifierFlags timestamp:GetCurrentEventTime() windowNumber:self.windowNumber context:[NSGraphicsContext currentContext] eventNumber:++gEventNumber clickCount:clickCount pressure:simulatePressure];
     if (!simulatePressure) {
         [self sendEvent:event];
         return;
@@ -126,9 +126,9 @@
 #endif
 }
 
-- (void)_mouseUpAtPoint:(NSPoint)point
+- (void)_mouseUpAtPoint:(NSPoint)point clickCount:(NSUInteger)clickCount
 {
-    [self sendEvent:[NSEvent mouseEventWithType:NSEventTypeLeftMouseUp location:point modifierFlags:0 timestamp:GetCurrentEventTime() windowNumber:self.windowNumber context:[NSGraphicsContext currentContext] eventNumber:++gEventNumber clickCount:1 pressure:0]];
+    [self sendEvent:[NSEvent mouseEventWithType:NSEventTypeLeftMouseUp location:point modifierFlags:0 timestamp:GetCurrentEventTime() windowNumber:self.windowNumber context:[NSGraphicsContext currentContext] eventNumber:++gEventNumber clickCount:clickCount pressure:0]];
 }
 #endif // PLATFORM(MAC)
 
@@ -286,14 +286,22 @@
 @implementation TestWKWebView (MacOnly)
 - (void)mouseDownAtPoint:(NSPoint)point simulatePressure:(BOOL)simulatePressure
 {
-    [_hostWindow _mouseDownAtPoint:point simulatePressure:simulatePressure];
+    [_hostWindow _mouseDownAtPoint:point simulatePressure:simulatePressure clickCount:1];
 }
 
 - (void)mouseUpAtPoint:(NSPoint)point
 {
-    [_hostWindow _mouseUpAtPoint:point];
+    [_hostWindow _mouseUpAtPoint:point clickCount:1];
 }
 
+- (void)sendClicksAtPoint:(NSPoint)point numberOfClicks:(NSUInteger)numberOfClicks
+{
+    for (NSUInteger clickCount = 1; clickCount <= numberOfClicks; ++clickCount) {
+        [_hostWindow _mouseDownAtPoint:point simulatePressure:NO clickCount:clickCount];
+        [_hostWindow _mouseUpAtPoint:point clickCount:clickCount];
+    }
+}
+
 - (void)typeCharacter:(char)character {
     NSString *characterAsString = [NSString stringWithFormat:@"%c" , character];
     NSEventType keyDownEventType = NSEventTypeKeyDown;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to