summaryrefslogtreecommitdiff
path: root/Source/WebCore/svg/SVGViewSpec.cpp
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@qt.io>2017-05-30 12:48:17 +0200
committerOswald Buddenhagen <oswald.buddenhagen@qt.io>2017-05-30 12:48:17 +0200
commit881da28418d380042aa95a97f0cbd42560a64f7c (patch)
treea794dff3274695e99c651902dde93d934ea7a5af /Source/WebCore/svg/SVGViewSpec.cpp
parent7e104c57a70fdf551bb3d22a5d637cdcbc69dbea (diff)
parent0fcedcd17cc00d3dd44c718b3cb36c1033319671 (diff)
downloadqtwebkit-881da28418d380042aa95a97f0cbd42560a64f7c.tar.gz
Merge 'wip/next' into dev
Change-Id: Iff9ee5e23bb326c4371ec8ed81d56f2f05d680e9
Diffstat (limited to 'Source/WebCore/svg/SVGViewSpec.cpp')
-rw-r--r--Source/WebCore/svg/SVGViewSpec.cpp56
1 files changed, 26 insertions, 30 deletions
diff --git a/Source/WebCore/svg/SVGViewSpec.cpp b/Source/WebCore/svg/SVGViewSpec.cpp
index 5ac02dbdd..0c69c7be5 100644
--- a/Source/WebCore/svg/SVGViewSpec.cpp
+++ b/Source/WebCore/svg/SVGViewSpec.cpp
@@ -18,8 +18,6 @@
*/
#include "config.h"
-
-#if ENABLE(SVG)
#include "SVGViewSpec.h"
#include "Document.h"
@@ -27,7 +25,6 @@
#include "SVGFitToViewBox.h"
#include "SVGNames.h"
#include "SVGParserUtilities.h"
-#include "SVGSVGElement.h"
#include "SVGTransformable.h"
namespace WebCore {
@@ -35,7 +32,7 @@ namespace WebCore {
// Define custom animated property 'viewBox'.
const SVGPropertyInfo* SVGViewSpec::viewBoxPropertyInfo()
{
- static const SVGPropertyInfo* s_propertyInfo = 0;
+ static const SVGPropertyInfo* s_propertyInfo = nullptr;
if (!s_propertyInfo) {
s_propertyInfo = new SVGPropertyInfo(AnimatedRect,
PropertyIsReadOnly,
@@ -50,7 +47,7 @@ const SVGPropertyInfo* SVGViewSpec::viewBoxPropertyInfo()
// Define custom animated property 'preserveAspectRatio'.
const SVGPropertyInfo* SVGViewSpec::preserveAspectRatioPropertyInfo()
{
- static const SVGPropertyInfo* s_propertyInfo = 0;
+ static const SVGPropertyInfo* s_propertyInfo = nullptr;
if (!s_propertyInfo) {
s_propertyInfo = new SVGPropertyInfo(AnimatedPreserveAspectRatio,
PropertyIsReadOnly,
@@ -66,7 +63,7 @@ const SVGPropertyInfo* SVGViewSpec::preserveAspectRatioPropertyInfo()
// Define custom non-animated property 'transform'.
const SVGPropertyInfo* SVGViewSpec::transformPropertyInfo()
{
- static const SVGPropertyInfo* s_propertyInfo = 0;
+ static const SVGPropertyInfo* s_propertyInfo = nullptr;
if (!s_propertyInfo) {
s_propertyInfo = new SVGPropertyInfo(AnimatedTransformList,
PropertyIsReadOnly,
@@ -87,19 +84,19 @@ SVGViewSpec::SVGViewSpec(SVGElement* contextElement)
const AtomicString& SVGViewSpec::viewBoxIdentifier()
{
- DEFINE_STATIC_LOCAL(AtomicString, s_identifier, ("SVGViewSpecViewBoxAttribute", AtomicString::ConstructFromLiteral));
+ static NeverDestroyed<AtomicString> s_identifier("SVGViewSpecViewBoxAttribute", AtomicString::ConstructFromLiteral);
return s_identifier;
}
const AtomicString& SVGViewSpec::preserveAspectRatioIdentifier()
{
- DEFINE_STATIC_LOCAL(AtomicString, s_identifier, ("SVGViewSpecPreserveAspectRatioAttribute", AtomicString::ConstructFromLiteral));
+ static NeverDestroyed<AtomicString> s_identifier("SVGViewSpecPreserveAspectRatioAttribute", AtomicString::ConstructFromLiteral);
return s_identifier;
}
const AtomicString& SVGViewSpec::transformIdentifier()
{
- DEFINE_STATIC_LOCAL(AtomicString, s_identifier, ("SVGViewSpecTransformAttribute", AtomicString::ConstructFromLiteral));
+ static NeverDestroyed<AtomicString> s_identifier("SVGViewSpecTransformAttribute", AtomicString::ConstructFromLiteral);
return s_identifier;
}
@@ -117,7 +114,7 @@ void SVGViewSpec::setTransformString(const String& transform)
SVGTransformList newList;
newList.parse(transform);
- if (RefPtr<SVGAnimatedProperty> wrapper = SVGAnimatedProperty::lookupWrapper<SVGElement, SVGAnimatedTransformList>(m_contextElement, transformPropertyInfo()))
+ if (auto wrapper = SVGAnimatedProperty::lookupWrapper<SVGElement, SVGAnimatedTransformList>(m_contextElement, transformPropertyInfo()))
static_pointer_cast<SVGAnimatedTransformList>(wrapper)->detachListWrappers(newList.size());
m_transform = newList;
@@ -141,50 +138,50 @@ String SVGViewSpec::preserveAspectRatioString() const
SVGElement* SVGViewSpec::viewTarget() const
{
if (!m_contextElement)
- return 0;
- Element* element = m_contextElement->treeScope()->getElementById(m_viewTargetString);
+ 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);
}
RefPtr<SVGTransformListPropertyTearOff> SVGViewSpec::transform()
{
if (!m_contextElement)
- return 0;
+ return nullptr;
// 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().get());
+ return static_pointer_cast<SVGTransformListPropertyTearOff>(static_reference_cast<SVGAnimatedTransformList>(lookupOrCreateTransformWrapper(this))->animVal());
}
-PassRefPtr<SVGAnimatedRect> SVGViewSpec::viewBoxAnimated()
+RefPtr<SVGAnimatedRect> SVGViewSpec::viewBoxAnimated()
{
if (!m_contextElement)
- return 0;
- return static_pointer_cast<SVGAnimatedRect>(lookupOrCreateViewBoxWrapper(this));
+ return nullptr;
+ return static_reference_cast<SVGAnimatedRect>(lookupOrCreateViewBoxWrapper(this));
}
-PassRefPtr<SVGAnimatedPreserveAspectRatio> SVGViewSpec::preserveAspectRatioAnimated()
+RefPtr<SVGAnimatedPreserveAspectRatio> SVGViewSpec::preserveAspectRatioAnimated()
{
if (!m_contextElement)
- return 0;
- return static_pointer_cast<SVGAnimatedPreserveAspectRatio>(lookupOrCreatePreserveAspectRatioWrapper(this));
+ return nullptr;
+ return static_reference_cast<SVGAnimatedPreserveAspectRatio>(lookupOrCreatePreserveAspectRatioWrapper(this));
}
-PassRefPtr<SVGAnimatedProperty> SVGViewSpec::lookupOrCreateViewBoxWrapper(SVGViewSpec* ownerType)
+Ref<SVGAnimatedProperty> SVGViewSpec::lookupOrCreateViewBoxWrapper(SVGViewSpec* ownerType)
{
ASSERT(ownerType);
ASSERT(ownerType->contextElement());
return SVGAnimatedProperty::lookupOrCreateWrapper<SVGElement, SVGAnimatedRect, FloatRect>(ownerType->contextElement(), viewBoxPropertyInfo(), ownerType->m_viewBox);
}
-PassRefPtr<SVGAnimatedProperty> SVGViewSpec::lookupOrCreatePreserveAspectRatioWrapper(SVGViewSpec* ownerType)
+Ref<SVGAnimatedProperty> SVGViewSpec::lookupOrCreatePreserveAspectRatioWrapper(SVGViewSpec* ownerType)
{
ASSERT(ownerType);
ASSERT(ownerType->contextElement());
return SVGAnimatedProperty::lookupOrCreateWrapper<SVGElement, SVGAnimatedPreserveAspectRatio, SVGPreserveAspectRatio>(ownerType->contextElement(), preserveAspectRatioPropertyInfo(), ownerType->m_preserveAspectRatio);
}
-PassRefPtr<SVGAnimatedProperty> SVGViewSpec::lookupOrCreateTransformWrapper(SVGViewSpec* ownerType)
+Ref<SVGAnimatedProperty> SVGViewSpec::lookupOrCreateTransformWrapper(SVGViewSpec* ownerType)
{
ASSERT(ownerType);
ASSERT(ownerType->contextElement());
@@ -209,7 +206,8 @@ static const UChar viewTargetSpec[] = {'v', 'i', 'e', 'w', 'T', 'a', 'r', 'g',
bool SVGViewSpec::parseViewSpec(const String& viewSpec)
{
- const UChar* currViewSpec = viewSpec.characters();
+ auto upconvertedCharacters = StringView(viewSpec).upconvertedCharacters();
+ const UChar* currViewSpec = upconvertedCharacters;
const UChar* end = currViewSpec + viewSpec.length();
if (currViewSpec >= end || !m_contextElement)
@@ -229,7 +227,7 @@ bool SVGViewSpec::parseViewSpec(const String& viewSpec)
return false;
currViewSpec++;
FloatRect viewBox;
- if (!SVGFitToViewBox::parseViewBox(m_contextElement->document(), currViewSpec, end, viewBox, false))
+ if (!SVGFitToViewBox::parseViewBox(&m_contextElement->document(), currViewSpec, end, viewBox, false))
return false;
setViewBoxBaseValue(viewBox);
if (currViewSpec >= end || *currViewSpec != ')')
@@ -253,7 +251,7 @@ bool SVGViewSpec::parseViewSpec(const String& viewSpec)
if (currViewSpec >= end || *currViewSpec != '(')
return false;
currViewSpec++;
- if (!parseZoomAndPan(currViewSpec, end, m_zoomAndPan))
+ if (!parse(currViewSpec, end, m_zoomAndPan))
return false;
if (currViewSpec >= end || *currViewSpec != ')')
return false;
@@ -295,5 +293,3 @@ bool SVGViewSpec::parseViewSpec(const String& viewSpec)
}
}
-
-#endif // ENABLE(SVG)