Title: [294133] branches/safari-7614.1.13-branch
Revision
294133
Author
alanc...@apple.com
Date
2022-05-12 17:55:22 -0700 (Thu, 12 May 2022)

Log Message

Cherry-pick r294088. rdar://problem/93134975

    ImageAnalysisQueue should extract and analyze images inside of subframes
    https://bugs.webkit.org/show_bug.cgi?id=240328
    rdar://93134975

    Reviewed by Tim Horton.

    Teach `ImageAnalysisQueue` to recursively find all images on the page (including images in of subframe content)
    and queue them for analysis. To do this, we refactor `enqueueAllImages` to call into a new recursive helper
    method, `enqueueAllImagesRecursive`, to look for more candidate image elements that exist inside frame owner
    elements (e.g. `iframe`).

    Test: ImageAnalysisTests.AnalyzeImagesInSubframes

    * page/ImageAnalysisQueue.cpp:
    (WebCore::ImageAnalysisQueue::enqueueAllImages):
    (WebCore::ImageAnalysisQueue::enqueueAllImagesRecursive):
    * page/ImageAnalysisQueue.h:
    ImageAnalysisQueue should extract and analyze images inside of subframes
    https://bugs.webkit.org/show_bug.cgi?id=240328
    rdar://93134975

    Reviewed by Tim Horton.

    Add an API test to verify that we extract and analyze images inside of subframes, in addition to images in the
    main frame.

    * TestWebKitAPI/Tests/WebKitCocoa/ImageAnalysisTests.mm:
    (TestWebKitAPI::TEST):
    * TestWebKitAPI/Tests/WebKitCocoa/multiple-images.html:

    Canonical link: https://commits.webkit.org/250478@main

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

Modified Paths

Diff

Modified: branches/safari-7614.1.13-branch/Source/WebCore/ChangeLog (294132 => 294133)


--- branches/safari-7614.1.13-branch/Source/WebCore/ChangeLog	2022-05-13 00:55:18 UTC (rev 294132)
+++ branches/safari-7614.1.13-branch/Source/WebCore/ChangeLog	2022-05-13 00:55:22 UTC (rev 294133)
@@ -1,5 +1,64 @@
 2022-05-12  Russell Epstein  <repst...@apple.com>
 
+        Cherry-pick r294088. rdar://problem/93134975
+
+    ImageAnalysisQueue should extract and analyze images inside of subframes
+    https://bugs.webkit.org/show_bug.cgi?id=240328
+    rdar://93134975
+    
+    Reviewed by Tim Horton.
+    
+    Teach `ImageAnalysisQueue` to recursively find all images on the page (including images in of subframe content)
+    and queue them for analysis. To do this, we refactor `enqueueAllImages` to call into a new recursive helper
+    method, `enqueueAllImagesRecursive`, to look for more candidate image elements that exist inside frame owner
+    elements (e.g. `iframe`).
+    
+    Test: ImageAnalysisTests.AnalyzeImagesInSubframes
+    
+    * page/ImageAnalysisQueue.cpp:
+    (WebCore::ImageAnalysisQueue::enqueueAllImages):
+    (WebCore::ImageAnalysisQueue::enqueueAllImagesRecursive):
+    * page/ImageAnalysisQueue.h:
+    ImageAnalysisQueue should extract and analyze images inside of subframes
+    https://bugs.webkit.org/show_bug.cgi?id=240328
+    rdar://93134975
+    
+    Reviewed by Tim Horton.
+    
+    Add an API test to verify that we extract and analyze images inside of subframes, in addition to images in the
+    main frame.
+    
+    * TestWebKitAPI/Tests/WebKitCocoa/ImageAnalysisTests.mm:
+    (TestWebKitAPI::TEST):
+    * TestWebKitAPI/Tests/WebKitCocoa/multiple-images.html:
+    
+    Canonical link: https://commits.webkit.org/250478@main
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294088 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-05-11  Wenson Hsieh  <wenson_hs...@apple.com>
+
+            ImageAnalysisQueue should extract and analyze images inside of subframes
+            https://bugs.webkit.org/show_bug.cgi?id=240328
+            rdar://93134975
+
+            Reviewed by Tim Horton.
+
+            Teach `ImageAnalysisQueue` to recursively find all images on the page (including images in of subframe content)
+            and queue them for analysis. To do this, we refactor `enqueueAllImages` to call into a new recursive helper
+            method, `enqueueAllImagesRecursive`, to look for more candidate image elements that exist inside frame owner
+            elements (e.g. `iframe`).
+
+            Test: ImageAnalysisTests.AnalyzeImagesInSubframes
+
+            * page/ImageAnalysisQueue.cpp:
+            (WebCore::ImageAnalysisQueue::enqueueAllImages):
+            (WebCore::ImageAnalysisQueue::enqueueAllImagesRecursive):
+            * page/ImageAnalysisQueue.h:
+
+2022-05-12  Russell Epstein  <repst...@apple.com>
+
         Cherry-pick r293968. rdar://problem/92892014
 
     [macOS] REGRESSION (r293825): Find highlight snapshots are incorrectly scaled

Modified: branches/safari-7614.1.13-branch/Source/WebCore/page/ImageAnalysisQueue.cpp (294132 => 294133)


--- branches/safari-7614.1.13-branch/Source/WebCore/page/ImageAnalysisQueue.cpp	2022-05-13 00:55:18 UTC (rev 294132)
+++ branches/safari-7614.1.13-branch/Source/WebCore/page/ImageAnalysisQueue.cpp	2022-05-13 00:55:22 UTC (rev 294133)
@@ -97,8 +97,18 @@
         m_identifier = identifier;
     }
 
+    enqueueAllImagesRecursive(document);
+}
+
+void ImageAnalysisQueue::enqueueAllImagesRecursive(Document& document)
+{
     for (auto& image : descendantsOfType<HTMLImageElement>(document))
         enqueueIfNeeded(image);
+
+    for (auto& frameOwner : descendantsOfType<HTMLFrameOwnerElement>(document)) {
+        if (RefPtr contentDocument = frameOwner.contentDocument())
+            enqueueAllImagesRecursive(*contentDocument);
+    }
 }
 
 void ImageAnalysisQueue::resumeProcessing()

Modified: branches/safari-7614.1.13-branch/Source/WebCore/page/ImageAnalysisQueue.h (294132 => 294133)


--- branches/safari-7614.1.13-branch/Source/WebCore/page/ImageAnalysisQueue.h	2022-05-13 00:55:18 UTC (rev 294132)
+++ branches/safari-7614.1.13-branch/Source/WebCore/page/ImageAnalysisQueue.h	2022-05-13 00:55:22 UTC (rev 294133)
@@ -54,6 +54,8 @@
     void resumeProcessingSoon();
     void resumeProcessing();
 
+    void enqueueAllImagesRecursive(Document&);
+
     enum class Priority : bool { Low, High };
     struct Task {
         WeakPtr<HTMLImageElement> element;

Modified: branches/safari-7614.1.13-branch/Tools/ChangeLog (294132 => 294133)


--- branches/safari-7614.1.13-branch/Tools/ChangeLog	2022-05-13 00:55:18 UTC (rev 294132)
+++ branches/safari-7614.1.13-branch/Tools/ChangeLog	2022-05-13 00:55:22 UTC (rev 294133)
@@ -1,5 +1,59 @@
 2022-05-12  Russell Epstein  <repst...@apple.com>
 
+        Cherry-pick r294088. rdar://problem/93134975
+
+    ImageAnalysisQueue should extract and analyze images inside of subframes
+    https://bugs.webkit.org/show_bug.cgi?id=240328
+    rdar://93134975
+    
+    Reviewed by Tim Horton.
+    
+    Teach `ImageAnalysisQueue` to recursively find all images on the page (including images in of subframe content)
+    and queue them for analysis. To do this, we refactor `enqueueAllImages` to call into a new recursive helper
+    method, `enqueueAllImagesRecursive`, to look for more candidate image elements that exist inside frame owner
+    elements (e.g. `iframe`).
+    
+    Test: ImageAnalysisTests.AnalyzeImagesInSubframes
+    
+    * page/ImageAnalysisQueue.cpp:
+    (WebCore::ImageAnalysisQueue::enqueueAllImages):
+    (WebCore::ImageAnalysisQueue::enqueueAllImagesRecursive):
+    * page/ImageAnalysisQueue.h:
+    ImageAnalysisQueue should extract and analyze images inside of subframes
+    https://bugs.webkit.org/show_bug.cgi?id=240328
+    rdar://93134975
+    
+    Reviewed by Tim Horton.
+    
+    Add an API test to verify that we extract and analyze images inside of subframes, in addition to images in the
+    main frame.
+    
+    * TestWebKitAPI/Tests/WebKitCocoa/ImageAnalysisTests.mm:
+    (TestWebKitAPI::TEST):
+    * TestWebKitAPI/Tests/WebKitCocoa/multiple-images.html:
+    
+    Canonical link: https://commits.webkit.org/250478@main
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294088 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-05-11  Wenson Hsieh  <wenson_hs...@apple.com>
+
+            ImageAnalysisQueue should extract and analyze images inside of subframes
+            https://bugs.webkit.org/show_bug.cgi?id=240328
+            rdar://93134975
+
+            Reviewed by Tim Horton.
+
+            Add an API test to verify that we extract and analyze images inside of subframes, in addition to images in the
+            main frame.
+
+            * TestWebKitAPI/Tests/WebKitCocoa/ImageAnalysisTests.mm:
+            (TestWebKitAPI::TEST):
+            * TestWebKitAPI/Tests/WebKitCocoa/multiple-images.html:
+
+2022-05-12  Russell Epstein  <repst...@apple.com>
+
         Cherry-pick r294084. rdar://problem/93036066
 
     Re-send connection configuration if webpushd dies

Modified: branches/safari-7614.1.13-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ImageAnalysisTests.mm (294132 => 294133)


--- branches/safari-7614.1.13-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ImageAnalysisTests.mm	2022-05-13 00:55:18 UTC (rev 294132)
+++ branches/safari-7614.1.13-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ImageAnalysisTests.mm	2022-05-13 00:55:22 UTC (rev 294133)
@@ -255,6 +255,23 @@
         EXPECT_WK_STREQ(overlayText, @"Foo bar");
 }
 
+TEST(ImageAnalysisTests, AnalyzeImagesInSubframes)
+{
+    auto requestSwizzler = makeImageAnalysisRequestSwizzler(processRequestWithResults);
+
+    auto webView = createWebViewWithTextRecognitionEnhancements();
+    [webView synchronouslyLoadTestPageNamed:@"multiple-images"];
+    __block bool doneInsertingFrame = false;
+    [webView callAsyncJavaScript:@"appendAndLoadSubframe(source)" arguments:@{ @"source" : @"multiple-images.html" } inFrame:nil inContentWorld:WKContentWorld.pageWorld completionHandler:^(id, NSError *error) {
+        EXPECT_NULL(error);
+        doneInsertingFrame = true;
+    }];
+    Util::run(&doneInsertingFrame);
+
+    [webView _startImageAnalysis:nil];
+    [webView waitForImageAnalysisRequests:10];
+}
+
 TEST(ImageAnalysisTests, AnalyzeDynamicallyLoadedImages)
 {
     auto requestSwizzler = makeImageAnalysisRequestSwizzler(processRequestWithResults);

Modified: branches/safari-7614.1.13-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/multiple-images.html (294132 => 294133)


--- branches/safari-7614.1.13-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/multiple-images.html	2022-05-13 00:55:18 UTC (rev 294132)
+++ branches/safari-7614.1.13-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/multiple-images.html	2022-05-13 00:55:22 UTC (rev 294133)
@@ -27,6 +27,16 @@
                 document.body.appendChild(image);
             }
 
+            async function appendAndLoadSubframe(source)
+            {
+                const frame = document.createElement("iframe");
+                frame.src = ""
+                await new Promise(resolve => {
+                    frame.addEventListener("load", resolve);
+                    document.body.appendChild(frame);
+                });
+            }
+
             function hideAllImages()
             {
                 Array.from(document.images).forEach(image => image.style.setProperty("display", "none"));
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to