summaryrefslogtreecommitdiff
path: root/Source/WebCore/svg/SVGSVGElement.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/svg/SVGSVGElement.h')
-rw-r--r--Source/WebCore/svg/SVGSVGElement.h220
1 files changed, 112 insertions, 108 deletions
diff --git a/Source/WebCore/svg/SVGSVGElement.h b/Source/WebCore/svg/SVGSVGElement.h
index b5b1e6cb8..ef54f12c3 100644
--- a/Source/WebCore/svg/SVGSVGElement.h
+++ b/Source/WebCore/svg/SVGSVGElement.h
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
* Copyright (C) 2004, 2005, 2006, 2007, 2010 Rob Buis <buis@kde.org>
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -18,10 +19,9 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef SVGSVGElement_h
-#define SVGSVGElement_h
+#pragma once
-#if ENABLE(SVG)
+#include "FloatPoint.h"
#include "SVGAnimatedBoolean.h"
#include "SVGAnimatedLength.h"
#include "SVGAnimatedPreserveAspectRatio.h"
@@ -33,158 +33,162 @@
namespace WebCore {
+class SMILTimeContainer;
class SVGAngle;
+class SVGLength;
class SVGMatrix;
+class SVGNumber;
+class SVGRect;
class SVGTransform;
class SVGViewSpec;
-class SVGViewElement;
-class SMILTimeContainer;
-
-class SVGSVGElement final : public SVGGraphicsElement,
- public SVGExternalResourcesRequired,
- public SVGFitToViewBox,
- public SVGZoomAndPan {
-public:
- static PassRefPtr<SVGSVGElement> create(const QualifiedName&, Document&);
- using SVGGraphicsElement::ref;
- using SVGGraphicsElement::deref;
+class SVGSVGElement final : public SVGGraphicsElement, public SVGExternalResourcesRequired, public SVGFitToViewBox, public SVGZoomAndPan {
- virtual bool isValid() const override { return SVGTests::isValid(); }
- virtual bool supportsFocus() const override { return true; }
+ BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGSVGElement)
+ DECLARE_ANIMATED_LENGTH(X, x)
+ DECLARE_ANIMATED_LENGTH(Y, y)
+ DECLARE_ANIMATED_LENGTH(Width, width)
+ DECLARE_ANIMATED_LENGTH(Height, height)
+ DECLARE_ANIMATED_BOOLEAN_OVERRIDE(ExternalResourcesRequired, externalResourcesRequired)
+ DECLARE_ANIMATED_RECT(ViewBox, viewBox)
+ DECLARE_ANIMATED_PRESERVEASPECTRATIO(PreserveAspectRatio, preserveAspectRatio)
+ END_DECLARE_ANIMATED_PROPERTIES
- // 'SVGSVGElement' functions
+public: // DOM
const AtomicString& contentScriptType() const;
- void setContentScriptType(const AtomicString& type);
+ void setContentScriptType(const AtomicString&);
const AtomicString& contentStyleType() const;
- void setContentStyleType(const AtomicString& type);
+ void setContentStyleType(const AtomicString&);
- FloatRect viewport() const;
+ Ref<SVGRect> viewport() const;
float pixelUnitToMillimeterX() const;
float pixelUnitToMillimeterY() const;
float screenPixelToMillimeterX() const;
float screenPixelToMillimeterY() const;
- bool useCurrentView() const { return m_useCurrentView; }
- SVGViewSpec* currentView();
-
- enum ConsiderCSSMode {
- RespectCSSProperties,
- IgnoreCSSProperties
- };
-
- // RenderSVGRoot wants to query the intrinsic size, by only examining the width/height attributes.
- Length intrinsicWidth(ConsiderCSSMode = RespectCSSProperties) const;
- Length intrinsicHeight(ConsiderCSSMode = RespectCSSProperties) const;
- FloatSize currentViewportSize() const;
- FloatRect currentViewBoxRect() const;
+ bool useCurrentView() const;
+ SVGViewSpec& currentView();
float currentScale() const;
- void setCurrentScale(float scale);
+ void setCurrentScale(float);
- SVGPoint& currentTranslate() { return m_translation; }
- void setCurrentTranslate(const FloatPoint&);
+ Ref<SVGPoint> currentTranslate();
+ FloatPoint currentTranslateValue();
- // Only used from the bindings.
- void updateCurrentTranslate();
+ unsigned suspendRedraw(unsigned maxWaitMilliseconds);
+ void unsuspendRedraw(unsigned suspendHandleId);
+ void unsuspendRedrawAll();
+ void forceRedraw();
- SMILTimeContainer* timeContainer() const { return m_timeContainer.get(); }
-
void pauseAnimations();
void unpauseAnimations();
bool animationsPaused() const;
float getCurrentTime() const;
- void setCurrentTime(float seconds);
+ void setCurrentTime(float);
- unsigned suspendRedraw(unsigned maxWaitMilliseconds);
- void unsuspendRedraw(unsigned suspendHandleId);
- void unsuspendRedrawAll();
- void forceRedraw();
-
- PassRefPtr<NodeList> getIntersectionList(const FloatRect&, SVGElement* referenceElement) const;
- PassRefPtr<NodeList> getEnclosureList(const FloatRect&, SVGElement* referenceElement) const;
- bool checkIntersection(const SVGElement*, const FloatRect&) const;
- bool checkEnclosure(const SVGElement*, const FloatRect&) const;
+ Ref<NodeList> getIntersectionList(SVGRect&, SVGElement* referenceElement);
+ Ref<NodeList> getEnclosureList(SVGRect&, SVGElement* referenceElement);
+ static bool checkIntersection(const SVGElement*, SVGRect&);
+ static bool checkEnclosure(const SVGElement*, SVGRect&);
void deselectAll();
- static float createSVGNumber();
- static SVGLength createSVGLength();
- static SVGAngle createSVGAngle();
- static SVGPoint createSVGPoint();
- static SVGMatrix createSVGMatrix();
- static FloatRect createSVGRect();
- static SVGTransform createSVGTransform();
- static SVGTransform createSVGTransformFromMatrix(const SVGMatrix&);
-
- AffineTransform viewBoxToViewTransform(float viewWidth, float viewHeight) const;
-
- void setupInitialView(const String& fragmentIdentifier, Element* anchorNode);
+ static Ref<SVGNumber> createSVGNumber();
+ static Ref<SVGLength> createSVGLength();
+ static Ref<SVGAngle> createSVGAngle();
+ static Ref<SVGPoint> createSVGPoint();
+ static Ref<SVGMatrix> createSVGMatrix();
+ static Ref<SVGRect> createSVGRect();
+ static Ref<SVGTransform> createSVGTransform();
+ static Ref<SVGTransform> createSVGTransformFromMatrix(SVGMatrix&);
Element* getElementById(const AtomicString&);
- bool widthAttributeEstablishesViewport() const;
- bool heightAttributeEstablishesViewport() const;
-
- SVGZoomAndPanType zoomAndPan() const { return m_zoomAndPan; }
- void setZoomAndPan(unsigned short zoomAndPan) { m_zoomAndPan = SVGZoomAndPan::parseFromNumber(zoomAndPan); }
+ SVGZoomAndPanType zoomAndPan() const;
+ void setZoomAndPan(unsigned short);
- bool hasEmptyViewBox() const { return viewBoxIsValid() && viewBox().isEmpty(); }
-
-private:
- SVGSVGElement(const QualifiedName&, Document&);
- virtual ~SVGSVGElement();
+public:
+ static Ref<SVGSVGElement> create(const QualifiedName&, Document&);
+ static Ref<SVGSVGElement> create(Document&);
+ void scrollToAnchor(const String& fragmentIdentifier, Element* anchor);
- virtual void didMoveToNewDocument(Document* oldDocument) override;
+ using SVGGraphicsElement::ref;
+ using SVGGraphicsElement::deref;
- virtual void parseAttribute(const QualifiedName&, const AtomicString&) override;
+ SMILTimeContainer& timeContainer();
- virtual bool rendererIsNeeded(const RenderStyle&) override;
- virtual RenderPtr<RenderElement> createElementRenderer(PassRef<RenderStyle>) override;
+ void setCurrentTranslate(const FloatPoint&); // Used to pan.
+ void updateCurrentTranslate(); // Used from DOM bindings to create an SVGStaticPropertyTearOff for currentTranslate.
- virtual InsertionNotificationRequest insertedInto(ContainerNode&) override;
- virtual void removedFrom(ContainerNode&) override;
+ bool hasIntrinsicWidth() const;
+ bool hasIntrinsicHeight() const;
+ Length intrinsicWidth() const;
+ Length intrinsicHeight() const;
- virtual void svgAttributeChanged(const QualifiedName&) override;
+ FloatSize currentViewportSize() const;
+ FloatRect currentViewBoxRect() const;
- virtual bool selfHasRelativeLengths() const override;
+ bool hasEmptyViewBox() const;
+ AffineTransform viewBoxToViewTransform(float viewWidth, float viewHeight) const;
- void inheritViewAttributes(SVGViewElement*);
+private:
+ SVGSVGElement(const QualifiedName&, Document&);
+ virtual ~SVGSVGElement();
- enum CollectIntersectionOrEnclosure {
- CollectIntersectionList,
- CollectEnclosureList
- };
+ bool isValid() const override;
+ void didMoveToNewDocument(Document& oldDocument) override;
+ void parseAttribute(const QualifiedName&, const AtomicString&) override;
+ bool rendererIsNeeded(const RenderStyle&) override;
+ RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) override;
+ InsertionNotificationRequest insertedInto(ContainerNode&) override;
+ void removedFrom(ContainerNode&) override;
+ void svgAttributeChanged(const QualifiedName&) override;
+ bool selfHasRelativeLengths() const override;
+ void prepareForDocumentSuspension() override;
+ void resumeFromDocumentSuspension() override;
+ AffineTransform localCoordinateSpaceTransform(SVGLocatable::CTMScope) const override;
+
+ Frame* frameForCurrentScale() const;
+ void inheritViewAttributes(const SVGViewElement&);
+ Ref<NodeList> collectIntersectionOrEnclosureList(SVGRect&, SVGElement*, bool (*checkFunction)(const SVGElement*, SVGRect&));
+
+ bool m_useCurrentView { false };
+ SVGZoomAndPanType m_zoomAndPan { SVGZoomAndPanMagnify };
+ Ref<SMILTimeContainer> m_timeContainer;
+ FloatPoint m_currentTranslate;
+ RefPtr<SVGViewSpec> m_viewSpec;
+};
- PassRefPtr<NodeList> collectIntersectionOrEnclosureList(const FloatRect&, SVGElement*, CollectIntersectionOrEnclosure) const;
+inline bool SVGSVGElement::useCurrentView() const
+{
+ return m_useCurrentView;
+}
- BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGSVGElement)
- DECLARE_ANIMATED_LENGTH(X, x)
- DECLARE_ANIMATED_LENGTH(Y, y)
- DECLARE_ANIMATED_LENGTH(Width, width)
- DECLARE_ANIMATED_LENGTH(Height, height)
- DECLARE_ANIMATED_BOOLEAN(ExternalResourcesRequired, externalResourcesRequired)
- DECLARE_ANIMATED_RECT(ViewBox, viewBox)
- DECLARE_ANIMATED_PRESERVEASPECTRATIO(PreserveAspectRatio, preserveAspectRatio)
- END_DECLARE_ANIMATED_PROPERTIES
+inline FloatPoint SVGSVGElement::currentTranslateValue()
+{
+ return m_currentTranslate;
+}
- virtual void documentWillSuspendForPageCache() override;
- virtual void documentDidResumeFromPageCache() override;
+inline SVGZoomAndPanType SVGSVGElement::zoomAndPan() const
+{
+ return m_zoomAndPan;
+}
- virtual AffineTransform localCoordinateSpaceTransform(SVGLocatable::CTMScope) const override;
+inline void SVGSVGElement::setZoomAndPan(unsigned short zoomAndPan)
+{
+ m_zoomAndPan = parseFromNumber(zoomAndPan);
+}
- bool m_useCurrentView;
- SVGZoomAndPanType m_zoomAndPan;
- RefPtr<SMILTimeContainer> m_timeContainer;
- SVGPoint m_translation;
- RefPtr<SVGViewSpec> m_viewSpec;
-};
+inline SMILTimeContainer& SVGSVGElement::timeContainer()
+{
+ return m_timeContainer.get();
+}
-NODE_TYPE_CASTS(SVGSVGElement)
+inline bool SVGSVGElement::hasEmptyViewBox() const
+{
+ return viewBoxIsValid() && viewBox().isEmpty();
+}
} // namespace WebCore
-
-#endif // ENABLE(SVG)
-#endif