Commit 61391b0f authored by Fredrik Söderquist's avatar Fredrik Söderquist Committed by Commit Bot

Perform a cycle check on the <use> target up front

Rather than deferring the check until ExpandUseElementsInShadowTree
(which will fail if the initial target is an ancestor of the <use>),
just check for cycles directly in BuildShadowAndInstanceTree(), and
don't build the initial shadow tree if the cycle check fails.
Stop cleaning up the partial tree after ExpandUseElementsInShadowTree(),
and adjust HasCycleUseReferencing such that it detects cycles earlier
(not requiring a clone into the shadow tree before a cycle can be
noticed.)

Behavior-wise this means that we now don't clone a target subtree if it
will create a cycle. We will however abort cloning of nested <use> after
a cycle is detected.

Bug: 397525
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I1b2c22bacb63d788509ec7984ac35357b84a3020
Reviewed-on: https://chromium-review.googlesource.com/c/1258065
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596652}
parent a70958a4
......@@ -4,12 +4,18 @@ layer at (0,0) size 800x600
LayoutSVGRoot {svg} at (0,0) size 800x600
LayoutSVGHiddenContainer {defs} at (0,0) size 0x0
LayoutSVGContainer {g} at (90,15) size 300x270.39
LayoutSVGContainer {g} at (90,15) size 20x20
LayoutSVGContainer {g} at (90,15) size 300x45
LayoutSVGEllipse {circle} at (90,15) size 20x20 [fill={[type=SOLID] [color=#FF7F00]}] [cx=100.00] [cy=25.00] [r=10.00]
LayoutSVGContainer {use} at (0,0) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,25.00)}]
LayoutSVGContainer {g} at (370,15) size 20x20
LayoutSVGContainer {use} at (370,15) size 20x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,25.00)}]
LayoutSVGContainer {g} at (370,15) size 20x20
LayoutSVGEllipse {circle} at (370,15) size 20x20 [stroke={[type=SOLID] [color=#808080] [stroke width=2.00] [line cap=ROUND] [dash array=[4.00]]}] [fill={[type=SOLID] [color=#FFFF00]}] [cx=380.00] [cy=25.00] [r=10.00]
LayoutSVGContainer {use} at (0,0) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,25.00)}]
LayoutSVGContainer {g} at (90,15) size 300x45
LayoutSVGEllipse {circle} at (370,15) size 20x20 [fill={[type=SOLID] [color=#FFFF00]}] [cx=380.00] [cy=25.00] [r=10.00]
LayoutSVGContainer {use} at (0,0) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,25.00)}]
LayoutSVGContainer {use} at (90,15) size 20x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,25.00)}]
LayoutSVGContainer {g} at (90,15) size 20x20
LayoutSVGEllipse {circle} at (90,15) size 20x20 [stroke={[type=SOLID] [color=#808080] [stroke width=2.00] [line cap=ROUND] [dash array=[4.00]]}] [fill={[type=SOLID] [color=#FF7F00]}] [cx=100.00] [cy=25.00] [r=10.00]
LayoutSVGContainer {use} at (0,0) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,25.00)}]
LayoutSVGText {text} at (100.19,258.39) size 279.59x27 contains 1 chunk(s)
LayoutSVGInlineText {#text} at (100.19,258.39) size 279.59x27
chunk 1 (middle anchor) text run 1 at (100.20,280.00) startOffset 0 endOffset 28 width 279.60: "This text should be visible."
......
......@@ -8,6 +8,7 @@ layer at (0,0) size 800x600
text run at (0,0) width 242: "You should only see this string ONCE"
LayoutSVGContainer {use} at (0,0) size 0x0 [transform={m=((0.71,0.71)(-0.71,0.71)) t=(250.00,-35.86)}]
LayoutSVGContainer {use} at (0,0) size 0x0 [transform={m=((0.71,0.71)(-0.71,0.71)) t=(250.00,-35.86)}]
LayoutSVGContainer {use} at (0,0) size 0x0 [transform={m=((0.71,0.71)(-0.71,0.71)) t=(250.00,-35.86)}]
layer at (10,10) size 580x380 backgroundClip at (54,55) size 746x545 clip at (54,55) size 536x335
LayoutSVGForeignObject {foreignObject} at (10,10) size 580x380
LayoutBlockFlow {xhtml:div} at (0,0) size 580x20
......
......@@ -9,4 +9,7 @@ layer at (0,0) size 800x600
LayoutSVGText {text} at (10,46) size 141x18 contains 1 chunk(s)
LayoutSVGInlineText {#text} at (10,46) size 141x18
chunk 1 text run 1 at (10.00,60.00) startOffset 0 endOffset 22 width 141.00: "This should not crash."
LayoutSVGContainer {use} at (0,0) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
LayoutSVGContainer {use} at (0,0) size 60x10 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
LayoutSVGContainer {g} at (0,0) size 60x10
LayoutSVGRect {rect} at (0,0) size 60x10 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
LayoutSVGContainer {use} at (0,0) size 0x0
......@@ -9,4 +9,8 @@ layer at (0,0) size 800x600
LayoutSVGText {text} at (10,46) size 141x18 contains 1 chunk(s)
LayoutSVGInlineText {#text} at (10,46) size 141x18
chunk 1 text run 1 at (10.00,60.00) startOffset 0 endOffset 22 width 141.00: "This should not crash."
LayoutSVGContainer {use} at (0,0) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
LayoutSVGContainer {use} at (0,0) size 60x10 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
LayoutSVGContainer {g} at (0,0) size 60x10
LayoutSVGRect {rect} at (0,0) size 60x10 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {use} at (0,0) size 0x0
......@@ -3,12 +3,22 @@ layer at (0,0) size 800x600
layer at (0,0) size 800x600
LayoutSVGRoot {svg} at (0,0) size 800x600
LayoutSVGHiddenContainer {defs} at (0,0) size 60x10
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {use} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 60x10
LayoutSVGContainer {use} at (0,0) size 60x10
LayoutSVGContainer {g} at (0,0) size 60x10
LayoutSVGRect {rect} at (0,0) size 60x10 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
LayoutSVGContainer {use} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 60x10
LayoutSVGRect {rect} at (0,0) size 60x10 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
LayoutSVGContainer {use} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {use} at (0,0) size 0x0
LayoutSVGText {text} at (10,46) size 141x18 contains 1 chunk(s)
LayoutSVGInlineText {#text} at (10,46) size 141x18
chunk 1 text run 1 at (10.00,60.00) startOffset 0 endOffset 22 width 141.00: "This should not crash."
LayoutSVGContainer {use} at (0,0) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
LayoutSVGContainer {use} at (0,0) size 60x10 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
LayoutSVGContainer {g} at (0,0) size 60x10
LayoutSVGRect {rect} at (0,0) size 60x10 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {use} at (0,0) size 0x0
......@@ -4,12 +4,18 @@ layer at (0,0) size 800x600
LayoutSVGRoot {svg} at (0,0) size 800x600
LayoutSVGHiddenContainer {defs} at (0,0) size 0x0
LayoutSVGContainer {g} at (90,15) size 300x270.39
LayoutSVGContainer {g} at (90,15) size 20x20
LayoutSVGContainer {g} at (90,15) size 300x45
LayoutSVGEllipse {circle} at (90,15) size 20x20 [fill={[type=SOLID] [color=#FF7F00]}] [cx=100.00] [cy=25.00] [r=10.00]
LayoutSVGContainer {use} at (0,0) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,25.00)}]
LayoutSVGContainer {g} at (370,15) size 20x20
LayoutSVGContainer {use} at (370,15) size 20x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,25.00)}]
LayoutSVGContainer {g} at (370,15) size 20x20
LayoutSVGEllipse {circle} at (370,15) size 20x20 [stroke={[type=SOLID] [color=#808080] [stroke width=2.00] [line cap=ROUND] [dash array=[4.00]]}] [fill={[type=SOLID] [color=#FFFF00]}] [cx=380.00] [cy=25.00] [r=10.00]
LayoutSVGContainer {use} at (0,0) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,25.00)}]
LayoutSVGContainer {g} at (90,15) size 300x45
LayoutSVGEllipse {circle} at (370,15) size 20x20 [fill={[type=SOLID] [color=#FFFF00]}] [cx=380.00] [cy=25.00] [r=10.00]
LayoutSVGContainer {use} at (0,0) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,25.00)}]
LayoutSVGContainer {use} at (90,15) size 20x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,25.00)}]
LayoutSVGContainer {g} at (90,15) size 20x20
LayoutSVGEllipse {circle} at (90,15) size 20x20 [stroke={[type=SOLID] [color=#808080] [stroke width=2.00] [line cap=ROUND] [dash array=[4.00]]}] [fill={[type=SOLID] [color=#FF7F00]}] [cx=100.00] [cy=25.00] [r=10.00]
LayoutSVGContainer {use} at (0,0) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,25.00)}]
LayoutSVGText {text} at (99.25,257.80) size 281.47x27.59 contains 1 chunk(s)
LayoutSVGInlineText {#text} at (99.25,257.80) size 281.47x27.59
chunk 1 (middle anchor) text run 1 at (99.26,280.00) startOffset 0 endOffset 28 width 281.47: "This text should be visible."
......
......@@ -8,6 +8,7 @@ layer at (0,0) size 800x600
text run at (0,0) width 245: "You should only see this string ONCE"
LayoutSVGContainer {use} at (0,0) size 0x0 [transform={m=((0.71,0.71)(-0.71,0.71)) t=(250.00,-35.86)}]
LayoutSVGContainer {use} at (0,0) size 0x0 [transform={m=((0.71,0.71)(-0.71,0.71)) t=(250.00,-35.86)}]
LayoutSVGContainer {use} at (0,0) size 0x0 [transform={m=((0.71,0.71)(-0.71,0.71)) t=(250.00,-35.86)}]
layer at (10,10) size 580x380 backgroundClip at (54,55) size 746x545 clip at (54,55) size 536x335
LayoutSVGForeignObject {foreignObject} at (10,10) size 580x380
LayoutBlockFlow {xhtml:div} at (0,0) size 580x18
......
......@@ -9,4 +9,7 @@ layer at (0,0) size 800x600
LayoutSVGText {text} at (10,45.50) size 141.31x18.50 contains 1 chunk(s)
LayoutSVGInlineText {#text} at (10,45.50) size 141.31x18.50
chunk 1 text run 1 at (10.00,60.00) startOffset 0 endOffset 22 width 141.32: "This should not crash."
LayoutSVGContainer {use} at (0,0) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
LayoutSVGContainer {use} at (0,0) size 60x10 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
LayoutSVGContainer {g} at (0,0) size 60x10
LayoutSVGRect {rect} at (0,0) size 60x10 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
LayoutSVGContainer {use} at (0,0) size 0x0
......@@ -9,4 +9,8 @@ layer at (0,0) size 800x600
LayoutSVGText {text} at (10,45.50) size 141.31x18.50 contains 1 chunk(s)
LayoutSVGInlineText {#text} at (10,45.50) size 141.31x18.50
chunk 1 text run 1 at (10.00,60.00) startOffset 0 endOffset 22 width 141.32: "This should not crash."
LayoutSVGContainer {use} at (0,0) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
LayoutSVGContainer {use} at (0,0) size 60x10 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
LayoutSVGContainer {g} at (0,0) size 60x10
LayoutSVGRect {rect} at (0,0) size 60x10 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {use} at (0,0) size 0x0
......@@ -3,12 +3,22 @@ layer at (0,0) size 800x600
layer at (0,0) size 800x600
LayoutSVGRoot {svg} at (0,0) size 800x600
LayoutSVGHiddenContainer {defs} at (0,0) size 60x10
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {use} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 60x10
LayoutSVGContainer {use} at (0,0) size 60x10
LayoutSVGContainer {g} at (0,0) size 60x10
LayoutSVGRect {rect} at (0,0) size 60x10 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
LayoutSVGContainer {use} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 60x10
LayoutSVGRect {rect} at (0,0) size 60x10 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
LayoutSVGContainer {use} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {use} at (0,0) size 0x0
LayoutSVGText {text} at (10,45.50) size 141.31x18.50 contains 1 chunk(s)
LayoutSVGInlineText {#text} at (10,45.50) size 141.31x18.50
chunk 1 text run 1 at (10.00,60.00) startOffset 0 endOffset 22 width 141.32: "This should not crash."
LayoutSVGContainer {use} at (0,0) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
LayoutSVGContainer {use} at (0,0) size 60x10 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
LayoutSVGContainer {g} at (0,0) size 60x10
LayoutSVGRect {rect} at (0,0) size 60x10 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {use} at (0,0) size 0x0
......@@ -5,12 +5,36 @@ layer at (0,0) size 800x600
LayoutSVGHiddenContainer {defs} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {use} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {use} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {use} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {use} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {use} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {use} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {use} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {use} at (0,0) size 0x0
LayoutSVGText {text} at (20,40) size 429.69x230 contains 1 chunk(s)
LayoutSVGInlineText {#text} at (20,40) size 429.69x230
chunk 1 text run 1 at (20.00,220.00) startOffset 0 endOffset 4 width 429.69: "FAIL"
......
......@@ -4,12 +4,18 @@ layer at (0,0) size 800x600
LayoutSVGRoot {svg} at (0,0) size 800x600
LayoutSVGHiddenContainer {defs} at (0,0) size 0x0
LayoutSVGContainer {g} at (90,15) size 300x270.39
LayoutSVGContainer {g} at (90,15) size 20x20
LayoutSVGContainer {g} at (90,15) size 300x45
LayoutSVGEllipse {circle} at (90,15) size 20x20 [fill={[type=SOLID] [color=#FF7F00]}] [cx=100.00] [cy=25.00] [r=10.00]
LayoutSVGContainer {use} at (0,0) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,25.00)}]
LayoutSVGContainer {g} at (370,15) size 20x20
LayoutSVGContainer {use} at (370,15) size 20x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,25.00)}]
LayoutSVGContainer {g} at (370,15) size 20x20
LayoutSVGEllipse {circle} at (370,15) size 20x20 [stroke={[type=SOLID] [color=#808080] [stroke width=2.00] [line cap=ROUND] [dash array=[4.00]]}] [fill={[type=SOLID] [color=#FFFF00]}] [cx=380.00] [cy=25.00] [r=10.00]
LayoutSVGContainer {use} at (0,0) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,25.00)}]
LayoutSVGContainer {g} at (90,15) size 300x45
LayoutSVGEllipse {circle} at (370,15) size 20x20 [fill={[type=SOLID] [color=#FFFF00]}] [cx=380.00] [cy=25.00] [r=10.00]
LayoutSVGContainer {use} at (0,0) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,25.00)}]
LayoutSVGContainer {use} at (90,15) size 20x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,25.00)}]
LayoutSVGContainer {g} at (90,15) size 20x20
LayoutSVGEllipse {circle} at (90,15) size 20x20 [stroke={[type=SOLID] [color=#808080] [stroke width=2.00] [line cap=ROUND] [dash array=[4.00]]}] [fill={[type=SOLID] [color=#FF7F00]}] [cx=100.00] [cy=25.00] [r=10.00]
LayoutSVGContainer {use} at (0,0) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,25.00)}]
LayoutSVGText {text} at (104.39,258.39) size 271.19x27 contains 1 chunk(s)
LayoutSVGInlineText {#text} at (104.39,258.39) size 271.19x27
chunk 1 (middle anchor) text run 1 at (104.40,280.00) startOffset 0 endOffset 28 width 271.20: "This text should be visible."
......
......@@ -8,6 +8,7 @@ layer at (0,0) size 800x600
text run at (0,0) width 228: "You should only see this string ONCE"
LayoutSVGContainer {use} at (0,0) size 0x0 [transform={m=((0.71,0.71)(-0.71,0.71)) t=(250.00,-35.86)}]
LayoutSVGContainer {use} at (0,0) size 0x0 [transform={m=((0.71,0.71)(-0.71,0.71)) t=(250.00,-35.86)}]
LayoutSVGContainer {use} at (0,0) size 0x0 [transform={m=((0.71,0.71)(-0.71,0.71)) t=(250.00,-35.86)}]
layer at (10,10) size 580x380 backgroundClip at (54,55) size 746x545 clip at (54,55) size 536x335
LayoutSVGForeignObject {foreignObject} at (10,10) size 580x380
LayoutBlockFlow {xhtml:div} at (0,0) size 580x20
......
......@@ -9,4 +9,7 @@ layer at (0,0) size 800x600
LayoutSVGText {text} at (10,46) size 136.50x18 contains 1 chunk(s)
LayoutSVGInlineText {#text} at (10,46) size 136.50x18
chunk 1 text run 1 at (10.00,60.00) startOffset 0 endOffset 22 width 136.50: "This should not crash."
LayoutSVGContainer {use} at (0,0) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
LayoutSVGContainer {use} at (0,0) size 60x10 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
LayoutSVGContainer {g} at (0,0) size 60x10
LayoutSVGRect {rect} at (0,0) size 60x10 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
LayoutSVGContainer {use} at (0,0) size 0x0
......@@ -9,4 +9,8 @@ layer at (0,0) size 800x600
LayoutSVGText {text} at (10,46) size 136.50x18 contains 1 chunk(s)
LayoutSVGInlineText {#text} at (10,46) size 136.50x18
chunk 1 text run 1 at (10.00,60.00) startOffset 0 endOffset 22 width 136.50: "This should not crash."
LayoutSVGContainer {use} at (0,0) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
LayoutSVGContainer {use} at (0,0) size 60x10 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
LayoutSVGContainer {g} at (0,0) size 60x10
LayoutSVGRect {rect} at (0,0) size 60x10 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {use} at (0,0) size 0x0
......@@ -3,12 +3,22 @@ layer at (0,0) size 800x600
layer at (0,0) size 800x600
LayoutSVGRoot {svg} at (0,0) size 800x600
LayoutSVGHiddenContainer {defs} at (0,0) size 60x10
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {use} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 60x10
LayoutSVGContainer {use} at (0,0) size 60x10
LayoutSVGContainer {g} at (0,0) size 60x10
LayoutSVGRect {rect} at (0,0) size 60x10 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
LayoutSVGContainer {use} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 60x10
LayoutSVGRect {rect} at (0,0) size 60x10 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
LayoutSVGContainer {use} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {use} at (0,0) size 0x0
LayoutSVGText {text} at (10,46) size 136.50x18 contains 1 chunk(s)
LayoutSVGInlineText {#text} at (10,46) size 136.50x18
chunk 1 text run 1 at (10.00,60.00) startOffset 0 endOffset 22 width 136.50: "This should not crash."
LayoutSVGContainer {use} at (0,0) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
LayoutSVGContainer {use} at (0,0) size 60x10 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
LayoutSVGContainer {g} at (0,0) size 60x10
LayoutSVGRect {rect} at (0,0) size 60x10 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {use} at (0,0) size 0x0
......@@ -5,12 +5,36 @@ layer at (0,0) size 800x600
LayoutSVGHiddenContainer {defs} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {use} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {use} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {use} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {use} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {use} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {use} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {use} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {g} at (0,0) size 0x0
LayoutSVGContainer {use} at (0,0) size 0x0
LayoutSVGText {text} at (20,40) size 429x225 contains 1 chunk(s)
LayoutSVGInlineText {#text} at (20,40) size 429x225
chunk 1 text run 1 at (20.00,220.00) startOffset 0 endOffset 4 width 429.00: "FAIL"
......
<!DOCTYPE html>
<div style="width: 100px; height: 100px; background-color: black"></div>
<!DOCTYPE html>
<svg>
<image xlink:href="../../images/resources/green-10.png" x="100"/>
<rect width="100" height="100"/>
</svg>
<!DOCTYPE html>
<svg id="second">
<g id="first">
<image xlink:href="../../images/resources/green-10.png" onload="foo()"></image>
<use xlink:href="#second" x="100" fill="red"/>
</g>
<use xlink:href="#first" x="100" fill="red"/>
<rect width="100" height="100"/>
</svg>
<!DOCTYPE html>
<svg id="root">
<image xlink:href="../../images/resources/green-10.png" onload="foo()"/>
<use xlink:href="#root" x="100" fill="red"/>
<rect width="100" height="100"/>
</svg>
......@@ -439,7 +439,7 @@ void SVGUseElement::BuildShadowAndInstanceTree(SVGElement& target) {
DCHECK(!InUseShadowTree());
// Do not allow self-referencing.
if (&target == this || IsDisallowedElement(target))
if (IsDisallowedElement(target) || HasCycleUseReferencing(*this, target))
return;
// Set up root SVG element in shadow tree.
......@@ -464,11 +464,7 @@ void SVGUseElement::BuildShadowAndInstanceTree(SVGElement& target) {
// Expand all <use> elements in the shadow tree.
// Expand means: replace the actual <use> element by what it references.
if (!ExpandUseElementsInShadowTree()) {
shadow_root.RemoveChildren(kOmitSubtreeModifiedEvent);
ClearResourceReference();
return;
}
ExpandUseElementsInShadowTree();
// If the instance root was a <use>, it could have been replaced now, so
// reset |m_targetElementInstance|.
......@@ -565,14 +561,13 @@ bool SVGUseElement::HasCycleUseReferencing(const ContainerNode& target_instance,
return true;
AtomicString target_id = target.GetIdAttribute();
ContainerNode* instance = target_instance.parentNode();
ContainerNode* instance = target_instance.ParentOrShadowHostElement();
while (instance && instance->IsSVGElement()) {
SVGElement* element = ToSVGElement(instance);
if (element->HasID() && element->GetIdAttribute() == target_id &&
element->GetDocument() == target.GetDocument())
return true;
instance = instance->parentNode();
instance = instance->ParentOrShadowHostElement();
}
return false;
}
......@@ -590,7 +585,7 @@ static void RemoveAttributesFromReplacementElement(
replacement_element.removeAttribute(XLinkNames::hrefAttr);
}
bool SVGUseElement::ExpandUseElementsInShadowTree() {
void SVGUseElement::ExpandUseElementsInShadowTree() {
// Why expand the <use> elements in the shadow tree here, and not just
// do this directly in buildShadowTree, if we encounter a <use> element?
//
......@@ -608,7 +603,7 @@ bool SVGUseElement::ExpandUseElementsInShadowTree() {
ToSVGElementOrNull(original_use.ResolveTargetElement(kDontAddObserver));
if (target) {
if (IsDisallowedElement(*target) || HasCycleUseReferencing(*use, *target))
return false;
return;
}
// Don't DCHECK(target) here, it may be "pending", too.
......@@ -633,7 +628,6 @@ bool SVGUseElement::ExpandUseElementsInShadowTree() {
use = Traversal<SVGUseElement>::Next(*replacing_element, &shadow_root);
}
return true;
}
void SVGUseElement::InvalidateShadowTree() {
......
......@@ -107,7 +107,7 @@ class SVGUseElement final : public SVGGraphicsElement,
void ClearResourceReference();
bool HasCycleUseReferencing(const ContainerNode& target_instance,
const SVGElement& new_target) const;
bool ExpandUseElementsInShadowTree();
void ExpandUseElementsInShadowTree();
void CloneNonMarkupEventListeners();
void AddReferencesToFirstDegreeNestedUseElements(SVGElement& target);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment