summaryrefslogtreecommitdiff
path: root/Source/WebCore/svg/SVGPathSegWithContext.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/svg/SVGPathSegWithContext.h')
-rw-r--r--Source/WebCore/svg/SVGPathSegWithContext.h34
1 files changed, 14 insertions, 20 deletions
diff --git a/Source/WebCore/svg/SVGPathSegWithContext.h b/Source/WebCore/svg/SVGPathSegWithContext.h
index 701067227..60f392582 100644
--- a/Source/WebCore/svg/SVGPathSegWithContext.h
+++ b/Source/WebCore/svg/SVGPathSegWithContext.h
@@ -17,35 +17,36 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef SVGPathSegWithContext_h
-#define SVGPathSegWithContext_h
+#pragma once
-#if ENABLE(SVG)
#include "SVGAnimatedPathSegListPropertyTearOff.h"
namespace WebCore {
class SVGPathSegWithContext : public SVGPathSeg {
public:
- SVGPathSegWithContext(SVGPathElement* element, SVGPathSegRole role)
+ SVGPathSegWithContext(const SVGPathElement& element, SVGPathSegRole role)
: m_role(role)
- , m_element(element)
+ , m_element(element.createWeakPtr())
{
}
- SVGAnimatedProperty* animatedProperty() const
+ RefPtr<SVGAnimatedProperty> animatedProperty() const
{
+ if (!m_element)
+ return nullptr;
+
switch (m_role) {
case PathSegUndefinedRole:
- return 0;
+ return nullptr;
case PathSegUnalteredRole:
return SVGAnimatedProperty::lookupWrapper<SVGPathElement, SVGAnimatedPathSegListPropertyTearOff>(m_element.get(), SVGPathElement::dPropertyInfo());
case PathSegNormalizedRole:
// FIXME: https://bugs.webkit.org/show_bug.cgi?id=15412 - Implement normalized path segment lists!
- return 0;
+ return nullptr;
};
- return 0;
+ return nullptr;
}
SVGPathElement* contextElement() const { return m_element.get(); }
@@ -54,24 +55,20 @@ public:
void setContextAndRole(SVGPathElement* element, SVGPathSegRole role)
{
m_role = role;
- m_element = element;
+ m_element = element ? element->createWeakPtr() : WeakPtr<SVGPathElement>();
}
protected:
void commitChange()
{
- if (!m_element) {
- ASSERT(m_role == PathSegUndefinedRole);
+ if (!m_element || m_role == PathSegUndefinedRole)
return;
- }
-
- ASSERT(m_role != PathSegUndefinedRole);
m_element->pathSegListChanged(m_role);
}
private:
SVGPathSegRole m_role;
- RefPtr<SVGPathElement> m_element;
+ WeakPtr<SVGPathElement> m_element;
};
class SVGPathSegSingleCoordinate : public SVGPathSegWithContext {
@@ -91,7 +88,7 @@ public:
}
protected:
- SVGPathSegSingleCoordinate(SVGPathElement* element, SVGPathSegRole role, float x, float y)
+ SVGPathSegSingleCoordinate(const SVGPathElement& element, SVGPathSegRole role, float x, float y)
: SVGPathSegWithContext(element, role)
, m_x(x)
, m_y(y)
@@ -104,6 +101,3 @@ private:
};
} // namespace WebCore
-
-#endif // ENABLE(SVG)
-#endif