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
+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.
// 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
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]
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]
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]
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
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
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
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
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
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
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
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
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"
+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.
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))
namespace WebCore {
RenderSVGRoot::RenderSVGRoot(SVGStyledElement* node)
- : RenderBox(node)
+ : RenderReplaced(node)
, m_isLayoutSizeChanged(false)
, m_needsBoundariesOrTransformUpdate(true)
, m_needsSizeNegotiationWithHostDocument(false)
{
- setReplaced(true);
}
RenderSVGRoot::~RenderSVGRoot()
}
}
-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())
LayoutSize oldSize(width(), height());
computeLogicalWidth();
computeLogicalHeight();
+ buildLocalToBorderBoxTransform();
SVGSVGElement* svg = static_cast<SVGSVGElement*>(node());
m_isLayoutSizeChanged = needsLayout || (svg->hasRelativeLengths() && oldSize != size());
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)
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;
}
{
// 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());
shadow->adjustRectForShadow(repaintRect);
LayoutRect rect = enclosingIntRect(repaintRect);
- RenderBox::computeRectForRepaint(repaintContainer, rect, fixed);
+ RenderReplaced::computeRectForRepaint(repaintContainer, rect, fixed);
repaintRect = rect;
}
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()
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))
#if ENABLE(SVG)
#include "FloatRect.h"
-#include "RenderBox.h"
+#include "RenderReplaced.h"
#include "SVGRenderSupport.h"
class AffineTransform;
class SVGStyledElement;
-class RenderSVGRoot : public RenderBox {
+class RenderSVGRoot : public RenderReplaced {
public:
explicit RenderSVGRoot(SVGStyledElement*);
virtual ~RenderSVGRoot();
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);
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;
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;
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);
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).
}