Diff
Modified: trunk/Source/WebCore/ChangeLog (173969 => 173970)
--- trunk/Source/WebCore/ChangeLog 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/ChangeLog 2014-09-25 17:25:43 UTC (rev 173970)
@@ -1,3 +1,135 @@
+2014-09-25 Christophe Dumez <[email protected]>
+
+ Stop using legacy NODE_TYPE_CASTS() macro in svg/
+ https://bugs.webkit.org/show_bug.cgi?id=137106
+
+ Reviewed by Ryosuke Niwa.
+
+ Stop using legacy NODE_TYPE_CASTS() in svg/ and use the new
+ SPECIALIZE_TYPE_TRAITS_*() macro instead so that is<>() / downcast<>()
+ can be used for those types.
+
+ No new tests, no behavior change.
+
+ * css/CSSComputedStyleDeclaration.cpp:
+ (WebCore::ComputedStyleExtractor::propertyValue):
+ * dom/Element.h:
+ * dom/Node.h:
+ (WebCore::is):
+ * dom/make_names.pl:
+ (printTypeHelpers):
+ * html/HTMLElement.h:
+ * html/HTMLMediaElement.h:
+ * html/HTMLPlugInImageElement.h:
+ * html/LabelableElement.h:
+ * mathml/MathMLElement.h:
+ Rename NodeTypeCastTraits::is() to NodeTypeCastTraits::isType() to
+ avoid naming conflict with the global is<>() function. This was an
+ issue when is<>() was called from one of the template specializations.
+
+ * rendering/svg/RenderSVGBlock.h:
+ (WebCore::RenderSVGBlock::graphicsElement):
+ * rendering/svg/RenderSVGGradientStop.cpp:
+ (WebCore::RenderSVGGradientStop::gradientElement):
+ * rendering/svg/RenderSVGInline.h:
+ (WebCore::RenderSVGInline::graphicsElement):
+ * rendering/svg/RenderSVGResourceClipper.cpp:
+ (WebCore::RenderSVGResourceClipper::pathOnlyClipping):
+ * rendering/svg/RenderSVGResourceContainer.cpp:
+ (WebCore::RenderSVGResourceContainer::transformOnNonScalingStroke):
+ * rendering/svg/RenderSVGShape.h:
+ (WebCore::RenderSVGShape::graphicsElement):
+ * rendering/svg/RenderSVGTransformableContainer.h:
+ * rendering/svg/SVGRenderSupport.cpp:
+ (WebCore::SVGRenderSupport::updateMaskedAncestorShouldIsolateBlending):
+ * rendering/svg/SVGRenderTreeAsText.cpp:
+ (WebCore::operator<<):
+ * rendering/svg/SVGRenderingContext.cpp:
+ (WebCore::SVGRenderingContext::prepareToRenderSVGContent):
+ * rendering/svg/SVGResources.cpp:
+ (WebCore::targetReferenceFromResource):
+ * svg/SVGAElement.cpp:
+ (WebCore::SVGAElement::defaultEventHandler):
+ * svg/SVGAnimateElement.cpp:
+ (WebCore::SVGAnimateElement::calculateAnimatedValue):
+ (WebCore::isSVGAnimateElement): Deleted.
+ Use is<>() / downcast<>() where appropriate.
+
+ * svg/SVGAnimateElement.h:
+ (WebCore::isSVGAnimateElement):
+ Use SPECIALIZE_TYPE_TRAITS_*() instead of NODE_TYPE_CASTS() and add
+ overload for isSVGAnimateElement() taking an SVGElement in argument to
+ bypass the is<SVGElement>() check when the input type is an SVGElement.
+
+ * svg/SVGAnimationElement.cpp:
+ (WebCore::SVGAnimationElement::currentValuesForValuesAnimation):
+ * svg/SVGElement.cpp:
+ (WebCore::SVGElement::getBoundingBox):
+ Use is<>() / downcast<>() where appropriate.
+
+ * svg/SVGElement.h:
+ * svg/SVGFilterPrimitiveStandardAttributes.h:
+ Use SPECIALIZE_TYPE_TRAITS_*() instead of NODE_TYPE_CASTS() and drop
+ the pre-existing NodeTypeCastTraits template specialization as it is
+ now generated by the macro.
+
+ * svg/SVGGradientElement.cpp:
+ (WebCore::isSVGGradientElement): Deleted.
+ * svg/SVGGradientElement.h:
+ (WebCore::isSVGGradientElement):
+ Use SPECIALIZE_TYPE_TRAITS_*() instead of NODE_TYPE_CASTS() and add
+ overload for isSVGAnimateElement() taking an SVGElement in argument to
+ bypass the is<SVGElement>() check when the input type is an SVGElement.
+
+ * svg/SVGGraphicsElement.h:
+ (WebCore::isSVGGraphicsElement):
+ Use SPECIALIZE_TYPE_TRAITS_*() instead of NODE_TYPE_CASTS().
+
+ * svg/SVGLinearGradientElement.cpp:
+ (WebCore::SVGLinearGradientElement::collectGradientAttributes):
+ * svg/SVGLocatable.cpp:
+ (WebCore::SVGLocatable::getTransformToElement):
+ * svg/SVGPolyElement.cpp:
+ (WebCore::SVGPolyElement::synchronizePoints):
+ (WebCore::SVGPolyElement::lookupOrCreatePointsWrapper):
+ (WebCore::isSVGPolyElement): Deleted.
+ Use is<>() / downcast<>() where appropriate.
+
+ * svg/SVGPolyElement.h:
+ (WebCore::isSVGPolyElement):
+ Use SPECIALIZE_TYPE_TRAITS_*() instead of NODE_TYPE_CASTS() and add
+ overload for isPolyElement() taking an SVGElement in argument to
+ bypass the is<SVGElement>() check when the input type is an SVGElement.
+
+ * svg/SVGRadialGradientElement.cpp:
+ (WebCore::SVGRadialGradientElement::collectGradientAttributes):
+ * svg/SVGTextContentElement.cpp:
+ (WebCore::SVGTextContentElement::synchronizeTextLength):
+ (WebCore::SVGTextContentElement::lookupOrCreateTextLengthWrapper):
+ (WebCore::SVGTextContentElement::elementFromRenderer):
+ Use is<>() / downcast<>() where appropriate.
+
+ * svg/SVGTextContentElement.h:
+ WebCore::isSVGTextContentElement):
+ Use SPECIALIZE_TYPE_TRAITS_*() instead of NODE_TYPE_CASTS().
+
+ * svg/SVGUseElement.cpp:
+ (WebCore::SVGUseElement::toClipPath):
+ Use is<>() / downcast<>() where appropriate. Also use tighter typing
+ for value returned by shadowTreeElement().
+
+ * svg/animation/SVGSMILElement.cpp:
+ (WebCore::SVGSMILElement::buildPendingResource):
+ (WebCore::SVGSMILElement::connectConditions):
+ (WebCore::SVGSMILElement::disconnectConditions):
+ Use is<>() / downcast<>() where appropriate.
+
+ * svg/animation/SVGSMILElement.h:
+ (WebCore::isSVGSMILElement):
+ Use SPECIALIZE_TYPE_TRAITS_*() instead of NODE_TYPE_CASTS() and drop
+ the pre-existing NodeTypeCastTraits template specialization as it is
+ now generated by the macro.
+
2014-09-25 Brent Fulgham <[email protected]>
Minor refactoring to mediaType/presentationType
Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (173969 => 173970)
--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2014-09-25 17:25:43 UTC (rev 173970)
@@ -1712,7 +1712,7 @@
renderer = styledNode->renderer();
- if (propertyID == CSSPropertyDisplay && !renderer && isSVGElement(*styledNode) && !downcast<SVGElement>(*styledNode).isValid())
+ if (propertyID == CSSPropertyDisplay && !renderer && is<SVGElement>(*styledNode) && !downcast<SVGElement>(*styledNode).isValid())
return nullptr;
style = computeRenderStyleForProperty(styledNode, m_pseudoElementSpecifier, propertyID);
Modified: trunk/Source/WebCore/dom/Element.h (173969 => 173970)
--- trunk/Source/WebCore/dom/Element.h 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/dom/Element.h 2014-09-25 17:25:43 UTC (rev 173970)
@@ -672,7 +672,7 @@
template <>
struct NodeTypeCastTraits<const Element, const Node> {
- static bool is(const Node& node) { return node.isElementNode(); }
+ static bool isType(const Node& node) { return node.isElementNode(); }
};
inline bool Node::hasAttributes() const
Modified: trunk/Source/WebCore/dom/Node.h (173969 => 173970)
--- trunk/Source/WebCore/dom/Node.h 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/dom/Node.h 2014-09-25 17:25:43 UTC (rev 173970)
@@ -741,12 +741,12 @@
template <typename ExpectedType, typename ArgType>
struct NodeTypeCastTraits {
- static bool is(ArgType&);
+ static bool isType(ArgType&);
};
template <typename ExpectedType>
struct NodeTypeCastTraits<ExpectedType, ExpectedType> {
- static bool is(ExpectedType&) { return true; }
+ static bool isType(ExpectedType&) { return true; }
};
// Type checking function for Nodes, to use before casting with downcast<>().
@@ -754,7 +754,7 @@
inline bool is(ArgType& node)
{
static_assert(!std::is_base_of<ExpectedType, ArgType>::value, "Unnecessary type check");
- return NodeTypeCastTraits<const ExpectedType, const ArgType>::is(node);
+ return NodeTypeCastTraits<const ExpectedType, const ArgType>::isType(node);
}
template <typename ExpectedType, typename ArgType>
@@ -762,7 +762,7 @@
{
ASSERT(node);
static_assert(!std::is_base_of<ExpectedType, ArgType>::value, "Unnecessary type check");
- return NodeTypeCastTraits<const ExpectedType, const ArgType>::is(*node);
+ return NodeTypeCastTraits<const ExpectedType, const ArgType>::isType(*node);
}
// Downcasting functions for Node types.
@@ -785,7 +785,7 @@
template <typename ArgType> \
class NodeTypeCastTraits<const ClassName, ArgType> { \
public: \
- static bool is(ArgType& node) { return is##ClassName(node); } \
+ static bool isType(ArgType& node) { return is##ClassName(node); } \
private:
#define SPECIALIZE_TYPE_TRAITS_END() \
Modified: trunk/Source/WebCore/dom/make_names.pl (173969 => 173970)
--- trunk/Source/WebCore/dom/make_names.pl 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/dom/make_names.pl 2014-09-25 17:25:43 UTC (rev 173970)
@@ -638,7 +638,7 @@
template <typename ArgType>
class NodeTypeCastTraits<const $class, ArgType> {
public:
- static bool is(ArgType& node) { return checkTagName(node); }
+ static bool isType(ArgType& node) { return checkTagName(node); }
private:
END
;
Modified: trunk/Source/WebCore/html/HTMLElement.h (173969 => 173970)
--- trunk/Source/WebCore/html/HTMLElement.h 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/html/HTMLElement.h 2014-09-25 17:25:43 UTC (rev 173970)
@@ -151,7 +151,7 @@
template <typename ArgType>
struct NodeTypeCastTraits<const HTMLElement, ArgType> {
- static bool is(ArgType& node) { return isHTMLElement(node); }
+ static bool isType(ArgType& node) { return isHTMLElement(node); }
};
NODE_TYPE_CASTS(HTMLElement)
Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (173969 => 173970)
--- trunk/Source/WebCore/html/HTMLMediaElement.h 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h 2014-09-25 17:25:43 UTC (rev 173970)
@@ -916,7 +916,7 @@
template <typename ArgType>
struct NodeTypeCastTraits<const HTMLMediaElement, ArgType> {
- static bool is(ArgType& node) { return isHTMLMediaElement(node); }
+ static bool isType(ArgType& node) { return isHTMLMediaElement(node); }
};
NODE_TYPE_CASTS(HTMLMediaElement)
Modified: trunk/Source/WebCore/html/HTMLPlugInImageElement.h (173969 => 173970)
--- trunk/Source/WebCore/html/HTMLPlugInImageElement.h 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/html/HTMLPlugInImageElement.h 2014-09-25 17:25:43 UTC (rev 173970)
@@ -163,7 +163,7 @@
template <typename ArgType>
struct NodeTypeCastTraits<const HTMLPlugInImageElement, ArgType> {
- static bool is(ArgType& node) { return isHTMLPlugInImageElement(node); }
+ static bool isType(ArgType& node) { return isHTMLPlugInImageElement(node); }
};
NODE_TYPE_CASTS(HTMLPlugInImageElement)
Modified: trunk/Source/WebCore/html/LabelableElement.h (173969 => 173970)
--- trunk/Source/WebCore/html/LabelableElement.h 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/html/LabelableElement.h 2014-09-25 17:25:43 UTC (rev 173970)
@@ -56,7 +56,7 @@
template <typename ArgType>
struct NodeTypeCastTraits<const LabelableElement, ArgType> {
- static bool is(ArgType& node) { return isLabelableElement(node); }
+ static bool isType(ArgType& node) { return isLabelableElement(node); }
};
NODE_TYPE_CASTS(LabelableElement)
Modified: trunk/Source/WebCore/mathml/MathMLElement.h (173969 => 173970)
--- trunk/Source/WebCore/mathml/MathMLElement.h 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/mathml/MathMLElement.h 2014-09-25 17:25:43 UTC (rev 173970)
@@ -78,7 +78,7 @@
template <typename ArgType>
struct NodeTypeCastTraits<const MathMLElement, ArgType> {
- static bool is(ArgType& node) { return isMathMLElement(node); }
+ static bool isType(ArgType& node) { return isMathMLElement(node); }
};
NODE_TYPE_CASTS(MathMLElement)
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGBlock.h (173969 => 173970)
--- trunk/Source/WebCore/rendering/svg/RenderSVGBlock.h 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGBlock.h 2014-09-25 17:25:43 UTC (rev 173970)
@@ -32,7 +32,7 @@
public:
virtual LayoutRect visualOverflowRect() const override final;
- SVGGraphicsElement& graphicsElement() const { return toSVGGraphicsElement(nodeForNonAnonymous()); }
+ SVGGraphicsElement& graphicsElement() const { return downcast<SVGGraphicsElement>(nodeForNonAnonymous()); }
protected:
RenderSVGBlock(SVGGraphicsElement&, PassRef<RenderStyle>);
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGGradientStop.cpp (173969 => 173970)
--- trunk/Source/WebCore/rendering/svg/RenderSVGGradientStop.cpp 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGGradientStop.cpp 2014-09-25 17:25:43 UTC (rev 173970)
@@ -67,8 +67,8 @@
SVGGradientElement* RenderSVGGradientStop::gradientElement()
{
- if (element().parentElement() && isSVGGradientElement(*element().parentElement()))
- return &toSVGGradientElement(*element().parentElement());
+ if (element().parentElement() && is<SVGGradientElement>(*element().parentElement()))
+ return &downcast<SVGGradientElement>(*element().parentElement());
return nullptr;
}
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGInline.h (173969 => 173970)
--- trunk/Source/WebCore/rendering/svg/RenderSVGInline.h 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGInline.h 2014-09-25 17:25:43 UTC (rev 173970)
@@ -30,7 +30,7 @@
public:
RenderSVGInline(SVGGraphicsElement&, PassRef<RenderStyle>);
- SVGGraphicsElement& graphicsElement() const { return toSVGGraphicsElement(nodeForNonAnonymous()); }
+ SVGGraphicsElement& graphicsElement() const { return downcast<SVGGraphicsElement>(nodeForNonAnonymous()); }
private:
void element() const = delete;
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp (173969 => 173970)
--- trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp 2014-09-25 17:25:43 UTC (rev 173970)
@@ -96,7 +96,7 @@
return false;
if (!childNode->isSVGElement() || !downcast<SVGElement>(*childNode).isSVGGraphicsElement())
continue;
- SVGGraphicsElement& styled = toSVGGraphicsElement(*childNode);
+ SVGGraphicsElement& styled = downcast<SVGGraphicsElement>(*childNode);
const RenderStyle& style = renderer->style();
if (style.display() == NONE || style.visibility() != VISIBLE)
continue;
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourceContainer.cpp (173969 => 173970)
--- trunk/Source/WebCore/rendering/svg/RenderSVGResourceContainer.cpp 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResourceContainer.cpp 2014-09-25 17:25:43 UTC (rev 173970)
@@ -211,7 +211,7 @@
if (!object->isSVGShape())
return resourceTransform;
- SVGGraphicsElement* element = toSVGGraphicsElement(object->node());
+ SVGGraphicsElement* element = downcast<SVGGraphicsElement>(object->node());
AffineTransform transform = element->getScreenCTM(SVGLocatable::DisallowStyleUpdate);
transform *= resourceTransform;
return transform;
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGShape.h (173969 => 173970)
--- trunk/Source/WebCore/rendering/svg/RenderSVGShape.h 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGShape.h 2014-09-25 17:25:43 UTC (rev 173970)
@@ -49,7 +49,7 @@
RenderSVGShape(SVGGraphicsElement&, PassRef<RenderStyle>, Path*, bool);
virtual ~RenderSVGShape();
- SVGGraphicsElement& graphicsElement() const { return toSVGGraphicsElement(RenderSVGModelObject::element()); }
+ SVGGraphicsElement& graphicsElement() const { return downcast<SVGGraphicsElement>(RenderSVGModelObject::element()); }
void setNeedsShapeUpdate() { m_needsShapeUpdate = true; }
virtual void setNeedsBoundariesUpdate() override final { m_needsBoundariesUpdate = true; }
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGTransformableContainer.h (173969 => 173970)
--- trunk/Source/WebCore/rendering/svg/RenderSVGTransformableContainer.h 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGTransformableContainer.h 2014-09-25 17:25:43 UTC (rev 173970)
@@ -30,7 +30,7 @@
class RenderSVGTransformableContainer final : public RenderSVGContainer {
public:
RenderSVGTransformableContainer(SVGGraphicsElement&, PassRef<RenderStyle>);
- SVGGraphicsElement& graphicsElement() { return toSVGGraphicsElement(RenderSVGContainer::element()); }
+ SVGGraphicsElement& graphicsElement() { return downcast<SVGGraphicsElement>(RenderSVGContainer::element()); }
virtual bool isSVGTransformableContainer() const { return true; }
virtual const AffineTransform& localToParentTransform() const { return m_localTransform; }
Modified: trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp (173969 => 173970)
--- trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp 2014-09-25 17:25:43 UTC (rev 173970)
@@ -464,7 +464,7 @@
continue;
if (ancestor->computedStyle()->svgStyle().hasMasker())
- toSVGGraphicsElement(*ancestor).setShouldIsolateBlending(maskedAncestorShouldIsolateBlending);
+ downcast<SVGGraphicsElement>(*ancestor).setShouldIsolateBlending(maskedAncestorShouldIsolateBlending);
return;
}
Modified: trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp (173969 => 173970)
--- trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp 2014-09-25 17:25:43 UTC (rev 173970)
@@ -343,8 +343,8 @@
writeNameValuePair(ts, "cx", element.cx().value(lengthContext));
writeNameValuePair(ts, "cy", element.cy().value(lengthContext));
writeNameValuePair(ts, "r", element.r().value(lengthContext));
- } else if (svgElement.hasTagName(SVGNames::polygonTag) || svgElement.hasTagName(SVGNames::polylineTag)) {
- const SVGPolyElement& element = toSVGPolyElement(svgElement);
+ } else if (is<SVGPolyElement>(svgElement)) {
+ const SVGPolyElement& element = downcast<SVGPolyElement>(svgElement);
writeNameAndQuotedValue(ts, "points", element.pointList().valueAsString());
} else if (is<SVGPathElement>(svgElement)) {
const SVGPathElement& element = downcast<SVGPathElement>(svgElement);
Modified: trunk/Source/WebCore/rendering/svg/SVGRenderingContext.cpp (173969 => 173970)
--- trunk/Source/WebCore/rendering/svg/SVGRenderingContext.cpp 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/rendering/svg/SVGRenderingContext.cpp 2014-09-25 17:25:43 UTC (rev 173970)
@@ -105,8 +105,8 @@
bool isolateMaskForBlending = false;
#if ENABLE(CSS_COMPOSITING)
- if (svgStyle.hasMasker() && downcast<SVGElement>(renderer.element())->isSVGGraphicsElement()) {
- SVGGraphicsElement& graphicsElement = toSVGGraphicsElement(*renderer.element());
+ if (svgStyle.hasMasker() && is<SVGGraphicsElement>(downcast<SVGElement>(renderer.element()))) {
+ SVGGraphicsElement& graphicsElement = downcast<SVGGraphicsElement>(*renderer.element());
isolateMaskForBlending = graphicsElement.shouldIsolateBlending();
}
#endif
Modified: trunk/Source/WebCore/rendering/svg/SVGResources.cpp (173969 => 173970)
--- trunk/Source/WebCore/rendering/svg/SVGResources.cpp 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/rendering/svg/SVGResources.cpp 2014-09-25 17:25:43 UTC (rev 173970)
@@ -143,8 +143,8 @@
String target;
if (is<SVGPatternElement>(element))
target = downcast<SVGPatternElement>(element).href();
- else if (isSVGGradientElement(element))
- target = toSVGGradientElement(element).href();
+ else if (is<SVGGradientElement>(element))
+ target = downcast<SVGGradientElement>(element).href();
else if (is<SVGFilterElement>(element))
target = downcast<SVGFilterElement>(element).href();
else
Modified: trunk/Source/WebCore/svg/SVGAElement.cpp (173969 => 173970)
--- trunk/Source/WebCore/svg/SVGAElement.cpp 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/svg/SVGAElement.cpp 2014-09-25 17:25:43 UTC (rev 173970)
@@ -160,8 +160,8 @@
if (url[0] == '#') {
Element* targetElement = treeScope().getElementById(url.substringSharingImpl(1));
- if (targetElement && isSVGSMILElement(*targetElement)) {
- toSVGSMILElement(*targetElement).beginByLinkActivation();
+ if (targetElement && is<SVGSMILElement>(*targetElement)) {
+ downcast<SVGSMILElement>(*targetElement).beginByLinkActivation();
event->setDefaultHandled();
return;
}
Modified: trunk/Source/WebCore/svg/SVGAnimateElement.cpp (173969 => 173970)
--- trunk/Source/WebCore/svg/SVGAnimateElement.cpp 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/svg/SVGAnimateElement.cpp 2014-09-25 17:25:43 UTC (rev 173970)
@@ -110,7 +110,7 @@
ASSERT(m_fromType->type() == m_animatedPropertyType);
ASSERT(m_toType);
- SVGAnimateElement& resultAnimationElement = toSVGAnimateElement(*resultElement);
+ SVGAnimateElement& resultAnimationElement = downcast<SVGAnimateElement>(*resultElement);
ASSERT(resultAnimationElement.m_animatedType);
ASSERT(resultAnimationElement.m_animatedPropertyType == m_animatedPropertyType);
@@ -459,12 +459,4 @@
return m_animator.get();
}
-bool isSVGAnimateElement(const Node& node)
-{
- return node.hasTagName(SVGNames::animateTag)
- || node.hasTagName(SVGNames::animateColorTag)
- || node.hasTagName(SVGNames::animateTransformTag)
- || node.hasTagName(SVGNames::setTag);
}
-
-}
Modified: trunk/Source/WebCore/svg/SVGAnimateElement.h (173969 => 173970)
--- trunk/Source/WebCore/svg/SVGAnimateElement.h 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/svg/SVGAnimateElement.h 2014-09-25 17:25:43 UTC (rev 173970)
@@ -74,9 +74,14 @@
std::unique_ptr<SVGAnimatedTypeAnimator> m_animator;
};
-void isSVGAnimateElement(const SVGAnimateElement&); // Catch unnecessary runtime check of type known at compile time.
-bool isSVGAnimateElement(const Node&);
-NODE_TYPE_CASTS(SVGAnimateElement)
+SPECIALIZE_TYPE_TRAITS_BEGIN(SVGAnimateElement)
+ static bool isSVGAnimateElement(const SVGElement& element)
+ {
+ return element.hasTagName(SVGNames::animateTag) || element.hasTagName(SVGNames::animateColorTag)
+ || element.hasTagName(SVGNames::animateTransformTag) || element.hasTagName(SVGNames::setTag);
+ }
+ static bool isSVGAnimateElement(const Node& node) { return is<SVGElement>(node) && isSVGAnimateElement(downcast<SVGElement>(node)); }
+SPECIALIZE_TYPE_TRAITS_END()
} // namespace WebCore
Modified: trunk/Source/WebCore/svg/SVGAnimationElement.cpp (173969 => 173970)
--- trunk/Source/WebCore/svg/SVGAnimationElement.cpp 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/svg/SVGAnimationElement.cpp 2014-09-25 17:25:43 UTC (rev 173970)
@@ -508,7 +508,7 @@
CalcMode calcMode = this->calcMode();
if (hasTagName(SVGNames::animateTag) || hasTagName(SVGNames::animateColorTag)) {
- AnimatedPropertyType attributeType = toSVGAnimateElement(*this).determineAnimatedPropertyType(targetElement());
+ AnimatedPropertyType attributeType = downcast<SVGAnimateElement>(*this).determineAnimatedPropertyType(targetElement());
// Fall back to discrete animations for Strings.
if (attributeType == AnimatedBoolean
|| attributeType == AnimatedEnumeration
Modified: trunk/Source/WebCore/svg/SVGElement.cpp (173969 => 173970)
--- trunk/Source/WebCore/svg/SVGElement.cpp 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/svg/SVGElement.cpp 2014-09-25 17:25:43 UTC (rev 173970)
@@ -452,8 +452,8 @@
bool SVGElement::getBoundingBox(FloatRect& rect, SVGLocatable::StyleUpdateStrategy styleUpdateStrategy)
{
- if (isSVGGraphicsElement()) {
- rect = toSVGGraphicsElement(*this).getBBox(styleUpdateStrategy);
+ if (is<SVGGraphicsElement>(*this)) {
+ rect = downcast<SVGGraphicsElement>(*this).getBBox(styleUpdateStrategy);
return true;
}
return false;
Modified: trunk/Source/WebCore/svg/SVGElement.h (173969 => 173970)
--- trunk/Source/WebCore/svg/SVGElement.h 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/svg/SVGElement.h 2014-09-25 17:25:43 UTC (rev 173970)
@@ -221,16 +221,10 @@
static bool equal(const QualifiedName& a, const QualifiedName& b) { return a.matches(b); }
};
-void isSVGElement(const SVGElement&); // Catch unnecessary runtime check of type known at compile time.
-inline bool isSVGElement(const Node& node) { return node.isSVGElement(); }
+SPECIALIZE_TYPE_TRAITS_BEGIN(SVGElement)
+ static bool isSVGElement(const Node& node) { return node.isSVGElement(); }
+SPECIALIZE_TYPE_TRAITS_END()
-template <typename ArgType>
-struct NodeTypeCastTraits<const SVGElement, ArgType> {
- static bool is(ArgType& node) { return isSVGElement(node); }
-};
-
-NODE_TYPE_CASTS(SVGElement)
-
inline bool Node::hasTagName(const SVGQualifiedName& name) const
{
return isSVGElement() && downcast<SVGElement>(*this).hasTagName(name);
Modified: trunk/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h (173969 => 173970)
--- trunk/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h 2014-09-25 17:25:43 UTC (rev 173970)
@@ -82,18 +82,11 @@
void invalidateFilterPrimitiveParent(SVGElement*);
-void isSVGFilterPrimitiveStandardAttributes(const SVGFilterPrimitiveStandardAttributes&); // Catch unnecessary runtime check of type known at compile time.
-inline bool isSVGFilterPrimitiveStandardAttributes(const SVGElement& element) { return element.isFilterEffect(); }
-inline bool isSVGFilterPrimitiveStandardAttributes(const Node& node) { return node.isSVGElement() && downcast<SVGElement>(node).isFilterEffect(); }
+SPECIALIZE_TYPE_TRAITS_BEGIN(SVGFilterPrimitiveStandardAttributes)
+ static bool isSVGFilterPrimitiveStandardAttributes(const SVGElement& element) { return element.isFilterEffect(); }
+ static bool isSVGFilterPrimitiveStandardAttributes(const Node& node) { return is<SVGElement>(node) && isSVGFilterPrimitiveStandardAttributes(downcast<SVGElement>(node)); }
+SPECIALIZE_TYPE_TRAITS_END()
-template <typename ArgType>
-struct NodeTypeCastTraits<const SVGFilterPrimitiveStandardAttributes, ArgType> {
- static bool is(ArgType& node) { return isSVGFilterPrimitiveStandardAttributes(node); }
-};
-
-NODE_TYPE_CASTS(SVGFilterPrimitiveStandardAttributes)
-
-
} // namespace WebCore
#endif
Modified: trunk/Source/WebCore/svg/SVGGradientElement.cpp (173969 => 173970)
--- trunk/Source/WebCore/svg/SVGGradientElement.cpp 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/svg/SVGGradientElement.cpp 2014-09-25 17:25:43 UTC (rev 173970)
@@ -160,9 +160,4 @@
return stops;
}
-bool isSVGGradientElement(const Node& node)
-{
- return node.hasTagName(SVGNames::radialGradientTag) || node.hasTagName(SVGNames::linearGradientTag);
}
-
-}
Modified: trunk/Source/WebCore/svg/SVGGradientElement.h (173969 => 173970)
--- trunk/Source/WebCore/svg/SVGGradientElement.h 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/svg/SVGGradientElement.h 2014-09-25 17:25:43 UTC (rev 173970)
@@ -107,9 +107,16 @@
END_DECLARE_ANIMATED_PROPERTIES
};
-void isSVGGradientElement(const SVGGradientElement&); // Catch unnecessary runtime check of type known at compile time.
-bool isSVGGradientElement(const Node&);
-NODE_TYPE_CASTS(SVGGradientElement)
+SPECIALIZE_TYPE_TRAITS_BEGIN(SVGGradientElement)
+static bool isSVGGradientElement(const SVGElement& element)
+{
+ return element.hasTagName(SVGNames::radialGradientTag) || element.hasTagName(SVGNames::linearGradientTag);
+}
+static bool isSVGGradientElement(const Node& node)
+{
+ return is<SVGElement>(node) && isSVGGradientElement(downcast<SVGElement>(node));
+}
+SPECIALIZE_TYPE_TRAITS_END()
} // namespace WebCore
Modified: trunk/Source/WebCore/svg/SVGGraphicsElement.h (173969 => 173970)
--- trunk/Source/WebCore/svg/SVGGraphicsElement.h 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/svg/SVGGraphicsElement.h 2014-09-25 17:25:43 UTC (rev 173970)
@@ -82,10 +82,10 @@
bool m_shouldIsolateBlending;
};
-void isSVGGraphicsElement(const SVGGraphicsElement&); // Catch unnecessary runtime check of type known at compile time.
-inline bool isSVGGraphicsElement(const SVGElement& element) { return element.isSVGGraphicsElement(); }
-inline bool isSVGGraphicsElement(const Node& node) { return node.isSVGElement() && downcast<SVGElement>(node).isSVGGraphicsElement(); }
-NODE_TYPE_CASTS(SVGGraphicsElement)
+SPECIALIZE_TYPE_TRAITS_BEGIN(SVGGraphicsElement)
+ static bool isSVGGraphicsElement(const SVGElement& element) { return element.isSVGGraphicsElement(); }
+ static bool isSVGGraphicsElement(const Node& node) { return is<SVGElement>(node) && isSVGGraphicsElement(downcast<SVGElement>(node)); }
+SPECIALIZE_TYPE_TRAITS_END()
} // namespace WebCore
Modified: trunk/Source/WebCore/svg/SVGLinearGradientElement.cpp (173969 => 173970)
--- trunk/Source/WebCore/svg/SVGLinearGradientElement.cpp 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/svg/SVGLinearGradientElement.cpp 2014-09-25 17:25:43 UTC (rev 173970)
@@ -173,8 +173,8 @@
while (true) {
// Respect xlink:href, take attributes from referenced element
Node* refNode = SVGURIReference::targetElementFromIRIString(current->href(), document());
- if (refNode && isSVGGradientElement(*refNode)) {
- current = toSVGGradientElement(refNode);
+ if (refNode && is<SVGGradientElement>(*refNode)) {
+ current = downcast<SVGGradientElement>(refNode);
// Cycle detection
if (processedGradients.contains(current))
Modified: trunk/Source/WebCore/svg/SVGLocatable.cpp (173969 => 173970)
--- trunk/Source/WebCore/svg/SVGLocatable.cpp 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/svg/SVGLocatable.cpp 2014-09-25 17:25:43 UTC (rev 173970)
@@ -101,8 +101,8 @@
{
AffineTransform ctm = getCTM(styleUpdateStrategy);
- if (target && target->isSVGGraphicsElement()) {
- AffineTransform targetCTM = toSVGGraphicsElement(*target).getCTM(styleUpdateStrategy);
+ if (target && is<SVGGraphicsElement>(target)) {
+ AffineTransform targetCTM = downcast<SVGGraphicsElement>(*target).getCTM(styleUpdateStrategy);
if (!targetCTM.isInvertible()) {
ec = SVGException::SVG_MATRIX_NOT_INVERTABLE;
return ctm;
Modified: trunk/Source/WebCore/svg/SVGPolyElement.cpp (173969 => 173970)
--- trunk/Source/WebCore/svg/SVGPolyElement.cpp 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/svg/SVGPolyElement.cpp 2014-09-25 17:25:43 UTC (rev 173970)
@@ -132,7 +132,7 @@
void SVGPolyElement::synchronizePoints(SVGElement* contextElement)
{
ASSERT(contextElement);
- SVGPolyElement& ownerType = toSVGPolyElement(*contextElement);
+ SVGPolyElement& ownerType = downcast<SVGPolyElement>(*contextElement);
if (!ownerType.m_points.shouldSynchronize)
return;
ownerType.m_points.synchronize(&ownerType, pointsPropertyInfo()->attributeName, ownerType.m_points.value.valueAsString());
@@ -141,7 +141,7 @@
PassRefPtr<SVGAnimatedProperty> SVGPolyElement::lookupOrCreatePointsWrapper(SVGElement* contextElement)
{
ASSERT(contextElement);
- SVGPolyElement& ownerType = toSVGPolyElement(*contextElement);
+ SVGPolyElement& ownerType = downcast<SVGPolyElement>(*contextElement);
return SVGAnimatedProperty::lookupOrCreateWrapper<SVGPolyElement, SVGAnimatedPointList, SVGPointList>
(&ownerType, pointsPropertyInfo(), ownerType.m_points.value);
}
@@ -158,9 +158,4 @@
return static_cast<SVGListPropertyTearOff<SVGPointList>*>(static_pointer_cast<SVGAnimatedPointList>(lookupOrCreatePointsWrapper(this))->animVal());
}
-bool isSVGPolyElement(const Node& node)
-{
- return node.hasTagName(SVGNames::polygonTag) || node.hasTagName(SVGNames::polylineTag);
}
-
-}
Modified: trunk/Source/WebCore/svg/SVGPolyElement.h (173969 => 173970)
--- trunk/Source/WebCore/svg/SVGPolyElement.h 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/svg/SVGPolyElement.h 2014-09-25 17:25:43 UTC (rev 173970)
@@ -62,9 +62,10 @@
mutable SVGSynchronizableAnimatedProperty<SVGPointList> m_points;
};
-void isSVGPolyElement(const SVGPolyElement&); // Catch unnecessary runtime check of type known at compile time.
-bool isSVGPolyElement(const Node&);
-NODE_TYPE_CASTS(SVGPolyElement)
+SPECIALIZE_TYPE_TRAITS_BEGIN(SVGPolyElement)
+ static bool isSVGPolyElement(const SVGElement& element) { return element.hasTagName(SVGNames::polygonTag) || element.hasTagName(SVGNames::polylineTag); }
+ static bool isSVGPolyElement(const Node& node) { return is<SVGElement>(node) && isSVGPolyElement(downcast<SVGElement>(node)); }
+SPECIALIZE_TYPE_TRAITS_END()
} // namespace WebCore
Modified: trunk/Source/WebCore/svg/SVGRadialGradientElement.cpp (173969 => 173970)
--- trunk/Source/WebCore/svg/SVGRadialGradientElement.cpp 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/svg/SVGRadialGradientElement.cpp 2014-09-25 17:25:43 UTC (rev 173970)
@@ -191,8 +191,8 @@
while (true) {
// Respect xlink:href, take attributes from referenced element
Node* refNode = SVGURIReference::targetElementFromIRIString(current->href(), document());
- if (refNode && isSVGGradientElement(*refNode)) {
- current = toSVGGradientElement(refNode);
+ if (refNode && is<SVGGradientElement>(*refNode)) {
+ current = downcast<SVGGradientElement>(refNode);
// Cycle detection
if (processedGradients.contains(current))
Modified: trunk/Source/WebCore/svg/SVGTextContentElement.cpp (173969 => 173970)
--- trunk/Source/WebCore/svg/SVGTextContentElement.cpp 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/svg/SVGTextContentElement.cpp 2014-09-25 17:25:43 UTC (rev 173970)
@@ -75,7 +75,7 @@
void SVGTextContentElement::synchronizeTextLength(SVGElement* contextElement)
{
ASSERT(contextElement);
- SVGTextContentElement& ownerType = toSVGTextContentElement(*contextElement);
+ SVGTextContentElement& ownerType = downcast<SVGTextContentElement>(*contextElement);
if (!ownerType.m_textLength.shouldSynchronize)
return;
AtomicString value(SVGPropertyTraits<SVGLength>::toString(ownerType.m_specifiedTextLength));
@@ -85,7 +85,7 @@
PassRefPtr<SVGAnimatedProperty> SVGTextContentElement::lookupOrCreateTextLengthWrapper(SVGElement* contextElement)
{
ASSERT(contextElement);
- SVGTextContentElement& ownerType = toSVGTextContentElement(*contextElement);
+ SVGTextContentElement& ownerType = downcast<SVGTextContentElement>(*contextElement);
return SVGAnimatedProperty::lookupOrCreateWrapper<SVGTextContentElement, SVGAnimatedLength, SVGLength>
(&ownerType, textLengthPropertyInfo(), ownerType.m_textLength.value);
}
@@ -296,10 +296,10 @@
SVGElement* element = downcast<SVGElement>(renderer->node());
ASSERT(element);
- if (!element->isTextContent())
+ if (!is<SVGTextContentElement>(element))
return nullptr;
- return toSVGTextContentElement(element);
+ return downcast<SVGTextContentElement>(element);
}
}
Modified: trunk/Source/WebCore/svg/SVGTextContentElement.h (173969 => 173970)
--- trunk/Source/WebCore/svg/SVGTextContentElement.h 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/svg/SVGTextContentElement.h 2014-09-25 17:25:43 UTC (rev 173970)
@@ -119,10 +119,10 @@
END_DECLARE_ANIMATED_PROPERTIES
};
-void isSVGTextContentElement(const SVGTextContentElement&); // Catch unnecessary runtime check of type known at compile time.
-inline bool isSVGTextContentElement(const SVGElement& element) { return element.isTextContent(); }
-inline bool isSVGTextContentElement(const Node& node) { return node.isSVGElement() && downcast<SVGElement>(node).isTextContent(); }
-NODE_TYPE_CASTS(SVGTextContentElement)
+SPECIALIZE_TYPE_TRAITS_BEGIN(SVGTextContentElement)
+ static bool isSVGTextContentElement(const SVGElement& element) { return element.isTextContent(); }
+ static bool isSVGTextContentElement(const Node& node) { return is<SVGElement>(node) && isSVGTextContentElement(downcast<SVGElement>(node)); }
+SPECIALIZE_TYPE_TRAITS_END()
} // namespace WebCore
Modified: trunk/Source/WebCore/svg/SVGUseElement.cpp (173969 => 173970)
--- trunk/Source/WebCore/svg/SVGUseElement.cpp 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/svg/SVGUseElement.cpp 2014-09-25 17:25:43 UTC (rev 173970)
@@ -543,16 +543,16 @@
{
ASSERT(path.isEmpty());
- Node* node = m_targetElementInstance ? m_targetElementInstance->shadowTreeElement() : nullptr;
- if (!node)
+ SVGElement* element = m_targetElementInstance ? m_targetElementInstance->shadowTreeElement() : nullptr;
+ if (!element)
return;
- if (node->isSVGElement() && downcast<SVGElement>(*node).isSVGGraphicsElement()) {
- if (!isDirectReference(downcast<SVGElement>(*node))) {
+ if (is<SVGGraphicsElement>(element)) {
+ if (!isDirectReference(*element)) {
// Spec: Indirect references are an error (14.3.5)
document().accessSVGExtensions().reportError("Not allowed to use indirect reference in <clip-path>");
} else {
- toSVGGraphicsElement(*node).toClipPath(path);
+ downcast<SVGGraphicsElement>(*element).toClipPath(path);
// FIXME: Avoid manual resolution of x/y here. Its potentially harmful.
SVGLengthContext lengthContext(this);
path.translate(FloatSize(x().value(lengthContext), y().value(lengthContext)));
Modified: trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp (173969 => 173970)
--- trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp 2014-09-25 17:25:43 UTC (rev 173970)
@@ -168,7 +168,7 @@
target = parentNode() && parentNode()->isElementNode() ? toElement(parentNode()) : nullptr;
else
target = SVGURIReference::targetElementFromIRIString(href, document(), &id);
- SVGElement* svgTarget = target && target->isSVGElement() ? downcast<SVGElement>(target) : nullptr;
+ SVGElement* svgTarget = target && is<SVGElement>(target) ? downcast<SVGElement>(target) : nullptr;
if (svgTarget && !svgTarget->inDocument())
svgTarget = nullptr;
@@ -536,11 +536,11 @@
condition.m_syncbase = treeScope().getElementById(condition.m_baseID);
if (!condition.m_syncbase)
continue;
- if (!isSVGSMILElement(*condition.m_syncbase)) {
+ if (!is<SVGSMILElement>(*condition.m_syncbase)) {
condition.m_syncbase = nullptr;
continue;
}
- toSVGSMILElement(*condition.m_syncbase).addTimeDependent(this);
+ downcast<SVGSMILElement>(*condition.m_syncbase).addTimeDependent(this);
}
}
}
@@ -568,7 +568,7 @@
condition.m_eventListener = nullptr;
} else if (condition.m_type == Condition::Syncbase) {
if (condition.m_syncbase)
- toSVGSMILElement(condition.m_syncbase.get())->removeTimeDependent(this);
+ downcast<SVGSMILElement>(condition.m_syncbase.get())->removeTimeDependent(this);
}
condition.m_syncbase = nullptr;
}
Modified: trunk/Source/WebCore/svg/animation/SVGSMILElement.h (173969 => 173970)
--- trunk/Source/WebCore/svg/animation/SVGSMILElement.h 2014-09-25 17:23:21 UTC (rev 173969)
+++ trunk/Source/WebCore/svg/animation/SVGSMILElement.h 2014-09-25 17:25:43 UTC (rev 173970)
@@ -237,18 +237,11 @@
friend class ConditionEventListener;
};
-void isSVGSMILElement(const SVGSMILElement&); // Catch unnecessary runtime check of type known at compile time.
-inline bool isSVGSMILElement(const SVGElement& element) { return element.isSMILElement(); }
-inline bool isSVGSMILElement(const Node& node) { return node.isSVGElement() && downcast<SVGElement>(node).isSMILElement(); }
+SPECIALIZE_TYPE_TRAITS_BEGIN(SVGSMILElement)
+ static bool isSVGSMILElement(const SVGElement& element) { return element.isSMILElement(); }
+ static bool isSVGSMILElement(const Node& node) { return is<SVGElement>(node) && isSVGSMILElement(downcast<SVGElement>(node)); }
+SPECIALIZE_TYPE_TRAITS_END()
-template <typename ArgType>
-struct NodeTypeCastTraits<const SVGSMILElement, ArgType> {
- static bool is(ArgType& node) { return isSVGSMILElement(node); }
-};
-
-
-NODE_TYPE_CASTS(SVGSMILElement)
-
}
#endif // SVGSMILElement_h