Title: [145433] trunk/Source/WebCore
Revision
145433
Author
[email protected]
Date
2013-03-11 16:48:37 -0700 (Mon, 11 Mar 2013)

Log Message

Replace static_cast<SVGStyledElement> with toSVGStyledElement()
https://bugs.webkit.org/show_bug.cgi?id=111651

Reviewed by Abhishek Arya.

toSVGStyledElement is preferred over static_cast<SVGStyledElement*> because bad casts
can be caught on our testing infrastructure. This patch replaces all
static_cast<SVGStyledElement> instances with toSVGStyledElement.

Additionally, this patch renames SVGElement::isStyled to SVGElement::isSVGStyledElement to
remove a confusing overlap with html styled elements. This name differs slighly from the
other is*() functions in SVGElement but this will be resolved up with webkit.org/b/107386.

No new tests as this is covered with existing tests.

* rendering/svg/RenderSVGModelObject.cpp:
(WebCore::getElementCTM):
* rendering/svg/RenderSVGResourceClipper.cpp:
(WebCore::RenderSVGResourceClipper::drawContentIntoMaskImage):
(WebCore::RenderSVGResourceClipper::calculateClipContentRepaintRect):
(WebCore::RenderSVGResourceClipper::hitTestClipContent):
* rendering/svg/RenderSVGResourceMasker.cpp:
(WebCore::RenderSVGResourceMasker::drawContentIntoMaskImage):
(WebCore::RenderSVGResourceMasker::calculateMaskContentRepaintRect):
* rendering/svg/RenderSVGResourcePattern.cpp:
(WebCore::RenderSVGResourcePattern::createTileImage):
* rendering/svg/SVGRenderSupport.cpp:
(WebCore::SVGRenderSupport::layoutChildren):
* rendering/svg/SVGResources.cpp:
(WebCore::registerPendingResource):
* svg/SVGAnimationElement.cpp:
(WebCore::SVGAnimationElement::isTargetAttributeCSSProperty):
(WebCore::SVGAnimationElement::computeCSSPropertyValue):
(WebCore::SVGAnimationElement::adjustForInheritance):
(WebCore::inheritsFromProperty):
* svg/SVGElement.cpp:
(WebCore::collectInstancesForSVGElement):
(WebCore::SVGElement::isAnimatableAttribute):
* svg/SVGElement.h:
(WebCore::SVGElement::isSVGStyledElement):
* svg/SVGElementInstance.cpp:
(WebCore::SVGElementInstance::invalidateAllInstancesOfElement):
(WebCore::SVGElementInstance::InstanceUpdateBlocker::InstanceUpdateBlocker):
* svg/SVGLocatable.cpp:
(WebCore::SVGLocatable::computeCTM):
* svg/SVGStyledElement.cpp:
(WebCore::SVGStyledElement::updateRelativeLengthsInformation):
* svg/SVGStyledElement.h:
(WebCore::SVGStyledElement::isSVGStyledElement):
* svg/SVGUseElement.cpp:
(WebCore::SVGUseElement::selfHasRelativeLengths):
* svg/graphics/filters/SVGFEImage.cpp:
(WebCore::FEImage::platformApplySoftware):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (145432 => 145433)


--- trunk/Source/WebCore/ChangeLog	2013-03-11 23:47:20 UTC (rev 145432)
+++ trunk/Source/WebCore/ChangeLog	2013-03-11 23:48:37 UTC (rev 145433)
@@ -1,3 +1,59 @@
+2013-03-11  Philip Rogers  <[email protected]>
+
+        Replace static_cast<SVGStyledElement> with toSVGStyledElement()
+        https://bugs.webkit.org/show_bug.cgi?id=111651
+
+        Reviewed by Abhishek Arya.
+
+        toSVGStyledElement is preferred over static_cast<SVGStyledElement*> because bad casts
+        can be caught on our testing infrastructure. This patch replaces all
+        static_cast<SVGStyledElement> instances with toSVGStyledElement.
+
+        Additionally, this patch renames SVGElement::isStyled to SVGElement::isSVGStyledElement to
+        remove a confusing overlap with html styled elements. This name differs slighly from the
+        other is*() functions in SVGElement but this will be resolved up with webkit.org/b/107386.
+
+        No new tests as this is covered with existing tests.
+
+        * rendering/svg/RenderSVGModelObject.cpp:
+        (WebCore::getElementCTM):
+        * rendering/svg/RenderSVGResourceClipper.cpp:
+        (WebCore::RenderSVGResourceClipper::drawContentIntoMaskImage):
+        (WebCore::RenderSVGResourceClipper::calculateClipContentRepaintRect):
+        (WebCore::RenderSVGResourceClipper::hitTestClipContent):
+        * rendering/svg/RenderSVGResourceMasker.cpp:
+        (WebCore::RenderSVGResourceMasker::drawContentIntoMaskImage):
+        (WebCore::RenderSVGResourceMasker::calculateMaskContentRepaintRect):
+        * rendering/svg/RenderSVGResourcePattern.cpp:
+        (WebCore::RenderSVGResourcePattern::createTileImage):
+        * rendering/svg/SVGRenderSupport.cpp:
+        (WebCore::SVGRenderSupport::layoutChildren):
+        * rendering/svg/SVGResources.cpp:
+        (WebCore::registerPendingResource):
+        * svg/SVGAnimationElement.cpp:
+        (WebCore::SVGAnimationElement::isTargetAttributeCSSProperty):
+        (WebCore::SVGAnimationElement::computeCSSPropertyValue):
+        (WebCore::SVGAnimationElement::adjustForInheritance):
+        (WebCore::inheritsFromProperty):
+        * svg/SVGElement.cpp:
+        (WebCore::collectInstancesForSVGElement):
+        (WebCore::SVGElement::isAnimatableAttribute):
+        * svg/SVGElement.h:
+        (WebCore::SVGElement::isSVGStyledElement):
+        * svg/SVGElementInstance.cpp:
+        (WebCore::SVGElementInstance::invalidateAllInstancesOfElement):
+        (WebCore::SVGElementInstance::InstanceUpdateBlocker::InstanceUpdateBlocker):
+        * svg/SVGLocatable.cpp:
+        (WebCore::SVGLocatable::computeCTM):
+        * svg/SVGStyledElement.cpp:
+        (WebCore::SVGStyledElement::updateRelativeLengthsInformation):
+        * svg/SVGStyledElement.h:
+        (WebCore::SVGStyledElement::isSVGStyledElement):
+        * svg/SVGUseElement.cpp:
+        (WebCore::SVGUseElement::selfHasRelativeLengths):
+        * svg/graphics/filters/SVGFEImage.cpp:
+        (WebCore::FEImage::platformApplySoftware):
+
 2013-03-11  Tim Horton  <[email protected]>
 
         PDFPlugin: Make scrolling between pages in non-continuous modes work

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGModelObject.cpp (145432 => 145433)


--- trunk/Source/WebCore/rendering/svg/RenderSVGModelObject.cpp	2013-03-11 23:47:20 UTC (rev 145432)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGModelObject.cpp	2013-03-11 23:48:37 UTC (rev 145433)
@@ -132,7 +132,7 @@
 
     while (current && current->isSVGElement()) {
         SVGElement* currentElement = toSVGElement(current);
-        if (currentElement->isStyled()) {
+        if (currentElement->isSVGStyledElement()) {
             localTransform = currentElement->renderer()->localToParentTransform();
             transform = localTransform.multiply(transform);
         }

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp (145432 => 145433)


--- trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp	2013-03-11 23:47:20 UTC (rev 145432)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp	2013-03-11 23:48:37 UTC (rev 145433)
@@ -234,7 +234,7 @@
     // Draw all clipPath children into a global mask.
     for (Node* childNode = node()->firstChild(); childNode; childNode = childNode->nextSibling()) {
         RenderObject* renderer = childNode->renderer();
-        if (!childNode->isSVGElement() || !toSVGElement(childNode)->isStyled() || !renderer)
+        if (!childNode->isSVGElement() || !toSVGElement(childNode)->isSVGStyledElement() || !renderer)
             continue;
         if (renderer->needsLayout()) {
             frame()->view()->setPaintBehavior(oldBehavior);
@@ -276,7 +276,7 @@
     // This is a rough heuristic to appraise the clip size and doesn't consider clip on clip.
     for (Node* childNode = node()->firstChild(); childNode; childNode = childNode->nextSibling()) {
         RenderObject* renderer = childNode->renderer();
-        if (!childNode->isSVGElement() || !toSVGElement(childNode)->isStyled() || !renderer)
+        if (!childNode->isSVGElement() || !toSVGElement(childNode)->isSVGStyledElement() || !renderer)
             continue;
         if (!renderer->isSVGShape() && !renderer->isSVGText() && !childNode->hasTagName(SVGNames::useTag))
             continue;
@@ -306,7 +306,7 @@
 
     for (Node* childNode = node()->firstChild(); childNode; childNode = childNode->nextSibling()) {
         RenderObject* renderer = childNode->renderer();
-        if (!childNode->isSVGElement() || !toSVGElement(childNode)->isStyled() || !renderer)
+        if (!childNode->isSVGElement() || !toSVGElement(childNode)->isSVGStyledElement() || !renderer)
             continue;
         if (!renderer->isSVGShape() && !renderer->isSVGText() && !childNode->hasTagName(SVGNames::useTag))
             continue;

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp (145432 => 145433)


--- trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp	2013-03-11 23:47:20 UTC (rev 145432)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp	2013-03-11 23:48:37 UTC (rev 145433)
@@ -137,7 +137,7 @@
     // Draw the content into the ImageBuffer.
     for (Node* node = maskElement->firstChild(); node; node = node->nextSibling()) {
         RenderObject* renderer = node->renderer();
-        if (!node->isSVGElement() || !toSVGElement(node)->isStyled() || !renderer)
+        if (!node->isSVGElement() || !toSVGElement(node)->isSVGStyledElement() || !renderer)
             continue;
         if (renderer->needsLayout())
             return false;
@@ -166,7 +166,7 @@
 {
     for (Node* childNode = node()->firstChild(); childNode; childNode = childNode->nextSibling()) {
         RenderObject* renderer = childNode->renderer();
-        if (!childNode->isSVGElement() || !toSVGElement(childNode)->isStyled() || !renderer)
+        if (!childNode->isSVGElement() || !toSVGElement(childNode)->isSVGStyledElement() || !renderer)
             continue;
         RenderStyle* style = renderer->style();
         if (!style || style->display() == NONE || style->visibility() != VISIBLE)

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp (145432 => 145433)


--- trunk/Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp	2013-03-11 23:47:20 UTC (rev 145432)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp	2013-03-11 23:48:37 UTC (rev 145433)
@@ -269,7 +269,7 @@
 
     // Draw the content into the ImageBuffer.
     for (Node* node = attributes.patternContentElement()->firstChild(); node; node = node->nextSibling()) {
-        if (!node->isSVGElement() || !toSVGElement(node)->isStyled() || !node->renderer())
+        if (!node->isSVGElement() || !toSVGElement(node)->isSVGStyledElement() || !node->renderer())
             continue;
         if (node->renderer()->needsLayout())
             return nullptr;

Modified: trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp (145432 => 145433)


--- trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp	2013-03-11 23:47:20 UTC (rev 145432)
+++ trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp	2013-03-11 23:48:37 UTC (rev 145433)
@@ -254,7 +254,7 @@
         if (layoutSizeChanged) {
             // When selfNeedsLayout is false and the layout size changed, we have to check whether this child uses relative lengths
             if (SVGElement* element = child->node()->isSVGElement() ? toSVGElement(child->node()) : 0) {
-                if (element->isStyled() && static_cast<SVGStyledElement*>(element)->hasRelativeLengths()) {
+                if (element->isSVGStyledElement() && toSVGStyledElement(element)->hasRelativeLengths()) {
                     // When the layout size changed and when using relative values tell the RenderSVGShape to update its shape object
                     if (child->isSVGShape())
                         toRenderSVGShape(child)->setNeedsShapeUpdate();

Modified: trunk/Source/WebCore/rendering/svg/SVGResources.cpp (145432 => 145433)


--- trunk/Source/WebCore/rendering/svg/SVGResources.cpp	2013-03-11 23:47:20 UTC (rev 145432)
+++ trunk/Source/WebCore/rendering/svg/SVGResources.cpp	2013-03-11 23:48:37 UTC (rev 145433)
@@ -179,8 +179,8 @@
 static inline void registerPendingResource(SVGDocumentExtensions* extensions, const AtomicString& id, SVGElement* element)
 {
     ASSERT(element);
-    ASSERT_WITH_SECURITY_IMPLICATION(element->isStyled());
-    extensions->addPendingResource(id, static_cast<SVGStyledElement*>(element));
+    ASSERT_WITH_SECURITY_IMPLICATION(element->isSVGStyledElement());
+    extensions->addPendingResource(id, toSVGStyledElement(element));
 }
 
 bool SVGResources::buildCachedResources(const RenderObject* object, const SVGRenderStyle* style)

Modified: trunk/Source/WebCore/svg/SVGAnimationElement.cpp (145432 => 145433)


--- trunk/Source/WebCore/svg/SVGAnimationElement.cpp	2013-03-11 23:47:20 UTC (rev 145432)
+++ trunk/Source/WebCore/svg/SVGAnimationElement.cpp	2013-03-11 23:48:37 UTC (rev 145433)
@@ -354,7 +354,7 @@
 bool SVGAnimationElement::isTargetAttributeCSSProperty(SVGElement* targetElement, const QualifiedName& attributeName)
 {
     ASSERT(targetElement);
-    if (!targetElement->isStyled())
+    if (!targetElement->isSVGStyledElement())
         return false;
 
     return SVGStyledElement::isAnimatableCSSProperty(attributeName);
@@ -635,7 +635,7 @@
 void SVGAnimationElement::computeCSSPropertyValue(SVGElement* element, CSSPropertyID id, String& value)
 {
     ASSERT(element);
-    ASSERT(element->isStyled());
+    ASSERT(element->isSVGStyledElement());
 
     // Don't include any properties resulting from CSS Transitions/Animations or SMIL animations, as we want to retrieve the "base value".
     element->setUseOverrideComputedStyle(true);
@@ -654,7 +654,7 @@
         return;
 
     SVGElement* svgParent = toSVGElement(parent);
-    if (!svgParent->isStyled())
+    if (!svgParent->isSVGStyledElement())
         return;
     computeCSSPropertyValue(svgParent, cssPropertyID(attributeName.localName()), value);
 }
@@ -664,7 +664,7 @@
     ASSERT(targetElement);
     DEFINE_STATIC_LOCAL(const AtomicString, inherit, ("inherit", AtomicString::ConstructFromLiteral));
     
-    if (value.isEmpty() || value != inherit || !targetElement->isStyled())
+    if (value.isEmpty() || value != inherit || !targetElement->isSVGStyledElement())
         return false;
     return SVGStyledElement::isAnimatableCSSProperty(attributeName);
 }

Modified: trunk/Source/WebCore/svg/SVGElement.cpp (145432 => 145433)


--- trunk/Source/WebCore/svg/SVGElement.cpp	2013-03-11 23:47:20 UTC (rev 145432)
+++ trunk/Source/WebCore/svg/SVGElement.cpp	2013-03-11 23:48:37 UTC (rev 145433)
@@ -357,10 +357,10 @@
     if (element->containingShadowRoot())
         return;
 
-    if (!element->isStyled())
+    if (!element->isSVGStyledElement())
         return;
 
-    SVGStyledElement* styledElement = static_cast<SVGStyledElement*>(element);
+    SVGStyledElement* styledElement = toSVGStyledElement(element);
     ASSERT(!styledElement->instanceUpdatesBlocked());
 
     instances = styledElement->instancesForElement();
@@ -728,7 +728,7 @@
     }
 
     if (name == classAttr)
-        return isStyled();
+        return isSVGStyledElement();
 
     return animatableAttributes.contains(name);
 }

Modified: trunk/Source/WebCore/svg/SVGElement.h (145432 => 145433)


--- trunk/Source/WebCore/svg/SVGElement.h	2013-03-11 23:47:20 UTC (rev 145432)
+++ trunk/Source/WebCore/svg/SVGElement.h	2013-03-11 23:48:37 UTC (rev 145433)
@@ -57,7 +57,7 @@
 
     SVGDocumentExtensions* accessDocumentSVGExtensions();
 
-    virtual bool isStyled() const { return false; }
+    virtual bool isSVGStyledElement() const { return false; }
     virtual bool isStyledTransformable() const { return false; }
     virtual bool isStyledLocatable() const { return false; }
     virtual bool isSVG() const { return false; }

Modified: trunk/Source/WebCore/svg/SVGElementInstance.cpp (145432 => 145433)


--- trunk/Source/WebCore/svg/SVGElementInstance.cpp	2013-03-11 23:47:20 UTC (rev 145432)
+++ trunk/Source/WebCore/svg/SVGElementInstance.cpp	2013-03-11 23:48:37 UTC (rev 145433)
@@ -125,7 +125,7 @@
     if (!element || !element->inDocument())
         return;
 
-    if (element->isStyled() && static_cast<SVGStyledElement*>(element)->instanceUpdatesBlocked())
+    if (element->isSVGStyledElement() && toSVGStyledElement(element)->instanceUpdatesBlocked())
         return;
 
     const HashSet<SVGElementInstance*>& set = element->instancesForElement();
@@ -199,7 +199,7 @@
 }
 
 SVGElementInstance::InstanceUpdateBlocker::InstanceUpdateBlocker(SVGElement* targetElement)
-    : m_targetElement(targetElement->isStyled() ? static_cast<SVGStyledElement*>(targetElement) : 0)
+    : m_targetElement(targetElement->isSVGStyledElement() ? toSVGStyledElement(targetElement) : 0)
 {
     if (m_targetElement)
         m_targetElement->setInstanceUpdatesBlocked(true);

Modified: trunk/Source/WebCore/svg/SVGLocatable.cpp (145432 => 145433)


--- trunk/Source/WebCore/svg/SVGLocatable.cpp	2013-03-11 23:47:20 UTC (rev 145432)
+++ trunk/Source/WebCore/svg/SVGLocatable.cpp	2013-03-11 23:48:37 UTC (rev 145433)
@@ -88,8 +88,8 @@
         if (!currentElement->isSVGElement())
             break;
 
-        if (toSVGElement(currentElement)->isStyled())
-            ctm = static_cast<SVGStyledElement*>(currentElement)->localCoordinateSpaceTransform(mode).multiply(ctm);
+        if (toSVGElement(currentElement)->isSVGStyledElement())
+            ctm = toSVGStyledElement(currentElement)->localCoordinateSpaceTransform(mode).multiply(ctm);
 
         // For getCTM() computation, stop at the nearest viewport element
         if (currentElement == stopAtElement)

Modified: trunk/Source/WebCore/svg/SVGStyledElement.cpp (145432 => 145433)


--- trunk/Source/WebCore/svg/SVGStyledElement.cpp	2013-03-11 23:47:20 UTC (rev 145432)
+++ trunk/Source/WebCore/svg/SVGStyledElement.cpp	2013-03-11 23:48:37 UTC (rev 145433)
@@ -456,13 +456,13 @@
             break;
 
         SVGElement* element = toSVGElement(node);
-        if (!element->isStyled()) {
+        if (!element->isSVGStyledElement()) {
             node = node->parentNode();
             continue;
         }
 
         // Register us in the parent element map.
-        static_cast<SVGStyledElement*>(element)->updateRelativeLengthsInformation(hasRelativeLengths, this);
+        toSVGStyledElement(element)->updateRelativeLengthsInformation(hasRelativeLengths, this);
         break;
     }
 }

Modified: trunk/Source/WebCore/svg/SVGStyledElement.h (145432 => 145433)


--- trunk/Source/WebCore/svg/SVGStyledElement.h	2013-03-11 23:47:20 UTC (rev 145432)
+++ trunk/Source/WebCore/svg/SVGStyledElement.h	2013-03-11 23:48:37 UTC (rev 145433)
@@ -79,7 +79,7 @@
     virtual bool selfHasRelativeLengths() const { return false; }
 
 private:
-    virtual bool isStyled() const { return true; }
+    virtual bool isSVGStyledElement() const OVERRIDE { return true; }
 
     virtual bool isKeyboardFocusable(KeyboardEvent*) const;
     virtual bool isMouseFocusable() const;

Modified: trunk/Source/WebCore/svg/SVGUseElement.cpp (145432 => 145433)


--- trunk/Source/WebCore/svg/SVGUseElement.cpp	2013-03-11 23:47:20 UTC (rev 145432)
+++ trunk/Source/WebCore/svg/SVGUseElement.cpp	2013-03-11 23:48:37 UTC (rev 145433)
@@ -947,10 +947,10 @@
         return false;
 
     SVGElement* element = m_targetElementInstance->correspondingElement();
-    if (!element || !element->isStyled())
+    if (!element || !element->isSVGStyledElement())
         return false;
 
-    return static_cast<SVGStyledElement*>(element)->hasRelativeLengths();
+    return toSVGStyledElement(element)->hasRelativeLengths();
 }
 
 void SVGUseElement::notifyFinished(CachedResource* resource)

Modified: trunk/Source/WebCore/svg/graphics/filters/SVGFEImage.cpp (145432 => 145433)


--- trunk/Source/WebCore/svg/graphics/filters/SVGFEImage.cpp	2013-03-11 23:47:20 UTC (rev 145432)
+++ trunk/Source/WebCore/svg/graphics/filters/SVGFEImage.cpp	2013-03-11 23:48:37 UTC (rev 145433)
@@ -126,7 +126,7 @@
         resultImage->context()->concatCTM(absoluteTransform);
 
         SVGElement* contextNode = toSVGElement(renderer->node());
-        if (contextNode->isStyled() && static_cast<SVGStyledElement*>(contextNode)->hasRelativeLengths()) {
+        if (contextNode->isSVGStyledElement() && toSVGStyledElement(contextNode)->hasRelativeLengths()) {
             SVGLengthContext lengthContext(contextNode);
             float width = 0;
             float height = 0;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to