WebKit Bugzilla
Attachment 346539 Details for
Bug 186751
: Remove the SVG elements' attributes macros
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Register SVGViewSpec attributes into SVGAttributeRegistry
186751-88.patch (text/plain), 15.06 KB, created by
Said Abou-Hallawa
on 2018-08-03 12:47:47 PDT
(
hide
)
Description:
Register SVGViewSpec attributes into SVGAttributeRegistry
Filename:
MIME Type:
Creator:
Said Abou-Hallawa
Created:
2018-08-03 12:47:47 PDT
Size:
15.06 KB
patch
obsolete
>diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index d6fd5a4243f..01717fed6ca 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,36 @@ >+2018-08-02 Said Abou-Hallawa <sabouhallawa@apple.com> >+ >+ [88] Remove the SVG elements' attributes macros >+ https://bugs.webkit.org/show_bug.cgi?id=186751 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Register SVGViewSpec attributes into SVGAttributeRegistry. >+ >+ * svg/SVGViewSpec.cpp: >+ (WebCore::SVGViewSpec::SVGViewSpec): >+ (WebCore::SVGViewSpec::registerAttributes): >+ (WebCore::SVGViewSpec::transform): >+ (WebCore::SVGViewSpec::reset): >+ (WebCore::SVGViewSpec::parseViewSpec): >+ (WebCore::SVGViewSpec::viewBoxPropertyInfo): Deleted. >+ (WebCore::SVGViewSpec::preserveAspectRatioPropertyInfo): Deleted. >+ (WebCore::SVGViewSpec::transformPropertyInfo): Deleted. >+ (WebCore::SVGViewSpec::viewBoxIdentifier): Deleted. >+ (WebCore::SVGViewSpec::preserveAspectRatioIdentifier): Deleted. >+ (WebCore::SVGViewSpec::transformIdentifier): Deleted. >+ (WebCore::SVGViewSpec::setZoomAndPan): Deleted. >+ (WebCore::SVGViewSpec::transformString const): Deleted. >+ (WebCore::SVGViewSpec::viewBoxString const): Deleted. >+ (WebCore::SVGViewSpec::preserveAspectRatioString const): Deleted. >+ (WebCore::SVGViewSpec::viewBoxAnimated): Deleted. >+ (WebCore::SVGViewSpec::preserveAspectRatioAnimated): Deleted. >+ (WebCore::SVGViewSpec::lookupOrCreateViewBoxWrapper): Deleted. >+ (WebCore::SVGViewSpec::lookupOrCreatePreserveAspectRatioWrapper): Deleted. >+ (WebCore::SVGViewSpec::lookupOrCreateTransformWrapper): Deleted. >+ * svg/SVGViewSpec.h: >+ * svg/SVGViewSpec.idl: >+ > 2018-08-02 Said Abou-Hallawa <sabouhallawa@apple.com> > > [87] Remove the SVG elements' attributes macros >diff --git a/Source/WebCore/svg/SVGViewSpec.cpp b/Source/WebCore/svg/SVGViewSpec.cpp >index 098a173dd1f..e4a6a837bde 100644 >--- a/Source/WebCore/svg/SVGViewSpec.cpp >+++ b/Source/WebCore/svg/SVGViewSpec.cpp >@@ -1,5 +1,6 @@ > /* > * Copyright (C) 2007, 2010 Rob Buis <buis@kde.org> >+ * Copyright (C) 2018 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 >@@ -31,94 +32,21 @@ > > namespace WebCore { > >-// Define custom animated property 'viewBox'. >-const SVGPropertyInfo* SVGViewSpec::viewBoxPropertyInfo() >-{ >- static const SVGPropertyInfo* s_propertyInfo = nullptr; >- if (!s_propertyInfo) { >- s_propertyInfo = new SVGPropertyInfo(AnimatedRect, >- PropertyIsReadOnly, >- SVGNames::viewBoxAttr, >- viewBoxIdentifier(), >- 0, >- 0); >- } >- return s_propertyInfo; >-} >- >-// Define custom animated property 'preserveAspectRatio'. >-const SVGPropertyInfo* SVGViewSpec::preserveAspectRatioPropertyInfo() >-{ >- static const SVGPropertyInfo* s_propertyInfo = nullptr; >- if (!s_propertyInfo) { >- s_propertyInfo = new SVGPropertyInfo(AnimatedPreserveAspectRatio, >- PropertyIsReadOnly, >- SVGNames::preserveAspectRatioAttr, >- preserveAspectRatioIdentifier(), >- 0, >- 0); >- } >- return s_propertyInfo; >-} >- >- >-// Define custom non-animated property 'transform'. >-const SVGPropertyInfo* SVGViewSpec::transformPropertyInfo() >-{ >- static const SVGPropertyInfo* s_propertyInfo = nullptr; >- if (!s_propertyInfo) { >- s_propertyInfo = new SVGPropertyInfo(AnimatedTransformList, >- PropertyIsReadOnly, >- SVGNames::transformAttr, >- transformIdentifier(), >- 0, >- 0); >- } >- return s_propertyInfo; >-} >- > SVGViewSpec::SVGViewSpec(SVGElement& contextElement) >- : m_contextElement(&contextElement) >-{ >-} >- >-const AtomicString& SVGViewSpec::viewBoxIdentifier() >-{ >- static NeverDestroyed<AtomicString> s_identifier("SVGViewSpecViewBoxAttribute", AtomicString::ConstructFromLiteral); >- return s_identifier; >-} >- >-const AtomicString& SVGViewSpec::preserveAspectRatioIdentifier() >-{ >- static NeverDestroyed<AtomicString> s_identifier("SVGViewSpecPreserveAspectRatioAttribute", AtomicString::ConstructFromLiteral); >- return s_identifier; >-} >- >-const AtomicString& SVGViewSpec::transformIdentifier() >-{ >- static NeverDestroyed<AtomicString> s_identifier("SVGViewSpecTransformAttribute", AtomicString::ConstructFromLiteral); >- return s_identifier; >-} >- >-ExceptionOr<void> SVGViewSpec::setZoomAndPan(unsigned short) >+ : SVGFitToViewBox(contextElement, PropertyIsReadOnly) >+ , SVGZoomAndPan(contextElement) >+ , m_contextElement(&contextElement) >+ , m_attributeOwnerProxy(*this, contextElement) > { >- // SVGViewSpec and all of its content is read-only. >- return Exception { NoModificationAllowedError }; >+ registerAttributes(); > } > >-String SVGViewSpec::transformString() const >+void SVGViewSpec::registerAttributes() > { >- return SVGPropertyTraits<SVGTransformListValues>::toString(m_transform); >-} >- >-String SVGViewSpec::viewBoxString() const >-{ >- return SVGPropertyTraits<FloatRect>::toString(m_viewBox); >-} >- >-String SVGViewSpec::preserveAspectRatioString() const >-{ >- return SVGPropertyTraits<SVGPreserveAspectRatioValue>::toString(m_preserveAspectRatio); >+ auto& registry = attributeRegistry(); >+ if (!registry.isEmpty()) >+ return; >+ registry.registerAttribute<SVGNames::transformAttr, &SVGViewSpec::m_transform>(); > } > > SVGElement* SVGViewSpec::viewTarget() const >@@ -136,51 +64,15 @@ RefPtr<SVGTransformList> SVGViewSpec::transform() > if (!m_contextElement) > return nullptr; > // Return the animVal here, as its readonly by default - which is exactly what we want here. >- return static_reference_cast<SVGAnimatedTransformList>(lookupOrCreateTransformWrapper(this))->animVal(); >-} >- >-RefPtr<SVGAnimatedRect> SVGViewSpec::viewBoxAnimated() >-{ >- if (!m_contextElement) >- return nullptr; >- return static_reference_cast<SVGAnimatedRect>(lookupOrCreateViewBoxWrapper(this)); >-} >- >-RefPtr<SVGAnimatedPreserveAspectRatio> SVGViewSpec::preserveAspectRatioAnimated() >-{ >- if (!m_contextElement) >- return nullptr; >- return static_reference_cast<SVGAnimatedPreserveAspectRatio>(lookupOrCreatePreserveAspectRatioWrapper(this)); >-} >- >-Ref<SVGAnimatedProperty> SVGViewSpec::lookupOrCreateViewBoxWrapper(SVGViewSpec* ownerType) >-{ >- ASSERT(ownerType); >- ASSERT(ownerType->m_contextElement); >- return SVGAnimatedProperty::lookupOrCreateWrapper<SVGElement, SVGAnimatedRect, FloatRect>(ownerType->m_contextElement, viewBoxPropertyInfo(), ownerType->m_viewBox); >-} >- >-Ref<SVGAnimatedProperty> SVGViewSpec::lookupOrCreatePreserveAspectRatioWrapper(SVGViewSpec* ownerType) >-{ >- ASSERT(ownerType); >- ASSERT(ownerType->m_contextElement); >- return SVGAnimatedProperty::lookupOrCreateWrapper<SVGElement, SVGAnimatedPreserveAspectRatio, SVGPreserveAspectRatioValue>(ownerType->m_contextElement, preserveAspectRatioPropertyInfo(), ownerType->m_preserveAspectRatio); >-} >- >-Ref<SVGAnimatedProperty> SVGViewSpec::lookupOrCreateTransformWrapper(SVGViewSpec* ownerType) >-{ >- ASSERT(ownerType); >- ASSERT(ownerType->m_contextElement); >- return SVGAnimatedProperty::lookupOrCreateWrapper<SVGElement, SVGAnimatedTransformList, SVGTransformListValues>(ownerType->m_contextElement, transformPropertyInfo(), ownerType->m_transform); >+ return m_transform.animatedProperty()->animVal(); > } > > void SVGViewSpec::reset() > { >- m_zoomAndPan = SVGZoomAndPanMagnify; >- m_transform.clear(); >- m_viewBox = { }; >- m_preserveAspectRatio = { }; > m_viewTargetString = emptyString(); >+ m_transform.resetValue(); >+ SVGFitToViewBox::reset(); >+ SVGZoomAndPan::reset(); > } > > static const UChar svgViewSpec[] = {'s', 'v', 'g', 'V', 'i', 'e', 'w'}; >@@ -213,9 +105,9 @@ bool SVGViewSpec::parseViewSpec(const String& viewSpec) > return false; > currViewSpec++; > FloatRect viewBox; >- if (!SVGFitToViewBox::parseViewBox(&m_contextElement->document(), currViewSpec, end, viewBox, false)) >+ if (!SVGFitToViewBox::parseViewBox(currViewSpec, end, viewBox, false)) > return false; >- setViewBoxBaseValue(viewBox); >+ setViewBox(viewBox); > if (currViewSpec >= end || *currViewSpec != ')') > return false; > currViewSpec++; >@@ -237,7 +129,7 @@ bool SVGViewSpec::parseViewSpec(const String& viewSpec) > if (currViewSpec >= end || *currViewSpec != '(') > return false; > currViewSpec++; >- if (!parse(currViewSpec, end, m_zoomAndPan)) >+ if (!SVGZoomAndPan::parseZoomAndPan(currViewSpec, end)) > return false; > if (currViewSpec >= end || *currViewSpec != ')') > return false; >@@ -251,7 +143,7 @@ bool SVGViewSpec::parseViewSpec(const String& viewSpec) > SVGPreserveAspectRatioValue preserveAspectRatio; > if (!preserveAspectRatio.parse(currViewSpec, end, false)) > return false; >- setPreserveAspectRatioBaseValue(preserveAspectRatio); >+ setPreserveAspectRatio(preserveAspectRatio); > if (currViewSpec >= end || *currViewSpec != ')') > return false; > currViewSpec++; >@@ -261,7 +153,7 @@ bool SVGViewSpec::parseViewSpec(const String& viewSpec) > if (currViewSpec >= end || *currViewSpec != '(') > return false; > currViewSpec++; >- SVGTransformable::parseTransformAttribute(m_transform, currViewSpec, end, SVGTransformable::DoNotClearList); >+ SVGTransformable::parseTransformAttribute(m_transform.value(), currViewSpec, end, SVGTransformable::DoNotClearList); > if (currViewSpec >= end || *currViewSpec != ')') > return false; > currViewSpec++; >diff --git a/Source/WebCore/svg/SVGViewSpec.h b/Source/WebCore/svg/SVGViewSpec.h >index 9fb5d42beee..124c1e0026b 100644 >--- a/Source/WebCore/svg/SVGViewSpec.h >+++ b/Source/WebCore/svg/SVGViewSpec.h >@@ -1,5 +1,6 @@ > /* > * Copyright (C) 2007 Rob Buis <buis@kde.org> >+ * Copyright (C) 2018 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 >@@ -30,7 +31,7 @@ namespace WebCore { > class SVGElement; > class SVGTransformList; > >-class SVGViewSpec final : public RefCounted<SVGViewSpec>, public SVGZoomAndPan, public SVGFitToViewBox { >+class SVGViewSpec final : public RefCounted<SVGViewSpec>, public SVGFitToViewBox, public SVGZoomAndPan { > public: > static Ref<SVGViewSpec> create(SVGElement& contextElement) > { >@@ -39,55 +40,28 @@ public: > > bool parseViewSpec(const String&); > void reset(); >+ void resetContextElement() { m_contextElement = nullptr; } > > SVGElement* viewTarget() const; >- >- String transformString() const; >- String viewBoxString() const; >- String preserveAspectRatioString() const; > const String& viewTargetString() const { return m_viewTargetString; } > >- SVGZoomAndPanType zoomAndPan() const { return m_zoomAndPan; } >- ExceptionOr<void> setZoomAndPan(unsigned short); >- void setZoomAndPanBaseValue(unsigned short zoomAndPan) { m_zoomAndPan = SVGZoomAndPan::parseFromNumber(zoomAndPan); } >- >- void resetContextElement() { m_contextElement = nullptr; } >- >- // Custom non-animated 'transform' property. >+ String transformString() const { return m_transform.toString(); } > RefPtr<SVGTransformList> transform(); >- SVGTransformListValues transformBaseValue() const { return m_transform; } >- >- // Custom animated 'viewBox' property. >- RefPtr<SVGAnimatedRect> viewBoxAnimated(); >- FloatRect& viewBox() { return m_viewBox; } >- void setViewBoxBaseValue(const FloatRect& viewBox) { m_viewBox = viewBox; } >- >- // Custom animated 'preserveAspectRatio' property. >- RefPtr<SVGAnimatedPreserveAspectRatio> preserveAspectRatioAnimated(); >- SVGPreserveAspectRatioValue& preserveAspectRatio() { return m_preserveAspectRatio; } >- void setPreserveAspectRatioBaseValue(const SVGPreserveAspectRatioValue& preserveAspectRatio) { m_preserveAspectRatio = preserveAspectRatio; } >+ SVGTransformListValues transformValue() const { return m_transform.value(); } > > private: > explicit SVGViewSpec(SVGElement&); > >- static const SVGPropertyInfo* transformPropertyInfo(); >- static const SVGPropertyInfo* viewBoxPropertyInfo(); >- static const SVGPropertyInfo* preserveAspectRatioPropertyInfo(); >- >- static const AtomicString& transformIdentifier(); >- static const AtomicString& viewBoxIdentifier(); >- static const AtomicString& preserveAspectRatioIdentifier(); >+ using AttributeOwnerProxy = SVGAttributeOwnerProxyImpl<SVGViewSpec, SVGFitToViewBox, SVGZoomAndPan>; >+ static void registerAttributes(); > >- static Ref<SVGAnimatedProperty> lookupOrCreateTransformWrapper(SVGViewSpec* contextElement); >- static Ref<SVGAnimatedProperty> lookupOrCreateViewBoxWrapper(SVGViewSpec* contextElement); >- static Ref<SVGAnimatedProperty> lookupOrCreatePreserveAspectRatioWrapper(SVGViewSpec* contextElement); >+ static AttributeOwnerProxy::AttributeRegistry& attributeRegistry() { return AttributeOwnerProxy::attributeRegistry(); } >+ static bool isKnownAttribute(const QualifiedName& attributeName) { return AttributeOwnerProxy::isKnownAttribute(attributeName); } > > SVGElement* m_contextElement; >- SVGZoomAndPanType m_zoomAndPan { SVGZoomAndPanMagnify }; >- SVGTransformListValues m_transform; >- FloatRect m_viewBox; >- SVGPreserveAspectRatioValue m_preserveAspectRatio; > String m_viewTargetString; >+ AttributeOwnerProxy m_attributeOwnerProxy; >+ SVGAnimatedTransformListAttribute m_transform { m_attributeOwnerProxy }; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/svg/SVGViewSpec.idl b/Source/WebCore/svg/SVGViewSpec.idl >index 5708c03ccb1..4411d576aa5 100644 >--- a/Source/WebCore/svg/SVGViewSpec.idl >+++ b/Source/WebCore/svg/SVGViewSpec.idl >@@ -1,5 +1,6 @@ > /* > * Copyright (C) 2007 Eric Seidel <eric@webkit.org> >+ * Copyright (C) 2018 Apple Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -35,9 +36,7 @@ > readonly attribute DOMString preserveAspectRatioString; > readonly attribute DOMString transformString; > readonly attribute DOMString viewTargetString; >- >- // SVGZoomAndPan >- attribute unsigned short zoomAndPan; > }; > > SVGViewSpec implements SVGFitToViewBox; >+SVGViewSpec implements SVGZoomAndPan;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 186751
:
342916
|
342917
|
342985
|
343001
|
343114
|
343123
|
343124
|
343127
|
343129
|
343162
|
343167
|
343169
|
343171
|
343174
|
343213
|
343217
|
343327
|
343335
|
343338
|
343339
|
343343
|
343415
|
343979
|
343989
|
344002
|
344513
|
344516
|
344523
|
344534
|
344536
|
344988
|
344990
|
346097
|
346103
|
346124
|
346129
|
346177
|
346179
|
346180
|
346182
|
346185
|
346188
|
346190
|
346192
|
346193
|
346197
|
346199
|
346201
|
346202
|
346203
|
346204
|
346205
|
346206
|
346207
|
346211
|
346212
|
346217
|
346224
|
346230
|
346233
|
346241
|
346244
|
346245
|
346315
|
346316
|
346317
|
346318
|
346319
|
346320
|
346322
|
346323
|
346324
|
346325
|
346326
|
346327
|
346328
|
346329
|
346330
|
346331
|
346332
|
346333
|
346334
|
346335
|
346336
|
346337
|
346338
|
346339
|
346340
|
346341
|
346342
|
346343
|
346344
|
346345
|
346346
|
346347
|
346348
|
346349
|
346350
|
346518
|
346519
|
346520
|
346521
|
346522
|
346524
|
346525
|
346526
|
346527
|
346528
|
346529
|
346530
|
346531
|
346532
|
346533
|
346534
|
346535
|
346536
|
346537
|
346538
|
346539
|
346540
|
346541
|
346545
|
346546
|
346549
|
346551
|
346552
|
346601
|
346602
|
346611
|
346636
|
346642