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,
} else if (qname.NamespaceURI() == svg_names::kNamespaceURI) {
element = SVGElementFactory::Create(qname.LocalName(), *this, flags);
if (!element)
element = SVGUnknownElement::Create(qname, *this);
element = MakeGarbageCollected<SVGUnknownElement>(qname, *this);
saw_elements_in_known_namespaces_ = true;
} else {
element = Element::Create(qname, this);
......
......@@ -80,7 +80,7 @@ Element* V0CustomElementRegistrationContext::CreateCustomTagElement(
if (html_names::xhtmlNamespaceURI == tag_name.NamespaceURI()) {
element = MakeGarbageCollected<HTMLElement>(tag_name, document);
} else if (svg_names::kNamespaceURI == tag_name.NamespaceURI()) {
element = SVGUnknownElement::Create(tag_name, document);
element = MakeGarbageCollected<SVGUnknownElement>(tag_name, document);
} else {
// XML elements are not custom elements, so return early.
return Element::Create(tag_name, &document);
......
......@@ -235,14 +235,16 @@ template <typename Property, typename TearOffType>
class SVGAnimatedProperty<Property, TearOffType, void>
: public SVGAnimatedPropertyCommon<Property> {
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);
}
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) {}
void SetAnimatedValue(SVGPropertyBase* value) override {
SVGAnimatedPropertyCommon<Property>::SetAnimatedValue(value);
......@@ -280,18 +282,6 @@ class SVGAnimatedProperty<Property, TearOffType, void>
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:
void UpdateAnimValTearOffIfNeeded() {
if (anim_val_tear_off_)
......@@ -314,16 +304,6 @@ template <typename Property>
class SVGAnimatedProperty<Property, void, void>
: public SVGAnimatedPropertyCommon<Property> {
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,
const QualifiedName& attribute_name,
Property* initial_value,
......
......@@ -70,14 +70,6 @@ class ListItemPropertyTraits {
new_item->Bind(binding);
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>
......@@ -198,10 +190,11 @@ class SVGListPropertyTearOffHelper : public SVGPropertyTearOff<ListProperty> {
return nullptr;
if (value->OwnerList() == ToDerived()->Target()) {
return ItemTraits::CreateTearOff(value, ToDerived()->GetBinding(),
ToDerived()->PropertyIsAnimVal());
return MakeGarbageCollected<ItemTearOffType>(
value, ToDerived()->GetBinding(), ToDerived()->PropertyIsAnimVal());
}
return ItemTraits::CreateTearOff(value, nullptr, kPropertyIsNotAnimVal);
return MakeGarbageCollected<ItemTearOffType>(value, nullptr,
kPropertyIsNotAnimVal);
}
private:
......
......@@ -25,6 +25,7 @@
#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_names.h"
#include "third_party/blink/renderer/platform/heap/heap.h"
namespace blink {
......@@ -61,7 +62,7 @@ void SVGAnimateTransformElement::ResolveTargetProperty() {
SVGPropertyBase* SVGAnimateTransformElement::CreatePropertyForAnimation(
const String& value) const {
DCHECK(IsAnimatingSVGDom());
return SVGTransformList::Create(transform_type_, value);
return MakeGarbageCollected<SVGTransformList>(transform_type_, value);
}
void SVGAnimateTransformElement::ParseAttribute(
......
......@@ -53,10 +53,6 @@ const SVGEnumerationMap& GetEnumerationMap<SVGLengthAdjustType>() {
// manually.
class SVGAnimatedTextLength final : public SVGAnimatedLength {
public:
static SVGAnimatedTextLength* Create(SVGTextContentElement* context_element) {
return MakeGarbageCollected<SVGAnimatedTextLength>(context_element);
}
SVGAnimatedTextLength(SVGTextContentElement* context_element)
: SVGAnimatedLength(context_element,
svg_names::kTextLengthAttr,
......@@ -78,7 +74,7 @@ class SVGAnimatedTextLength final : public SVGAnimatedLength {
SVGTextContentElement::SVGTextContentElement(const QualifiedName& tag_name,
Document& document)
: SVGGraphicsElement(tag_name, document),
text_length_(SVGAnimatedTextLength::Create(this)),
text_length_(MakeGarbageCollected<SVGAnimatedTextLength>(this)),
text_length_is_specified_by_user_(false),
length_adjust_(
MakeGarbageCollected<SVGAnimatedEnumeration<SVGLengthAdjustType>>(
......
......@@ -44,13 +44,8 @@ class SVGTransformList final
public:
typedef SVGTransformListTearOff TearOffType;
static SVGTransformList* Create() {
return MakeGarbageCollected<SVGTransformList>();
}
static SVGTransformList* Create(SVGTransformType, const String&);
SVGTransformList();
SVGTransformList(SVGTransformType, const String&);
~SVGTransformList() override;
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