diff options
Diffstat (limited to 'Source/WebCore/rendering/svg/RenderSVGViewportContainer.cpp')
-rw-r--r-- | Source/WebCore/rendering/svg/RenderSVGViewportContainer.cpp | 82 |
1 files changed, 15 insertions, 67 deletions
diff --git a/Source/WebCore/rendering/svg/RenderSVGViewportContainer.cpp b/Source/WebCore/rendering/svg/RenderSVGViewportContainer.cpp index f03467c62..932fb8517 100644 --- a/Source/WebCore/rendering/svg/RenderSVGViewportContainer.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGViewportContainer.cpp @@ -21,21 +21,16 @@ */ #include "config.h" - -#if ENABLE(SVG) #include "RenderSVGViewportContainer.h" #include "GraphicsContext.h" #include "RenderView.h" -#include "SVGElementInstance.h" -#include "SVGNames.h" #include "SVGSVGElement.h" -#include "SVGUseElement.h" namespace WebCore { -RenderSVGViewportContainer::RenderSVGViewportContainer(SVGSVGElement& element, PassRef<RenderStyle> style) - : RenderSVGContainer(element, std::move(style)) +RenderSVGViewportContainer::RenderSVGViewportContainer(SVGSVGElement& element, RenderStyle&& style) + : RenderSVGContainer(element, WTFMove(style)) , m_didTransformToRootUpdate(false) , m_isLayoutSizeChanged(false) , m_needsTransformUpdate(true) @@ -44,7 +39,7 @@ RenderSVGViewportContainer::RenderSVGViewportContainer(SVGSVGElement& element, P SVGSVGElement& RenderSVGViewportContainer::svgSVGElement() const { - return toSVGSVGElement(RenderSVGContainer::element()); + return downcast<SVGSVGElement>(RenderSVGContainer::element()); } void RenderSVGViewportContainer::determineIfLayoutSizeChanged() @@ -55,67 +50,22 @@ void RenderSVGViewportContainer::determineIfLayoutSizeChanged() void RenderSVGViewportContainer::applyViewportClip(PaintInfo& paintInfo) { if (SVGRenderSupport::isOverflowHidden(*this)) - paintInfo.context->clip(m_viewport); + paintInfo.context().clip(m_viewport); } void RenderSVGViewportContainer::calcViewport() { - SVGSVGElement& svg = svgSVGElement(); - FloatRect oldViewport = m_viewport; - - SVGLengthContext lengthContext(&svg); - m_viewport = FloatRect(svg.x().value(lengthContext), svg.y().value(lengthContext), svg.width().value(lengthContext), svg.height().value(lengthContext)); - - SVGElement* correspondingElement = svg.correspondingElement(); - if (correspondingElement && svg.isInShadowTree()) { - const HashSet<SVGElementInstance*>& instances = correspondingElement->instancesForElement(); - ASSERT(!instances.isEmpty()); - - SVGUseElement* useElement = 0; - const HashSet<SVGElementInstance*>::const_iterator end = instances.end(); - for (HashSet<SVGElementInstance*>::const_iterator it = instances.begin(); it != end; ++it) { - const SVGElementInstance* instance = (*it); - ASSERT(instance->correspondingElement()->hasTagName(SVGNames::svgTag) || instance->correspondingElement()->hasTagName(SVGNames::symbolTag)); - if (instance->shadowTreeElement() == &svg) { - ASSERT(correspondingElement == instance->correspondingElement()); - useElement = instance->directUseElement(); - if (!useElement) - useElement = instance->correspondingUseElement(); - break; - } - } - - ASSERT(useElement); - bool isSymbolElement = correspondingElement->hasTagName(SVGNames::symbolTag); - - // Spec (<use> on <symbol>): This generated 'svg' will always have explicit values for attributes width and height. - // If attributes width and/or height are provided on the 'use' element, then these attributes - // will be transferred to the generated 'svg'. If attributes width and/or height are not specified, - // the generated 'svg' element will use values of 100% for these attributes. - - // Spec (<use> on <svg>): If attributes width and/or height are provided on the 'use' element, then these - // values will override the corresponding attributes on the 'svg' in the generated tree. - - SVGLengthContext lengthContext(&svg); - if (useElement->hasAttribute(SVGNames::widthAttr)) - m_viewport.setWidth(useElement->width().value(lengthContext)); - else if (isSymbolElement && svg.hasAttribute(SVGNames::widthAttr)) { - SVGLength containerWidth(LengthModeWidth, "100%"); - m_viewport.setWidth(containerWidth.value(lengthContext)); - } - - if (useElement->hasAttribute(SVGNames::heightAttr)) - m_viewport.setHeight(useElement->height().value(lengthContext)); - else if (isSymbolElement && svg.hasAttribute(SVGNames::heightAttr)) { - SVGLength containerHeight(LengthModeHeight, "100%"); - m_viewport.setHeight(containerHeight.value(lengthContext)); - } - } - - if (oldViewport != m_viewport) { - setNeedsBoundariesUpdate(); - setNeedsTransformUpdate(); - } + SVGSVGElement& element = svgSVGElement(); + SVGLengthContext lengthContext(&element); + FloatRect newViewport(element.x().value(lengthContext), element.y().value(lengthContext), element.width().value(lengthContext), element.height().value(lengthContext)); + + if (m_viewport == newViewport) + return; + + m_viewport = newViewport; + + setNeedsBoundariesUpdate(); + setNeedsTransformUpdate(); } bool RenderSVGViewportContainer::calculateLocalTransform() @@ -153,5 +103,3 @@ void RenderSVGViewportContainer::paint(PaintInfo& paintInfo, const LayoutPoint& } } - -#endif // ENABLE(SVG) |