WebKit Bugzilla
Attachment 349103 Details for
Bug 189391
: [LFC] Add support for min/max-height percentage values.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-189391-20180906192012.patch (text/plain), 12.95 KB, created by
zalan
on 2018-09-06 19:20:15 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
zalan
Created:
2018-09-06 19:20:15 PDT
Size:
12.95 KB
patch
obsolete
>Subversion Revision: 235763 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 7dbbe9c501e47bbeb796ccd06b9f50122770c0ed..5e62064dcaabb8fefb69b657ee8cfceec5a86abb 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,26 @@ >+2018-09-06 Zalan Bujtas <zalan@apple.com> >+ >+ [LFC] Add support for min/max-height percentage values. >+ https://bugs.webkit.org/show_bug.cgi?id=189391 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ The percentage is calculated with respect to the height of the generated box's containing block. >+ If the height of the containing block is not specified explicitly (i.e., it depends on content height), and this element >+ is not absolutely positioned, the percentage value is treated as '0' (for 'min-height') or 'none' (for 'max-height'). >+ >+ Test: fast/block/block-only/min-max-height-percentage.html >+ >+ * layout/FormattingContext.cpp: >+ (WebCore::Layout::FormattingContext::computeOutOfFlowVerticalGeometry const): >+ * layout/FormattingContext.h: >+ * layout/FormattingContextGeometry.cpp: >+ (WebCore::Layout::FormattingContext::Geometry::computedValueIfNotAuto): >+ (WebCore::Layout::FormattingContext::Geometry::computedMaxHeight): >+ (WebCore::Layout::FormattingContext::Geometry::computedMinHeight): >+ * layout/blockformatting/BlockFormattingContext.cpp: >+ (WebCore::Layout::BlockFormattingContext::computeHeightAndMargin const): >+ > 2018-09-06 Zalan Bujtas <zalan@apple.com> > > [LFC][BFC] Add support for min(max)-height >diff --git a/Source/WebCore/layout/FormattingContext.cpp b/Source/WebCore/layout/FormattingContext.cpp >index 8eaaf3c23de7e3265a38b05918ae700ed7d19993..86d9728815cd442edc942cace4f96facdc128a39 100644 >--- a/Source/WebCore/layout/FormattingContext.cpp >+++ b/Source/WebCore/layout/FormattingContext.cpp >@@ -86,14 +86,13 @@ void FormattingContext::computeOutOfFlowVerticalGeometry(const LayoutContext& la > }; > > auto verticalGeometry = compute({ }); >- // FIXME: Add support for percentage values where the containing block's height is explicitly specified. >- if (auto maxHeight = Geometry::fixedValue(layoutBox.style().logicalMaxHeight())) { >+ if (auto maxHeight = Geometry::computedMaxHeight(layoutContext, layoutBox)) { > auto maxVerticalGeometry = compute(maxHeight); > if (verticalGeometry.heightAndMargin.height > maxVerticalGeometry.heightAndMargin.height) > verticalGeometry = maxVerticalGeometry; > } > >- if (auto minHeight = Geometry::fixedValue(layoutBox.style().logicalMinHeight())) { >+ if (auto minHeight = Geometry::computedMinHeight(layoutContext, layoutBox)) { > auto minVerticalGeometry = compute(minHeight); > if (verticalGeometry.heightAndMargin.height < minVerticalGeometry.heightAndMargin.height) > verticalGeometry = minVerticalGeometry; >diff --git a/Source/WebCore/layout/FormattingContext.h b/Source/WebCore/layout/FormattingContext.h >index 3d7b98c5a399f89322126f02de1c573739757b2d..374f17cbf209944427942fb8229a698dd8b3e6d2 100644 >--- a/Source/WebCore/layout/FormattingContext.h >+++ b/Source/WebCore/layout/FormattingContext.h >@@ -103,6 +103,9 @@ protected: > static std::optional<LayoutUnit> computedValueIfNotAuto(const Length& geometryProperty, LayoutUnit containingBlockWidth); > static std::optional<LayoutUnit> fixedValue(const Length& geometryProperty); > >+ static std::optional<LayoutUnit> computedMinHeight(const LayoutContext&, const Box&); >+ static std::optional<LayoutUnit> computedMaxHeight(const LayoutContext&, const Box&); >+ > private: > static VerticalGeometry outOfFlowReplacedVerticalGeometry(const LayoutContext&, const Box&, std::optional<LayoutUnit> precomputedHeight = { }); > static HorizontalGeometry outOfFlowReplacedHorizontalGeometry(const LayoutContext&, const Box&, std::optional<LayoutUnit> precomputedWidth = { }); >diff --git a/Source/WebCore/layout/FormattingContextGeometry.cpp b/Source/WebCore/layout/FormattingContextGeometry.cpp >index 02e644d2bc79e76038e91ad0b978fe86d273d435..81634d03bee39126c2579e4afb2a5228f2ff474b 100644 >--- a/Source/WebCore/layout/FormattingContextGeometry.cpp >+++ b/Source/WebCore/layout/FormattingContextGeometry.cpp >@@ -82,6 +82,7 @@ std::optional<LayoutUnit> FormattingContext::Geometry::computedValueIfNotAuto(co > > if (geometryProperty.isAuto()) > return std::nullopt; >+ > return valueForLength(geometryProperty, containingBlockWidth); > } > >@@ -92,6 +93,58 @@ std::optional<LayoutUnit> FormattingContext::Geometry::fixedValue(const Length& > return { geometryProperty.value() }; > } > >+// https://www.w3.org/TR/CSS22/visudet.html#min-max-heights >+// Specifies a percentage for determining the used value. The percentage is calculated with respect to the height of the generated box's containing block. >+// If the height of the containing block is not specified explicitly (i.e., it depends on content height), and this element is not absolutely positioned, >+// the percentage value is treated as '0' (for 'min-height') or 'none' (for 'max-height'). >+std::optional<LayoutUnit> FormattingContext::Geometry::computedMaxHeight(const LayoutContext& layoutContext, const Box& layoutBox) >+{ >+ auto maxHeight = layoutBox.style().logicalMaxHeight(); >+ if (maxHeight.isUndefined() || maxHeight.isAuto()) >+ return { }; >+ >+ if (maxHeight.isFixed()) >+ return { maxHeight.value() }; >+ >+ std::optional<LayoutUnit> containingBlockHeightValue; >+ auto height = layoutBox.containingBlock()->style().logicalHeight(); >+ if (height.isFixed()) >+ containingBlockHeightValue = { height.value() }; >+ else if (layoutBox.isOutOfFlowPositioned()) { >+ // Containing block's height is already computed. >+ containingBlockHeightValue = layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock()).height(); >+ } >+ >+ if (containingBlockHeightValue) >+ return valueForLength(maxHeight, *containingBlockHeightValue); >+ >+ return { }; >+} >+ >+std::optional<LayoutUnit> FormattingContext::Geometry::computedMinHeight(const LayoutContext& layoutContext, const Box& layoutBox) >+{ >+ auto minHeight = layoutBox.style().logicalMinHeight(); >+ if (minHeight.isUndefined() || minHeight.isAuto()) >+ return { }; >+ >+ if (minHeight.isFixed()) >+ return { minHeight.value() }; >+ >+ std::optional<LayoutUnit> containingBlockHeightValue; >+ auto height = layoutBox.containingBlock()->style().logicalHeight(); >+ if (height.isFixed()) >+ containingBlockHeightValue = { height.value() }; >+ else if (layoutBox.isOutOfFlowPositioned()) { >+ // Containing block's height is already computed. >+ containingBlockHeightValue = layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock()).height(); >+ } >+ >+ if (containingBlockHeightValue) >+ return valueForLength(minHeight, *containingBlockHeightValue); >+ >+ return { 0 }; >+} >+ > static LayoutUnit staticVerticalPositionForOutOfFlowPositioned(const LayoutContext& layoutContext, const Box& layoutBox) > { > ASSERT(layoutBox.isOutOfFlowPositioned()); >diff --git a/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp b/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >index ada5b465c3adec371f30f7ee2bcee97abb8174ab..ac9d21532c8f9eb54f762c41a586a980eda42b51 100644 >--- a/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >+++ b/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >@@ -291,14 +291,13 @@ void BlockFormattingContext::computeHeightAndMargin(const LayoutContext& layoutC > }; > > auto heightAndMargin = compute({ }); >- // FIXME: Add support for percentage values where the containing block's height is explicitly specified. >- if (auto maxHeight = Geometry::fixedValue(layoutBox.style().logicalMaxHeight())) { >+ if (auto maxHeight = Geometry::computedMaxHeight(layoutContext, layoutBox)) { > auto maxHeightAndMargin = compute(maxHeight); > if (heightAndMargin.height > maxHeightAndMargin.height) > heightAndMargin = maxHeightAndMargin; > } > >- if (auto minHeight = Geometry::fixedValue(layoutBox.style().logicalMinHeight())) { >+ if (auto minHeight = Geometry::computedMinHeight(layoutContext, layoutBox)) { > auto minHeightAndMargin = compute(minHeight); > if (heightAndMargin.height < minHeightAndMargin.height) > heightAndMargin = minHeightAndMargin; >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 3c1eed479191ce174a578e5f19db59b0117564ee..d98c217485f4422cc74783f395564a4c54f15e78 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,12 @@ >+2018-09-06 Zalan Bujtas <zalan@apple.com> >+ >+ [LFC] Add support for min/max-height percentage values. >+ https://bugs.webkit.org/show_bug.cgi?id=189391 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * LayoutReloaded/misc/LFC-passing-tests.txt: >+ > 2018-09-06 Zalan Bujtas <zalan@apple.com> > > [LFC][BFC] Add support for min(max)-height >diff --git a/Tools/LayoutReloaded/misc/LFC-passing-tests.txt b/Tools/LayoutReloaded/misc/LFC-passing-tests.txt >index 3bfae6c0aaf8ea2017d937e8cb44d121db9d276c..bbe8c23b31fc6885b4be5feae6e05977a914b59f 100644 >--- a/Tools/LayoutReloaded/misc/LFC-passing-tests.txt >+++ b/Tools/LayoutReloaded/misc/LFC-passing-tests.txt >@@ -61,3 +61,4 @@ fast/block/block-only/float-min-max-width.html > fast/block/block-only/inflow-min-max-height.html > fast/block/block-only/absolute-position-min-max-height.html > fast/block/block-only/float-min-max-height.html >+fast/block/block-only/min-max-height-percentage.html >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index d0a46bebfb808627621fff6fb81f03ebfb203352..82ab8b0f7679af276fdab65285ed2a827cf500c1 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,13 @@ >+2018-09-06 Zalan Bujtas <zalan@apple.com> >+ >+ [LFC] Add support for min/max-height percentage values. >+ https://bugs.webkit.org/show_bug.cgi?id=189391 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * fast/block/block-only/min-max-height-percentage-expected.txt: Added. >+ * fast/block/block-only/min-max-height-percentage.html: Added. >+ > 2018-09-06 Zalan Bujtas <zalan@apple.com> > > [LFC][BFC] Add support for min(max)-height >diff --git a/LayoutTests/fast/block/block-only/min-max-height-percentage-expected.txt b/LayoutTests/fast/block/block-only/min-max-height-percentage-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..8cbf2ad4057898e158e16dd8215a1c8887207251 >--- /dev/null >+++ b/LayoutTests/fast/block/block-only/min-max-height-percentage-expected.txt >@@ -0,0 +1,25 @@ >+layer at (0,0) size 800x600 >+ RenderView at (0,0) size 800x600 >+layer at (0,0) size 800x586 >+ RenderBlock {HTML} at (0,0) size 800x586 >+ RenderBody {BODY} at (8,8) size 784x570 >+ RenderBlock {DIV} at (0,0) size 200x100 >+ RenderBlock {DIV} at (0,0) size 100x50 >+ RenderBlock {DIV} at (0,0) size 20x80 >+ RenderBlock {DIV} at (0,100) size 200x100 >+ RenderBlock {DIV} at (0,0) size 100x50 >+ RenderBlock {DIV} at (0,0) size 20x10 >+ RenderBlock {DIV} at (0,200) size 200x10 >+ RenderBlock {DIV} at (0,0) size 100x10 >+ RenderBlock {DIV} at (0,0) size 20x10 >+layer at (8,318) size 200x80 >+ RenderBlock (relative positioned) {DIV} at (0,310) size 200x80 >+ RenderBlock {DIV} at (0,0) size 20x80 >+layer at (8,318) size 100x40 >+ RenderBlock (positioned) {DIV} at (0,0) size 100x40 >+ RenderBlock {DIV} at (0,0) size 20x80 >+layer at (8,498) size 200x80 >+ RenderBlock (relative positioned) {DIV} at (0,490) size 200x80 >+ RenderBlock {DIV} at (0,0) size 20x80 >+layer at (8,498) size 100x40 >+ RenderBlock (positioned) {DIV} at (0,0) size 100x40 >diff --git a/LayoutTests/fast/block/block-only/min-max-height-percentage.html b/LayoutTests/fast/block/block-only/min-max-height-percentage.html >new file mode 100644 >index 0000000000000000000000000000000000000000..4e9aa6aed2c957faf902f8f2232dc9ab3b112611 >--- /dev/null >+++ b/LayoutTests/fast/block/block-only/min-max-height-percentage.html >@@ -0,0 +1,35 @@ >+<!DOCTYPE html> >+<html> >+<body> >+<div style="width: 200px; height: 100px;"> >+ <div style="width: 100px; max-height: 50%;"> >+ <div style="width: 20px; height: 80px;"></div> >+ </div> >+</div> >+ >+<div style="width: 200px; height: 100px;"> >+ <div style="width: 100px; min-height: 50%;"> >+ <div style="width: 20px; height: 10px;"></div> >+ </div> >+</div> >+ >+<div style="width: 200px; margin-bottom: 100px;"> >+ <div style="width: 100px; min-height: 50%;"> >+ <div style="width: 20px; height: 10px;"></div> >+ </div> >+</div> >+ >+<div style="position: relative; width: 200px; margin-bottom: 100px;"> >+ <div style="position: absolute; width: 100px; max-height: 50%;"> >+ <div style="width: 20px; height: 80px;"></div> >+ </div> >+ <div style="width: 20px; height: 80px;"></div> >+</div> >+ >+<div style="position: relative; width: 200px;"> >+ <div style="position: absolute; width: 100px; min-height: 50%;"></div> >+ <div style="width: 20px; height: 80px;"></div> >+</div> >+ >+</body> >+</html>
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
Flags:
koivisto
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 189391
: 349103