RenderSVGRoot should inherit from RenderReplaced
authorzimmermann@webkit.org <zimmermann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Jan 2012 08:45:17 +0000 (08:45 +0000)
committerzimmermann@webkit.org <zimmermann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Jan 2012 08:45:17 +0000 (08:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=76446

Reviewed by Zoltan Herczeg.

Source/WebCore:

Let RenderSVGRoot inherit from RenderReplaced, instead of faking RenderReplaced, by inherting from RenderBox
and calling setReplaced(true) in the constructor. The outermost <svg> element is a replaced element in the
sense of CSS, and thus this is just a logical move. It fixes some issues where the <svg> root appeared
as selection leaf, covered by existing tests.

It allows us to simplify the painting, as outlines, etc. are painted by RenderReplaced now.
While I was it, speed up the local to border box computations by caching the result.

* rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::paint):
* rendering/svg/RenderSVGRoot.cpp:
(WebCore::RenderSVGRoot::RenderSVGRoot):
(WebCore::RenderSVGRoot::layout):
(WebCore::RenderSVGRoot::paintReplaced):
(WebCore::RenderSVGRoot::willBeDestroyed):
(WebCore::RenderSVGRoot::styleWillChange):
(WebCore::RenderSVGRoot::styleDidChange):
(WebCore::RenderSVGRoot::updateFromElement):
(WebCore::RenderSVGRoot::buildLocalToBorderBoxTransform):
(WebCore::RenderSVGRoot::localToParentTransform):
(WebCore::RenderSVGRoot::computeFloatRectForRepaint):
(WebCore::RenderSVGRoot::mapLocalToContainer):
(WebCore::RenderSVGRoot::nodeAtPoint):
* rendering/svg/RenderSVGRoot.h:
(WebCore::RenderSVGRoot::canHaveChildren):
(WebCore::RenderSVGRoot::canBeSelectionLeaf):
* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::setupInitialView):

LayoutTests:

Update test results after making RenderSVGRoot inherit from RenderReplaced.

* platform/chromium/test_expectations.txt:
* platform/mac/svg/custom/linking-a-03-b-all-expected.png: Text layout changed, we didn't relayout the tree when entering a new view before.
* platform/mac/svg/custom/linking-a-03-b-all-expected.txt: Ditto.
* platform/mac/svg/custom/linking-a-03-b-viewBox-expected.png: Ditto.
* platform/mac/svg/custom/linking-a-03-b-viewBox-expected.txt: Ditto.
* platform/mac/svg/custom/linking-a-03-b-viewBox-transform-expected.png: Ditto.
* platform/mac/svg/custom/linking-a-03-b-viewBox-transform-expected.txt: Ditto.
* platform/mac/svg/custom/mouse-move-on-svg-container-expected.png: Moving the circle, triggered a selection before, where it shouldn't. It's gone now.
* platform/mac/svg/custom/mouse-move-on-svg-container-expected.txt: Ditto.
* platform/mac/svg/custom/mouse-move-on-svg-container-standalone-expected.png: Ditto.
* platform/mac/svg/custom/mouse-move-on-svg-container-standalone-expected.txt: Ditto.
* platform/mac/svg/custom/mouse-move-on-svg-root-expected.png: Ditto.
* platform/mac/svg/custom/mouse-move-on-svg-root-expected.txt: Ditto.
* platform/mac/svg/custom/mouse-move-on-svg-root-standalone-expected.png: Ditto.
* platform/mac/svg/custom/mouse-move-on-svg-root-standalone-expected.txt: Ditto.
* platform/mac/svg/custom/pointer-events-image-css-transform-expected.png: Caret position which is reported changed, due the selection leaf changes.
* platform/mac/svg/custom/pointer-events-image-css-transform-expected.txt: Ditto.
* platform/mac/svg/custom/pointer-events-image-expected.png: Ditto.
* platform/mac/svg/custom/pointer-events-image-expected.txt: Ditto.
* platform/mac/svg/custom/pointer-events-text-css-transform-expected.png: Ditto.
* platform/mac/svg/custom/pointer-events-text-css-transform-expected.txt: Ditto.
* platform/mac/svg/custom/pointer-events-text-expected.png: Ditto.
* platform/mac/svg/custom/pointer-events-text-expected.txt: Ditto.
* platform/mac/svg/foreignObject/text-tref-02-b-expected.png: This now reports a valid size for the RenderSVGRoot in the <fO> subtree.
* svg/foreignObject/text-tref-02-b-expected.txt: Ditto.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105247 268f45cc-cd09-0410-ab3c-d52691b4dbfc

31 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/chromium/test_expectations.txt
LayoutTests/platform/mac/svg/custom/linking-a-03-b-all-expected.png
LayoutTests/platform/mac/svg/custom/linking-a-03-b-all-expected.txt
LayoutTests/platform/mac/svg/custom/linking-a-03-b-viewBox-expected.png
LayoutTests/platform/mac/svg/custom/linking-a-03-b-viewBox-expected.txt
LayoutTests/platform/mac/svg/custom/linking-a-03-b-viewBox-transform-expected.png
LayoutTests/platform/mac/svg/custom/linking-a-03-b-viewBox-transform-expected.txt
LayoutTests/platform/mac/svg/custom/mouse-move-on-svg-container-expected.png
LayoutTests/platform/mac/svg/custom/mouse-move-on-svg-container-expected.txt
LayoutTests/platform/mac/svg/custom/mouse-move-on-svg-container-standalone-expected.png
LayoutTests/platform/mac/svg/custom/mouse-move-on-svg-container-standalone-expected.txt
LayoutTests/platform/mac/svg/custom/mouse-move-on-svg-root-expected.png
LayoutTests/platform/mac/svg/custom/mouse-move-on-svg-root-expected.txt
LayoutTests/platform/mac/svg/custom/mouse-move-on-svg-root-standalone-expected.png
LayoutTests/platform/mac/svg/custom/mouse-move-on-svg-root-standalone-expected.txt
LayoutTests/platform/mac/svg/custom/pointer-events-image-css-transform-expected.png
LayoutTests/platform/mac/svg/custom/pointer-events-image-css-transform-expected.txt
LayoutTests/platform/mac/svg/custom/pointer-events-image-expected.png
LayoutTests/platform/mac/svg/custom/pointer-events-image-expected.txt
LayoutTests/platform/mac/svg/custom/pointer-events-text-css-transform-expected.png
LayoutTests/platform/mac/svg/custom/pointer-events-text-css-transform-expected.txt
LayoutTests/platform/mac/svg/custom/pointer-events-text-expected.png
LayoutTests/platform/mac/svg/custom/pointer-events-text-expected.txt
LayoutTests/platform/mac/svg/foreignObject/text-tref-02-b-expected.png
LayoutTests/svg/foreignObject/text-tref-02-b-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderReplaced.cpp
Source/WebCore/rendering/svg/RenderSVGRoot.cpp
Source/WebCore/rendering/svg/RenderSVGRoot.h
Source/WebCore/svg/SVGSVGElement.cpp

index 6dcb026..dc1b966 100644 (file)
@@ -1,3 +1,38 @@
+2012-01-17  Nikolas Zimmermann  <nzimmermann@rim.com>
+
+        RenderSVGRoot should inherit from RenderReplaced
+        https://bugs.webkit.org/show_bug.cgi?id=76446
+
+        Reviewed by Zoltan Herczeg.
+
+        Update test results after making RenderSVGRoot inherit from RenderReplaced.
+
+        * platform/chromium/test_expectations.txt:
+        * platform/mac/svg/custom/linking-a-03-b-all-expected.png: Text layout changed, we didn't relayout the tree when entering a new view before.
+        * platform/mac/svg/custom/linking-a-03-b-all-expected.txt: Ditto.
+        * platform/mac/svg/custom/linking-a-03-b-viewBox-expected.png: Ditto.
+        * platform/mac/svg/custom/linking-a-03-b-viewBox-expected.txt: Ditto.
+        * platform/mac/svg/custom/linking-a-03-b-viewBox-transform-expected.png: Ditto.
+        * platform/mac/svg/custom/linking-a-03-b-viewBox-transform-expected.txt: Ditto.
+        * platform/mac/svg/custom/mouse-move-on-svg-container-expected.png: Moving the circle, triggered a selection before, where it shouldn't. It's gone now.
+        * platform/mac/svg/custom/mouse-move-on-svg-container-expected.txt: Ditto.
+        * platform/mac/svg/custom/mouse-move-on-svg-container-standalone-expected.png: Ditto.
+        * platform/mac/svg/custom/mouse-move-on-svg-container-standalone-expected.txt: Ditto.
+        * platform/mac/svg/custom/mouse-move-on-svg-root-expected.png: Ditto.
+        * platform/mac/svg/custom/mouse-move-on-svg-root-expected.txt: Ditto.
+        * platform/mac/svg/custom/mouse-move-on-svg-root-standalone-expected.png: Ditto.
+        * platform/mac/svg/custom/mouse-move-on-svg-root-standalone-expected.txt: Ditto.
+        * platform/mac/svg/custom/pointer-events-image-css-transform-expected.png: Caret position which is reported changed, due the selection leaf changes.
+        * platform/mac/svg/custom/pointer-events-image-css-transform-expected.txt: Ditto.
+        * platform/mac/svg/custom/pointer-events-image-expected.png: Ditto.
+        * platform/mac/svg/custom/pointer-events-image-expected.txt: Ditto.
+        * platform/mac/svg/custom/pointer-events-text-css-transform-expected.png: Ditto.
+        * platform/mac/svg/custom/pointer-events-text-css-transform-expected.txt: Ditto.
+        * platform/mac/svg/custom/pointer-events-text-expected.png: Ditto.
+        * platform/mac/svg/custom/pointer-events-text-expected.txt: Ditto.
+        * platform/mac/svg/foreignObject/text-tref-02-b-expected.png: This now reports a valid size for the RenderSVGRoot in the <fO> subtree.
+        * svg/foreignObject/text-tref-02-b-expected.txt: Ditto.
+
 2012-01-17  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r105244.
index f087272..ac33851 100644 (file)
@@ -3878,3 +3878,24 @@ BUGWK65711 : svg/text/append-text-node-to-tspan.html = IMAGE+TEXT IMAGE
 
 // Uint8ClampedArray still not implemented.
 BUGWK74455 : fast/js/dfg-uint8clampedarray.html = TEXT
+
+// Text layout should have changed, kerning should look more natural. We previously didn't relayout
+// the text when moving to a new view target, and thus didn't update the scaledFont.
+BUGWK76446 : svg/custom/linking-a-03-b-all.svg = IMAGE+TEXT
+BUGWK76446 : svg/custom/linking-a-03-b-viewBox-transform.svg = IMAGE+TEXT
+BUGWK76446 : svg/custom/linking-a-03-b-viewBox.svg = IMAGE+TEXT
+
+// Selection should have disappeared, a side-effect of moving RenderSVGRoot to RenderReplaced (a progression!)
+BUGWK76446 : svg/custom/mouse-move-on-svg-container-standalone.svg = IMAGE+TEXT
+BUGWK76446 : svg/custom/mouse-move-on-svg-container.xhtml = IMAGE+TEXT
+BUGWK76446 : svg/custom/mouse-move-on-svg-root-standalone.svg = IMAGE+TEXT
+BUGWK76446 : svg/custom/mouse-move-on-svg-root.xhtml = IMAGE+TEXT
+
+// Caret position reported differently, should start at 0 instead of 18.
+BUGWK76446 : svg/custom/pointer-events-image-css-transform.svg = TEXT
+BUGWK76446 : svg/custom/pointer-events-image.svg = TEXT
+BUGWK76446 : svg/custom/pointer-events-text-css-transform.svg = TEXT
+BUGWK76446 : svg/custom/pointer-events-text.svg = TEXT
+
+// RenderSVGRoot now reports a correct size.
+BUGWK76646 : svg/foreignObject/text-tref-02-b.svg = TEXT
index ca3bff9..10f7e20 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/custom/linking-a-03-b-all-expected.png and b/LayoutTests/platform/mac/svg/custom/linking-a-03-b-all-expected.png differ
index be3ad61..8ea7456 100644 (file)
@@ -3,21 +3,21 @@ layer at (0,0) size 800x600
 layer at (0,0) size 480x360
   RenderSVGRoot {svg} at (0,0) size 480x360
     RenderSVGContainer {g} at (0,0) size 480x360
-      RenderSVGText {text} at (100,9) size 184x14 contains 1 chunk(s)
-        RenderSVGInlineText {#text} at (0,0) size 184x14
-          chunk 1 text run 1 at (100.00,20.00) startOffset 0 endOffset 41 width 184.00: "Some circles with ids, for linking tests."
+      RenderSVGText {text} at (100,9) size 188x14 contains 1 chunk(s)
+        RenderSVGInlineText {#text} at (0,0) size 188x14
+          chunk 1 text run 1 at (100.00,20.00) startOffset 0 endOffset 41 width 188.00: "Some circles with ids, for linking tests."
       RenderSVGPath {circle} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [cx=220.00] [cy=140.00] [r=35.00]
-      RenderSVGText {text} at (203,87) size 40x14 contains 1 chunk(s)
-        RenderSVGInlineText {#text} at (0,0) size 40x14
-          chunk 1 text run 1 at (203.00,99.00) startOffset 0 endOffset 8 width 40.00: "circle-1"
+      RenderSVGText {text} at (203,87) size 39x14 contains 1 chunk(s)
+        RenderSVGInlineText {#text} at (0,0) size 39x14
+          chunk 1 text run 1 at (203.00,99.00) startOffset 0 endOffset 8 width 38.40: "circle-1"
       RenderSVGPath {circle} at (5,84) size 239x239 [stroke={[type=SOLID] [color=#00FF00] [stroke width=4.00]}] [fill={[type=SOLID] [color=#FFFF00]}] [cx=100.00] [cy=260.00] [r=20.00]
-      RenderSVGText {text} at (80,283) size 40x14 contains 1 chunk(s)
-        RenderSVGInlineText {#text} at (0,0) size 40x14
-          chunk 1 text run 1 at (80.00,295.00) startOffset 0 endOffset 8 width 40.00: "circle-2"
+      RenderSVGText {text} at (80,283) size 39x14 contains 1 chunk(s)
+        RenderSVGInlineText {#text} at (0,0) size 39x14
+          chunk 1 text run 1 at (80.00,295.00) startOffset 0 endOffset 8 width 38.40: "circle-2"
       RenderSVGRect {rect} at (0,20) size 322x340 [stroke={[type=SOLID] [color=#000000]}] [x=64.00] [y=227.00] [width=72.00] [height=72.00]
       RenderSVGPath {circle} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#0000FF] [stroke width=10.00]}] [cx=340.00] [cy=260.00] [r=50.00]
-      RenderSVGText {text} at (320,320) size 40x14 contains 1 chunk(s)
-        RenderSVGInlineText {#text} at (0,0) size 40x14
-          chunk 1 text run 1 at (320.00,332.00) startOffset 0 endOffset 8 width 40.00: "circle-3"
+      RenderSVGText {text} at (320,320) size 39x14 contains 1 chunk(s)
+        RenderSVGInlineText {#text} at (0,0) size 39x14
+          chunk 1 text run 1 at (320.00,332.00) startOffset 0 endOffset 8 width 38.40: "circle-3"
     RenderSVGContainer {g} at (0,0) size 480x360
       RenderSVGRect {rect} at (0,0) size 480x360 [stroke={[type=SOLID] [color=#000000]}] [x=1.00] [y=1.00] [width=478.00] [height=358.00]
index 4ce10e1..706125c 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/custom/linking-a-03-b-viewBox-expected.png and b/LayoutTests/platform/mac/svg/custom/linking-a-03-b-viewBox-expected.png differ
index f52265f..1301509 100644 (file)
@@ -3,21 +3,21 @@ layer at (0,0) size 800x600
 layer at (0,0) size 480x360
   RenderSVGRoot {svg} at (0,0) size 480x360
     RenderSVGContainer {g} at (57,0) size 423x360
-      RenderSVGText {text} at (100,9) size 184x14 contains 1 chunk(s)
-        RenderSVGInlineText {#text} at (0,0) size 184x14
-          chunk 1 text run 1 at (100.00,20.00) startOffset 0 endOffset 41 width 184.00: "Some circles with ids, for linking tests."
+      RenderSVGText {text} at (100,9) size 188x14 contains 1 chunk(s)
+        RenderSVGInlineText {#text} at (0,0) size 188x14
+          chunk 1 text run 1 at (100.00,20.00) startOffset 0 endOffset 41 width 188.00: "Some circles with ids, for linking tests."
       RenderSVGPath {circle} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [cx=220.00] [cy=140.00] [r=35.00]
-      RenderSVGText {text} at (203,87) size 40x14 contains 1 chunk(s)
-        RenderSVGInlineText {#text} at (0,0) size 40x14
-          chunk 1 text run 1 at (203.00,99.00) startOffset 0 endOffset 8 width 40.00: "circle-1"
+      RenderSVGText {text} at (203,87) size 39x14 contains 1 chunk(s)
+        RenderSVGInlineText {#text} at (0,0) size 39x14
+          chunk 1 text run 1 at (203.00,99.00) startOffset 0 endOffset 8 width 38.40: "circle-1"
       RenderSVGPath {circle} at (130,55) size 220x220 [stroke={[type=SOLID] [color=#00FF00] [stroke width=4.00]}] [fill={[type=SOLID] [color=#FFFF00]}] [cx=100.00] [cy=260.00] [r=20.00]
-      RenderSVGText {text} at (80,283) size 40x14 contains 1 chunk(s)
-        RenderSVGInlineText {#text} at (0,0) size 40x14
-          chunk 1 text run 1 at (80.00,295.00) startOffset 0 endOffset 8 width 40.00: "circle-2"
+      RenderSVGText {text} at (80,283) size 39x14 contains 1 chunk(s)
+        RenderSVGInlineText {#text} at (0,0) size 39x14
+          chunk 1 text run 1 at (80.00,295.00) startOffset 0 endOffset 8 width 38.40: "circle-2"
       RenderSVGRect {rect} at (57,0) size 366x360 [stroke={[type=SOLID] [color=#000000]}] [x=64.00] [y=227.00] [width=72.00] [height=72.00]
       RenderSVGPath {circle} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#0000FF] [stroke width=10.00]}] [cx=340.00] [cy=260.00] [r=50.00]
-      RenderSVGText {text} at (320,320) size 40x14 contains 1 chunk(s)
-        RenderSVGInlineText {#text} at (0,0) size 40x14
-          chunk 1 text run 1 at (320.00,332.00) startOffset 0 endOffset 8 width 40.00: "circle-3"
+      RenderSVGText {text} at (320,320) size 39x14 contains 1 chunk(s)
+        RenderSVGInlineText {#text} at (0,0) size 39x14
+          chunk 1 text run 1 at (320.00,332.00) startOffset 0 endOffset 8 width 38.40: "circle-3"
     RenderSVGContainer {g} at (0,0) size 480x360
       RenderSVGRect {rect} at (0,0) size 480x360 [stroke={[type=SOLID] [color=#000000]}] [x=1.00] [y=1.00] [width=478.00] [height=358.00]
index ca3bff9..10f7e20 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/custom/linking-a-03-b-viewBox-transform-expected.png and b/LayoutTests/platform/mac/svg/custom/linking-a-03-b-viewBox-transform-expected.png differ
index be3ad61..8ea7456 100644 (file)
@@ -3,21 +3,21 @@ layer at (0,0) size 800x600
 layer at (0,0) size 480x360
   RenderSVGRoot {svg} at (0,0) size 480x360
     RenderSVGContainer {g} at (0,0) size 480x360
-      RenderSVGText {text} at (100,9) size 184x14 contains 1 chunk(s)
-        RenderSVGInlineText {#text} at (0,0) size 184x14
-          chunk 1 text run 1 at (100.00,20.00) startOffset 0 endOffset 41 width 184.00: "Some circles with ids, for linking tests."
+      RenderSVGText {text} at (100,9) size 188x14 contains 1 chunk(s)
+        RenderSVGInlineText {#text} at (0,0) size 188x14
+          chunk 1 text run 1 at (100.00,20.00) startOffset 0 endOffset 41 width 188.00: "Some circles with ids, for linking tests."
       RenderSVGPath {circle} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=SOLID] [color=#FF0000]}] [cx=220.00] [cy=140.00] [r=35.00]
-      RenderSVGText {text} at (203,87) size 40x14 contains 1 chunk(s)
-        RenderSVGInlineText {#text} at (0,0) size 40x14
-          chunk 1 text run 1 at (203.00,99.00) startOffset 0 endOffset 8 width 40.00: "circle-1"
+      RenderSVGText {text} at (203,87) size 39x14 contains 1 chunk(s)
+        RenderSVGInlineText {#text} at (0,0) size 39x14
+          chunk 1 text run 1 at (203.00,99.00) startOffset 0 endOffset 8 width 38.40: "circle-1"
       RenderSVGPath {circle} at (5,84) size 239x239 [stroke={[type=SOLID] [color=#00FF00] [stroke width=4.00]}] [fill={[type=SOLID] [color=#FFFF00]}] [cx=100.00] [cy=260.00] [r=20.00]
-      RenderSVGText {text} at (80,283) size 40x14 contains 1 chunk(s)
-        RenderSVGInlineText {#text} at (0,0) size 40x14
-          chunk 1 text run 1 at (80.00,295.00) startOffset 0 endOffset 8 width 40.00: "circle-2"
+      RenderSVGText {text} at (80,283) size 39x14 contains 1 chunk(s)
+        RenderSVGInlineText {#text} at (0,0) size 39x14
+          chunk 1 text run 1 at (80.00,295.00) startOffset 0 endOffset 8 width 38.40: "circle-2"
       RenderSVGRect {rect} at (0,20) size 322x340 [stroke={[type=SOLID] [color=#000000]}] [x=64.00] [y=227.00] [width=72.00] [height=72.00]
       RenderSVGPath {circle} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#0000FF] [stroke width=10.00]}] [cx=340.00] [cy=260.00] [r=50.00]
-      RenderSVGText {text} at (320,320) size 40x14 contains 1 chunk(s)
-        RenderSVGInlineText {#text} at (0,0) size 40x14
-          chunk 1 text run 1 at (320.00,332.00) startOffset 0 endOffset 8 width 40.00: "circle-3"
+      RenderSVGText {text} at (320,320) size 39x14 contains 1 chunk(s)
+        RenderSVGInlineText {#text} at (0,0) size 39x14
+          chunk 1 text run 1 at (320.00,332.00) startOffset 0 endOffset 8 width 38.40: "circle-3"
     RenderSVGContainer {g} at (0,0) size 480x360
       RenderSVGRect {rect} at (0,0) size 480x360 [stroke={[type=SOLID] [color=#000000]}] [x=1.00] [y=1.00] [width=478.00] [height=358.00]
index 18c26ce..9e85389 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/custom/mouse-move-on-svg-container-expected.png and b/LayoutTests/platform/mac/svg/custom/mouse-move-on-svg-container-expected.png differ
index 4bdf67c..47273b9 100644 (file)
@@ -11,5 +11,4 @@ layer at (0,0) size 800x410
             chunk 1 (middle anchor) text run 1 at (48.50,50.00) startOffset 0 endOffset 49 width 303.00: "The circle should stay in the bottom-right corner"
       RenderText {#text} at (0,0) size 0x0
       RenderText {#text} at (0,0) size 0x0
-selection start: position 0 of child 0 {#text} of child 3 {text} of child 1 {svg} of body
-selection end:   position 24 of child 0 {#text} of child 3 {text} of child 1 {svg} of body
+caret: position 0 of child 0 {#text} of child 3 {text} of child 1 {svg} of body
index 18c26ce..9e85389 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/custom/mouse-move-on-svg-container-standalone-expected.png and b/LayoutTests/platform/mac/svg/custom/mouse-move-on-svg-container-standalone-expected.png differ
index 5acbadf..245767b 100644 (file)
@@ -7,5 +7,4 @@ layer at (0,0) size 406x406
     RenderSVGText {text} at (48,36) size 303x18 contains 1 chunk(s)
       RenderSVGInlineText {#text} at (0,0) size 303x18
         chunk 1 (middle anchor) text run 1 at (48.50,50.00) startOffset 0 endOffset 49 width 303.00: "The circle should stay in the bottom-right corner"
-selection start: position 0 of child 0 {#text} of child 3 {text} of child 0 {svg} of document
-selection end:   position 24 of child 0 {#text} of child 3 {text} of child 0 {svg} of document
+caret: position 0 of child 0 {#text} of child 3 {text} of child 0 {svg} of document
index b0e1396..65225e6 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/custom/mouse-move-on-svg-root-expected.png and b/LayoutTests/platform/mac/svg/custom/mouse-move-on-svg-root-expected.png differ
index b19efde..e8ff39d 100644 (file)
@@ -10,5 +10,4 @@ layer at (0,0) size 800x410
             chunk 1 (middle anchor) text run 1 at (93.00,50.00) startOffset 0 endOffset 34 width 214.00: "The circle should be in the middle"
       RenderText {#text} at (0,0) size 0x0
       RenderText {#text} at (0,0) size 0x0
-selection start: position 16 of child 0 {#text} of child 3 {text} of child 1 {svg} of body
-selection end:   position 34 of child 0 {#text} of child 3 {text} of child 1 {svg} of body
+caret: position 0 of child 0 {#text} of child 3 {text} of child 1 {svg} of body
index b0e1396..65225e6 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/custom/mouse-move-on-svg-root-standalone-expected.png and b/LayoutTests/platform/mac/svg/custom/mouse-move-on-svg-root-standalone-expected.png differ
index d16e247..b757a68 100644 (file)
@@ -6,5 +6,4 @@ layer at (0,0) size 406x406
     RenderSVGText {text} at (93,36) size 214x18 contains 1 chunk(s)
       RenderSVGInlineText {#text} at (0,0) size 214x18
         chunk 1 (middle anchor) text run 1 at (93.00,50.00) startOffset 0 endOffset 34 width 214.00: "The circle should be in the middle"
-selection start: position 16 of child 0 {#text} of child 3 {text} of child 0 {svg} of document
-selection end:   position 34 of child 0 {#text} of child 3 {text} of child 0 {svg} of document
+caret: position 0 of child 0 {#text} of child 3 {text} of child 0 {svg} of document
index c17e91f..357d86b 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/custom/pointer-events-image-css-transform-expected.png and b/LayoutTests/platform/mac/svg/custom/pointer-events-image-css-transform-expected.png differ
index 1be9fce..baddfeb 100644 (file)
@@ -359,4 +359,4 @@ layer at (0,0) size 800x600
       RenderSVGText {text} at (504,549) size 28x18 contains 1 chunk(s)
         RenderSVGInlineText {#text} at (0,0) size 28x18
           chunk 1 text run 1 at (504.00,563.00) startOffset 0 endOffset 4 width 28.00: "miss"
-caret: position 18 of child 0 {#text} of child 5 {text} of child 1 {svg} of document
+caret: position 0 of child 0 {#text} of child 3 {text} of child 1 {svg} of document
index c17e91f..357d86b 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/custom/pointer-events-image-expected.png and b/LayoutTests/platform/mac/svg/custom/pointer-events-image-expected.png differ
index 866f061..777299d 100644 (file)
@@ -359,4 +359,4 @@ layer at (0,0) size 800x600
       RenderSVGText {text} at (504,549) size 28x18 contains 1 chunk(s)
         RenderSVGInlineText {#text} at (0,0) size 28x18
           chunk 1 text run 1 at (504.00,563.00) startOffset 0 endOffset 4 width 28.00: "miss"
-caret: position 18 of child 0 {#text} of child 5 {text} of child 0 {svg} of document
+caret: position 0 of child 0 {#text} of child 3 {text} of child 0 {svg} of document
index ba1d005..b310ba4 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/custom/pointer-events-text-css-transform-expected.png and b/LayoutTests/platform/mac/svg/custom/pointer-events-text-css-transform-expected.png differ
index d576e52..d4d340d 100644 (file)
@@ -519,4 +519,4 @@ layer at (0,0) size 800x600
       RenderSVGText {text} at (504,549) size 28x18 contains 1 chunk(s)
         RenderSVGInlineText {#text} at (0,0) size 28x18
           chunk 1 text run 1 at (504.00,563.00) startOffset 0 endOffset 4 width 28.00: "miss"
-caret: position 18 of child 0 {#text} of child 5 {text} of child 1 {svg} of document
+caret: position 0 of child 0 {#text} of child 3 {text} of child 1 {svg} of document
index dc4543c..fb97e7b 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/custom/pointer-events-text-expected.png and b/LayoutTests/platform/mac/svg/custom/pointer-events-text-expected.png differ
index 75ce953..9e30b67 100644 (file)
@@ -519,4 +519,4 @@ layer at (0,0) size 800x600
       RenderSVGText {text} at (504,549) size 28x18 contains 1 chunk(s)
         RenderSVGInlineText {#text} at (0,0) size 28x18
           chunk 1 text run 1 at (504.00,563.00) startOffset 0 endOffset 4 width 28.00: "miss"
-caret: position 18 of child 0 {#text} of child 5 {text} of child 0 {svg} of document
+caret: position 0 of child 0 {#text} of child 3 {text} of child 0 {svg} of document
index b2feeb1..2cc6c37 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/foreignObject/text-tref-02-b-expected.png and b/LayoutTests/platform/mac/svg/foreignObject/text-tref-02-b-expected.png differ
index 27ff864..a058094 100644 (file)
@@ -23,7 +23,7 @@ layer at (0,0) size 800x600
         RenderSVGInlineText {#text} at (0,0) size 0x0
       RenderSVGHiddenContainer {defs} at (0,0) size 0x0
         RenderSVGForeignObject {foreignObject} at (0,0) size 0x0
-          RenderSVGRoot {svg} at (0,0) size 0x0
+          RenderSVGRoot {svg} at (0,0) size 42x4
             RenderSVGText {text} at (0,-15) size 42x18 contains 1 chunk(s)
               RenderSVGInlineText {#text} at (0,0) size 42x18
                 chunk 1 text run 1 at (0.00,0.00) startOffset 0 endOffset 5 width 41.00: "Hello"
index ebc4ec9..f0c156d 100644 (file)
@@ -1,3 +1,39 @@
+2012-01-17  Nikolas Zimmermann  <nzimmermann@rim.com>
+
+        RenderSVGRoot should inherit from RenderReplaced
+        https://bugs.webkit.org/show_bug.cgi?id=76446
+
+        Reviewed by Zoltan Herczeg.
+
+        Let RenderSVGRoot inherit from RenderReplaced, instead of faking RenderReplaced, by inherting from RenderBox
+        and calling setReplaced(true) in the constructor. The outermost <svg> element is a replaced element in the
+        sense of CSS, and thus this is just a logical move. It fixes some issues where the <svg> root appeared
+        as selection leaf, covered by existing tests.
+
+        It allows us to simplify the painting, as outlines, etc. are painted by RenderReplaced now.
+        While I was it, speed up the local to border box computations by caching the result.
+
+        * rendering/RenderReplaced.cpp:
+        (WebCore::RenderReplaced::paint):
+        * rendering/svg/RenderSVGRoot.cpp:
+        (WebCore::RenderSVGRoot::RenderSVGRoot):
+        (WebCore::RenderSVGRoot::layout):
+        (WebCore::RenderSVGRoot::paintReplaced):
+        (WebCore::RenderSVGRoot::willBeDestroyed):
+        (WebCore::RenderSVGRoot::styleWillChange):
+        (WebCore::RenderSVGRoot::styleDidChange):
+        (WebCore::RenderSVGRoot::updateFromElement):
+        (WebCore::RenderSVGRoot::buildLocalToBorderBoxTransform):
+        (WebCore::RenderSVGRoot::localToParentTransform):
+        (WebCore::RenderSVGRoot::computeFloatRectForRepaint):
+        (WebCore::RenderSVGRoot::mapLocalToContainer):
+        (WebCore::RenderSVGRoot::nodeAtPoint):
+        * rendering/svg/RenderSVGRoot.h:
+        (WebCore::RenderSVGRoot::canHaveChildren):
+        (WebCore::RenderSVGRoot::canBeSelectionLeaf):
+        * svg/SVGSVGElement.cpp:
+        (WebCore::SVGSVGElement::setupInitialView):
+
 2012-01-17  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r105244.
index 017dd67..c51292a 100644 (file)
@@ -122,7 +122,7 @@ void RenderReplaced::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
     if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSelfOutline) && style()->outlineWidth())
         paintOutline(paintInfo.context, paintRect);
     
-    if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection)
+    if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection && !canHaveChildren())
         return;
     
     if (!paintInfo.shouldPaintWithinRoot(this))
index 6994654..d51617b 100644 (file)
@@ -55,12 +55,11 @@ using namespace std;
 namespace WebCore {
 
 RenderSVGRoot::RenderSVGRoot(SVGStyledElement* node)
-    : RenderBox(node)
+    : RenderReplaced(node)
     , m_isLayoutSizeChanged(false)
     , m_needsBoundariesOrTransformUpdate(true)
     , m_needsSizeNegotiationWithHostDocument(false)
 {
-    setReplaced(true);
 }
 
 RenderSVGRoot::~RenderSVGRoot()
@@ -99,25 +98,6 @@ void RenderSVGRoot::computeIntrinsicRatioInformation(FloatSize& intrinsicRatio,
     }
 }
 
-void RenderSVGRoot::computePreferredLogicalWidths()
-{
-    ASSERT(preferredLogicalWidthsDirty());
-
-    LayoutUnit borderAndPadding = borderAndPaddingWidth();
-    LayoutUnit width = computeReplacedLogicalWidth(false) + borderAndPadding;
-
-    if (style()->maxWidth().isFixed())
-        width = min(width, style()->maxWidth().value() + (style()->boxSizing() == CONTENT_BOX ? borderAndPadding : 0));
-
-    if (style()->width().isPercent() || (style()->width().isAuto() && style()->height().isPercent())) {
-        m_minPreferredLogicalWidth = 0;
-        m_maxPreferredLogicalWidth = width;
-    } else
-        m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = width;
-
-    setPreferredLogicalWidthsDirty(false);
-}
-
 bool RenderSVGRoot::isEmbeddedThroughSVGImage() const
 {
     if (!node())
@@ -245,6 +225,7 @@ void RenderSVGRoot::layout()
     LayoutSize oldSize(width(), height());
     computeLogicalWidth();
     computeLogicalHeight();
+    buildLocalToBorderBoxTransform();
 
     SVGSVGElement* svg = static_cast<SVGSVGElement*>(node());
     m_isLayoutSizeChanged = needsLayout || (svg->hasRelativeLengths() && oldSize != size());
@@ -270,44 +251,33 @@ void RenderSVGRoot::layout()
     setNeedsLayout(false);
 }
 
-bool RenderSVGRoot::selfWillPaint()
-{
-    SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(this);
-    return resources && resources->filter();
-}
-
-void RenderSVGRoot::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
+void RenderSVGRoot::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& adjustedPaintOffset)
 {
-    if (paintInfo.context->paintingDisabled())
-        return;
-
-    bool isVisible = style()->visibility() == VISIBLE;
-    LayoutPoint borderBoxOriginInContainer = paintOffset + parentOriginToBorderBox();
-
-    if (hasBoxDecorations() && (paintInfo.phase == PaintPhaseBlockBackground || paintInfo.phase == PaintPhaseChildBlockBackground) && isVisible)
-        paintBoxDecorations(paintInfo, borderBoxOriginInContainer);
-
-    if (paintInfo.phase == PaintPhaseBlockBackground)
-        return;
-
     // An empty viewport disables rendering.
     if (borderBoxRect().isEmpty())
         return;
 
-    // Don't paint if we don't have kids, except if we have filters we should paint those.
-    if (!firstChild() && !selfWillPaint())
+    // Don't paint, if the context explicitely disabled it.
+    if (paintInfo.context->paintingDisabled())
         return;
 
+    // Don't paint if we don't have kids, except if we have filters we should paint those.
+    if (!firstChild()) {
+        SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(this);
+        if (!resources || !resources->filter())
+            return;
+    }
+
     // Make a copy of the PaintInfo because applyTransform will modify the damage rect.
     PaintInfo childPaintInfo(paintInfo);
     childPaintInfo.context->save();
 
     // Apply initial viewport clip - not affected by overflow handling
-    childPaintInfo.context->clip(overflowClipRect(borderBoxOriginInContainer, paintInfo.renderRegion));
+    childPaintInfo.context->clip(overflowClipRect(adjustedPaintOffset, paintInfo.renderRegion));
 
     // Convert from container offsets (html renderers) to a relative transform (svg renderers).
     // Transform from our paint container's coordinate system to our local coords.
-    childPaintInfo.applyTransform(localToRepaintContainerTransform(paintOffset));
+    childPaintInfo.applyTransform(AffineTransform::translation(adjustedPaintOffset.x() - x(), adjustedPaintOffset.y() - y()) * localToParentTransform());
 
     bool continueRendering = true;
     if (childPaintInfo.phase == PaintPhaseForeground)
@@ -320,69 +290,55 @@ void RenderSVGRoot::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
         SVGRenderSupport::finishRenderSVGContent(this, childPaintInfo, paintInfo.context);
 
     childPaintInfo.context->restore();
-
-    if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSelfOutline) && style()->outlineWidth() && isVisible)
-        paintOutline(paintInfo.context, LayoutRect(borderBoxOriginInContainer, size()));
 }
 
 void RenderSVGRoot::willBeDestroyed()
 {
     SVGResourcesCache::clientDestroyed(this);
-    RenderBox::willBeDestroyed();
+    RenderReplaced::willBeDestroyed();
 }
 
 void RenderSVGRoot::styleWillChange(StyleDifference diff, const RenderStyle* newStyle)
 {
     if (diff == StyleDifferenceLayout)
         setNeedsBoundariesUpdate();
-    RenderBox::styleWillChange(diff, newStyle);
+    RenderReplaced::styleWillChange(diff, newStyle);
 }
 
 void RenderSVGRoot::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
 {
-    RenderBox::styleDidChange(diff, oldStyle);
+    RenderReplaced::styleDidChange(diff, oldStyle);
     SVGResourcesCache::clientStyleChanged(this, diff, style());
 }
 
 void RenderSVGRoot::updateFromElement()
 {
-    RenderBox::updateFromElement();
+    RenderReplaced::updateFromElement();
     SVGResourcesCache::clientUpdatedFromElement(this, style());
 }
 
 // RenderBox methods will expect coordinates w/o any transforms in coordinates
 // relative to our borderBox origin.  This method gives us exactly that.
-AffineTransform RenderSVGRoot::localToBorderBoxTransform() const
+void RenderSVGRoot::buildLocalToBorderBoxTransform()
 {
-    LayoutSize borderAndPadding = borderOriginToContentBox();
     SVGSVGElement* svg = static_cast<SVGSVGElement*>(node());
     float scale = style()->effectiveZoom();
     FloatPoint translate = svg->currentTranslate();
-    AffineTransform ctm(scale, 0, 0, scale, borderAndPadding.width() + translate.x(), borderAndPadding.height() + translate.y());
-    return ctm * svg->viewBoxToViewTransform(width() / scale, height() / scale);
-}
-
-LayoutSize RenderSVGRoot::parentOriginToBorderBox() const
-{
-    return locationOffset();
-}
-
-LayoutSize RenderSVGRoot::borderOriginToContentBox() const
-{
-    return LayoutSize(borderLeft() + paddingLeft(), borderTop() + paddingTop());
-}
-
-AffineTransform RenderSVGRoot::localToRepaintContainerTransform(const LayoutPoint& parentOriginInContainer) const
-{
-    return AffineTransform::translation(parentOriginInContainer.x(), parentOriginInContainer.y()) * localToParentTransform();
+    LayoutSize borderAndPadding(borderLeft() + paddingLeft(), borderTop() + paddingTop());
+    m_localToBorderBoxTransform = svg->viewBoxToViewTransform(width() / scale, height() / scale);
+    if (borderAndPadding.isEmpty() && scale == 1 && translate == FloatPoint::zero())
+        return;
+    m_localToBorderBoxTransform = AffineTransform(scale, 0, 0, scale, borderAndPadding.width() + translate.x(), borderAndPadding.height() + translate.y()) * m_localToBorderBoxTransform;
 }
 
 const AffineTransform& RenderSVGRoot::localToParentTransform() const
 {
-    LayoutSize parentToBorderBoxOffset = parentOriginToBorderBox();
-
-    m_localToParentTransform = AffineTransform::translation(parentToBorderBoxOffset.width(), parentToBorderBoxOffset.height()) * localToBorderBoxTransform();
-
+    // Slightly optimized version of m_localToParentTransform = AffineTransform::translation(x(), y()) * m_localToBorderBoxTransform;
+    m_localToParentTransform = m_localToBorderBoxTransform;
+    if (x())
+        m_localToParentTransform.setE(m_localToParentTransform.e() + x());
+    if (y())
+        m_localToParentTransform.setF(m_localToParentTransform.f() + y());
     return m_localToParentTransform;
 }
 
@@ -395,7 +351,7 @@ void RenderSVGRoot::computeFloatRectForRepaint(RenderBoxModelObject* repaintCont
 {
     // Apply our local transforms (except for x/y translation), then our shadow, 
     // and then call RenderBox's method to handle all the normal CSS Box model bits
-    repaintRect = localToBorderBoxTransform().mapRect(repaintRect);
+    repaintRect = m_localToBorderBoxTransform.mapRect(repaintRect);
 
     // Apply initial viewport clip - not affected by overflow settings    
     repaintRect.intersect(borderBoxRect());
@@ -405,7 +361,7 @@ void RenderSVGRoot::computeFloatRectForRepaint(RenderBoxModelObject* repaintCont
         shadow->adjustRectForShadow(repaintRect);
 
     LayoutRect rect = enclosingIntRect(repaintRect);
-    RenderBox::computeRectForRepaint(repaintContainer, rect, fixed);
+    RenderReplaced::computeRectForRepaint(repaintContainer, rect, fixed);
     repaintRect = rect;
 }
 
@@ -415,8 +371,8 @@ void RenderSVGRoot::mapLocalToContainer(RenderBoxModelObject* repaintContainer,
     ASSERT(useTransforms); // mapping a point through SVG w/o respecting trasnforms is useless.
 
     // Transform to our border box and let RenderBox transform the rest of the way.
-    transformState.applyTransform(localToBorderBoxTransform());
-    RenderBox::mapLocalToContainer(repaintContainer, fixed, useTransforms, transformState, wasFixed);
+    transformState.applyTransform(m_localToBorderBoxTransform);
+    RenderReplaced::mapLocalToContainer(repaintContainer, fixed, useTransforms, transformState, wasFixed);
 }
 
 void RenderSVGRoot::updateCachedBoundaries()
@@ -433,7 +389,7 @@ void RenderSVGRoot::updateCachedBoundaries()
 bool RenderSVGRoot::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction hitTestAction)
 {
     LayoutPoint pointInParent = pointInContainer - toLayoutSize(accumulatedOffset);
-    LayoutPoint pointInBorderBox = pointInParent - parentOriginToBorderBox();
+    LayoutPoint pointInBorderBox(pointInParent.x() - x(), pointInParent.y() - y());
 
     // Note: For now, we're ignoring hits to border and padding for <svg>
     if (!contentBoxRect().contains(pointInBorderBox))
index c099499..ea6580f 100644 (file)
@@ -25,7 +25,7 @@
 
 #if ENABLE(SVG)
 #include "FloatRect.h"
-#include "RenderBox.h"
+#include "RenderReplaced.h"
 
 #include "SVGRenderSupport.h"
 
@@ -34,7 +34,7 @@ namespace WebCore {
 class AffineTransform;
 class SVGStyledElement;
 
-class RenderSVGRoot : public RenderBox {
+class RenderSVGRoot : public RenderReplaced {
 public:
     explicit RenderSVGRoot(SVGStyledElement*);
     virtual ~RenderSVGRoot();
@@ -64,15 +64,15 @@ public:
 private:
     virtual RenderObjectChildList* virtualChildren() { return children(); }
     virtual const RenderObjectChildList* virtualChildren() const { return children(); }
+    virtual bool canHaveChildren() const { return true; }
 
     virtual bool isSVGRoot() const { return true; }
     virtual const char* renderName() const { return "RenderSVGRoot"; }
 
-    virtual void computePreferredLogicalWidths();
     virtual LayoutUnit computeReplacedLogicalWidth(bool includeMaxWidth = true) const;
     virtual LayoutUnit computeReplacedLogicalHeight() const;
     virtual void layout();
-    virtual void paint(PaintInfo&, const LayoutPoint&);
+    virtual void paintReplaced(PaintInfo&, const LayoutPoint&);
 
     virtual void willBeDestroyed();
     virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
@@ -94,14 +94,10 @@ private:
     virtual void computeFloatRectForRepaint(RenderBoxModelObject* repaintContainer, FloatRect& repaintRect, bool fixed) const;
 
     virtual void mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool useTransforms, bool fixed, TransformState&, bool* wasFixed = 0) const;
+    virtual bool canBeSelectionLeaf() const { return false; }
 
-    bool selfWillPaint();
     void updateCachedBoundaries();
-
-    LayoutSize parentOriginToBorderBox() const;
-    LayoutSize borderOriginToContentBox() const;
-    AffineTransform localToRepaintContainerTransform(const LayoutPoint& parentOriginInContainer) const;
-    AffineTransform localToBorderBoxTransform() const;
+    void buildLocalToBorderBoxTransform();
 
     RenderObjectChildList m_children;
     IntSize m_containerSize;
@@ -109,6 +105,7 @@ private:
     FloatRect m_strokeBoundingBox;
     FloatRect m_repaintBoundingBox;
     mutable AffineTransform m_localToParentTransform;
+    AffineTransform m_localToBorderBoxTransform;
     bool m_isLayoutSizeChanged : 1;
     bool m_needsBoundariesOrTransformUpdate : 1;
     bool m_needsSizeNegotiationWithHostDocument : 1;
index 0d26682..03554fd 100644 (file)
@@ -603,20 +603,14 @@ AffineTransform SVGSVGElement::viewBoxToViewTransform(float viewWidth, float vie
 void SVGSVGElement::setupInitialView(const String& fragmentIdentifier, Element* anchorNode)
 {
     bool hadUseCurrentView = m_useCurrentView;
-    setUseCurrentView(false);
     if (fragmentIdentifier.startsWith("xpointer(")) {
         // FIXME: XPointer references are ignored (https://bugs.webkit.org/show_bug.cgi?id=17491)
-        return;
-    }
-    if (fragmentIdentifier.startsWith("svgView(")) {
-        if (!currentView()->parseViewSpec(fragmentIdentifier))
-            return;
-        setUseCurrentView(true);
-        return;
-    }
-    if (anchorNode && anchorNode->hasTagName(SVGNames::viewTag)) {
-        SVGViewElement* viewElement = anchorNode->hasTagName(SVGNames::viewTag) ? static_cast<SVGViewElement*>(anchorNode) : 0;
-        if (viewElement) {
+        setUseCurrentView(false);
+    } else if (fragmentIdentifier.startsWith("svgView(")) {
+        if (currentView()->parseViewSpec(fragmentIdentifier))
+            setUseCurrentView(true);
+    } else if (anchorNode && anchorNode->hasTagName(SVGNames::viewTag)) {
+        if (SVGViewElement* viewElement = anchorNode->hasTagName(SVGNames::viewTag) ? static_cast<SVGViewElement*>(anchorNode) : 0) {
             SVGElement* element = SVGLocatable::nearestViewportElement(viewElement);
             if (element->hasTagName(SVGNames::svgTag)) {
                 SVGSVGElement* svg = static_cast<SVGSVGElement*>(element);
@@ -624,13 +618,18 @@ void SVGSVGElement::setupInitialView(const String& fragmentIdentifier, Element*
                 setUseCurrentView(true);
             }
         }
-        return;
     }
-    if (hadUseCurrentView) {
+
+    if (!hadUseCurrentView) {
+        if (!m_useCurrentView)
+            return;
+    } else if (!m_useCurrentView)
         currentView()->setTransform(emptyString());
-        if (RenderObject* object = renderer())
-            RenderSVGResource::markForLayoutAndParentResourceInvalidation(object);
-    }
+
+    // Force a layout, otherwise RenderSVGRoots localToBorderBoxTransform won't be rebuild.
+    if (RenderObject* object = renderer())
+        RenderSVGResource::markForLayoutAndParentResourceInvalidation(object);
+
     // FIXME: We need to decide which <svg> to focus on, and zoom to it.
     // FIXME: We need to actually "highlight" the viewTarget(s).
 }