Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 866b410bceb84beb179dff08a712f1c00c962ecd
      
https://github.com/WebKit/WebKit/commit/866b410bceb84beb179dff08a712f1c00c962ecd
  Author: Wenson Hsieh <wenson_hs...@apple.com>
  Date:   2024-04-15 (Mon, 15 Apr 2024)

  Changed paths:
    M Source/WebCore/page/ElementTargetingController.cpp
    M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/ElementTargetingTests.mm
    A Tools/TestWebKitAPI/Tests/WebKitCocoa/element-targeting-6.html

  Log Message:
  -----------
  [Remote Inspection] Tune viewport area ratio size thresholds to be less 
restrictive on mobile sites
https://bugs.webkit.org/show_bug.cgi?id=272654
rdar://126271452

Reviewed by Abrar Rahman Protyasha.

Currently, the constants used to identify absolutely-positioned or in-flow 
candidates when finding
targets have been (for the most part) tested against desktop content on macOS. 
However, these
thresholds are slightly too restrictive on mobile, where potential targets tend 
to fill a larger
portion of the viewport.

To account for this, this patch turns the 5 constant values below into 
linearly-interpolated values,
depending on the viewport area. At roughly desktop-class viewport areas, these 
are equivalent to
their current values; on mobile, these are tuned to be relatively larger.

```
Form Factor    Area       Max AbsPos      Max In-Flow    Min In-Flow    Max 
Nearby    Max Adj. Area
---------------------------------------------------------------------------------------------------
Desktop        800000     0.750           0.500          0.005          0.250   
      0.250
Mobile         200000     1.000           1.000          0.010          0.500   
      0.300
```

* Source/WebCore/page/ElementTargetingController.cpp:
(WebCore::linearlyInterpolatedViewportRatio):
(WebCore::maximumAreaRatioForAbsolutelyPositionedContent):
(WebCore::maximumAreaRatioForInFlowContent):
(WebCore::maximumAreaRatioForNearbyTargets):
(WebCore::minimumAreaRatioForInFlowContent):
(WebCore::maximumAreaRatioForTrackingAdjustmentAreas):

Turn all of these hard-coded constants into helper functions that take the 
current viewport size as
input, and return linearly-interpolated values, clamped to the given 
minimum/maximum values.

(WebCore::inflatedClientRectForAdjustmentRegionTracking):
(WebCore::ElementTargetingController::findTargets):

Make an additional adjustment: treat candidates with no children as targets, 
even if they're above
size thresholds.

* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/ElementTargetingTests.mm:
(-[WKWebView expectSingleTargetedSelector:at:]):

Pull this testing helper out of `ElementTargeting.ParentRelativeSelectors` and 
into a helper method
in a testing category on `TestWKWebView`, so that we can use it from both of 
the below tests.

(TestWebKitAPI::TEST(ElementTargeting, ParentRelativeSelectors)):
(TestWebKitAPI::TEST(ElementTargeting, TargetInFlowElements)):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/element-targeting-6.html: Added.

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to