Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 0ed01cbc13ea3b49619b3b31b1e2c9c441edb57c
https://github.com/WebKit/WebKit/commit/0ed01cbc13ea3b49619b3b31b1e2c9c441edb57c
Author: Jessica Cheung <[email protected]>
Date: 2026-09-22 (Tue, 22 Sep 2026)
Changed paths:
M Source/WebCore/Headers.cmake
M Source/WebCore/Sources.txt
M Source/WebCore/WebCore.xcodeproj/project.pbxproj
M Source/WebCore/editing/TextManipulationController.cpp
M Source/WebCore/editing/TextManipulationController.h
M Source/WebCore/editing/TextManipulationItem.h
A Source/WebCore/page/ViewportProximityInfo.cpp
A Source/WebCore/page/ViewportProximityInfo.h
M Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in
Log Message:
-----------
[Webpage Translation Refactoring] Text items aren't aware of visibility
https://bugs.webkit.org/show_bug.cgi?id=324729
rdar://188010534
Reviewed by Ryosuke Niwa.
Items to be translated on a webpage has TextManipulationToken
which has TextManipulationTokenInfo. TextManipulationTokenInfo has
the notion of visibility via `bool isVisible` but it does not account
for overflow clip. Additionally, this visibility is per token, not per
item (container of texts).
It would be helpful to know this visibility information for items, so
add support for a ViewportProximityInfo struct.
ViewportProximityInfo has three ViewportRelations:
- Intersecting: the item is on the screen
- Offscreen
- ClippedByAncestor: the item is scrolled out of sight or clipped
ViewportProximityInfo itself has these fields:
- ViewportRelation: by default assumed to be Intersecting
- viewportSizedDistance: the distance an item is from the normalized
corresponding viewport dimension (e.g. an item of 0.30 distance is
further away from an item of 0.10)
- viewportCoverage: the portion of the screen that the item
takes up ranging from [0,1], 1 being completely covering the whole
screen and 0 being completely offscreen
API tests will be added in a follow-up PR.
* Source/WebCore/Headers.cmake:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/editing/TextManipulationController.cpp:
(WebCore::TextManipulationController::addItemIfPossible):
(WebCore::TextManipulationController::observeParagraphs):
(WebCore::TextManipulationController::addItem):
* Source/WebCore/editing/TextManipulationController.h:
* Source/WebCore/editing/TextManipulationItem.h:
* Source/WebCore/page/ViewportProximityInfo.cpp: Added.
(WebCore::visibleAbsoluteRect):
(WebCore::visibleViewportRectInRootView):
(WebCore::viewportProximityInfo):
(WebCore::absoluteTextBounds):
(WebCore::ancestorFrameClipInRootView):
(WebCore::viewportProximityInfoForRange):
* Source/WebCore/page/ViewportProximityInfo.h:
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:
Canonical link: https://commits.webkit.org/321641@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications