Skip to content

Commit

Permalink
[iOS] Support rendering native <meter> in vertical writing mode
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=261593
rdar://115536615

Reviewed by Wenson Hsieh.

Adjust painting code to draw a vertical <meter> when using a vertical
writing mode. The "track" is already drawn vertically, this patch fixes the
filled area.

* LayoutTests/platform/ios/TestExpectations:
* Source/WebCore/rendering/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::paintMeter):

Canonical link: https://commits.webkit.org/268074@main
  • Loading branch information
pxlcoder committed Sep 18, 2023
1 parent 2e6a6bb commit 84c3c78
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 0 additions & 2 deletions LayoutTests/platform/ios/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -1179,8 +1179,6 @@ css3/color-filters/color-filter-caret-color.html [ Skip ]
# Not relevant for iOS.
css3/color-filters/color-filter-ignore-semantic.html [ Skip ]

webkit.org/b/261593 fast/forms/vertical-writing-mode/meter.html [ ImageOnlyFailure ]

# WebCryptoAPI features that enabled only for iOS 11/High Sierra+
crypto/subtle/rsa-pss-generate-export-key-jwk-sha1.html [ Pass ]
crypto/subtle/rsa-pss-generate-export-key-jwk-sha224.html [ Pass ]
Expand Down
16 changes: 12 additions & 4 deletions Source/WebCore/rendering/RenderThemeIOS.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2140,6 +2140,7 @@ static void paintAttachmentBorder(GraphicsContext& context, Path& borderPath)
GraphicsContextStateSaver stateSaver(context);

auto styleColorOptions = renderer.styleColorOptions();
auto isHorizontalWritingMode = renderer.style().isHorizontalWritingMode();

float cornerRadius = std::min(rect.width(), rect.height()) / 2.0f;
FloatRoundedRect roundedFillRect(rect, FloatRoundedRect::Radii(cornerRadius));
Expand All @@ -2151,10 +2152,17 @@ static void paintAttachmentBorder(GraphicsContext& context, Path& borderPath)
context.clipRoundedRect(roundedFillRect);

FloatRect fillRect(roundedFillRect.rect());
if (renderMeter.style().isLeftToRightDirection())
fillRect.move(fillRect.width() * (element->valueRatio() - 1), 0);
else
fillRect.move(fillRect.width() * (1 - element->valueRatio()), 0);

auto fillRectInlineSize = isHorizontalWritingMode ? fillRect.width() : fillRect.height();
FloatSize gaugeRegionPosition(fillRectInlineSize * (element->valueRatio() - 1), 0);

if (!isHorizontalWritingMode)
gaugeRegionPosition = gaugeRegionPosition.transposedSize();

if (!renderer.style().isLeftToRightDirection())
gaugeRegionPosition = -gaugeRegionPosition;

fillRect.move(gaugeRegionPosition);
roundedFillRect.setRect(fillRect);

switch (element->gaugeRegion()) {
Expand Down

0 comments on commit 84c3c78

Please sign in to comment.