Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a295ea495b3bdefa3963df88c83e7b0bdf5d1449
      
https://github.com/WebKit/WebKit/commit/a295ea495b3bdefa3963df88c83e7b0bdf5d1449
  Author: Rupin Mittal <[email protected]>
  Date:   2025-11-05 (Wed, 05 Nov 2025)

  Changed paths:
    M Source/WebKit/CMakeLists.txt
    M Source/WebKit/DerivedSources-input.xcfilelist
    M Source/WebKit/DerivedSources.make
    A Source/WebKit/Shared/TextManipulationParameters.h
    A Source/WebKit/Shared/TextManipulationParameters.serialization.in
    M Source/WebKit/Shared/WebPageCreationParameters.h
    M Source/WebKit/Shared/WebPageCreationParameters.serialization.in
    M Source/WebKit/UIProcess/WebPageProxy.cpp
    M Source/WebKit/UIProcess/WebPageProxyInternals.h
    M Source/WebKit/WebKit.xcodeproj/project.pbxproj
    M Source/WebKit/WebProcess/WebPage/WebPage.cpp
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/SiteIsolation.mm

  Log Message:
  -----------
  [Site Isolation] Text in cross-site iframe isn't translated if frame is added 
after user translates page
https://bugs.webkit.org/show_bug.cgi?id=301981
rdar://164059026

Reviewed by Wenson Hsieh and Sihui Liu.

If the user translates a page, and later a cross-site iframe is added, the
text in this iframe should be translated automatically as well. This happens
with site isolation off, but not with site isolation on.

With site isolation off, the process is:
1. User translates the page
2. WebPageProxy::startTextManipulations sends IPC to 
WebPage::startTextManipulations
3. WebPage stores m_textManipulationIncludesSubframes and 
textManipulationExclusionRules
4. Cross-site iframe is added
5. WebPage::didCommitLoad calls startTextManipulationForFrame because
   m_textManipulationIncludesSubframes is already set
6. Text gets translated

With site isolation on, the iframe is added to a new WebPage instead of the
existing one. So in step 5, WebPage::didCommitLoad doesn't call
startTextManipulationForFrame because this new WebPage doesn't have
m_textManipulationIncludesSubframes set. And so the text isn't translated.

To fix this, WebPageProxy::startTextManipulations stores these
TextManipulationParameters so that they'll be sent to new WebPages created
in the future (via WebPageCreationParamters). Once WebPage::didCommitLoad
is called, it'll call startTextManipulationForFrame.

These TextManipulationParameters are cleared from WebPageProxy whenever the
main frame navigates.

Test: Tools/TestWebKitAPI/Tests/WebKitCocoa/SiteIsolation.mm

* Source/WebKit/CMakeLists.txt:
* Source/WebKit/DerivedSources-input.xcfilelist:
* Source/WebKit/DerivedSources.make:
* Source/WebKit/Shared/TextManipulationParameters.h: Added.
* Source/WebKit/Shared/TextManipulationParameters.serialization.in: Added.
* Source/WebKit/Shared/WebPageCreationParameters.h:
* Source/WebKit/Shared/WebPageCreationParameters.serialization.in:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didCommitLoadForFrame):

If the main frame navigates, clear the TextManipulationParameters.

(WebKit::WebPageProxy::creationParameters):

Send the TextManipulationParameters to the new WebPage.

(WebKit::WebPageProxy::startTextManipulations):

Store the TextManipulationParameters.

* Source/WebKit/UIProcess/WebPageProxyInternals.h:
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/SiteIsolation.mm:
(TestWebKitAPI::(SiteIsolation, 
TextManipulationInIframeIfIframeIsAddedAfterTranslationCall)):

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to