WebKit Bugzilla
Attachment 346533 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 SVGSVGElement
186751-82.patch (text/plain), 17.17 KB, created by
Said Abou-Hallawa
on 2018-08-03 12:44:54 PDT
(
hide
)
Description:
Remove SVG macros from SVGSVGElement
Filename:
MIME Type:
Creator:
Said Abou-Hallawa
Created:
2018-08-03 12:44:54 PDT
Size:
17.17 KB
patch
obsolete
>diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 65b75124891..fc1ef0f2e62 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,28 @@ >+2018-08-02 Said Abou-Hallawa <sabouhallawa@apple.com> >+ >+ [82] Remove the SVG elements' attributes macros >+ https://bugs.webkit.org/show_bug.cgi?id=186751 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Remove SVG macros from SVGSVGElement. >+ >+ * svg/SVGSVGElement.cpp: >+ (WebCore::SVGSVGElement::SVGSVGElement): >+ (WebCore::SVGSVGElement::registerAttributes): >+ (WebCore::SVGSVGElement::parseAttribute): >+ (WebCore::SVGSVGElement::svgAttributeChanged): >+ (WebCore::SVGSVGElement::viewBoxToViewTransform const): >+ (WebCore::SVGSVGElement::resetScrollAnchor): >+ (WebCore::SVGSVGElement::inheritViewAttributes): >+ * svg/SVGSVGElement.h: >+ (WebCore::SVGSVGElement::useCurrentView const): Deleted. >+ (WebCore::SVGSVGElement::currentTranslateValue): Deleted. >+ (WebCore::SVGSVGElement::zoomAndPan const): Deleted. >+ (WebCore::SVGSVGElement::setZoomAndPan): Deleted. >+ (WebCore::SVGSVGElement::timeContainer): Deleted. >+ (WebCore::SVGSVGElement::hasEmptyViewBox const): Deleted. >+ > 2018-08-02 Said Abou-Hallawa <sabouhallawa@apple.com> > > [81] Remove the SVG elements' attributes macros >diff --git a/Source/WebCore/svg/SVGSVGElement.cpp b/Source/WebCore/svg/SVGSVGElement.cpp >index c5f0af57487..e9f245dfab4 100644 >--- a/Source/WebCore/svg/SVGSVGElement.cpp >+++ b/Source/WebCore/svg/SVGSVGElement.cpp >@@ -1,7 +1,7 @@ > /* > * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> > * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Rob Buis <buis@kde.org> >- * Copyright (C) 2007-2017 Apple Inc. All rights reserved. >+ * Copyright (C) 2007-2018 Apple Inc. All rights reserved. > * Copyright (C) 2014 Adobe Systems Incorporated. All rights reserved. > * > * This library is free software; you can redistribute it and/or >@@ -52,36 +52,15 @@ namespace WebCore { > > WTF_MAKE_ISO_ALLOCATED_IMPL(SVGSVGElement); > >-// Animated property definitions >-DEFINE_ANIMATED_LENGTH(SVGSVGElement, SVGNames::xAttr, X, x) >-DEFINE_ANIMATED_LENGTH(SVGSVGElement, SVGNames::yAttr, Y, y) >-DEFINE_ANIMATED_LENGTH(SVGSVGElement, SVGNames::widthAttr, Width, width) >-DEFINE_ANIMATED_LENGTH(SVGSVGElement, SVGNames::heightAttr, Height, height) >-DEFINE_ANIMATED_BOOLEAN(SVGSVGElement, SVGNames::externalResourcesRequiredAttr, ExternalResourcesRequired, externalResourcesRequired) >-DEFINE_ANIMATED_PRESERVEASPECTRATIO(SVGSVGElement, SVGNames::preserveAspectRatioAttr, PreserveAspectRatio, preserveAspectRatio) >-DEFINE_ANIMATED_RECT(SVGSVGElement, SVGNames::viewBoxAttr, ViewBox, viewBox) >- >-BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGSVGElement) >- REGISTER_LOCAL_ANIMATED_PROPERTY(x) >- REGISTER_LOCAL_ANIMATED_PROPERTY(y) >- REGISTER_LOCAL_ANIMATED_PROPERTY(width) >- REGISTER_LOCAL_ANIMATED_PROPERTY(height) >- REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) >- REGISTER_LOCAL_ANIMATED_PROPERTY(viewBox) >- REGISTER_LOCAL_ANIMATED_PROPERTY(preserveAspectRatio) >- REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) >-END_REGISTER_ANIMATED_PROPERTIES >- > inline SVGSVGElement::SVGSVGElement(const QualifiedName& tagName, Document& document) > : SVGGraphicsElement(tagName, document) >- , m_x(LengthModeWidth) >- , m_y(LengthModeHeight) >- , m_width(LengthModeWidth, "100%"_s) >- , m_height(LengthModeHeight, "100%"_s) >+ , SVGExternalResourcesRequired(*this) >+ , SVGFitToViewBox(*this) >+ , SVGZoomAndPan(*this) > , m_timeContainer(SMILTimeContainer::create(*this)) > { > ASSERT(hasTagName(SVGNames::svgTag)); >- registerAnimatedPropertiesForSVGSVGElement(); >+ registerAttributes(); > document.registerForDocumentSuspensionCallbacks(this); > } > >@@ -214,6 +193,17 @@ void SVGSVGElement::updateCurrentTranslate() > document().renderView()->repaint(); > } > >+void SVGSVGElement::registerAttributes() >+{ >+ auto& registry = attributeRegistry(); >+ if (!registry.isEmpty()) >+ return; >+ registry.registerAttribute<SVGNames::xAttr, &SVGSVGElement::m_x>(); >+ registry.registerAttribute<SVGNames::yAttr, &SVGSVGElement::m_y>(); >+ registry.registerAttribute<SVGNames::widthAttr, &SVGSVGElement::m_width>(); >+ registry.registerAttribute<SVGNames::heightAttr, &SVGSVGElement::m_height>(); >+} >+ > void SVGSVGElement::parseAttribute(const QualifiedName& name, const AtomicString& value) > { > if (!nearestViewportElement()) { >@@ -252,9 +242,9 @@ void SVGSVGElement::parseAttribute(const QualifiedName& name, const AtomicString > 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) { > auto length = SVGLengthValue::construct(LengthModeWidth, value, parseError, ForbidNegativeLengths); > if (parseError != NoError || value.isEmpty()) { >@@ -262,7 +252,7 @@ void SVGSVGElement::parseAttribute(const QualifiedName& name, const AtomicString > // Not sure it's correct for the empty string or for something that can't be parsed. > length = SVGLengthValue(LengthModeWidth, "100%"_s); > } >- setWidthBaseValue(length); >+ m_width.setValue(length); > } else if (name == SVGNames::heightAttr) { > auto length = SVGLengthValue::construct(LengthModeHeight, value, parseError, ForbidNegativeLengths); > if (parseError != NoError || value.isEmpty()) { >@@ -270,43 +260,32 @@ void SVGSVGElement::parseAttribute(const QualifiedName& name, const AtomicString > // Not sure it's correct for the empty string or for something that can't be parsed. > length = SVGLengthValue(LengthModeHeight, "100%"_s); > } >- setHeightBaseValue(length); >+ m_height.setValue(length); > } > > reportAttributeParsingError(parseError, name, value); > >- SVGExternalResourcesRequired::parseAttribute(name, value); >- SVGFitToViewBox::parseAttribute(this, name, value); >- SVGZoomAndPan::parseAttribute(*this, name, value); > SVGGraphicsElement::parseAttribute(name, value); >+ SVGExternalResourcesRequired::parseAttribute(name, value); >+ SVGFitToViewBox::parseAttribute(name, value); >+ SVGZoomAndPan::parseAttribute(name, value); > } > > void SVGSVGElement::svgAttributeChanged(const QualifiedName& attrName) > { >- bool updateRelativeLengthsOrViewBox = false; >- if (attrName == SVGNames::widthAttr || attrName == SVGNames::heightAttr || attrName == SVGNames::xAttr || attrName == SVGNames::yAttr) { >+ if (isKnownAttribute(attrName)) { >+ InstanceInvalidationGuard guard(*this); > invalidateSVGPresentationAttributeStyle(); >- updateRelativeLengthsOrViewBox = true; >- } >- >- if (SVGFitToViewBox::isKnownAttribute(attrName)) { >- updateRelativeLengthsOrViewBox = true; >- if (auto* renderer = this->renderer()) >- renderer->setNeedsTransformUpdate(); >- } >- >- InstanceInvalidationGuard guard(*this); > >- if (updateRelativeLengthsOrViewBox >- || SVGLangSpace::isKnownAttribute(attrName) >- || SVGExternalResourcesRequired::isKnownAttribute(attrName) >- || SVGZoomAndPan::isKnownAttribute(attrName)) { > if (auto renderer = this->renderer()) > RenderSVGResource::markForLayoutAndParentResourceInvalidation(*renderer); > return; > } > > SVGGraphicsElement::svgAttributeChanged(attrName); >+ SVGExternalResourcesRequired::svgAttributeChanged(attrName); >+ SVGFitToViewBox::svgAttributeChanged(attrName); >+ SVGZoomAndPan::svgAttributeChanged(attrName); > } > > unsigned SVGSVGElement::suspendRedraw(unsigned) >@@ -634,7 +613,7 @@ AffineTransform SVGSVGElement::viewBoxToViewTransform(float viewWidth, float vie > return SVGFitToViewBox::viewBoxToViewTransform(currentViewBoxRect(), preserveAspectRatio(), viewWidth, viewHeight); > > AffineTransform transform = SVGFitToViewBox::viewBoxToViewTransform(currentViewBoxRect(), m_viewSpec->preserveAspectRatio(), viewWidth, viewHeight); >- m_viewSpec->transformBaseValue().concatenate(transform); >+ m_viewSpec->transformValue().concatenate(transform); > return transform; > } > >@@ -716,9 +695,9 @@ void SVGSVGElement::resetScrollAnchor() > if (!m_currentViewFragmentIdentifier.isEmpty()) { > if (auto* rootElement = findRootAnchor(m_currentViewFragmentIdentifier)) { > SVGViewSpec& view = rootElement->currentView(); >- view.setViewBoxBaseValue(viewBox()); >- view.setPreserveAspectRatioBaseValue(preserveAspectRatioBaseValue()); >- view.setZoomAndPanBaseValue(zoomAndPan()); >+ view.setViewBox(viewBox()); >+ view.setPreserveAspectRatio(preserveAspectRatio()); >+ view.setZoomAndPan(zoomAndPan()); > m_currentViewFragmentIdentifier = { }; > } > } >@@ -734,19 +713,19 @@ void SVGSVGElement::inheritViewAttributes(const SVGViewElement& viewElement) > m_useCurrentView = true; > > if (viewElement.hasAttribute(SVGNames::viewBoxAttr)) >- view.setViewBoxBaseValue(viewElement.viewBox()); >+ view.setViewBox(viewElement.viewBox()); > else >- view.setViewBoxBaseValue(viewBox()); >+ view.setViewBox(viewBox()); > > if (viewElement.hasAttribute(SVGNames::preserveAspectRatioAttr)) >- view.setPreserveAspectRatioBaseValue(viewElement.preserveAspectRatioBaseValue()); >+ view.setPreserveAspectRatio(viewElement.preserveAspectRatioBaseValue()); > else >- view.setPreserveAspectRatioBaseValue(preserveAspectRatioBaseValue()); >+ view.setPreserveAspectRatio(preserveAspectRatioBaseValue()); > > if (viewElement.hasAttribute(SVGNames::zoomAndPanAttr)) >- view.setZoomAndPanBaseValue(viewElement.zoomAndPan()); >+ view.setZoomAndPan(viewElement.zoomAndPan()); > else >- view.setZoomAndPanBaseValue(zoomAndPan()); >+ view.setZoomAndPan(zoomAndPan()); > } > > void SVGSVGElement::prepareForDocumentSuspension() >diff --git a/Source/WebCore/svg/SVGSVGElement.h b/Source/WebCore/svg/SVGSVGElement.h >index 2c8f1d80bc0..b39088a94cc 100644 >--- a/Source/WebCore/svg/SVGSVGElement.h >+++ b/Source/WebCore/svg/SVGSVGElement.h >@@ -1,7 +1,7 @@ > /* > * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> > * Copyright (C) 2004, 2005, 2006, 2007, 2010 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 >@@ -44,17 +44,6 @@ class SVGViewSpec; > > class SVGSVGElement final : public SVGGraphicsElement, public SVGExternalResourcesRequired, public SVGFitToViewBox, public SVGZoomAndPan { > WTF_MAKE_ISO_ALLOCATED(SVGSVGElement); >- >- BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGSVGElement) >- DECLARE_ANIMATED_LENGTH(X, x) >- DECLARE_ANIMATED_LENGTH(Y, y) >- DECLARE_ANIMATED_LENGTH(Width, width) >- DECLARE_ANIMATED_LENGTH(Height, height) >- DECLARE_ANIMATED_BOOLEAN_OVERRIDE(ExternalResourcesRequired, externalResourcesRequired) >- DECLARE_ANIMATED_RECT(ViewBox, viewBox) >- DECLARE_ANIMATED_PRESERVEASPECTRATIO(PreserveAspectRatio, preserveAspectRatio) >- END_DECLARE_ANIMATED_PROPERTIES >- > public: // DOM > const AtomicString& contentScriptType() const; > void setContentScriptType(const AtomicString&); >@@ -69,14 +58,14 @@ public: // DOM > float screenPixelToMillimeterX() const; > float screenPixelToMillimeterY() const; > >- bool useCurrentView() const; >+ bool useCurrentView() const { return m_useCurrentView; } > SVGViewSpec& currentView(); > > float currentScale() const; > void setCurrentScale(float); > > Ref<SVGPoint> currentTranslate(); >- FloatPoint currentTranslateValue(); >+ FloatPoint currentTranslateValue() { return m_currentTranslate; } > > unsigned suspendRedraw(unsigned maxWaitMilliseconds); > void unsuspendRedraw(unsigned suspendHandleId); >@@ -108,9 +97,6 @@ public: // DOM > > Element* getElementById(const AtomicString&); > >- SVGZoomAndPanType zoomAndPan() const; >- void setZoomAndPan(unsigned short); >- > public: > static Ref<SVGSVGElement> create(const QualifiedName&, Document&); > static Ref<SVGSVGElement> create(Document&); >@@ -120,7 +106,7 @@ public: > using SVGGraphicsElement::ref; > using SVGGraphicsElement::deref; > >- SMILTimeContainer& timeContainer(); >+ SMILTimeContainer& timeContainer() { return m_timeContainer.get(); } > > void setCurrentTranslate(const FloatPoint&); // Used to pan. > void updateCurrentTranslate(); // Used from DOM bindings to create an SVGStaticPropertyTearOff for currentTranslate. >@@ -133,26 +119,42 @@ public: > FloatSize currentViewportSize() const; > FloatRect currentViewBoxRect() const; > >- bool hasEmptyViewBox() const; > AffineTransform viewBoxToViewTransform(float viewWidth, float viewHeight) 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: > SVGSVGElement(const QualifiedName&, Document&); > virtual ~SVGSVGElement(); > >- bool isValid() const override; >- void didMoveToNewDocument(Document& oldDocument, Document& newDocument) override; >+ using AttributeOwnerProxy = SVGAttributeOwnerProxyImpl<SVGSVGElement, SVGGraphicsElement, SVGExternalResourcesRequired, SVGFitToViewBox, SVGZoomAndPan>; >+ 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; >+ bool selfHasRelativeLengths() const override; >+ bool isValid() const override; >+ > bool rendererIsNeeded(const RenderStyle&) override; > RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) override; > InsertedIntoAncestorResult insertedIntoAncestor(InsertionType, ContainerNode&) override; > void removedFromAncestor(RemovalType, ContainerNode&) override; >- void svgAttributeChanged(const QualifiedName&) override; >- bool selfHasRelativeLengths() const override; > void prepareForDocumentSuspension() override; > void resumeFromDocumentSuspension() override; >- AffineTransform localCoordinateSpaceTransform(SVGLocatable::CTMScope) const override; >+ void didMoveToNewDocument(Document& oldDocument, Document& newDocument) override; > >+ AffineTransform localCoordinateSpaceTransform(SVGLocatable::CTMScope) const override; > RefPtr<Frame> frameForCurrentScale() const; > void inheritViewAttributes(const SVGViewElement&); > Ref<NodeList> collectIntersectionOrEnclosureList(SVGRect&, SVGElement*, bool (*checkFunction)(SVGElement&, SVGRect&)); >@@ -162,41 +164,16 @@ private: > SVGSVGElement* findRootAnchor(const String&) const; > > bool m_useCurrentView { false }; >- SVGZoomAndPanType m_zoomAndPan { SVGZoomAndPanMagnify }; > Ref<SMILTimeContainer> m_timeContainer; > FloatPoint m_currentTranslate; > RefPtr<SVGViewSpec> m_viewSpec; > String m_currentViewFragmentIdentifier; >-}; > >-inline bool SVGSVGElement::useCurrentView() const >-{ >- return m_useCurrentView; >-} >- >-inline FloatPoint SVGSVGElement::currentTranslateValue() >-{ >- return m_currentTranslate; >-} >- >-inline SVGZoomAndPanType SVGSVGElement::zoomAndPan() const >-{ >- return m_zoomAndPan; >-} >- >-inline void SVGSVGElement::setZoomAndPan(unsigned short zoomAndPan) >-{ >- m_zoomAndPan = parseFromNumber(zoomAndPan); >-} >- >-inline SMILTimeContainer& SVGSVGElement::timeContainer() >-{ >- return m_timeContainer.get(); >-} >- >-inline bool SVGSVGElement::hasEmptyViewBox() const >-{ >- return viewBoxIsValid() && viewBox().isEmpty(); >-} >+ AttributeOwnerProxy m_attributeOwnerProxy { *this }; >+ SVGAnimatedLengthAttribute m_x { m_attributeOwnerProxy, LengthModeWidth }; >+ SVGAnimatedLengthAttribute m_y { m_attributeOwnerProxy, LengthModeHeight}; >+ SVGAnimatedLengthAttribute m_width { m_attributeOwnerProxy, LengthModeWidth, "100%"_s }; >+ SVGAnimatedLengthAttribute m_height { m_attributeOwnerProxy, LengthModeHeight, "100%"_s }; >+}; > > } // 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