Title: [248627] branches/safari-608-branch
Revision
248627
Author
alanc...@apple.com
Date
2019-08-13 13:01:36 -0700 (Tue, 13 Aug 2019)

Log Message

Cherry-pick r248548. rdar://problem/54237813

    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):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248548 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-608-branch/Source/WebKit/ChangeLog (248626 => 248627)


--- branches/safari-608-branch/Source/WebKit/ChangeLog	2019-08-13 20:01:33 UTC (rev 248626)
+++ branches/safari-608-branch/Source/WebKit/ChangeLog	2019-08-13 20:01:36 UTC (rev 248627)
@@ -1,5 +1,50 @@
 2019-08-13  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r248548. rdar://problem/54237813
+
+    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):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248548 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-08-12  Megan Gardner  <megan_gard...@apple.com>
+
+            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-13  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r248543. rdar://problem/54237801
 
     Clear m_sessionStorageNamespaces on the background thread

Modified: branches/safari-608-branch/Source/WebKit/UIProcess/mac/WKTextFinderClient.mm (248626 => 248627)


--- branches/safari-608-branch/Source/WebKit/UIProcess/mac/WKTextFinderClient.mm	2019-08-13 20:01:33 UTC (rev 248626)
+++ branches/safari-608-branch/Source/WebKit/UIProcess/mac/WKTextFinderClient.mm	2019-08-13 20:01:36 UTC (rev 248627)
@@ -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: branches/safari-608-branch/Tools/ChangeLog (248626 => 248627)


--- branches/safari-608-branch/Tools/ChangeLog	2019-08-13 20:01:33 UTC (rev 248626)
+++ branches/safari-608-branch/Tools/ChangeLog	2019-08-13 20:01:36 UTC (rev 248627)
@@ -1,5 +1,49 @@
 2019-08-13  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r248548. rdar://problem/54237813
+
+    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):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248548 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-08-12  Megan Gardner  <megan_gard...@apple.com>
+
+            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-13  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r248166. rdar://problem/54237837
 
     [macOS 10.15] Image dragged from Safari does not appear in Notes

Modified: branches/safari-608-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/FindInPage.mm (248626 => 248627)


--- branches/safari-608-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/FindInPage.mm	2019-08-13 20:01:33 UTC (rev 248626)
+++ branches/safari-608-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/FindInPage.mm	2019-08-13 20:01:36 UTC (rev 248627)
@@ -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
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to