diff options
-rw-r--r-- | src/css/layout.nim | 4 | ||||
-rw-r--r-- | test/layout/float-child-percentage-width-ignored.color.expected | 2 | ||||
-rw-r--r-- | test/layout/float-child-percentage-width-ignored.html | 4 |
3 files changed, 8 insertions, 2 deletions
diff --git a/src/css/layout.nim b/src/css/layout.nim index a833126c..c737f9f8 100644 --- a/src/css/layout.nim +++ b/src/css/layout.nim @@ -144,7 +144,7 @@ func px(l: CSSLength; lctx: LayoutContext; p: LayoutUnit = 0): return px(l, lctx.attrs, p) func canpx(l: CSSLength; sc: SizeConstraint): bool = - return l.u != cuAuto and (l.u != cuPerc or sc.isDefinite()) + return l.u != cuAuto and (l.u != cuPerc or sc.t == scStretch) # Note: for margins only # For percentages, use 0 for indefinite, and containing box's size for @@ -909,7 +909,7 @@ func spx(l: CSSLength; lctx: LayoutContext; p: SizeConstraint; proc resolveContentWidth(sizes: var ResolvedSizes; widthpx: LayoutUnit; parentWidth: SizeConstraint; computed: CSSValues; isauto = false) = - if not sizes.space.w.isDefinite() or not parentWidth.isDefinite(): + if not sizes.space.w.isDefinite() or parentWidth.t != scStretch: # width is indefinite, so no conflicts can be resolved here. return let total = widthpx + sizes.margin[dtHorizontal].sum() + diff --git a/test/layout/float-child-percentage-width-ignored.color.expected b/test/layout/float-child-percentage-width-ignored.color.expected new file mode 100644 index 00000000..5d875773 --- /dev/null +++ b/test/layout/float-child-percentage-width-ignored.color.expected @@ -0,0 +1,2 @@ +[48;2;255;0;0mtest[49m + diff --git a/test/layout/float-child-percentage-width-ignored.html b/test/layout/float-child-percentage-width-ignored.html new file mode 100644 index 00000000..02236838 --- /dev/null +++ b/test/layout/float-child-percentage-width-ignored.html @@ -0,0 +1,4 @@ +<!DOCTYPE html> +<div style="float: left; background: purple"> +<div style="width: 4ch; background: red"> +test |