WebKit Bugzilla
Attachment 346528 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 SVGUseElement
186751-77.patch (text/plain), 13.34 KB, created by
Said Abou-Hallawa
on 2018-08-03 12:41:52 PDT
(
hide
)
Description:
Remove SVG macros from SVGUseElement
Filename:
MIME Type:
Creator:
Said Abou-Hallawa
Created:
2018-08-03 12:41:52 PDT
Size:
13.34 KB
patch
obsolete
>diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 66c2c1610bb..a9166335924 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,22 @@ >+2018-08-02 Said Abou-Hallawa <sabouhallawa@apple.com> >+ >+ [77] Remove the SVG elements' attributes macros >+ https://bugs.webkit.org/show_bug.cgi?id=186751 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Remove SVG macros from SVGUseElement. >+ >+ * svg/SVGUseElement.cpp: >+ (WebCore::SVGUseElement::SVGUseElement): >+ (WebCore::SVGUseElement::registerAttributes): >+ (WebCore::SVGUseElement::parseAttribute): >+ (WebCore::SVGUseElement::insertedIntoAncestor): >+ (WebCore::SVGUseElement::transferSizeAttributesToTargetClone const): >+ (WebCore::SVGUseElement::svgAttributeChanged): >+ (WebCore::SVGUseElement::notifyFinished): >+ * svg/SVGUseElement.h: >+ > 2018-08-02 Said Abou-Hallawa <sabouhallawa@apple.com> > > [76] Remove the SVG elements' attributes macros >diff --git a/Source/WebCore/svg/SVGUseElement.cpp b/Source/WebCore/svg/SVGUseElement.cpp >index 072c5908ee5..19bd6186fb0 100644 >--- a/Source/WebCore/svg/SVGUseElement.cpp >+++ b/Source/WebCore/svg/SVGUseElement.cpp >@@ -5,7 +5,7 @@ > * Copyright (C) 2011 Torch Mobile (Beijing) Co. Ltd. All rights reserved. > * Copyright (C) 2012 University of Szeged > * Copyright (C) 2012 Renata Hodovan <reni@webkit.org> >- * Copyright (C) 2015-2017 Apple Inc. All rights reserved. >+ * Copyright (C) 2015-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 >@@ -46,34 +46,15 @@ namespace WebCore { > > WTF_MAKE_ISO_ALLOCATED_IMPL(SVGUseElement); > >-DEFINE_ANIMATED_LENGTH(SVGUseElement, SVGNames::xAttr, X, x) >-DEFINE_ANIMATED_LENGTH(SVGUseElement, SVGNames::yAttr, Y, y) >-DEFINE_ANIMATED_LENGTH(SVGUseElement, SVGNames::widthAttr, Width, width) >-DEFINE_ANIMATED_LENGTH(SVGUseElement, SVGNames::heightAttr, Height, height) >-DEFINE_ANIMATED_STRING(SVGUseElement, XLinkNames::hrefAttr, Href, href) >-DEFINE_ANIMATED_BOOLEAN(SVGUseElement, SVGNames::externalResourcesRequiredAttr, ExternalResourcesRequired, externalResourcesRequired) >- >-BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGUseElement) >- REGISTER_LOCAL_ANIMATED_PROPERTY(x) >- REGISTER_LOCAL_ANIMATED_PROPERTY(y) >- REGISTER_LOCAL_ANIMATED_PROPERTY(width) >- REGISTER_LOCAL_ANIMATED_PROPERTY(height) >- REGISTER_LOCAL_ANIMATED_PROPERTY(href) >- REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) >- REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) >-END_REGISTER_ANIMATED_PROPERTIES >- > inline SVGUseElement::SVGUseElement(const QualifiedName& tagName, Document& document) > : SVGGraphicsElement(tagName, document) >- , m_x(LengthModeWidth) >- , m_y(LengthModeHeight) >- , m_width(LengthModeWidth) >- , m_height(LengthModeHeight) >+ , SVGExternalResourcesRequired(*this) >+ , SVGURIReference(*this) > , m_svgLoadEventTimer(*this, &SVGElement::svgLoadEventTimerFired) > { > ASSERT(hasCustomStyleResolveCallbacks()); > ASSERT(hasTagName(SVGNames::useTag)); >- registerAnimatedPropertiesForSVGUseElement(); >+ registerAttributes(); > } > > Ref<SVGUseElement> SVGUseElement::create(const QualifiedName& tagName, Document& document) >@@ -87,18 +68,29 @@ SVGUseElement::~SVGUseElement() > m_externalDocument->removeClient(*this); > } > >+void SVGUseElement::registerAttributes() >+{ >+ auto& registry = attributeRegistry(); >+ if (!registry.isEmpty()) >+ return; >+ registry.registerAttribute<SVGNames::xAttr, &SVGUseElement::m_x>(); >+ registry.registerAttribute<SVGNames::yAttr, &SVGUseElement::m_y>(); >+ registry.registerAttribute<SVGNames::widthAttr, &SVGUseElement::m_width>(); >+ registry.registerAttribute<SVGNames::heightAttr, &SVGUseElement::m_height>(); >+} >+ > void SVGUseElement::parseAttribute(const QualifiedName& name, const AtomicString& value) > { > SVGParsingError parseError = NoError; > > if (name == SVGNames::xAttr) >- setXBaseValue(SVGLengthValue::construct(LengthModeWidth, value, parseError)); >+ m_x.setValue(SVGLengthValue::construct(LengthModeWidth, value, parseError)); > else if (name == SVGNames::yAttr) >- setYBaseValue(SVGLengthValue::construct(LengthModeHeight, value, parseError)); >+ m_y.setValue(SVGLengthValue::construct(LengthModeHeight, value, parseError)); > else if (name == SVGNames::widthAttr) >- setWidthBaseValue(SVGLengthValue::construct(LengthModeWidth, value, parseError, ForbidNegativeLengths)); >+ m_width.setValue(SVGLengthValue::construct(LengthModeWidth, value, parseError, ForbidNegativeLengths)); > else if (name == SVGNames::heightAttr) >- setHeightBaseValue(SVGLengthValue::construct(LengthModeHeight, value, parseError, ForbidNegativeLengths)); >+ m_height.setValue(SVGLengthValue::construct(LengthModeHeight, value, parseError, ForbidNegativeLengths)); > > reportAttributeParsingError(parseError, name, value); > >@@ -113,7 +105,7 @@ Node::InsertedIntoAncestorResult SVGUseElement::insertedIntoAncestor(InsertionTy > if (insertionType.connectedToDocument) { > if (m_shadowTreeNeedsUpdate) > document().addSVGUseElement(*this); >- SVGExternalResourcesRequired::insertedIntoDocument(this); >+ SVGExternalResourcesRequired::insertedIntoDocument(); > invalidateShadowTree(); > // FIXME: Move back the call to updateExternalDocument() here once notifyFinished is made always async. > return InsertedIntoAncestorResult::NeedsPostInsertionCallback; >@@ -156,14 +148,14 @@ void SVGUseElement::transferSizeAttributesToTargetClone(SVGElement& shadowElemen > // If attributes width and/or height are provided on the 'use' element, then these attributes > // will be transferred to the generated 'svg'. If attributes width and/or height are not specified, > // the generated 'svg' element will use values of 100% for these attributes. >- shadowElement.setAttribute(SVGNames::widthAttr, (widthIsValid() && width().valueInSpecifiedUnits()) ? AtomicString(width().valueAsString()) : "100%"); >- shadowElement.setAttribute(SVGNames::heightAttr, (heightIsValid() && height().valueInSpecifiedUnits()) ? AtomicString(height().valueAsString()) : "100%"); >+ shadowElement.setAttribute(SVGNames::widthAttr, width().valueInSpecifiedUnits() ? AtomicString(width().valueAsString()) : "100%"); >+ shadowElement.setAttribute(SVGNames::heightAttr, height().valueInSpecifiedUnits() ? AtomicString(height().valueAsString()) : "100%"); > } else if (is<SVGSVGElement>(shadowElement)) { > // Spec (<use> on <svg>): If attributes width and/or height are provided on the 'use' element, then these > // values will override the corresponding attributes on the 'svg' in the generated tree. > auto correspondingElement = makeRefPtr(shadowElement.correspondingElement()); >- shadowElement.setAttribute(SVGNames::widthAttr, (widthIsValid() && width().valueInSpecifiedUnits()) ? AtomicString(width().valueAsString()) : (correspondingElement ? correspondingElement->getAttribute(SVGNames::widthAttr) : nullAtom())); >- shadowElement.setAttribute(SVGNames::heightAttr, (heightIsValid() && height().valueInSpecifiedUnits()) ? AtomicString(height().valueAsString()) : (correspondingElement ? correspondingElement->getAttribute(SVGNames::heightAttr) : nullAtom())); >+ shadowElement.setAttribute(SVGNames::widthAttr, width().valueInSpecifiedUnits()) ? AtomicString(width().valueAsString() : (correspondingElement ? correspondingElement->getAttribute(SVGNames::widthAttr) : nullAtom())); >+ shadowElement.setAttribute(SVGNames::heightAttr, height().valueInSpecifiedUnits()) ? AtomicString(height().valueAsString() : (correspondingElement ? correspondingElement->getAttribute(SVGNames::heightAttr) : nullAtom())); > } > } > >@@ -171,7 +163,7 @@ void SVGUseElement::svgAttributeChanged(const QualifiedName& attrName) > { > InstanceInvalidationGuard guard(*this); > >- if (attrName == SVGNames::xAttr || attrName == SVGNames::yAttr || attrName == SVGNames::widthAttr || attrName == SVGNames::heightAttr) { >+ if (isKnownAttribute(attrName)) { > updateRelativeLengthsInformation(); > if (attrName == SVGNames::widthAttr || attrName == SVGNames::heightAttr) { > // FIXME: It's unnecessarily inefficient to update both width and height each time either is changed. >@@ -183,21 +175,17 @@ void SVGUseElement::svgAttributeChanged(const QualifiedName& attrName) > return; > } > >- if (SVGExternalResourcesRequired::handleAttributeChange(this, attrName)) >- return; >- > if (SVGURIReference::isKnownAttribute(attrName)) { > updateExternalDocument(); > invalidateShadowTree(); > return; > } > >- if (SVGLangSpace::isKnownAttribute(attrName) || SVGExternalResourcesRequired::isKnownAttribute(attrName)) { >+ if (SVGLangSpace::isKnownAttribute(attrName) || SVGExternalResourcesRequired::isKnownAttribute(attrName)) > invalidateShadowTree(); >- return; >- } > > SVGGraphicsElement::svgAttributeChanged(attrName); >+ SVGExternalResourcesRequired::svgAttributeChanged(attrName); > } > > static HashSet<AtomicString> createAllowedElementSet() >@@ -572,7 +560,7 @@ void SVGUseElement::notifyFinished(CachedResource& resource) > if (resource.errorOccurred()) > dispatchEvent(Event::create(eventNames().errorEvent, false, false)); > else if (!resource.wasCanceled()) >- SVGExternalResourcesRequired::dispatchLoadEvent(this); >+ SVGExternalResourcesRequired::dispatchLoadEvent(); > } > > void SVGUseElement::finishParsingChildren() >diff --git a/Source/WebCore/svg/SVGUseElement.h b/Source/WebCore/svg/SVGUseElement.h >index 65060bb2874..a9d7902acf3 100644 >--- a/Source/WebCore/svg/SVGUseElement.h >+++ b/Source/WebCore/svg/SVGUseElement.h >@@ -1,7 +1,7 @@ > /* > * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> > * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> >- * Copyright (C) 2015 Apple Inc. All rights reserved. >+ * Copyright (C) 2015-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 >@@ -36,16 +36,6 @@ class SVGGElement; > > class SVGUseElement final : public SVGGraphicsElement, public SVGExternalResourcesRequired, public SVGURIReference, private CachedSVGDocumentClient { > WTF_MAKE_ISO_ALLOCATED(SVGUseElement); >- >- BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGUseElement) >- DECLARE_ANIMATED_LENGTH(X, x) >- DECLARE_ANIMATED_LENGTH(Y, y) >- DECLARE_ANIMATED_LENGTH(Width, width) >- DECLARE_ANIMATED_LENGTH(Height, height) >- DECLARE_ANIMATED_STRING_OVERRIDE(Href, href) >- DECLARE_ANIMATED_BOOLEAN_OVERRIDE(ExternalResourcesRequired, externalResourcesRequired) >- END_DECLARE_ANIMATED_PROPERTIES >- > public: > static Ref<SVGUseElement> create(const QualifiedName&, Document&); > virtual ~SVGUseElement(); >@@ -56,6 +46,16 @@ public: > > RenderElement* rendererClipChild() const; > >+ const SVGLengthValue& x() const { return m_x.currentValue(); } >+ const SVGLengthValue& y() const { return m_y.currentValue(); } >+ const SVGLengthValue& width() const { return m_width.currentValue(); } >+ const SVGLengthValue& height() const { return m_height.currentValue(); } >+ >+ RefPtr<SVGAnimatedLength> xAnimated() { return m_x.animatedProperty(); } >+ RefPtr<SVGAnimatedLength> yAnimated() { return m_y.animatedProperty(); } >+ RefPtr<SVGAnimatedLength> widthAnimated() { return m_width.animatedProperty(); } >+ RefPtr<SVGAnimatedLength> heightAnimated() { return m_height.animatedProperty(); } >+ > private: > SVGUseElement(const QualifiedName&, Document&); > >@@ -64,8 +64,16 @@ private: > void didFinishInsertingNode() final; > void removedFromAncestor(RemovalType, ContainerNode&) override; > void buildPendingResource() override; >+ >+ using AttributeOwnerProxy = SVGAttributeOwnerProxyImpl<SVGUseElement, SVGGraphicsElement, SVGExternalResourcesRequired, SVGURIReference>; >+ static AttributeOwnerProxy::AttributeRegistry& attributeRegistry() { return AttributeOwnerProxy::attributeRegistry(); } >+ static bool isKnownAttribute(const QualifiedName& attributeName) { return AttributeOwnerProxy::isKnownAttribute(attributeName); } >+ static void registerAttributes(); >+ >+ const SVGAttributeOwnerProxy& attributeOwnerProxy() const final { return m_attributeOwnerProxy; } > void parseAttribute(const QualifiedName&, const AtomicString&) override; > void svgAttributeChanged(const QualifiedName&) override; >+ > RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) override; > Path toClipPath() override; > bool haveLoadedRequiredResources() override; >@@ -92,6 +100,12 @@ private: > void clearShadowTree(); > void invalidateDependentShadowTrees(); > >+ AttributeOwnerProxy m_attributeOwnerProxy { *this }; >+ SVGAnimatedLengthAttribute m_x { m_attributeOwnerProxy, LengthModeWidth }; >+ SVGAnimatedLengthAttribute m_y { m_attributeOwnerProxy, LengthModeHeight }; >+ SVGAnimatedLengthAttribute m_width { m_attributeOwnerProxy, LengthModeWidth }; >+ SVGAnimatedLengthAttribute m_height { m_attributeOwnerProxy, LengthModeHeight }; >+ > bool m_haveFiredLoadEvent { false }; > bool m_shadowTreeNeedsUpdate { true }; > CachedResourceHandle<CachedSVGDocument> m_externalDocument;
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