Changeset 70317 in webkit


Ignore:
Timestamp:
Oct 22, 2010 10:43:31 AM (14 years ago)
Author:
krit@webkit.org
Message:

2010-10-22 Cosmin Truta <ctruta@chromium.org>

Reviewed by Nikolas Zimmermann.

getBoundingClientRect does not work with SVG <text>
https://bugs.webkit.org/show_bug.cgi?id=46775

Dispatched the calls from Element::getBoundingClientRect to getBBox
through SVGElement::boundingBox.
Recognized SVGTextElement in addition to SVGStyledLocatableElement
as a class that provides getBBox.
Fixed the result of zooming: adjusted the getBoundingClientRect rectangle
for absolute zoom, even for SVG elements.

Additional cleanup task:
Removed redundant overloads of SVGStyledTransformableElement
methods: nearestViewportElement, farthestViewportElement, getBBox.
These methods are already inherited from SVGStyledLocatableElement.

Test: css3/zoom-coords.xhtml

  • WebCore.xcodeproj/project.pbxproj: Set role of SVGLocatable.h to private.
  • dom/Element.cpp: (Element::getBoundingClientRect): Used SVGElement::boundingBox. Adjusted coordinates for absolute zoom, for all kinds of elements.
  • svg/SVGElement.cpp:
  • svg/SVGElement.h: (SVGElement::boundingBox): Added.
  • svg/SVGStyledTransformableElement.cpp:
  • svg/SVGStyledTransformableElement.h: (SVGStyledTransformableElement::nearestViewportElement): Removed. (SVGStyledTransformableElement::farthestViewportElement): Removed. (SVGStyledTransformableElement::getBBox): Removed.

2010-10-22 Cosmin Truta <ctruta@chromium.org>

Reviewed by Nikolas Zimmermann.

getBoundingClientRect does not work with SVG <text>
https://bugs.webkit.org/show_bug.cgi?id=46775

Added coordinate checks on various zoomed-in and zoomed-out
XHTML and SVG elements, using getBoundingClientRect.

  • css3/zoom-coords.xhtml: Added.
  • css3/zoom-coords-expected.txt: Added.
Location:
trunk
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r70316 r70317  
     12010-10-22  Cosmin Truta  <ctruta@chromium.org>
     2
     3        Reviewed by Nikolas Zimmermann.
     4
     5        getBoundingClientRect does not work with SVG <text>
     6        https://bugs.webkit.org/show_bug.cgi?id=46775
     7
     8        Added coordinate checks on various zoomed-in and zoomed-out
     9        XHTML and SVG elements, using getBoundingClientRect.
     10
     11        * css3/zoom-coords.xhtml: Added.
     12        * css3/zoom-coords-expected.txt: Added.
     13
    1142010-10-22  Adam Roben  <aroben@apple.com>
    215
  • trunk/WebCore/ChangeLog

    r70314 r70317  
     12010-10-22  Cosmin Truta  <ctruta@chromium.org>
     2
     3        Reviewed by Nikolas Zimmermann.
     4
     5        getBoundingClientRect does not work with SVG <text>
     6        https://bugs.webkit.org/show_bug.cgi?id=46775
     7
     8        Dispatched the calls from Element::getBoundingClientRect to getBBox
     9        through SVGElement::boundingBox.
     10        Recognized SVGTextElement in addition to SVGStyledLocatableElement
     11        as a class that provides getBBox.
     12        Fixed the result of zooming: adjusted the getBoundingClientRect rectangle
     13        for absolute zoom, even for SVG elements.
     14
     15        Additional cleanup task:
     16        Removed redundant overloads of SVGStyledTransformableElement
     17        methods: nearestViewportElement, farthestViewportElement, getBBox.
     18        These methods are already inherited from SVGStyledLocatableElement.
     19
     20        Test: css3/zoom-coords.xhtml
     21
     22        * WebCore.xcodeproj/project.pbxproj: Set role of SVGLocatable.h to private.
     23        * dom/Element.cpp:
     24        (Element::getBoundingClientRect): Used SVGElement::boundingBox.
     25        Adjusted coordinates for absolute zoom, for all kinds of elements.
     26        * svg/SVGElement.cpp:
     27        * svg/SVGElement.h:
     28        (SVGElement::boundingBox): Added.
     29        * svg/SVGStyledTransformableElement.cpp:
     30        * svg/SVGStyledTransformableElement.h:
     31        (SVGStyledTransformableElement::nearestViewportElement): Removed.
     32        (SVGStyledTransformableElement::farthestViewportElement): Removed.
     33        (SVGStyledTransformableElement::getBBox): Removed.
     34
    1352010-10-22  Patrick Gansterer  <paroga@webkit.org>
    236
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r70300 r70317  
    40494049                B2227A3F0D00BF220071B782 /* SVGListTraits.h in Headers */ = {isa = PBXBuildFile; fileRef = B22278A90D00BF200071B782 /* SVGListTraits.h */; settings = {ATTRIBUTES = (Private, ); }; };
    40504050                B2227A400D00BF220071B782 /* SVGLocatable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B22278AA0D00BF200071B782 /* SVGLocatable.cpp */; };
    4051                 B2227A410D00BF220071B782 /* SVGLocatable.h in Headers */ = {isa = PBXBuildFile; fileRef = B22278AB0D00BF200071B782 /* SVGLocatable.h */; };
     4051                B2227A410D00BF220071B782 /* SVGLocatable.h in Headers */ = {isa = PBXBuildFile; fileRef = B22278AB0D00BF200071B782 /* SVGLocatable.h */; settings = {ATTRIBUTES = (Private, ); }; };
    40524052                B2227A430D00BF220071B782 /* SVGMarkerElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B22278AD0D00BF200071B782 /* SVGMarkerElement.cpp */; };
    40534053                B2227A440D00BF220071B782 /* SVGMarkerElement.h in Headers */ = {isa = PBXBuildFile; fileRef = B22278AE0D00BF200071B782 /* SVGMarkerElement.h */; };
  • trunk/WebCore/dom/Element.cpp

    r70302 r70317  
    5353#include "RenderView.h"
    5454#include "RenderWidget.h"
    55 #include "SVGStyledLocatableElement.h"
    5655#include "Settings.h"
    5756#include "TextIterator.h"
     
    6059
    6160#if ENABLE(SVG)
     61#include "SVGElement.h"
    6262#include "SVGNames.h"
    6363#endif
     
    489489    Vector<FloatQuad> quads;
    490490#if ENABLE(SVG)
    491     if (isSVGElement()) {
     491    if (isSVGElement() && renderer()) {
    492492        // Get the bounding rectangle from the SVG model.
    493493        const SVGElement* svgElement = static_cast<const SVGElement*>(this);
    494         if (svgElement->isStyledLocatable()) {
    495             if (renderer()) {
    496                 const FloatRect& localRect = static_cast<const SVGStyledLocatableElement*>(svgElement)->getBBox();
    497                 quads.append(renderer()->localToAbsoluteQuad(localRect));
    498             }
    499         }
     494        FloatRect localRect;
     495        if (svgElement->boundingBox(localRect))
     496            quads.append(renderer()->localToAbsoluteQuad(localRect));
    500497    } else
    501498#endif
     
    518515    }
    519516
    520     if (renderBoxModelObject())
    521         adjustIntRectForAbsoluteZoom(result, renderBoxModelObject());
    522 
     517    adjustIntRectForAbsoluteZoom(result, renderer());
    523518    return ClientRect::create(result);
    524519}
  • trunk/WebCore/svg/SVGElement.cpp

    r69868 r70317  
    4343#include "SVGNames.h"
    4444#include "SVGSVGElement.h"
     45#include "SVGStyledLocatableElement.h"
     46#include "SVGTextElement.h"
    4547#include "SVGURIReference.h"
    4648#include "SVGUseElement.h"
     
    178180    }
    179181    return rareSVGData()->elementInstances();
     182}
     183
     184bool SVGElement::boundingBox(FloatRect& rect, SVGLocatable::StyleUpdateStrategy styleUpdateStrategy) const
     185{
     186    if (isStyledLocatable()) {
     187        rect = static_cast<const SVGStyledLocatableElement*>(this)->getBBox(styleUpdateStrategy);
     188        return true;
     189    }
     190    if (hasTagName(SVGNames::textTag)) {
     191        rect = static_cast<const SVGTextElement*>(this)->getBBox(styleUpdateStrategy);
     192        return true;
     193    }
     194    return false;
    180195}
    181196
  • trunk/WebCore/svg/SVGElement.h

    r70135 r70317  
    2525#if ENABLE(SVG)
    2626#include "SVGDocumentExtensions.h"
     27#include "SVGLocatable.h"
    2728#include "StyledElement.h"
    2829
     
    7273        const HashSet<SVGElementInstance*>& instancesForElement() const;
    7374
     75        bool boundingBox(FloatRect&, SVGLocatable::StyleUpdateStrategy = SVGLocatable::AllowStyleUpdate) const;
     76
    7477        void setCursorElement(SVGCursorElement*);
    7578        void setCursorImageValue(CSSCursorImageValue*);
  • trunk/WebCore/svg/SVGStyledTransformableElement.cpp

    r69517 r70317  
    9191}
    9292
    93 SVGElement* SVGStyledTransformableElement::nearestViewportElement() const
    94 {
    95     return SVGTransformable::nearestViewportElement(this);
    96 }
    97 
    98 SVGElement* SVGStyledTransformableElement::farthestViewportElement() const
    99 {
    100     return SVGTransformable::farthestViewportElement(this);
    101 }
    102 
    103 FloatRect SVGStyledTransformableElement::getBBox(StyleUpdateStrategy styleUpdateStrategy) const
    104 {
    105     return SVGTransformable::getBBox(this, styleUpdateStrategy);
    106 }
    107 
    10893RenderObject* SVGStyledTransformableElement::createRenderer(RenderArena* arena, RenderStyle*)
    10994{
  • trunk/WebCore/svg/SVGStyledTransformableElement.h

    r69517 r70317  
    3838    virtual AffineTransform getCTM(StyleUpdateStrategy = AllowStyleUpdate) const;
    3939    virtual AffineTransform getScreenCTM(StyleUpdateStrategy = AllowStyleUpdate) const;
    40     virtual SVGElement* nearestViewportElement() const;
    41     virtual SVGElement* farthestViewportElement() const;
    4240
    4341    virtual AffineTransform localCoordinateSpaceTransform(SVGLocatable::CTMScope mode) const { return SVGTransformable::localCoordinateSpaceTransform(mode); }
    4442    virtual AffineTransform animatedLocalTransform() const;
    4543    virtual AffineTransform* supplementalTransform();
    46 
    47     virtual FloatRect getBBox(StyleUpdateStrategy = AllowStyleUpdate) const;
    4844
    4945    bool isKnownAttribute(const QualifiedName&);
Note: See TracChangeset for help on using the changeset viewer.