Skip to content

Commit be2e2f1

Browse files
Make iOS Find UI reveal matches in scrollable elements
https://bugs.webkit.org/show_bug.cgi?id=178789 Patch by Frederic Wang <[email protected]> on 2017-11-01 Reviewed by Tim Horton. Source/WebKit: * WebProcess/WebPage/ios/FindControllerIOS.mm: (WebKit::FindController::didFindString): Reveal selection up to the main frame. The main frame is handled by the SmartMagnificationController. Tools: This patch exposes WKWebView's findString function in order to test the fix for bug 178789. * DumpRenderTree/ios/UIScriptControllerIOS.mm: (WTR::UIScriptController::findString): Dummy implementation of findString. * DumpRenderTree/mac/UIScriptControllerMac.mm: (WTR::UIScriptController::findString): Ditto. * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl: Declare findString. * TestRunnerShared/UIScriptContext/UIScriptController.cpp: (WTR::UIScriptController::findString): Dummy implementation of findString. * TestRunnerShared/UIScriptContext/UIScriptController.h: Declare findString. * WebKitTestRunner/ios/UIScriptControllerIOS.mm: (WTR::UIScriptController::findString): Implement findString by forwarding the call to the web view. * WebKitTestRunner/mac/UIScriptControllerMac.mm: (WTR::UIScriptController::findString): Dummy implementation of findString. LayoutTests: Adds a test to verify that an overflow node is scrolled to reveal results it contains when iOS's Find UI is used. * platform/ios/fast/scrolling/find-text-in-overflow-node-expected.txt: Added. * platform/ios/fast/scrolling/find-text-in-overflow-node.html: Added. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@224284 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 1165a53 commit be2e2f1

File tree

13 files changed

+148
-0
lines changed

13 files changed

+148
-0
lines changed

LayoutTests/ChangeLog

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
2017-11-01 Frederic Wang <[email protected]>
2+
3+
Make iOS Find UI reveal matches in scrollable elements
4+
https://bugs.webkit.org/show_bug.cgi?id=178789
5+
6+
Reviewed by Tim Horton.
7+
8+
Adds a test to verify that an overflow node is scrolled to reveal results it contains when
9+
iOS's Find UI is used.
10+
11+
* platform/ios/fast/scrolling/find-text-in-overflow-node-expected.txt: Added.
12+
* platform/ios/fast/scrolling/find-text-in-overflow-node.html: Added.
13+
114
2017-11-01 Per Arne Vollan <[email protected]>
215

316
Mark fast/dom/Window/window-resize-update-scrollbars.html as a timeout on Windows.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Use iOS Find UI to search for the text "match". The following overflow node should scroll to show the fourth result.
2+
3+
match 2
4+
5+
match 3
6+
7+
match 4
8+
9+
10+
PASS Initial position of overflow node
11+
PASS Position of overflow node after the three first results
12+
PASS Position of overflow node after the fourth result
13+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Find text in overflow node</title>
5+
<meta name="viewport" content="width=device-width">
6+
<script src="../../../../resources/testharness.js"></script>
7+
<script src="../../../../resources/testharnessreport.js"></script>
8+
<script type="text/javascript">
9+
setup({ "explicit_done": true });
10+
function run() {
11+
if (!window.testRunner || !testRunner.runUIScript)
12+
return;
13+
14+
var node = document.getElementById("scrollable");
15+
test(function() {
16+
assert_equals(node.scrollTop, 0);
17+
}, "Initial position of overflow node");
18+
var afterMatch3 = async_test("Position of overflow node after the three first results");
19+
var afterMatch4 = async_test("Position of overflow node after the fourth result");
20+
testRunner.runUIScript(`
21+
uiController.findString("match", 0, 4); // match
22+
uiController.findString("match", 0, 4); // match 2
23+
uiController.findString("match", 0, 4); // match 3
24+
uiController.uiScriptComplete("Done");
25+
`, afterMatch3.step_func_done(function() {
26+
assert_equals(node.scrollTop, 0);
27+
testRunner.runUIScript(`
28+
uiController.findString("match", 0, 4); // match 4
29+
uiController.uiScriptComplete("Done");
30+
`, afterMatch4.step_func_done(function() {
31+
assert_greater_than(node.scrollTop, 0);
32+
}));
33+
}));
34+
35+
done();
36+
}
37+
</script>
38+
<style>
39+
#scrollable {
40+
border: 1px solid black;
41+
background: gray;
42+
width: 200px;
43+
height: 200px;
44+
overflow-y: auto;
45+
-webkit-overflow-scrolling: touch;
46+
}
47+
</style>
48+
</head>
49+
<body onload="run()">
50+
<p>Use iOS Find UI to search for the text "match". The following overflow node should scroll to show the fourth result.</p>
51+
<p>match 2</p>
52+
<p>match 3</p>
53+
<div id="scrollable">
54+
<div style="height: 200px; background: linear-gradient(135deg, blue, cyan);"></div>
55+
<p>match 4</p>
56+
</div>
57+
</body>
58+
</html>

Source/WebKit/ChangeLog

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2017-11-01 Frederic Wang <[email protected]>
2+
3+
Make iOS Find UI reveal matches in scrollable elements
4+
https://bugs.webkit.org/show_bug.cgi?id=178789
5+
6+
Reviewed by Tim Horton.
7+
8+
* WebProcess/WebPage/ios/FindControllerIOS.mm:
9+
(WebKit::FindController::didFindString): Reveal selection up to the main frame. The main frame
10+
is handled by the SmartMagnificationController.
11+
112
2017-11-01 Michael Catanzaro <[email protected]>
213

314
REGRESSION(r224192): [WPE] Fix WebEventFactory::createWebWheelEvent

Source/WebKit/WebProcess/WebPage/ios/FindControllerIOS.mm

+4
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ static void setSelectionChangeUpdatesEnabledInAllFrames(WebPage& page, bool enab
157157
frame.selection().setUpdateAppearanceEnabled(true);
158158
frame.selection().updateAppearance();
159159
frame.selection().setUpdateAppearanceEnabled(false);
160+
161+
// Scrolling the main frame is handled by the SmartMagnificationController class but we still
162+
// need to consider overflow nodes and subframes here.
163+
frame.selection().revealSelection(SelectionRevealMode::RevealUpToMainFrame, ScrollAlignment::alignToEdgeIfNeeded, WebCore::DoNotRevealExtent);
160164
}
161165

162166
void FindController::didFailToFindString()

Tools/ChangeLog

+23
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
2017-11-01 Frederic Wang <[email protected]>
2+
3+
Make iOS Find UI reveal matches in scrollable elements
4+
https://bugs.webkit.org/show_bug.cgi?id=178789
5+
6+
Reviewed by Tim Horton.
7+
8+
This patch exposes WKWebView's findString function in order to test the fix for bug 178789.
9+
10+
* DumpRenderTree/ios/UIScriptControllerIOS.mm:
11+
(WTR::UIScriptController::findString): Dummy implementation of findString.
12+
* DumpRenderTree/mac/UIScriptControllerMac.mm:
13+
(WTR::UIScriptController::findString): Ditto.
14+
* TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl: Declare findString.
15+
* TestRunnerShared/UIScriptContext/UIScriptController.cpp:
16+
(WTR::UIScriptController::findString): Dummy implementation of findString.
17+
* TestRunnerShared/UIScriptContext/UIScriptController.h: Declare findString.
18+
* WebKitTestRunner/ios/UIScriptControllerIOS.mm:
19+
(WTR::UIScriptController::findString): Implement findString by forwarding the call to the
20+
web view.
21+
* WebKitTestRunner/mac/UIScriptControllerMac.mm:
22+
(WTR::UIScriptController::findString): Dummy implementation of findString.
23+
124
2017-11-01 Alex Christensen <[email protected]>
225

326
Add a test for _WKInputDelegate.willSubmitFormValues

Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm

+4
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,10 @@ static CGPoint contentOffsetBoundedInValidRange(UIScrollView *scrollView, CGPoin
319319
{
320320
}
321321

322+
void UIScriptController::findString(JSStringRef, unsigned long options, unsigned long maxCount)
323+
{
324+
}
325+
322326
void UIScriptController::removeViewFromWindow(JSValueRef)
323327
{
324328
}

Tools/DumpRenderTree/mac/UIScriptControllerMac.mm

+4
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@
123123
{
124124
}
125125

126+
void UIScriptController::findString(JSStringRef, unsigned long options, unsigned long maxCount)
127+
{
128+
}
129+
126130
void UIScriptController::removeViewFromWindow(JSValueRef callback)
127131
{
128132
unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent);

Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl

+2
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ interface UIScriptController {
239239
void simulateRotation(DeviceOrientation orientation, object callback);
240240
void simulateRotationLikeSafari(DeviceOrientation orientation, object callback);
241241

242+
void findString(DOMString string, unsigned long options, unsigned long maxCount);
243+
242244
// Unparent and parent the web view, simulating, for example, tab switching.
243245
void removeViewFromWindow(object callback);
244246
void addViewToWindow(object callback);

Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,10 @@ void UIScriptController::simulateRotationLikeSafari(DeviceOrientation*, JSValueR
445445
{
446446
}
447447

448+
void UIScriptController::findString(JSStringRef, unsigned long options, unsigned long maxCount)
449+
{
450+
}
451+
448452
void UIScriptController::removeViewFromWindow(JSValueRef)
449453
{
450454
}

Tools/TestRunnerShared/UIScriptContext/UIScriptController.h

+2
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ class UIScriptController : public JSWrappable {
166166
void simulateRotation(DeviceOrientation*, JSValueRef);
167167
void simulateRotationLikeSafari(DeviceOrientation*, JSValueRef);
168168

169+
void findString(JSStringRef, unsigned long options, unsigned long maxCount);
170+
169171
// These use a callback to allow the client to know when view visibility state updates get to the web process.
170172
void removeViewFromWindow(JSValueRef);
171173
void addViewToWindow(JSValueRef);

Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm

+6
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,12 @@ static UIDeviceOrientation toUIDeviceOrientation(DeviceOrientation* orientation)
620620
[[UIDevice currentDevice] setOrientation:toUIDeviceOrientation(orientation) animated:YES];
621621
}
622622

623+
void UIScriptController::findString(JSStringRef string, unsigned long options, unsigned long maxCount)
624+
{
625+
TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
626+
[webView _findString:toWTFString(toWK(string)) options:options maxCount:maxCount];
627+
}
628+
623629
void UIScriptController::removeViewFromWindow(JSValueRef callback)
624630
{
625631
TestController::singleton().mainWebView()->removeFromWindow();

Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm

+4
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@
164164
{
165165
}
166166

167+
void UIScriptController::findString(JSStringRef, unsigned long options, unsigned long maxCount)
168+
{
169+
}
170+
167171
void UIScriptController::removeViewFromWindow(JSValueRef callback)
168172
{
169173
#if WK_API_ENABLED

0 commit comments

Comments
 (0)