Skip to content

Commit

Permalink
Add occluded viewport width + height to VisibilityChangedEvent
Browse files Browse the repository at this point in the history
Summary:
# Context

With the occlusion fix now launched for fb4a, in order for Merlin to properly calculate the viewport coverage in the same way, we need to provide the transformed (occluded) rect width and height of the viewport.

# This diff
Add the transformed viewport height + width to VisibilityChangeEvent so that consumers (Merlin) can use this to calculate coverage percentage including the occlusion fix.

Reviewed By: adityasharat

Differential Revision: D55091986

fbshipit-source-id: f541f8a151e98203dca20645ff0da9c6ee383791
  • Loading branch information
henrykam authored and facebook-github-bot committed Mar 20, 2024
1 parent 123e28d commit e97ae62
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,9 @@ public interface VisibilityBoundsTransformer {

int getViewportArea(View view);

int getViewportWidth(View view);

int getViewportHeight(View view);

boolean shouldUseTransformedVisibleRect(VisibilityOutput visibilityOutput);
}
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,15 @@ private static void processVisibilityOutputsNonInc(
final int visibleHeight = getVisibleHeight(intersection);
int rootHostViewWidth = getRootHostViewWidth(extensionState);
int rootHostViewHeight = getRootHostViewHeight(extensionState);
if (shouldUseTransformedVisibleRect && transformer != null) {
final Host host = getRootHost(extensionState);
if (host != null && (host.getParent() instanceof View)) {
final View parent = (View) host.getParent();
rootHostViewWidth = transformer.getViewportWidth(parent);
rootHostViewHeight = transformer.getViewportHeight(parent);
}
}

VisibilityUtils.dispatchOnVisibilityChanged(
visibilityChangedHandler,
getVisibleTop(visibilityOutputBounds, intersection),
Expand Down

0 comments on commit e97ae62

Please sign in to comment.