WebKit Bugzilla
Attachment 346320 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 SVGTextContentElement
186751-37.patch (text/plain), 13.79 KB, created by
Said Abou-Hallawa
on 2018-08-01 17:43:56 PDT
(
hide
)
Description:
Remove SVG macros from SVGTextContentElement
Filename:
MIME Type:
Creator:
Said Abou-Hallawa
Created:
2018-08-01 17:43:56 PDT
Size:
13.79 KB
patch
obsolete
>diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 41f0c51f94a..b8516fb5e61 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,39 @@ >+2018-08-01 Said Abou-Hallawa <sabouhallawa@apple.com> >+ >+ [37] Remove the SVG elements' attributes macros >+ https://bugs.webkit.org/show_bug.cgi?id=186751 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Remove SVG macros from SVGTextContentElement. >+ >+ -- No need to include the attributes of SVGExternalResourcesRequired. >+ -- Move the custom textLength attribute handling to a superclass derived >+ from SVGAnimatedLengthAttribute. Override only the the methods that >+ need special handling. >+ >+ * svg/SVGTextContentElement.cpp: >+ (WebCore::SVGTextContentElement::SVGTextContentElement): >+ (WebCore::SVGTextContentElement::registerAttributes): >+ (WebCore::SVGTextContentElement::parseAttribute): >+ (WebCore::SVGTextContentElement::svgAttributeChanged): >+ (WebCore::SVGTextContentElement::textLengthPropertyInfo): Deleted. >+ (WebCore::SVGTextContentElement::synchronizeTextLength): Deleted. >+ (WebCore::SVGTextContentElement::lookupOrCreateTextLengthWrapper): Deleted. >+ (WebCore::SVGTextContentElement::textLengthAnimated): Deleted. >+ (WebCore::SVGTextContentElement::isSupportedAttribute): Deleted. >+ * svg/SVGTextContentElement.h: >+ (WebCore::SVGTextContentElement::attributeRegistry): >+ (WebCore::SVGTextContentElement::specifiedTextLength): >+ (WebCore::SVGTextContentElement::textLength const): >+ (WebCore::SVGTextContentElement::lengthAdjust const): >+ (WebCore::SVGTextContentElement::textLengthAnimated): >+ (WebCore::SVGTextContentElement::lengthAdjustAnimated): >+ (WebCore::SVGTextContentElement::isKnownAttribute): >+ (WebCore::SVGTextContentElement::SVGAnimatedCustomLengthAttribute::SVGAnimatedCustomLengthAttribute): >+ (WebCore::SVGTextContentElement::SVGAnimatedCustomLengthAttribute::synchronize): >+ (WebCore::SVGTextContentElement::SVGAnimatedCustomLengthAttribute::animatedProperty): >+ > 2018-08-01 Said Abou-Hallawa <sabouhallawa@apple.com> > > [36] Remove the SVG elements' attributes macros >diff --git a/Source/WebCore/svg/SVGTextContentElement.cpp b/Source/WebCore/svg/SVGTextContentElement.cpp >index 703b60141d1..644c006cfe1 100644 >--- a/Source/WebCore/svg/SVGTextContentElement.cpp >+++ b/Source/WebCore/svg/SVGTextContentElement.cpp >@@ -1,6 +1,7 @@ > /* > * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> > * Copyright (C) 2004, 2005, 2006, 2007, 2008 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 >@@ -42,67 +43,11 @@ namespace WebCore { > > WTF_MAKE_ISO_ALLOCATED_IMPL(SVGTextContentElement); > >-// Define custom animated property 'textLength'. >-const SVGPropertyInfo* SVGTextContentElement::textLengthPropertyInfo() >-{ >- static const SVGPropertyInfo* s_propertyInfo = nullptr; >- if (!s_propertyInfo) { >- s_propertyInfo = new SVGPropertyInfo(AnimatedLength, >- PropertyIsReadWrite, >- SVGNames::textLengthAttr, >- SVGNames::textLengthAttr->localName(), >- &SVGTextContentElement::synchronizeTextLength, >- &SVGTextContentElement::lookupOrCreateTextLengthWrapper); >- } >- return s_propertyInfo; >-} >- >-// Animated property definitions >-DEFINE_ANIMATED_ENUMERATION(SVGTextContentElement, SVGNames::lengthAdjustAttr, LengthAdjust, lengthAdjust, SVGLengthAdjustType) >-DEFINE_ANIMATED_BOOLEAN(SVGTextContentElement, SVGNames::externalResourcesRequiredAttr, ExternalResourcesRequired, externalResourcesRequired) >- >-BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGTextContentElement) >- REGISTER_LOCAL_ANIMATED_PROPERTY(textLength) >- REGISTER_LOCAL_ANIMATED_PROPERTY(lengthAdjust) >- REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) >- REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) >-END_REGISTER_ANIMATED_PROPERTIES >- > SVGTextContentElement::SVGTextContentElement(const QualifiedName& tagName, Document& document) > : SVGGraphicsElement(tagName, document) >- , m_textLength(LengthModeOther) >- , m_specifiedTextLength(LengthModeOther) >- , m_lengthAdjust(SVGLengthAdjustSpacing) >-{ >- registerAnimatedPropertiesForSVGTextContentElement(); >-} >- >-void SVGTextContentElement::synchronizeTextLength(SVGElement* contextElement) >+ , SVGExternalResourcesRequired(*this) > { >- ASSERT(contextElement); >- SVGTextContentElement& ownerType = downcast<SVGTextContentElement>(*contextElement); >- if (!ownerType.m_textLength.shouldSynchronize) >- return; >- AtomicString value(SVGPropertyTraits<SVGLengthValue>::toString(ownerType.m_specifiedTextLength)); >- ownerType.m_textLength.synchronize(&ownerType, textLengthPropertyInfo()->attributeName, value); >-} >- >-Ref<SVGAnimatedProperty> SVGTextContentElement::lookupOrCreateTextLengthWrapper(SVGElement* contextElement) >-{ >- ASSERT(contextElement); >- SVGTextContentElement& ownerType = downcast<SVGTextContentElement>(*contextElement); >- return SVGAnimatedProperty::lookupOrCreateWrapper<SVGTextContentElement, SVGAnimatedLength, SVGLengthValue> >- (&ownerType, textLengthPropertyInfo(), ownerType.m_textLength.value); >-} >- >-Ref<SVGAnimatedLength> SVGTextContentElement::textLengthAnimated() >-{ >- static NeverDestroyed<SVGLengthValue> defaultTextLength(LengthModeOther); >- if (m_specifiedTextLength == defaultTextLength) >- m_textLength.value.newValueSpecifiedUnits(LengthTypeNumber, getComputedTextLength()); >- >- m_textLength.shouldSynchronize = true; >- return static_reference_cast<SVGAnimatedLength>(lookupOrCreateTextLengthWrapper(this)); >+ registerAttributes(); > } > > unsigned SVGTextContentElement::getNumberOfChars() >@@ -193,18 +138,6 @@ ExceptionOr<void> SVGTextContentElement::selectSubString(unsigned charnum, unsig > return { }; > } > >-bool SVGTextContentElement::isSupportedAttribute(const QualifiedName& attrName) >-{ >- static const auto supportedAttributes = makeNeverDestroyed([] { >- HashSet<QualifiedName> set; >- SVGLangSpace::addSupportedAttributes(set); >- SVGExternalResourcesRequired::addSupportedAttributes(set); >- set.add({ SVGNames::lengthAdjustAttr.get(), SVGNames::textLengthAttr.get() }); >- return set; >- }()); >- return supportedAttributes.get().contains<SVGAttributeHashTranslator>(attrName); >-} >- > bool SVGTextContentElement::isPresentationAttribute(const QualifiedName& name) const > { > if (name.matches(XMLNames::spaceAttr)) >@@ -225,6 +158,15 @@ void SVGTextContentElement::collectStyleForPresentationAttribute(const Qualified > SVGGraphicsElement::collectStyleForPresentationAttribute(name, value, style); > } > >+void SVGTextContentElement::registerAttributes() >+{ >+ auto& registry = attributeRegistry(); >+ if (!registry.isEmpty()) >+ return; >+ registry.registerAttribute(SVGAnimatedCustomLengthAttributeAccessor::singleton<SVGNames::textLengthAttr, &SVGTextContentElement::m_textLength>()); >+ registry.registerAttribute<SVGNames::lengthAdjustAttr, SVGLengthAdjustType, &SVGTextContentElement::m_lengthAdjust>(); >+} >+ > void SVGTextContentElement::parseAttribute(const QualifiedName& name, const AtomicString& value) > { > SVGParsingError parseError = NoError; >@@ -232,9 +174,9 @@ void SVGTextContentElement::parseAttribute(const QualifiedName& name, const Atom > if (name == SVGNames::lengthAdjustAttr) { > auto propertyValue = SVGPropertyTraits<SVGLengthAdjustType>::fromString(value); > if (propertyValue > 0) >- setLengthAdjustBaseValue(propertyValue); >+ m_lengthAdjust.setValue(propertyValue); > } else if (name == SVGNames::textLengthAttr) >- m_textLength.value = SVGLengthValue::construct(LengthModeOther, value, parseError, ForbidNegativeLengths); >+ m_textLength.setValue(SVGLengthValue::construct(LengthModeOther, value, parseError, ForbidNegativeLengths)); > > reportAttributeParsingError(parseError, name, value); > >@@ -244,18 +186,19 @@ void SVGTextContentElement::parseAttribute(const QualifiedName& name, const Atom > > void SVGTextContentElement::svgAttributeChanged(const QualifiedName& attrName) > { >- if (!isSupportedAttribute(attrName)) { >- SVGGraphicsElement::svgAttributeChanged(attrName); >+ if (isKnownAttribute(attrName)) { >+ if (attrName == SVGNames::textLengthAttr) >+ m_specifiedTextLength = m_textLength.value(); >+ >+ if (auto renderer = this->renderer()) { >+ InstanceInvalidationGuard guard(*this); >+ RenderSVGResource::markForLayoutAndParentResourceInvalidation(*renderer); >+ } > return; > } > >- if (attrName == SVGNames::textLengthAttr) >- m_specifiedTextLength = m_textLength.value; >- >- if (auto renderer = this->renderer()) { >- InstanceInvalidationGuard guard(*this); >- RenderSVGResource::markForLayoutAndParentResourceInvalidation(*renderer); >- } >+ SVGGraphicsElement::svgAttributeChanged(attrName); >+ SVGExternalResourcesRequired::svgAttributeChanged(attrName); > } > > bool SVGTextContentElement::selfHasRelativeLengths() const >diff --git a/Source/WebCore/svg/SVGTextContentElement.h b/Source/WebCore/svg/SVGTextContentElement.h >index d2f3fb6c0e5..8c6652bc9f4 100644 >--- a/Source/WebCore/svg/SVGTextContentElement.h >+++ b/Source/WebCore/svg/SVGTextContentElement.h >@@ -1,6 +1,7 @@ > /* > * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> > * Copyright (C) 2004, 2005, 2006, 2008 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 >@@ -85,11 +86,15 @@ public: > > static SVGTextContentElement* elementFromRenderer(RenderObject*); > >- // textLength is not declared using the standard DECLARE_ANIMATED_LENGTH macro >- // as its getter needs special handling (return getComputedTextLength(), instead of m_textLength). >- SVGLengthValue& specifiedTextLength() { return m_specifiedTextLength; } >- Ref<SVGAnimatedLength> textLengthAnimated(); >- static const SVGPropertyInfo* textLengthPropertyInfo(); >+ using AttributeOwnerProxy = SVGAttributeOwnerProxyImpl<SVGTextContentElement, SVGGraphicsElement, SVGExternalResourcesRequired>; >+ static AttributeOwnerProxy::AttributeRegistry& attributeRegistry() { return AttributeOwnerProxy::attributeRegistry(); } >+ >+ const SVGLengthValue& specifiedTextLength() { return m_specifiedTextLength; } >+ const SVGLengthValue& textLength() const { return m_textLength.currentValue(); } >+ const SVGLengthAdjustType& lengthAdjust() const { return m_lengthAdjust.currentValue(); } >+ >+ RefPtr<SVGAnimatedLength> textLengthAnimated() { return m_textLength.animatedProperty(); } >+ RefPtr<SVGAnimatedEnumeration> lengthAdjustAnimated() { return m_lengthAdjust.animatedProperty(); } > > protected: > SVGTextContentElement(const QualifiedName&, Document&); >@@ -105,19 +110,47 @@ protected: > > private: > bool isTextContent() const final { return true; } >+ const SVGAttributeOwnerProxy& attributeOwnerProxy() const override { return m_attributeOwnerProxy; } >+ >+ static void registerAttributes(); >+ static bool isKnownAttribute(const QualifiedName& attributeName) { return AttributeOwnerProxy::isKnownAttribute(attributeName); } >+ >+ class SVGAnimatedCustomLengthAttribute : public SVGAnimatedLengthAttribute { >+ public: >+ using SVGAnimatedLengthAttribute::operator=; >+ >+ SVGAnimatedCustomLengthAttribute(SVGTextContentElement& element, SVGAttributeOwnerProxy& attributeOwnerProxy, SVGLengthMode lengthMode) >+ : SVGAnimatedLengthAttribute(attributeOwnerProxy, lengthMode) >+ , m_element(element) >+ { >+ } >+ >+ void synchronize(Element&, const QualifiedName& attributeName) >+ { >+ if (!shouldSynchronize()) >+ return; >+ String string(SVGPropertyTraits<SVGLengthValue>::toString(m_element.m_specifiedTextLength)); >+ static_cast<Element&>(m_element).setSynchronizedLazyAttribute(attributeName, string); >+ } >+ >+ RefPtr<SVGAnimatedLength> animatedProperty() >+ { >+ static NeverDestroyed<SVGLengthValue> defaultTextLength(LengthModeOther); >+ if (m_element.m_specifiedTextLength == defaultTextLength) >+ m_element.m_textLength.value().newValueSpecifiedUnits(LengthTypeNumber, m_element.getComputedTextLength()); >+ >+ setShouldSynchronize(true); >+ return static_reference_cast<SVGAnimatedLength>(m_attributeOwnerProxy.lookupOrCreateAnimatedProperty(*this).releaseNonNull()); >+ } >+ >+ private: >+ SVGTextContentElement& m_element; >+ }; > >- static bool isSupportedAttribute(const QualifiedName&); >- >- // Custom 'textLength' property >- static void synchronizeTextLength(SVGElement* contextElement); >- static Ref<SVGAnimatedProperty> lookupOrCreateTextLengthWrapper(SVGElement* contextElement); >- mutable SVGSynchronizableAnimatedProperty<SVGLengthValue> m_textLength; >- SVGLengthValue m_specifiedTextLength; >- >- BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGTextContentElement) >- DECLARE_ANIMATED_ENUMERATION(LengthAdjust, lengthAdjust, SVGLengthAdjustType) >- DECLARE_ANIMATED_BOOLEAN_OVERRIDE(ExternalResourcesRequired, externalResourcesRequired) >- END_DECLARE_ANIMATED_PROPERTIES >+ AttributeOwnerProxy m_attributeOwnerProxy { *this }; >+ SVGAnimatedCustomLengthAttribute m_textLength { *this, m_attributeOwnerProxy, LengthModeOther }; >+ SVGAnimatedEnumerationAttribute<SVGLengthAdjustType> m_lengthAdjust { m_attributeOwnerProxy, SVGLengthAdjustSpacing }; >+ SVGLengthValue m_specifiedTextLength { LengthModeOther }; > }; > > } // namespace WebCore
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