Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 49304f808259f936a4b3523c8fd7636bf2b46878
https://github.com/WebKit/WebKit/commit/49304f808259f936a4b3523c8fd7636bf2b46878
Author: Alan Baradlay <[email protected]>
Date: 2026-05-10 (Sun, 10 May 2026)
Changed paths:
M Source/WebCore/rendering/RenderImage.cpp
M Source/WebCore/rendering/RenderReplaced.cpp
M Source/WebCore/rendering/RenderReplaced.h
M Source/WebCore/rendering/RenderWidget.cpp
M Source/WebCore/rendering/RenderWidget.h
M Source/WebCore/rendering/svg/RenderSVGRoot.cpp
M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGRoot.cpp
Log Message:
-----------
[cleanup] Refactor replaced element intrinsic size and aspect ratio
computation
https://bugs.webkit.org/show_bug.cgi?id=314455
Reviewed by Antti Koivisto.
Previously, a single monolithic function
(computeAspectRatioInformationForRenderBox)
handled three tasks at once:
1. getting the intrinsic size,
2. getting the preferred aspect ratio, and
3. caching the result to m_intrinsicSize.
It took a RenderReplaced* parameter to optionally delegate to an embedded SVG
root renderer.
The problem was that this made it impossible to ask for just the ratio without
also computing the size and triggering the cache update. Callers like
computeIntrinsicAspectRatio() and intrinsicRatio() only needed the ratio but
had to go through the whole combined function.
The fix moves embedded-content handling into virtual overrides where the logic
belongs:
- RenderImage::computeIntrinsicSize() and preferredAspectRatio() now handle
the SVG-image embedded case (zoom, DPR, writing mode).
- RenderWidget::computeIntrinsicSize() and preferredAspectRatio() now handle
the iframe/object embedded case (zoom, writing mode).
This eliminates computeAspectRatioInformationForRenderBox entirely and removes
the RenderReplaced* parameter from
computeIntrinsicSizesConstrainedByTransferredMinMaxSizes.
Ratio queries (computeIntrinsicAspectRatio, intrinsicRatio) are now simple
one-liners with no side effects.
No behavior change (the m_intrinsicSize caching still happens during layout
via computeIntrinsicSizesConstrainedByTransferredMinMaxSizes)
* Source/WebCore/rendering/RenderImage.cpp:
(WebCore::RenderImage::computeIntrinsicSize const):
(WebCore::RenderImage::preferredAspectRatio const):
* Source/WebCore/rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::computeIntrinsicSizesConstrainedByTransferredMinMaxSizes
const):
(WebCore::RenderReplaced::computeIntrinsicAspectRatio const):
(WebCore::RenderReplaced::computeIntrinsicSize const):
(WebCore::RenderReplaced::preferredAspectRatio const):
(WebCore::RenderReplaced::computeReplacedLogicalWidth const):
(WebCore::RenderReplaced::computeReplacedLogicalHeight const):
(WebCore::RenderReplaced::intrinsicRatio const):
(WebCore::RenderReplaced::computeAspectRatioInformationForRenderBox const):
Deleted.
* Source/WebCore/rendering/RenderReplaced.h:
* Source/WebCore/rendering/RenderWidget.cpp:
(WebCore::RenderWidget::computeIntrinsicSize const):
(WebCore::RenderWidget::preferredAspectRatio const):
* Source/WebCore/rendering/RenderWidget.h:
* Source/WebCore/rendering/svg/RenderSVGRoot.cpp:
(WebCore::RenderSVGRoot::computeIntrinsicSize const):
(WebCore::RenderSVGRoot::preferredAspectRatio const):
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGRoot.cpp:
(WebCore::LegacyRenderSVGRoot::computeIntrinsicSize const):
(WebCore::LegacyRenderSVGRoot::preferredAspectRatio const):
Canonical link: https://commits.webkit.org/312972@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications