https://bugs.webkit.org/show_bug.cgi?id=141725.
Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2015-03-06
Reviewed by Darin Adler.
Source/WebCore:
The current viewport of the <svg> element should be retrieved from its
renderer if the renderer is available. If the renderer is not created yet,
this means the viewport is needed to calculate the size of the renderer.
In this case, we should return the element size if it is intrinsic size.
Test: svg/css/svg-css-different-intrinsic-sizes.html
* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::currentViewportSize): Change the order for
returning the viewport of the <svg> element. We should consider the case
of a valid renderer before considering the case of an intrinsic size.
LayoutTests:
* svg/css/svg-css-different-intrinsic-sizes-expected.html: Added.
* svg/css/svg-css-different-intrinsic-sizes.html: Added.
The intrinsic size of the <svg> element is overridden by CSS. The elements
inside the <svg> should consider the css size (which is equal to the <svg>
element viewport) instead of the <svg> element intrinsic size.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181165
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2015-03-06 Said Abou-Hallawa <sabouhallawa@apple.com>
+
+ An SVG element without intrinsic size inherits the container size as its viewport instead of inheriting the container viewport.
+ https://bugs.webkit.org/show_bug.cgi?id=141725.
+
+ Reviewed by Darin Adler.
+
+ * svg/css/svg-css-different-intrinsic-sizes-expected.html: Added.
+ * svg/css/svg-css-different-intrinsic-sizes.html: Added.
+ The intrinsic size of the <svg> element is overridden by CSS. The elements
+ inside the <svg> should consider the css size (which is equal to the <svg>
+ element viewport) instead of the <svg> element intrinsic size.
+
2015-03-06 Simon Fraser <simon.fraser@apple.com>
Allow composited clip-path to be updated without a layer repaint
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+ <style>
+ div {
+ background-image: url("data:image/svg+xml, \
+ <svg xmlns='http://www.w3.org/2000/svg'> \
+ <rect width='75' height='75' fill='yellow'/> \
+ <rect width='50' height='50' fill='lime'/> \
+ <rect width='25' height='25' fill='red'/> \
+ </svg>");
+ width: 75px;
+ height: 75px;
+ }
+ </style>
+</head>
+<body>
+ <div></div>
+ <div></div>
+ <div></div>
+ <div></div>
+ <div></div>
+ <div></div>
+ <div></div>
+</body>
+</html>
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+ <style>
+ div {
+ background: yellow;
+ width: 75px;
+ height: 75px;
+ }
+ svg {
+ background: lime;
+ }
+ svg.intrinsic-size {
+ width: 50px;
+ height: 50px;
+ }
+ rect {
+ fill: red;
+ }
+ </style>
+</head>
+<body>
+ <div>
+ <svg class='intrinsic-size' width='100' height='100'>
+ <rect width='50%' height='50%'/>
+ </svg>
+ </div>
+ <div>
+ <svg width='100' height='100'>
+ <style>
+ svg {
+ width: 50px;
+ height: 50px;
+ }
+ </style>
+ <rect width='50%' height='50%'/>
+ </svg>
+ </div>
+ <div>
+ <svg class='intrinsic-size' width='100' height='100'>
+ <svg viewbox='0 0 100 100'>
+ <rect width='50%' height='50%'/>
+ </svg>
+ </svg>
+ </div>
+ <div>
+ <svg class='intrinsic-size' width='100' height='100'>
+ <svg class='intrinsic-size' viewbox='0 0 100 100'>
+ <rect width='50' height='50'/>
+ </svg>
+ </svg>
+ </div>
+ <div>
+ <svg class='intrinsic-size' width='100' height='100'>
+ <svg class='intrinsic-size' width='50%' height='50%' viewbox='0 0 100 100'>
+ <rect width='100%' height='100%'/>
+ </svg>
+ </svg>
+ </div>
+ <div>
+ <svg class='intrinsic-size' width='100' height='100'>
+ <svg width='50%' height='50%' viewbox='0 0 100 100'>
+ <rect width='100' height='100'/>
+ </svg>
+ </svg>
+ </div>
+ <div>
+ <svg width='100' height='100'>
+ <style>
+ svg {
+ width: 50px;
+ height: 50px;
+ }
+ </style>
+ <svg width='50%' height='50%' viewbox='0 0 100 100'>
+ <rect width='100' height='100'/>
+ </svg>
+ </svg>
+ </div>
+</body>
+</html>
+2015-03-06 Said Abou-Hallawa <sabouhallawa@apple.com>
+
+ An SVG element without intrinsic size inherits the container size as its viewport instead of inheriting the container viewport.
+ https://bugs.webkit.org/show_bug.cgi?id=141725.
+
+ Reviewed by Darin Adler.
+
+ The current viewport of the <svg> element should be retrieved from its
+ renderer if the renderer is available. If the renderer is not created yet,
+ this means the viewport is needed to calculate the size of the renderer.
+ In this case, we should return the element size if it is intrinsic size.
+
+ Test: svg/css/svg-css-different-intrinsic-sizes.html
+
+ * svg/SVGSVGElement.cpp:
+ (WebCore::SVGSVGElement::currentViewportSize): Change the order for
+ returning the viewport of the <svg> element. We should consider the case
+ of a valid renderer before considering the case of an intrinsic size.
+
2015-03-06 Simon Fraser <simon.fraser@apple.com>
Allow composited clip-path to be updated without a layer repaint
FloatSize SVGSVGElement::currentViewportSize() const
{
- if (hasIntrinsicWidth() && hasIntrinsicHeight())
- return FloatSize(floatValueForLength(intrinsicWidth(), 0), floatValueForLength(intrinsicHeight(), 0));
+ FloatSize viewportSize;
+
+ if (renderer()) {
+ if (is<RenderSVGRoot>(*renderer())) {
+ auto& root = downcast<RenderSVGRoot>(*renderer());
+ viewportSize = root.contentBoxRect().size() / root.style().effectiveZoom();
+ } else
+ viewportSize = downcast<RenderSVGViewportContainer>(*renderer()).viewport().size();
+ }
- if (!renderer())
- return { };
+ if (!viewportSize.isEmpty())
+ return viewportSize;
- if (is<RenderSVGRoot>(*renderer())) {
- auto& root = downcast<RenderSVGRoot>(*renderer());
- return root.contentBoxRect().size() / root.style().effectiveZoom();
- }
+ if (!(hasIntrinsicWidth() && hasIntrinsicHeight()))
+ return { };
- return downcast<RenderSVGViewportContainer>(*renderer()).viewport().size();
+ return FloatSize(floatValueForLength(intrinsicWidth(), 0), floatValueForLength(intrinsicHeight(), 0));
}
bool SVGSVGElement::hasIntrinsicWidth() const