WebKit Bugzilla
Attachment 346535 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]
Remove SVG macros from SVGPathElement
186751-84.patch (text/plain), 16.86 KB, created by
Said Abou-Hallawa
on 2018-08-03 12:45:49 PDT
(
hide
)
Description:
Remove SVG macros from SVGPathElement
Filename:
MIME Type:
Creator:
Said Abou-Hallawa
Created:
2018-08-03 12:45:49 PDT
Size:
16.86 KB
patch
obsolete
>diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 78cf95f3bd8..c7e13dc44b0 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,36 @@ >+2018-08-02 Said Abou-Hallawa <sabouhallawa@apple.com> >+ >+ [84] Remove the SVG elements' attributes macros >+ https://bugs.webkit.org/show_bug.cgi?id=186751 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Remove SVG macros from SVGPathElement. >+ >+ -- Remove the parsing of 'pathLength' attribute since this is now parsed >+ by the SVGGeomtryElement. >+ -- Replace the custom handling for the 'd' attribute by a class which >+ is derived from SVGAnimatedPathSegListAttribute. Its purpose is to >+ build the path from the byte stream when it is only needed. >+ >+ * svg/SVGPathElement.cpp: >+ (WebCore::SVGPathElement::SVGPathElement): >+ (WebCore::SVGPathElement::registerAttributes): >+ (WebCore::SVGPathElement::parseAttribute): >+ (WebCore::SVGPathElement::svgAttributeChanged): >+ (WebCore::SVGPathElement::pathByteStream const): >+ (WebCore::SVGPathElement::lookupOrCreateDWrapper): >+ (WebCore::SVGPathElement::animatedPropertyWillBeDeleted): >+ (WebCore::SVGPathElement::pathSegList): >+ (WebCore::SVGPathElement::animatedPathSegList): >+ (WebCore::SVGPathElement::pathSegListChanged): >+ (WebCore::SVGPathElement::dPropertyInfo): Deleted. >+ (WebCore::SVGPathElement::isSupportedAttribute): Deleted. >+ (WebCore::SVGPathElement::synchronizeD): Deleted. >+ * svg/SVGPathElement.h: >+ * svg/SVGPathSegWithContext.h: >+ (WebCore::SVGPathSegWithContext::animatedProperty const): >+ > 2018-08-02 Said Abou-Hallawa <sabouhallawa@apple.com> > > [83] Remove the SVG elements' attributes macros >diff --git a/Source/WebCore/svg/SVGPathElement.cpp b/Source/WebCore/svg/SVGPathElement.cpp >index 1dac18c5cc1..0c6d6bf89f4 100644 >--- a/Source/WebCore/svg/SVGPathElement.cpp >+++ b/Source/WebCore/svg/SVGPathElement.cpp >@@ -56,39 +56,12 @@ namespace WebCore { > > WTF_MAKE_ISO_ALLOCATED_IMPL(SVGPathElement); > >-// Define custom animated property 'd'. >-const SVGPropertyInfo* SVGPathElement::dPropertyInfo() >-{ >- static const SVGPropertyInfo* s_propertyInfo = nullptr; >- if (!s_propertyInfo) { >- s_propertyInfo = new SVGPropertyInfo(AnimatedPath, >- PropertyIsReadWrite, >- SVGNames::dAttr, >- SVGNames::dAttr->localName(), >- &SVGPathElement::synchronizeD, >- &SVGPathElement::lookupOrCreateDWrapper); >- } >- return s_propertyInfo; >-} >- >-// Animated property definitions >-DEFINE_ANIMATED_NUMBER(SVGPathElement, SVGNames::pathLengthAttr, PathLength, pathLength) >-DEFINE_ANIMATED_BOOLEAN(SVGPathElement, SVGNames::externalResourcesRequiredAttr, ExternalResourcesRequired, externalResourcesRequired) >- >-BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGPathElement) >- REGISTER_LOCAL_ANIMATED_PROPERTY(d) >- REGISTER_LOCAL_ANIMATED_PROPERTY(pathLength) >- REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) >- REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGeometryElement) >-END_REGISTER_ANIMATED_PROPERTIES >- > inline SVGPathElement::SVGPathElement(const QualifiedName& tagName, Document& document) > : SVGGeometryElement(tagName, document) >- , m_pathSegList(PathSegUnalteredRole) >- , m_isAnimValObserved(false) >+ , SVGExternalResourcesRequired(*this) > { > ASSERT(hasTagName(SVGNames::pathTag)); >- registerAnimatedPropertiesForSVGPathElement(); >+ registerAttributes(); > } > > Ref<SVGPathElement> SVGPathElement::create(const QualifiedName& tagName, Document& document) >@@ -212,16 +185,12 @@ Ref<SVGPathSegCurvetoQuadraticSmoothRel> SVGPathElement::createSVGPathSegCurveto > return SVGPathSegCurvetoQuadraticSmoothRel::create(*this, role, x, y); > } > >-bool SVGPathElement::isSupportedAttribute(const QualifiedName& attrName) >+void SVGPathElement::registerAttributes() > { >- static const auto supportedAttributes = makeNeverDestroyed([] { >- HashSet<QualifiedName> set; >- SVGLangSpace::addSupportedAttributes(set); >- SVGExternalResourcesRequired::addSupportedAttributes(set); >- set.add({ SVGNames::dAttr.get(), SVGNames::pathLengthAttr.get() }); >- return set; >- }()); >- return supportedAttributes.get().contains<SVGAttributeHashTranslator>(attrName); >+ auto& registry = attributeRegistry(); >+ if (!registry.isEmpty()) >+ return; >+ registry.registerAttribute(SVGAnimatedCustomPathSegListAttributeAccessor::singleton<SVGNames::dAttr, &SVGPathElement::m_pathSegList>()); > } > > void SVGPathElement::parseAttribute(const QualifiedName& name, const AtomicString& value) >@@ -233,43 +202,35 @@ void SVGPathElement::parseAttribute(const QualifiedName& name, const AtomicStrin > return; > } > >- if (name == SVGNames::pathLengthAttr) { >- setPathLengthBaseValue(value.toFloat()); >- if (pathLengthBaseValue() < 0) >- document().accessSVGExtensions().reportError("A negative value for path attribute <pathLength> is not allowed"); >- return; >- } >- > SVGGeometryElement::parseAttribute(name, value); > SVGExternalResourcesRequired::parseAttribute(name, value); > } > > void SVGPathElement::svgAttributeChanged(const QualifiedName& attrName) > { >- if (!isSupportedAttribute(attrName)) { >- SVGGeometryElement::svgAttributeChanged(attrName); >- return; >- } >- >- InstanceInvalidationGuard guard(*this); >+ if (isKnownAttribute(attrName)) { >+ InstanceInvalidationGuard guard(*this); > >- RenderSVGPath* renderer = downcast<RenderSVGPath>(this->renderer()); >+ RenderSVGPath* renderer = downcast<RenderSVGPath>(this->renderer()); >+ if (attrName == SVGNames::dAttr) { >+ if (m_pathSegList.shouldSynchronize() && !lookupAnimatedProperty(m_pathSegList)->isAnimating()) { >+ SVGPathSegListValues newList(PathSegUnalteredRole); >+ buildSVGPathSegListValuesFromByteStream(m_pathByteStream, *this, newList, UnalteredParsing); >+ m_pathSegList.setValue(WTFMove(newList)); >+ } > >- if (attrName == SVGNames::dAttr) { >- if (m_pathSegList.shouldSynchronize && !SVGAnimatedProperty::lookupWrapper<SVGPathElement, SVGAnimatedPathSegListPropertyTearOff>(this, dPropertyInfo())->isAnimating()) { >- SVGPathSegListValues newList(PathSegUnalteredRole); >- buildSVGPathSegListValuesFromByteStream(m_pathByteStream, *this, newList, UnalteredParsing); >- m_pathSegList.value = WTFMove(newList); >+ if (renderer) >+ renderer->setNeedsShapeUpdate(); >+ invalidateMPathDependencies(); > } > > if (renderer) >- renderer->setNeedsShapeUpdate(); >- >- invalidateMPathDependencies(); >+ RenderSVGResource::markForLayoutAndParentResourceInvalidation(*renderer); >+ return; > } > >- if (renderer) >- RenderSVGResource::markForLayoutAndParentResourceInvalidation(*renderer); >+ SVGGeometryElement::svgAttributeChanged(attrName); >+ SVGExternalResourcesRequired::svgAttributeChanged(attrName); > } > > void SVGPathElement::invalidateMPathDependencies() >@@ -299,13 +260,12 @@ void SVGPathElement::removedFromAncestor(RemovalType removalType, ContainerNode& > > const SVGPathByteStream& SVGPathElement::pathByteStream() const > { >- auto property = SVGAnimatedProperty::lookupWrapper<SVGPathElement, SVGAnimatedPathSegListPropertyTearOff>(this, dPropertyInfo()); >+ auto property = lookupAnimatedProperty(m_pathSegList); > if (!property || !property->isAnimating()) > return m_pathByteStream; > >- SVGPathByteStream* animatedPathByteStream = static_cast<SVGAnimatedPathSegListPropertyTearOff*>(property.get())->animatedPathByteStream(); >- if (!animatedPathByteStream) >- return m_pathByteStream; >+ if (auto* animatedPathByteStream = static_cast<SVGAnimatedPathSegListPropertyTearOff*>(property.get())->animatedPathByteStream()) >+ return *animatedPathByteStream; > > return *animatedPathByteStream; > } >@@ -323,42 +283,23 @@ Path SVGPathElement::pathForByteStream() const > return buildPathFromByteStream(pathByteStreamToUse); > } > >-Ref<SVGAnimatedProperty> SVGPathElement::lookupOrCreateDWrapper(SVGElement* contextElement) >-{ >- ASSERT(contextElement); >- SVGPathElement& ownerType = downcast<SVGPathElement>(*contextElement); >- >- if (auto property = SVGAnimatedProperty::lookupWrapper<SVGPathElement, SVGAnimatedPathSegListPropertyTearOff>(&ownerType, dPropertyInfo())) >- return *property; >- >- if (ownerType.m_pathSegList.value.isEmpty()) >- buildSVGPathSegListValuesFromByteStream(ownerType.m_pathByteStream, ownerType, ownerType.m_pathSegList.value, UnalteredParsing); >- >- return SVGAnimatedProperty::lookupOrCreateWrapper<SVGPathElement, SVGAnimatedPathSegListPropertyTearOff, SVGPathSegListValues>(&ownerType, dPropertyInfo(), ownerType.m_pathSegList.value); >-} >- >-void SVGPathElement::synchronizeD(SVGElement* contextElement) >+RefPtr<SVGAnimatedProperty> SVGPathElement::lookupOrCreateDWrapper() > { >- ASSERT(contextElement); >- SVGPathElement& ownerType = downcast<SVGPathElement>(*contextElement); >- if (!ownerType.m_pathSegList.shouldSynchronize) >- return; >- ownerType.m_pathSegList.synchronize(&ownerType, dPropertyInfo()->attributeName, ownerType.m_pathSegList.value.valueAsString()); >+ return m_pathSegList.animatedProperty(); > } > > void SVGPathElement::animatedPropertyWillBeDeleted() > { > // m_pathSegList.shouldSynchronize is set to true when the 'd' wrapper for m_pathSegList > // is created and cached. We need to reset it back to false when this wrapper is deleted >- // so we can be sure if shouldSynchronize is true, SVGAnimatedProperty::lookupWrapper() >+ // so we can be sure if shouldSynchronize is true, SVGAttributeAccessor::lookupAnimatedProperty() > // will return a valid cached 'd' wrapper for the m_pathSegList. >- m_pathSegList.shouldSynchronize = false; >+ m_pathSegList.setShouldSynchronize(false); > } > > Ref<SVGPathSegList> SVGPathElement::pathSegList() > { >- m_pathSegList.shouldSynchronize = true; >- return static_reference_cast<SVGAnimatedPathSegListPropertyTearOff>(lookupOrCreateDWrapper(this))->baseVal(); >+ return static_pointer_cast<SVGAnimatedPathSegListPropertyTearOff>(lookupOrCreateDWrapper())->baseVal(); > } > > RefPtr<SVGPathSegList> SVGPathElement::normalizedPathSegList() >@@ -369,9 +310,8 @@ RefPtr<SVGPathSegList> SVGPathElement::normalizedPathSegList() > > Ref<SVGPathSegList> SVGPathElement::animatedPathSegList() > { >- m_pathSegList.shouldSynchronize = true; > m_isAnimValObserved = true; >- return static_reference_cast<SVGAnimatedPathSegListPropertyTearOff>(lookupOrCreateDWrapper(this))->animVal(); >+ return static_pointer_cast<SVGAnimatedPathSegListPropertyTearOff>(lookupOrCreateDWrapper())->animVal(); > } > > RefPtr<SVGPathSegList> SVGPathElement::animatedNormalizedPathSegList() >@@ -394,14 +334,16 @@ void SVGPathElement::pathSegListChanged(SVGPathSegRole role, ListModification li > case PathSegNormalizedRole: > // FIXME: https://bugs.webkit.org/show_bug.cgi?id=15412 - Implement normalized path segment lists! > break; >- case PathSegUnalteredRole: >+ case PathSegUnalteredRole: { >+ auto& pathSegList = m_pathSegList.value(false); > if (listModification == ListModificationAppend) { >- ASSERT(!m_pathSegList.value.isEmpty()); >- appendSVGPathByteStreamFromSVGPathSeg(m_pathSegList.value.last().copyRef(), m_pathByteStream, UnalteredParsing); >+ ASSERT(!pathSegList.isEmpty()); >+ appendSVGPathByteStreamFromSVGPathSeg(pathSegList.last().copyRef(), m_pathByteStream, UnalteredParsing); > } else >- buildSVGPathByteStreamFromSVGPathSegListValues(m_pathSegList.value, m_pathByteStream, UnalteredParsing); >+ buildSVGPathByteStreamFromSVGPathSegListValues(pathSegList, m_pathByteStream, UnalteredParsing); > m_cachedPath = std::nullopt; > break; >+ } > case PathSegUndefinedRole: > return; > } >diff --git a/Source/WebCore/svg/SVGPathElement.h b/Source/WebCore/svg/SVGPathElement.h >index 1e4ec8f6385..48c95a4e7e8 100644 >--- a/Source/WebCore/svg/SVGPathElement.h >+++ b/Source/WebCore/svg/SVGPathElement.h >@@ -1,6 +1,7 @@ > /* > * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> > * Copyright (C) 2004, 2005, 2006, 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 >@@ -23,6 +24,7 @@ > #include "Path.h" > #include "SVGAnimatedBoolean.h" > #include "SVGAnimatedNumber.h" >+#include "SVGAnimatedPath.h" > #include "SVGExternalResourcesRequired.h" > #include "SVGGeometryElement.h" > #include "SVGNames.h" >@@ -95,32 +97,30 @@ public: > > FloatRect getBBox(StyleUpdateStrategy = AllowStyleUpdate) final; > >- static const SVGPropertyInfo* dPropertyInfo(); >- > bool isAnimValObserved() const { return m_isAnimValObserved; } > > void animatedPropertyWillBeDeleted(); > > size_t approximateMemoryCost() const final; > >+ const SVGPathSegListValues& pathSegList() const { return m_pathSegList.currentValue(); } >+ RefPtr<SVGAnimatedPathSegList> pathSegListAnimated() { return m_pathSegList.animatedProperty(); } >+ > private: > SVGPathElement(const QualifiedName&, Document&); > >- bool isValid() const final { return SVGTests::isValid(); } >+ using AttributeOwnerProxy = SVGAttributeOwnerProxyImpl<SVGPathElement, SVGGeometryElement, SVGExternalResourcesRequired>; >+ static auto& attributeRegistry() { return AttributeOwnerProxy::attributeRegistry(); } >+ static bool isKnownAttribute(const QualifiedName& attributeName) { return AttributeOwnerProxy::isKnownAttribute(attributeName); } >+ static void registerAttributes(); > >- static bool isSupportedAttribute(const QualifiedName&); >+ const SVGAttributeOwnerProxy& attributeOwnerProxy() const final { return m_attributeOwnerProxy; } > void parseAttribute(const QualifiedName&, const AtomicString&) final; > void svgAttributeChanged(const QualifiedName&) final; >- bool supportsMarkers() const final { return true; } > >- // Custom 'd' property >- static void synchronizeD(SVGElement* contextElement); >- static Ref<SVGAnimatedProperty> lookupOrCreateDWrapper(SVGElement* contextElement); >- >- BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGPathElement) >- DECLARE_ANIMATED_NUMBER(PathLength, pathLength) >- DECLARE_ANIMATED_BOOLEAN_OVERRIDE(ExternalResourcesRequired, externalResourcesRequired) >- END_DECLARE_ANIMATED_PROPERTIES >+ bool isValid() const final { return SVGTests::isValid(); } >+ bool supportsMarkers() const final { return true; } >+ RefPtr<SVGAnimatedProperty> lookupOrCreateDWrapper(); > > RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final; > >@@ -132,8 +132,31 @@ private: > private: > SVGPathByteStream m_pathByteStream; > mutable std::optional<Path> m_cachedPath; >- mutable SVGSynchronizableAnimatedProperty<SVGPathSegListValues> m_pathSegList; >- bool m_isAnimValObserved; >+ bool m_isAnimValObserved { false }; >+ >+ class SVGAnimatedCustomPathSegListAttribute : public SVGAnimatedPathSegListAttribute { >+ public: >+ SVGAnimatedCustomPathSegListAttribute(SVGPathElement& element, const SVGAttributeOwnerProxy& attributeOwnerProxy) >+ : SVGAnimatedPathSegListAttribute(attributeOwnerProxy, PathSegUnalteredRole) >+ , m_element(element) >+ { >+ } >+ >+ SVGPathSegListValues& value(bool shouldBuildSegListValues = true) >+ { >+ if (shouldBuildSegListValues && m_property.isEmpty()) >+ buildSVGPathSegListValuesFromByteStream(m_element.m_pathByteStream, m_element, m_property, UnalteredParsing); >+ return m_property; >+ } >+ >+ private: >+ SVGPathElement& m_element; >+ }; >+ >+ using SVGAnimatedCustomPathSegListAttributeAccessor = SVGAnimatedAttributeAccessor<SVGPathElement, SVGAnimatedCustomPathSegListAttribute, AnimatedPath>; >+ >+ AttributeOwnerProxy m_attributeOwnerProxy { *this }; >+ SVGAnimatedCustomPathSegListAttribute m_pathSegList { *this, m_attributeOwnerProxy }; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/svg/SVGPathSegWithContext.h b/Source/WebCore/svg/SVGPathSegWithContext.h >index 4e395b9e2fa..573016ddbfa 100644 >--- a/Source/WebCore/svg/SVGPathSegWithContext.h >+++ b/Source/WebCore/svg/SVGPathSegWithContext.h >@@ -40,7 +40,7 @@ public: > case PathSegUndefinedRole: > return nullptr; > case PathSegUnalteredRole: >- return SVGAnimatedProperty::lookupWrapper<SVGPathElement, SVGAnimatedPathSegListPropertyTearOff>(m_element.get(), SVGPathElement::dPropertyInfo()); >+ return m_element->pathSegListAnimated(); > case PathSegNormalizedRole: > // FIXME: https://bugs.webkit.org/show_bug.cgi?id=15412 - Implement normalized path segment lists! > return nullptr;
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