Title: [248548] trunk
Revision
248548
Author
[email protected]
Date
2019-08-12 14:40:56 -0700 (Mon, 12 Aug 2019)

Log Message

Fix Crash in Mail Search
https://bugs.webkit.org/show_bug.cgi?id=200589
Source/WebKit:

<rdar://problem/53666720>

Reviewed by Tim Horton.

If we search in Mail backwards first, for AppKit reasons
we get a -1 for the index of the found item.
Do not try and insert data in this case.

* UIProcess/mac/WKTextFinderClient.mm:

Tools:

Reviewed by Tim Horton.

If you search backwards first in mail, we would crash,
this tests that codepath.

* TestWebKitAPI/Tests/WebKitCocoa/FindInPage.mm:
(TEST):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (248547 => 248548)


--- trunk/Source/WebKit/ChangeLog	2019-08-12 21:37:16 UTC (rev 248547)
+++ trunk/Source/WebKit/ChangeLog	2019-08-12 21:40:56 UTC (rev 248548)
@@ -1,3 +1,17 @@
+2019-08-12  Megan Gardner  <[email protected]>
+
+        Fix Crash in Mail Search
+        https://bugs.webkit.org/show_bug.cgi?id=200589
+        <rdar://problem/53666720>
+
+        Reviewed by Tim Horton.
+
+        If we search in Mail backwards first, for AppKit reasons 
+        we get a -1 for the index of the found item.
+        Do not try and insert data in this case.
+
+        * UIProcess/mac/WKTextFinderClient.mm:
+
 2019-08-12  Adrian Perez de Castro  <[email protected]>
 
         [WPE][GTK] Fix building without unified sources

Modified: trunk/Source/WebKit/UIProcess/mac/WKTextFinderClient.mm (248547 => 248548)


--- trunk/Source/WebKit/UIProcess/mac/WKTextFinderClient.mm	2019-08-12 21:37:16 UTC (rev 248547)
+++ trunk/Source/WebKit/UIProcess/mac/WKTextFinderClient.mm	2019-08-12 21:40:56 UTC (rev 248548)
@@ -81,7 +81,9 @@
             // The rest will remain empty, but it's important to NSTextFinder
             // that they at least exist.
             allMatches.resize(matchCount);
-            allMatches[matchIndex].appendVector(matchRects);
+            // FIXME: Clean this up and figure out why we are getting a -1 index
+            if (matchIndex >= 0 && static_cast<uint32_t>(matchIndex) < matchCount)
+                allMatches[matchIndex].appendVector(matchRects);
         }
 
         [m_textFinderClient didFindStringMatchesWithRects:allMatches didWrapAround:didWrapAround];

Modified: trunk/Tools/ChangeLog (248547 => 248548)


--- trunk/Tools/ChangeLog	2019-08-12 21:37:16 UTC (rev 248547)
+++ trunk/Tools/ChangeLog	2019-08-12 21:40:56 UTC (rev 248548)
@@ -1,3 +1,16 @@
+2019-08-12  Megan Gardner  <[email protected]>
+
+        Fix Crash in Mail Search
+        https://bugs.webkit.org/show_bug.cgi?id=200589
+
+        Reviewed by Tim Horton.
+
+        If you search backwards first in mail, we would crash,
+        this tests that codepath.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/FindInPage.mm:
+        (TEST):
+
 2019-08-12  Wenson Hsieh  <[email protected]>
 
         [iPadOS] Web pages sometimes load at half width in Safari

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FindInPage.mm (248547 => 248548)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FindInPage.mm	2019-08-12 21:37:16 UTC (rev 248547)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FindInPage.mm	2019-08-12 21:40:56 UTC (rev 248548)
@@ -224,6 +224,22 @@
     EXPECT_FALSE(result.didWrap);
 }
 
+TEST(WebKit, FindInPageBackwardsFirst)
+{
+    RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]);
+    [webView _setOverrideDeviceScaleFactor:2];
+
+    [webView loadHTMLString:@"word word" baseURL:nil];
+    [webView _test_waitForDidFinishNavigation];
+
+    // Find one match, doing an incremental search.
+    auto result = findMatches(webView.get(), @"word", wrapBackwardsFindOptions, 1);
+    EXPECT_EQ((NSUInteger)1, [result.matches count]);
+
+    result = findMatches(webView.get(), @"word", wrapBackwardsFindOptions, 1);
+    EXPECT_EQ((NSUInteger)1, [result.matches count]);
+}
+
 TEST(WebKit, FindInPageWrappingSubframe)
 {
     RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to