https://bugs.webkit.org/show_bug.cgi?id=137004
Reviewed by Benjamin Poulain.
Use downcast<SVG*Element>() instead of toSVG*Element() for casting SVG
Elements and get rid of the transition toSVG*Element() macros.
Also use downcast<MathML*Element>() instead of toMathML*Element() for
casting MathML Elements.
The HTML Elements casting counterparts will be taken care of in a
separate patch.
No new tests, no behavior change.
* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::alternativeText):
(WebCore::AccessibilityNodeObject::accessibilityDescription):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::remoteSVGRootElement):
* bindings/js/JSElementCustom.cpp:
(WebCore::toJSNewlyCreated):
* bindings/js/JSNodeCustom.cpp:
(WebCore::createWrapperInline):
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::propertyValue):
* css/CSSCursorImageValue.cpp:
(WebCore::resourceReferencedByCursorElement):
(WebCore::CSSCursorImageValue::updateIfSVGCursorIsUsed):
* css/ElementRuleCollector.cpp:
(WebCore::ElementRuleCollector::matchAllRules):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::locateCousinList):
(WebCore::StyleResolver::canShareStyleWithElement):
(WebCore::StyleResolver::locateSharedStyle):
* dom/DocumentStyleSheetCollection.cpp:
(WebCore::DocumentStyleSheetCollection::collectActiveStyleSheets):
* dom/Element.cpp:
(WebCore::Element::synchronizeAllAttributes):
(WebCore::Element::synchronizeAttribute):
(WebCore::Element::boundsInRootViewSpace):
(WebCore::Element::getBoundingClientRect):
(WebCore::Element::childShouldCreateRenderer):
(WebCore::Element::fastAttributeLookupAllowed):
* dom/EventDispatcher.cpp:
(WebCore::eventTargetRespectingTargetRules):
* dom/ScriptElement.cpp:
(WebCore::toScriptElementIfPossible):
* dom/make_names.pl:
(printTypeHelpers):
* html/HTMLFrameOwnerElement.cpp:
(WebCore::HTMLFrameOwnerElement::getSVGDocument):
* inspector/InspectorCSSAgent.cpp:
(WebCore::InspectorCSSAgent::viaInspectorStyleSheet):
* mathml/MathMLElement.cpp:
(WebCore::MathMLElement::isPhrasingContent):
(WebCore::MathMLElement::childShouldCreateRenderer):
(WebCore::MathMLElement::attributeChanged):
* mathml/MathMLElement.h:
(WebCore::Node::hasTagName):
* mathml/MathMLSelectElement.cpp:
(WebCore::MathMLSelectElement::getSelectedSemanticsChild):
* page/EventHandler.cpp:
(WebCore::EventHandler::handleMousePressEvent):
(WebCore::EventHandler::handleMouseMoveEvent):
(WebCore::EventHandler::handleMouseReleaseEvent):
(WebCore::instanceAssociatedWithShadowTreeElement):
* page/Frame.cpp:
(WebCore::Frame::setPageAndTextZoomFactors):
* page/FrameView.cpp:
(WebCore::FrameView::scrollToAnchor):
* rendering/RenderTableCell.cpp:
(WebCore::RenderTableCell::parseColSpanFromDOM):
(WebCore::RenderTableCell::parseRowSpanFromDOM):
(WebCore::RenderTableCell::computePreferredLogicalWidths):
* rendering/mathml/RenderMathMLMenclose.cpp:
(WebCore::RenderMathMLMenclose::addChild):
(WebCore::RenderMathMLMenclose::computePreferredLogicalWidths):
(WebCore::RenderMathMLMenclose::updateLogicalHeight):
(WebCore::RenderMathMLMenclose::paint):
* rendering/svg/RenderSVGBlock.h:
(WebCore::RenderSVGBlock::graphicsElement):
* rendering/svg/RenderSVGForeignObject.cpp:
(WebCore::RenderSVGForeignObject::foreignObjectElement):
* rendering/svg/RenderSVGGradientStop.cpp:
(WebCore::RenderSVGGradientStop::gradientElement):
* rendering/svg/RenderSVGGradientStop.h:
* rendering/svg/RenderSVGImage.cpp:
(WebCore::RenderSVGImage::imageElement):
* rendering/svg/RenderSVGInline.h:
(WebCore::RenderSVGInline::graphicsElement):
* rendering/svg/RenderSVGModelObject.cpp:
(WebCore::getElementCTM):
(WebCore::RenderSVGModelObject::checkIntersection):
(WebCore::RenderSVGModelObject::checkEnclosure):
* rendering/svg/RenderSVGModelObject.h:
(WebCore::RenderSVGModelObject::element):
* rendering/svg/RenderSVGRect.cpp:
(WebCore::RenderSVGRect::rectElement):
* rendering/svg/RenderSVGResource.cpp:
(WebCore::removeFromCacheAndInvalidateDependencies):
* rendering/svg/RenderSVGResourceClipper.cpp:
(WebCore::RenderSVGResourceClipper::pathOnlyClipping):
(WebCore::RenderSVGResourceClipper::drawContentIntoMaskImage):
* rendering/svg/RenderSVGResourceClipper.h:
* rendering/svg/RenderSVGResourceContainer.cpp:
(WebCore::RenderSVGResourceContainer::transformOnNonScalingStroke):
* rendering/svg/RenderSVGResourceFilter.h:
* rendering/svg/RenderSVGResourceLinearGradient.h:
* rendering/svg/RenderSVGResourceMarker.h:
* rendering/svg/RenderSVGResourceMasker.h:
* rendering/svg/RenderSVGResourcePattern.cpp:
(WebCore::RenderSVGResourcePattern::patternElement):
* rendering/svg/RenderSVGResourceRadialGradient.h:
* rendering/svg/RenderSVGRoot.cpp:
(WebCore::RenderSVGRoot::svgSVGElement):
* rendering/svg/RenderSVGShape.h:
(WebCore::RenderSVGShape::graphicsElement):
* rendering/svg/RenderSVGText.cpp:
(WebCore::RenderSVGText::textElement):
* rendering/svg/RenderSVGTextPath.cpp:
(WebCore::RenderSVGTextPath::textPathElement):
(WebCore::RenderSVGTextPath::layoutPath):
* rendering/svg/RenderSVGTransformableContainer.cpp:
(WebCore::RenderSVGTransformableContainer::calculateLocalTransform):
* rendering/svg/RenderSVGTransformableContainer.h:
* rendering/svg/RenderSVGViewportContainer.cpp:
(WebCore::RenderSVGViewportContainer::svgSVGElement):
* rendering/svg/SVGPathData.cpp:
(WebCore::updatePathFromLineElement):
(WebCore::updatePathFromPathElement):
(WebCore::updatePathFromPolygonElement):
(WebCore::updatePathFromPolylineElement):
* rendering/svg/SVGRenderSupport.cpp:
(WebCore::SVGRenderSupport::layoutChildren):
(WebCore::SVGRenderSupport::applyStrokeStyleToContext):
(WebCore::SVGRenderSupport::updateMaskedAncestorShouldIsolateBlending):
* rendering/svg/SVGRenderTreeAsText.cpp:
(WebCore::operator<<):
* rendering/svg/SVGRenderingContext.cpp:
(WebCore::SVGRenderingContext::prepareToRenderSVGContent):
* rendering/svg/SVGResources.cpp:
(WebCore::targetReferenceFromResource):
(WebCore::SVGResources::buildCachedResources):
* rendering/svg/SVGTextLayoutEngine.cpp:
(WebCore::SVGTextLayoutEngine::layoutTextOnLineOrPath):
* svg/SVGAElement.cpp:
(WebCore::SVGAElement::createElementRenderer):
(WebCore::SVGAElement::defaultEventHandler):
* svg/SVGAltGlyphDefElement.cpp:
(WebCore::SVGAltGlyphDefElement::hasValidGlyphElements):
* svg/SVGAltGlyphElement.cpp:
(WebCore::SVGAltGlyphElement::hasValidGlyphElements):
* svg/SVGAnimateElement.cpp:
(WebCore::SVGAnimateElement::calculateAnimatedValue):
* svg/SVGAnimatedTransformList.cpp:
(WebCore::SVGAnimatedTransformListAnimator::SVGAnimatedTransformListAnimator):
* svg/SVGAnimationElement.cpp:
(WebCore::SVGAnimationElement::currentValuesForValuesAnimation):
(WebCore::SVGAnimationElement::adjustForInheritance):
* svg/SVGDocument.cpp:
(WebCore::SVGDocument::rootElement):
* svg/SVGElement.cpp:
(WebCore::SVGElement::ownerSVGElement):
(WebCore::SVGElement::viewportElement):
(WebCore::SVGElement::getBoundingBox):
(WebCore::SVGElement::childShouldCreateRenderer):
(WebCore::SVGElement::title):
(WebCore::SVGElement::updateRelativeLengthsInformation):
* svg/SVGElement.h:
(WebCore::Node::hasTagName):
* svg/SVGFEComponentTransferElement.cpp:
(WebCore::SVGFEComponentTransferElement::build):
* svg/SVGFEImageElement.cpp:
(WebCore::SVGFEImageElement::buildPendingResource):
* svg/SVGFilterElement.cpp:
(WebCore::SVGFilterElement::childShouldCreateRenderer):
* svg/SVGFilterPrimitiveStandardAttributes.h:
(WebCore::isSVGFilterPrimitiveStandardAttributes):
* svg/SVGFontData.cpp:
(WebCore::SVGFontData::applySVGGlyphSelection):
* svg/SVGFontElement.cpp:
(WebCore::SVGFontElement::ensureGlyphCache):
* svg/SVGFontFaceElement.cpp:
(WebCore::SVGFontFaceElement::rebuildFontFace):
* svg/SVGFontFaceFormatElement.cpp:
(WebCore::SVGFontFaceFormatElement::childrenChanged):
* svg/SVGFontFaceSrcElement.cpp:
(WebCore::SVGFontFaceSrcElement::srcValue):
(WebCore::SVGFontFaceSrcElement::childrenChanged):
* svg/SVGFontFaceUriElement.cpp:
(WebCore::SVGFontFaceUriElement::childrenChanged):
* svg/SVGGlyphElement.cpp:
(WebCore::SVGGlyphElement::invalidateGlyphCache):
* svg/SVGGraphicsElement.h:
(WebCore::isSVGGraphicsElement):
* svg/SVGHKernElement.cpp:
(WebCore::SVGHKernElement::insertedInto):
(WebCore::SVGHKernElement::removedFrom):
* svg/SVGImageLoader.cpp:
(WebCore::SVGImageLoader::dispatchLoadEvent):
* svg/SVGLengthContext.cpp:
(WebCore::SVGLengthContext::determineViewport):
* svg/SVGLinearGradientElement.cpp:
(WebCore::setGradientAttributes):
(WebCore::SVGLinearGradientElement::collectGradientAttributes):
* svg/SVGLocatable.cpp:
(WebCore::SVGLocatable::nearestViewportElement):
(WebCore::SVGLocatable::farthestViewportElement):
(WebCore::SVGLocatable::computeCTM):
(WebCore::SVGLocatable::getTransformToElement):
* svg/SVGMPathElement.cpp:
(WebCore::SVGMPathElement::buildPendingResource):
(WebCore::SVGMPathElement::pathElement):
(WebCore::SVGMPathElement::notifyParentOfPathChange):
* svg/SVGMarkerElement.cpp:
(WebCore::SVGMarkerElement::synchronizeOrientType):
(WebCore::SVGMarkerElement::lookupOrCreateOrientTypeWrapper):
* svg/SVGPathElement.cpp:
(WebCore::SVGPathElement::invalidateMPathDependencies):
(WebCore::SVGPathElement::lookupOrCreateDWrapper):
(WebCore::SVGPathElement::synchronizeD):
* svg/SVGPathSegList.cpp:
(WebCore::SVGPathSegList::commitChange):
* svg/SVGPatternElement.cpp:
(WebCore::SVGPatternElement::collectPatternAttributes):
* svg/SVGPolyElement.cpp:
(WebCore::SVGPolyElement::synchronizePoints):
(WebCore::SVGPolyElement::lookupOrCreatePointsWrapper):
* svg/SVGRadialGradientElement.cpp:
(WebCore::setGradientAttributes):
(WebCore::SVGRadialGradientElement::collectGradientAttributes):
* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::setupInitialView):
* svg/SVGTextContentElement.cpp:
(WebCore::SVGTextContentElement::synchronizeTextLength):
(WebCore::SVGTextContentElement::lookupOrCreateTextLengthWrapper):
(WebCore::SVGTextContentElement::elementFromRenderer):
* svg/SVGTextContentElement.h:
(WebCore::isSVGTextContentElement):
* svg/SVGTextPathElement.cpp:
(WebCore::SVGTextPathElement::buildPendingResource):
* svg/SVGUseElement.cpp:
(WebCore::dumpInstanceTree):
(WebCore::SVGUseElement::buildPendingResource):
(WebCore::SVGUseElement::toClipPath):
(WebCore::SVGUseElement::buildInstanceTree):
(WebCore::SVGUseElement::hasCycleUseReferencing):
(WebCore::SVGUseElement::expandUseElementsInShadowTree):
(WebCore::SVGUseElement::associateInstancesWithShadowTreeElements):
* svg/SVGVKernElement.cpp:
(WebCore::SVGVKernElement::insertedInto):
(WebCore::SVGVKernElement::removedFrom):
* svg/SVGViewSpec.cpp:
(WebCore::SVGViewSpec::viewTarget):
* svg/animation/SVGSMILElement.cpp:
(WebCore::SVGSMILElement::buildPendingResource):
(WebCore::SVGSMILElement::connectConditions):
(WebCore::SVGSMILElement::disconnectConditions):
* svg/animation/SVGSMILElement.h:
(WebCore::isSVGSMILElement):
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::hasSingleSecurityOrigin):
(WebCore::SVGImage::setContainerSize):
(WebCore::SVGImage::containerSize):
(WebCore::SVGImage::embeddedContentBox):
(WebCore::SVGImage::hasRelativeWidth):
(WebCore::SVGImage::hasRelativeHeight):
(WebCore::SVGImage::computeIntrinsicDimensions):
(WebCore::SVGImage::startAnimation):
(WebCore::SVGImage::stopAnimation):
* svg/graphics/filters/SVGFEImage.cpp:
(WebCore::FEImage::platformApplySoftware):
* svg/properties/SVGAnimatedPathSegListPropertyTearOff.h:
(WebCore::SVGAnimatedPathSegListPropertyTearOff::animValDidChange):
* svg/properties/SVGPathSegListPropertyTearOff.cpp:
(WebCore::SVGPathSegListPropertyTearOff::contextElement):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@173859
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2014-09-22 Christophe Dumez <cdumez@apple.com>
+
+ Use downcast<SVG*Element>() instead of toSVG*Element()
+ https://bugs.webkit.org/show_bug.cgi?id=137004
+
+ Reviewed by Benjamin Poulain.
+
+ Use downcast<SVG*Element>() instead of toSVG*Element() for casting SVG
+ Elements and get rid of the transition toSVG*Element() macros.
+
+ Also use downcast<MathML*Element>() instead of toMathML*Element() for
+ casting MathML Elements.
+
+ The HTML Elements casting counterparts will be taken care of in a
+ separate patch.
+
+ No new tests, no behavior change.
+
+ * accessibility/AccessibilityNodeObject.cpp:
+ (WebCore::AccessibilityNodeObject::alternativeText):
+ (WebCore::AccessibilityNodeObject::accessibilityDescription):
+ * accessibility/AccessibilityRenderObject.cpp:
+ (WebCore::AccessibilityRenderObject::remoteSVGRootElement):
+ * bindings/js/JSElementCustom.cpp:
+ (WebCore::toJSNewlyCreated):
+ * bindings/js/JSNodeCustom.cpp:
+ (WebCore::createWrapperInline):
+ * css/CSSComputedStyleDeclaration.cpp:
+ (WebCore::ComputedStyleExtractor::propertyValue):
+ * css/CSSCursorImageValue.cpp:
+ (WebCore::resourceReferencedByCursorElement):
+ (WebCore::CSSCursorImageValue::updateIfSVGCursorIsUsed):
+ * css/ElementRuleCollector.cpp:
+ (WebCore::ElementRuleCollector::matchAllRules):
+ * css/StyleResolver.cpp:
+ (WebCore::StyleResolver::locateCousinList):
+ (WebCore::StyleResolver::canShareStyleWithElement):
+ (WebCore::StyleResolver::locateSharedStyle):
+ * dom/DocumentStyleSheetCollection.cpp:
+ (WebCore::DocumentStyleSheetCollection::collectActiveStyleSheets):
+ * dom/Element.cpp:
+ (WebCore::Element::synchronizeAllAttributes):
+ (WebCore::Element::synchronizeAttribute):
+ (WebCore::Element::boundsInRootViewSpace):
+ (WebCore::Element::getBoundingClientRect):
+ (WebCore::Element::childShouldCreateRenderer):
+ (WebCore::Element::fastAttributeLookupAllowed):
+ * dom/EventDispatcher.cpp:
+ (WebCore::eventTargetRespectingTargetRules):
+ * dom/ScriptElement.cpp:
+ (WebCore::toScriptElementIfPossible):
+ * dom/make_names.pl:
+ (printTypeHelpers):
+ * html/HTMLFrameOwnerElement.cpp:
+ (WebCore::HTMLFrameOwnerElement::getSVGDocument):
+ * inspector/InspectorCSSAgent.cpp:
+ (WebCore::InspectorCSSAgent::viaInspectorStyleSheet):
+ * mathml/MathMLElement.cpp:
+ (WebCore::MathMLElement::isPhrasingContent):
+ (WebCore::MathMLElement::childShouldCreateRenderer):
+ (WebCore::MathMLElement::attributeChanged):
+ * mathml/MathMLElement.h:
+ (WebCore::Node::hasTagName):
+ * mathml/MathMLSelectElement.cpp:
+ (WebCore::MathMLSelectElement::getSelectedSemanticsChild):
+ * page/EventHandler.cpp:
+ (WebCore::EventHandler::handleMousePressEvent):
+ (WebCore::EventHandler::handleMouseMoveEvent):
+ (WebCore::EventHandler::handleMouseReleaseEvent):
+ (WebCore::instanceAssociatedWithShadowTreeElement):
+ * page/Frame.cpp:
+ (WebCore::Frame::setPageAndTextZoomFactors):
+ * page/FrameView.cpp:
+ (WebCore::FrameView::scrollToAnchor):
+ * rendering/RenderTableCell.cpp:
+ (WebCore::RenderTableCell::parseColSpanFromDOM):
+ (WebCore::RenderTableCell::parseRowSpanFromDOM):
+ (WebCore::RenderTableCell::computePreferredLogicalWidths):
+ * rendering/mathml/RenderMathMLMenclose.cpp:
+ (WebCore::RenderMathMLMenclose::addChild):
+ (WebCore::RenderMathMLMenclose::computePreferredLogicalWidths):
+ (WebCore::RenderMathMLMenclose::updateLogicalHeight):
+ (WebCore::RenderMathMLMenclose::paint):
+ * rendering/svg/RenderSVGBlock.h:
+ (WebCore::RenderSVGBlock::graphicsElement):
+ * rendering/svg/RenderSVGForeignObject.cpp:
+ (WebCore::RenderSVGForeignObject::foreignObjectElement):
+ * rendering/svg/RenderSVGGradientStop.cpp:
+ (WebCore::RenderSVGGradientStop::gradientElement):
+ * rendering/svg/RenderSVGGradientStop.h:
+ * rendering/svg/RenderSVGImage.cpp:
+ (WebCore::RenderSVGImage::imageElement):
+ * rendering/svg/RenderSVGInline.h:
+ (WebCore::RenderSVGInline::graphicsElement):
+ * rendering/svg/RenderSVGModelObject.cpp:
+ (WebCore::getElementCTM):
+ (WebCore::RenderSVGModelObject::checkIntersection):
+ (WebCore::RenderSVGModelObject::checkEnclosure):
+ * rendering/svg/RenderSVGModelObject.h:
+ (WebCore::RenderSVGModelObject::element):
+ * rendering/svg/RenderSVGRect.cpp:
+ (WebCore::RenderSVGRect::rectElement):
+ * rendering/svg/RenderSVGResource.cpp:
+ (WebCore::removeFromCacheAndInvalidateDependencies):
+ * rendering/svg/RenderSVGResourceClipper.cpp:
+ (WebCore::RenderSVGResourceClipper::pathOnlyClipping):
+ (WebCore::RenderSVGResourceClipper::drawContentIntoMaskImage):
+ * rendering/svg/RenderSVGResourceClipper.h:
+ * rendering/svg/RenderSVGResourceContainer.cpp:
+ (WebCore::RenderSVGResourceContainer::transformOnNonScalingStroke):
+ * rendering/svg/RenderSVGResourceFilter.h:
+ * rendering/svg/RenderSVGResourceLinearGradient.h:
+ * rendering/svg/RenderSVGResourceMarker.h:
+ * rendering/svg/RenderSVGResourceMasker.h:
+ * rendering/svg/RenderSVGResourcePattern.cpp:
+ (WebCore::RenderSVGResourcePattern::patternElement):
+ * rendering/svg/RenderSVGResourceRadialGradient.h:
+ * rendering/svg/RenderSVGRoot.cpp:
+ (WebCore::RenderSVGRoot::svgSVGElement):
+ * rendering/svg/RenderSVGShape.h:
+ (WebCore::RenderSVGShape::graphicsElement):
+ * rendering/svg/RenderSVGText.cpp:
+ (WebCore::RenderSVGText::textElement):
+ * rendering/svg/RenderSVGTextPath.cpp:
+ (WebCore::RenderSVGTextPath::textPathElement):
+ (WebCore::RenderSVGTextPath::layoutPath):
+ * rendering/svg/RenderSVGTransformableContainer.cpp:
+ (WebCore::RenderSVGTransformableContainer::calculateLocalTransform):
+ * rendering/svg/RenderSVGTransformableContainer.h:
+ * rendering/svg/RenderSVGViewportContainer.cpp:
+ (WebCore::RenderSVGViewportContainer::svgSVGElement):
+ * rendering/svg/SVGPathData.cpp:
+ (WebCore::updatePathFromLineElement):
+ (WebCore::updatePathFromPathElement):
+ (WebCore::updatePathFromPolygonElement):
+ (WebCore::updatePathFromPolylineElement):
+ * rendering/svg/SVGRenderSupport.cpp:
+ (WebCore::SVGRenderSupport::layoutChildren):
+ (WebCore::SVGRenderSupport::applyStrokeStyleToContext):
+ (WebCore::SVGRenderSupport::updateMaskedAncestorShouldIsolateBlending):
+ * rendering/svg/SVGRenderTreeAsText.cpp:
+ (WebCore::operator<<):
+ * rendering/svg/SVGRenderingContext.cpp:
+ (WebCore::SVGRenderingContext::prepareToRenderSVGContent):
+ * rendering/svg/SVGResources.cpp:
+ (WebCore::targetReferenceFromResource):
+ (WebCore::SVGResources::buildCachedResources):
+ * rendering/svg/SVGTextLayoutEngine.cpp:
+ (WebCore::SVGTextLayoutEngine::layoutTextOnLineOrPath):
+ * svg/SVGAElement.cpp:
+ (WebCore::SVGAElement::createElementRenderer):
+ (WebCore::SVGAElement::defaultEventHandler):
+ * svg/SVGAltGlyphDefElement.cpp:
+ (WebCore::SVGAltGlyphDefElement::hasValidGlyphElements):
+ * svg/SVGAltGlyphElement.cpp:
+ (WebCore::SVGAltGlyphElement::hasValidGlyphElements):
+ * svg/SVGAnimateElement.cpp:
+ (WebCore::SVGAnimateElement::calculateAnimatedValue):
+ * svg/SVGAnimatedTransformList.cpp:
+ (WebCore::SVGAnimatedTransformListAnimator::SVGAnimatedTransformListAnimator):
+ * svg/SVGAnimationElement.cpp:
+ (WebCore::SVGAnimationElement::currentValuesForValuesAnimation):
+ (WebCore::SVGAnimationElement::adjustForInheritance):
+ * svg/SVGDocument.cpp:
+ (WebCore::SVGDocument::rootElement):
+ * svg/SVGElement.cpp:
+ (WebCore::SVGElement::ownerSVGElement):
+ (WebCore::SVGElement::viewportElement):
+ (WebCore::SVGElement::getBoundingBox):
+ (WebCore::SVGElement::childShouldCreateRenderer):
+ (WebCore::SVGElement::title):
+ (WebCore::SVGElement::updateRelativeLengthsInformation):
+ * svg/SVGElement.h:
+ (WebCore::Node::hasTagName):
+ * svg/SVGFEComponentTransferElement.cpp:
+ (WebCore::SVGFEComponentTransferElement::build):
+ * svg/SVGFEImageElement.cpp:
+ (WebCore::SVGFEImageElement::buildPendingResource):
+ * svg/SVGFilterElement.cpp:
+ (WebCore::SVGFilterElement::childShouldCreateRenderer):
+ * svg/SVGFilterPrimitiveStandardAttributes.h:
+ (WebCore::isSVGFilterPrimitiveStandardAttributes):
+ * svg/SVGFontData.cpp:
+ (WebCore::SVGFontData::applySVGGlyphSelection):
+ * svg/SVGFontElement.cpp:
+ (WebCore::SVGFontElement::ensureGlyphCache):
+ * svg/SVGFontFaceElement.cpp:
+ (WebCore::SVGFontFaceElement::rebuildFontFace):
+ * svg/SVGFontFaceFormatElement.cpp:
+ (WebCore::SVGFontFaceFormatElement::childrenChanged):
+ * svg/SVGFontFaceSrcElement.cpp:
+ (WebCore::SVGFontFaceSrcElement::srcValue):
+ (WebCore::SVGFontFaceSrcElement::childrenChanged):
+ * svg/SVGFontFaceUriElement.cpp:
+ (WebCore::SVGFontFaceUriElement::childrenChanged):
+ * svg/SVGGlyphElement.cpp:
+ (WebCore::SVGGlyphElement::invalidateGlyphCache):
+ * svg/SVGGraphicsElement.h:
+ (WebCore::isSVGGraphicsElement):
+ * svg/SVGHKernElement.cpp:
+ (WebCore::SVGHKernElement::insertedInto):
+ (WebCore::SVGHKernElement::removedFrom):
+ * svg/SVGImageLoader.cpp:
+ (WebCore::SVGImageLoader::dispatchLoadEvent):
+ * svg/SVGLengthContext.cpp:
+ (WebCore::SVGLengthContext::determineViewport):
+ * svg/SVGLinearGradientElement.cpp:
+ (WebCore::setGradientAttributes):
+ (WebCore::SVGLinearGradientElement::collectGradientAttributes):
+ * svg/SVGLocatable.cpp:
+ (WebCore::SVGLocatable::nearestViewportElement):
+ (WebCore::SVGLocatable::farthestViewportElement):
+ (WebCore::SVGLocatable::computeCTM):
+ (WebCore::SVGLocatable::getTransformToElement):
+ * svg/SVGMPathElement.cpp:
+ (WebCore::SVGMPathElement::buildPendingResource):
+ (WebCore::SVGMPathElement::pathElement):
+ (WebCore::SVGMPathElement::notifyParentOfPathChange):
+ * svg/SVGMarkerElement.cpp:
+ (WebCore::SVGMarkerElement::synchronizeOrientType):
+ (WebCore::SVGMarkerElement::lookupOrCreateOrientTypeWrapper):
+ * svg/SVGPathElement.cpp:
+ (WebCore::SVGPathElement::invalidateMPathDependencies):
+ (WebCore::SVGPathElement::lookupOrCreateDWrapper):
+ (WebCore::SVGPathElement::synchronizeD):
+ * svg/SVGPathSegList.cpp:
+ (WebCore::SVGPathSegList::commitChange):
+ * svg/SVGPatternElement.cpp:
+ (WebCore::SVGPatternElement::collectPatternAttributes):
+ * svg/SVGPolyElement.cpp:
+ (WebCore::SVGPolyElement::synchronizePoints):
+ (WebCore::SVGPolyElement::lookupOrCreatePointsWrapper):
+ * svg/SVGRadialGradientElement.cpp:
+ (WebCore::setGradientAttributes):
+ (WebCore::SVGRadialGradientElement::collectGradientAttributes):
+ * svg/SVGSVGElement.cpp:
+ (WebCore::SVGSVGElement::setupInitialView):
+ * svg/SVGTextContentElement.cpp:
+ (WebCore::SVGTextContentElement::synchronizeTextLength):
+ (WebCore::SVGTextContentElement::lookupOrCreateTextLengthWrapper):
+ (WebCore::SVGTextContentElement::elementFromRenderer):
+ * svg/SVGTextContentElement.h:
+ (WebCore::isSVGTextContentElement):
+ * svg/SVGTextPathElement.cpp:
+ (WebCore::SVGTextPathElement::buildPendingResource):
+ * svg/SVGUseElement.cpp:
+ (WebCore::dumpInstanceTree):
+ (WebCore::SVGUseElement::buildPendingResource):
+ (WebCore::SVGUseElement::toClipPath):
+ (WebCore::SVGUseElement::buildInstanceTree):
+ (WebCore::SVGUseElement::hasCycleUseReferencing):
+ (WebCore::SVGUseElement::expandUseElementsInShadowTree):
+ (WebCore::SVGUseElement::associateInstancesWithShadowTreeElements):
+ * svg/SVGVKernElement.cpp:
+ (WebCore::SVGVKernElement::insertedInto):
+ (WebCore::SVGVKernElement::removedFrom):
+ * svg/SVGViewSpec.cpp:
+ (WebCore::SVGViewSpec::viewTarget):
+ * svg/animation/SVGSMILElement.cpp:
+ (WebCore::SVGSMILElement::buildPendingResource):
+ (WebCore::SVGSMILElement::connectConditions):
+ (WebCore::SVGSMILElement::disconnectConditions):
+ * svg/animation/SVGSMILElement.h:
+ (WebCore::isSVGSMILElement):
+ * svg/graphics/SVGImage.cpp:
+ (WebCore::SVGImage::hasSingleSecurityOrigin):
+ (WebCore::SVGImage::setContainerSize):
+ (WebCore::SVGImage::containerSize):
+ (WebCore::SVGImage::embeddedContentBox):
+ (WebCore::SVGImage::hasRelativeWidth):
+ (WebCore::SVGImage::hasRelativeHeight):
+ (WebCore::SVGImage::computeIntrinsicDimensions):
+ (WebCore::SVGImage::startAnimation):
+ (WebCore::SVGImage::stopAnimation):
+ * svg/graphics/filters/SVGFEImage.cpp:
+ (WebCore::FEImage::platformApplySoftware):
+ * svg/properties/SVGAnimatedPathSegListPropertyTearOff.h:
+ (WebCore::SVGAnimatedPathSegListPropertyTearOff::animValDidChange):
+ * svg/properties/SVGPathSegListPropertyTearOff.cpp:
+ (WebCore::SVGPathSegListPropertyTearOff::contextElement):
+
2014-09-22 Pratik Solanki <psolanki@apple.com>
Follow on fix for [iOS] ASSERTION FAILED: WTF::isMainThread() in WebCore::memoryCache() when using WebKit1
// SVG elements all can have a <svg:title> element inside which should act as the descriptive text.
if (node->isSVGElement())
- textOrder.append(AccessibilityText(toSVGElement(node)->title(), AlternativeText));
+ textOrder.append(AccessibilityText(downcast<SVGElement>(*node).title(), AlternativeText));
#if ENABLE(MATHML)
if (node->isMathMLElement())
// SVG elements all can have a <svg:title> element inside which should act as the descriptive text.
if (m_node && m_node->isSVGElement())
- return toSVGElement(m_node)->title();
+ return downcast<SVGElement>(*m_node).title();
#if ENABLE(MATHML)
if (m_node && m_node->isMathMLElement())
return nullptr;
Frame& frame = frameView->frame();
- Document* doc = frame.document();
- if (!doc || !doc->isSVGDocument())
+ Document* document = frame.document();
+ if (!document || !document->isSVGDocument())
return nullptr;
- SVGSVGElement* rootElement = toSVGDocument(doc)->rootElement();
+ SVGSVGElement* rootElement = downcast<SVGDocument>(*document).rootElement();
if (!rootElement)
return nullptr;
RenderObject* rendererRoot = rootElement->renderer();
if (element->isHTMLElement())
wrapper = createJSHTMLWrapper(globalObject, toHTMLElement(element));
else if (element->isSVGElement())
- wrapper = createJSSVGWrapper(globalObject, toSVGElement(element));
+ wrapper = createJSSVGWrapper(globalObject, downcast<SVGElement>(element));
else
wrapper = CREATE_DOM_WRAPPER(globalObject, Element, element);
if (node->isHTMLElement())
wrapper = createJSHTMLWrapper(globalObject, toHTMLElement(node));
else if (node->isSVGElement())
- wrapper = createJSSVGWrapper(globalObject, toSVGElement(node));
+ wrapper = createJSSVGWrapper(globalObject, downcast<SVGElement>(node));
else
wrapper = CREATE_DOM_WRAPPER(globalObject, Element, node);
break;
renderer = styledNode->renderer();
- if (propertyID == CSSPropertyDisplay && !renderer && isSVGElement(*styledNode) && !toSVGElement(*styledNode).isValid())
+ if (propertyID == CSSPropertyDisplay && !renderer && isSVGElement(*styledNode) && !downcast<SVGElement>(*styledNode).isValid())
return nullptr;
style = computeRenderStyleForProperty(styledNode, m_pseudoElementSpecifier, propertyID);
{
Element* element = SVGURIReference::targetElementFromIRIString(url, document);
if (element && isSVGCursorElement(element))
- return toSVGCursorElement(element);
+ return downcast<SVGCursorElement>(element);
- return 0;
+ return nullptr;
}
CSSCursorImageValue::CSSCursorImageValue(PassRef<CSSValue> imageValue, bool hasHotSpot, const IntPoint& hotSpot)
if (cachedImageURL() != element->document().completeURL(cursorElement->href()))
clearCachedImage();
- SVGElement* svgElement = toSVGElement(element);
- m_referencedElements.add(svgElement);
- svgElement->setCursorImageValue(this);
- cursorElement->addClient(svgElement);
+ SVGElement& svgElement = downcast<SVGElement>(*element);
+ m_referencedElements.add(&svgElement);
+ svgElement.setCursorImageValue(this);
+ cursorElement->addClient(&svgElement);
return true;
}
// Now check SMIL animation override style.
if (includeSMILProperties && styledElement.isSVGElement())
- addElementStyleProperties(toSVGElement(styledElement).animatedSMILStyleProperties(), false /* isCacheable */);
+ addElementStyleProperties(downcast<SVGElement>(styledElement).animatedSMILStyleProperties(), false /* isCacheable */);
}
}
return 0;
if (!parent || !parent->isStyledElement())
return 0;
- StyledElement* p = toStyledElement(parent);
- if (p->inlineStyle())
+ StyledElement* styledParent = toStyledElement(parent);
+ if (styledParent->inlineStyle())
return 0;
- if (p->isSVGElement() && toSVGElement(p)->animatedSMILStyleProperties())
+ if (styledParent->isSVGElement() && downcast<SVGElement>(*styledParent).animatedSMILStyleProperties())
return 0;
- if (p->hasID() && m_ruleSets.features().idsInRules.contains(p->idForStyleResolution().impl()))
+ if (styledParent->hasID() && m_ruleSets.features().idsInRules.contains(styledParent->idForStyleResolution().impl()))
return 0;
- RenderStyle* parentStyle = p->renderStyle();
+ RenderStyle* parentStyle = styledParent->renderStyle();
unsigned subcount = 0;
- Node* thisCousin = p;
- Node* currentNode = p->previousSibling();
+ Node* thisCousin = styledParent;
+ Node* currentNode = styledParent->previousSibling();
// Reserve the tries for this level. This effectively makes sure that the algorithm
// will never go deeper than cStyleSearchLevelThreshold levels into recursion.
return false;
if (element->needsStyleRecalc())
return false;
- if (element->isSVGElement() && toSVGElement(element)->animatedSMILStyleProperties())
+ if (element->isSVGElement() && downcast<SVGElement>(*element).animatedSMILStyleProperties())
return false;
if (element->isLink() != state.element()->isLink())
return false;
{
State& state = m_state;
if (!state.styledElement() || !state.parentStyle())
- return 0;
+ return nullptr;
// If the element has inline style it is probably unique.
if (state.styledElement()->inlineStyle())
- return 0;
- if (state.styledElement()->isSVGElement() && toSVGElement(state.styledElement())->animatedSMILStyleProperties())
- return 0;
+ return nullptr;
+ if (state.styledElement()->isSVGElement() && downcast<SVGElement>(*state.styledElement()).animatedSMILStyleProperties())
+ return nullptr;
// Ids stop style sharing if they show up in the stylesheets.
if (state.styledElement()->hasID() && m_ruleSets.features().idsInRules.contains(state.styledElement()->idForStyleResolution().impl()))
- return 0;
+ return nullptr;
if (parentElementPreventsSharing(state.element()->parentElement()))
- return 0;
+ return nullptr;
if (state.element() == state.document().cssTarget())
- return 0;
+ return nullptr;
if (elementHasDirectionAuto(state.element()))
- return 0;
+ return nullptr;
// Cache whether state.element is affected by any known class selectors.
// FIXME: This shouldn't be a member variable. The style sharing code could be factored out of StyleResolver.
// If we have exhausted all our budget or our cousins.
if (!shareElement)
- return 0;
+ return nullptr;
// Can't share if sibling rules apply. This is checked at the end as it should rarely fail.
if (styleSharingCandidateMatchesRuleSet(m_ruleSets.sibling()))
- return 0;
+ return nullptr;
// Can't share if attribute rules apply.
if (styleSharingCandidateMatchesRuleSet(m_ruleSets.uncommonAttribute()))
- return 0;
+ return nullptr;
// Tracking child index requires unique style for each node. This may get set by the sibling rule match above.
if (parentElementPreventsSharing(state.element()->parentElement()))
- return 0;
+ return nullptr;
return shareElement->renderStyle();
}
return;
}
#endif
- } else if ((node->isHTMLElement() && (toHTMLElement(*node).hasTagName(linkTag) || toHTMLElement(*node).hasTagName(styleTag))) || (node->isSVGElement() && toSVGElement(*node).hasTagName(SVGNames::styleTag))) {
+ } else if ((node->isHTMLElement() && (toHTMLElement(*node).hasTagName(linkTag) || toHTMLElement(*node).hasTagName(styleTag))) || (node->isSVGElement() && downcast<SVGElement>(*node).hasTagName(SVGNames::styleTag))) {
Element& element = toElement(*node);
AtomicString title = element.fastGetAttribute(titleAttr);
bool enabledViaScript = false;
// Get the current preferred styleset. This is the
// set of sheets that will be enabled.
if (isSVGStyleElement(element))
- sheet = toSVGStyleElement(element).sheet();
+ sheet = downcast<SVGStyleElement>(element).sheet();
else if (isHTMLLinkElement(element))
sheet = toHTMLLinkElement(element).sheet();
else
if (elementData()->animatedSVGAttributesAreDirty()) {
ASSERT(isSVGElement());
- toSVGElement(this)->synchronizeAnimatedSVGAttribute(anyQName());
+ downcast<SVGElement>(*this).synchronizeAnimatedSVGAttribute(anyQName());
}
}
if (UNLIKELY(elementData()->animatedSVGAttributesAreDirty())) {
ASSERT(isSVGElement());
- toSVGElement(this)->synchronizeAnimatedSVGAttribute(name);
+ downcast<SVGElement>(*this).synchronizeAnimatedSVGAttribute(name);
}
}
if (elementData()->animatedSVGAttributesAreDirty()) {
// We're not passing a namespace argument on purpose. SVGNames::*Attr are defined w/o namespaces as well.
ASSERT_WITH_SECURITY_IMPLICATION(isSVGElement());
- toSVGElement(this)->synchronizeAnimatedSVGAttribute(QualifiedName(nullAtom, localName, nullAtom));
+ downcast<SVGElement>(*this).synchronizeAnimatedSVGAttribute(QualifiedName(nullAtom, localName, nullAtom));
}
}
if (isSVGElement() && renderer()) {
// Get the bounding rectangle from the SVG model.
- SVGElement* svgElement = toSVGElement(this);
+ SVGElement& svgElement = downcast<SVGElement>(*this);
FloatRect localRect;
- if (svgElement->getBoundingBox(localRect))
+ if (svgElement.getBoundingBox(localRect))
quads.append(renderer()->localToAbsoluteQuad(localRect));
} else {
// Get the bounding rectangle from the box model.
Vector<FloatQuad> quads;
if (isSVGElement() && renderer() && !renderer()->isSVGRoot()) {
// Get the bounding rectangle from the SVG model.
- SVGElement* svgElement = toSVGElement(this);
+ SVGElement& svgElement = downcast<SVGElement>(*this);
FloatRect localRect;
- if (svgElement->getBoundingBox(localRect))
+ if (svgElement.getBoundingBox(localRect))
quads.append(renderer()->localToAbsoluteQuad(localRect));
} else {
// Get the bounding rectangle from the box model.
// Only create renderers for SVG elements whose parents are SVG elements, or for proper <svg xmlns="svgNS"> subdocuments.
if (child.isSVGElement()) {
ASSERT(!isSVGElement());
- return child.hasTagName(SVGNames::svgTag) && toSVGElement(child).isValid();
+ const SVGElement& childElement = downcast<SVGElement>(child);
+ return isSVGSVGElement(childElement) && childElement.isValid();
}
return true;
}
return false;
if (isSVGElement())
- return !toSVGElement(this)->isAnimatableAttribute(name);
+ return !downcast<SVGElement>(*this).isAnimatableAttribute(name);
return true;
}
// At this time, SVG nodes are not supported in non-<use> shadow trees.
if (!shadowHostElement || !shadowHostElement->hasTagName(SVGNames::useTag))
return referenceNode;
- SVGUseElement* useElement = toSVGUseElement(shadowHostElement);
- if (SVGElementInstance* instance = useElement->instanceForShadowTreeElement(&referenceNode))
+ SVGUseElement& useElement = downcast<SVGUseElement>(*shadowHostElement);
+ if (SVGElementInstance* instance = useElement.instanceForShadowTreeElement(&referenceNode))
return *instance;
return referenceNode;
return toHTMLScriptElement(element);
if (isSVGScriptElement(element))
- return toSVGScriptElement(element);
+ return downcast<SVGScriptElement>(element);
- return 0;
+ return nullptr;
}
}
struct ElementTypeCastTraits<const $class, ArgType> {
static bool is(ArgType& node) { return $checkHelper(node); }
};
-
+END
+ ;
+ if ($parameters{namespace} eq "HTML") {
+ print F <<END
// FIXME: Remove these macros once the code has been ported to using
// downcast<*Element>().
#define to$class(x) WebCore::downcast<WebCore::$class>(x)
END
- ;
-
+ ;
+ }
print F "\n";
}
}
SVGDocument* HTMLFrameOwnerElement::getSVGDocument(ExceptionCode& ec) const
{
- Document* doc = contentDocument();
- if (doc && doc->isSVGDocument())
- return toSVGDocument(doc);
+ Document* document = contentDocument();
+ if (document && document->isSVGDocument())
+ return downcast<SVGDocument>(document);
// Spec: http://www.w3.org/TR/SVG/struct.html#InterfaceGetSVGDocument
ec = NOT_SUPPORTED_ERR;
- return 0;
+ return nullptr;
}
void HTMLFrameOwnerElement::scheduleSetNeedsStyleRecalc(StyleChangeType changeType)
if (styleElement->isHTMLElement())
cssStyleSheet = toHTMLStyleElement(styleElement.get())->sheet();
else if (styleElement->isSVGElement())
- cssStyleSheet = toSVGStyleElement(styleElement.get())->sheet();
+ cssStyleSheet = downcast<SVGStyleElement>(*styleElement).sheet();
if (!cssStyleSheet)
return nullptr;
return node.isTextNode();
if (node.isMathMLElement()) {
- auto& mathmlElement = toMathMLElement(node);
+ auto& mathmlElement = downcast<MathMLElement>(node);
return mathmlElement.hasTagName(MathMLNames::mathTag);
}
if (node.isSVGElement()) {
- auto& svgElement = toSVGElement(node);
+ auto& svgElement = downcast<SVGElement>(node);
return svgElement.hasTagName(SVGNames::svgTag);
}
// See annotation-xml.model.mathml, annotation-xml.model.svg and annotation-xml.model.xhtml in the HTML5 RelaxNG schema.
if (child.isMathMLElement() && (MathMLSelectElement::isMathMLEncoding(value) || MathMLSelectElement::isHTMLEncoding(value))) {
- auto& mathmlElement = toMathMLElement(child);
+ auto& mathmlElement = downcast<MathMLElement>(child);
return mathmlElement.hasTagName(MathMLNames::mathTag);
}
if (child.isSVGElement() && (MathMLSelectElement::isSVGEncoding(value) || MathMLSelectElement::isHTMLEncoding(value))) {
- auto& svgElement = toSVGElement(child);
+ auto& svgElement = downcast<SVGElement>(child);
return svgElement.hasTagName(SVGNames::svgTag);
}
if (isSemanticAnnotation() && (name == MathMLNames::srcAttr || name == MathMLNames::encodingAttr)) {
Element* parent = parentElement();
if (parent && parent->isMathMLElement() && parent->hasTagName(semanticsTag))
- toMathMLElement(parent)->updateSelectedChild();
+ downcast<MathMLElement>(*parent).updateSelectedChild();
}
StyledElement::attributeChanged(name, oldValue, newValue, reason);
}
inline bool Node::hasTagName(const MathMLQualifiedName& name) const
{
- return isMathMLElement() && toMathMLElement(*this).hasTagName(name);
+ return isMathMLElement() && downcast<MathMLElement>(*this).hasTagName(name);
}
} // namespace WebCore
Element* child = firstElementChild();
if (!child)
- return child;
+ return nullptr;
- if (!child->isMathMLElement() || !toMathMLElement(child)->isPresentationMathML()) {
+ if (!child->isMathMLElement() || !downcast<MathMLElement>(*child).isPresentationMathML()) {
// The first child is not a presentation MathML element. Hence we move to the second child and start searching an annotation child that could be displayed.
child = child->nextElementSibling();
- } else if (!toMathMLElement(child)->isSemanticAnnotation()) {
+ } else if (!downcast<MathMLElement>(*child).isSemanticAnnotation()) {
// The first child is a presentation MathML but not an annotation, so we can just display it.
return child;
}
return true;
if (m_frame.document()->isSVGDocument()
- && toSVGDocument(m_frame.document())->zoomAndPanEnabled()) {
+ && downcast<SVGDocument>(*m_frame.document()).zoomAndPanEnabled()) {
if (event.event().shiftKey() && singleClick) {
m_svgPan = true;
- toSVGDocument(m_frame.document())->startPan(m_frame.view()->windowToContents(event.event().position()));
+ downcast<SVGDocument>(*m_frame.document()).startPan(m_frame.view()->windowToContents(event.event().position()));
return true;
}
}
#endif
if (m_svgPan) {
- toSVGDocument(m_frame.document())->updatePan(m_frame.view()->windowToContents(m_lastKnownMousePosition));
+ downcast<SVGDocument>(m_frame.document())->updatePan(m_frame.view()->windowToContents(m_lastKnownMousePosition));
return true;
}
if (m_svgPan) {
m_svgPan = false;
- toSVGDocument(m_frame.document())->updatePan(m_frame.view()->windowToContents(m_lastKnownMousePosition));
+ downcast<SVGDocument>(m_frame.document())->updatePan(m_frame.view()->windowToContents(m_lastKnownMousePosition));
return true;
}
static inline SVGElementInstance* instanceAssociatedWithShadowTreeElement(Node* referenceNode)
{
if (!referenceNode || !referenceNode->isSVGElement())
- return 0;
+ return nullptr;
ShadowRoot* shadowRoot = referenceNode->containingShadowRoot();
if (!shadowRoot)
- return 0;
+ return nullptr;
Element* shadowTreeParentElement = shadowRoot->hostElement();
if (!shadowTreeParentElement || !shadowTreeParentElement->hasTagName(useTag))
- return 0;
+ return nullptr;
- return toSVGUseElement(shadowTreeParentElement)->instanceForShadowTreeElement(referenceNode);
+ return downcast<SVGUseElement>(*shadowTreeParentElement).instanceForShadowTreeElement(referenceNode);
}
static RenderElement* nearestCommonHoverAncestor(RenderElement* obj1, RenderElement* obj2)
// Respect SVGs zoomAndPan="disabled" property in standalone SVG documents.
// FIXME: How to handle compound documents + zoomAndPan="disabled"? Needs SVG WG clarification.
if (document->isSVGDocument()) {
- if (!toSVGDocument(document)->zoomAndPanEnabled())
+ if (!downcast<SVGDocument>(*document).zoomAndPanEnabled())
return;
}
frame().document()->setCSSTarget(anchorElement);
if (frame().document()->isSVGDocument()) {
- if (SVGSVGElement* svg = toSVGDocument(frame().document())->rootElement()) {
+ if (SVGSVGElement* svg = downcast<SVGDocument>(*frame().document()).rootElement()) {
svg->setupInitialView(name, anchorElement);
if (!anchorElement)
return true;
return std::min<unsigned>(toHTMLTableCellElement(element())->colSpan(), maxColumnIndex);
#if ENABLE(MATHML)
if (element()->hasTagName(MathMLNames::mtdTag))
- return std::min<unsigned>(toMathMLElement(element())->colSpan(), maxColumnIndex);
+ return std::min<unsigned>(downcast<MathMLElement>(*element()).colSpan(), maxColumnIndex);
#endif
return 1;
}
return std::min<unsigned>(toHTMLTableCellElement(element())->rowSpan(), maxRowIndex);
#if ENABLE(MATHML)
if (element()->hasTagName(MathMLNames::mtdTag))
- return std::min<unsigned>(toMathMLElement(element())->rowSpan(), maxRowIndex);
+ return std::min<unsigned>(downcast<MathMLElement>(*element()).rowSpan(), maxRowIndex);
#endif
return 1;
}
void RenderMathMLMenclose::addChild(RenderObject* newChild, RenderObject* beforeChild)
{
- MathMLMencloseElement* menclose = toMathMLMencloseElement(element());
+ MathMLMencloseElement* menclose = downcast<MathMLMencloseElement>(element());
// Allow an anonymous RenderMathMLSquareRoot to handle drawing the radical
// notation, rather than duplicating the code needed to paint a root.
if (!firstChild() && menclose->isRadical())
RenderMathMLBlock::computePreferredLogicalWidths();
const int paddingTop = 6;
- MathMLMencloseElement* menclose = toMathMLMencloseElement(element());
+ MathMLMencloseElement* menclose = downcast<MathMLMencloseElement>(element());
const Vector<String>& notationValues = menclose->notationValues();
size_t notationalValueSize = notationValues.size();
for (size_t i = 0; i < notationalValueSize; i++) {
void RenderMathMLMenclose::updateLogicalHeight()
{
- MathMLMencloseElement* menclose = toMathMLMencloseElement(element());
+ MathMLMencloseElement* menclose = downcast<MathMLMencloseElement>(element());
const Vector<String>& notationValues = menclose->notationValues();
size_t notationalValueSize = notationValues.size();
for (size_t i = 0; i < notationalValueSize; i++)
if (info.context->paintingDisabled() || info.phase != PaintPhaseForeground || style().visibility() != VISIBLE)
return;
- MathMLMencloseElement* menclose = toMathMLMencloseElement(element());
+ MathMLMencloseElement* menclose = downcast<MathMLMencloseElement>(element());
const Vector<String>& notationValues = menclose->notationValues();
size_t notationalValueSize = notationValues.size();
bool isDefaultLongDiv = menclose->isDefaultLongDiv();
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>);
SVGForeignObjectElement& RenderSVGForeignObject::foreignObjectElement() const
{
- return toSVGForeignObjectElement(RenderSVGBlock::graphicsElement());
+ return downcast<SVGForeignObjectElement>(RenderSVGBlock::graphicsElement());
}
void RenderSVGForeignObject::paint(PaintInfo& paintInfo, const LayoutPoint&)
SVGGradientElement* RenderSVGGradientStop::gradientElement()
{
if (element().parentElement() && isSVGGradientElement(*element().parentElement()))
- return &toSVGGradientElement(*element().parentElement());
+ return &downcast<SVGGradientElement>(*element().parentElement());
return nullptr;
}
RenderSVGGradientStop(SVGStopElement&, PassRef<RenderStyle>);
virtual ~RenderSVGGradientStop();
- SVGStopElement& element() const { return toSVGStopElement(RenderObject::nodeForNonAnonymous()); }
+ SVGStopElement& element() const { return downcast<SVGStopElement>(RenderObject::nodeForNonAnonymous()); }
private:
virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override;
SVGImageElement& RenderSVGImage::imageElement() const
{
- return toSVGImageElement(RenderSVGModelObject::element());
+ return downcast<SVGImageElement>(RenderSVGModelObject::element());
}
bool RenderSVGImage::updateImageViewport()
public:
RenderSVGInline(SVGGraphicsElement&, PassRef<RenderStyle>);
- SVGGraphicsElement& graphicsElement() const { return toSVGGraphicsElement(nodeForNonAnonymous()); }
+ SVGGraphicsElement& graphicsElement() const { return downcast<SVGGraphicsElement>(nodeForNonAnonymous()); }
private:
void element() const = delete;
Node* current = element;
while (current && current->isSVGElement()) {
- SVGElement* currentElement = toSVGElement(current);
- localTransform = currentElement->renderer()->localToParentTransform();
+ SVGElement& currentElement = downcast<SVGElement>(*current);
+ localTransform = currentElement.renderer()->localToParentTransform();
transform = localTransform.multiply(transform);
// For getCTM() computation, stop at the nearest viewport element
- if (currentElement == stopAtElement)
+ if (¤tElement == stopAtElement)
break;
current = current->parentOrShadowHostNode();
if (!isGraphicsElement(*renderer))
return false;
AffineTransform ctm;
- SVGElement* svgElement = toSVGElement(renderer->element());
+ SVGElement* svgElement = downcast<SVGElement>(renderer->element());
getElementCTM(svgElement, ctm);
ASSERT(svgElement->renderer());
return intersectsAllowingEmpty(rect, ctm.mapRect(svgElement->renderer()->repaintRectInLocalCoordinates()));
if (!isGraphicsElement(*renderer))
return false;
AffineTransform ctm;
- SVGElement* svgElement = toSVGElement(renderer->element());
+ SVGElement* svgElement = downcast<SVGElement>(renderer->element());
getElementCTM(svgElement, ctm);
ASSERT(svgElement->renderer());
return rect.contains(ctm.mapRect(svgElement->renderer()->repaintRectInLocalCoordinates()));
bool hasSVGShadow() const { return m_hasSVGShadow; }
void setHasSVGShadow(bool hasShadow) { m_hasSVGShadow = hasShadow; }
- SVGElement& element() const { return toSVGElement(nodeForNonAnonymous()); }
+ SVGElement& element() const { return downcast<SVGElement>(nodeForNonAnonymous()); }
protected:
RenderSVGModelObject(SVGElement&, PassRef<RenderStyle>);
SVGRectElement& RenderSVGRect::rectElement() const
{
- return toSVGRectElement(RenderSVGShape::graphicsElement());
+ return downcast<SVGRectElement>(RenderSVGShape::graphicsElement());
}
void RenderSVGRect::updateShapeFromElement()
if (!renderer.element() || !renderer.element()->isSVGElement())
return;
- HashSet<SVGElement*>* dependencies = renderer.document().accessSVGExtensions()->setOfElementsReferencingTarget(toSVGElement(renderer.element()));
+ HashSet<SVGElement*>* dependencies = renderer.document().accessSVGExtensions()->setOfElementsReferencingTarget(downcast<SVGElement>(renderer.element()));
if (!dependencies)
return;
for (auto* element : *dependencies) {
// Only shapes or paths are supported for direct clipping. We need to fallback to masking for texts.
if (renderer->isSVGText())
return false;
- if (!childNode->isSVGElement() || !toSVGElement(childNode)->isSVGGraphicsElement())
+ 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;
return false;
// Fallback to masking, if there is more than one clipping path.
if (clipPath.isEmpty()) {
- styled->toClipPath(clipPath);
+ styled.toClipPath(clipPath);
clipRule = svgStyle.clipRule();
} else
return false;
WindRule newClipRule = style.svgStyle().clipRule();
bool isUseElement = child.hasTagName(SVGNames::useTag);
if (isUseElement) {
- SVGUseElement& useElement = toSVGUseElement(child);
+ SVGUseElement& useElement = downcast<SVGUseElement>(child);
renderer = useElement.rendererClipChild();
if (!renderer)
continue;
RenderSVGResourceClipper(SVGClipPathElement&, PassRef<RenderStyle>);
virtual ~RenderSVGResourceClipper();
- SVGClipPathElement& clipPathElement() const { return toSVGClipPathElement(nodeForNonAnonymous()); }
+ SVGClipPathElement& clipPathElement() const { return downcast<SVGClipPathElement>(nodeForNonAnonymous()); }
virtual void removeAllClientsFromCache(bool markForInvalidation = true) override;
virtual void removeClientFromCache(RenderElement&, bool markForInvalidation = true) override;
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;
RenderSVGResourceFilter(SVGFilterElement&, PassRef<RenderStyle>);
virtual ~RenderSVGResourceFilter();
- SVGFilterElement& filterElement() const { return toSVGFilterElement(RenderSVGResourceContainer::element()); }
+ SVGFilterElement& filterElement() const { return downcast<SVGFilterElement>(RenderSVGResourceContainer::element()); }
virtual void removeAllClientsFromCache(bool markForInvalidation = true) override;
virtual void removeClientFromCache(RenderElement&, bool markForInvalidation = true) override;
RenderSVGResourceLinearGradient(SVGLinearGradientElement&, PassRef<RenderStyle>);
virtual ~RenderSVGResourceLinearGradient();
- SVGLinearGradientElement& linearGradientElement() const { return toSVGLinearGradientElement(RenderSVGResourceGradient::gradientElement()); }
+ SVGLinearGradientElement& linearGradientElement() const { return downcast<SVGLinearGradientElement>(RenderSVGResourceGradient::gradientElement()); }
virtual RenderSVGResourceType resourceType() const { return s_resourceType; }
static RenderSVGResourceType s_resourceType;
RenderSVGResourceMarker(SVGMarkerElement&, PassRef<RenderStyle>);
virtual ~RenderSVGResourceMarker();
- SVGMarkerElement& markerElement() const { return toSVGMarkerElement(RenderSVGResourceContainer::element()); }
+ SVGMarkerElement& markerElement() const { return downcast<SVGMarkerElement>(RenderSVGResourceContainer::element()); }
virtual void removeAllClientsFromCache(bool markForInvalidation = true) override;
virtual void removeClientFromCache(RenderElement&, bool markForInvalidation = true) override;
RenderSVGResourceMasker(SVGMaskElement&, PassRef<RenderStyle>);
virtual ~RenderSVGResourceMasker();
- SVGMaskElement& maskElement() const { return toSVGMaskElement(RenderSVGResourceContainer::element()); }
+ SVGMaskElement& maskElement() const { return downcast<SVGMaskElement>(RenderSVGResourceContainer::element()); }
virtual void removeAllClientsFromCache(bool markForInvalidation = true) override;
virtual void removeClientFromCache(RenderElement&, bool markForInvalidation = true) override;
SVGPatternElement& RenderSVGResourcePattern::patternElement() const
{
- return toSVGPatternElement(RenderSVGResourceContainer::element());
+ return downcast<SVGPatternElement>(RenderSVGResourceContainer::element());
}
void RenderSVGResourcePattern::removeAllClientsFromCache(bool markForInvalidation)
RenderSVGResourceRadialGradient(SVGRadialGradientElement&, PassRef<RenderStyle>);
virtual ~RenderSVGResourceRadialGradient();
- SVGRadialGradientElement& radialGradientElement() const { return toSVGRadialGradientElement(RenderSVGResourceGradient::gradientElement()); }
+ SVGRadialGradientElement& radialGradientElement() const { return downcast<SVGRadialGradientElement>(RenderSVGResourceGradient::gradientElement()); }
virtual RenderSVGResourceType resourceType() const { return s_resourceType; }
static RenderSVGResourceType s_resourceType;
SVGSVGElement& RenderSVGRoot::svgSVGElement() const
{
- return toSVGSVGElement(nodeForNonAnonymous());
+ return downcast<SVGSVGElement>(nodeForNonAnonymous());
}
void RenderSVGRoot::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, double& intrinsicRatio) const
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; }
SVGTextElement& RenderSVGText::textElement() const
{
- return toSVGTextElement(RenderSVGBlock::graphicsElement());
+ return downcast<SVGTextElement>(RenderSVGBlock::graphicsElement());
}
bool RenderSVGText::isChildAllowed(const RenderObject& child, const RenderStyle&) const
SVGTextPathElement& RenderSVGTextPath::textPathElement() const
{
- return toSVGTextPathElement(RenderSVGInline::graphicsElement());
+ return downcast<SVGTextPathElement>(RenderSVGInline::graphicsElement());
}
Path RenderSVGTextPath::layoutPath() const
if (!targetElement || !targetElement->hasTagName(SVGNames::pathTag))
return Path();
- SVGPathElement* pathElement = toSVGPathElement(targetElement);
+ SVGPathElement& pathElement = downcast<SVGPathElement>(*targetElement);
Path pathData;
- updatePathFromGraphicsElement(pathElement, pathData);
+ updatePathFromGraphicsElement(&pathElement, pathData);
// Spec: The transform attribute on the referenced 'path' element represents a
// supplemental transformation relative to the current user coordinate system for
// the current 'text' element, including any adjustments to the current user coordinate
// system due to a possible transform attribute on the current 'text' element.
// http://www.w3.org/TR/SVG/text.html#TextPathElement
- pathData.transform(pathElement->animatedLocalTransform());
+ pathData.transform(pathElement.animatedLocalTransform());
return pathData;
}
// If we're either the renderer for a <use> element, or for any <g> element inside the shadow
// tree, that was created during the use/symbol/svg expansion in SVGUseElement. These containers
// need to respect the translations induced by their corresponding use elements x/y attributes.
- SVGUseElement* useElement = 0;
+ SVGUseElement* useElement = nullptr;
if (isSVGUseElement(element))
- useElement = &toSVGUseElement(element);
+ useElement = &downcast<SVGUseElement>(element);
else if (element.isInShadowTree() && isSVGGElement(element)) {
SVGElement* correspondingElement = element.correspondingElement();
if (correspondingElement && isSVGUseElement(correspondingElement))
- useElement = toSVGUseElement(correspondingElement);
+ useElement = downcast<SVGUseElement>(correspondingElement);
}
if (useElement) {
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; }
SVGSVGElement& RenderSVGViewportContainer::svgSVGElement() const
{
- return toSVGSVGElement(RenderSVGContainer::element());
+ return downcast<SVGSVGElement>(RenderSVGContainer::element());
}
void RenderSVGViewportContainer::determineIfLayoutSizeChanged()
static void updatePathFromLineElement(SVGElement* element, Path& path)
{
- SVGLineElement* line = toSVGLineElement(element);
+ SVGLineElement* line = downcast<SVGLineElement>(element);
SVGLengthContext lengthContext(element);
path.moveTo(FloatPoint(line->x1().value(lengthContext), line->y1().value(lengthContext)));
static void updatePathFromPathElement(SVGElement* element, Path& path)
{
- buildPathFromByteStream(toSVGPathElement(element)->pathByteStream(), path);
+ buildPathFromByteStream(downcast<SVGPathElement>(element)->pathByteStream(), path);
}
static void updatePathFromPolygonElement(SVGElement* element, Path& path)
{
- SVGPointList& points = toSVGPolygonElement(element)->animatedPoints()->values();
+ SVGPointList& points = downcast<SVGPolygonElement>(element)->animatedPoints()->values();
if (points.isEmpty())
return;
static void updatePathFromPolylineElement(SVGElement* element, Path& path)
{
- SVGPointList& points = toSVGPolylineElement(element)->animatedPoints()->values();
+ SVGPointList& points = downcast<SVGPolylineElement>(element)->animatedPoints()->values();
if (points.isEmpty())
return;
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 (SVGElement* element = child->node()->isSVGElement() ? downcast<SVGElement>(child->node()) : nullptr) {
if (element->hasRelativeLengths()) {
// When the layout size changed and when using relative values tell the RenderSVGShape to update its shape object
if (child->isSVGShape())
const SVGRenderStyle& svgStyle = style.svgStyle();
- SVGLengthContext lengthContext(toSVGElement(renderer.element()));
+ SVGLengthContext lengthContext(downcast<SVGElement>(renderer.element()));
context->setStrokeThickness(lengthContext.valueForLength(svgStyle.strokeWidth()));
context->setLineCap(svgStyle.capStyle());
context->setLineJoin(svgStyle.joinStyle());
bool maskedAncestorShouldIsolateBlending = renderer.style().hasBlendMode();
for (auto* ancestor = renderer.element()->parentElement(); ancestor && ancestor->isSVGElement(); ancestor = ancestor->parentElement()) {
- if (!toSVGElement(ancestor)->isSVGGraphicsElement() || !isolatesBlending(*ancestor->computedStyle()))
+ if (!downcast<SVGElement>(*ancestor).isSVGGraphicsElement() || !isolatesBlending(*ancestor->computedStyle()))
continue;
if (ancestor->computedStyle()->svgStyle().hasMasker())
- toSVGGraphicsElement(ancestor)->setShouldIsolateBlending(maskedAncestorShouldIsolateBlending);
+ downcast<SVGGraphicsElement>(*ancestor).setShouldIsolateBlending(maskedAncestorShouldIsolateBlending);
return;
}
SVGLengthContext lengthContext(&svgElement);
if (isSVGRectElement(svgElement)) {
- const SVGRectElement& element = toSVGRectElement(svgElement);
+ const SVGRectElement& element = downcast<SVGRectElement>(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 (isSVGLineElement(svgElement)) {
- const SVGLineElement& element = toSVGLineElement(svgElement);
+ const SVGLineElement& element = downcast<SVGLineElement>(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 (isSVGEllipseElement(svgElement)) {
- const SVGEllipseElement& element = toSVGEllipseElement(svgElement);
+ const SVGEllipseElement& element = downcast<SVGEllipseElement>(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 (isSVGCircleElement(svgElement)) {
- const SVGCircleElement& element = toSVGCircleElement(svgElement);
+ const SVGCircleElement& element = downcast<SVGCircleElement>(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)) {
- const SVGPolyElement& element = toSVGPolyElement(svgElement);
+ const SVGPolyElement& element = downcast<SVGPolyElement>(svgElement);
writeNameAndQuotedValue(ts, "points", element.pointList().valueAsString());
} else if (isSVGPathElement(svgElement)) {
- const SVGPathElement& element = toSVGPathElement(svgElement);
+ const SVGPathElement& element = downcast<SVGPathElement>(svgElement);
String pathString;
// FIXME: We should switch to UnalteredParsing here - this will affect the path dumping output of dozens of tests.
buildStringFromByteStream(element.pathByteStream(), pathString, NormalizedParsing);
bool isolateMaskForBlending = false;
#if ENABLE(CSS_COMPOSITING)
- if (svgStyle.hasMasker() && toSVGElement(renderer.element())->isSVGGraphicsElement()) {
- SVGGraphicsElement& graphicsElement = *toSVGGraphicsElement(renderer.element());
+ if (svgStyle.hasMasker() && downcast<SVGElement>(renderer.element())->isSVGGraphicsElement()) {
+ SVGGraphicsElement& graphicsElement = downcast<SVGGraphicsElement>(*renderer.element());
isolateMaskForBlending = graphicsElement.shouldIsolateBlending();
}
#endif
referenceBox = renderer.strokeBoundingBox();
else if (clipPath.referenceBox() == ViewBox && renderer.element()) {
FloatSize viewportSize;
- SVGLengthContext(toSVGElement(renderer.element())).determineViewport(viewportSize);
+ SVGLengthContext(downcast<SVGElement>(renderer.element())).determineViewport(viewportSize);
referenceBox.setWidth(viewportSize.width());
referenceBox.setHeight(viewportSize.height());
} else
{
String target;
if (isSVGPatternElement(element))
- target = toSVGPatternElement(element).href();
+ target = downcast<SVGPatternElement>(element).href();
else if (isSVGGradientElement(element))
- target = toSVGGradientElement(element).href();
+ target = downcast<SVGGradientElement>(element).href();
else if (isSVGFilterElement(element))
- target = toSVGFilterElement(element).href();
+ target = downcast<SVGFilterElement>(element).href();
else
ASSERT_NOT_REACHED();
if (!renderer.element())
return false;
- auto& element = toSVGElement(*renderer.element());
+ auto& element = downcast<SVGElement>(*renderer.element());
Document& document = element.document();
if (m_inPathLayout && m_textPath.isEmpty())
return;
- SVGElement* lengthContext = toSVGElement(text->parent()->element());
+ RenderElement* textParent = text->parent();
+ ASSERT(textParent);
+ SVGElement* lengthContext = downcast<SVGElement>(textParent->element());
- RenderObject* textParent = text->parent();
- bool definesTextLength = textParent ? parentDefinesTextLength(textParent) : false;
+ bool definesTextLength = parentDefinesTextLength(textParent);
const SVGRenderStyle& svgStyle = style->svgStyle();
RenderPtr<RenderElement> SVGAElement::createElementRenderer(PassRef<RenderStyle> style)
{
- if (parentNode() && parentNode()->isSVGElement() && toSVGElement(parentNode())->isTextContent())
+ if (parentNode() && parentNode()->isSVGElement() && downcast<SVGElement>(*parentNode()).isTextContent())
return createRenderer<RenderSVGInline>(*this, WTF::move(style));
return createRenderer<RenderSVGTransformableContainer>(*this, WTF::move(style));
if (url[0] == '#') {
Element* targetElement = treeScope().getElementById(url.substringSharingImpl(1));
if (targetElement && isSVGSMILElement(*targetElement)) {
- toSVGSMILElement(*targetElement).beginByLinkActivation();
+ downcast<SVGSMILElement>(*targetElement).beginByLinkActivation();
event->setDefaultHandled();
return;
}
fountFirstGlyphRef = true;
String referredGlyphName;
- if (toSVGGlyphRefElement(child).hasValidGlyphElement(referredGlyphName))
+ if (downcast<SVGGlyphRefElement>(child).hasValidGlyphElement(referredGlyphName))
glyphNames.append(referredGlyphName);
else {
// As the spec says "If any of the referenced glyphs are unavailable,
// As the spec says "The first 'altGlyphItem' in which all referenced glyphs
// are available is chosen."
- if (toSVGAltGlyphItemElement(child).hasValidGlyphElements(glyphNames) && !glyphNames.isEmpty())
+ if (downcast<SVGAltGlyphItemElement>(child).hasValidGlyphElements(glyphNames) && !glyphNames.isEmpty())
return true;
}
}
}
if (isSVGAltGlyphDefElement(element)
- && toSVGAltGlyphDefElement(element)->hasValidGlyphElements(glyphNames))
+ && downcast<SVGAltGlyphDefElement>(*element).hasValidGlyphElements(glyphNames))
return true;
return false;
ASSERT(m_fromType->type() == m_animatedPropertyType);
ASSERT(m_toType);
- SVGAnimateElement* resultAnimationElement = toSVGAnimateElement(resultElement);
- ASSERT(resultAnimationElement->m_animatedType);
- ASSERT(resultAnimationElement->m_animatedPropertyType == m_animatedPropertyType);
+ SVGAnimateElement& resultAnimationElement = downcast<SVGAnimateElement>(*resultElement);
+ ASSERT(resultAnimationElement.m_animatedType);
+ ASSERT(resultAnimationElement.m_animatedPropertyType == m_animatedPropertyType);
if (hasTagName(SVGNames::setTag))
percentage = 1;
// Values-animation accumulates using the last values entry corresponding to the end of duration time.
SVGAnimatedType* toAtEndOfDurationType = m_toAtEndOfDurationType ? m_toAtEndOfDurationType.get() : m_toType.get();
- m_animator->calculateAnimatedValue(percentage, repeatCount, m_fromType.get(), m_toType.get(), toAtEndOfDurationType, resultAnimationElement->m_animatedType.get());
+ m_animator->calculateAnimatedValue(percentage, repeatCount, m_fromType.get(), m_toType.get(), toAtEndOfDurationType, resultAnimationElement.m_animatedType.get());
}
bool SVGAnimateElement::calculateToAtEndOfDurationValue(const String& toAtEndOfDurationString)
SVGAnimatedTransformListAnimator::SVGAnimatedTransformListAnimator(SVGAnimationElement* animationElement, SVGElement* contextElement)
: SVGAnimatedTypeAnimator(AnimatedTransformList, animationElement, contextElement)
- , m_transformTypeString(SVGTransform::transformTypePrefixForParsing(toSVGAnimateTransformElement(animationElement)->transformType()))
+ , m_transformTypeString(SVGTransform::transformTypePrefixForParsing(downcast<SVGAnimateTransformElement>(animationElement)->transformType()))
{
// Only <animateTransform> uses this animator, as <animate> doesn't allow to animate transform lists directly.
ASSERT(animationElement->hasTagName(SVGNames::animateTransformTag));
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
if (!parent || !parent->isSVGElement())
return;
- SVGElement* svgParent = toSVGElement(parent);
- computeCSSPropertyValue(svgParent, cssPropertyID(attributeName.localName()), value);
+ SVGElement& svgParent = downcast<SVGElement>(*parent);
+ computeCSSPropertyValue(&svgParent, cssPropertyID(attributeName.localName()), value);
}
static bool inheritsFromProperty(SVGElement*, const QualifiedName& attributeName, const String& value)
SVGSVGElement* SVGDocument::rootElement() const
{
- Element* elem = documentElement();
- if (elem && elem->hasTagName(SVGNames::svgTag))
- return toSVGSVGElement(elem);
+ Element* element = documentElement();
+ if (element && isSVGSVGElement(element))
+ return downcast<SVGSVGElement>(element);
- return 0;
+ return nullptr;
}
bool SVGDocument::zoomAndPanEnabled() const
SVGSVGElement* SVGElement::ownerSVGElement() const
{
- ContainerNode* n = parentOrShadowHostNode();
- while (n) {
- if (n->hasTagName(SVGNames::svgTag))
- return toSVGSVGElement(n);
+ ContainerNode* node = parentOrShadowHostNode();
+ while (node) {
+ if (isSVGSVGElement(node))
+ return downcast<SVGSVGElement>(node);
- n = n->parentOrShadowHostNode();
+ node = node->parentOrShadowHostNode();
}
- return 0;
+ return nullptr;
}
SVGElement* SVGElement::viewportElement() const
{
// This function needs shadow tree support - as RenderSVGContainer uses this function
// to determine the "overflow" property. <use> on <symbol> wouldn't work otherwhise.
- ContainerNode* n = parentOrShadowHostNode();
- while (n) {
- if (n->hasTagName(SVGNames::svgTag) || isSVGImageElement(n) || n->hasTagName(SVGNames::symbolTag))
- return toSVGElement(n);
+ ContainerNode* node = parentOrShadowHostNode();
+ while (node) {
+ if (isSVGSVGElement(node) || isSVGImageElement(node) || node->hasTagName(SVGNames::symbolTag))
+ return downcast<SVGElement>(node);
- n = n->parentOrShadowHostNode();
+ node = node->parentOrShadowHostNode();
}
- return 0;
+ return nullptr;
}
SVGDocumentExtensions* SVGElement::accessDocumentSVGExtensions()
bool SVGElement::getBoundingBox(FloatRect& rect, SVGLocatable::StyleUpdateStrategy styleUpdateStrategy)
{
if (isSVGGraphicsElement()) {
- rect = toSVGGraphicsElement(this)->getBBox(styleUpdateStrategy);
+ rect = downcast<SVGGraphicsElement>(*this).getBBox(styleUpdateStrategy);
return true;
}
return false;
invalidTextContent.get().add(SVGNames::tspanTag);
}
if (child.isSVGElement()) {
- const SVGElement& svgChild = toSVGElement(child);
+ const SVGElement& svgChild = downcast<SVGElement>(child);
if (invalidTextContent.get().contains(svgChild.tagQName()))
return false;
// that do enable SVG in a shadow tree.
ASSERT(!shadowHostElement || shadowHostElement->hasTagName(SVGNames::useTag));
if (shadowHostElement && shadowHostElement->hasTagName(SVGNames::useTag)) {
- SVGUseElement* useElement = toSVGUseElement(shadowHostElement);
+ SVGUseElement& useElement = downcast<SVGUseElement>(*shadowHostElement);
// If the <use> title is not empty we found the title to use.
- String useTitle(useElement->title());
+ String useTitle(useElement.title());
if (!useTitle.isEmpty())
return useTitle;
}
break;
// Register us in the parent element map.
- toSVGElement(node)->updateRelativeLengthsInformation(hasRelativeLengths, this);
+ downcast<SVGElement>(*node).updateRelativeLengthsInformation(hasRelativeLengths, this);
break;
}
}
inline bool Node::hasTagName(const SVGQualifiedName& name) const
{
- return isSVGElement() && toSVGElement(*this).hasTagName(name);
+ return isSVGElement() && downcast<SVGElement>(*this).hasTagName(name);
}
} // namespace WebCore
for (auto& child : childrenOfType<SVGElement>(*this)) {
if (isSVGFEFuncRElement(child))
- red = toSVGFEFuncRElement(child).transferFunction();
+ red = downcast<SVGFEFuncRElement>(child).transferFunction();
else if (isSVGFEFuncGElement(child))
- green = toSVGFEFuncGElement(child).transferFunction();
+ green = downcast<SVGFEFuncGElement>(child).transferFunction();
else if (isSVGFEFuncBElement(child))
- blue = toSVGFEFuncBElement(child).transferFunction();
+ blue = downcast<SVGFEFuncBElement>(child).transferFunction();
else if (isSVGFEFuncAElement(child))
- alpha = toSVGFEFuncAElement(child).transferFunction();
+ alpha = downcast<SVGFEFuncAElement>(child).transferFunction();
}
RefPtr<FilterEffect> effect = FEComponentTransfer::create(filter, red, green, blue, alpha);
} else if (target->isSVGElement()) {
// Register us with the target in the dependencies map. Any change of hrefElement
// that leads to relayout/repainting now informs us, so we can react to it.
- document().accessSVGExtensions()->addElementReferencingTarget(this, toSVGElement(target));
+ document().accessSVGExtensions()->addElementReferencingTarget(this, downcast<SVGElement>(target));
}
invalidate();
if (!child.isSVGElement())
return false;
- const SVGElement& svgElement = toSVGElement(child);
+ const SVGElement& svgElement = downcast<SVGElement>(child);
static NeverDestroyed<HashSet<QualifiedName>> allowedChildElementTags;
if (allowedChildElementTags.get().isEmpty()) {
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() && toSVGElement(node).isFilterEffect(); }
+inline bool isSVGFilterPrimitiveStandardAttributes(const Node& node) { return node.isSVGElement() && downcast<SVGElement>(node).isFilterEffect(); }
template <typename ArgType>
struct ElementTypeCastTraits<const SVGFilterPrimitiveStandardAttributes, ArgType> {
language = parentRendererElement->getAttribute(XMLNames::langAttr);
if (isSVGAltGlyphElement(parentRendererElement)) {
- SVGAltGlyphElement* altGlyph = toSVGAltGlyphElement(parentRendererElement);
- if (!altGlyph->hasValidGlyphElements(altGlyphNames))
+ SVGAltGlyphElement& altGlyph = downcast<SVGAltGlyphElement>(*parentRendererElement);
+ if (!altGlyph.hasValidGlyphElements(altGlyphNames))
altGlyphNames.clear();
}
}
Vector<String> ligatures;
for (auto& child : childrenOfType<SVGElement>(*this)) {
if (isSVGGlyphElement(child)) {
- SVGGlyphElement& glyph = toSVGGlyphElement(child);
+ SVGGlyphElement& glyph = downcast<SVGGlyphElement>(child);
AtomicString unicode = glyph.fastGetAttribute(SVGNames::unicodeAttr);
AtomicString glyphId = glyph.getIdAttribute();
if (glyphId.isEmpty() && unicode.isEmpty())
if (unicode.length() > 1 && !U16_IS_SURROGATE(unicode[0]))
ligatures.append(unicode.string());
} else if (isSVGHKernElement(child)) {
- SVGHKernElement& hkern = toSVGHKernElement(child);
+ SVGHKernElement& hkern = downcast<SVGHKernElement>(child);
SVGKerningPair kerningPair;
if (hkern.buildHorizontalKerningPair(kerningPair))
m_horizontalKerningMap.insert(kerningPair);
} else if (isSVGVKernElement(child)) {
- SVGVKernElement& vkern = toSVGVKernElement(child);
+ SVGVKernElement& vkern = downcast<SVGVKernElement>(child);
SVGKerningPair kerningPair;
if (vkern.buildVerticalKerningPair(kerningPair))
m_verticalKerningMap.insert(kerningPair);
} else if (isSVGMissingGlyphElement(child) && !firstMissingGlyphElement)
- firstMissingGlyphElement = &toSVGMissingGlyphElement(child);
+ firstMissingGlyphElement = &downcast<SVGMissingGlyphElement>(child);
}
// Register each character of each ligature, if needed.
RefPtr<CSSValueList> list;
if (describesParentFont) {
- m_fontElement = toSVGFontElement(parentNode());
+ m_fontElement = downcast<SVGFontElement>(parentNode());
list = CSSValueList::createCommaSeparated();
list->append(CSSFontFaceSrcValue::createLocal(fontFamily()));
} else {
- m_fontElement = 0;
+ m_fontElement = nullptr;
if (srcElement)
list = srcElement->srcValue();
}
ancestor = ancestor->parentNode();
if (ancestor && ancestor->hasTagName(font_faceTag))
- toSVGFontFaceElement(ancestor)->rebuildFontFace();
+ downcast<SVGFontFaceElement>(*ancestor).rebuildFontFace();
}
}
for (auto& child : childrenOfType<SVGElement>(*this)) {
RefPtr<CSSFontFaceSrcValue> srcValue;
if (isSVGFontFaceUriElement(child))
- srcValue = toSVGFontFaceUriElement(child).srcValue();
+ srcValue = downcast<SVGFontFaceUriElement>(child).srcValue();
else if (isSVGFontFaceNameElement(child))
- srcValue = toSVGFontFaceNameElement(child).srcValue();
+ srcValue = downcast<SVGFontFaceNameElement>(child).srcValue();
if (srcValue && srcValue->resource().length())
list->append(srcValue.releaseNonNull());
}
{
SVGElement::childrenChanged(change);
if (parentNode() && isSVGFontFaceElement(parentNode()))
- toSVGFontFaceElement(parentNode())->rebuildFontFace();
+ downcast<SVGFontFaceElement>(*parentNode()).rebuildFontFace();
}
}
ContainerNode* grandparent = parentNode()->parentNode();
if (grandparent && grandparent->hasTagName(font_faceTag))
- toSVGFontFaceElement(grandparent)->rebuildFontFace();
+ downcast<SVGFontFaceElement>(*grandparent).rebuildFontFace();
}
Node::InsertionNotificationRequest SVGFontFaceUriElement::insertedInto(ContainerNode& rootParent)
{
ContainerNode* fontNode = parentNode();
if (fontNode && isSVGFontElement(fontNode))
- toSVGFontElement(fontNode)->invalidateGlyphCache();
+ downcast<SVGFontElement>(*fontNode).invalidateGlyphCache();
}
void SVGGlyphElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
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() && toSVGElement(node).isSVGGraphicsElement(); }
+inline bool isSVGGraphicsElement(const Node& node) { return node.isSVGElement() && downcast<SVGElement>(node).isSVGGraphicsElement(); }
NODE_TYPE_CASTS(SVGGraphicsElement)
} // namespace WebCore
{
ContainerNode* fontNode = parentNode();
if (fontNode && isSVGFontElement(fontNode))
- toSVGFontElement(fontNode)->invalidateGlyphCache();
+ downcast<SVGFontElement>(*fontNode).invalidateGlyphCache();
return SVGElement::insertedInto(rootParent);
}
{
ContainerNode* fontNode = parentNode();
if (fontNode && isSVGFontElement(fontNode))
- toSVGFontElement(fontNode)->invalidateGlyphCache();
+ downcast<SVGFontElement>(*fontNode).invalidateGlyphCache();
SVGElement::removedFrom(rootParent);
}
if (image()->errorOccurred())
element().dispatchEvent(Event::create(eventNames().errorEvent, false, false));
else {
- if (toSVGImageElement(element()).externalResourcesRequiredBaseValue())
- toSVGImageElement(ImageLoader::element()).sendSVGLoadEventIfPossible(true);
+ if (downcast<SVGImageElement>(element()).externalResourcesRequiredBaseValue())
+ downcast<SVGImageElement>(ImageLoader::element()).sendSVGLoadEventIfPossible(true);
}
}
// Root <svg> element lengths are resolved against the top level viewport.
if (m_context->isOutermostSVGSVGElement()) {
- viewportSize = toSVGSVGElement(m_context)->currentViewportSize();
+ viewportSize = downcast<SVGSVGElement>(*m_context).currentViewportSize();
return true;
}
if (!viewportElement || !isSVGSVGElement(viewportElement))
return false;
- const SVGSVGElement* svg = toSVGSVGElement(viewportElement);
- viewportSize = svg->currentViewBoxRect().size();
+ const SVGSVGElement& svg = downcast<SVGSVGElement>(*viewportElement);
+ viewportSize = svg.currentViewBoxRect().size();
if (viewportSize.isEmpty())
- viewportSize = svg->currentViewportSize();
+ viewportSize = svg.currentViewportSize();
return true;
}
}
if (isLinear) {
- SVGLinearGradientElement* linear = toSVGLinearGradientElement(&element);
+ SVGLinearGradientElement& linear = downcast<SVGLinearGradientElement>(element);
if (!attributes.hasX1() && element.hasAttribute(SVGNames::x1Attr))
- attributes.setX1(linear->x1());
+ attributes.setX1(linear.x1());
if (!attributes.hasY1() && element.hasAttribute(SVGNames::y1Attr))
- attributes.setY1(linear->y1());
+ attributes.setY1(linear.y1());
if (!attributes.hasX2() && element.hasAttribute(SVGNames::x2Attr))
- attributes.setX2(linear->x2());
+ attributes.setX2(linear.x2());
if (!attributes.hasY2() && element.hasAttribute(SVGNames::y2Attr))
- attributes.setY2(linear->y2());
+ attributes.setY2(linear.y2());
}
}
// Respect xlink:href, take attributes from referenced element
Node* refNode = SVGURIReference::targetElementFromIRIString(current->href(), document());
if (refNode && isSVGGradientElement(*refNode)) {
- current = toSVGGradientElement(refNode);
+ current = downcast<SVGGradientElement>(refNode);
// Cycle detection
if (processedGradients.contains(current))
ASSERT(element);
for (Element* current = element->parentOrShadowHostElement(); current; current = current->parentOrShadowHostElement()) {
if (isViewportElement(current))
- return toSVGElement(current);
+ return downcast<SVGElement>(current);
}
- return 0;
+ return nullptr;
}
SVGElement* SVGLocatable::farthestViewportElement(const SVGElement* element)
{
ASSERT(element);
- SVGElement* farthest = 0;
+ SVGElement* farthest = nullptr;
for (Element* current = element->parentOrShadowHostElement(); current; current = current->parentOrShadowHostElement()) {
if (isViewportElement(current))
- farthest = toSVGElement(current);
+ farthest = downcast<SVGElement>(current);
}
return farthest;
}
AffineTransform ctm;
- SVGElement* stopAtElement = mode == NearestViewportScope ? nearestViewportElement(element) : 0;
+ SVGElement* stopAtElement = mode == NearestViewportScope ? nearestViewportElement(element) : nullptr;
for (Element* currentElement = element; currentElement; currentElement = currentElement->parentOrShadowHostElement()) {
if (!currentElement->isSVGElement())
break;
- ctm = toSVGElement(currentElement)->localCoordinateSpaceTransform(mode).multiply(ctm);
+ ctm = downcast<SVGElement>(*currentElement).localCoordinateSpaceTransform(mode).multiply(ctm);
// For getCTM() computation, stop at the nearest viewport element
if (currentElement == stopAtElement)
AffineTransform ctm = getCTM(styleUpdateStrategy);
if (target && target->isSVGGraphicsElement()) {
- AffineTransform targetCTM = toSVGGraphicsElement(target)->getCTM(styleUpdateStrategy);
+ AffineTransform targetCTM = downcast<SVGGraphicsElement>(*target).getCTM(styleUpdateStrategy);
if (!targetCTM.isInvertible()) {
ec = SVGException::SVG_MATRIX_NOT_INVERTABLE;
return ctm;
} else if (target->isSVGElement()) {
// Register us with the target in the dependencies map. Any change of hrefElement
// that leads to relayout/repainting now informs us, so we can react to it.
- document().accessSVGExtensions()->addElementReferencingTarget(this, toSVGElement(target));
+ document().accessSVGExtensions()->addElementReferencingTarget(this, downcast<SVGElement>(target));
}
targetPathChanged();
SVGPathElement* SVGMPathElement::pathElement()
{
Element* target = targetElementFromIRIString(href(), document());
- if (target && target->hasTagName(SVGNames::pathTag))
- return toSVGPathElement(target);
- return 0;
+ if (target && isSVGPathElement(target))
+ return downcast<SVGPathElement>(target);
+ return nullptr;
}
void SVGMPathElement::targetPathChanged()
void SVGMPathElement::notifyParentOfPathChange(ContainerNode* parent)
{
if (parent && isSVGAnimateMotionElement(parent))
- toSVGAnimateMotionElement(parent)->updateAnimationPath();
+ downcast<SVGAnimateMotionElement>(*parent).updateAnimationPath();
}
} // namespace WebCore
void SVGMarkerElement::synchronizeOrientType(SVGElement* contextElement)
{
ASSERT(contextElement);
- SVGMarkerElement* ownerType = toSVGMarkerElement(contextElement);
- if (!ownerType->m_orientType.shouldSynchronize)
+ SVGMarkerElement& ownerType = downcast<SVGMarkerElement>(*contextElement);
+ if (!ownerType.m_orientType.shouldSynchronize)
return;
// If orient is not auto, the previous call to synchronizeOrientAngle already set the orientAttr to the right angle.
- if (ownerType->m_orientType.value != SVGMarkerOrientAuto)
+ if (ownerType.m_orientType.value != SVGMarkerOrientAuto)
return;
DEPRECATED_DEFINE_STATIC_LOCAL(AtomicString, autoString, ("auto", AtomicString::ConstructFromLiteral));
- ownerType->m_orientType.synchronize(ownerType, orientTypePropertyInfo()->attributeName, autoString);
+ ownerType.m_orientType.synchronize(&ownerType, orientTypePropertyInfo()->attributeName, autoString);
}
PassRefPtr<SVGAnimatedProperty> SVGMarkerElement::lookupOrCreateOrientTypeWrapper(SVGElement* contextElement)
{
ASSERT(contextElement);
- SVGMarkerElement* ownerType = toSVGMarkerElement(contextElement);
+ SVGMarkerElement& ownerType = downcast<SVGMarkerElement>(*contextElement);
return SVGAnimatedProperty::lookupOrCreateWrapper<SVGMarkerElement, SVGAnimatedEnumerationPropertyTearOff<SVGMarkerOrientType>, SVGMarkerOrientType>
- (ownerType, orientTypePropertyInfo(), ownerType->m_orientType.value);
+ (&ownerType, orientTypePropertyInfo(), ownerType.m_orientType.value);
}
PassRefPtr<SVGAnimatedEnumerationPropertyTearOff<SVGMarkerOrientType>> SVGMarkerElement::orientTypeAnimated()
// markForLayoutAndParentResourceInvalidation so we update any mpath dependencies manually.
if (HashSet<SVGElement*>* dependencies = document().accessSVGExtensions()->setOfElementsReferencingTarget(this)) {
for (auto* element : *dependencies) {
- if (element->hasTagName(SVGNames::mpathTag))
- toSVGMPathElement(element)->targetPathChanged();
+ if (isSVGMPathElement(element))
+ downcast<SVGMPathElement>(*element).targetPathChanged();
}
}
}
PassRefPtr<SVGAnimatedProperty> SVGPathElement::lookupOrCreateDWrapper(SVGElement* contextElement)
{
ASSERT(contextElement);
- SVGPathElement* ownerType = toSVGPathElement(contextElement);
+ SVGPathElement& ownerType = downcast<SVGPathElement>(*contextElement);
- if (SVGAnimatedProperty* property = SVGAnimatedProperty::lookupWrapper<SVGPathElement, SVGAnimatedPathSegListPropertyTearOff>(ownerType, dPropertyInfo()))
+ if (SVGAnimatedProperty* property = SVGAnimatedProperty::lookupWrapper<SVGPathElement, SVGAnimatedPathSegListPropertyTearOff>(&ownerType, dPropertyInfo()))
return property;
// Build initial SVGPathSegList.
- buildSVGPathSegListFromByteStream(ownerType->m_pathByteStream.get(), ownerType, ownerType->m_pathSegList.value, UnalteredParsing);
+ buildSVGPathSegListFromByteStream(ownerType.m_pathByteStream.get(), &ownerType, ownerType.m_pathSegList.value, UnalteredParsing);
return SVGAnimatedProperty::lookupOrCreateWrapper<SVGPathElement, SVGAnimatedPathSegListPropertyTearOff, SVGPathSegList>
- (ownerType, dPropertyInfo(), ownerType->m_pathSegList.value);
+ (&ownerType, dPropertyInfo(), ownerType.m_pathSegList.value);
}
void SVGPathElement::synchronizeD(SVGElement* contextElement)
{
ASSERT(contextElement);
- SVGPathElement* ownerType = toSVGPathElement(contextElement);
- if (!ownerType->m_pathSegList.shouldSynchronize)
+ SVGPathElement& ownerType = downcast<SVGPathElement>(*contextElement);
+ if (!ownerType.m_pathSegList.shouldSynchronize)
return;
- ownerType->m_pathSegList.synchronize(ownerType, dPropertyInfo()->attributeName, ownerType->m_pathSegList.value.valueAsString());
+ ownerType.m_pathSegList.synchronize(&ownerType, dPropertyInfo()->attributeName, ownerType.m_pathSegList.value.valueAsString());
}
SVGPathSegListPropertyTearOff* SVGPathElement::pathSegList()
void SVGPathSegList::commitChange(SVGElement* contextElement, ListModification listModification)
{
ASSERT(contextElement);
- toSVGPathElement(contextElement)->pathSegListChanged(m_role, listModification);
+ downcast<SVGPathElement>(contextElement)->pathSegListChanged(m_role, listModification);
}
}
// Respect xlink:href, take attributes from referenced element
Element* refElement = SVGURIReference::targetElementFromIRIString(current->href(), document());
if (refElement && isSVGPatternElement(refElement)) {
- current = toSVGPatternElement(refElement);
+ current = downcast<SVGPatternElement>(refElement);
// Cycle detection
if (processedPatterns.contains(current))
void SVGPolyElement::synchronizePoints(SVGElement* contextElement)
{
ASSERT(contextElement);
- SVGPolyElement* ownerType = toSVGPolyElement(contextElement);
- if (!ownerType->m_points.shouldSynchronize)
+ SVGPolyElement& ownerType = downcast<SVGPolyElement>(*contextElement);
+ if (!ownerType.m_points.shouldSynchronize)
return;
- ownerType->m_points.synchronize(ownerType, pointsPropertyInfo()->attributeName, ownerType->m_points.value.valueAsString());
+ ownerType.m_points.synchronize(&ownerType, pointsPropertyInfo()->attributeName, ownerType.m_points.value.valueAsString());
}
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);
+ (&ownerType, pointsPropertyInfo(), ownerType.m_points.value);
}
SVGListPropertyTearOff<SVGPointList>* SVGPolyElement::points()
}
if (isRadial) {
- SVGRadialGradientElement* radial = toSVGRadialGradientElement(&element);
+ SVGRadialGradientElement& radial = downcast<SVGRadialGradientElement>(element);
if (!attributes.hasCx() && element.hasAttribute(SVGNames::cxAttr))
- attributes.setCx(radial->cx());
+ attributes.setCx(radial.cx());
if (!attributes.hasCy() && element.hasAttribute(SVGNames::cyAttr))
- attributes.setCy(radial->cy());
+ attributes.setCy(radial.cy());
if (!attributes.hasR() && element.hasAttribute(SVGNames::rAttr))
- attributes.setR(radial->r());
+ attributes.setR(radial.r());
if (!attributes.hasFx() && element.hasAttribute(SVGNames::fxAttr))
- attributes.setFx(radial->fx());
+ attributes.setFx(radial.fx());
if (!attributes.hasFy() && element.hasAttribute(SVGNames::fyAttr))
- attributes.setFy(radial->fy());
+ attributes.setFy(radial.fy());
if (!attributes.hasFr() && element.hasAttribute(SVGNames::frAttr))
- attributes.setFr(radial->fr());
+ attributes.setFr(radial.fr());
}
}
// Respect xlink:href, take attributes from referenced element
Node* refNode = SVGURIReference::targetElementFromIRIString(current->href(), document());
if (refNode && isSVGGradientElement(*refNode)) {
- current = toSVGGradientElement(refNode);
+ current = downcast<SVGGradientElement>(refNode);
// Cycle detection
if (processedGradients.contains(current))
// Any view specification attributes included on the given ‘view’ element override the corresponding view specification
// attributes on the closest ancestor ‘svg’ element.
if (anchorNode && isSVGViewElement(anchorNode)) {
- if (SVGViewElement* viewElement = toSVGViewElement(anchorNode)) {
- SVGElement* element = SVGLocatable::nearestViewportElement(viewElement);
- if (element->hasTagName(SVGNames::svgTag)) {
- SVGSVGElement* svg = toSVGSVGElement(element);
- svg->inheritViewAttributes(viewElement);
-
- if (RenderElement* renderer = svg->renderer())
- RenderSVGResource::markForLayoutAndParentResourceInvalidation(*renderer);
- }
+ SVGViewElement& viewElement = downcast<SVGViewElement>(*anchorNode);
+ SVGElement* element = SVGLocatable::nearestViewportElement(&viewElement);
+ if (isSVGSVGElement(element)) {
+ SVGSVGElement& svg = downcast<SVGSVGElement>(*element);
+ svg.inheritViewAttributes(&viewElement);
+
+ if (RenderElement* renderer = svg.renderer())
+ RenderSVGResource::markForLayoutAndParentResourceInvalidation(*renderer);
}
return;
}
void SVGTextContentElement::synchronizeTextLength(SVGElement* contextElement)
{
ASSERT(contextElement);
- SVGTextContentElement* ownerType = toSVGTextContentElement(contextElement);
- if (!ownerType->m_textLength.shouldSynchronize)
+ SVGTextContentElement& ownerType = downcast<SVGTextContentElement>(*contextElement);
+ if (!ownerType.m_textLength.shouldSynchronize)
return;
- AtomicString value(SVGPropertyTraits<SVGLength>::toString(ownerType->m_specifiedTextLength));
- ownerType->m_textLength.synchronize(ownerType, textLengthPropertyInfo()->attributeName, value);
+ AtomicString value(SVGPropertyTraits<SVGLength>::toString(ownerType.m_specifiedTextLength));
+ ownerType.m_textLength.synchronize(&ownerType, textLengthPropertyInfo()->attributeName, value);
}
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);
+ (&ownerType, textLengthPropertyInfo(), ownerType.m_textLength.value);
}
PassRefPtr<SVGAnimatedLength> SVGTextContentElement::textLengthAnimated()
SVGTextContentElement* SVGTextContentElement::elementFromRenderer(RenderObject* renderer)
{
if (!renderer)
- return 0;
+ return nullptr;
if (!renderer->isSVGText() && !renderer->isSVGInline())
- return 0;
+ return nullptr;
- SVGElement* element = toSVGElement(renderer->node());
+ SVGElement* element = downcast<SVGElement>(renderer->node());
ASSERT(element);
if (!element->isTextContent())
- return 0;
+ return nullptr;
- return toSVGTextContentElement(element);
+ return downcast<SVGTextContentElement>(element);
}
}
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() && toSVGElement(node).isTextContent(); }
+inline bool isSVGTextContentElement(const Node& node) { return node.isSVGElement() && downcast<SVGElement>(node).isTextContent(); }
NODE_TYPE_CASTS(SVGTextContentElement)
} // namespace WebCore
} else if (target->hasTagName(SVGNames::pathTag)) {
// Register us with the target in the dependencies map. Any change of hrefElement
// that leads to relayout/repainting now informs us, so we can react to it.
- document().accessSVGExtensions()->addElementReferencingTarget(this, toSVGElement(target));
+ document().accessSVGExtensions()->addElementReferencingTarget(this, downcast<SVGElement>(target));
}
}
SVGElement* element = targetInstance->correspondingElement();
ASSERT(element);
- if (element->hasTagName(SVGNames::useTag)) {
- if (toSVGUseElement(element)->cachedDocumentIsStillLoading())
+ if (isSVGUseElement(element)) {
+ if (downcast<SVGUseElement>(*element).cachedDocumentIsStillLoading())
return;
}
}
if (target->isSVGElement()) {
- buildShadowAndInstanceTree(toSVGElement(target));
+ buildShadowAndInstanceTree(downcast<SVGElement>(target));
invalidateDependentShadowTrees();
}
{
ASSERT(path.isEmpty());
- Node* n = m_targetElementInstance ? m_targetElementInstance->shadowTreeElement() : 0;
- if (!n)
+ Node* node = m_targetElementInstance ? m_targetElementInstance->shadowTreeElement() : nullptr;
+ if (!node)
return;
- if (n->isSVGElement() && toSVGElement(*n).isSVGGraphicsElement()) {
- if (!isDirectReference(toSVGElement(*n))) {
+ if (node->isSVGElement() && downcast<SVGElement>(*node).isSVGGraphicsElement()) {
+ if (!isDirectReference(downcast<SVGElement>(*node))) {
// Spec: Indirect references are an error (14.3.5)
document().accessSVGExtensions()->reportError("Not allowed to use indirect reference in <clip-path>");
} else {
- toSVGGraphicsElement(*n).toClipPath(path);
+ downcast<SVGGraphicsElement>(*node).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)));
// Spec: If the referenced object is itself a 'use', or if there are 'use' subelements within the referenced
// object, the instance tree will contain recursive expansion of the indirect references to form a complete tree.
bool targetHasUseTag = target->hasTagName(SVGNames::useTag);
- SVGElement* newTarget = 0;
+ SVGElement* newTarget = nullptr;
if (targetHasUseTag) {
- foundProblem = hasCycleUseReferencing(toSVGUseElement(target), targetInstance, newTarget);
+ foundProblem = hasCycleUseReferencing(downcast<SVGUseElement>(target), targetInstance, newTarget);
if (foundProblem)
return;
if (!targetHasUseTag || !newTarget)
return;
- RefPtr<SVGElementInstance> newInstance = SVGElementInstance::create(this, toSVGUseElement(target), newTarget);
+ RefPtr<SVGElementInstance> newInstance = SVGElementInstance::create(this, downcast<SVGUseElement>(target), newTarget);
SVGElementInstance* newInstancePtr = newInstance.get();
targetInstance->appendChild(newInstance.release());
buildInstanceTree(newTarget, newInstancePtr, foundProblem, foundUse);
{
ASSERT(referencedDocument());
Element* targetElement = SVGURIReference::targetElementFromIRIString(use->href(), *referencedDocument());
- newTarget = 0;
+ newTarget = nullptr;
if (targetElement && targetElement->isSVGElement())
- newTarget = toSVGElement(targetElement);
+ newTarget = downcast<SVGElement>(targetElement);
if (!newTarget)
return false;
// contains <use> tags, we'd miss them. So once we're done with settin' up the
// actual shadow tree (after the special case modification for svg/symbol) we have
// to walk it completely and expand all <use> elements.
- if (element->hasTagName(SVGNames::useTag)) {
- SVGUseElement* use = toSVGUseElement(element);
- ASSERT(!use->cachedDocumentIsStillLoading());
+ if (isSVGUseElement(element)) {
+ SVGUseElement& use = downcast<SVGUseElement>(*element);
+ ASSERT(!use.cachedDocumentIsStillLoading());
ASSERT(referencedDocument());
- Element* targetElement = SVGURIReference::targetElementFromIRIString(use->href(), *referencedDocument());
- SVGElement* target = 0;
+ Element* targetElement = SVGURIReference::targetElementFromIRIString(use.href(), *referencedDocument());
+ SVGElement* target = nullptr;
if (targetElement && targetElement->isSVGElement())
- target = toSVGElement(targetElement);
+ target = downcast<SVGElement>(targetElement);
// Don't ASSERT(target) here, it may be "pending", too.
// Setup sub-shadow tree root node
RefPtr<SVGGElement> cloneParent = SVGGElement::create(SVGNames::gTag, *referencedDocument());
- use->cloneChildNodes(cloneParent.get());
+ use.cloneChildNodes(cloneParent.get());
// Spec: In the generated content, the 'use' will be replaced by 'g', where all attributes from the
// 'use' element except for x, y, width, height and xlink:href are transferred to the generated 'g' element.
- transferUseAttributesToReplacedElement(use, cloneParent.get());
+ transferUseAttributesToReplacedElement(&use, cloneParent.get());
if (target && !isDisallowedElement(*target)) {
RefPtr<Element> newChild = target->cloneElementWithChildren();
RefPtr<Node> replacingElement(cloneParent.get());
// Replace <use> with referenced content.
- ASSERT(use->parentNode());
- use->parentNode()->replaceChild(cloneParent.release(), use);
+ ASSERT(use.parentNode());
+ use.parentNode()->replaceChild(cloneParent.release(), &use);
// Expand the siblings because the *element* is replaced and we will
// lose the sibling chain when we are back from recursion.
} else
ASSERT(target->nodeName() == originalElement->nodeName());
- SVGElement* element = 0;
+ SVGElement* element = nullptr;
if (target->isSVGElement())
- element = toSVGElement(target);
+ element = downcast<SVGElement>(target);
ASSERT(!targetInstance->shadowTreeElement());
targetInstance->setShadowTreeElement(element);
if (rootParent.inDocument()) {
ContainerNode* fontNode = parentNode();
if (fontNode && isSVGFontElement(fontNode))
- toSVGFontElement(fontNode)->invalidateGlyphCache();
+ downcast<SVGFontElement>(*fontNode).invalidateGlyphCache();
}
return SVGElement::insertedInto(rootParent);
{
ContainerNode* fontNode = parentNode();
if (fontNode && isSVGFontElement(fontNode))
- toSVGFontElement(fontNode)->invalidateGlyphCache();
+ downcast<SVGFontElement>(*fontNode).invalidateGlyphCache();
SVGElement::removedFrom(rootParent);
}
SVGElement* SVGViewSpec::viewTarget() const
{
if (!m_contextElement)
- return 0;
+ return nullptr;
Element* element = m_contextElement->treeScope().getElementById(m_viewTargetString);
if (!element || !element->isSVGElement())
- return 0;
- return toSVGElement(element);
+ return nullptr;
+ return downcast<SVGElement>(element);
}
SVGTransformListPropertyTearOff* SVGViewSpec::transform()
String href = getAttribute(XLinkNames::hrefAttr);
Element* target;
if (href.isEmpty())
- target = parentNode() && parentNode()->isElementNode() ? toElement(parentNode()) : 0;
+ target = parentNode() && parentNode()->isElementNode() ? toElement(parentNode()) : nullptr;
else
target = SVGURIReference::targetElementFromIRIString(href, document(), &id);
- SVGElement* svgTarget = target && target->isSVGElement() ? toSVGElement(target) : 0;
+ SVGElement* svgTarget = target && target->isSVGElement() ? downcast<SVGElement>(target) : nullptr;
if (svgTarget && !svgTarget->inDocument())
- svgTarget = 0;
+ svgTarget = nullptr;
if (svgTarget != targetElement())
setTargetElement(svgTarget);
condition.m_syncbase = nullptr;
continue;
}
- toSVGSMILElement(*condition.m_syncbase).addTimeDependent(this);
+ downcast<SVGSMILElement>(*condition.m_syncbase).addTimeDependent(this);
}
}
}
if (eventBase)
eventBase->removeEventListener(condition.m_name, condition.m_eventListener.get(), false);
condition.m_eventListener->disconnectAnimation();
- condition.m_eventListener = 0;
+ 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 = 0;
+ condition.m_syncbase = nullptr;
}
}
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() && toSVGElement(node).isSMILElement(); }
+inline bool isSVGSMILElement(const Node& node) { return node.isSVGElement() && downcast<SVGElement>(node).isSMILElement(); }
template <typename ArgType>
struct ElementTypeCastTraits<const SVGSMILElement, ArgType> {
if (!m_page)
return true;
- SVGSVGElement* rootElement = toSVGDocument(m_page->mainFrame().document())->rootElement();
+ SVGSVGElement* rootElement = downcast<SVGDocument>(m_page->mainFrame().document())->rootElement();
if (!rootElement)
return true;
if (!m_page || !usesContainerSize())
return;
- SVGSVGElement* rootElement = toSVGDocument(m_page->mainFrame().document())->rootElement();
+ SVGSVGElement* rootElement = downcast<SVGDocument>(m_page->mainFrame().document())->rootElement();
if (!rootElement)
return;
RenderSVGRoot* renderer = toRenderSVGRoot(rootElement->renderer());
{
if (!m_page)
return IntSize();
- SVGSVGElement* rootElement = toSVGDocument(m_page->mainFrame().document())->rootElement();
+ SVGSVGElement* rootElement = downcast<SVGDocument>(m_page->mainFrame().document())->rootElement();
if (!rootElement)
return IntSize();
{
if (!m_page)
return 0;
- SVGSVGElement* rootElement = toSVGDocument(m_page->mainFrame().document())->rootElement();
+ SVGSVGElement* rootElement = downcast<SVGDocument>(m_page->mainFrame().document())->rootElement();
if (!rootElement)
return 0;
return toRenderBox(rootElement->renderer());
{
if (!m_page)
return false;
- SVGSVGElement* rootElement = toSVGDocument(m_page->mainFrame().document())->rootElement();
+ SVGSVGElement* rootElement = downcast<SVGDocument>(m_page->mainFrame().document())->rootElement();
if (!rootElement)
return false;
return rootElement->intrinsicWidth().isPercent();
{
if (!m_page)
return false;
- SVGSVGElement* rootElement = toSVGDocument(m_page->mainFrame().document())->rootElement();
+ SVGSVGElement* rootElement = downcast<SVGDocument>(m_page->mainFrame().document())->rootElement();
if (!rootElement)
return false;
return rootElement->intrinsicHeight().isPercent();
{
if (!m_page)
return;
- SVGSVGElement* rootElement = toSVGDocument(m_page->mainFrame().document())->rootElement();
+ SVGSVGElement* rootElement = downcast<SVGDocument>(m_page->mainFrame().document())->rootElement();
if (!rootElement)
return;
{
if (!m_page)
return;
- SVGSVGElement* rootElement = toSVGDocument(m_page->mainFrame().document())->rootElement();
+ SVGSVGElement* rootElement = downcast<SVGDocument>(m_page->mainFrame().document())->rootElement();
if (!rootElement)
return;
rootElement->unpauseAnimations();
{
if (!m_page)
return;
- SVGSVGElement* rootElement = toSVGDocument(m_page->mainFrame().document())->rootElement();
+ SVGSVGElement* rootElement = downcast<SVGDocument>(m_page->mainFrame().document())->rootElement();
if (!rootElement)
return;
rootElement->pauseAnimations();
const AffineTransform& absoluteTransform = filter().absoluteTransform();
resultImage->context()->concatCTM(absoluteTransform);
- SVGElement* contextNode = toSVGElement(renderer->element());
+ SVGElement* contextNode = downcast<SVGElement>(renderer->element());
if (contextNode->hasRelativeLengths()) {
SVGLengthContext lengthContext(contextNode);
FloatSize viewportSize;
void animValDidChange()
{
ASSERT(m_animatedPathByteStream);
- SVGPathElement* pathElement = toSVGPathElement(contextElement());
+ SVGPathElement* pathElement = downcast<SVGPathElement>(contextElement());
// If the animVal is observed from JS, we have to update it on each animation step.
// This is an expensive operation and only done, if someone actually observes the animatedPathSegList() while an animation is running.
{
SVGElement* contextElement = m_animatedProperty->contextElement();
ASSERT(contextElement);
- return toSVGPathElement(contextElement);
+ return downcast<SVGPathElement>(contextElement);
}
bool SVGPathSegListPropertyTearOff::processIncomingListItemValue(const ListItemType& newItem, unsigned* indexToModify)