[webkit-changes] [WebKit/WebKit] 90b0d8: Store replaced element's aspect ratio into its own...

Sammy Gill noreply at github.com
Tue Dec 6 13:00:36 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 90b0d80278b29c29d422dc253e081ad689960056
      https://github.com/WebKit/WebKit/commit/90b0d80278b29c29d422dc253e081ad689960056
  Author: Sammy Gill <sammy.gill at apple.com>
  Date:   2022-12-06 (Tue, 06 Dec 2022)

  Changed paths:
    M LayoutTests/platform/gtk/fast/replaced/width100percent-image-expected.txt
    M LayoutTests/platform/ios/fast/replaced/width100percent-image-expected.txt
    M LayoutTests/platform/mac/fast/replaced/width100percent-image-expected.txt
    M Source/WebCore/platform/graphics/FloatSize.h
    M Source/WebCore/rendering/RenderBox.h
    M Source/WebCore/rendering/RenderImage.cpp
    M Source/WebCore/rendering/RenderImage.h
    M Source/WebCore/rendering/RenderReplaced.cpp
    M Source/WebCore/rendering/RenderReplaced.h
    M Source/WebCore/rendering/style/RenderStyle.h
    M Source/WebCore/rendering/svg/LegacyRenderSVGRoot.cpp
    M Source/WebCore/rendering/svg/LegacyRenderSVGRoot.h
    M Source/WebCore/rendering/svg/RenderSVGRoot.cpp
    M Source/WebCore/rendering/svg/RenderSVGRoot.h

  Log Message:
  -----------
  Store replaced element's aspect ratio into its own struct.
https://bugs.webkit.org/show_bug.cgi?id=248096
rdar://102525236

Reviewed by Alan Baradlay.

When replaced element's compute their aspect ratio, the value is stored
inside of a double This value is computed fairly deep in the
computeIntrinsicRatioInformation call stack and then is propagated back
up to where it will be used. This has been causing some slight
issues with precision when making other changes to replaced element
sizing code that uses the aspect ratio.

To help with this, this patch changes how the aspect ratio is stored by
instead storing each dimension that corresponds with the aspect ratio
into a FloatSize. This variable is then propagated back up the same call
stack the same way and then the caller can determine how they want to
use the aspect ratio (compute into a double or use the individual
dimensions).

For this patch there is no functional change because we will store the
value in a double regardless. However, we do seem to progress on a test
(fast/replaced/width100percent-image). The new sizes match how other
browsers are sizing the image. This is likely due to the change in
RenderReplaced::computeIntrinsicRatioInformation. The old version was
computing the intrinsicRatio by dividing two floats. The new version
is storing the dimensions in FloatSize, but the aspect ratio is being
computed by casting one of the values in the operation to a double.
aspectRatioDouble was added into FloatSize to help with this.

This patch also introduces aspectRatioLogicalWidth and
aspectRatioLogicalHeight inside RenderStyle. These methods will return
the correct width/height depending on the writing mode.

* LayoutTests/platform/gtk/fast/replaced/width100percent-image-expected.txt:
* LayoutTests/platform/ios/fast/replaced/width100percent-image-expected.txt:
* LayoutTests/platform/mac/fast/replaced/width100percent-image-expected.txt:
* Source/WebCore/platform/graphics/FloatSize.h:
(WebCore::FloatSize::aspectRatioDouble const):
* Source/WebCore/rendering/RenderBox.h:
(WebCore::RenderBox::computeIntrinsicRatioInformation const):
* Source/WebCore/rendering/RenderImage.cpp:
(WebCore::RenderImage::computeIntrinsicRatioInformation const):
* Source/WebCore/rendering/RenderImage.h:
* Source/WebCore/rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::computeAspectRatioInformationForRenderBox const):
(WebCore::RenderReplaced::computeIntrinsicAspectRatio const):
(WebCore::RenderReplaced::computeIntrinsicRatioInformation const):
(WebCore::RenderReplaced::computeReplacedLogicalWidth const):
(WebCore::resolveHeightForRatio):
(WebCore::RenderReplaced::computeReplacedLogicalHeight const):
* Source/WebCore/rendering/RenderReplaced.h:
* Source/WebCore/rendering/style/RenderStyle.h:
(WebCore::RenderStyle::aspectRatioLogicalWidth const):
(WebCore::RenderStyle::aspectRatioLogicalHeight const):
* Source/WebCore/rendering/svg/LegacyRenderSVGRoot.cpp:
(WebCore::LegacyRenderSVGRoot::computeIntrinsicRatioInformation const):
* Source/WebCore/rendering/svg/LegacyRenderSVGRoot.h:
* Source/WebCore/rendering/svg/RenderSVGRoot.cpp:
(WebCore::RenderSVGRoot::computeIntrinsicRatioInformation const):
* Source/WebCore/rendering/svg/RenderSVGRoot.h:

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




More information about the webkit-changes mailing list