Changeset 68867 in webkit


Ignore:
Timestamp:
Oct 1, 2010 12:16:23 AM (14 years ago)
Author:
Nikolas Zimmermann
Message:

2010-10-01 Nikolas Zimmermann <nzimmermann@rim.com>

Reviewed by Dirk Schulze.

Add helper methods to cast between renderers & SVGTextContent/PositioningElement
https://bugs.webkit.org/show_bug.cgi?id=46963

Doesn't affect any tests.

  • svg/SVGTextContentElement.cpp: (WebCore::SVGTextContentElement::elementFromRenderer):
  • svg/SVGTextContentElement.h:
  • svg/SVGTextPositioningElement.cpp: (WebCore::SVGTextPositioningElement::elementFromRenderer):
  • svg/SVGTextPositioningElement.h:
Location:
trunk/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r68865 r68867  
     12010-10-01  Nikolas Zimmermann  <nzimmermann@rim.com>
     2
     3        Reviewed by Dirk Schulze.
     4
     5        Add helper methods to cast between renderers & SVGTextContent/PositioningElement
     6        https://bugs.webkit.org/show_bug.cgi?id=46963
     7
     8        Doesn't affect any tests.
     9
     10        * svg/SVGTextContentElement.cpp:
     11        (WebCore::SVGTextContentElement::elementFromRenderer):
     12        * svg/SVGTextContentElement.h:
     13        * svg/SVGTextPositioningElement.cpp:
     14        (WebCore::SVGTextPositioningElement::elementFromRenderer):
     15        * svg/SVGTextPositioningElement.h:
     16
    1172010-09-30  MORITA Hajime  <morrita@google.com>
    218
  • trunk/WebCore/svg/SVGTextContentElement.cpp

    r66397 r68867  
    2727#include "CSSValueKeywords.h"
    2828#include "Frame.h"
     29#include "RenderObject.h"
    2930#include "SVGTextQuery.h"
    3031#include "SelectionController.h"
     
    216217}
    217218
     219SVGTextContentElement* SVGTextContentElement::elementFromRenderer(RenderObject* renderer)
     220{
     221    if (!renderer)
     222        return 0;
     223
     224    if (!renderer->isSVGText() && !renderer->isSVGInline())
     225        return 0;
     226
     227    Node* node = renderer->node();
     228    ASSERT(node);
     229    ASSERT(node->isSVGElement());
     230
     231    if (!node->hasTagName(SVGNames::textTag)
     232        && !node->hasTagName(SVGNames::tspanTag)
     233#if ENABLE(SVG_FONTS)
     234        && !node->hasTagName(SVGNames::altGlyphTag)
     235#endif
     236        && !node->hasTagName(SVGNames::trefTag)
     237        && !node->hasTagName(SVGNames::textPathTag))
     238        return 0;
     239
     240    return static_cast<SVGTextContentElement*>(node);
     241}
     242
    218243}
    219244
  • trunk/WebCore/svg/SVGTextContentElement.h

    r66397 r68867  
    5555        bool isKnownAttribute(const QualifiedName&);
    5656
     57        static SVGTextContentElement* elementFromRenderer(RenderObject*);
     58
    5759    protected:
    5860        SVGTextContentElement(const QualifiedName&, Document*);
  • trunk/WebCore/svg/SVGTextPositioningElement.cpp

    r66397 r68867  
    144144}
    145145
     146SVGTextPositioningElement* SVGTextPositioningElement::elementFromRenderer(RenderObject* renderer)
     147{
     148    if (!renderer)
     149        return 0;
     150
     151    if (!renderer->isSVGText() && !renderer->isSVGInline())
     152        return 0;
     153
     154    Node* node = renderer->node();
     155    ASSERT(node);
     156    ASSERT(node->isSVGElement());
     157
     158    if (!node->hasTagName(SVGNames::textTag)
     159        && !node->hasTagName(SVGNames::tspanTag)
     160#if ENABLE(SVG_FONTS)
     161        && !node->hasTagName(SVGNames::altGlyphTag)
     162#endif
     163        && !node->hasTagName(SVGNames::trefTag))
     164        return 0;
     165
     166    return static_cast<SVGTextPositioningElement*>(node);
     167}
     168
     169
    146170}
    147171
  • trunk/WebCore/svg/SVGTextPositioningElement.h

    r66397 r68867  
    3030
    3131    class SVGTextPositioningElement : public SVGTextContentElement {
     32    public:
     33        static SVGTextPositioningElement* elementFromRenderer(RenderObject*);
     34
    3235    protected:
    3336        SVGTextPositioningElement(const QualifiedName&, Document*);
Note: See TracChangeset for help on using the changeset viewer.