[webkit-changes] [WebKit/WebKit] 277320: [InteractionRegions] Add support for icon masking

Etienne Segonzac noreply at github.com
Thu Mar 14 23:42:25 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 2773206a322f67c458e1f13355cb91640e8f5925
      https://github.com/WebKit/WebKit/commit/2773206a322f67c458e1f13355cb91640e8f5925
  Author: Etienne Segonzac <sgz at apple.com>
  Date:   2024-03-14 (Thu, 14 Mar 2024)

  Changed paths:
    M LayoutTests/interaction-region/content-hint-expected.txt
    A LayoutTests/interaction-region/icon-masking-expected.txt
    A LayoutTests/interaction-region/icon-masking.html
    M Source/WebCore/page/InteractionRegion.cpp
    M Source/WebCore/rendering/EventRegion.cpp
    M Source/WebCore/rendering/EventRegion.h
    M Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeInteractionRegionLayers.mm

  Log Message:
  -----------
  [InteractionRegions] Add support for icon masking
https://bugs.webkit.org/show_bug.cgi?id=270982
<rdar://118882637?

Reviewed by Tim Horton.

Use a shape-outside-like approach to generate InteractionRegion clip
paths for small interactive images.

* Source/WebCore/page/InteractionRegion.cpp:
(WebCore::interactionRegionForRenderedRegion):
Add heuristics to find potential "icons" and generate clip paths for the
regions based on their shapes. (Using the same code as CSS `shape-outside`).

Change the way we handle simple links/buttons containers (with a single
child that also gets an Interaction Region). Instead of prioritizing the
region of the Link/Button (see EventRegion#shouldConsolidateInteractionRegion),
turn the container into a Guard and keep the child's region, which is
likely more interesting (clip path, corners etc...).

(WebCore::hasTransparentContainerStyle):
Extract the "transparent container" logic to a function.
(WebCore::>>findSVGClipElements):
Extract the code looking for an SVG shape in a function.
(WebCore::isGuardContainer):
Check to see if an element is a simple container we should turn into a
Guard to allow it's single child's to shape the Interaction Region.
(WebCore::RefPtr<Image>findIconImage):
Find the potential Image candidate for the raster shape generation.

* Source/WebCore/rendering/EventRegion.h:
* Source/WebCore/rendering/EventRegion.cpp:
(WebCore::EventRegionContext::removeSuperfluousInteractionRegions):
(WebCore::EventRegionContext::uniteInteractionRegions):
Keep track of Guards rects generated for elements, and don't filter them
based on overlap.
(WebCore::guardRectForRegionBounds):
Inflate the rect for regions with complex paths that are also small.
(WebCore::EventRegionContext::shrinkWrapInteractionRegions):
White space clean-up.

* Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeInteractionRegionLayers.mm:
(WebKit::interactionRegionGroupNameForRegion):
Rollback a previous change for InteractionRegion layers grouping. The
current system will actually benefit from grouping regions across
layers.

* LayoutTests/interaction-region/content-hint-expected.txt:
Re-baseline with the new guard containers.
* LayoutTests/interaction-region/icon-masking-expected.txt: Added.
* LayoutTests/interaction-region/icon-masking.html: Added.
Add new test file covering icon masking.

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



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


More information about the webkit-changes mailing list