Changeset 87526 in webkit
- Timestamp:
- May 27, 2011 11:27:50 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 92 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r87523 r87526 1 2011-05-27 Nikolas Zimmermann <nzimmermann@rim.com> 2 3 Reviewed by Rob Buis. 4 5 embedded SVG object doesn't scale right 6 https://bugs.webkit.org/show_bug.cgi?id=10526 7 8 <object> tags should treat width/height on a referenced SVG as intrinsic width/height 9 https://bugs.webkit.org/show_bug.cgi?id=11976 10 11 Incorrect handling of percentage values for width/height on embedded elements 12 https://bugs.webkit.org/show_bug.cgi?id=14793 13 14 WebKit fails some WICD 1.0 core test cases 15 https://bugs.webkit.org/show_bug.cgi?id=15836 (partially fixed, all 'rightsizing' tests are fixed) 16 17 CSS 2.1: Support replaced elements with relative intrinsic sizes 18 https://bugs.webkit.org/show_bug.cgai?id=15849 (partially fixed) 19 20 SVG embedded as <object> doesn't respect width/height attributes 21 https://bugs.webkit.org/show_bug.cgi?id=34972 22 23 Explicit size of object tag ignored 24 https://bugs.webkit.org/show_bug.cgi?id=37086 25 26 * http/tests/misc/object-embedding-svg-delayed-size-negotiation.xhtml: Added. 27 * http/tests/misc/resources/embedded.svg: Added. 28 * http/tests/misc/resources/svg-slow.pl: Added. 29 * platform/mac/http/tests/misc/object-embedding-svg-delayed-size-negotiation-expected.png: Added. 30 * platform/mac/http/tests/misc/object-embedding-svg-delayed-size-negotiation-expected.txt: Added. 31 * platform/mac/svg/custom/object-no-size-attributes-expected.png: Added. 32 * platform/mac/svg/custom/object-no-size-attributes-expected.txt: Added. 33 * platform/mac/svg/custom/object-sizing-expected.png: Added. 34 * platform/mac/svg/custom/object-sizing-expected.txt: Added. 35 * platform/mac/svg/custom/object-sizing-explicit-height-expected.png: Added. 36 * platform/mac/svg/custom/object-sizing-explicit-height-expected.txt: Added. 37 * platform/mac/svg/custom/object-sizing-explicit-width-expected.png: Added. 38 * platform/mac/svg/custom/object-sizing-explicit-width-expected.txt: Added. 39 * platform/mac/svg/custom/object-sizing-explicit-width-height-expected.png: Added. 40 * platform/mac/svg/custom/object-sizing-explicit-width-height-expected.txt: Added. 41 * platform/mac/svg/custom/object-sizing-no-width-height-change-content-box-size-expected.png: Added. 42 * platform/mac/svg/custom/object-sizing-no-width-height-change-content-box-size-expected.txt: Added. 43 * platform/mac/svg/custom/object-sizing-no-width-height-expected.png: Added. 44 * platform/mac/svg/custom/object-sizing-no-width-height-expected.txt: Added. 45 * platform/mac/svg/hixie/text/003-expected.png: 46 * platform/mac/svg/hixie/text/003-expected.txt: 47 * platform/mac/svg/in-html/by-reference-expected.txt: 48 * platform/mac/svg/wicd: Added. 49 * platform/mac/svg/wicd/rightsizing-grid-expected.png: Added. 50 * platform/mac/svg/wicd/rightsizing-grid-expected.txt: Added. 51 * platform/mac/svg/wicd/test-rightsizing-a-expected.png: Added. 52 * platform/mac/svg/wicd/test-rightsizing-a-expected.txt: Added. 53 * platform/mac/svg/wicd/test-rightsizing-b-expected.png: Added. 54 * platform/mac/svg/wicd/test-rightsizing-b-expected.txt: Added. 55 * platform/mac/svg/zoom/page/relative-sized-document-scrollbars-expected.txt: 56 * platform/mac/svg/zoom/page/zoom-foreignObject-expected.png: 57 * platform/mac/svg/zoom/page/zoom-foreignObject-expected.txt: 58 * platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-2-expected.png: Added. 59 * platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-2-expected.txt: Added. 60 * platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-expected.png: Added. 61 * platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-expected.txt: Added. 62 * platform/mac/svg/zoom/page/zoom-svg-through-object-with-huge-size-expected.png: Added. 63 * platform/mac/svg/zoom/page/zoom-svg-through-object-with-huge-size-expected.txt: Added. 64 * platform/mac/svg/zoom/page/zoom-svg-through-object-with-no-width-height-expected.png: Added. 65 * platform/mac/svg/zoom/page/zoom-svg-through-object-with-no-width-height-expected.txt: Added. 66 * platform/mac/svg/zoom/page/zoom-svg-through-object-with-override-size-expected.png: Added. 67 * platform/mac/svg/zoom/page/zoom-svg-through-object-with-override-size-expected.txt: Added. 68 * platform/mac/svg/zoom/page/zoom-svg-through-object-with-percentage-size-expected.png: Added. 69 * platform/mac/svg/zoom/page/zoom-svg-through-object-with-percentage-size-expected.txt: Added. 70 * platform/mac/svg/zoom/page/zoom-svg-through-object-with-text-expected.png: Added. 71 * platform/mac/svg/zoom/page/zoom-svg-through-object-with-text-expected.txt: Added. 72 * svg/custom/object-no-size-attributes.xhtml: Added. 73 * svg/custom/object-sizing-explicit-height.xhtml: Added. 74 * svg/custom/object-sizing-explicit-width-height.xhtml: Added. 75 * svg/custom/object-sizing-explicit-width.xhtml: Added. 76 * svg/custom/object-sizing-no-width-height-change-content-box-size.xhtml: Added. 77 * svg/custom/object-sizing-no-width-height.xhtml: Added. 78 * svg/custom/object-sizing.xhtml: Added. 79 * svg/custom/resources/embedded.svg: Added. 80 * svg/custom/resources/red-circle.svg: Added. 81 * svg/in-html/by-reference-expected.png: 82 * svg/wicd: Added. 83 * svg/wicd/resources: Added. 84 * svg/wicd/resources/a.svg: Added. 85 * svg/wicd/resources/bcde.svg: Added. 86 * svg/wicd/resources/empty1.svg: Added. 87 * svg/wicd/resources/empty2.svg: Added. 88 * svg/wicd/resources/empty3.svg: Added. 89 * svg/wicd/resources/f.svg: Added. 90 * svg/wicd/resources/g.svg: Added. 91 * svg/wicd/resources/h.svg: Added. 92 * svg/wicd/resources/i.svg: Added. 93 * svg/wicd/resources/j.svg: Added. 94 * svg/wicd/resources/k.svg: Added. 95 * svg/wicd/resources/l.svg: Added. 96 * svg/wicd/resources/main.css: Added. 97 (body,html): 98 (body): 99 (.buttons): 100 (h1): 101 (h2): 102 (h4): 103 (p): 104 (table): 105 (th): 106 (td,th): 107 (td a): 108 (a): 109 (a:hover): 110 (a:focus): 111 (a:visited): 112 (a.index): 113 (a.index:hover): 114 (a.index:focus): 115 (a.index:visited): 116 (ul): 117 (ol): 118 (.red): 119 (.navi): 120 (.navi a): 121 (.navi a:hover): 122 (.navi a:visited): 123 * svg/wicd/resources/mnop.svg: Added. 124 * svg/wicd/resources/q.svg: Added. 125 * svg/wicd/resources/r.svg: Added. 126 * svg/wicd/resources/s.svg: Added. 127 * svg/wicd/resources/t.svg: Added. 128 * svg/wicd/resources/test-rightsizing-a.css: Added. 129 (html,body): 130 (div.all): 131 (object.w100): 132 (object.h100): 133 * svg/wicd/resources/test-rightsizing-b.css: Added. 134 (html,body): 135 (object): 136 * svg/wicd/resources/test-svg-child-object-rightsizing.gif: Added. 137 * svg/wicd/resources/test-svg-child-object-rightsizing.png: Added. 138 * svg/wicd/resources/test-svg-child-object-rightsizing.svg: Added. 139 * svg/wicd/resources/test-svg-child-object-rightsizing1.svg: Added. 140 * svg/wicd/rightsizing-grid.xhtml: Added. 141 * svg/wicd/test-rightsizing-a.xhtml: Added. 142 * svg/wicd/test-rightsizing-b.xhtml: Added. 143 * svg/zoom/page/resources: Added. 144 * svg/zoom/page/resources/absolute-sized-svg.png: Added. 145 * svg/zoom/page/resources/absolute-sized-svg.svg: Added. 146 * svg/zoom/page/resources/huge-rect.svg: Added. 147 * svg/zoom/page/resources/percentage-sized-svg.png: Added. 148 * svg/zoom/page/resources/percentage-sized-svg.svg: Added. 149 * svg/zoom/page/resources/text.svg: Added. 150 * svg/zoom/page/resources/tux.svg: Added. 151 * svg/zoom/page/zoom-svg-through-object-with-absolute-size-2.xhtml: Added. 152 * svg/zoom/page/zoom-svg-through-object-with-absolute-size.xhtml: Added. 153 * svg/zoom/page/zoom-svg-through-object-with-huge-size.xhtml: Added. 154 * svg/zoom/page/zoom-svg-through-object-with-override-size.html: Added. 155 * svg/zoom/page/zoom-svg-through-object-with-percentage-size.xhtml: Added. 156 * svg/zoom/page/zoom-svg-through-object-with-text.xhtml: Added. 157 1 158 2011-05-25 Martin Robinson <mrobinson@igalia.com> 2 159 -
trunk/LayoutTests/platform/mac/svg/hixie/text/003-expected.txt
r77485 r87526 1 1 layer at (0,0) size 800x600 2 2 RenderView at (0,0) size 800x600 3 layer at (0,0) size 800x4 024 RenderBlock {HTML} at (0,0) size 800x4 025 RenderBody {BODY} at (8,16) size 784x3 703 layer at (0,0) size 800x416 4 RenderBlock {HTML} at (0,0) size 800x416 5 RenderBody {BODY} at (8,16) size 784x384 6 6 RenderBlock {P} at (0,0) size 784x18 7 7 RenderText {#text} at (0,0) size 608x18 8 8 text run at (0,0) width 608: "The following two blocks should look identical (to the pixel), and they should both say \"PASS\":" 9 RenderBlock {P} at (0,34) size 784x16 010 RenderEmbeddedObject {OBJECT} at (0,0) size 306x156[border: (3px inset #000080)]11 layer at (0,0) size 300x15012 RenderView at (0,0) size 300x15013 layer at (0,0) size 300x15014 RenderSVGRoot {svg} at (0,0) size 180x1509 RenderBlock {P} at (0,34) size 784x167 10 RenderEmbeddedObject {OBJECT} at (0,0) size 790x163 [border: (3px inset #000080)] 11 layer at (0,0) size 784x157 12 RenderView at (0,0) size 784x157 13 layer at (0,0) size 784x157 14 RenderSVGRoot {svg} at (0,0) size 471x157 15 15 RenderSVGText {text} at (0,-1) size 3x3 contains 1 chunk(s) 16 16 RenderSVGInlineText {#text} at (0,0) size 3x3 17 chunk 1 text run 1 at (0.00,0.80) startOffset 0 endOffset 4 width 2.3 7: "PASS"18 RenderBlock {P} at (0,21 0) size 784x16019 RenderEmbeddedObject {OBJECT} at (0,0) size 306x156[border: (3px inset #000080)]20 layer at (0,0) size 300x15021 RenderView at (0,0) size 300x15022 layer at (0,0) size 300x15023 RenderSVGRoot {svg} at (0, 39) size 143x6924 RenderSVGText {text} at (0,-10 0) size 2367x1150contains 1 chunk(s)25 RenderSVGInlineText {#text} at (0,0) size 23 67x115026 chunk 1 text run 1 at (0.00,800.00) startOffset 0 endOffset 4 width 23 66.67: "PASS"17 chunk 1 text run 1 at (0.00,0.80) startOffset 0 endOffset 4 width 2.39: "PASS" 18 RenderBlock {P} at (0,217) size 784x167 19 RenderEmbeddedObject {OBJECT} at (0,0) size 790x163 [border: (3px inset #000080)] 20 layer at (0,0) size 784x157 21 RenderView at (0,0) size 784x157 22 layer at (0,0) size 784x157 23 RenderSVGRoot {svg} at (0,0) size 375x157 24 RenderSVGText {text} at (0,-105) size 2386x1156 contains 1 chunk(s) 25 RenderSVGInlineText {#text} at (0,0) size 2386x1156 26 chunk 1 text run 1 at (0.00,800.00) startOffset 0 endOffset 4 width 2385.20: "PASS" -
trunk/LayoutTests/platform/mac/svg/in-html/by-reference-expected.txt
r68198 r87526 22 22 layer at (0,0) size 100x100 23 23 RenderView at (0,0) size 100x100 24 layer at (0,0) size 50x5024 layer at (0,0) size 100x100 25 25 RenderSVGRoot {svg} at (0,0) size 0x0 26 26 RenderText {#text} at (208,86) size 4x18 -
trunk/LayoutTests/platform/mac/svg/zoom/page/relative-sized-document-scrollbars-expected.txt
r69386 r87526 1 layer at (0,0) size 135 6x10111 layer at (0,0) size 1357x1011 2 2 RenderView at (0,0) size 785x585 3 layer at (0,0) size 135 6x10113 layer at (0,0) size 1357x1011 4 4 RenderSVGRoot {svg} at (12,8) size 1333x995 5 5 RenderSVGPath {rect} at (12,8) size 1333x995 [stroke={[type=SOLID] [color=#000000]}] [x=7.85] [y=5.85] [width=769.30] [height=573.30] -
trunk/LayoutTests/platform/mac/svg/zoom/page/zoom-foreignObject-expected.txt
r75351 r87526 1 layer at (0,0) size 113 0x8421 layer at (0,0) size 1131x843 2 2 RenderView at (0,0) size 785x585 3 layer at (0,0) size 113 0x8424 RenderSVGRoot {svg} at (12,12) size 111 8x8303 layer at (0,0) size 1131x843 4 RenderSVGRoot {svg} at (12,12) size 1119x831 5 5 RenderSVGForeignObject {foreignObject} at (10,10) size 580x380 6 6 RenderBlock {xhtml:div} at (0,0) size 580x18 -
trunk/LayoutTests/svg/in-html/by-reference-expected.png
-
Property
svn:mime-type
set to
image/png
-
Property
svn:mime-type
set to
-
trunk/Source/WebCore/ChangeLog
r87524 r87526 1 2011-05-27 Nikolas Zimmermann <nzimmermann@rim.com> 2 3 Reviewed by Rob Buis. 4 5 embedded SVG object doesn't scale right 6 https://bugs.webkit.org/show_bug.cgi?id=10526 7 8 <object> tags should treat width/height on a referenced SVG as intrinsic width/height 9 https://bugs.webkit.org/show_bug.cgi?id=11976 10 11 Incorrect handling of percentage values for width/height on embedded elements 12 https://bugs.webkit.org/show_bug.cgi?id=14793 13 14 WebKit fails some WICD 1.0 core test cases 15 https://bugs.webkit.org/show_bug.cgi?id=15836 (partially fixed, all 'rightsizing' tests are fixed) 16 17 CSS 2.1: Support replaced elements with relative intrinsic sizes 18 https://bugs.webkit.org/show_bug.cgai?id=15849 (partially fixed) 19 20 SVG embedded as <object> doesn't respect width/height attributes 21 https://bugs.webkit.org/show_bug.cgi?id=34972 22 23 Explicit size of object tag ignored 24 https://bugs.webkit.org/show_bug.cgi?id=37086 25 26 Add partial support of CSS 2.1 replaced elements with intrinsic size. The feature itself is complete but has only 27 been implemented for RenderPart, to support SVG content document size negotiation. It serves as starting point for a generalization, in future. 28 The changes in RenderPart are a 1:1 transliteration of the spec (http://www.w3.org/TR/CSS21/visudet.html#inline-replaced-width/height, see code). 29 30 SVG 1.1 says: 31 The 'width' attribute on the outermost svg element establishes the viewport's width, unless the following conditions are met: 32 ... 33 and there are CSS-compatible positioning properties ([CSS2], section 9.3) specified on the referencing element (e.g., the 'object' element) 34 or on the containing document's outermost svg element that are sufficient to establish the width of the viewport. Under these conditions, 35 the positioning properties establish the viewport's width. 36 37 If an <object> carries width/height attributes, these specify the viewport size of the embedded SVG, instead of its own 38 width/height or viewBox properties. If an <object> has no width/height information, its intrinsic size needs to be calculated depending 39 on the intrinsic ratio (viewBox width divided by height ratio) and the width/height properties on the outermost referenced <svg> element. 40 This requires a negotiation between the host document and the embedded document. 41 (There are several more factors that need to be considered, the CSS spec covers this and the RenderPart::computeReplaced* code covers this.) 42 43 Fixes dozens of long-standing bug reports. The number one integration issue when using SVG through <object> is resolved: "right sizing". 44 45 Tests: http/tests/misc/object-embedding-svg-delayed-size-negotiation.xhtml 46 svg/custom/object-no-size-attributes.xhtml (bug 11976, from Eric Seidel) 47 svg/custom/object-sizing-explicit-height.xhtml (bug 10526, from Ryan Cannon) 48 svg/custom/object-sizing-explicit-width-height.xhtml 49 svg/custom/object-sizing-explicit-width.xhtml (bug 14793, from Oliver Hunt) 50 svg/custom/object-sizing-no-width-height-change-content-box-size.xhtml 51 svg/custom/object-sizing-no-width-height.xhtml 52 svg/custom/object-sizing.xhtml (bug 37086, from Jeff Schiller) 53 svg/wicd/rightsizing-grid.xhtml (bug 15836, WICD rightsizing test now works) 54 svg/wicd/test-rightsizing-a.xhtml (ditto) 55 svg/wicd/test-rightsizing-b.xhtml (ditto) 56 svg/zoom/page/zoom-svg-through-object-with-absolute-size-2.xhtml 57 svg/zoom/page/zoom-svg-through-object-with-absolute-size.xhtml 58 svg/zoom/page/zoom-svg-through-object-with-huge-size.xhtml 59 svg/zoom/page/zoom-svg-through-object-with-override-size.html (bug 34972, from Andreas Kling) 60 svg/zoom/page/zoom-svg-through-object-with-percentage-size.xhtml 61 svg/zoom/page/zoom-svg-through-object-with-text.xhtml 62 63 * platform/Length.h: 64 (WebCore::Length::isSpecified): 65 * rendering/RenderPart.cpp: 66 (WebCore::RenderPart::embeddedSVGContentRenderer): 67 (WebCore::RenderPart::computeEmbeddedDocumentReplacedWidth): 68 (WebCore::RenderPart::computeEmbeddedDocumentReplacedHeight): 69 (WebCore::RenderPart::computeReplacedLogicalWidth): 70 (WebCore::RenderPart::computeReplacedLogicalHeight): 71 (WebCore::RenderPart::layout): 72 * rendering/RenderPart.h: 73 * rendering/RenderReplaced.cpp: 74 (WebCore::RenderReplaced::computeReplacedLogicalWidth): 75 (WebCore::RenderReplaced::computeReplacedLogicalHeight): 76 * rendering/svg/RenderSVGRoot.cpp: 77 (WebCore::RenderSVGRoot::RenderSVGRoot): 78 (WebCore::RenderSVGRoot::computeIntrinsicRatio): 79 (WebCore::RenderSVGRoot::computeIntrinsicWidth): 80 (WebCore::RenderSVGRoot::computeIntrinsicHeight): 81 (WebCore::RenderSVGRoot::negotiateSizeWithHostDocumentIfNeeded): 82 (WebCore::RenderSVGRoot::computeReplacedLogicalWidth): 83 (WebCore::RenderSVGRoot::computeReplacedLogicalHeight): 84 (WebCore::RenderSVGRoot::layout): 85 * rendering/svg/RenderSVGRoot.h: 86 * svg/SVGLength.cpp: 87 (WebCore::SVGLength::determineViewport): 88 * svg/SVGSVGElement.cpp: 89 (WebCore::SVGSVGElement::currentScale): 90 (WebCore::SVGSVGElement::setCurrentScale): 91 (WebCore::SVGSVGElement::currentViewBoxRect): 92 (WebCore::SVGSVGElement::viewBoxToViewTransform): 93 * svg/SVGSVGElement.h: 94 1 95 2011-05-27 Michael Saboff <msaboff@apple.com> 2 96 -
trunk/Source/WebCore/platform/Length.h
r81925 r87526 174 174 bool isFixed() const { return type() == Fixed; } 175 175 bool isIntrinsicOrAuto() const { return type() == Auto || type() == MinIntrinsic || type() == Intrinsic; } 176 bool isSpecified() const { return type() == Fixed || type() == Percent; } 176 177 177 178 Length blend(const Length& from, float progress) const -
trunk/Source/WebCore/rendering/RenderPart.cpp
r83518 r87526 4 4 * (C) 2000 Stefan Schimanski (1Stein@gmx.de) 5 5 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 6 7 * 7 8 * This library is free software; you can redistribute it and/or … … 29 30 #include "HTMLFrameElementBase.h" 30 31 #include "PluginViewBase.h" 32 #include "RenderSVGRoot.h" 31 33 #include "RenderView.h" 34 35 using namespace std; 32 36 33 37 namespace WebCore { … … 91 95 #endif 92 96 93 } 97 #if ENABLE(SVG) 98 RenderSVGRoot* RenderPart::embeddedSVGContentRenderer() const 99 { 100 if (!node() || !widget() || !widget()->isFrameView()) 101 return 0; 102 103 FrameView* view = static_cast<FrameView*>(widget()); 104 RenderObject* contentRenderer = view->frame() ? view->frame()->contentRenderer() : 0; 105 if (!contentRenderer) 106 return 0; 107 108 RenderObject* svgRootRenderer = contentRenderer->firstChild(); 109 if (!svgRootRenderer || !svgRootRenderer->isSVGRoot()) 110 return 0; 111 112 return toRenderSVGRoot(svgRootRenderer); 113 } 114 115 int RenderPart::computeEmbeddedDocumentReplacedWidth(bool includeMaxWidth, RenderStyle* contentRenderStyle) const 116 { 117 int logicalWidth = computeReplacedLogicalWidthUsing(contentRenderStyle->logicalWidth()); 118 int minLogicalWidth = computeReplacedLogicalWidthUsing(contentRenderStyle->logicalMinWidth()); 119 int maxLogicalWidth = !includeMaxWidth || contentRenderStyle->logicalMaxWidth().isUndefined() ? logicalWidth : computeReplacedLogicalWidthUsing(contentRenderStyle->logicalMaxWidth()); 120 int width = max(minLogicalWidth, min(logicalWidth, maxLogicalWidth)); 121 return width; 122 } 123 124 int RenderPart::computeEmbeddedDocumentReplacedHeight(RenderStyle* contentRenderStyle) const 125 { 126 int logicalHeight = computeReplacedLogicalHeightUsing(contentRenderStyle->logicalHeight()); 127 int minLogicalHeight = computeReplacedLogicalHeightUsing(contentRenderStyle->logicalMinHeight()); 128 int maxLogicalHeight = contentRenderStyle->logicalMaxHeight().isUndefined() ? logicalHeight : computeReplacedLogicalHeightUsing(contentRenderStyle->logicalMaxHeight()); 129 int height = max(minLogicalHeight, min(logicalHeight, maxLogicalHeight)); 130 return height; 131 } 132 133 int RenderPart::computeReplacedLogicalWidth(bool includeMaxWidth) const 134 { 135 RenderSVGRoot* contentRenderer = embeddedSVGContentRenderer(); 136 RenderStyle* contentRenderStyle = contentRenderer ? contentRenderer->style() : 0; 137 138 if (!contentRenderer || !contentRenderStyle || style()->width().isSpecified()) 139 return RenderWidget::computeReplacedLogicalWidth(includeMaxWidth); 140 141 // 10.3.2 Inline, replaced elements: http://www.w3.org/TR/CSS21/visudet.html#inline-replaced-width 142 if (style()->width().isAuto()) { 143 bool heightIsAuto = style()->height().isAuto(); 144 bool hasIntrinsicWidth = contentRenderStyle->width().isFixed(); 145 146 // If 'height' and 'width' both have computed values of 'auto' and the element also has an intrinsic width, then that intrinsic width is the used value of 'width'. 147 if (heightIsAuto && hasIntrinsicWidth) 148 return computeEmbeddedDocumentReplacedWidth(includeMaxWidth, contentRenderStyle); 149 150 bool hasIntrinsicHeight = contentRenderStyle->height().isFixed(); 151 FloatSize intrinsicRatio = contentRenderer->computeIntrinsicRatio(); 152 if (!intrinsicRatio.isEmpty()) { 153 // If 'height' and 'width' both have computed values of 'auto' and the element has no intrinsic width, but does have an intrinsic height and intrinsic ratio; 154 // or if 'width' has a computed value of 'auto', 'height' has some other computed value, and the element does have an intrinsic ratio; then the used value 155 // of 'width' is: (used height) * (intrinsic ratio) 156 if ((heightIsAuto && !hasIntrinsicWidth && hasIntrinsicHeight) || !heightIsAuto) { 157 int logicalHeight = computeReplacedLogicalHeightUsing(heightIsAuto ? contentRenderStyle->logicalHeight() : style()->logicalHeight()); 158 return static_cast<int>(ceilf(logicalHeight * intrinsicRatio.width() / intrinsicRatio.height())); 159 } 160 161 // If 'height' and 'width' both have computed values of 'auto' and the element has an intrinsic ratio but no intrinsic height or width, then the used value of 162 // 'width' is undefined in CSS 2.1. However, it is suggested that, if the containing block's width does not itself depend on the replaced element's width, then 163 // the used value of 'width' is calculated from the constraint equation used for block-level, non-replaced elements in normal flow. 164 // FIXME: Don't ignore padding/margin/border here. 165 RenderBlock* containingBlock = this->containingBlock(); 166 if (heightIsAuto && !hasIntrinsicWidth && !hasIntrinsicHeight && containingBlock) 167 return containingBlock->width(); 168 } 169 170 // Otherwise, if 'width' has a computed value of 'auto', and the element has an intrinsic width, then that intrinsic width is the used value of 'width'. 171 if (hasIntrinsicWidth) 172 return computeEmbeddedDocumentReplacedWidth(includeMaxWidth, contentRenderStyle); 173 } 174 175 // Otherwise, if 'width' has a computed value of 'auto', but none of the conditions above are met, then the used value of 'width' becomes 300px. If 300px is too 176 // wide to fit the device, UAs should use the width of the largest rectangle that has a 2:1 ratio and fits the device instead. 177 return intrinsicLogicalWidth(); 178 } 179 180 int RenderPart::computeReplacedLogicalHeight() const 181 { 182 RenderSVGRoot* contentRenderer = embeddedSVGContentRenderer(); 183 RenderStyle* contentRenderStyle = contentRenderer ? contentRenderer->style() : 0; 184 185 if (!contentRenderer || !contentRenderStyle || style()->height().isSpecified()) 186 return RenderWidget::computeReplacedLogicalHeight(); 187 188 // 10.6.2 Inline, replaced elements: http://www.w3.org/TR/CSS21/visudet.html#inline-replaced-height 189 if (style()->height().isAuto()) { 190 bool widthIsAuto = style()->width().isAuto(); 191 bool hasIntrinsicHeight = contentRenderStyle->height().isFixed(); 192 193 // If 'height' and 'width' both have computed values of 'auto' and the element also has an intrinsic height, then that intrinsic height is the used value of 'height'. 194 if (widthIsAuto && hasIntrinsicHeight) 195 return computeEmbeddedDocumentReplacedHeight(contentRenderStyle); 196 197 // Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic ratio then the used value of 'height' is: 198 // (used width) / (intrinsic ratio) 199 FloatSize intrinsicRatio = contentRenderer->computeIntrinsicRatio(); 200 if (!intrinsicRatio.isEmpty()) { 201 int logicalWidth = computeReplacedLogicalWidthUsing(widthIsAuto ? contentRenderStyle->logicalWidth() : style()->logicalWidth()); 202 return static_cast<int>(ceilf(logicalWidth * intrinsicRatio.height() / intrinsicRatio.width())); 203 } 204 205 // Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic height, then that intrinsic height is the used value of 'height'. 206 if (hasIntrinsicHeight) 207 return computeEmbeddedDocumentReplacedHeight(contentRenderStyle); 208 } 209 210 // Otherwise, if 'height' has a computed value of 'auto', but none of the conditions above are met, then the used value of 'height' must be set to the height 211 // of the largest rectangle that has a 2:1 ratio, has a height not greater than 150px, and has a width not greater than the device width. 212 return intrinsicLogicalHeight(); 213 } 214 215 void RenderPart::layout() 216 { 217 ASSERT(needsLayout()); 218 219 if ((style()->width().isAuto() || style()->height().isAuto()) && embeddedSVGContentRenderer()) 220 setPreferredLogicalWidthsDirty(true); 221 222 RenderWidget::layout(); 223 } 224 #endif 225 226 } -
trunk/Source/WebCore/rendering/RenderPart.h
r83518 r87526 28 28 namespace WebCore { 29 29 30 class RenderSVGRoot; 31 30 32 // Renderer for frames via RenderFrameBase, and plug-ins via RenderEmbeddedObject. 31 33 class RenderPart : public RenderWidget { … … 44 46 #if USE(ACCELERATED_COMPOSITING) 45 47 virtual bool requiresLayer() const; 48 #endif 49 50 #if ENABLE(SVG) 51 RenderSVGRoot* embeddedSVGContentRenderer() const; 52 int computeEmbeddedDocumentReplacedWidth(bool includeMaxWidth, RenderStyle* contentRenderStyle) const; 53 int computeEmbeddedDocumentReplacedHeight(RenderStyle* contentRenderStyle) const; 54 virtual int computeReplacedLogicalWidth(bool includeMaxWidth = true) const; 55 virtual int computeReplacedLogicalHeight() const; 56 virtual void layout(); 46 57 #endif 47 58 -
trunk/Source/WebCore/rendering/RenderReplaced.cpp
r86400 r87526 192 192 } 193 193 194 static inline bool lengthIsSpecified(Length length)195 {196 LengthType lengthType = length.type();197 return lengthType == Fixed || lengthType == Percent;198 }199 200 194 int RenderReplaced::computeReplacedLogicalWidth(bool includeMaxWidth) const 201 195 { 202 196 int logicalWidth; 203 if (lengthIsSpecified(style()->width())) 197 // FIXME: Shouldn't this use style()->logicalWidth(), similar to what computeReplacedLogicalHeight() does? 198 if (style()->width().isSpecified()) 204 199 logicalWidth = computeReplacedLogicalWidthUsing(style()->logicalWidth()); 205 200 else if (m_hasIntrinsicSize) … … 217 212 { 218 213 int logicalHeight; 219 if ( lengthIsSpecified(style()->logicalHeight()))214 if (style()->logicalHeight().isSpecified()) 220 215 logicalHeight = computeReplacedLogicalHeightUsing(style()->logicalHeight()); 221 216 else if (m_hasIntrinsicSize) -
trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp
r87277 r87526 4 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> 5 5 * Copyright (C) 2009 Google, Inc. 6 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 6 7 * 7 8 * This library is free software; you can redistribute it and/or … … 26 27 #include "RenderSVGRoot.h" 27 28 29 #include "Frame.h" 28 30 #include "GraphicsContext.h" 29 31 #include "HitTestResult.h" 32 #include "RenderPart.h" 30 33 #include "RenderSVGContainer.h" 31 34 #include "RenderSVGResource.h" … … 36 39 #include "SVGSVGElement.h" 37 40 #include "SVGStyledElement.h" 41 #include "SVGViewSpec.h" 38 42 #include "TransformState.h" 39 43 … … 50 54 , m_isLayoutSizeChanged(false) 51 55 , m_needsBoundariesOrTransformUpdate(true) 56 , m_didNegotiateSize(false) 52 57 { 53 58 setReplaced(true); … … 56 61 RenderSVGRoot::~RenderSVGRoot() 57 62 { 63 } 64 65 FloatSize RenderSVGRoot::computeIntrinsicRatio() const 66 { 67 // Spec: http://dev.w3.org/SVG/profiles/1.1F2/publish/coords.html#IntrinsicSizing 68 // The intrinsic aspect ratio of the viewport of SVG content is necessary for example, when including 69 // SVG from an ‘object’ element in HTML styled with CSS. It is possible (indeed, common) for an SVG 70 // graphic to have an intrinsic aspect ratio but not to have an intrinsic width or height. 71 // The intrinsic aspect ratio must be calculated based upon the following rules: 72 // The aspect ratio is calculated by dividing a width by a height. 73 74 // If the ‘width’ and ‘height’ of the rootmost ‘svg’ element are both specified with unit identifiers 75 // (in, mm, cm, pt, pc, px, em, ex) or in user units, then the aspect ratio is calculated from the 76 // ‘width’ and ‘height’ attributes after resolving both values to user units. 77 if (style()->width().isFixed() && style()->height().isFixed()) 78 return FloatSize(width(), height()); 79 80 // If either/both of the ‘width’ and ‘height’ of the rootmost ‘svg’ element are in percentage units (or omitted), 81 // the aspect ratio is calculated from the width and height values of the ‘viewBox’ specified for the current SVG 82 // document fragment. If the ‘viewBox’ is not correctly specified, or set to 'none', the intrinsic aspect ratio 83 // cannot be calculated and is considered unspecified. 84 return static_cast<SVGSVGElement*>(node())->currentViewBoxRect().size(); 58 85 } 59 86 … … 77 104 } 78 105 106 int RenderSVGRoot::computeIntrinsicWidth(int replacedWidth) const 107 { 108 if (!style()->width().isPercent()) 109 return replacedWidth; 110 111 SVGSVGElement* svg = static_cast<SVGSVGElement*>(node()); 112 return static_cast<int>(ceilf(replacedWidth * svg->currentScale())); 113 } 114 115 int RenderSVGRoot::computeIntrinsicHeight(int replacedHeight) const 116 { 117 if (!style()->height().isPercent()) 118 return replacedHeight; 119 120 const SVGSVGElement* svg = static_cast<SVGSVGElement*>(node()); 121 return static_cast<int>(ceilf(replacedHeight * svg->currentScale())); 122 } 123 124 void RenderSVGRoot::negotiateSizeWithHostDocumentIfNeeded() 125 { 126 if (m_didNegotiateSize) 127 return; 128 129 Frame* frame = node() && node()->document() ? node()->document()->frame() : 0; 130 if (!frame) 131 return; 132 133 // If our frame has an owner renderer, we're embedded through eg. object/embed. 134 // If we're embedded in a host document, we may be loaded after the host document 135 // has finished layout. If the <object> doesn't specifiy width/height attributes 136 // it has defaulted to 300x150 intrinsic size. If the SVG document has been loaded 137 // we notify the RenderPart about the potential size changes, now it can properly 138 // synchronize the intrinsic width/height/ratio, as defined in the SVG spec. 139 if (RenderPart* ownerRenderer = frame->ownerRenderer()) { 140 ownerRenderer->setNeedsLayoutAndPrefWidthsRecalc(); 141 m_didNegotiateSize = true; 142 } 143 } 144 79 145 int RenderSVGRoot::computeReplacedLogicalWidth(bool includeMaxWidth) const 80 146 { 81 147 int replacedWidth = RenderBox::computeReplacedLogicalWidth(includeMaxWidth); 82 if (!style()->logicalWidth().isPercent()) 83 return replacedWidth; 84 85 // FIXME: Investigate in size rounding issues 86 SVGSVGElement* svg = static_cast<SVGSVGElement*>(node()); 87 return static_cast<int>(roundf(replacedWidth * svg->currentScale())); 148 Frame* frame = node() && node()->document() ? node()->document()->frame() : 0; 149 if (!frame) 150 return computeIntrinsicWidth(replacedWidth); 151 152 // If our frame has an owner renderer, we're embedded through eg. object/embed. 153 RenderPart* ownerRenderer = frame->ownerRenderer(); 154 if (!ownerRenderer) 155 return computeIntrinsicWidth(replacedWidth); 156 157 RenderStyle* ownerRendererStyle = ownerRenderer->style(); 158 ASSERT(ownerRendererStyle); 159 ASSERT(frame->contentRenderer()); 160 161 Length ownerWidth = ownerRendererStyle->width(); 162 if (ownerWidth.isAuto()) 163 return computeIntrinsicWidth(replacedWidth); 164 165 // Spec: http://dev.w3.org/SVG/profiles/1.1F2/publish/coords.html#ViewportSpace 166 // The SVG user agent negotiates with its parent user agent to determine the viewport into which the SVG user agent can render 167 // the document. In some circumstances, SVG content will be embedded (by reference or inline) within a containing document. 168 // This containing document might include attributes, properties and/or other parameters (explicit or implicit) which specify 169 // or provide hints about the dimensions of the viewport for the SVG content. SVG content itself optionally can provide 170 // information about the appropriate viewport region for the content via the ‘width’ and ‘height’ XML attributes on the 171 // outermost svg element. The negotiation process uses any information provided by the containing document and the SVG 172 // content itself to choose the viewport location and size. 173 174 // The ‘width’ attribute on the outermost svg element establishes the viewport's width, unless the following conditions are met: 175 // * the SVG content is a separately stored resource that is embedded by reference (such as the ‘object’ element in XHTML [XHTML]), 176 // or the SVG content is embedded inline within a containing document; 177 // * and the referencing element or containing document is styled using CSS [CSS2] or XSL [XSL]; 178 // * and there are CSS-compatible positioning properties ([CSS2], section 9.3) specified on the referencing element 179 // (e.g., the ‘object’ element) or on the containing document's outermost svg element that are sufficient to establish 180 // the width of the viewport. 181 // 182 // Under these conditions, the positioning properties establish the viewport's width. 183 int logicalWidth = ownerRenderer->computeReplacedLogicalWidthUsing(ownerWidth); 184 int minLogicalWidth = ownerRenderer->computeReplacedLogicalWidthUsing(ownerRendererStyle->logicalMinWidth()); 185 int maxLogicalWidth = !includeMaxWidth || ownerRendererStyle->logicalMaxWidth().isUndefined() ? logicalWidth : ownerRenderer->computeReplacedLogicalWidthUsing(ownerRendererStyle->logicalMaxWidth()); 186 return max(minLogicalWidth, min(logicalWidth, maxLogicalWidth)); 88 187 } 89 188 … … 91 190 { 92 191 int replacedHeight = RenderBox::computeReplacedLogicalHeight(); 93 if (!style()->logicalHeight().isPercent()) 94 return replacedHeight; 95 96 // FIXME: Investigate in size rounding issues 97 SVGSVGElement* svg = static_cast<SVGSVGElement*>(node()); 98 return static_cast<int>(roundf(replacedHeight * svg->currentScale())); 192 193 Frame* frame = node() && node()->document() ? node()->document()->frame() : 0; 194 if (!frame) 195 return computeIntrinsicHeight(replacedHeight); 196 197 // If our frame has an owner renderer, we're embedded through eg. object/embed. 198 RenderPart* ownerRenderer = frame->ownerRenderer(); 199 if (!ownerRenderer) 200 return computeIntrinsicHeight(replacedHeight); 201 202 RenderStyle* ownerRendererStyle = ownerRenderer->style(); 203 ASSERT(ownerRendererStyle); 204 ASSERT(frame->contentRenderer()); 205 206 Length ownerHeight = ownerRendererStyle->height(); 207 if (ownerHeight.isAuto()) 208 return computeIntrinsicHeight(replacedHeight); 209 210 // Spec: http://dev.w3.org/SVG/profiles/1.1F2/publish/coords.html#ViewportSpace 211 // See comment in RenderSVGRoot::computeReplacedLogicalWidth(). 212 // Similarly, if there are positioning properties specified on the referencing element or on the outermost svg element that 213 // are sufficient to establish the height of the viewport, then these positioning properties establish the viewport's height; 214 // otherwise, the ‘height’ attribute on the outermost svg element establishes the viewport's height. 215 int logicalHeight = ownerRenderer->computeReplacedLogicalHeightUsing(ownerHeight); 216 int minLogicalHeight = ownerRenderer->computeReplacedLogicalHeightUsing(ownerRendererStyle->logicalMinHeight()); 217 int maxLogicalHeight = ownerRendererStyle->logicalMaxHeight().isUndefined() ? logicalHeight : ownerRenderer->computeReplacedLogicalHeightUsing(ownerRendererStyle->logicalMaxHeight()); 218 return max(minLogicalHeight, min(logicalHeight, maxLogicalHeight)); 99 219 } 100 220 … … 110 230 111 231 IntSize oldSize(width(), height()); 232 negotiateSizeWithHostDocumentIfNeeded(); 112 233 computeLogicalWidth(); 113 234 computeLogicalHeight(); -
trunk/Source/WebCore/rendering/svg/RenderSVGRoot.h
r86705 r87526 40 40 virtual ~RenderSVGRoot(); 41 41 42 FloatSize computeIntrinsicRatio() const; 42 43 const RenderObjectChildList* children() const { return &m_children; } 43 44 RenderObjectChildList* children() { return &m_children; } … … 48 49 49 50 private: 51 int computeIntrinsicWidth(int replacedWidth) const; 52 int computeIntrinsicHeight(int replacedHeight) const; 53 void negotiateSizeWithHostDocumentIfNeeded(); 54 50 55 virtual RenderObjectChildList* virtualChildren() { return children(); } 51 56 virtual const RenderObjectChildList* virtualChildren() const { return children(); } … … 99 104 bool m_isLayoutSizeChanged : 1; 100 105 bool m_needsBoundariesOrTransformUpdate : 1; 106 bool m_didNegotiateSize : 1; 101 107 }; 102 108 -
trunk/Source/WebCore/svg/SVGLength.cpp
r86542 r87526 27 27 #include "CSSHelper.h" 28 28 #include "FloatConversion.h" 29 #include "Frame.h" 29 30 #include "FrameView.h" 30 31 #include "RenderObject.h" 32 #include "RenderPart.h" 31 33 #include "RenderView.h" 32 34 #include "SVGNames.h" … … 318 320 Document* document = context->document(); 319 321 if (document->documentElement() == context) { 320 if (RenderView* view = toRenderView(document->renderer())) { 321 width = view->viewWidth(); 322 height = view->viewHeight(); 323 return true; 322 if (context->isSVG()) { 323 Frame* frame = context->document() ? context->document()->frame() : 0; 324 if (RenderPart* ownerRenderer = frame->ownerRenderer()) { 325 width = ownerRenderer->width(); 326 height = ownerRenderer->height(); 327 return true; 328 } 324 329 } 325 330 326 return false; 327 } 328 329 // Resolve value against nearest viewport element (common case: inner <svg> elements) 331 RenderView* view = toRenderView(document->renderer()); 332 if (!view) 333 return false; 334 335 width = view->viewWidth(); 336 height = view->viewHeight(); 337 return true; 338 } 339 340 // Take size from nearest viewport element (common case: inner <svg> elements) 330 341 SVGElement* viewportElement = context->viewportElement(); 331 342 if (viewportElement && viewportElement->isSVG()) { … … 342 353 } 343 354 344 // Resolve value against enclosing non-SVG RenderBox355 // Take size from enclosing non-SVG RenderBox (common case: inline SVG) 345 356 if (!context->parentNode() || context->parentNode()->isSVGElement()) 346 357 return false; -
trunk/Source/WebCore/svg/SVGSVGElement.cpp
r87010 r87526 35 35 #include "FloatRect.h" 36 36 #include "Frame.h" 37 #include "FrameTree.h" 37 38 #include "FrameSelection.h" 38 39 #include "FrameView.h" … … 199 200 float SVGSVGElement::currentScale() const 200 201 { 201 // Only the page zoom factor is relevant for SVG 202 if (Frame* frame = document()->frame()) 203 return frame->pageZoomFactor(); 204 return m_scale; 202 if (!inDocument()) 203 return 1; 204 205 Frame* frame = document()->frame(); 206 if (!frame) 207 return 1; 208 209 FrameTree* frameTree = frame->tree(); 210 ASSERT(frameTree); 211 212 // If we have a parent frame, only return the user-specified m_scale here. 213 if (frameTree->parent()) 214 return m_scale; 215 216 return frame->pageZoomFactor(); 205 217 } 206 218 207 219 void SVGSVGElement::setCurrentScale(float scale) 208 220 { 209 if (Frame* frame = document()->frame()) { 210 // Calling setCurrentScale() on the outermost <svg> element in a standalone SVG document 211 // is allowed to change the page zoom factor, influencing the document size, scrollbars etc. 212 if (parentNode() == document()) 213 frame->setPageZoomFactor(scale); 221 if (!inDocument()) 214 222 return; 223 224 Frame* frame = document()->frame(); 225 if (!frame) 226 return; 227 228 FrameTree* frameTree = frame->tree(); 229 ASSERT(frameTree); 230 231 bool hasFrameParent = frameTree->parent(); 232 233 // Calling setCurrentScale() on the outermost <svg> element in a standalone SVG document 234 // is allowed to change the page zoom factor, influencing the document size, scrollbars etc. 235 if (!hasFrameParent && isOutermostSVG()) { 236 frame->setPageZoomFactor(scale); 237 m_scale = 1; 238 return; 215 239 } 216 240 217 241 m_scale = scale; 242 218 243 if (RenderObject* object = renderer()) 219 244 RenderSVGResource::markForLayoutAndParentResourceInvalidation(object); … … 587 612 } 588 613 614 FloatRect SVGSVGElement::currentViewBoxRect() const 615 { 616 if (useCurrentView()) { 617 if (SVGViewSpec* view = currentView()) // what if we should use it but it is not set? 618 return view->viewBox(); 619 return FloatRect(); 620 } 621 622 return viewBox(); 623 } 624 589 625 AffineTransform SVGSVGElement::viewBoxToViewTransform(float viewWidth, float viewHeight) const 590 626 { 591 FloatRect viewBoxRect; 592 if (useCurrentView()) { 593 if (currentView()) // what if we should use it but it is not set? 594 viewBoxRect = currentView()->viewBox(); 595 } else 596 viewBoxRect = viewBox(); 597 598 AffineTransform ctm = SVGFitToViewBox::viewBoxToViewTransform(viewBoxRect, preserveAspectRatio(), viewWidth, viewHeight); 599 627 AffineTransform ctm = SVGFitToViewBox::viewBoxToViewTransform(currentViewBoxRect(), preserveAspectRatio(), viewWidth, viewHeight); 600 628 if (useCurrentView() && currentView()) { 601 629 AffineTransform transform; -
trunk/Source/WebCore/svg/SVGSVGElement.h
r87125 r87526 78 78 79 79 SVGViewSpec* currentView() const; 80 FloatRect currentViewBoxRect() const; 80 81 81 82 float currentScale() const;
Note: See TracChangeset
for help on using the changeset viewer.