Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1377)

Unified Diff: Source/core/svg/SVGViewSpec.cpp

Issue 153883003: [SVG] SVGAnimatedTransform{,List} migration to new SVG property impl. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: haraken review Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/svg/SVGViewSpec.cpp
diff --git a/Source/core/svg/SVGViewSpec.cpp b/Source/core/svg/SVGViewSpec.cpp
index 9db13554a3768037ac91037303cccf5f6e647d12..bcd8a7851c77c30c2082d4765bfa73a3de9d5050 100644
--- a/Source/core/svg/SVGViewSpec.cpp
+++ b/Source/core/svg/SVGViewSpec.cpp
@@ -29,21 +29,6 @@
namespace WebCore {
-// Define custom non-animated property 'transform'.
-const SVGPropertyInfo* SVGViewSpec::transformPropertyInfo()
-{
- static const SVGPropertyInfo* s_propertyInfo = 0;
- if (!s_propertyInfo) {
- s_propertyInfo = new SVGPropertyInfo(AnimatedTransformList,
- PropertyIsReadOnly,
- SVGNames::transformAttr,
- transformIdentifier(),
- 0,
- 0);
- }
- return s_propertyInfo;
-}
-
SVGViewSpec::SVGViewSpec(SVGSVGElement* contextElement)
: m_contextElement(contextElement)
, m_zoomAndPan(SVGZoomAndPanMagnify)
@@ -51,23 +36,19 @@ SVGViewSpec::SVGViewSpec(SVGSVGElement* contextElement)
// This contextElement will be only used for keeping this alive from the tearoff.
// SVGSVGElement holds a strong-ref to this SVGViewSpec, so this is kept alive as:
// AnimatedProperty tearoff -(contextElement)-> SVGSVGElement -(RefPtr)-> SVGViewSpec.
+ , m_transform(SVGAnimatedTransformList::create(contextElement, SVGNames::transformAttr, SVGTransformList::create()))
, m_viewBox(SVGAnimatedRect::create(contextElement, SVGNames::viewBoxAttr))
, m_preserveAspectRatio(SVGAnimatedPreserveAspectRatio::create(contextElement, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create()))
{
ASSERT(m_contextElement);
ScriptWrappable::init(this);
+ m_transform->setReadOnly();
m_viewBox->setReadOnly();
m_preserveAspectRatio->setReadOnly();
// Note: addToPropertyMap is not needed, as SVGViewSpec do not correspond to an element.
}
-const AtomicString& SVGViewSpec::transformIdentifier()
-{
- DEFINE_STATIC_LOCAL(AtomicString, s_identifier, ("SVGViewSpecTransformAttribute", AtomicString::ConstructFromLiteral));
- return s_identifier;
-}
-
void SVGViewSpec::setZoomAndPan(unsigned short, ExceptionState& exceptionState)
{
// SVGViewSpec and all of its content is read-only.
@@ -79,23 +60,12 @@ String SVGViewSpec::preserveAspectRatioString() const
return m_preserveAspectRatio->baseValue()->valueAsString();
}
-void SVGViewSpec::setTransformString(const String& transform)
-{
- if (!m_contextElement)
- return;
-
- SVGTransformList newList;
- newList.parse(transform);
-
- if (SVGAnimatedProperty* wrapper = SVGAnimatedProperty::lookupWrapper<SVGElement, SVGAnimatedTransformList>(m_contextElement, transformPropertyInfo()))
- static_cast<SVGAnimatedTransformList*>(wrapper)->detachListWrappers(newList.size());
-
- m_transform = newList;
-}
-
String SVGViewSpec::transformString() const
{
- return SVGPropertyTraits<SVGTransformList>::toString(m_transform);
+ if (!m_transform)
+ return String();
+
+ return m_transform->baseValue()->valueAsString();
}
String SVGViewSpec::viewBoxString() const
@@ -113,23 +83,9 @@ SVGElement* SVGViewSpec::viewTarget() const
return toSVGElement(element);
}
-SVGTransformListPropertyTearOff* SVGViewSpec::transform()
-{
- if (!m_contextElement)
- return 0;
- // Return the animVal here, as its readonly by default - which is exactly what we want here.
- return static_cast<SVGTransformListPropertyTearOff*>(static_pointer_cast<SVGAnimatedTransformList>(lookupOrCreateTransformWrapper(this))->animVal());
-}
-
-PassRefPtr<SVGAnimatedProperty> SVGViewSpec::lookupOrCreateTransformWrapper(SVGViewSpec* ownerType)
-{
- ASSERT(ownerType);
- ASSERT(ownerType->contextElement());
- return SVGAnimatedProperty::lookupOrCreateWrapper<SVGElement, SVGAnimatedTransformList, SVGTransformList>(ownerType->contextElement(), transformPropertyInfo(), ownerType->m_transform);
-}
-
void SVGViewSpec::detachContextElement()
{
+ m_transform = 0;
fs 2014/02/17 14:14:31 Any reason we can't hold on to these when the cont
kouhei (in TOK) 2014/02/18 02:09:15 These tear-offs' wrappers keep context element ali
m_viewBox = 0;
m_preserveAspectRatio = 0;
m_contextElement = 0;
@@ -138,7 +94,7 @@ void SVGViewSpec::detachContextElement()
void SVGViewSpec::reset()
{
m_zoomAndPan = SVGZoomAndPanMagnify;
- m_transform.clear();
+ m_transform->baseValue()->clear();
ASSERT(m_viewBox);
m_viewBox->baseValue()->setValue(FloatRect());
ASSERT(m_preserveAspectRatio);
@@ -188,7 +144,7 @@ bool SVGViewSpec::parseViewSpecInternal(const CharType* ptr, const CharType* end
ptr++;
if (ptr >= end)
return false;
- setViewTargetString(String(viewTargetStart, ptr - viewTargetStart));
+ m_viewTargetString = String(viewTargetStart, ptr - viewTargetStart);
ptr++;
} else
return false;
@@ -220,7 +176,7 @@ bool SVGViewSpec::parseViewSpecInternal(const CharType* ptr, const CharType* end
if (ptr >= end || *ptr != '(')
return false;
ptr++;
- parseTransformAttribute(m_transform, ptr, end, DoNotClearList);
+ m_transform->baseValue()->parse(ptr, end);
fs 2014/02/17 14:14:31 This appears to drop the "DoNotClearList"-semantic
kouhei (in TOK) 2014/02/18 02:09:15 True, added to description. I think this is a corr
if (ptr >= end || *ptr != ')')
return false;
ptr++;

Powered by Google App Engine
This is Rietveld 408576698