Commit 0cbea45a authored by Henrique Ferreiro's avatar Henrique Ferreiro Committed by Commit Bot

Inline static Create() from core/svg - 11

As advised in [1], this CL ports calls to Foo::Create() factory
functions to use MakeGarbageCollected<Foo> from classes in
//third_party/blink/renderer/core/svg.

[1] https://groups.google.com/a/chromium.org/forum/#!msg/blink-dev/iJ1bawbxbWs/vEdfT5QtBgAJ

Bug: 939691
Change-Id: I12580470b68aeec1331019be33c96847592b10c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1576563
Commit-Queue: Henrique Ferreiro <hferreiro@igalia.com>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#653574}
parent e94eb183
...@@ -943,7 +943,7 @@ Element* Document::CreateRawElement(const QualifiedName& qname, ...@@ -943,7 +943,7 @@ Element* Document::CreateRawElement(const QualifiedName& qname,
} else if (qname.NamespaceURI() == svg_names::kNamespaceURI) { } else if (qname.NamespaceURI() == svg_names::kNamespaceURI) {
element = SVGElementFactory::Create(qname.LocalName(), *this, flags); element = SVGElementFactory::Create(qname.LocalName(), *this, flags);
if (!element) if (!element)
element = SVGUnknownElement::Create(qname, *this); element = MakeGarbageCollected<SVGUnknownElement>(qname, *this);
saw_elements_in_known_namespaces_ = true; saw_elements_in_known_namespaces_ = true;
} else { } else {
element = Element::Create(qname, this); element = Element::Create(qname, this);
......
...@@ -80,7 +80,7 @@ Element* V0CustomElementRegistrationContext::CreateCustomTagElement( ...@@ -80,7 +80,7 @@ Element* V0CustomElementRegistrationContext::CreateCustomTagElement(
if (html_names::xhtmlNamespaceURI == tag_name.NamespaceURI()) { if (html_names::xhtmlNamespaceURI == tag_name.NamespaceURI()) {
element = MakeGarbageCollected<HTMLElement>(tag_name, document); element = MakeGarbageCollected<HTMLElement>(tag_name, document);
} else if (svg_names::kNamespaceURI == tag_name.NamespaceURI()) { } else if (svg_names::kNamespaceURI == tag_name.NamespaceURI()) {
element = SVGUnknownElement::Create(tag_name, document); element = MakeGarbageCollected<SVGUnknownElement>(tag_name, document);
} else { } else {
// XML elements are not custom elements, so return early. // XML elements are not custom elements, so return early.
return Element::Create(tag_name, &document); return Element::Create(tag_name, &document);
......
...@@ -235,14 +235,16 @@ template <typename Property, typename TearOffType> ...@@ -235,14 +235,16 @@ template <typename Property, typename TearOffType>
class SVGAnimatedProperty<Property, TearOffType, void> class SVGAnimatedProperty<Property, TearOffType, void>
: public SVGAnimatedPropertyCommon<Property> { : public SVGAnimatedPropertyCommon<Property> {
public: public:
static SVGAnimatedProperty<Property>* Create( SVGAnimatedProperty(SVGElement* context_element,
SVGElement* context_element,
const QualifiedName& attribute_name, const QualifiedName& attribute_name,
Property* initial_value, Property* initial_value,
CSSPropertyID css_property_id = CSSPropertyID::kInvalid) { CSSPropertyID css_property_id = CSSPropertyID::kInvalid,
return new SVGAnimatedProperty<Property>(context_element, attribute_name, unsigned initial_value_bits = 0)
initial_value, css_property_id); : SVGAnimatedPropertyCommon<Property>(context_element,
} attribute_name,
initial_value,
css_property_id,
initial_value_bits) {}
void SetAnimatedValue(SVGPropertyBase* value) override { void SetAnimatedValue(SVGPropertyBase* value) override {
SVGAnimatedPropertyCommon<Property>::SetAnimatedValue(value); SVGAnimatedPropertyCommon<Property>::SetAnimatedValue(value);
...@@ -280,18 +282,6 @@ class SVGAnimatedProperty<Property, TearOffType, void> ...@@ -280,18 +282,6 @@ class SVGAnimatedProperty<Property, TearOffType, void>
SVGAnimatedPropertyCommon<Property>::Trace(visitor); SVGAnimatedPropertyCommon<Property>::Trace(visitor);
} }
protected:
SVGAnimatedProperty(SVGElement* context_element,
const QualifiedName& attribute_name,
Property* initial_value,
CSSPropertyID css_property_id = CSSPropertyID::kInvalid,
unsigned initial_value_bits = 0)
: SVGAnimatedPropertyCommon<Property>(context_element,
attribute_name,
initial_value,
css_property_id,
initial_value_bits) {}
private: private:
void UpdateAnimValTearOffIfNeeded() { void UpdateAnimValTearOffIfNeeded() {
if (anim_val_tear_off_) if (anim_val_tear_off_)
...@@ -314,16 +304,6 @@ template <typename Property> ...@@ -314,16 +304,6 @@ template <typename Property>
class SVGAnimatedProperty<Property, void, void> class SVGAnimatedProperty<Property, void, void>
: public SVGAnimatedPropertyCommon<Property> { : public SVGAnimatedPropertyCommon<Property> {
public: public:
static SVGAnimatedProperty<Property>* Create(
SVGElement* context_element,
const QualifiedName& attribute_name,
Property* initial_value,
CSSPropertyID css_property_id = CSSPropertyID::kInvalid) {
return new SVGAnimatedProperty<Property>(context_element, attribute_name,
initial_value, css_property_id);
}
protected:
SVGAnimatedProperty(SVGElement* context_element, SVGAnimatedProperty(SVGElement* context_element,
const QualifiedName& attribute_name, const QualifiedName& attribute_name,
Property* initial_value, Property* initial_value,
......
...@@ -70,14 +70,6 @@ class ListItemPropertyTraits { ...@@ -70,14 +70,6 @@ class ListItemPropertyTraits {
new_item->Bind(binding); new_item->Bind(binding);
return new_item->Target(); return new_item->Target();
} }
static ItemTearOffType* CreateTearOff(
ItemPropertyType* value,
SVGAnimatedPropertyBase* binding,
PropertyIsAnimValType property_is_anim_val) {
return MakeGarbageCollected<ItemTearOffType>(value, binding,
property_is_anim_val);
}
}; };
template <typename Derived, typename ListProperty> template <typename Derived, typename ListProperty>
...@@ -198,10 +190,11 @@ class SVGListPropertyTearOffHelper : public SVGPropertyTearOff<ListProperty> { ...@@ -198,10 +190,11 @@ class SVGListPropertyTearOffHelper : public SVGPropertyTearOff<ListProperty> {
return nullptr; return nullptr;
if (value->OwnerList() == ToDerived()->Target()) { if (value->OwnerList() == ToDerived()->Target()) {
return ItemTraits::CreateTearOff(value, ToDerived()->GetBinding(), return MakeGarbageCollected<ItemTearOffType>(
ToDerived()->PropertyIsAnimVal()); value, ToDerived()->GetBinding(), ToDerived()->PropertyIsAnimVal());
} }
return ItemTraits::CreateTearOff(value, nullptr, kPropertyIsNotAnimVal); return MakeGarbageCollected<ItemTearOffType>(value, nullptr,
kPropertyIsNotAnimVal);
} }
private: private:
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "third_party/blink/renderer/core/svg/properties/svg_animated_property.h" #include "third_party/blink/renderer/core/svg/properties/svg_animated_property.h"
#include "third_party/blink/renderer/core/svg/svg_transform_list.h" #include "third_party/blink/renderer/core/svg/svg_transform_list.h"
#include "third_party/blink/renderer/core/svg_names.h" #include "third_party/blink/renderer/core/svg_names.h"
#include "third_party/blink/renderer/platform/heap/heap.h"
namespace blink { namespace blink {
...@@ -61,7 +62,7 @@ void SVGAnimateTransformElement::ResolveTargetProperty() { ...@@ -61,7 +62,7 @@ void SVGAnimateTransformElement::ResolveTargetProperty() {
SVGPropertyBase* SVGAnimateTransformElement::CreatePropertyForAnimation( SVGPropertyBase* SVGAnimateTransformElement::CreatePropertyForAnimation(
const String& value) const { const String& value) const {
DCHECK(IsAnimatingSVGDom()); DCHECK(IsAnimatingSVGDom());
return SVGTransformList::Create(transform_type_, value); return MakeGarbageCollected<SVGTransformList>(transform_type_, value);
} }
void SVGAnimateTransformElement::ParseAttribute( void SVGAnimateTransformElement::ParseAttribute(
......
...@@ -53,10 +53,6 @@ const SVGEnumerationMap& GetEnumerationMap<SVGLengthAdjustType>() { ...@@ -53,10 +53,6 @@ const SVGEnumerationMap& GetEnumerationMap<SVGLengthAdjustType>() {
// manually. // manually.
class SVGAnimatedTextLength final : public SVGAnimatedLength { class SVGAnimatedTextLength final : public SVGAnimatedLength {
public: public:
static SVGAnimatedTextLength* Create(SVGTextContentElement* context_element) {
return MakeGarbageCollected<SVGAnimatedTextLength>(context_element);
}
SVGAnimatedTextLength(SVGTextContentElement* context_element) SVGAnimatedTextLength(SVGTextContentElement* context_element)
: SVGAnimatedLength(context_element, : SVGAnimatedLength(context_element,
svg_names::kTextLengthAttr, svg_names::kTextLengthAttr,
...@@ -78,7 +74,7 @@ class SVGAnimatedTextLength final : public SVGAnimatedLength { ...@@ -78,7 +74,7 @@ class SVGAnimatedTextLength final : public SVGAnimatedLength {
SVGTextContentElement::SVGTextContentElement(const QualifiedName& tag_name, SVGTextContentElement::SVGTextContentElement(const QualifiedName& tag_name,
Document& document) Document& document)
: SVGGraphicsElement(tag_name, document), : SVGGraphicsElement(tag_name, document),
text_length_(SVGAnimatedTextLength::Create(this)), text_length_(MakeGarbageCollected<SVGAnimatedTextLength>(this)),
text_length_is_specified_by_user_(false), text_length_is_specified_by_user_(false),
length_adjust_( length_adjust_(
MakeGarbageCollected<SVGAnimatedEnumeration<SVGLengthAdjustType>>( MakeGarbageCollected<SVGAnimatedEnumeration<SVGLengthAdjustType>>(
......
...@@ -44,13 +44,8 @@ class SVGTransformList final ...@@ -44,13 +44,8 @@ class SVGTransformList final
public: public:
typedef SVGTransformListTearOff TearOffType; typedef SVGTransformListTearOff TearOffType;
static SVGTransformList* Create() {
return MakeGarbageCollected<SVGTransformList>();
}
static SVGTransformList* Create(SVGTransformType, const String&);
SVGTransformList(); SVGTransformList();
SVGTransformList(SVGTransformType, const String&);
~SVGTransformList() override; ~SVGTransformList() override;
SVGTransform* Consolidate(); SVGTransform* Consolidate();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment