Skip to content

Commit

Permalink
Interaction Regions generation should get geometry from the RenderTree
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=272328
<rdar://125901606>

Reviewed by Alan Baradlay.

Interaction Regions generation happens during the EventRegion paint
phase, and should get geometry from the RenderTree instead of going
through the DOM.
Replace the calls to `Element#boundingClientRect()` with a custom
function based on `RenderObject#absoluteQuads()`.

* Source/WebCore/page/InteractionRegion.cpp:
(WebCore::absoluteBoundingRect):
(WebCore::interactionRegionForRenderedRegion):

Canonical link: https://commits.webkit.org/277290@main
  • Loading branch information
etiennesegonzac committed Apr 10, 2024
1 parent ffe1284 commit 857ff84
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Source/WebCore/page/InteractionRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@ static bool isGuardContainer(const Element& element)
return hasTransparentContainerStyle(renderer.style());
}

static FloatRect absoluteBoundingRect(const RenderObject& renderer)
{
Vector<FloatQuad> quads;
renderer.absoluteQuads(quads);
return unitedBoundingBoxes(quads);
}

static bool cachedImageIsPhoto(const CachedImage& cachedImage)
{
if (cachedImage.errorOccurred())
Expand Down Expand Up @@ -423,16 +430,16 @@ std::optional<InteractionRegion> interactionRegionForRenderedRegion(RenderObject
std::optional<Path> clipPath = std::nullopt;
RefPtr styleClipPath = regionRenderer.style().clipPath();

if (styleClipPath && styleClipPath->type() == PathOperation::OperationType::Shape) {
auto boundingRect = originalElement->boundingClientRect();
if (styleClipPath && styleClipPath->type() == PathOperation::OperationType::Shape && originalElement) {
auto boundingRect = absoluteBoundingRect(regionRenderer);
clipPath = styleClipPath->getPath(TransformOperationData(FloatRect(FloatPoint(), boundingRect.size())));
} else if (iconImage && originalElement) {
LayoutRect imageRect(rect);
Ref shape = Shape::createRasterShape(iconImage.get(), 0, imageRect, imageRect, WritingMode::HorizontalTb, 0);
Shape::DisplayPaths paths;
shape->buildDisplayPaths(paths);
auto path = paths.shape;
auto boundingRect = originalElement->boundingClientRect();
auto boundingRect = absoluteBoundingRect(regionRenderer);
path.translate(FloatSize(-boundingRect.x(), -boundingRect.y()));
clipPath = path;
} else if (svgClipElements) {
Expand Down

0 comments on commit 857ff84

Please sign in to comment.