Skip to content

Commit 13e204c

Browse files
committed
Apply overflow to replaced boxes
See: - w3c/csswg-drafts#7058 - whatwg/html#8028
1 parent 018ff6b commit 13e204c

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

weasyprint/css/html5_ua.css

+1
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,7 @@ style { display: none; }
543543
sub { font-size: smaller; line-height: normal; vertical-align: sub; }
544544
summary { display: block; /* unicode-bidi: isolate; */ }
545545
sup { font-size: smaller; line-height: normal; vertical-align: super; }
546+
img, svg { overflow: hidden; }
546547

547548
table { border-collapse: separate; border-color: gray; border-spacing: 2px; display: table; text-indent: 0; /* unicode-bidi: isolate; */ }
548549

weasyprint/css/tests_ua.css

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ h4 { bookmark-level: 4; bookmark-label: content(text) }
3434
h5 { bookmark-level: 5; bookmark-label: content(text) }
3535
h6 { bookmark-level: 6; bookmark-label: content(text) }
3636

37+
img, svg { overflow: hidden; }
38+
3739
::marker { unicode-bidi: isolate; font-variant-numeric: tabular-nums }
3840

3941
::footnote-call { content: counter(footnote) }

weasyprint/draw.py

+4-9
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def draw_stacking_context(stream, stacking_context):
113113
# Point 2
114114
if isinstance(box, (boxes.BlockBox, boxes.MarginBox,
115115
boxes.InlineBlockBox, boxes.TableCellBox,
116-
boxes.FlexContainerBox)):
116+
boxes.FlexContainerBox, boxes.ReplacedBox)):
117117
# The canvas background was removed by layout_backgrounds
118118
draw_background(stream, box.background)
119119
draw_border(stream, box)
@@ -148,14 +148,12 @@ def draw_stacking_context(stream, stacking_context):
148148
# Point 6
149149
if isinstance(box, boxes.InlineBox):
150150
draw_inline_level(stream, stacking_context.page, box)
151+
elif isinstance(box, boxes.ReplacedBox):
152+
draw_replacedbox(stream, box)
151153

152154
# Point 7
153155
for block in [box] + stacking_context.blocks_and_cells:
154-
if isinstance(block, boxes.ReplacedBox):
155-
draw_background(stream, block.background)
156-
draw_border(stream, block)
157-
draw_replacedbox(stream, block)
158-
elif block.children:
156+
if block.children:
159157
if block != box:
160158
stream.begin_marked_content(block, mcid=True)
161159
if isinstance(block.children[-1], boxes.LineBox):
@@ -983,9 +981,6 @@ def draw_replacedbox(stream, box):
983981
return
984982

985983
with stacked(stream):
986-
rounded_box_path(stream, box.rounded_content_box())
987-
stream.clip()
988-
stream.end()
989984
stream.transform(e=draw_x, f=draw_y)
990985
with stacked(stream):
991986
# TODO: Use the real intrinsic size here, not affected by

0 commit comments

Comments
 (0)