WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-221671-20210216111650.patch (text/plain), 10.46 KB, created by
Rob Buis
on 2021-02-16 02:16:52 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Rob Buis
Created:
2021-02-16 02:16:52 PST
Size:
10.46 KB
patch
obsolete
>Subversion Revision: 272848 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 1ad216b3b3637d0de72990c270a3a02116aeed64..e1026526d36b99a9c6801a91e7b3ecbad06d50a2 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,18 @@ >+2021-02-16 Rob Buis <rbuis@igalia.com> >+ >+ Take into account box-sizing in replaced element intrinsic sizing >+ https://bugs.webkit.org/show_bug.cgi?id=221671 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Test: imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-033.html >+ >+ * rendering/RenderReplaced.cpp: >+ (WebCore::resolveWidthForRatio): >+ (WebCore::RenderReplaced::computeReplacedLogicalWidth const): >+ (WebCore::resolveHeightForRatio): >+ (WebCore::RenderReplaced::computeReplacedLogicalHeight const): >+ > 2021-02-15 Rob Buis <rbuis@igalia.com> > > Improve readability in RenderFlexibleBox::childIntrinsicLogicalWidth >diff --git a/Source/WebCore/rendering/RenderReplaced.cpp b/Source/WebCore/rendering/RenderReplaced.cpp >index 0cf967255aabe350d443a46938f953c2fa7507dc..b41771d17cff9dbc34c304c7cb1feaa54a1f700e 100644 >--- a/Source/WebCore/rendering/RenderReplaced.cpp >+++ b/Source/WebCore/rendering/RenderReplaced.cpp >@@ -532,6 +532,13 @@ LayoutUnit RenderReplaced::computeConstrainedLogicalWidth(ShouldComputePreferred > return computeReplacedLogicalWidthRespectingMinMaxWidth(logicalWidth, shouldComputePreferred); > } > >+static inline LayoutUnit resolveWidthForRatio(LayoutUnit borderAndPaddingLogicalHeight, LayoutUnit logicalHeight, double aspectRatio, BoxSizing boxSizing) >+{ >+ if (boxSizing == BoxSizing::BorderBox) >+ return roundToInt(round((logicalHeight + borderAndPaddingLogicalHeight) * aspectRatio)); >+ return roundToInt(round(logicalHeight * aspectRatio)); >+} >+ > LayoutUnit RenderReplaced::computeReplacedLogicalWidth(ShouldComputePreferred shouldComputePreferred) const > { > if (style().logicalWidth().isSpecified() || style().logicalWidth().isIntrinsic()) >@@ -567,7 +574,10 @@ LayoutUnit RenderReplaced::computeReplacedLogicalWidth(ShouldComputePreferred sh > if (intrinsicRatio && ((computedHeightIsAuto && !hasIntrinsicWidth && hasIntrinsicHeight) || !computedHeightIsAuto)) { > LayoutUnit estimatedUsedWidth = hasIntrinsicWidth ? LayoutUnit(constrainedSize.width()) : computeConstrainedLogicalWidth(shouldComputePreferred); > LayoutUnit logicalHeight = computeReplacedLogicalHeight(Optional<LayoutUnit>(estimatedUsedWidth)); >- return computeReplacedLogicalWidthRespectingMinMaxWidth(roundToInt(round(logicalHeight * intrinsicRatio)), shouldComputePreferred); >+ BoxSizing boxSizing = BoxSizing::ContentBox; >+ if (style().hasAspectRatio()) >+ boxSizing = style().boxSizingForAspectRatio(); >+ return computeReplacedLogicalWidthRespectingMinMaxWidth(resolveWidthForRatio(borderAndPaddingLogicalHeight(), logicalHeight, intrinsicRatio, boxSizing), shouldComputePreferred); > } > > >@@ -596,6 +606,13 @@ LayoutUnit RenderReplaced::computeReplacedLogicalWidth(ShouldComputePreferred sh > return computeReplacedLogicalWidthRespectingMinMaxWidth(intrinsicLogicalWidth(), shouldComputePreferred); > } > >+static inline LayoutUnit resolveHeightForRatio(LayoutUnit borderAndPaddingLogicalWidth, LayoutUnit logicalWidth, double aspectRatio, BoxSizing boxSizing) >+{ >+ if (boxSizing == BoxSizing::BorderBox) >+ return roundToInt(round((logicalWidth + borderAndPaddingLogicalWidth) / aspectRatio)); >+ return roundToInt(round(logicalWidth / aspectRatio)); >+} >+ > LayoutUnit RenderReplaced::computeReplacedLogicalHeight(Optional<LayoutUnit> estimatedUsedWidth) const > { > // 10.5 Content height: the 'height' property: http://www.w3.org/TR/CSS21/visudet.html#propdef-height >@@ -625,7 +642,10 @@ LayoutUnit RenderReplaced::computeReplacedLogicalHeight(Optional<LayoutUnit> est > // (used width) / (intrinsic ratio) > if (intrinsicRatio) { > LayoutUnit usedWidth = estimatedUsedWidth ? estimatedUsedWidth.value() : availableLogicalWidth(); >- return computeReplacedLogicalHeightRespectingMinMaxHeight(roundToInt(round(usedWidth / intrinsicRatio))); >+ BoxSizing boxSizing = BoxSizing::ContentBox; >+ if (style().hasAspectRatio()) >+ boxSizing = style().boxSizingForAspectRatio(); >+ return computeReplacedLogicalHeightRespectingMinMaxHeight(resolveHeightForRatio(borderAndPaddingLogicalWidth(), usedWidth, intrinsicRatio, boxSizing)); > } > > // Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic height, then that intrinsic height is the used value of 'height'. >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index f0125fdb3787ae48ecea333fbb14b199f8c12b0a..65c42d3767ab97413fe9c459d721dffec9e63fb8 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,12 @@ >+2021-02-16 Rob Buis <rbuis@igalia.com> >+ >+ Take into account box-sizing in replaced element intrinsic sizing >+ https://bugs.webkit.org/show_bug.cgi?id=221671 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * TestExpectations: >+ > 2021-02-15 Manuel Rego Casasnovas <rego@igalia.com> > > [selectors] Update WPT test suite >diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog >index 7daebf3550f628dceedd6f9f2832264d7c17af60..d690d32aacc07745488bcc0aa5e84b8b5dc2a8a9 100644 >--- a/LayoutTests/imported/w3c/ChangeLog >+++ b/LayoutTests/imported/w3c/ChangeLog >@@ -1,3 +1,13 @@ >+2021-02-16 Rob Buis <rbuis@igalia.com> >+ >+ Take into account box-sizing in replaced element intrinsic sizing >+ https://bugs.webkit.org/show_bug.cgi?id=221671 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-033-expected.xht: Added. >+ * web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-033.html: Added. >+ > 2021-02-15 Manuel Rego Casasnovas <rego@igalia.com> > > [selectors] Update WPT test suite >diff --git a/LayoutTests/TestExpectations b/LayoutTests/TestExpectations >index e015154506595b46d36bc24122fef106466d8d9f..01d364a41594ec42cd12e3b44d636d05929d619f 100644 >--- a/LayoutTests/TestExpectations >+++ b/LayoutTests/TestExpectations >@@ -4588,8 +4588,6 @@ webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/ > webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/intrinsic-size-008.html [ ImageOnlyFailure ] > webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/intrinsic-size-010.html [ ImageOnlyFailure ] > webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/intrinsic-size-011.html [ ImageOnlyFailure ] >-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-031.html [ ImageOnlyFailure ] >-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-032.html [ ImageOnlyFailure ] > webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/table-element-001.html [ ImageOnlyFailure ] > webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/contain-intrinsic-size/contain-intrinsic-size-001.html [ ImageOnlyFailure ] > webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/contain-intrinsic-size/contain-intrinsic-size-002.html [ ImageOnlyFailure ] >diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-033-expected.xht b/LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-033-expected.xht >new file mode 100644 >index 0000000000000000000000000000000000000000..05a13794482a94f6c10bd9d4c98704e63ef60331 >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-033-expected.xht >@@ -0,0 +1,19 @@ >+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> >+<html xmlns="http://www.w3.org/1999/xhtml"> >+ <head> >+ <title>CSS Reftest Reference</title> >+ <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" /> >+ <style type="text/css"><![CDATA[ >+ div >+ { >+ background-color: green; >+ height: 100px; >+ width: 100px; >+ } >+ ]]></style> >+ </head> >+ <body> >+ <p>Test passes if there is a filled green square and <strong>no red</strong>.</p> >+ <div></div> >+ </body> >+</html> >diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-033.html b/LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-033.html >new file mode 100644 >index 0000000000000000000000000000000000000000..c41e2bfb088d178550cc16d1d2f4cbb11e80a25b >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-033.html >@@ -0,0 +1,36 @@ >+<!DOCTYPE html> >+<title>CSS aspect-ratio: img inline size with box-sizing (vertical writing mode)</title> >+<link rel="author" title="Mozilla" href="https://www.mozilla.org/"> >+<link rel="help" href="https://drafts.csswg.org/css-sizing-4/#aspect-ratio"> >+<link rel="match" href="../../reference/ref-filled-green-100px-square.xht" /> >+<style> >+img { >+ writing-mode: vertical-lr; >+ border-top: 40px solid green; >+} >+</style> >+ >+<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> >+ >+<!-- >+ 1st: A green rect 60x100. >+ border-top is 60x40 and the content box is 60x60. >+ We use 'aspect-ratio: auto && <ratio>', so the aspect-ratio works with >+ content-box dimensions always. The block size of the content box is >+ (100px - 40px) = 60px, so the inline size is 60px * 1/1 = 60px. >+ (note: height here is the inline size of border-box.) >+ >+ 2nd: A green rect 20x100. >+ border-top is 20x40 and the content box is 20x60. >+ (note: height here is the inline size of content-box.) >+ >+ 3rd: A green rect 20x100. >+ border-top is 20x40 and the content box is 20x60 because we compute >+ the inline size by aspect-ratio which works with border-box and so the >+ inline size is 100px / 5 = 20px. >+ (note: height here is the inline size of border-box.) >+--> >+<img src="support/1x1-green.png" style="height: 100px; aspect-ratio: auto 1/10; box-sizing: border-box;" >+><img src="support/1x1-green.png" style="height: 60px; aspect-ratio: 1/3; box-sizing: content-box;" >+><img src="support/1x1-green.png" style="height: 100px; aspect-ratio: 1/5; box-sizing: border-box;"> >+
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 221671
:
419838
|
419854
|
420278
|
420441
|
420643
|
421212
|
421298
|
421613
|
421906
|
421932