Log Message
Data interaction causes selection to fall out of sync between web/UI processes https://bugs.webkit.org/show_bug.cgi?id=168735 <rdar://problem/30657817>
Reviewed by Tim Horton. Source/WebKit2: Fixes a bug with data interaction causing selection state to fall out of sync between the UI and web processes, and also introduces testing infrastructure and tests for grabbing UI-side selection view rects in TestWebKitAPI. While performing a data interaction operation, we now lift restrictions for assisting the focused node. * UIProcess/ios/WKContentViewInteraction.h: * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView cleanupInteraction]): (-[WKContentView _startAssistingNode:userIsInteracting:blurPreviousNode:userObject:]): Tools: Adds a new method to TestWKWebView for querying selection view rects from the UI process and augments data interaction unit tests to check for selection rects using this new hook. * TestWebKitAPI/Tests/ios/DataInteractionTests.mm: (makeCGRectValue): (TestWebKitAPI::TEST): * TestWebKitAPI/cocoa/TestWKWebView.h: * TestWebKitAPI/cocoa/TestWKWebView.mm: (-[TestWKWebView selectionRectsAfterPresentationUpdate]): * TestWebKitAPI/ios/DataInteractionSimulator.h: * TestWebKitAPI/ios/DataInteractionSimulator.mm: (-[DataInteractionSimulator _resetSimulatedState]): (-[DataInteractionSimulator runFrom:to:]): (-[DataInteractionSimulator finalSelectionRects]):
Modified Paths
- trunk/Source/WebKit2/ChangeLog
- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h
- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm
- trunk/Tools/ChangeLog
- trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm
- trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h
- trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm
- trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.h
- trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.mm
Diff
Modified: trunk/Source/WebKit2/ChangeLog (212897 => 212898)
--- trunk/Source/WebKit2/ChangeLog 2017-02-23 16:58:26 UTC (rev 212897)
+++ trunk/Source/WebKit2/ChangeLog 2017-02-23 17:23:51 UTC (rev 212898)
@@ -1,3 +1,20 @@
+2017-02-22 Wenson Hsieh <[email protected]>
+
+ Data interaction causes selection to fall out of sync between web/UI processes
+ https://bugs.webkit.org/show_bug.cgi?id=168735
+ <rdar://problem/30657817>
+
+ Reviewed by Tim Horton.
+
+ Fixes a bug with data interaction causing selection state to fall out of sync between the UI and web processes,
+ and also introduces testing infrastructure and tests for grabbing UI-side selection view rects in TestWebKitAPI.
+ While performing a data interaction operation, we now lift restrictions for assisting the focused node.
+
+ * UIProcess/ios/WKContentViewInteraction.h:
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView cleanupInteraction]):
+ (-[WKContentView _startAssistingNode:userIsInteracting:blurPreviousNode:userObject:]):
+
2017-02-23 Carlos Garcia Campos <[email protected]>
[GTK] Crash attempting to load Flash plugin in Wayland
Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h (212897 => 212898)
--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h 2017-02-23 16:58:26 UTC (rev 212897)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h 2017-02-23 17:23:51 UTC (rev 212898)
@@ -190,6 +190,7 @@
#if ENABLE(DATA_INTERACTION)
WebKit::WKDataInteractionState _dataInteractionState;
+ BOOL _isPerformingDataInteractionOperation;
#endif
}
Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (212897 => 212898)
--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm 2017-02-23 16:58:26 UTC (rev 212897)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm 2017-02-23 17:23:51 UTC (rev 212898)
@@ -645,6 +645,7 @@
[_dataInteractionGestureRecognizer setDelegate:nil];
[self removeGestureRecognizer:_dataInteractionGestureRecognizer.get()];
[self teardownDataInteractionDelegates];
+ _isPerformingDataInteractionOperation = NO;
#endif
_inspectorNodeSearchEnabled = NO;
@@ -3773,6 +3774,9 @@
else {
// The default behavior is to allow node assistance if the user is interacting or the keyboard is already active.
shouldShowKeyboard = userIsInteracting || _textSelectionAssistant;
+#if ENABLE(DATA_INTERACTION)
+ shouldShowKeyboard |= _isPerformingDataInteractionOperation;
+#endif
}
if (!shouldShowKeyboard)
return;
Modified: trunk/Tools/ChangeLog (212897 => 212898)
--- trunk/Tools/ChangeLog 2017-02-23 16:58:26 UTC (rev 212897)
+++ trunk/Tools/ChangeLog 2017-02-23 17:23:51 UTC (rev 212898)
@@ -1,3 +1,26 @@
+2017-02-22 Wenson Hsieh <[email protected]>
+
+ Data interaction causes selection to fall out of sync between web/UI processes
+ https://bugs.webkit.org/show_bug.cgi?id=168735
+ <rdar://problem/30657817>
+
+ Reviewed by Tim Horton.
+
+ Adds a new method to TestWKWebView for querying selection view rects from the UI process and augments data
+ interaction unit tests to check for selection rects using this new hook.
+
+ * TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
+ (makeCGRectValue):
+ (TestWebKitAPI::TEST):
+ * TestWebKitAPI/cocoa/TestWKWebView.h:
+ * TestWebKitAPI/cocoa/TestWKWebView.mm:
+ (-[TestWKWebView selectionRectsAfterPresentationUpdate]):
+ * TestWebKitAPI/ios/DataInteractionSimulator.h:
+ * TestWebKitAPI/ios/DataInteractionSimulator.mm:
+ (-[DataInteractionSimulator _resetSimulatedState]):
+ (-[DataInteractionSimulator runFrom:to:]):
+ (-[DataInteractionSimulator finalSelectionRects]):
+
2017-02-22 Carlos Garcia Campos <[email protected]>
Better handle Thread and RunLoop initialization
Modified: trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm (212897 => 212898)
--- trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm 2017-02-23 16:58:26 UTC (rev 212897)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm 2017-02-23 17:23:51 UTC (rev 212898)
@@ -47,6 +47,11 @@
@end
+static NSValue *makeCGRectValue(CGFloat x, CGFloat y, CGFloat width, CGFloat height)
+{
+ return [NSValue valueWithCGRect:CGRectMake(x, y, width, height)];
+}
+
namespace TestWebKitAPI {
TEST(DataInteractionTests, ImageToContentEditable)
@@ -63,6 +68,7 @@
EXPECT_TRUE([observedEventNames containsObject:DataInteractionEnterEventName]);
EXPECT_TRUE([observedEventNames containsObject:DataInteractionOverEventName]);
EXPECT_TRUE([observedEventNames containsObject:DataInteractionPerformOperationEventName]);
+ EXPECT_TRUE([[dataInteractionSimulator finalSelectionRects] isEqualToArray:@[ makeCGRectValue(1, 201, 215, 174) ]]);
}
TEST(DataInteractionTests, ImageToTextarea)
@@ -81,6 +87,9 @@
EXPECT_TRUE([observedEventNames containsObject:DataInteractionEnterEventName]);
EXPECT_TRUE([observedEventNames containsObject:DataInteractionOverEventName]);
EXPECT_TRUE([observedEventNames containsObject:DataInteractionPerformOperationEventName]);
+
+ NSArray *expectedSelectionRects = [NSArray arrayWithObjects:makeCGRectValue(6, 203, 188, 14), makeCGRectValue(6, 217, 188, 14), makeCGRectValue(6, 231, 66, 14), nil];
+ EXPECT_TRUE([[dataInteractionSimulator finalSelectionRects] isEqualToArray:expectedSelectionRects]);
}
TEST(DataInteractionTests, ContentEditableToContentEditable)
@@ -99,6 +108,7 @@
EXPECT_TRUE([observedEventNames containsObject:DataInteractionEnterEventName]);
EXPECT_TRUE([observedEventNames containsObject:DataInteractionOverEventName]);
EXPECT_TRUE([observedEventNames containsObject:DataInteractionPerformOperationEventName]);
+ EXPECT_TRUE([[dataInteractionSimulator finalSelectionRects] isEqualToArray:@[ makeCGRectValue(1, 201, 961, 227) ]]);
}
TEST(DataInteractionTests, ContentEditableToTextarea)
@@ -117,6 +127,7 @@
EXPECT_TRUE([observedEventNames containsObject:DataInteractionEnterEventName]);
EXPECT_TRUE([observedEventNames containsObject:DataInteractionOverEventName]);
EXPECT_TRUE([observedEventNames containsObject:DataInteractionPerformOperationEventName]);
+ EXPECT_TRUE([[dataInteractionSimulator finalSelectionRects] isEqualToArray:@[ makeCGRectValue(6, 203, 990, 232) ]]);
}
TEST(DataInteractionTests, LinkToInput)
@@ -134,6 +145,7 @@
EXPECT_TRUE([observedEventNames containsObject:DataInteractionEnterEventName]);
EXPECT_TRUE([observedEventNames containsObject:DataInteractionOverEventName]);
EXPECT_TRUE([observedEventNames containsObject:DataInteractionPerformOperationEventName]);
+ EXPECT_TRUE([[dataInteractionSimulator finalSelectionRects] isEqualToArray:@[ makeCGRectValue(101, 273, 2613, 232) ]]);
}
TEST(DataInteractionTests, BackgroundImageLinkToInput)
@@ -151,6 +163,7 @@
EXPECT_TRUE([observedEventNames containsObject:DataInteractionEnterEventName]);
EXPECT_TRUE([observedEventNames containsObject:DataInteractionOverEventName]);
EXPECT_TRUE([observedEventNames containsObject:DataInteractionPerformOperationEventName]);
+ EXPECT_TRUE([[dataInteractionSimulator finalSelectionRects] isEqualToArray:@[ makeCGRectValue(101, 241, 2613, 232) ]]);
}
TEST(DataInteractionTests, CanPreventStart)
@@ -167,6 +180,7 @@
NSArray *observedEventNames = [dataInteractionSimulator observedEventNames];
EXPECT_FALSE([observedEventNames containsObject:DataInteractionEnterEventName]);
EXPECT_FALSE([observedEventNames containsObject:DataInteractionOverEventName]);
+ EXPECT_TRUE([[dataInteractionSimulator finalSelectionRects] isEqualToArray:@[ ]]);
}
TEST(DataInteractionTests, CanPreventOperation)
@@ -183,6 +197,7 @@
NSArray *observedEventNames = [dataInteractionSimulator observedEventNames];
EXPECT_TRUE([observedEventNames containsObject:DataInteractionEnterEventName]);
EXPECT_TRUE([observedEventNames containsObject:DataInteractionOverEventName]);
+ EXPECT_TRUE([[dataInteractionSimulator finalSelectionRects] isEqualToArray:@[ ]]);
}
TEST(DataInteractionTests, EnterAndLeaveEvents)
@@ -201,6 +216,7 @@
EXPECT_TRUE([observedEventNames containsObject:DataInteractionOverEventName]);
EXPECT_TRUE([observedEventNames containsObject:DataInteractionLeaveEventName]);
EXPECT_FALSE([observedEventNames containsObject:DataInteractionPerformOperationEventName]);
+ EXPECT_TRUE([[dataInteractionSimulator finalSelectionRects] isEqualToArray:@[ ]]);
}
TEST(DataInteractionTests, HandlesDataInteractionFailureGracefully)
@@ -235,6 +251,7 @@
[dataInteractionSimulator setExternalItemProvider:simulatedItemProvider.get()];
[dataInteractionSimulator runFrom:CGPointMake(300, 400) to:CGPointMake(100, 300)];
EXPECT_WK_STREQ(textPayload.UTF8String, [webView stringByEvaluatingJavaScript:@"editor.textContent"].UTF8String);
+ EXPECT_TRUE([[dataInteractionSimulator finalSelectionRects] isEqualToArray:@[ makeCGRectValue(1, 201, 1936, 227) ]]);
}
TEST(DataInteractionTests, ExternalSourceJPEGOnly)
@@ -253,6 +270,7 @@
[dataInteractionSimulator setExternalItemProvider:simulatedItemProvider.get()];
[dataInteractionSimulator runFrom:CGPointMake(300, 400) to:CGPointMake(100, 300)];
EXPECT_TRUE([webView editorContainsImageElement]);
+ EXPECT_TRUE([[dataInteractionSimulator finalSelectionRects] isEqualToArray:@[ makeCGRectValue(1, 201, 215, 174) ]]);
}
} // namespace TestWebKitAPI
Modified: trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h (212897 => 212898)
--- trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h 2017-02-23 16:58:26 UTC (rev 212897)
+++ trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h 2017-02-23 17:23:51 UTC (rev 212898)
@@ -24,6 +24,7 @@
*/
#import <WebKit/WebKit.h>
+#import <wtf/RetainPtr.h>
#if WK_API_ENABLED
@@ -41,6 +42,12 @@
- (void)performAfterLoading:(dispatch_block_t)actions;
@end
+#if PLATFORM(IOS)
+@interface TestWKWebView (IOSOnly)
+@property (nonatomic, readonly) RetainPtr<NSArray> selectionRectsAfterPresentationUpdate;
+@end
+#endif
+
#if PLATFORM(MAC)
@interface TestWKWebView (MacOnly)
// Simulates clicking with a pressure-sensitive device, if possible.
Modified: trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm (212897 => 212898)
--- trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm 2017-02-23 16:58:26 UTC (rev 212897)
+++ trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm 2017-02-23 17:23:51 UTC (rev 212898)
@@ -259,6 +259,29 @@
@end
+#if PLATFORM(IOS)
+
+@implementation TestWKWebView (IOSOnly)
+
+- (RetainPtr<NSArray>)selectionRectsAfterPresentationUpdate
+{
+ RetainPtr<TestWKWebView> retainedSelf = self;
+
+ __block bool isDone = false;
+ __block RetainPtr<NSArray> selectionRects;
+ [self _doAfterNextPresentationUpdate:^() {
+ selectionRects = adoptNS([[retainedSelf _uiTextSelectionRects] retain]);
+ isDone = true;
+ }];
+
+ TestWebKitAPI::Util::run(&isDone);
+ return selectionRects;
+}
+
+@end
+
+#endif
+
#if PLATFORM(MAC)
@implementation TestWKWebView (MacOnly)
- (void)mouseDownAtPoint:(NSPoint)point simulatePressure:(BOOL)simulatePressure
Modified: trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.h (212897 => 212898)
--- trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.h 2017-02-23 16:58:26 UTC (rev 212897)
+++ trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.h 2017-02-23 17:23:51 UTC (rev 212898)
@@ -53,6 +53,7 @@
RetainPtr<MockDataInteractionInfo> _dataInteractionInfo;
RetainPtr<NSMutableArray> _observedEventNames;
RetainPtr<UIItemProvider> _externalItemProvider;
+ RetainPtr<NSArray *> _finalSelectionRects;
CGPoint _startLocation;
CGPoint _endLocation;
@@ -68,6 +69,7 @@
@property (nonatomic, strong) UIItemProvider *externalItemProvider;
@property (nonatomic, readonly) BOOL didTryToBeginDataInteraction;
@property (nonatomic, readonly) NSArray *observedEventNames;
+@property (nonatomic, readonly) NSArray *finalSelectionRects;
@end
Modified: trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.mm (212897 => 212898)
--- trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.mm 2017-02-23 16:58:26 UTC (rev 212897)
+++ trunk/Tools/TestWebKitAPI/ios/DataInteractionSimulator.mm 2017-02-23 17:23:51 UTC (rev 212898)
@@ -121,6 +121,7 @@
_isDoneWithCurrentRun = false;
_didTryToBeginDataInteraction = NO;
_observedEventNames = adoptNS([[NSMutableArray alloc] init]);
+ _finalSelectionRects = @[ ];
}
- (NSArray *)observedEventNames
@@ -155,8 +156,14 @@
Util::run(&_isDoneWithCurrentRun);
[_gestureRecognizer setMockNumberOfTouches:0];
[_webView clearMessageHandlers:dataInteractionEventNames()];
+ _finalSelectionRects = [_webView selectionRectsAfterPresentationUpdate];
}
+- (NSArray *)finalSelectionRects
+{
+ return _finalSelectionRects.get();
+}
+
- (void)_advanceProgress
{
_gestureProgress = std::min(1.0, std::max(0.0, progressIncrementStep + _gestureProgress));
_______________________________________________ webkit-changes mailing list [email protected] https://lists.webkit.org/mailman/listinfo/webkit-changes
