Changeset 181165 in webkit


Ignore:
Timestamp:
Mar 6, 2015 10:15:48 AM (9 years ago)
Author:
commit-queue@webkit.org
Message:

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.

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.

Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r181164 r181165  
     12015-03-06  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        An SVG element without intrinsic size inherits the container size as its viewport instead of inheriting the container viewport.
     4        https://bugs.webkit.org/show_bug.cgi?id=141725.
     5
     6        Reviewed by Darin Adler.
     7
     8        * svg/css/svg-css-different-intrinsic-sizes-expected.html: Added.
     9        * svg/css/svg-css-different-intrinsic-sizes.html: Added.
     10        The intrinsic size of the <svg> element is overridden by CSS. The elements
     11        inside the <svg> should consider the css size (which is equal to the <svg>
     12        element viewport) instead of the <svg> element intrinsic size.
     13
    1142015-03-06  Simon Fraser  <simon.fraser@apple.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r181164 r181165  
     12015-03-06  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        An SVG element without intrinsic size inherits the container size as its viewport instead of inheriting the container viewport.
     4        https://bugs.webkit.org/show_bug.cgi?id=141725.
     5
     6        Reviewed by Darin Adler.
     7
     8        The current viewport of the <svg> element should be retrieved from its
     9        renderer if the renderer is available. If the renderer is not created yet,
     10        this means the viewport is needed to calculate the size of the renderer.
     11        In this case, we should return the element size if it is intrinsic size.
     12       
     13        Test: svg/css/svg-css-different-intrinsic-sizes.html
     14
     15        * svg/SVGSVGElement.cpp:
     16        (WebCore::SVGSVGElement::currentViewportSize): Change the order for
     17        returning the viewport of the <svg> element. We should consider the case
     18        of a valid renderer before considering the case of an intrinsic size.
     19
    1202015-03-06  Simon Fraser  <simon.fraser@apple.com>
    221
  • trunk/Source/WebCore/svg/SVGSVGElement.cpp

    r179991 r181165  
    527527FloatSize SVGSVGElement::currentViewportSize() const
    528528{
    529     if (hasIntrinsicWidth() && hasIntrinsicHeight())
    530         return FloatSize(floatValueForLength(intrinsicWidth(), 0), floatValueForLength(intrinsicHeight(), 0));
    531 
    532     if (!renderer())
     529    FloatSize viewportSize;
     530
     531    if (renderer()) {
     532        if (is<RenderSVGRoot>(*renderer())) {
     533            auto& root = downcast<RenderSVGRoot>(*renderer());
     534            viewportSize = root.contentBoxRect().size() / root.style().effectiveZoom();
     535        } else
     536            viewportSize = downcast<RenderSVGViewportContainer>(*renderer()).viewport().size();
     537    }
     538
     539    if (!viewportSize.isEmpty())
     540        return viewportSize;
     541
     542    if (!(hasIntrinsicWidth() && hasIntrinsicHeight()))
    533543        return { };
    534544
    535     if (is<RenderSVGRoot>(*renderer())) {
    536         auto& root = downcast<RenderSVGRoot>(*renderer());
    537         return root.contentBoxRect().size() / root.style().effectiveZoom();
    538     }
    539 
    540     return downcast<RenderSVGViewportContainer>(*renderer()).viewport().size();
     545    return FloatSize(floatValueForLength(intrinsicWidth(), 0), floatValueForLength(intrinsicHeight(), 0));
    541546}
    542547
Note: See TracChangeset for help on using the changeset viewer.