+2013-09-09 Andreas Kling <akling@apple.com>
+
+ Generate more SVG type checks and conversions.
+ <https://webkit.org/b/121066>
+
+ Reviewed by Anders Carlsson.
+
+ Switch another slew of SVG elements to auto-generated isFooElement()
+ and toFooElement() helpers.
+
+ Removed now-unnecessary casts and assertions as appropriate.
+ Converted some simple loops to childrenOfType iteration instead of
+ traversing child Nodes.
+
+ PS. This patch also adds const versions of toFooElement().
+
2013-09-09 Dean Jackson <dino@apple.com>
[WebGL] Allow multithreaded OpenGL contexts
static inline SVGCursorElement* resourceReferencedByCursorElement(const String& url, Document* document)
{
Element* element = SVGURIReference::targetElementFromIRIString(url, document);
- if (element && element->hasTagName(SVGNames::cursorTag))
- return static_cast<SVGCursorElement*>(element);
+ if (element && isSVGCursorElement(element))
+ return toSVGCursorElement(element);
return 0;
}
// Get the current preferred styleset. This is the
// set of sheets that will be enabled.
#if ENABLE(SVG)
- if (e->hasTagName(SVGNames::styleTag))
- sheet = static_cast<SVGStyleElement*>(n)->sheet();
+ if (isSVGStyleElement(e))
+ sheet = toSVGStyleElement(e)->sheet();
else
#endif
{
if (elementData()->m_animatedSVGAttributesAreDirty) {
// We're not passing a namespace argument on purpose. SVGNames::*Attr are defined w/o namespaces as well.
ASSERT(isSVGElement());
- static_cast<const SVGElement*>(this)->synchronizeAnimatedSVGAttribute(QualifiedName(nullAtom, localName, nullAtom));
+ toSVGElement(this)->synchronizeAnimatedSVGAttribute(QualifiedName(nullAtom, localName, nullAtom));
}
#endif
}
#if ENABLE(SVG)
if (isSVGElement())
- return !static_cast<const SVGElement*>(this)->isAnimatableAttribute(name);
+ return !toSVGElement(this)->isAnimatableAttribute(name);
#endif
return true;
print F "template <> inline bool isElementOfType<$class>(const Element* element) { return $checkHelper(element); }\n";
print F "inline $class* $castingHelper(Node* node) { ASSERT_WITH_SECURITY_IMPLICATION(!node || $checkHelper(node)); return reinterpret_cast<".$class."*>(node); }\n";
print F "inline $class* $castingHelper(Element* element) { ASSERT_WITH_SECURITY_IMPLICATION(!element || $checkHelper(element)); return reinterpret_cast<".$class."*>(element); }\n";
+ print F "inline const $class* $castingHelper(const Node* node) { ASSERT_WITH_SECURITY_IMPLICATION(!node || $checkHelper(node)); return reinterpret_cast<const ".$class."*>(node); }\n";
+ print F "inline const $class* $castingHelper(const Element* element) { ASSERT_WITH_SECURITY_IMPLICATION(!element || $checkHelper(element)); return reinterpret_cast<const ".$class."*>(element); }\n";
print F "\n";
}
cssStyleSheet = toHTMLStyleElement(styleElement.get())->sheet();
#if ENABLE(SVG)
else if (styleElement->isSVGElement())
- cssStyleSheet = static_cast<SVGStyleElement*>(styleElement.get())->sheet();
+ cssStyleSheet = toSVGStyleElement(styleElement.get())->sheet();
#endif
if (!cssStyleSheet)
#endif
if (fontName.isEmpty())
- return static_cast<SVGFontElement*>(list->item(0));
+ return toSVGFontElement(list->item(0));
for (unsigned i = 0; i < listLength; ++i) {
- SVGFontElement* element = static_cast<SVGFontElement*>(list->item(i));
+ SVGFontElement* element = toSVGFontElement(list->item(i));
if (element->getIdAttribute() == fontName)
return element;
}
void RenderSVGEllipse::calculateRadiiAndCenter()
{
ASSERT(element());
- if (element()->hasTagName(SVGNames::circleTag)) {
+ if (isSVGCircleElement(element())) {
- SVGCircleElement* circle = static_cast<SVGCircleElement*>(element());
+ SVGCircleElement* circle = toSVGCircleElement(element());
SVGLengthContext lengthContext(circle);
float radius = circle->r().value(lengthContext);
return;
}
- ASSERT(element()->hasTagName(SVGNames::ellipseTag));
- SVGEllipseElement* ellipse = static_cast<SVGEllipseElement*>(element());
+ ASSERT(isSVGEllipseElement(element()));
+ SVGEllipseElement* ellipse = toSVGEllipseElement(element());
SVGLengthContext lengthContext(ellipse);
m_radii = FloatSize(ellipse->rx().value(lengthContext), ellipse->ry().value(lengthContext));
ASSERT(!view().layoutStateEnabled()); // RenderSVGRoot disables layoutState for the SVG rendering tree.
LayoutRepainter repainter(*this, SVGRenderSupport::checkForSVGRepaintDuringLayout(this));
- SVGForeignObjectElement* foreign = static_cast<SVGForeignObjectElement*>(element());
+ SVGForeignObjectElement* foreign = toSVGForeignObjectElement(element());
bool updateCachedBoundariesInParents = false;
if (m_needsTransformUpdate) {
return false;
}
// Only one visible shape/path was found. Directly continue clipping and transform the content to userspace if necessary.
- if (static_cast<SVGClipPathElement*>(element())->clipPathUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
+ if (toSVGClipPathElement(element())->clipPathUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
AffineTransform transform;
transform.translate(objectBoundingBox.x(), objectBoundingBox.y());
transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.height());
m_clipper.set(object, new ClipperData);
bool shouldCreateClipData = false;
- AffineTransform animatedLocalTransform = static_cast<SVGClipPathElement*>(element())->animatedLocalTransform();
+ AffineTransform animatedLocalTransform = toSVGClipPathElement(element())->animatedLocalTransform();
ClipperData* clipperData = m_clipper.get(object);
if (!clipperData->clipMaskImage) {
if (pathOnlyClipping(context, animatedLocalTransform, objectBoundingBox))
ASSERT(maskContext);
AffineTransform maskContentTransformation;
- SVGClipPathElement* clipPath = static_cast<SVGClipPathElement*>(element());
+ SVGClipPathElement* clipPath = toSVGClipPathElement(element());
if (clipPath->clipPathUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
maskContentTransformation.translate(objectBoundingBox.x(), objectBoundingBox.y());
maskContentTransformation.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.height());
continue;
m_clipBoundaries.unite(renderer->localToParentTransform().mapRect(renderer->repaintRectInLocalCoordinates()));
}
- m_clipBoundaries = static_cast<SVGClipPathElement*>(element())->animatedLocalTransform().mapRect(m_clipBoundaries);
+ m_clipBoundaries = toSVGClipPathElement(element())->animatedLocalTransform().mapRect(m_clipBoundaries);
}
bool RenderSVGResourceClipper::hitTestClipContent(const FloatRect& objectBoundingBox, const FloatPoint& nodeAtPoint)
if (!SVGRenderSupport::pointInClippingArea(this, point))
return false;
- SVGClipPathElement* clipPathElement = static_cast<SVGClipPathElement*>(element());
+ SVGClipPathElement* clipPathElement = toSVGClipPathElement(element());
if (clipPathElement->clipPathUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
AffineTransform transform;
transform.translate(objectBoundingBox.x(), objectBoundingBox.y());
if (m_clipBoundaries.isEmpty())
calculateClipContentRepaintRect();
- if (static_cast<SVGClipPathElement*>(element())->clipPathUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
+ if (toSVGClipPathElement(element())->clipPathUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
FloatRect objectBoundingBox = object->objectBoundingBox();
AffineTransform transform;
transform.translate(objectBoundingBox.x(), objectBoundingBox.y());
bool hitTestClipContent(const FloatRect&, const FloatPoint&);
- SVGUnitTypes::SVGUnitType clipPathUnits() const { return static_cast<SVGClipPathElement*>(element())->clipPathUnits(); }
+ SVGUnitTypes::SVGUnitType clipPathUnits() const { return toSVGClipPathElement(element())->clipPathUnits(); }
static RenderSVGResourceType s_resourceType;
private:
FloatPoint RenderSVGResourceLinearGradient::startPoint(const LinearGradientAttributes& attributes) const
{
- return SVGLengthContext::resolvePoint(static_cast<const SVGElement*>(element()), attributes.gradientUnits(), attributes.x1(), attributes.y1());
+ return SVGLengthContext::resolvePoint(element(), attributes.gradientUnits(), attributes.x1(), attributes.y1());
}
FloatPoint RenderSVGResourceLinearGradient::endPoint(const LinearGradientAttributes& attributes) const
{
- return SVGLengthContext::resolvePoint(static_cast<const SVGElement*>(element()), attributes.gradientUnits(), attributes.x2(), attributes.y2());
+ return SVGLengthContext::resolvePoint(element(), attributes.gradientUnits(), attributes.x2(), attributes.y2());
}
void RenderSVGResourceLinearGradient::buildGradient(GradientData* gradientData) const
bool updateCachedBoundariesInParents = false;
if (m_needsTransformUpdate) {
- SVGTextElement* text = static_cast<SVGTextElement*>(element());
+ SVGTextElement* text = toSVGTextElement(element());
m_localTransform = text->animatedLocalTransform();
m_needsTransformUpdate = false;
updateCachedBoundariesInParents = true;
static void updatePathFromCircleElement(SVGElement* element, Path& path)
{
- ASSERT(element->hasTagName(SVGNames::circleTag));
- SVGCircleElement* circle = static_cast<SVGCircleElement*>(element);
+ ASSERT(isSVGCircleElement(element));
+ SVGCircleElement* circle = toSVGCircleElement(element);
SVGLengthContext lengthContext(element);
float r = circle->r().value(lengthContext);
SVGElement* svgElement = shape.element();
SVGLengthContext lengthContext(svgElement);
- if (svgElement->hasTagName(SVGNames::rectTag)) {
+ if (isSVGRectElement(svgElement)) {
SVGRectElement* element = toSVGRectElement(svgElement);
writeNameValuePair(ts, "x", element->x().value(lengthContext));
writeNameValuePair(ts, "y", element->y().value(lengthContext));
writeNameValuePair(ts, "width", element->width().value(lengthContext));
writeNameValuePair(ts, "height", element->height().value(lengthContext));
- } else if (svgElement->hasTagName(SVGNames::lineTag)) {
- SVGLineElement* element = static_cast<SVGLineElement*>(svgElement);
+ } else if (isSVGLineElement(svgElement)) {
+ SVGLineElement* element = toSVGLineElement(svgElement);
writeNameValuePair(ts, "x1", element->x1().value(lengthContext));
writeNameValuePair(ts, "y1", element->y1().value(lengthContext));
writeNameValuePair(ts, "x2", element->x2().value(lengthContext));
writeNameValuePair(ts, "y2", element->y2().value(lengthContext));
- } else if (svgElement->hasTagName(SVGNames::ellipseTag)) {
- SVGEllipseElement* element = static_cast<SVGEllipseElement*>(svgElement);
+ } else if (isSVGEllipseElement(svgElement)) {
+ SVGEllipseElement* element = toSVGEllipseElement(svgElement);
writeNameValuePair(ts, "cx", element->cx().value(lengthContext));
writeNameValuePair(ts, "cy", element->cy().value(lengthContext));
writeNameValuePair(ts, "rx", element->rx().value(lengthContext));
writeNameValuePair(ts, "ry", element->ry().value(lengthContext));
- } else if (svgElement->hasTagName(SVGNames::circleTag)) {
- SVGCircleElement* element = static_cast<SVGCircleElement*>(svgElement);
+ } else if (isSVGCircleElement(svgElement)) {
+ SVGCircleElement* element = toSVGCircleElement(svgElement);
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)) {
- SVGPolyElement* element = static_cast<SVGPolyElement*>(svgElement);
+ SVGPolyElement* element = toSVGPolyElement(svgElement);
writeNameAndQuotedValue(ts, "points", element->pointList().valueAsString());
- } else if (svgElement->hasTagName(SVGNames::pathTag)) {
+ } else if (isSVGPathElement(svgElement)) {
SVGPathElement* element = toSVGPathElement(svgElement);
String pathString;
// FIXME: We should switch to UnalteredParsing here - this will affect the path dumping output of dozens of tests.
bool foundFirstAltGlyphItem = false;
for (Node* child = firstChild(); child; child = child->nextSibling()) {
- if (!foundFirstAltGlyphItem && child->hasTagName(SVGNames::glyphRefTag)) {
+ if (!foundFirstAltGlyphItem && isSVGGlyphRefElement(child)) {
fountFirstGlyphRef = true;
String referredGlyphName;
- if (static_cast<SVGGlyphRefElement*>(child)->hasValidGlyphElement(referredGlyphName))
+ if (toSVGGlyphRefElement(child)->hasValidGlyphElement(referredGlyphName))
glyphNames.append(referredGlyphName);
else {
// As the spec says "If any of the referenced glyphs are unavailable,
glyphNames.clear();
return false;
}
- } else if (!fountFirstGlyphRef && child->hasTagName(SVGNames::altGlyphItemTag)) {
+ } else if (!fountFirstGlyphRef && isSVGAltGlyphItemElement(child)) {
foundFirstAltGlyphItem = true;
- Vector<String> referredGlyphNames;
// As the spec says "The first 'altGlyphItem' in which all referenced glyphs
// are available is chosen."
- if (static_cast<SVGAltGlyphItemElement*>(child)->hasValidGlyphElements(glyphNames) && !glyphNames.isEmpty())
+ if (toSVGAltGlyphItemElement(child)->hasValidGlyphElements(glyphNames) && !glyphNames.isEmpty())
return true;
}
}
if (!element)
return false;
- if (element->hasTagName(SVGNames::glyphTag)) {
+ if (isSVGGlyphElement(element)) {
glyphNames.append(target);
return true;
}
- if (element->hasTagName(SVGNames::altGlyphDefTag)
- && static_cast<SVGAltGlyphDefElement*>(element)->hasValidGlyphElements(glyphNames))
+ if (isSVGAltGlyphDefElement(element)
+ && toSVGAltGlyphDefElement(element)->hasValidGlyphElements(glyphNames))
return true;
return false;
#if ENABLE(SVG) && ENABLE(SVG_FONTS)
#include "SVGAltGlyphItemElement.h"
+#include "ElementIterator.h"
#include "SVGGlyphRefElement.h"
#include "SVGNames.h"
//
// Here we fill glyphNames and return true only if all referenced glyphs are valid and
// there is at least one glyph.
- for (Node* child = firstChild(); child; child = child->nextSibling()) {
- if (child->hasTagName(SVGNames::glyphRefTag)) {
- String referredGlyphName;
- if (static_cast<SVGGlyphRefElement*>(child)->hasValidGlyphElement(referredGlyphName))
- glyphNames.append(referredGlyphName);
- else {
- glyphNames.clear();
- return false;
- }
+
+ for (auto glyphRef = childrenOfType<SVGGlyphRefElement>(this).begin(), end = childrenOfType<SVGGlyphRefElement>(this).end(); glyphRef != end; ++glyphRef) {
+ String referredGlyphName;
+ if (glyphRef->hasValidGlyphElement(referredGlyphName))
+ glyphNames.append(referredGlyphName);
+ else {
+ glyphNames.clear();
+ return false;
}
}
return !glyphNames.isEmpty();
SVGAnimatedTransformListAnimator::SVGAnimatedTransformListAnimator(SVGAnimationElement* animationElement, SVGElement* contextElement)
: SVGAnimatedTypeAnimator(AnimatedTransformList, animationElement, contextElement)
- , m_transformTypeString(SVGTransform::transformTypePrefixForParsing(static_cast<SVGAnimateTransformElement*>(animationElement)->transformType()))
+ , m_transformTypeString(SVGTransform::transformTypePrefixForParsing(toSVGAnimateTransformElement(animationElement)->transformType()))
{
// Only <animateTransform> uses this animator, as <animate> doesn't allow to animate transform lists directly.
ASSERT(animationElement->hasTagName(SVGNames::animateTransformTag));
bool SVGDocument::childShouldCreateRenderer(const Node* child) const
{
- if (child->hasTagName(SVGNames::svgTag))
+ if (isSVGSVGElement(child))
return toSVGSVGElement(child)->isValid();
return true;
}
bool SVGElement::isOutermostSVGSVGElement() const
{
- if (!hasTagName(SVGNames::svgTag))
+ if (!isSVGSVGElement(this))
return false;
// If we're living in a shadow tree, we're a <svg> element that got created as replacement
SVGDocumentExtensions* accessDocumentSVGExtensions();
virtual bool isSVGGraphicsElement() const { return false; }
- virtual bool isSVGSVGElement() const { return false; }
virtual bool isFilterEffect() const { return false; }
virtual bool isGradientStop() const { return false; }
virtual bool isTextContent() const { return false; }
#include "SVGFEComponentTransferElement.h"
#include "Attr.h"
+#include "ElementIterator.h"
#include "FilterEffect.h"
#include "SVGFEFuncAElement.h"
#include "SVGFEFuncBElement.h"
ComponentTransferFunction green;
ComponentTransferFunction blue;
ComponentTransferFunction alpha;
-
- for (Node* node = firstChild(); node; node = node->nextSibling()) {
- if (node->hasTagName(SVGNames::feFuncRTag))
- red = static_cast<SVGFEFuncRElement*>(node)->transferFunction();
- else if (node->hasTagName(SVGNames::feFuncGTag))
- green = static_cast<SVGFEFuncGElement*>(node)->transferFunction();
- else if (node->hasTagName(SVGNames::feFuncBTag))
- blue = static_cast<SVGFEFuncBElement*>(node)->transferFunction();
- else if (node->hasTagName(SVGNames::feFuncATag))
- alpha = static_cast<SVGFEFuncAElement*>(node)->transferFunction();
+
+ for (auto child = childrenOfType<SVGElement>(this).begin(), end = childrenOfType<SVGElement>(this).end(); child != end; ++child) {
+ SVGElement* element = &*child;
+ if (isSVGFEFuncRElement(element))
+ red = toSVGFEFuncRElement(element)->transferFunction();
+ else if (isSVGFEFuncGElement(element))
+ green = toSVGFEFuncGElement(element)->transferFunction();
+ else if (isSVGFEFuncBElement(element))
+ blue = toSVGFEFuncBElement(element)->transferFunction();
+ else if (isSVGFEFuncAElement(element))
+ alpha = toSVGFEFuncAElement(element)->transferFunction();
}
RefPtr<FilterEffect> effect = FEComponentTransfer::create(filter, red, green, blue, alpha);
#include "SVGFELightElement.h"
#include "Attribute.h"
+#include "ElementIterator.h"
#include "RenderObject.h"
#include "RenderSVGResource.h"
#include "SVGElementInstance.h"
SVGFELightElement* SVGFELightElement::findLightElement(const SVGElement* svgElement)
{
- for (Node* node = svgElement->firstChild(); node; node = node->nextSibling()) {
- if (node->hasTagName(SVGNames::feDistantLightTag)
- || node->hasTagName(SVGNames::fePointLightTag)
- || node->hasTagName(SVGNames::feSpotLightTag)) {
- return static_cast<SVGFELightElement*>(node);
- }
+ for (auto child = childrenOfType<SVGElement>(svgElement).begin(), end = childrenOfType<SVGElement>(svgElement).end(); child != end; ++child) {
+ if (isSVGFEDistantLightElement(*child) || isSVGFEPointLightElement(*child) || isSVGFESpotLightElement(*child))
+ return static_cast<SVGFELightElement*>(const_cast<SVGElement*>(&*child));
}
return 0;
}
#if ENABLE(SVG) && ENABLE(FILTERS)
#include "SVGFEMergeElement.h"
+#include "ElementIterator.h"
#include "FilterEffect.h"
#include "SVGFEMergeNodeElement.h"
#include "SVGFilterBuilder.h"
{
RefPtr<FilterEffect> effect = FEMerge::create(filter);
FilterEffectVector& mergeInputs = effect->inputEffects();
- for (Node* node = firstChild(); node; node = node->nextSibling()) {
- if (node->hasTagName(SVGNames::feMergeNodeTag)) {
- FilterEffect* mergeEffect = filterBuilder->getEffectById(static_cast<SVGFEMergeNodeElement*>(node)->in1());
- if (!mergeEffect)
- return 0;
- mergeInputs.append(mergeEffect);
- }
+
+ for (auto mergeNode = childrenOfType<SVGFEMergeNodeElement>(this).begin(), end = childrenOfType<SVGFEMergeNodeElement>(this).end(); mergeNode != end; ++mergeNode) {
+ FilterEffect* mergeEffect = filterBuilder->getEffectById(mergeNode->in1());
+ if (!mergeEffect)
+ return 0;
+ mergeInputs.append(mergeEffect);
}
if (mergeInputs.isEmpty())
END_DECLARE_ANIMATED_PROPERTIES
};
-inline SVGFilterElement* toSVGFilterElement(Node* node)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(!node || node->hasTagName(SVGNames::filterTag));
- return static_cast<SVGFilterElement*>(node);
-}
-
}
#endif
if (Element* parentRenderObjectElement = toElement(parentRenderObject->node())) {
language = parentRenderObjectElement->getAttribute(XMLNames::langAttr);
- if (parentRenderObjectElement->hasTagName(SVGNames::altGlyphTag)) {
- SVGAltGlyphElement* altGlyph = static_cast<SVGAltGlyphElement*>(parentRenderObjectElement);
+ if (isSVGAltGlyphElement(parentRenderObjectElement)) {
+ SVGAltGlyphElement* altGlyph = toSVGAltGlyphElement(parentRenderObjectElement);
if (!altGlyph->hasValidGlyphElements(altGlyphNames))
altGlyphNames.clear();
}
#include "SVGFontElement.h"
#include "Document.h"
+#include "ElementIterator.h"
#include "Font.h"
#include "GlyphPageTreeNode.h"
#include "SVGGlyphElement.h"
SVGMissingGlyphElement* firstMissingGlyphElement = 0;
Vector<String> ligatures;
- for (Node* child = firstChild(); child; child = child->nextSibling()) {
- if (child->hasTagName(SVGNames::glyphTag)) {
- SVGGlyphElement* glyph = static_cast<SVGGlyphElement*>(child);
+ for (auto child = childrenOfType<SVGElement>(this).begin(), end = childrenOfType<SVGElement>(this).end(); child != end; ++child) {
+ SVGElement* element = &*child;
+ if (isSVGGlyphElement(element)) {
+ SVGGlyphElement* glyph = toSVGGlyphElement(element);
AtomicString unicode = glyph->fastGetAttribute(SVGNames::unicodeAttr);
AtomicString glyphId = glyph->getIdAttribute();
if (glyphId.isEmpty() && unicode.isEmpty())
// Register ligatures, if needed, don't mix up with surrogate pairs though!
if (unicode.length() > 1 && !U16_IS_SURROGATE(unicode[0]))
ligatures.append(unicode.string());
- } else if (child->hasTagName(SVGNames::hkernTag)) {
- SVGHKernElement* hkern = static_cast<SVGHKernElement*>(child);
+ } else if (isSVGHKernElement(element)) {
+ SVGHKernElement* hkern = toSVGHKernElement(element);
hkern->buildHorizontalKerningPair(m_horizontalKerningPairs);
- } else if (child->hasTagName(SVGNames::vkernTag)) {
- SVGVKernElement* vkern = static_cast<SVGVKernElement*>(child);
+ } else if (isSVGVKernElement(element)) {
+ SVGVKernElement* vkern = toSVGVKernElement(element);
vkern->buildVerticalKerningPair(m_verticalKerningPairs);
- } else if (child->hasTagName(SVGNames::missing_glyphTag) && !firstMissingGlyphElement)
- firstMissingGlyphElement = toSVGMissingGlyphElement(child);
+ } else if (isSVGMissingGlyphElement(element) && !firstMissingGlyphElement)
+ firstMissingGlyphElement = toSVGMissingGlyphElement(element);
}
// Register each character of each ligature, if needed.
#include "CSSValueKeywords.h"
#include "CSSValueList.h"
#include "Document.h"
+#include "ElementIterator.h"
#include "Font.h"
#include "SVGDocumentExtensions.h"
#include "SVGFontElement.h"
// we currently ignore all but the first src element, alternatively we could concat them
SVGFontFaceSrcElement* srcElement = 0;
-
- for (Node* child = firstChild(); child && !srcElement; child = child->nextSibling()) {
- if (child->hasTagName(font_face_srcTag))
- srcElement = static_cast<SVGFontFaceSrcElement*>(child);
- }
+ auto firstFontFaceSrcElementChild = childrenOfType<SVGFontFaceSrcElement>(this).begin();
+ if (firstFontFaceSrcElementChild != childrenOfType<SVGFontFaceSrcElement>(this).end())
+ srcElement = &*firstFontFaceSrcElementChild;
bool describesParentFont = isSVGFontElement(parentNode());
RefPtr<CSSValueList> list;
RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
for (Node* child = firstChild(); child; child = child->nextSibling()) {
RefPtr<CSSFontFaceSrcValue> srcValue;
- if (child->hasTagName(font_face_uriTag))
- srcValue = static_cast<SVGFontFaceUriElement*>(child)->srcValue();
- else if (child->hasTagName(font_face_nameTag))
- srcValue = static_cast<SVGFontFaceNameElement*>(child)->srcValue();
+ if (isSVGFontFaceUriElement(child))
+ srcValue = toSVGFontFaceUriElement(child)->srcValue();
+ else if (isSVGFontFaceNameElement(child))
+ srcValue = toSVGFontFaceNameElement(child)->srcValue();
if (srcValue && srcValue->resource().length())
list->append(srcValue);
}
// Take size from nearest viewport element.
SVGElement* viewportElement = m_context->viewportElement();
- if (!viewportElement || !viewportElement->isSVGSVGElement())
+ if (!viewportElement || !isSVGSVGElement(viewportElement))
return false;
- const SVGSVGElement* svg = static_cast<const SVGSVGElement*>(viewportElement);
+ const SVGSVGElement* svg = toSVGSVGElement(viewportElement);
FloatSize viewportSize = svg->currentViewBoxRect().size();
if (viewportSize.isEmpty())
viewportSize = svg->currentViewportSize();
END_DECLARE_ANIMATED_PROPERTIES
};
-inline SVGLinearGradientElement* toSVGLinearGradientElement(Node* node)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(!node || node->hasTagName(SVGNames::linearGradientTag));
- return static_cast<SVGLinearGradientElement*>(node);
-}
-
} // namespace WebCore
#endif // ENABLE(SVG)
void SVGMPathElement::notifyParentOfPathChange(ContainerNode* parent)
{
- if (parent && parent->hasTagName(SVGNames::animateMotionTag))
- static_cast<SVGAnimateMotionElement*>(parent)->updateAnimationPath();
+ if (parent && isSVGAnimateMotionElement(parent))
+ toSVGAnimateMotionElement(parent)->updateAnimationPath();
}
} // namespace WebCore
END_DECLARE_ANIMATED_PROPERTIES
};
-inline SVGMPathElement* toSVGMPathElement(Node* node)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(!node || node->hasTagName(SVGNames::mpathTag));
- return static_cast<SVGMPathElement*>(node);
-}
-
} // namespace WebCore
#endif // ENABLE(SVG)
mutable SVGSynchronizableAnimatedProperty<SVGMarkerOrientType> m_orientType;
};
-inline SVGMarkerElement* toSVGMarkerElement(Node* node)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(!node || node->hasTagName(SVGNames::markerTag));
- return static_cast<SVGMarkerElement*>(node);
-}
-
}
#endif
virtual void synchronizeSystemLanguage() { SVGTests::synchronizeSystemLanguage(this); }
};
-inline SVGMaskElement* toSVGMaskElement(Node* node)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(!node || node->hasTagName(SVGNames::maskTag));
- return static_cast<SVGMaskElement*>(node);
-}
-
}
#endif
virtual bool rendererIsNeeded(const RenderStyle&) { return false; }
};
-inline SVGMissingGlyphElement* toSVGMissingGlyphElement(Node* node)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(!node || node->hasTagName(SVGNames::missing_glyphTag));
- return static_cast<SVGMissingGlyphElement*>(node);
-}
-
} // namespace WebCore
#endif // ENABLE(SVG_FONTS)
bool m_isAnimValObserved;
};
-inline SVGPathElement* toSVGPathElement(Element* element)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(!element || element->hasTagName(SVGNames::pathTag));
- return static_cast<SVGPathElement*>(element);
-}
-
} // namespace WebCore
#endif // ENABLE(SVG)
processedPatterns.add(current);
// Respect xlink:href, take attributes from referenced element
- Node* refNode = SVGURIReference::targetElementFromIRIString(current->href(), &document());
- if (refNode && refNode->hasTagName(SVGNames::patternTag)) {
- current = static_cast<const SVGPatternElement*>(const_cast<const Node*>(refNode));
+ Element* refElement = SVGURIReference::targetElementFromIRIString(current->href(), &document());
+ if (refElement && isSVGPatternElement(refElement)) {
+ current = toSVGPatternElement(refElement);
// Cycle detection
if (processedPatterns.contains(current)) {
virtual void synchronizeSystemLanguage() { SVGTests::synchronizeSystemLanguage(this); }
};
-inline SVGPatternElement* toSVGPatternElement(Node* node)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(!node || node->hasTagName(SVGNames::patternTag));
- return static_cast<SVGPatternElement*>(node);
-}
-
} // namespace WebCore
#endif // ENABLE(SVG)
END_DECLARE_ANIMATED_PROPERTIES
};
-inline SVGRadialGradientElement* toSVGRadialGradientElement(Node* node)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(!node || node->hasTagName(SVGNames::radialGradientTag));
- return static_cast<SVGRadialGradientElement*>(node);
-}
-
} // namespace WebCore
#endif // ENABLE(SVG)
END_DECLARE_ANIMATED_PROPERTIES
};
-inline SVGRectElement* toSVGRectElement(Node* node)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(!node || node->hasTagName(SVGNames::rectTag));
- return static_cast<SVGRectElement*>(node);
-}
-
} // namespace WebCore
#endif // ENABLE(SVG)
// or MyDrawing.svg#xpointer(id('MyView'))) then the closest ancestor ‘svg’ element is displayed in the viewport.
// Any view specification attributes included on the given ‘view’ element override the corresponding view specification
// attributes on the closest ancestor ‘svg’ element.
- if (anchorNode && anchorNode->hasTagName(SVGNames::viewTag)) {
- if (SVGViewElement* viewElement = anchorNode->hasTagName(SVGNames::viewTag) ? static_cast<SVGViewElement*>(anchorNode) : 0) {
+ if (anchorNode && isSVGViewElement(anchorNode)) {
+ if (SVGViewElement* viewElement = toSVGViewElement(anchorNode)) {
SVGElement* element = SVGLocatable::nearestViewportElement(viewElement);
if (element->hasTagName(SVGNames::svgTag)) {
SVGSVGElement* svg = static_cast<SVGSVGElement*>(element);
SVGSVGElement(const QualifiedName&, Document*);
virtual ~SVGSVGElement();
- virtual bool isSVGSVGElement() const OVERRIDE { return true; }
-
virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
virtual bool rendererIsNeeded(const RenderStyle&) OVERRIDE;
RefPtr<SVGViewSpec> m_viewSpec;
};
-inline SVGSVGElement* toSVGSVGElement(Node* node)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(!node || node->isSVGElement());
- ASSERT_WITH_SECURITY_IMPLICATION(!node || toSVGElement(node)->isSVGSVGElement());
- return static_cast<SVGSVGElement*>(node);
-}
-
-inline const SVGSVGElement* toSVGSVGElement(const Node* node)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(!node || node->isSVGElement());
- ASSERT_WITH_SECURITY_IMPLICATION(!node || toSVGElement(node)->isSVGSVGElement());
- return static_cast<const SVGSVGElement*>(node);
-}
-
} // namespace WebCore
#endif // ENABLE(SVG)
END_DECLARE_ANIMATED_PROPERTIES
};
-inline SVGTextPathElement* toSVGTextPathElement(Node* node)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(!node || node->hasTagName(SVGNames::textPathTag));
- return static_cast<SVGTextPathElement*>(node);
-}
-
} // namespace WebCore
#endif // ENABLE(SVG)
virtual bool rendererIsNeeded(const RenderStyle&) { return false; }
};
-template <> inline bool isElementOfType<SVGTitleElement>(const Element* element) { return element->hasTagName(SVGNames::titleTag); }
-
} // namespace WebCore
#endif // ENABLE(SVG)
Timer<SVGElement> m_svgLoadEventTimer;
};
-inline SVGUseElement* toSVGUseElement(Node* node)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(!node || node->hasTagName(SVGNames::useTag));
- return static_cast<SVGUseElement*>(node);
-}
-
}
#endif
a
#if ENABLE_SVG_FONTS
-altGlyph
-altGlyphDef
-altGlyphItem
+altGlyph generateTypeHelpers
+altGlyphDef generateTypeHelpers
+altGlyphItem generateTypeHelpers
#endif
animate
animateColor
-animateMotion
-animateTransform
+animateMotion generateTypeHelpers
+animateTransform generateTypeHelpers
set
-circle
-clipPath
+circle generateTypeHelpers
+clipPath generateTypeHelpers
#if 0
color_profile
#endif
-cursor
+cursor generateTypeHelpers
defs
desc
-ellipse
+ellipse generateTypeHelpers
#if ENABLE_FILTERS
feBlend
feColorMatrix
feConvolveMatrix
feDiffuseLighting
feDisplacementMap
-feDistantLight
+feDistantLight generateTypeHelpers
feDropShadow
feFlood
-feFuncA
-feFuncB
-feFuncG
-feFuncR
+feFuncA generateTypeHelpers
+feFuncB generateTypeHelpers
+feFuncG generateTypeHelpers
+feFuncR generateTypeHelpers
feGaussianBlur
feImage
feMerge
-feMergeNode
+feMergeNode generateTypeHelpers
feMorphology
feOffset
-fePointLight
+fePointLight generateTypeHelpers
feSpecularLighting
-feSpotLight
+feSpotLight generateTypeHelpers
feTile
feTurbulence
-filter
+filter generateTypeHelpers
#endif
#if ENABLE_SVG_FONTS
font generateTypeHelpers
font_face generateTypeHelpers
font_face_format
-font_face_name
-font_face_src
-font_face_uri
+font_face_name generateTypeHelpers
+font_face_src generateTypeHelpers
+font_face_uri generateTypeHelpers
#endif
foreignObject generateTypeHelpers
g
#if ENABLE_SVG_FONTS
-glyph
-glyphRef
-hkern interfaceName=SVGHKernElement
+glyph generateTypeHelpers
+glyphRef generateTypeHelpers
+hkern interfaceName=SVGHKernElement, generateTypeHelpers
#endif
image generateTypeHelpers
-line
-linearGradient
-marker
-mask
+line generateTypeHelpers
+linearGradient generateTypeHelpers
+marker generateTypeHelpers
+mask generateTypeHelpers
metadata
#if ENABLE_SVG_FONTS
-missing_glyph
+missing_glyph generateTypeHelpers
#endif
-mpath interfaceName=SVGMPathElement
-path
-pattern
+mpath interfaceName=SVGMPathElement, generateTypeHelpers
+path generateTypeHelpers
+pattern generateTypeHelpers
polygon
polyline
-radialGradient
-rect
+radialGradient generateTypeHelpers
+rect generateTypeHelpers
script constructorNeedsCreatedByParser, generateTypeHelpers
stop
-style constructorNeedsCreatedByParser
-svg interfaceName=SVGSVGElement
+style constructorNeedsCreatedByParser, generateTypeHelpers
+svg interfaceName=SVGSVGElement, generateTypeHelpers
switch
symbol
-text
-textPath
-title
+text generateTypeHelpers
+textPath generateTypeHelpers
+title generateTypeHelpers
tref interfaceName=SVGTRefElement
tspan interfaceName=SVGTSpanElement
-use constructorNeedsCreatedByParser
-view
+use constructorNeedsCreatedByParser, generateTypeHelpers
+view generateTypeHelpers
#if ENABLE_SVG_FONTS
-vkern interfaceName=SVGVKernElement
+vkern interfaceName=SVGVKernElement, generateTypeHelpers
#endif