Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assertion in WebCore::calculateAdjustedInnerBorder() #6138

Conversation

vitorroriz
Copy link
Contributor

@vitorroriz vitorroriz commented Nov 4, 2022

bdb44a7

Assertion in WebCore::calculateAdjustedInnerBorder()
https://bugs.webkit.org/show_bug.cgi?id=247569
rdar://99885016

Reviewed by Antti Koivisto.

The adjusting function calculateAdjustedInnerBorder assumes it will be called only when:

[1]: the radii of one of the vertex of the edge we are painting is zero.

In BorderPainter::paintBorderSides(...), when borderWillArcInnerEdge(...) evaluates to true,
a path would be used for calling paintOneBorderSide(...) which would result in calculateAdjustedInnerBorder
being called when [1] does not hold for the test added here.

borderWillArcInnerEdge return trues if one of the radius it receives isZero(), however isZero() checks
that both height and width of the radius are zero, while one of them being zero would already invalidate
rendering the border as rounded, as described by https://w3c.github.io/csswg-drafts/css-backgrounds/#border-radii

Therefore, we propose changing borderWillArcInnerEdge to use isEmpty(), that checks that the height or width of
the radius is zero.

* LayoutTests/css3/calc/inner-border-radius-longer-than-width.html: Added.
* LayoutTests/css3/calc/inner-border-radius-longer-than-width-expected.html: Added.

This test would trigger the following assertion on calculateAdjustedInnerBorder():
'ASSERT(!(newRadii.bottomLeft().width() && newRadii.bottomRight().width()));'

* Source/WebCore/rendering/style/BorderData.h:
(WebCore::BorderData::hasBorderRadius const):
* Source/WebCore/display/css/DisplayBoxDecorationPainter.cpp:
(WebCore::Display::BorderPainter::borderWillArcInnerEdge):
* Source/WebCore/rendering/BorderPainter.cpp:
(WebCore::borderWillArcInnerEdge):

borderWillArchInnerEdge() and hasBorderRadius() uses now isEmpty() instead of isZero(), since isEmpty()
checks if either the height or width of the radius is zero.

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

f3ae352

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe   πŸ›  πŸ§ͺ win
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim βœ… πŸ›  mac-debug βœ… πŸ›  gtk βœ… πŸ›  wincairo
βœ… πŸ§ͺ webkitperl   πŸ§ͺ ios-wk2 βœ… πŸ›  mac-AS-debug   πŸ§ͺ gtk-wk2
  πŸ§ͺ api-ios βœ… πŸ§ͺ api-mac βœ… πŸ§ͺ api-gtk
βœ… πŸ›  tv   πŸ§ͺ mac-wk1
βœ… πŸ›  tv-sim βœ… πŸ§ͺ mac-wk2
βœ… πŸ›  πŸ§ͺ merge βœ… πŸ›  watch   πŸ§ͺ mac-AS-debug-wk2
βœ… πŸ›  watch-sim βœ… πŸ§ͺ mac-wk2-stress

@vitorroriz vitorroriz self-assigned this Nov 4, 2022
@vitorroriz vitorroriz marked this pull request as draft November 4, 2022 17:22
@vitorroriz vitorroriz force-pushed the eng/assertion-in-calculateAdjustedInnerBorder branch from 1406ffa to e984cbc Compare November 7, 2022 13:46
@vitorroriz vitorroriz added CSS Cascading Style Sheets implementation Safari 15 labels Nov 7, 2022
@vitorroriz vitorroriz marked this pull request as ready for review November 7, 2022 13:50
Comment on lines 1 to 6
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x584
RenderBlock {DIV} at (0,0) size 300x243 [bgcolor=#B8860B] [border: none (100px solid #FF0000) (43px solid #000000) none]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't create new render tree dump based tests, they are annoying to maintain as they are very sensitive to unrelated changes.

Instead this should likely be a reftest where you add an -expected.html file that the test result gets pixel-compared against. For non-visual things a text based test (testRunner.dumpAsText()) can be used.

@vitorroriz vitorroriz force-pushed the eng/assertion-in-calculateAdjustedInnerBorder branch from e984cbc to e0711e8 Compare November 7, 2022 20:00
Comment on lines 1 to 18
<html>
<head>
<link rel="help" href="https://developer.mozilla.org/en-US/docs/Web/CSS/border-top-right-radius">
<style>
.class4 {
/* bug happens when width < border-bottom-left-radius + border-bottom-right-radius (horizontal) with vertical axis of the elipse values set to 0 */
border-bottom: solid;
width: 200px;
height: 200px;
background-color: darkgoldenrod;
border-right: 100px solid red;
border-bottom-width: 43px;
}
</style>
</head>
<body>
<div class="class4"></div>
</body>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to add -ref.html except for WPT tests.

@vitorroriz vitorroriz force-pushed the eng/assertion-in-calculateAdjustedInnerBorder branch from e0711e8 to f3ae352 Compare November 8, 2022 12:47
@anttijk anttijk added the merge-queue Applied to send a pull request to merge-queue label Nov 8, 2022
https://bugs.webkit.org/show_bug.cgi?id=247569
rdar://99885016

Reviewed by Antti Koivisto.

The adjusting function calculateAdjustedInnerBorder assumes it will be called only when:

[1]: the radii of one of the vertex of the edge we are painting is zero.

In BorderPainter::paintBorderSides(...), when borderWillArcInnerEdge(...) evaluates to true,
a path would be used for calling paintOneBorderSide(...) which would result in calculateAdjustedInnerBorder
being called when [1] does not hold for the test added here.

borderWillArcInnerEdge return trues if one of the radius it receives isZero(), however isZero() checks
that both height and width of the radius are zero, while one of them being zero would already invalidate
rendering the border as rounded, as described by https://w3c.github.io/csswg-drafts/css-backgrounds/#border-radii

Therefore, we propose changing borderWillArcInnerEdge to use isEmpty(), that checks that the height or width of
the radius is zero.

* LayoutTests/css3/calc/inner-border-radius-longer-than-width.html: Added.
* LayoutTests/css3/calc/inner-border-radius-longer-than-width-expected.html: Added.

This test would trigger the following assertion on calculateAdjustedInnerBorder():
'ASSERT(!(newRadii.bottomLeft().width() && newRadii.bottomRight().width()));'

* Source/WebCore/rendering/style/BorderData.h:
(WebCore::BorderData::hasBorderRadius const):
* Source/WebCore/display/css/DisplayBoxDecorationPainter.cpp:
(WebCore::Display::BorderPainter::borderWillArcInnerEdge):
* Source/WebCore/rendering/BorderPainter.cpp:
(WebCore::borderWillArcInnerEdge):

borderWillArchInnerEdge() and hasBorderRadius() uses now isEmpty() instead of isZero(), since isEmpty()
checks if either the height or width of the radius is zero.

Canonical link: https://commits.webkit.org/256445@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/assertion-in-calculateAdjustedInnerBorder branch from f3ae352 to bdb44a7 Compare November 8, 2022 13:48
@webkit-commit-queue
Copy link
Collaborator

Committed 256445@main (bdb44a7): https://commits.webkit.org/256445@main

Reviewed commits have been landed. Closing PR #6138 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit bdb44a7 into WebKit:main Nov 8, 2022
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CSS Cascading Style Sheets implementation
Projects
None yet
4 participants