Changeset 28559 in webkit


Ignore:
Timestamp:
Dec 8, 2007 12:53:33 AM (16 years ago)
Author:
rwlbuis@webkit.org
Message:

Reviewed by Darin.

http://bugs.webkit.org/show_bug.cgi?id=15528
svg_dynamic_cast should be removed

Replace svg_dynamic_cast with a combination of
isSVGElement and static_cast.

Location:
trunk/WebCore
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r28558 r28559  
     12007-12-08  Rob Buis  <buis@kde.org>
     2
     3        Reviewed by Darin.
     4
     5        http://bugs.webkit.org/show_bug.cgi?id=15528
     6        svg_dynamic_cast should be removed
     7
     8        Replace svg_dynamic_cast with a combination of
     9        isSVGElement and static_cast.
     10
     11        * rendering/SVGRootInlineBox.cpp:
     12        (WebCore::SVGRootInlineBox::buildLayoutInformation):
     13        (WebCore::SVGRootInlineBox::buildTextChunks):
     14        * svg/SVGAnimationElement.cpp:
     15        (WebCore::SVGAnimationElement::targetElement):
     16        * svg/SVGElement.h:
     17        * svg/SVGElementInstance.cpp:
     18        (WebCore::SVGElementInstance::updateInstance):
     19        * svg/SVGFilterElement.cpp:
     20        (WebCore::SVGFilterElement::canvasResource):
     21        * svg/SVGGradientElement.cpp:
     22        (WebCore::SVGGradientElement::buildStops):
     23        * svg/SVGLocatable.cpp:
     24        (WebCore::SVGLocatable::getTransformToElement):
     25        * svg/SVGMaskElement.cpp:
     26        (WebCore::SVGMaskElement::drawMaskerContent):
     27        * svg/SVGSwitchElement.cpp:
     28        (WebCore::SVGSwitchElement::childShouldCreateRenderer):
     29        * svg/SVGUseElement.cpp:
     30        (WebCore::SVGUseElement::insertedIntoDocument):
     31        (WebCore::SVGUseElement::buildPendingResource):
     32        (WebCore::SVGUseElement::buildInstanceTree):
     33        (WebCore::SVGUseElement::handleDeepUseReferencing):
     34        (WebCore::SVGUseElement::buildShadowTree):
     35        (WebCore::SVGUseElement::expandUseElementsInShadowTree):
     36        (WebCore::SVGUseElement::associateInstancesWithShadowTreeElements):
     37        * svg/graphics/SVGResource.cpp:
     38        (WebCore::getResourceById):
     39
    1402007-12-07  Antti Koivisto  <antti@apple.com>
    241
  • trunk/WebCore/rendering/SVGRootInlineBox.cpp

    r28298 r28559  
    914914
    915915                // Handle text-anchor/textLength on path, which is special.
    916                 SVGElement* textElement = svg_dynamic_cast(flowBox->object()->element());
    917                 ASSERT(textElement);
    918 
    919                 SVGTextContentElement* textContent = static_cast<SVGTextContentElement*>(textElement);
     916                SVGTextContentElement* textContent = 0;
     917                Node* node = flowBox->object()->element();
     918                if (node && node->isSVGElement())
     919                    textContent = static_cast<SVGTextContentElement*>(node);
    920920                ASSERT(textContent);
    921921
     
    13291329            RenderText* text = textBox->textObject();
    13301330            ASSERT(text);
    1331 
    1332             SVGElement* textElement = svg_dynamic_cast(text->element()->parent());
    13331331            ASSERT(text->element());
    13341332
    1335             SVGTextContentElement* textContent = static_cast<SVGTextContentElement*>(textElement);
     1333            SVGTextContentElement* textContent = 0;
     1334            Node* node = text->element()->parent();
     1335            if (node && node->isSVGElement())
     1336                textContent = static_cast<SVGTextContentElement*>(node);
    13361337            ASSERT(textContent);
    1337            
     1338
    13381339            // Start new character range for the first chunk
    13391340            bool isFirstCharacter = info.svgTextChunks.isEmpty() && info.chunk.start == info.it && info.chunk.start == info.chunk.end;
  • trunk/WebCore/svg/SVGAnimationElement.cpp

    r26543 r28559  
    7979{
    8080    if (!m_targetElement) {
     81        Node *target = 0;
    8182        if (!m_href.isEmpty()) {
    82             Element* element = ownerDocument()->getElementById(SVGURIReference::getTarget(m_href));
    83             m_targetElement = svg_dynamic_cast(element);
     83            target = document()->getElementById(SVGURIReference::getTarget(m_href));
    8484        } else if (parentNode()) {
    85             Node* target = parentNode();
     85            // TODO : do we really need to skip non element nodes? Can that happen at all?
     86            target = parentNode();
    8687            while (target) {
    8788                if (target->nodeType() != ELEMENT_NODE)
     
    9091                    break;
    9192            }
    92             m_targetElement = svg_dynamic_cast(target);
    9393        }
    94     }
    95                        
     94        if (target && target->isSVGElement())
     95            m_targetElement = static_cast<SVGElement*>(target);
     96    }
     97 
    9698    return m_targetElement;
    9799}
  • trunk/WebCore/svg/SVGElement.h

    r26538 r28559  
    245245    };
    246246
    247     static inline SVGElement* svg_dynamic_cast(Node* node)
    248     {
    249         SVGElement* svgElement = 0;
    250         if (node && node->isSVGElement())
    251             svgElement = static_cast<SVGElement*>(node);
    252         return svgElement;
    253     }
    254 
    255247} // namespace WebCore
    256248
  • trunk/WebCore/svg/SVGElementInstance.cpp

    r26497 r28559  
    163163    // For all other nodes this logic is sufficient.
    164164    RefPtr<Node> clone = m_element->cloneNode(true);
    165     SVGElement* svgClone = svg_dynamic_cast(clone.get());
     165    SVGElement* svgClone = 0;
     166    if (clone && clone->isSVGElement())
     167        svgClone = static_cast<SVGElement*>(clone.get());
    166168    ASSERT(svgClone);
    167169
  • trunk/WebCore/svg/SVGFilterElement.cpp

    r26442 r28559  
    142142    m_filter->clearEffects();
    143143    for (Node* n = firstChild(); n != 0; n = n->nextSibling()) {
    144         SVGElement* element = svg_dynamic_cast(n);
     144        SVGElement* element = 0;
     145        if (n->isSVGElement())
     146            element = static_cast<SVGElement*>(n);
    145147        if (element && element->isFilterEffect()) {
    146148            SVGFilterPrimitiveStandardAttributes* filterAttributes = static_cast<SVGFilterPrimitiveStandardAttributes*>(element);
  • trunk/WebCore/svg/SVGGradientElement.cpp

    r26549 r28559  
    120120    RenderStyle* gradientStyle = 0;
    121121    for (Node* n = firstChild(); n; n = n->nextSibling()) {
    122         SVGElement* element = svg_dynamic_cast(n);
     122        SVGElement* element = 0;
     123        if (n->isSVGElement())
     124            element = static_cast<SVGElement*>(n);
    123125        if (element && element->isGradientStop()) {
    124126            SVGStopElement* stop = static_cast<SVGStopElement*>(element);
  • trunk/WebCore/svg/SVGLocatable.cpp

    r26534 r28559  
    132132    AffineTransform ctm = getCTM();
    133133
    134     SVGElement* targetElement = svg_dynamic_cast(target);
    135     if (targetElement && targetElement->isStyledLocatable()) {
    136         AffineTransform targetCTM = static_cast<SVGStyledLocatableElement*>(targetElement)->getCTM();
     134    if (target && target->isStyledLocatable()) {
     135        AffineTransform targetCTM = static_cast<SVGStyledLocatableElement*>(target)->getCTM();
    137136        if (!targetCTM.isInvertible()) {
    138137            ec = SVG_MATRIX_NOT_INVERTABLE;
  • trunk/WebCore/svg/SVGMaskElement.cpp

    r26745 r28559  
    160160    // Render subtree into ImageBuffer
    161161    for (Node* n = firstChild(); n; n = n->nextSibling()) {
    162         SVGElement* elem = svg_dynamic_cast(n);
     162        SVGElement* elem = 0;
     163        if (n->isSVGElement())
     164            elem = static_cast<SVGElement*>(n);
    163165        if (!elem || !elem->isStyled())
    164166            continue;
  • trunk/WebCore/svg/SVGSwitchElement.cpp

    r26534 r28559  
    4545{
    4646    for (Node* n = firstChild(); n != 0; n = n->nextSibling()) {
    47         SVGElement* element = svg_dynamic_cast(n);
    48         if (element && element->isValid())
    49             return (n == child); // Only allow this child if it's the first valid child
     47        if (n->isSVGElement()) {
     48            SVGElement* element = static_cast<SVGElement*>(n);
     49            if (element && element->isValid())
     50                return (n == child); // Only allow this child if it's the first valid child
     51        }
    5052    }
    5153
  • trunk/WebCore/svg/SVGUseElement.cpp

    r26534 r28559  
    117117
    118118    String id = SVGURIReference::getTarget(href());
    119     Element* targetElement = ownerDocument()->getElementById(id);
     119    Element* targetElement = document()->getElementById(id);
    120120    if (!targetElement) {
    121121        document()->accessSVGExtensions()->addPendingResource(id, this);
     
    259259
    260260    String id = SVGURIReference::getTarget(href());
    261     Element* targetElement = ownerDocument()->getElementById(id);
    262     SVGElement* target = svg_dynamic_cast(targetElement);
     261    Element* targetElement = document()->getElementById(id);
     262    SVGElement* target = 0;
     263    if (targetElement && targetElement->isSVGElement())
     264        target = static_cast<SVGElement*>(targetElement);
    263265
    264266    // Do not allow self-referencing.
     
    389391
    390392    for (Node* node = target->firstChild(); node; node = node->nextSibling()) {
    391         SVGElement* element = svg_dynamic_cast(node);
     393        SVGElement* element = 0;
     394        if (node->isSVGElement())
     395            element = static_cast<SVGElement*>(node);
    392396
    393397        // Skip any non-svg nodes or any disallowed element.
     
    420424{
    421425    String id = SVGURIReference::getTarget(use->href());
    422     Element* targetElement = ownerDocument()->getElementById(id);
    423     SVGElement* target = svg_dynamic_cast(targetElement);
     426    Element* targetElement = document()->getElementById(id);
     427    SVGElement* target = 0;
     428    if (targetElement && targetElement->isSVGElement())
     429        target = static_cast<SVGElement*>(targetElement);
    424430
    425431    if (!target)
     
    499505        removeDisallowedElementsFromSubtree(newChild.get());
    500506
    501     SVGElement* newChildPtr = svg_dynamic_cast(newChild.get());
     507    SVGElement* newChildPtr = 0;
     508    if (newChild->isSVGElement())
     509        newChildPtr = static_cast<SVGElement*>(newChild.get());
    502510    ASSERT(newChildPtr);
    503511
     
    525533
    526534        String id = SVGURIReference::getTarget(use->href());
    527         Element* targetElement = ownerDocument()->getElementById(id);
    528         SVGElement* target = svg_dynamic_cast(targetElement);
     535        Element* targetElement = document()->getElementById(id);
     536        SVGElement* target = 0;
     537        if (targetElement && targetElement->isSVGElement())
     538            target = static_cast<SVGElement*>(targetElement);
    529539
    530540        // Don't ASSERT(target) here, it may be "pending", too.
     
    574584                removeDisallowedElementsFromSubtree(newChild.get());
    575585
    576             SVGElement* newChildPtr = svg_dynamic_cast(newChild.get());
     586            SVGElement* newChildPtr = 0;
     587            if (newChild->isSVGElement())
     588                newChildPtr = static_cast<SVGElement*>(newChild.get());
    577589            ASSERT(newChildPtr);
    578590
     
    699711        ASSERT(target->nodeName() == originalElement->nodeName());
    700712
    701     SVGElement* element = svg_dynamic_cast(target);
     713    SVGElement* element = 0;
     714    if (target->isSVGElement())
     715        element = static_cast<SVGElement*>(target);
    702716
    703717    ASSERT(!targetInstance->shadowTreeElement());
  • trunk/WebCore/svg/graphics/SVGResource.cpp

    r28319 r28559  
    159159
    160160    Element* element = document->getElementById(id);
    161     SVGElement* svgElement = svg_dynamic_cast(element);
     161    SVGElement* svgElement = 0;
     162    if (element && element->isSVGElement())
     163        svgElement = static_cast<SVGElement*>(element);
    162164
    163165    if (svgElement && svgElement->isStyled())
Note: See TracChangeset for help on using the changeset viewer.