Changeset 88007 in webkit


Ignore:
Timestamp:
Jun 3, 2011 5:11:19 AM (13 years ago)
Author:
Nikolas Zimmermann
Message:

2011-06-03 Nikolas Zimmermann <nzimmermann@rim.com>

Reviewed by Andreas Kling.

Zooming <object style="width/height: auto" data="foo.svg"/> doesn't work as expected
https://bugs.webkit.org/show_bug.cgi?id=62005

Zooming an object with auto size, that references a svg with fixed size was broken. The svg size stayed the same.
Added new tests covering this zooming.

  • platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-2-expected.png:
  • platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-2-expected.txt:
  • platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-expected.png:
  • platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-expected.txt:
  • platform/mac/svg/zoom/page/zoom-svg-through-object-with-auto-size-expected.png: Added.
  • platform/mac/svg/zoom/page/zoom-svg-through-object-with-auto-size-expected.txt: Added.
  • svg/zoom/page/resources/circle.svg: Added.
  • svg/zoom/page/zoom-svg-through-object-with-auto-size.html: Added.

2011-06-03 Nikolas Zimmermann <nzimmermann@rim.com>

Reviewed by Andreas Kling.

Zooming <object style="width/height: auto" data="foo.svg"/> doesn't work as expected
https://bugs.webkit.org/show_bug.cgi?id=62005

Zooming an object with auto size, that references a svg with fixed size was broken. The svg size stayed the same.
Get rid of the dependency between RenderSVGRoot and SVGSVGElement::currentScale(), always ask for the effective
zoom in the RenderStyle instead of asking SVGSVGElement.

The SVGSVGElement::currentScale()/setCurrentScale() methods are now only used when called from the bindings (eg. JS).
They only take effect on the outermost <svg> element in standalone documents, otherwhise they are no-ops.

Test: svg/zoom/page/zoom-svg-through-object-with-auto-size.html

  • rendering/svg/RenderSVGRoot.cpp: (WebCore::RenderSVGRoot::computeIntrinsicWidth): (WebCore::RenderSVGRoot::computeIntrinsicHeight): (WebCore::RenderSVGRoot::localToBorderBoxTransform):
  • svg/SVGSVGElement.cpp: (WebCore::SVGSVGElement::SVGSVGElement): (WebCore::SVGSVGElement::currentScale): (WebCore::SVGSVGElement::setCurrentScale):
  • svg/SVGSVGElement.h:
Location:
trunk
Files:
4 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r88005 r88007  
     12011-06-03  Nikolas Zimmermann  <nzimmermann@rim.com>
     2
     3        Reviewed by Andreas Kling.
     4
     5        Zooming <object style="width/height: auto" data="foo.svg"/> doesn't work as expected
     6        https://bugs.webkit.org/show_bug.cgi?id=62005
     7
     8        Zooming an object with auto size, that references a svg with fixed size was broken. The svg size stayed the same.
     9        Added new tests covering this zooming.
     10
     11        * platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-2-expected.png:
     12        * platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-2-expected.txt:
     13        * platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-expected.png:
     14        * platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-expected.txt:
     15        * platform/mac/svg/zoom/page/zoom-svg-through-object-with-auto-size-expected.png: Added.
     16        * platform/mac/svg/zoom/page/zoom-svg-through-object-with-auto-size-expected.txt: Added.
     17        * svg/zoom/page/resources/circle.svg: Added.
     18        * svg/zoom/page/zoom-svg-through-object-with-auto-size.html: Added.
     19
    1202011-06-03  Csaba Osztrogonác  <ossy@webkit.org>
    221
  • trunk/LayoutTests/platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-2-expected.txt

    r87526 r88007  
    2828                          RenderView at (0,0) size 138x69
    2929                        layer at (0,0) size 138x69
    30                           RenderSVGRoot {svg} at (23,0) size 92x69
     30                          RenderSVGRoot {svg} at (22,0) size 93x69
    3131                            RenderSVGContainer {g} at (27,8) size 73x46
    3232                              RenderSVGPath {rect} at (28,8) size 11x17 [stroke={[type=SOLID] [color=#000000]}] [x=30.00] [y=46.00] [width=50.00] [height=80.00]
     
    4141                              RenderSVGInlineText {#text} at (0,0) size 272x48
    4242                                chunk 1 text run 1 at (10.00,340.00) startOffset 0 endOffset 16 width 271.30: "$Revision: 1.7 $"
    43                             RenderSVGPath {rect} at (23,0) size 92x69 [stroke={[type=SOLID] [color=#000000]}] [x=1.00] [y=1.00] [width=478.00] [height=358.00]
     43                            RenderSVGPath {rect} at (22,0) size 93x69 [stroke={[type=SOLID] [color=#000000]}] [x=1.00] [y=1.00] [width=478.00] [height=358.00]
    4444                      RenderText {#text} at (0,0) size 0x0
    4545                    RenderTableCell {td} at (245,90) size 244x82 [r=2 c=1 rs=1 cs=1]
  • trunk/LayoutTests/platform/mac/svg/zoom/page/zoom-svg-through-object-with-absolute-size-expected.txt

    r87526 r88007  
    2828                          RenderView at (0,0) size 138x69
    2929                        layer at (0,0) size 138x69
    30                           RenderSVGRoot {svg} at (23,0) size 92x69
     30                          RenderSVGRoot {svg} at (22,0) size 93x69
    3131                            RenderSVGContainer {g} at (27,8) size 73x46
    3232                              RenderSVGPath {rect} at (28,8) size 11x17 [stroke={[type=SOLID] [color=#000000]}] [x=30.00] [y=46.00] [width=50.00] [height=80.00]
     
    4141                              RenderSVGInlineText {#text} at (0,0) size 272x48
    4242                                chunk 1 text run 1 at (10.00,340.00) startOffset 0 endOffset 16 width 271.30: "$Revision: 1.7 $"
    43                             RenderSVGPath {rect} at (23,0) size 92x69 [stroke={[type=SOLID] [color=#000000]}] [x=1.00] [y=1.00] [width=478.00] [height=358.00]
     43                            RenderSVGPath {rect} at (22,0) size 93x69 [stroke={[type=SOLID] [color=#000000]}] [x=1.00] [y=1.00] [width=478.00] [height=358.00]
    4444                      RenderText {#text} at (0,0) size 0x0
    4545                    RenderTableCell {td} at (245,90) size 244x82 [r=2 c=1 rs=1 cs=1]
  • trunk/Source/WebCore/ChangeLog

    r88004 r88007  
     12011-06-03  Nikolas Zimmermann  <nzimmermann@rim.com>
     2
     3        Reviewed by Andreas Kling.
     4
     5        Zooming <object style="width/height: auto" data="foo.svg"/> doesn't work as expected
     6        https://bugs.webkit.org/show_bug.cgi?id=62005
     7
     8        Zooming an object with auto size, that references a svg with fixed size was broken. The svg size stayed the same.
     9        Get rid of the dependency between RenderSVGRoot and SVGSVGElement::currentScale(), always ask for the effective
     10        zoom in the RenderStyle instead of asking SVGSVGElement.
     11
     12        The SVGSVGElement::currentScale()/setCurrentScale() methods are now only used when called from the bindings (eg. JS).
     13        They only take effect on the outermost <svg> element in standalone documents, otherwhise they are no-ops.
     14
     15        Test: svg/zoom/page/zoom-svg-through-object-with-auto-size.html
     16
     17        * rendering/svg/RenderSVGRoot.cpp:
     18        (WebCore::RenderSVGRoot::computeIntrinsicWidth):
     19        (WebCore::RenderSVGRoot::computeIntrinsicHeight):
     20        (WebCore::RenderSVGRoot::localToBorderBoxTransform):
     21        * svg/SVGSVGElement.cpp:
     22        (WebCore::SVGSVGElement::SVGSVGElement):
     23        (WebCore::SVGSVGElement::currentScale):
     24        (WebCore::SVGSVGElement::setCurrentScale):
     25        * svg/SVGSVGElement.h:
     26
    1272011-06-03  Mario Sanchez Prada  <msanchez@igalia.com>
    228
  • trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp

    r87801 r88007  
    118118    if (!style()->width().isPercent())
    119119        return replacedWidth;
    120 
    121     SVGSVGElement* svg = static_cast<SVGSVGElement*>(node());
    122     return static_cast<int>(ceilf(replacedWidth * svg->currentScale()));
     120    return static_cast<int>(ceilf(replacedWidth * style()->effectiveZoom()));
    123121}
    124122
     
    127125    if (!style()->height().isPercent())
    128126        return replacedHeight;
    129 
    130     const SVGSVGElement* svg = static_cast<SVGSVGElement*>(node());
    131     return static_cast<int>(ceilf(replacedHeight * svg->currentScale()));
     127    return static_cast<int>(ceilf(replacedHeight * style()->effectiveZoom()));
    132128}
    133129
     
    368364    IntSize borderAndPadding = borderOriginToContentBox();
    369365    SVGSVGElement* svg = static_cast<SVGSVGElement*>(node());
    370     float scale = svg->currentScale();
     366    float scale = style()->effectiveZoom();
    371367    FloatPoint translate = svg->currentTranslate();
    372368    AffineTransform ctm(scale, 0, 0, scale, borderAndPadding.width() + translate.x(), borderAndPadding.height() + translate.y());
  • trunk/Source/WebCore/svg/SVGSVGElement.cpp

    r87526 r88007  
    7474    , m_useCurrentView(false)
    7575    , m_timeContainer(SMILTimeContainer::create(this))
    76     , m_scale(1)
    7776    , m_containerSize(300, 150)
    7877    , m_hasSetContainerSize(false)
     
    200199float SVGSVGElement::currentScale() const
    201200{
    202     if (!inDocument())
     201    if (!inDocument() || !isOutermostSVG())
    203202        return 1;
    204203
     
    210209    ASSERT(frameTree);
    211210
    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();
     211    // The behaviour of currentScale() is undefined, when we're dealing with non-standalone SVG documents.
     212    // If the svg is embedded, the scaling is handled by the host renderer, so when asking from inside
     213    // the SVG document, a scale value of 1 seems reasonable, as it doesn't know anything about the parent scale.
     214    return frameTree->parent() ? 1 : frame->pageZoomFactor();
    217215}
    218216
    219217void SVGSVGElement::setCurrentScale(float scale)
    220218{
    221     if (!inDocument())
     219    if (!inDocument() || !isOutermostSVG())
    222220        return;
    223221
     
    229227    ASSERT(frameTree);
    230228
    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;
     229    // The behaviour of setCurrentScale() is undefined, when we're dealing with non-standalone SVG documents.
     230    // We choose the ignore this call, it's pretty useless to support calling setCurrentScale() from within
     231    // an embedded SVG document, for the same reasons as in currentScale() - needs resolution by SVG WG.
     232    if (frameTree->parent())
    238233        return;
    239     }
    240 
    241     m_scale = scale;
    242 
    243     if (RenderObject* object = renderer())
    244         RenderSVGResource::markForLayoutAndParentResourceInvalidation(object);
     234
     235    frame->setPageZoomFactor(scale);
    245236}
    246237
  • trunk/Source/WebCore/svg/SVGSVGElement.h

    r87526 r88007  
    172172    RefPtr<SMILTimeContainer> m_timeContainer;
    173173    FloatPoint m_translation;
    174     float m_scale;
    175174    mutable OwnPtr<SVGViewSpec> m_viewSpec;
    176175    IntSize m_containerSize;
Note: See TracChangeset for help on using the changeset viewer.