diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-02-13 15:05:36 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-02-14 10:33:47 +0000 |
commit | e684a3455bcc29a6e3e66a004e352dea4e1141e7 (patch) | |
tree | d55b4003bde34d7d05f558f02cfd82b2a66a7aac /chromium/third_party/blink/renderer/core/html/custom | |
parent | 2b94bfe47ccb6c08047959d1c26e392919550e86 (diff) | |
download | qtwebengine-chromium-e684a3455bcc29a6e3e66a004e352dea4e1141e7.tar.gz |
BASELINE: Update Chromium to 72.0.3626.110 and Ninja to 1.9.0
Change-Id: Ic57220b00ecc929a893c91f5cc552f5d3e99e922
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/third_party/blink/renderer/core/html/custom')
43 files changed, 599 insertions, 156 deletions
diff --git a/chromium/third_party/blink/renderer/core/html/custom/README.md b/chromium/third_party/blink/renderer/core/html/custom/README.md index 243b82bd0b7..d8cab10145c 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/README.md +++ b/chromium/third_party/blink/renderer/core/html/custom/README.md @@ -83,7 +83,7 @@ with CustomElement so you can run them with: ###### Layout Tests The custom element layout tests are generally in -third_party/WebKit/LayoutTests/custom-elements. +third_party/blink/web_tests/custom-elements. All custom elements layout tests use the [web-platform-tests harness](https://web-platform-tests.org/) and follow its style. The diff --git a/chromium/third_party/blink/renderer/core/html/custom/custom_element.cc b/chromium/third_party/blink/renderer/core/html/custom/custom_element.cc index 25176be6956..372e3ec5cb5 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/custom_element.cc +++ b/chromium/third_party/blink/renderer/core/html/custom/custom_element.cc @@ -9,6 +9,7 @@ #include "third_party/blink/renderer/core/frame/local_dom_window.h" #include "third_party/blink/renderer/core/html/custom/ce_reactions_scope.h" #include "third_party/blink/renderer/core/html/custom/custom_element_definition.h" +#include "third_party/blink/renderer/core/html/custom/custom_element_form_associated_callback_reaction.h" #include "third_party/blink/renderer/core/html/custom/custom_element_reaction_stack.h" #include "third_party/blink/renderer/core/html/custom/custom_element_registry.h" #include "third_party/blink/renderer/core/html/custom/v0_custom_element.h" @@ -98,7 +99,7 @@ bool CustomElement::ShouldCreateCustomElement(const AtomicString& name) { bool CustomElement::ShouldCreateCustomElement(const QualifiedName& tag_name) { return ShouldCreateCustomElement(tag_name.LocalName()) && - tag_name.NamespaceURI() == HTMLNames::xhtmlNamespaceURI; + tag_name.NamespaceURI() == html_names::xhtmlNamespaceURI; } bool CustomElement::ShouldCreateCustomizedBuiltinElement( @@ -110,7 +111,7 @@ bool CustomElement::ShouldCreateCustomizedBuiltinElement( bool CustomElement::ShouldCreateCustomizedBuiltinElement( const QualifiedName& tag_name) { return ShouldCreateCustomizedBuiltinElement(tag_name.LocalName()) && - tag_name.NamespaceURI() == HTMLNames::xhtmlNamespaceURI; + tag_name.NamespaceURI() == html_names::xhtmlNamespaceURI; } static CustomElementDefinition* DefinitionFor( @@ -175,7 +176,7 @@ Element* CustomElement::CreateUncustomizedOrUndefinedElementTemplate( // custom element state to "undefined". if (level == kQNameIsValid) element->SetCustomElementState(CustomElementState::kUndefined); - else if (tag_name.NamespaceURI() == HTMLNames::xhtmlNamespaceURI && + else if (tag_name.NamespaceURI() == html_names::xhtmlNamespaceURI && (CustomElement::IsValidName(tag_name.LocalName()) || !is_value.IsNull())) element->SetCustomElementState(CustomElementState::kUndefined); @@ -261,6 +262,17 @@ void CustomElement::EnqueueAttributeChangedCallback( new_value); } +void CustomElement::EnqueueFormAssociatedCallback( + Element& element, + HTMLFormElement* nullable_form) { + auto* definition = DefinitionForElementWithoutCheck(element); + if (definition->HasFormAssociatedCallback()) { + Enqueue(&element, + MakeGarbageCollected<CustomElementFormAssociatedCallbackReaction>( + definition, nullable_form)); + } +} + void CustomElement::TryToUpgrade(Element* element, bool upgrade_invisible_elements) { // Try to upgrade an element diff --git a/chromium/third_party/blink/renderer/core/html/custom/custom_element.h b/chromium/third_party/blink/renderer/core/html/custom/custom_element.h index a0eb6747e54..a7ce7c32af7 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/custom_element.h +++ b/chromium/third_party/blink/renderer/core/html/custom/custom_element.h @@ -18,6 +18,7 @@ namespace blink { class Document; class Element; class HTMLElement; +class HTMLFormElement; class QualifiedName; class CustomElementDefinition; class CustomElementReaction; @@ -103,6 +104,8 @@ class CORE_EXPORT CustomElement { const QualifiedName&, const AtomicString& old_value, const AtomicString& new_value); + static void EnqueueFormAssociatedCallback(Element& element, + HTMLFormElement* nullable_form); static void TryToUpgrade(Element*, bool upgrade_invisible_elements = false); diff --git a/chromium/third_party/blink/renderer/core/html/custom/custom_element_definition.cc b/chromium/third_party/blink/renderer/core/html/custom/custom_element_definition.cc index 2764e2efd42..30979be3de3 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/custom_element_definition.cc +++ b/chromium/third_party/blink/renderer/core/html/custom/custom_element_definition.cc @@ -17,6 +17,7 @@ #include "third_party/blink/renderer/core/html/custom/custom_element_reaction.h" #include "third_party/blink/renderer/core/html/custom/custom_element_reaction_stack.h" #include "third_party/blink/renderer/core/html/custom/custom_element_upgrade_reaction.h" +#include "third_party/blink/renderer/core/html/custom/element_internals.h" #include "third_party/blink/renderer/core/html/html_element.h" #include "third_party/blink/renderer/core/html_element_factory.h" #include "third_party/blink/renderer/platform/bindings/exception_state.h" @@ -29,11 +30,16 @@ CustomElementDefinition::CustomElementDefinition( CustomElementDefinition::CustomElementDefinition( const CustomElementDescriptor& descriptor, - const HashSet<AtomicString>& observed_attributes) + const HashSet<AtomicString>& observed_attributes, + const Vector<String>& disabled_features, + FormAssociationFlag form_association_flag) : descriptor_(descriptor), observed_attributes_(observed_attributes), has_style_attribute_changed_callback_( - observed_attributes.Contains(HTMLNames::styleAttr.LocalName())) {} + observed_attributes.Contains(html_names::kStyleAttr.LocalName())), + disable_internals_(disabled_features.Contains(String("internals"))), + is_form_associated_(form_association_flag == FormAssociationFlag::kYes) {} + CustomElementDefinition::~CustomElementDefinition() = default; void CustomElementDefinition::Trace(blink::Visitor* visitor) { @@ -61,7 +67,7 @@ static String ErrorMessageForConstructorResult(Element* element, return "The result must be in the same document"; // 6.1.8. If result's namespace is not the HTML namespace, then throw a // NotSupportedError. - if (element->namespaceURI() != HTMLNames::xhtmlNamespaceURI) + if (element->namespaceURI() != html_names::xhtmlNamespaceURI) return "The result must have HTML namespace"; // 6.1.9. If result's local name is not equal to localName, then throw a // NotSupportedError. @@ -104,7 +110,7 @@ HTMLElement* CustomElementDefinition::CreateElementForConstructor( } else { element = HTMLElement::Create(QualifiedName(g_null_atom, Descriptor().LocalName(), - HTMLNames::xhtmlNamespaceURI), + html_names::xhtmlNamespaceURI), document); } // TODO(davaajav): write this as one call to setCustomElementState instead of @@ -206,6 +212,9 @@ void CustomElementDefinition::Upgrade(Element* element) { } element->SetCustomElementDefinition(this); + + if (IsFormAssociated()) + ToHTMLElement(element)->EnsureElementInternals().DidUpgrade(); AddDefaultStylesTo(*element); } @@ -230,9 +239,9 @@ void CustomElementDefinition::AddDefaultStylesTo(Element& element) { for (CSSStyleSheet* sheet : default_styles) sheet->AddToCustomElementTagNames(local_tag_name); } - element.SetNeedsStyleRecalc(kLocalStyleChange, - StyleChangeReasonForTracing::Create( - StyleChangeReason::kActiveStylesheetsUpdate)); + element.SetNeedsStyleRecalc( + kLocalStyleChange, StyleChangeReasonForTracing::Create( + style_change_reason::kActiveStylesheetsUpdate)); } bool CustomElementDefinition::HasAttributeChangedCallback( diff --git a/chromium/third_party/blink/renderer/core/html/custom/custom_element_definition.h b/chromium/third_party/blink/renderer/core/html/custom/custom_element_definition.h index 760c9b76ce2..f94bf3ae33b 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/custom_element_definition.h +++ b/chromium/third_party/blink/renderer/core/html/custom/custom_element_definition.h @@ -23,8 +23,14 @@ class Document; class Element; class ExceptionState; class HTMLElement; +class HTMLFormElement; class QualifiedName; +enum class FormAssociationFlag { + kNo, + kYes, +}; + class CORE_EXPORT CustomElementDefinition : public GarbageCollectedFinalized<CustomElementDefinition>, public NameClient { @@ -68,6 +74,8 @@ class CORE_EXPORT CustomElementDefinition virtual bool HasAdoptedCallback() const = 0; bool HasAttributeChangedCallback(const QualifiedName&) const; bool HasStyleAttributeChangedCallback() const; + virtual bool HasFormAssociatedCallback() const = 0; + virtual bool HasDisabledStateChangedCallback() const = 0; virtual void RunConnectedCallback(Element*) = 0; virtual void RunDisconnectedCallback(Element*) = 0; @@ -78,6 +86,10 @@ class CORE_EXPORT CustomElementDefinition const QualifiedName&, const AtomicString& old_value, const AtomicString& new_value) = 0; + virtual void RunFormAssociatedCallback(Element* element, + HTMLFormElement* nullable_form) = 0; + virtual void RunDisabledStateChangedCallback(Element* element, + bool is_disabled) = 0; void EnqueueUpgradeReaction(Element*, bool upgrade_invisible_elements = false); @@ -103,6 +115,8 @@ class CORE_EXPORT CustomElementDefinition bool HasDefaultStyleSheets() const { return !default_style_sheets_.IsEmpty(); } + bool DisableInternals() const { return disable_internals_; } + bool IsFormAssociated() const { return is_form_associated_; } class CORE_EXPORT ConstructionStackScope final { STACK_ALLOCATED(); @@ -122,7 +136,9 @@ class CORE_EXPORT CustomElementDefinition CustomElementDefinition(const CustomElementDescriptor&); CustomElementDefinition(const CustomElementDescriptor&, - const HashSet<AtomicString>& observed_attributes); + const HashSet<AtomicString>& observed_attributes, + const Vector<String>& disabled_features, + FormAssociationFlag form_association_flag); void AddDefaultStylesTo(Element&); @@ -139,6 +155,8 @@ class CORE_EXPORT CustomElementDefinition HashSet<AtomicString> observed_attributes_; bool has_style_attribute_changed_callback_; bool added_default_style_sheet_ = false; + bool disable_internals_ = false; + bool is_form_associated_ = false; HeapVector<Member<CSSStyleSheet>> default_style_sheets_; diff --git a/chromium/third_party/blink/renderer/core/html/custom/custom_element_definition_test.cc b/chromium/third_party/blink/renderer/core/html/custom/custom_element_definition_test.cc index b9377f13020..07d98d1445b 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/custom_element_definition_test.cc +++ b/chromium/third_party/blink/renderer/core/html/custom/custom_element_definition_test.cc @@ -34,9 +34,12 @@ TEST(CustomElementDefinitionTest, upgrade_clearsReactionQueueOnFailure) { << "sanity check: this element should be ready to upgrade"; { CEReactionsScope reactions; + HeapVector<Member<Command>>* commands = + MakeGarbageCollected<HeapVector<Member<Command>>>(); + commands->push_back(MakeGarbageCollected<Unreached>( + "upgrade failure should clear the reaction queue")); reactions.EnqueueToCurrentQueue( - element, new TestReaction({new Unreached( - "upgrade failure should clear the reaction queue")})); + element, MakeGarbageCollected<TestReaction>(commands)); ConstructorFails definition(CustomElementDescriptor("a-a", "a-a")); definition.Upgrade(element); } @@ -50,9 +53,12 @@ TEST(CustomElementDefinitionTest, EXPECT_EQ(CustomElementState::kUndefined, element->GetCustomElementState()) << "sanity check: this element should be ready to upgrade"; ResetCustomElementReactionStackForTest reset_reaction_stack; + HeapVector<Member<Command>>* commands = + MakeGarbageCollected<HeapVector<Member<Command>>>(); + commands->push_back(MakeGarbageCollected<Unreached>( + "upgrade failure should clear the reaction queue")); reset_reaction_stack.Stack().EnqueueToBackupQueue( - element, new TestReaction({new Unreached( - "upgrade failure should clear the reaction queue")})); + element, MakeGarbageCollected<TestReaction>(commands)); ConstructorFails definition(CustomElementDescriptor("a-a", "a-a")); definition.Upgrade(element); EXPECT_EQ(CustomElementState::kFailed, element->GetCustomElementState()) diff --git a/chromium/third_party/blink/renderer/core/html/custom/custom_element_descriptor.h b/chromium/third_party/blink/renderer/core/html/custom/custom_element_descriptor.h index d47ce6da73e..d24e368a0b9 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/custom_element_descriptor.h +++ b/chromium/third_party/blink/renderer/core/html/custom/custom_element_descriptor.h @@ -49,7 +49,7 @@ class CORE_EXPORT CustomElementDescriptor final { bool Matches(const Element& element) const { return LocalName() == element.localName() && (IsAutonomous() || GetName() == element.IsValue()) && - element.namespaceURI() == HTMLNames::xhtmlNamespaceURI; + element.namespaceURI() == html_names::xhtmlNamespaceURI; } bool IsAutonomous() const { return name_ == local_name_; } diff --git a/chromium/third_party/blink/renderer/core/html/custom/custom_element_form_associated_callback_reaction.cc b/chromium/third_party/blink/renderer/core/html/custom/custom_element_form_associated_callback_reaction.cc new file mode 100644 index 00000000000..dc77d5c9cdf --- /dev/null +++ b/chromium/third_party/blink/renderer/core/html/custom/custom_element_form_associated_callback_reaction.cc @@ -0,0 +1,30 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "third_party/blink/renderer/core/html/custom/custom_element_form_associated_callback_reaction.h" + +#include "third_party/blink/renderer/core/dom/document.h" +#include "third_party/blink/renderer/core/html/custom/custom_element_definition.h" +#include "third_party/blink/renderer/core/html/forms/html_form_element.h" + +namespace blink { + +CustomElementFormAssociatedCallbackReaction:: + CustomElementFormAssociatedCallbackReaction( + CustomElementDefinition* definition, + HTMLFormElement* nullable_form) + : CustomElementReaction(definition), form_(nullable_form) { + DCHECK(definition->HasFormAssociatedCallback()); +} + +void CustomElementFormAssociatedCallbackReaction::Trace(Visitor* visitor) { + visitor->Trace(form_); + CustomElementReaction::Trace(visitor); +} + +void CustomElementFormAssociatedCallbackReaction::Invoke(Element* element) { + definition_->RunFormAssociatedCallback(element, form_.Get()); +} + +} // namespace blink diff --git a/chromium/third_party/blink/renderer/core/html/custom/custom_element_form_associated_callback_reaction.h b/chromium/third_party/blink/renderer/core/html/custom/custom_element_form_associated_callback_reaction.h new file mode 100644 index 00000000000..01d1d1b2de3 --- /dev/null +++ b/chromium/third_party/blink/renderer/core/html/custom/custom_element_form_associated_callback_reaction.h @@ -0,0 +1,32 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_HTML_CUSTOM_CUSTOM_ELEMENT_FORM_ASSOCIATED_CALLBACK_REACTION_H_ +#define THIRD_PARTY_BLINK_RENDERER_CORE_HTML_CUSTOM_CUSTOM_ELEMENT_FORM_ASSOCIATED_CALLBACK_REACTION_H_ + +#include "base/macros.h" +#include "third_party/blink/renderer/core/html/custom/custom_element_reaction.h" + +namespace blink { + +class HTMLFormElement; + +class CustomElementFormAssociatedCallbackReaction final + : public CustomElementReaction { + public: + CustomElementFormAssociatedCallbackReaction(CustomElementDefinition*, + HTMLFormElement* nullable_form); + void Trace(Visitor*) override; + + private: + void Invoke(Element*) override; + + Member<HTMLFormElement> form_; + + DISALLOW_COPY_AND_ASSIGN(CustomElementFormAssociatedCallbackReaction); +}; + +} // namespace blink + +#endif // THIRD_PARTY_BLINK_RENDERER_CORE_HTML_CUSTOM_CUSTOM_ELEMENT_FORM_ASSOCIATED_CALLBACK_REACTION_H_ diff --git a/chromium/third_party/blink/renderer/core/html/custom/custom_element_reaction_queue_test.cc b/chromium/third_party/blink/renderer/core/html/custom/custom_element_reaction_queue_test.cc index af1de9ce0da..651efd1e45e 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/custom_element_reaction_queue_test.cc +++ b/chromium/third_party/blink/renderer/core/html/custom/custom_element_reaction_queue_test.cc @@ -17,7 +17,10 @@ namespace blink { TEST(CustomElementReactionQueueTest, invokeReactions_one) { std::vector<char> log; CustomElementReactionQueue* queue = new CustomElementReactionQueue(); - queue->Add(new TestReaction({new Log('a', log)})); + HeapVector<Member<Command>>* commands = + MakeGarbageCollected<HeapVector<Member<Command>>>(); + commands->push_back(MakeGarbageCollected<Log>('a', log)); + queue->Add(MakeGarbageCollected<TestReaction>(commands)); queue->InvokeReactions(nullptr); EXPECT_EQ(log, std::vector<char>({'a'})) << "the reaction should have been invoked"; @@ -26,9 +29,24 @@ TEST(CustomElementReactionQueueTest, invokeReactions_one) { TEST(CustomElementReactionQueueTest, invokeReactions_many) { std::vector<char> log; CustomElementReactionQueue* queue = new CustomElementReactionQueue(); - queue->Add(new TestReaction({new Log('a', log)})); - queue->Add(new TestReaction({new Log('b', log)})); - queue->Add(new TestReaction({new Log('c', log)})); + { + HeapVector<Member<Command>>* commands = + MakeGarbageCollected<HeapVector<Member<Command>>>(); + commands->push_back(MakeGarbageCollected<Log>('a', log)); + queue->Add(MakeGarbageCollected<TestReaction>(commands)); + } + { + HeapVector<Member<Command>>* commands = + MakeGarbageCollected<HeapVector<Member<Command>>>(); + commands->push_back(MakeGarbageCollected<Log>('b', log)); + queue->Add(MakeGarbageCollected<TestReaction>(commands)); + } + { + HeapVector<Member<Command>>* commands = + MakeGarbageCollected<HeapVector<Member<Command>>>(); + commands->push_back(MakeGarbageCollected<Log>('c', log)); + queue->Add(MakeGarbageCollected<TestReaction>(commands)); + } queue->InvokeReactions(nullptr); EXPECT_EQ(log, std::vector<char>({'a', 'b', 'c'})) << "the reaction should have been invoked"; @@ -38,16 +56,27 @@ TEST(CustomElementReactionQueueTest, invokeReactions_recursive) { std::vector<char> log; CustomElementReactionQueue* queue = new CustomElementReactionQueue(); - CustomElementReaction* third = new TestReaction( - {new Log('c', log), new Recurse(queue)}); // "Empty" recursion + HeapVector<Member<Command>>* third_commands = + MakeGarbageCollected<HeapVector<Member<Command>>>(); + third_commands->push_back(MakeGarbageCollected<Log>('c', log)); + third_commands->push_back(MakeGarbageCollected<Recurse>(queue)); + CustomElementReaction* third = + MakeGarbageCollected<TestReaction>(third_commands); // "Empty" recursion - CustomElementReaction* second = new TestReaction( - {new Log('b', log), - new Enqueue(queue, third)}); // Unwinds one level of recursion + HeapVector<Member<Command>>* second_commands = + MakeGarbageCollected<HeapVector<Member<Command>>>(); + second_commands->push_back(MakeGarbageCollected<Log>('b', log)); + second_commands->push_back(MakeGarbageCollected<Enqueue>(queue, third)); + CustomElementReaction* second = MakeGarbageCollected<TestReaction>( + second_commands); // Unwinds one level of recursion - CustomElementReaction* first = - new TestReaction({new Log('a', log), new Enqueue(queue, second), - new Recurse(queue)}); // Non-empty recursion + HeapVector<Member<Command>>* first_commands = + MakeGarbageCollected<HeapVector<Member<Command>>>(); + first_commands->push_back(MakeGarbageCollected<Log>('a', log)); + first_commands->push_back(MakeGarbageCollected<Enqueue>(queue, second)); + first_commands->push_back(MakeGarbageCollected<Recurse>(queue)); + CustomElementReaction* first = MakeGarbageCollected<TestReaction>( + first_commands); // Non-empty recursion queue->Add(first); queue->InvokeReactions(nullptr); @@ -59,11 +88,26 @@ TEST(CustomElementReactionQueueTest, clear_duringInvoke) { std::vector<char> log; CustomElementReactionQueue* queue = new CustomElementReactionQueue(); - queue->Add(new TestReaction({new Log('a', log)})); - queue->Add(new TestReaction({new Call(WTF::Bind( - [](CustomElementReactionQueue* queue, Element*) { queue->Clear(); }, - WrapPersistent(queue)))})); - queue->Add(new TestReaction({new Log('b', log)})); + { + HeapVector<Member<Command>>* commands = + MakeGarbageCollected<HeapVector<Member<Command>>>(); + commands->push_back(MakeGarbageCollected<Log>('a', log)); + queue->Add(MakeGarbageCollected<TestReaction>(commands)); + } + { + HeapVector<Member<Command>>* commands = + MakeGarbageCollected<HeapVector<Member<Command>>>(); + commands->push_back(new Call(WTF::Bind( + [](CustomElementReactionQueue* queue, Element*) { queue->Clear(); }, + WrapPersistent(queue)))); + queue->Add(MakeGarbageCollected<TestReaction>(commands)); + } + { + HeapVector<Member<Command>>* commands = + MakeGarbageCollected<HeapVector<Member<Command>>>(); + commands->push_back(MakeGarbageCollected<Log>('b', log)); + queue->Add(MakeGarbageCollected<TestReaction>(commands)); + } queue->InvokeReactions(nullptr); EXPECT_EQ(log, std::vector<char>({'a'})) diff --git a/chromium/third_party/blink/renderer/core/html/custom/custom_element_reaction_stack.cc b/chromium/third_party/blink/renderer/core/html/custom/custom_element_reaction_stack.cc index 17f2895c4e0..48b65d63226 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/custom_element_reaction_stack.cc +++ b/chromium/third_party/blink/renderer/core/html/custom/custom_element_reaction_stack.cc @@ -66,7 +66,7 @@ void CustomElementReactionStack::Enqueue(Member<ElementQueue>& queue, Element* element, CustomElementReaction* reaction) { if (!queue) - queue = new ElementQueue(); + queue = MakeGarbageCollected<ElementQueue>(); queue->push_back(element); CustomElementReactionQueue* reactions = map_.at(element); diff --git a/chromium/third_party/blink/renderer/core/html/custom/custom_element_reaction_stack_test.cc b/chromium/third_party/blink/renderer/core/html/custom/custom_element_reaction_stack_test.cc index 5ed8fbfa8b8..49ec44d502d 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/custom_element_reaction_stack_test.cc +++ b/chromium/third_party/blink/renderer/core/html/custom/custom_element_reaction_stack_test.cc @@ -21,8 +21,11 @@ TEST(CustomElementReactionStackTest, one) { CustomElementReactionStack* stack = new CustomElementReactionStack(); stack->Push(); + HeapVector<Member<Command>>* commands = + MakeGarbageCollected<HeapVector<Member<Command>>>(); + commands->push_back(MakeGarbageCollected<Log>('a', log)); stack->EnqueueToCurrentQueue(CreateElement("a"), - new TestReaction({new Log('a', log)})); + MakeGarbageCollected<TestReaction>(commands)); stack->PopInvokingReactions(); EXPECT_EQ(log, std::vector<char>({'a'})) @@ -34,10 +37,20 @@ TEST(CustomElementReactionStackTest, multipleElements) { CustomElementReactionStack* stack = new CustomElementReactionStack(); stack->Push(); - stack->EnqueueToCurrentQueue(CreateElement("a"), - new TestReaction({new Log('a', log)})); - stack->EnqueueToCurrentQueue(CreateElement("a"), - new TestReaction({new Log('b', log)})); + { + HeapVector<Member<Command>>* commands = + MakeGarbageCollected<HeapVector<Member<Command>>>(); + commands->push_back(MakeGarbageCollected<Log>('a', log)); + stack->EnqueueToCurrentQueue(CreateElement("a"), + MakeGarbageCollected<TestReaction>(commands)); + } + { + HeapVector<Member<Command>>* commands = + MakeGarbageCollected<HeapVector<Member<Command>>>(); + commands->push_back(MakeGarbageCollected<Log>('b', log)); + stack->EnqueueToCurrentQueue(CreateElement("a"), + MakeGarbageCollected<TestReaction>(commands)); + } stack->PopInvokingReactions(); EXPECT_EQ(log, std::vector<char>({'a', 'b'})) @@ -49,8 +62,11 @@ TEST(CustomElementReactionStackTest, popTopEmpty) { CustomElementReactionStack* stack = new CustomElementReactionStack(); stack->Push(); + HeapVector<Member<Command>>* commands = + MakeGarbageCollected<HeapVector<Member<Command>>>(); + commands->push_back(MakeGarbageCollected<Log>('a', log)); stack->EnqueueToCurrentQueue(CreateElement("a"), - new TestReaction({new Log('a', log)})); + MakeGarbageCollected<TestReaction>(commands)); stack->Push(); stack->PopInvokingReactions(); @@ -63,11 +79,21 @@ TEST(CustomElementReactionStackTest, popTop) { CustomElementReactionStack* stack = new CustomElementReactionStack(); stack->Push(); - stack->EnqueueToCurrentQueue(CreateElement("a"), - new TestReaction({new Log('a', log)})); + { + HeapVector<Member<Command>>* commands = + MakeGarbageCollected<HeapVector<Member<Command>>>(); + commands->push_back(MakeGarbageCollected<Log>('a', log)); + stack->EnqueueToCurrentQueue(CreateElement("a"), + MakeGarbageCollected<TestReaction>(commands)); + } stack->Push(); - stack->EnqueueToCurrentQueue(CreateElement("a"), - new TestReaction({new Log('b', log)})); + { + HeapVector<Member<Command>>* commands = + MakeGarbageCollected<HeapVector<Member<Command>>>(); + commands->push_back(MakeGarbageCollected<Log>('b', log)); + stack->EnqueueToCurrentQueue(CreateElement("a"), + MakeGarbageCollected<TestReaction>(commands)); + } stack->PopInvokingReactions(); EXPECT_EQ(log, std::vector<char>({'b'})) @@ -81,10 +107,27 @@ TEST(CustomElementReactionStackTest, requeueingDoesNotReorderElements) { CustomElementReactionStack* stack = new CustomElementReactionStack(); stack->Push(); - stack->EnqueueToCurrentQueue(element, new TestReaction({new Log('a', log)})); - stack->EnqueueToCurrentQueue(CreateElement("a"), - new TestReaction({new Log('z', log)})); - stack->EnqueueToCurrentQueue(element, new TestReaction({new Log('b', log)})); + { + HeapVector<Member<Command>>* commands = + MakeGarbageCollected<HeapVector<Member<Command>>>(); + commands->push_back(MakeGarbageCollected<Log>('a', log)); + stack->EnqueueToCurrentQueue(element, + MakeGarbageCollected<TestReaction>(commands)); + } + { + HeapVector<Member<Command>>* commands = + MakeGarbageCollected<HeapVector<Member<Command>>>(); + commands->push_back(MakeGarbageCollected<Log>('z', log)); + stack->EnqueueToCurrentQueue(CreateElement("a"), + MakeGarbageCollected<TestReaction>(commands)); + } + { + HeapVector<Member<Command>>* commands = + MakeGarbageCollected<HeapVector<Member<Command>>>(); + commands->push_back(MakeGarbageCollected<Log>('b', log)); + stack->EnqueueToCurrentQueue(element, + MakeGarbageCollected<TestReaction>(commands)); + } stack->PopInvokingReactions(); EXPECT_EQ(log, std::vector<char>({'a', 'b', 'z'})) @@ -98,13 +141,35 @@ TEST(CustomElementReactionStackTest, oneReactionQueuePerElement) { CustomElementReactionStack* stack = new CustomElementReactionStack(); stack->Push(); - stack->EnqueueToCurrentQueue(element, new TestReaction({new Log('a', log)})); - stack->EnqueueToCurrentQueue(CreateElement("a"), - new TestReaction({new Log('z', log)})); + { + HeapVector<Member<Command>>* commands = + MakeGarbageCollected<HeapVector<Member<Command>>>(); + commands->push_back(MakeGarbageCollected<Log>('a', log)); + stack->EnqueueToCurrentQueue(element, + MakeGarbageCollected<TestReaction>(commands)); + } + { + HeapVector<Member<Command>>* commands = + MakeGarbageCollected<HeapVector<Member<Command>>>(); + commands->push_back(MakeGarbageCollected<Log>('z', log)); + stack->EnqueueToCurrentQueue(CreateElement("a"), + MakeGarbageCollected<TestReaction>(commands)); + } stack->Push(); - stack->EnqueueToCurrentQueue(CreateElement("a"), - new TestReaction({new Log('y', log)})); - stack->EnqueueToCurrentQueue(element, new TestReaction({new Log('b', log)})); + { + HeapVector<Member<Command>>* commands = + MakeGarbageCollected<HeapVector<Member<Command>>>(); + commands->push_back(MakeGarbageCollected<Log>('y', log)); + stack->EnqueueToCurrentQueue(CreateElement("a"), + MakeGarbageCollected<TestReaction>(commands)); + } + { + HeapVector<Member<Command>>* commands = + MakeGarbageCollected<HeapVector<Member<Command>>>(); + commands->push_back(MakeGarbageCollected<Log>('b', log)); + stack->EnqueueToCurrentQueue(element, + MakeGarbageCollected<TestReaction>(commands)); + } stack->PopInvokingReactions(); EXPECT_EQ(log, std::vector<char>({'y', 'a', 'b'})) @@ -147,9 +212,17 @@ TEST(CustomElementReactionStackTest, enqueueFromReaction) { CustomElementReactionStack* stack = new CustomElementReactionStack(); stack->Push(); - stack->EnqueueToCurrentQueue( - element, new TestReaction({new EnqueueToStack( - stack, element, new TestReaction({new Log('a', log)}))})); + { + HeapVector<Member<Command>>* subcommands = + MakeGarbageCollected<HeapVector<Member<Command>>>(); + subcommands->push_back(MakeGarbageCollected<Log>('a', log)); + HeapVector<Member<Command>>* commands = + MakeGarbageCollected<HeapVector<Member<Command>>>(); + commands->push_back(MakeGarbageCollected<EnqueueToStack>( + stack, element, MakeGarbageCollected<TestReaction>(subcommands))); + stack->EnqueueToCurrentQueue(element, + MakeGarbageCollected<TestReaction>(commands)); + } stack->PopInvokingReactions(); EXPECT_EQ(log, std::vector<char>({'a'})) << "enqueued reaction from another " diff --git a/chromium/third_party/blink/renderer/core/html/custom/custom_element_reaction_test_helpers.h b/chromium/third_party/blink/renderer/core/html/custom/custom_element_reaction_test_helpers.h index 29cbabc7ed8..396d89d636c 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/custom_element_reaction_test_helpers.h +++ b/chromium/third_party/blink/renderer/core/html/custom/custom_element_reaction_test_helpers.h @@ -107,25 +107,20 @@ class Enqueue : public Command { class TestReaction : public CustomElementReaction { public: - TestReaction(std::initializer_list<Command*> commands) - : CustomElementReaction(nullptr) { - // TODO(dominicc): Simply pass the initializer list when - // HeapVector supports initializer lists like Vector. - for (auto* const command : commands) - commands_.push_back(command); - } + TestReaction(HeapVector<Member<Command>>* commands) + : CustomElementReaction(nullptr), commands_(commands) {} ~TestReaction() override = default; void Trace(blink::Visitor* visitor) override { CustomElementReaction::Trace(visitor); visitor->Trace(commands_); } void Invoke(Element* element) override { - for (auto& command : commands_) + for (auto& command : *commands_) command->Run(element); } private: - HeapVector<Member<Command>> commands_; + Member<HeapVector<Member<Command>>> commands_; DISALLOW_COPY_AND_ASSIGN(TestReaction); }; diff --git a/chromium/third_party/blink/renderer/core/html/custom/custom_element_registry.cc b/chromium/third_party/blink/renderer/core/html/custom/custom_element_registry.cc index c4ca5d9e54c..866bdc2f28f 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/custom_element_registry.cc +++ b/chromium/third_party/blink/renderer/core/html/custom/custom_element_registry.cc @@ -89,8 +89,8 @@ CustomElementRegistry* CustomElementRegistry::Create( CustomElementRegistry::CustomElementRegistry(const LocalDOMWindow* owner) : element_definition_is_running_(false), owner_(owner), - v0_(new V0RegistrySet()), - upgrade_candidates_(new UpgradeCandidateMap()), + v0_(MakeGarbageCollected<V0RegistrySet>()), + upgrade_candidates_(MakeGarbageCollected<UpgradeCandidateMap>()), reaction_stack_(&CustomElementReactionStack::Current()) {} void CustomElementRegistry::Trace(blink::Visitor* visitor) { @@ -107,7 +107,7 @@ CustomElementDefinition* CustomElementRegistry::define( ScriptState* script_state, const AtomicString& name, V8CustomElementConstructor* constructor, - const ElementDefinitionOptions& options, + const ElementDefinitionOptions* options, ExceptionState& exception_state) { ScriptCustomElementDefinitionBuilder builder(script_state, this, constructor, exception_state); @@ -119,7 +119,7 @@ CustomElementDefinition* CustomElementRegistry::DefineInternal( ScriptState* script_state, const AtomicString& name, CustomElementDefinitionBuilder& builder, - const ElementDefinitionOptions& options, + const ElementDefinitionOptions* options, ExceptionState& exception_state) { TRACE_EVENT1("blink", "CustomElementRegistry::define", "name", name.Utf8()); if (!builder.CheckConstructorIntrinsics()) @@ -150,10 +150,10 @@ CustomElementDefinition* CustomElementRegistry::DefineInternal( // Step 7. customized built-in elements definition // element interface extends option checks - if (options.hasExtends()) { + if (options->hasExtends()) { // 7.1. If element interface is valid custom element name, throw exception - const AtomicString& extends = AtomicString(options.extends()); - if (ThrowIfValidName(AtomicString(options.extends()), exception_state)) + const AtomicString& extends = AtomicString(options->extends()); + if (ThrowIfValidName(AtomicString(options->extends()), exception_state)) return nullptr; // 7.2. If element interface is undefined element, throw exception if (htmlElementTypeForTag(extends) == @@ -212,9 +212,8 @@ CustomElementDefinition* CustomElementRegistry::DefineInternal( CHECK(!exception_state.HadException()); CHECK(definition->Descriptor() == descriptor); if (RuntimeEnabledFeatures::CustomElementDefaultStyleEnabled() && - options.hasStyles()) - definition->SetDefaultStyleSheets(options.styles()); - + options->hasStyles()) + definition->SetDefaultStyleSheets(options->styles()); definitions_.emplace_back(definition); NameIdMap::AddResult result = name_id_map_.insert(descriptor.GetName(), id); CHECK(result.is_new_entry); @@ -304,7 +303,8 @@ void CustomElementRegistry::AddCandidate(Element* candidate) { if (it != upgrade_candidates_->end()) { set = it->value; } else { - set = upgrade_candidates_->insert(name, new UpgradeCandidateSet()) + set = upgrade_candidates_ + ->insert(name, MakeGarbageCollected<UpgradeCandidateSet>()) .stored_value->value; } set->insert(candidate); diff --git a/chromium/third_party/blink/renderer/core/html/custom/custom_element_registry.h b/chromium/third_party/blink/renderer/core/html/custom/custom_element_registry.h index a323e28be66..5b3f44845d1 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/custom_element_registry.h +++ b/chromium/third_party/blink/renderer/core/html/custom/custom_element_registry.h @@ -42,7 +42,7 @@ class CORE_EXPORT CustomElementRegistry final : public ScriptWrappable { CustomElementDefinition* define(ScriptState*, const AtomicString& name, V8CustomElementConstructor* constructor, - const ElementDefinitionOptions&, + const ElementDefinitionOptions*, ExceptionState&); ScriptValue get(const AtomicString& name); @@ -72,7 +72,7 @@ class CORE_EXPORT CustomElementRegistry final : public ScriptWrappable { CustomElementDefinition* DefineInternal(ScriptState*, const AtomicString& name, CustomElementDefinitionBuilder&, - const ElementDefinitionOptions&, + const ElementDefinitionOptions*, ExceptionState&); bool V0NameIsDefined(const AtomicString& name); diff --git a/chromium/third_party/blink/renderer/core/html/custom/custom_element_registry.idl b/chromium/third_party/blink/renderer/core/html/custom/custom_element_registry.idl index aab5cdf98ab..8061cb734e4 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/custom_element_registry.idl +++ b/chromium/third_party/blink/renderer/core/html/custom/custom_element_registry.idl @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// https://html.spec.whatwg.org/C/custom-elements.html#customelementregistry + interface CustomElementRegistry { [CallWith=ScriptState, CEReactions, CustomElementCallbacks, RaisesException, MeasureAs=CustomElementRegistryDefine] void define(DOMString name, CustomElementConstructor constructor, optional ElementDefinitionOptions options); any get(DOMString name); @@ -10,3 +12,10 @@ interface CustomElementRegistry { }; callback CustomElementConstructor = any (); + +// Blink specific types. HTML standard does not explicitly define these types. +callback CustomElementAdoptedCallback = void (Document oldOwner, Document newOwner); +callback CustomElementAttributeChangedCallback = void (DOMString localName, DOMString? oldValue, DOMString? newValue, USVString? attrNamespace); +callback CustomElementFormAssociatedCallback = void (HTMLFormElement? form); +callback CustomElementDisabledStateChangedCallback = void (boolean disabled); + diff --git a/chromium/third_party/blink/renderer/core/html/custom/custom_element_registry_test.cc b/chromium/third_party/blink/renderer/core/html/custom/custom_element_registry_test.cc index 7cef1b7046a..522e8116366 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/custom_element_registry_test.cc +++ b/chromium/third_party/blink/renderer/core/html/custom/custom_element_registry_test.cc @@ -43,7 +43,7 @@ class CustomElementRegistryTest : public PageTestBase { CustomElementDefinition* Define(const AtomicString& name, CustomElementDefinitionBuilder& builder, - const ElementDefinitionOptions& options, + const ElementDefinitionOptions* options, ExceptionState& exception_state) { return Registry().DefineInternal(GetScriptState(), name, builder, options, exception_state); @@ -170,8 +170,9 @@ class LogUpgradeDefinition : public TestCustomElementDefinition { : TestCustomElementDefinition( descriptor, { - "attr1", "attr2", HTMLNames::contenteditableAttr.LocalName(), - }) {} + "attr1", "attr2", html_names::kContenteditableAttr.LocalName(), + }, + {}) {} void Trace(blink::Visitor* visitor) override { TestCustomElementDefinition::Trace(visitor); @@ -242,7 +243,7 @@ class LogUpgradeDefinition : public TestCustomElementDefinition { Document* new_owner) override { logs_.push_back(kAdoptedCallback); EXPECT_EQ(element, element_); - adopted_.push_back(new Adopted(old_owner, new_owner)); + adopted_.push_back(MakeGarbageCollected<Adopted>(old_owner, new_owner)); } void RunAttributeChangedCallback(Element* element, @@ -265,7 +266,7 @@ class LogUpgradeBuilder final : public TestCustomElementDefinitionBuilder { CustomElementDefinition* Build(const CustomElementDescriptor& descriptor, CustomElementDefinition::Id) override { - return new LogUpgradeDefinition(descriptor); + return MakeGarbageCollected<LogUpgradeDefinition>(descriptor); } DISALLOW_COPY_AND_ASSIGN(LogUpgradeBuilder); @@ -276,15 +277,16 @@ TEST_F(CustomElementRegistryTest, define_upgradesInDocumentElements) { Element* element = CreateElement("a-a").InDocument(&GetDocument()); element->setAttribute( - QualifiedName(g_null_atom, "attr1", HTMLNames::xhtmlNamespaceURI), "v1"); - element->SetBooleanAttribute(HTMLNames::contenteditableAttr, true); + QualifiedName(g_null_atom, "attr1", html_names::xhtmlNamespaceURI), "v1"); + element->SetBooleanAttribute(html_names::kContenteditableAttr, true); GetDocument().documentElement()->AppendChild(element); LogUpgradeBuilder builder; NonThrowableExceptionState should_not_throw; { CEReactionsScope reactions; - Define("a-a", builder, ElementDefinitionOptions(), should_not_throw); + Define("a-a", builder, ElementDefinitionOptions::Create(), + should_not_throw); } LogUpgradeDefinition* definition = static_cast<LogUpgradeDefinition*>(Registry().DefinitionForName("a-a")); @@ -326,7 +328,8 @@ TEST_F(CustomElementRegistryTest, attributeChangedCallback) { NonThrowableExceptionState should_not_throw; { CEReactionsScope reactions; - Define("a-a", builder, ElementDefinitionOptions(), should_not_throw); + Define("a-a", builder, ElementDefinitionOptions::Create(), + should_not_throw); } LogUpgradeDefinition* definition = static_cast<LogUpgradeDefinition*>(Registry().DefinitionForName("a-a")); @@ -335,7 +338,7 @@ TEST_F(CustomElementRegistryTest, attributeChangedCallback) { { CEReactionsScope reactions; element->setAttribute( - QualifiedName(g_null_atom, "attr2", HTMLNames::xhtmlNamespaceURI), + QualifiedName(g_null_atom, "attr2", html_names::xhtmlNamespaceURI), "v2"); } EXPECT_EQ(LogUpgradeDefinition::kAttributeChangedCallback, @@ -361,7 +364,8 @@ TEST_F(CustomElementRegistryTest, disconnectedCallback) { NonThrowableExceptionState should_not_throw; { CEReactionsScope reactions; - Define("a-a", builder, ElementDefinitionOptions(), should_not_throw); + Define("a-a", builder, ElementDefinitionOptions::Create(), + should_not_throw); } LogUpgradeDefinition* definition = static_cast<LogUpgradeDefinition*>(Registry().DefinitionForName("a-a")); @@ -388,7 +392,8 @@ TEST_F(CustomElementRegistryTest, adoptedCallback) { NonThrowableExceptionState should_not_throw; { CEReactionsScope reactions; - Define("a-a", builder, ElementDefinitionOptions(), should_not_throw); + Define("a-a", builder, ElementDefinitionOptions::Create(), + should_not_throw); } LogUpgradeDefinition* definition = static_cast<LogUpgradeDefinition*>(Registry().DefinitionForName("a-a")); @@ -417,10 +422,10 @@ TEST_F(CustomElementRegistryTest, adoptedCallback) { TEST_F(CustomElementRegistryTest, lookupCustomElementDefinition) { NonThrowableExceptionState should_not_throw; TestCustomElementDefinitionBuilder builder; - CustomElementDefinition* definition_a = - Define("a-a", builder, ElementDefinitionOptions(), should_not_throw); - ElementDefinitionOptions options; - options.setExtends("div"); + CustomElementDefinition* definition_a = Define( + "a-a", builder, ElementDefinitionOptions::Create(), should_not_throw); + ElementDefinitionOptions* options = ElementDefinitionOptions::Create(); + options->setExtends("div"); CustomElementDefinition* definition_b = Define("b-b", builder, options, should_not_throw); // look up defined autonomous custom element @@ -451,8 +456,8 @@ TEST_F(CustomElementRegistryTest, DefineEmbedderCustomElements) { NonThrowableExceptionState should_not_throw; TestCustomElementDefinitionBuilder builder; CustomElementDefinition* definition_embedder = - Define("embeddercustomelement", builder, ElementDefinitionOptions(), - should_not_throw); + Define("embeddercustomelement", builder, + ElementDefinitionOptions::Create(), should_not_throw); CustomElementDefinition* definition = Registry().DefinitionFor(CustomElementDescriptor( "embeddercustomelement", "embeddercustomelement")); @@ -473,8 +478,8 @@ TEST_F(CustomElementRegistryTest, DisallowedEmbedderCustomElements) { TestCustomElementDefinitionBuilder builder; CustomElementDefinition* definition_embedder = - Define("embeddercustomelement", builder, ElementDefinitionOptions(), - IGNORE_EXCEPTION_FOR_TESTING); + Define("embeddercustomelement", builder, + ElementDefinitionOptions::Create(), IGNORE_EXCEPTION_FOR_TESTING); CustomElementDefinition* definition = Registry().DefinitionFor(CustomElementDescriptor( "embeddercustomelement", "embeddercustomelement")); diff --git a/chromium/third_party/blink/renderer/core/html/custom/custom_element_test.cc b/chromium/third_party/blink/renderer/core/html/custom/custom_element_test.cc index 97f0af76e0b..349c7931623 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/custom_element_test.cc +++ b/chromium/third_party/blink/renderer/core/html/custom/custom_element_test.cc @@ -199,12 +199,12 @@ TEST(CustomElementTest, StateByCreateElement) { EXPECT_EQ(data.state, element->GetCustomElementState()) << data.name; EXPECT_EQ(data.v0state, element->GetV0CustomElementState()) << data.name; - element = document.createElementNS(HTMLNames::xhtmlNamespaceURI, data.name, + element = document.createElementNS(html_names::xhtmlNamespaceURI, data.name, ASSERT_NO_EXCEPTION); EXPECT_EQ(data.state, element->GetCustomElementState()) << data.name; EXPECT_EQ(data.v0state, element->GetV0CustomElementState()) << data.name; - element = document.createElementNS(SVGNames::svgNamespaceURI, data.name, + element = document.createElementNS(svg_names::kNamespaceURI, data.name, ASSERT_NO_EXCEPTION); EXPECT_EQ(CustomElementState::kUncustomized, element->GetCustomElementState()) @@ -225,7 +225,8 @@ TEST(CustomElementTest, CEReactionsScope reactions; TestCustomElementDefinitionBuilder builder; registry->DefineInternal(script_state, "a-a", builder, - ElementDefinitionOptions(), should_not_throw); + ElementDefinitionOptions::Create(), + should_not_throw); } CustomElementDefinition* definition = registry->DefinitionFor(CustomElementDescriptor("a-a", "a-a")); diff --git a/chromium/third_party/blink/renderer/core/html/custom/custom_element_test_helpers.cc b/chromium/third_party/blink/renderer/core/html/custom/custom_element_test_helpers.cc index 37ee736cf49..87b6f04aa50 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/custom_element_test_helpers.cc +++ b/chromium/third_party/blink/renderer/core/html/custom/custom_element_test_helpers.cc @@ -9,7 +9,7 @@ namespace blink { CustomElementDefinition* TestCustomElementDefinitionBuilder::Build( const CustomElementDescriptor& descriptor, CustomElementDefinition::Id) { - return new TestCustomElementDefinition(descriptor); + return MakeGarbageCollected<TestCustomElementDefinition>(descriptor); } } // namespace blink diff --git a/chromium/third_party/blink/renderer/core/html/custom/custom_element_test_helpers.h b/chromium/third_party/blink/renderer/core/html/custom/custom_element_test_helpers.h index 97d6c590de2..9f6b8183ad8 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/custom_element_test_helpers.h +++ b/chromium/third_party/blink/renderer/core/html/custom/custom_element_test_helpers.h @@ -49,9 +49,12 @@ class TestCustomElementDefinition : public CustomElementDefinition { : CustomElementDefinition(descriptor) {} TestCustomElementDefinition(const CustomElementDescriptor& descriptor, - HashSet<AtomicString>&& observed_attributes) + HashSet<AtomicString>&& observed_attributes, + const Vector<String>& disabled_features) : CustomElementDefinition(descriptor, - std::move(observed_attributes)) {} + std::move(observed_attributes), + disabled_features, + FormAssociationFlag::kNo) {} ~TestCustomElementDefinition() override = default; @@ -74,6 +77,8 @@ class TestCustomElementDefinition : public CustomElementDefinition { bool HasConnectedCallback() const override { return false; } bool HasDisconnectedCallback() const override { return false; } bool HasAdoptedCallback() const override { return false; } + bool HasFormAssociatedCallback() const override { return false; } + bool HasDisabledStateChangedCallback() const override { return false; } void RunConnectedCallback(Element*) override { NOTREACHED() << "definition does not have connected callback"; @@ -95,6 +100,14 @@ class TestCustomElementDefinition : public CustomElementDefinition { const AtomicString& new_value) override { NOTREACHED() << "definition does not have attribute changed callback"; } + void RunFormAssociatedCallback(Element* element, + HTMLFormElement* nullable_form) override { + NOTREACHED() << "definition does not have formAssociatedCallback"; + } + void RunDisabledStateChangedCallback(Element* element, + bool is_disabled) override { + NOTREACHED() << "definition does not have disabledStateChangedCallback"; + } DISALLOW_COPY_AND_ASSIGN(TestCustomElementDefinition); }; @@ -104,7 +117,8 @@ class CreateElement { public: CreateElement(const AtomicString& local_name) - : namespace_uri_(HTMLNames::xhtmlNamespaceURI), local_name_(local_name) {} + : namespace_uri_(html_names::xhtmlNamespaceURI), + local_name_(local_name) {} CreateElement& InDocument(Document* document) { document_ = document; @@ -117,7 +131,7 @@ class CreateElement { } CreateElement& WithId(const AtomicString& id) { - attributes_.push_back(std::make_pair(HTMLNames::idAttr, id)); + attributes_.push_back(std::make_pair(html_names::kIdAttr, id)); return *this; } diff --git a/chromium/third_party/blink/renderer/core/html/custom/custom_element_upgrade_sorter.cc b/chromium/third_party/blink/renderer/core/html/custom/custom_element_upgrade_sorter.cc index 8c2d88e956a..0e045400c20 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/custom_element_upgrade_sorter.cc +++ b/chromium/third_party/blink/renderer/core/html/custom/custom_element_upgrade_sorter.cc @@ -15,8 +15,8 @@ namespace blink { CustomElementUpgradeSorter::CustomElementUpgradeSorter() - : elements_(new HeapHashSet<Member<Element>>()), - parent_child_map_(new ParentChildMap()) {} + : elements_(MakeGarbageCollected<HeapHashSet<Member<Element>>>()), + parent_child_map_(MakeGarbageCollected<ParentChildMap>()) {} static HTMLLinkElement* GetLinkElementForImport(const Document& import) { if (HTMLImportLoader* loader = import.ImportLoader()) @@ -33,7 +33,7 @@ CustomElementUpgradeSorter::AddToParentChildMap(Node* parent, Node* child) { return kParentAlreadyExistsInMap; } - ChildSet* child_set = new ChildSet(); + ChildSet* child_set = MakeGarbageCollected<ChildSet>(); child_set->insert(child); result.stored_value->value = child_set; return kParentAddedToMap; diff --git a/chromium/third_party/blink/renderer/core/html/custom/custom_element_upgrade_sorter_test.cc b/chromium/third_party/blink/renderer/core/html/custom/custom_element_upgrade_sorter_test.cc index 431aa916d10..93808872260 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/custom_element_upgrade_sorter_test.cc +++ b/chromium/third_party/blink/renderer/core/html/custom/custom_element_upgrade_sorter_test.cc @@ -6,7 +6,7 @@ #include <memory> #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/blink/renderer/bindings/core/v8/string_or_dictionary.h" +#include "third_party/blink/renderer/bindings/core/v8/string_or_element_creation_options.h" #include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h" #include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/dom/element.h" @@ -28,8 +28,8 @@ class CustomElementUpgradeSorterTest : public PageTestBase { Element* CreateElementWithId(const char* local_name, const char* id) { NonThrowableExceptionState no_exceptions; Element* element = GetDocument().CreateElementForBinding( - local_name, StringOrDictionary(), no_exceptions); - element->setAttribute(HTMLNames::idAttr, id); + local_name, StringOrElementCreationOptions(), no_exceptions); + element->setAttribute(html_names::kIdAttr, id); return element; } @@ -41,7 +41,7 @@ class CustomElementUpgradeSorterTest : public PageTestBase { TEST_F(CustomElementUpgradeSorterTest, inOtherDocument_notInSet) { NonThrowableExceptionState no_exceptions; Element* element = GetDocument().CreateElementForBinding( - "a-a", StringOrDictionary(), no_exceptions); + "a-a", StringOrElementCreationOptions(), no_exceptions); Document* other_document = HTMLDocument::CreateForTest(); other_document->AppendChild(element); @@ -60,7 +60,7 @@ TEST_F(CustomElementUpgradeSorterTest, inOtherDocument_notInSet) { TEST_F(CustomElementUpgradeSorterTest, oneCandidate) { NonThrowableExceptionState no_exceptions; Element* element = GetDocument().CreateElementForBinding( - "a-a", StringOrDictionary(), no_exceptions); + "a-a", StringOrElementCreationOptions(), no_exceptions); GetDocument().documentElement()->AppendChild(element); CustomElementUpgradeSorter sorter; diff --git a/chromium/third_party/blink/renderer/core/html/custom/element_internals.cc b/chromium/third_party/blink/renderer/core/html/custom/element_internals.cc new file mode 100644 index 00000000000..3d14c75c849 --- /dev/null +++ b/chromium/third_party/blink/renderer/core/html/custom/element_internals.cc @@ -0,0 +1,117 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "third_party/blink/renderer/core/html/custom/element_internals.h" + +#include "third_party/blink/renderer/core/dom/node_lists_node_data.h" +#include "third_party/blink/renderer/core/fileapi/file.h" +#include "third_party/blink/renderer/core/html/custom/custom_element.h" +#include "third_party/blink/renderer/core/html/forms/form_data.h" +#include "third_party/blink/renderer/core/html/forms/html_form_element.h" +#include "third_party/blink/renderer/core/html/html_element.h" + +namespace blink { + +ElementInternals::ElementInternals(HTMLElement& target) : target_(target) { + value_.SetUSVString(String()); +} + +void ElementInternals::Trace(Visitor* visitor) { + visitor->Trace(target_); + visitor->Trace(value_); + visitor->Trace(entry_source_); + ListedElement::Trace(visitor); + ScriptWrappable::Trace(visitor); +} + +void ElementInternals::setFormValue(const FileOrUSVString& value, + ExceptionState& exception_state) { + setFormValue(value, nullptr, exception_state); +} + +void ElementInternals::setFormValue(const FileOrUSVString& value, + FormData* entry_source, + ExceptionState& exception_state) { + if (!Target().IsFormAssociatedCustomElement()) { + exception_state.ThrowDOMException( + DOMExceptionCode::kInvalidStateError, + "The target element is not a form-associated custom element."); + return; + } + if (!entry_source || entry_source->size() == 0u) { + value_ = value; + entry_source_ = nullptr; + return; + } + value_ = value; + entry_source_ = MakeGarbageCollected<FormData>(*entry_source); +} + +HTMLFormElement* ElementInternals::form(ExceptionState& exception_state) const { + if (!Target().IsFormAssociatedCustomElement()) { + exception_state.ThrowDOMException( + DOMExceptionCode::kInvalidStateError, + "The target element is not a form-associated custom element."); + return nullptr; + } + return ListedElement::Form(); +} + +void ElementInternals::DidUpgrade() { + ContainerNode* parent = Target().parentNode(); + if (!parent) + return; + InsertedInto(*parent); + if (auto* owner_form = Form()) { + if (auto* lists = owner_form->NodeLists()) + lists->InvalidateCaches(nullptr); + } + for (ContainerNode* node = parent; node; node = node->parentNode()) { + if (IsHTMLFieldSetElement(node)) { + // TODO(tkent): Invalidate only HTMLFormControlsCollections. + if (auto* lists = node->NodeLists()) + lists->InvalidateCaches(nullptr); + } + } +} + +bool ElementInternals::IsFormControlElement() const { + return false; +} + +bool ElementInternals::IsElementInternals() const { + return true; +} + +bool ElementInternals::IsEnumeratable() const { + return true; +} + +void ElementInternals::AppendToFormData(FormData& form_data) { + const AtomicString& name = Target().FastGetAttribute(html_names::kNameAttr); + if (!entry_source_ || entry_source_->size() == 0u) { + if (name.IsNull()) + return; + if (value_.IsFile()) + form_data.AppendFromElement(name, value_.GetAsFile()); + else if (value_.IsUSVString()) + form_data.AppendFromElement(name, value_.GetAsUSVString()); + else + form_data.AppendFromElement(name, g_empty_string); + return; + } + for (const auto& entry : entry_source_->Entries()) { + if (entry->isFile()) + form_data.append(entry->name(), entry->GetFile()); + else + form_data.append(entry->name(), entry->Value()); + } +} + +void ElementInternals::DidChangeForm() { + ListedElement::DidChangeForm(); + CustomElement::EnqueueFormAssociatedCallback(Target(), Form()); +} + +} // namespace blink diff --git a/chromium/third_party/blink/renderer/core/html/custom/element_internals.h b/chromium/third_party/blink/renderer/core/html/custom/element_internals.h new file mode 100644 index 00000000000..d32036402cd --- /dev/null +++ b/chromium/third_party/blink/renderer/core/html/custom/element_internals.h @@ -0,0 +1,60 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_HTML_CUSTOM_ELEMENT_INTERNALS_H_ +#define THIRD_PARTY_BLINK_RENDERER_CORE_HTML_CUSTOM_ELEMENT_INTERNALS_H_ + +#include "third_party/blink/renderer/bindings/core/v8/file_or_usv_string.h" +#include "third_party/blink/renderer/core/html/forms/listed_element.h" +#include "third_party/blink/renderer/platform/bindings/script_wrappable.h" +#include "third_party/blink/renderer/platform/wtf/casting.h" + +namespace blink { + +class HTMLElement; + +class ElementInternals : public ScriptWrappable, public ListedElement { + DEFINE_WRAPPERTYPEINFO(); + USING_GARBAGE_COLLECTED_MIXIN(ElementInternals); + + public: + ElementInternals(HTMLElement& target); + void Trace(Visitor* visitor) override; + + HTMLElement& Target() const { return *target_; } + void DidUpgrade(); + + // IDL attributes/operations + void setFormValue(const FileOrUSVString& value, + ExceptionState& exception_state); + void setFormValue(const FileOrUSVString& value, + FormData* entry_source, + ExceptionState& exception_state); + HTMLFormElement* form(ExceptionState& exception_state) const; + + private: + // ListedElement overrides: + bool IsFormControlElement() const override; + bool IsElementInternals() const override; + bool IsEnumeratable() const override; + void AppendToFormData(FormData& form_data) override; + void DidChangeForm() override; + + Member<HTMLElement> target_; + + FileOrUSVString value_; + Member<FormData> entry_source_; + + DISALLOW_COPY_AND_ASSIGN(ElementInternals); +}; + +template <> +struct DowncastTraits<ElementInternals> { + static bool AllowFrom(const ListedElement& listed_element) { + return listed_element.IsElementInternals(); + } +}; + +} // namespace blink +#endif // THIRD_PARTY_BLINK_RENDERER_CORE_HTML_CUSTOM_ELEMENT_INTERNALS_H_ diff --git a/chromium/third_party/blink/renderer/core/html/custom/element_internals.idl b/chromium/third_party/blink/renderer/core/html/custom/element_internals.idl new file mode 100644 index 00000000000..c918fba298d --- /dev/null +++ b/chromium/third_party/blink/renderer/core/html/custom/element_internals.idl @@ -0,0 +1,16 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// https://docs.google.com/document/d/1JO8puctCSpW-ZYGU8lF-h4FWRIDQNDVexzHoOQ2iQmY/edit?pli=1#heading=h.pjt9nhs3gu3k + +[ + Exposed=Window, + RuntimeEnabled=ElementInternals +] +interface ElementInternals { + // Attributes and operations for form-associated custom elements. + [RaisesException] void setFormValue(FormDataEntryValue value, optional FormData entrySource); + [RaisesException] readonly attribute HTMLFormElement? form; +}; + diff --git a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element.cc b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element.cc index 4901ae8926c..4e10b8db5ee 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element.cc +++ b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element.cc @@ -73,7 +73,7 @@ bool V0CustomElement::IsValidName(const AtomicString& name) { DEFINE_STATIC_LOCAL(Vector<AtomicString>, reserved_names, ()); if (reserved_names.IsEmpty()) { // FIXME(crbug.com/426605): We should be able to remove this. - reserved_names.push_back(MathMLNames::annotation_xmlTag.LocalName()); + reserved_names.push_back(mathml_names::kAnnotationXmlTag.LocalName()); } if (kNotFound == reserved_names.Find(name)) diff --git a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_async_import_microtask_queue.h b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_async_import_microtask_queue.h index f3476bc2e81..331eb3fd049 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_async_import_microtask_queue.h +++ b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_async_import_microtask_queue.h @@ -39,13 +39,14 @@ class V0CustomElementAsyncImportMicrotaskQueue : public V0CustomElementMicrotaskQueueBase { public: static V0CustomElementAsyncImportMicrotaskQueue* Create() { - return new V0CustomElementAsyncImportMicrotaskQueue(); + return MakeGarbageCollected<V0CustomElementAsyncImportMicrotaskQueue>(); } + V0CustomElementAsyncImportMicrotaskQueue() = default; + void Enqueue(V0CustomElementMicrotaskStep*); private: - V0CustomElementAsyncImportMicrotaskQueue() = default; void DoDispatch() override; }; diff --git a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_callback_queue.cc b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_callback_queue.cc index f7a744a580b..c4de24bce0c 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_callback_queue.cc +++ b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_callback_queue.cc @@ -36,7 +36,7 @@ namespace blink { V0CustomElementCallbackQueue* V0CustomElementCallbackQueue::Create( Element* element) { - return new V0CustomElementCallbackQueue(element); + return MakeGarbageCollected<V0CustomElementCallbackQueue>(element); } V0CustomElementCallbackQueue::V0CustomElementCallbackQueue(Element* element) diff --git a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_callback_queue.h b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_callback_queue.h index 370954e4724..529e1c09d91 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_callback_queue.h +++ b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_callback_queue.h @@ -46,6 +46,8 @@ class V0CustomElementCallbackQueue public: static V0CustomElementCallbackQueue* Create(Element*); + explicit V0CustomElementCallbackQueue(Element*); + typedef int ElementQueueId; ElementQueueId Owner() const { return owner_; } @@ -66,8 +68,6 @@ class V0CustomElementCallbackQueue void Trace(blink::Visitor*); private: - explicit V0CustomElementCallbackQueue(Element*); - Member<Element> element_; HeapVector<Member<V0CustomElementProcessingStep>> queue_; ElementQueueId owner_; diff --git a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_definition.cc b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_definition.cc index 3ac97190502..d7f446b42f0 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_definition.cc +++ b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_definition.cc @@ -35,7 +35,7 @@ namespace blink { V0CustomElementDefinition* V0CustomElementDefinition::Create( const V0CustomElementDescriptor& descriptor, V0CustomElementLifecycleCallbacks* callbacks) { - return new V0CustomElementDefinition(descriptor, callbacks); + return MakeGarbageCollected<V0CustomElementDefinition>(descriptor, callbacks); } V0CustomElementDefinition::V0CustomElementDefinition( diff --git a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_definition.h b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_definition.h index f1ece759b56..6b5806d85a3 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_definition.h +++ b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_definition.h @@ -42,6 +42,9 @@ class V0CustomElementDefinition final static V0CustomElementDefinition* Create(const V0CustomElementDescriptor&, V0CustomElementLifecycleCallbacks*); + V0CustomElementDefinition(const V0CustomElementDescriptor&, + V0CustomElementLifecycleCallbacks*); + const V0CustomElementDescriptor& Descriptor() const { return descriptor_; } V0CustomElementLifecycleCallbacks* Callbacks() const { return callbacks_.Get(); @@ -50,9 +53,6 @@ class V0CustomElementDefinition final void Trace(blink::Visitor*); private: - V0CustomElementDefinition(const V0CustomElementDescriptor&, - V0CustomElementLifecycleCallbacks*); - V0CustomElementDescriptor descriptor_; Member<V0CustomElementLifecycleCallbacks> callbacks_; }; diff --git a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_microtask_import_step.h b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_microtask_import_step.h index 3888a2f5e2c..eb152f5d3a6 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_microtask_import_step.h +++ b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_microtask_import_step.h @@ -49,9 +49,10 @@ class V0CustomElementMicrotaskImportStep final : public V0CustomElementMicrotaskStep { public: static V0CustomElementMicrotaskImportStep* Create(HTMLImportChild* import) { - return new V0CustomElementMicrotaskImportStep(import); + return MakeGarbageCollected<V0CustomElementMicrotaskImportStep>(import); } + explicit V0CustomElementMicrotaskImportStep(HTMLImportChild*); ~V0CustomElementMicrotaskImportStep() override; // API for HTML Imports @@ -61,8 +62,6 @@ class V0CustomElementMicrotaskImportStep final void Trace(blink::Visitor*) override; private: - explicit V0CustomElementMicrotaskImportStep(HTMLImportChild*); - void DidUpgradeAllCustomElements(); bool ShouldWaitForImport() const; diff --git a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_microtask_resolution_step.cc b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_microtask_resolution_step.cc index 5a0224dea7d..eed62964c73 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_microtask_resolution_step.cc +++ b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_microtask_resolution_step.cc @@ -40,8 +40,8 @@ V0CustomElementMicrotaskResolutionStep::Create( V0CustomElementRegistrationContext* context, Element* element, const V0CustomElementDescriptor& descriptor) { - return new V0CustomElementMicrotaskResolutionStep(context, element, - descriptor); + return MakeGarbageCollected<V0CustomElementMicrotaskResolutionStep>( + context, element, descriptor); } V0CustomElementMicrotaskResolutionStep::V0CustomElementMicrotaskResolutionStep( diff --git a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_microtask_resolution_step.h b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_microtask_resolution_step.h index 000de7da616..83bb565de1d 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_microtask_resolution_step.h +++ b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_microtask_resolution_step.h @@ -48,15 +48,14 @@ class V0CustomElementMicrotaskResolutionStep final Element*, const V0CustomElementDescriptor&); + V0CustomElementMicrotaskResolutionStep(V0CustomElementRegistrationContext*, + Element*, + const V0CustomElementDescriptor&); ~V0CustomElementMicrotaskResolutionStep() override; void Trace(blink::Visitor*) override; private: - V0CustomElementMicrotaskResolutionStep(V0CustomElementRegistrationContext*, - Element*, - const V0CustomElementDescriptor&); - Result Process() override; #if !defined(NDEBUG) diff --git a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_microtask_run_queue.h b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_microtask_run_queue.h index 92c4c36273d..9ac97493dd2 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_microtask_run_queue.h +++ b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_microtask_run_queue.h @@ -18,9 +18,11 @@ class V0CustomElementMicrotaskRunQueue : public GarbageCollected<V0CustomElementMicrotaskRunQueue> { public: static V0CustomElementMicrotaskRunQueue* Create() { - return new V0CustomElementMicrotaskRunQueue; + return MakeGarbageCollected<V0CustomElementMicrotaskRunQueue>(); } + V0CustomElementMicrotaskRunQueue(); + void Enqueue(HTMLImportLoader* parent_loader, V0CustomElementMicrotaskStep*, bool import_is_sync); @@ -30,8 +32,6 @@ class V0CustomElementMicrotaskRunQueue void Trace(blink::Visitor*); private: - V0CustomElementMicrotaskRunQueue(); - void Dispatch(); Member<V0CustomElementSyncMicrotaskQueue> sync_queue_; diff --git a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_observer.cc b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_observer.cc index 637440bde08..a450e7667cf 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_observer.cc +++ b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_observer.cc @@ -42,7 +42,7 @@ typedef HeapHashMap<WeakMember<Element>, Member<V0CustomElementObserver>> static ElementObserverMap& ElementObservers() { DEFINE_STATIC_LOCAL(Persistent<ElementObserverMap>, map, - (new ElementObserverMap)); + (MakeGarbageCollected<ElementObserverMap>())); return *map; } diff --git a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_registration_context.cc b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_registration_context.cc index 9fa081ea367..73ad40a0bec 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_registration_context.cc +++ b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_registration_context.cc @@ -76,9 +76,9 @@ Element* V0CustomElementRegistrationContext::CreateCustomTagElement( Element* element; - if (HTMLNames::xhtmlNamespaceURI == tag_name.NamespaceURI()) { + if (html_names::xhtmlNamespaceURI == tag_name.NamespaceURI()) { element = HTMLElement::Create(tag_name, document); - } else if (SVGNames::svgNamespaceURI == tag_name.NamespaceURI()) { + } else if (svg_names::kNamespaceURI == tag_name.NamespaceURI()) { element = SVGUnknownElement::Create(tag_name, document); } else { // XML elements are not custom elements, so return early. @@ -132,7 +132,7 @@ void V0CustomElementRegistrationContext::SetIsAttributeAndTypeExtension( const AtomicString& type) { DCHECK(element); DCHECK(!type.IsEmpty()); - element->setAttribute(HTMLNames::isAttr, type); + element->setAttribute(html_names::kIsAttr, type); SetTypeExtension(element, type); } diff --git a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_registration_context.h b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_registration_context.h index 52f2b66497f..fbdc75506d9 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_registration_context.h +++ b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_registration_context.h @@ -46,9 +46,10 @@ class V0CustomElementRegistrationContext final : public GarbageCollectedFinalized<V0CustomElementRegistrationContext> { public: static V0CustomElementRegistrationContext* Create() { - return new V0CustomElementRegistrationContext(); + return MakeGarbageCollected<V0CustomElementRegistrationContext>(); } + V0CustomElementRegistrationContext(); ~V0CustomElementRegistrationContext() = default; void DocumentWasDetached() { registry_.DocumentWasDetached(); } @@ -70,9 +71,6 @@ class V0CustomElementRegistrationContext final void Trace(blink::Visitor*); - protected: - V0CustomElementRegistrationContext(); - // Instance creation void DidGiveTypeExtension(Element*, const AtomicString& type); diff --git a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_registry.cc b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_registry.cc index 40de265ccfd..eccbfad76d2 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_registry.cc +++ b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_registry.cc @@ -73,8 +73,8 @@ V0CustomElementDefinition* V0CustomElementRegistry::RegisterElement( if (!constructor_builder->ValidateOptions(type, tag_name, exception_state)) return nullptr; - DCHECK(tag_name.NamespaceURI() == HTMLNames::xhtmlNamespaceURI || - tag_name.NamespaceURI() == SVGNames::svgNamespaceURI); + DCHECK(tag_name.NamespaceURI() == html_names::xhtmlNamespaceURI || + tag_name.NamespaceURI() == svg_names::kNamespaceURI); DCHECK(!document_was_detached_); @@ -109,7 +109,7 @@ V0CustomElementDefinition* V0CustomElementRegistry::RegisterElement( return nullptr; } - if (tag_name.NamespaceURI() == SVGNames::svgNamespaceURI) { + if (tag_name.NamespaceURI() == svg_names::kNamespaceURI) { UseCounter::Count(document, WebFeature::kV0CustomElementsRegisterSVGElement); } else { diff --git a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_scheduler.cc b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_scheduler.cc index 42c3237e97c..7a8ba361b0c 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_scheduler.cc +++ b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_scheduler.cc @@ -52,7 +52,7 @@ typedef HeapHashMap<Member<Element>, Member<V0CustomElementCallbackQueue>> static ElementCallbackQueueMap& CallbackQueues() { DEFINE_STATIC_LOCAL(Persistent<ElementCallbackQueueMap>, map, - (new ElementCallbackQueueMap)); + (MakeGarbageCollected<ElementCallbackQueueMap>())); return *map; } diff --git a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_sync_microtask_queue.h b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_sync_microtask_queue.h index 0385acf794c..ecc502b9ce0 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_sync_microtask_queue.h +++ b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_sync_microtask_queue.h @@ -13,13 +13,14 @@ class V0CustomElementSyncMicrotaskQueue : public V0CustomElementMicrotaskQueueBase { public: static V0CustomElementSyncMicrotaskQueue* Create() { - return new V0CustomElementSyncMicrotaskQueue(); + return MakeGarbageCollected<V0CustomElementSyncMicrotaskQueue>(); } + V0CustomElementSyncMicrotaskQueue() = default; + void Enqueue(V0CustomElementMicrotaskStep*); private: - V0CustomElementSyncMicrotaskQueue() = default; void DoDispatch() override; }; diff --git a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_upgrade_candidate_map.cc b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_upgrade_candidate_map.cc index 72e0c7757ed..a74a1b2ae3d 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_upgrade_candidate_map.cc +++ b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_upgrade_candidate_map.cc @@ -36,7 +36,7 @@ namespace blink { V0CustomElementUpgradeCandidateMap* V0CustomElementUpgradeCandidateMap::Create() { - return new V0CustomElementUpgradeCandidateMap(); + return MakeGarbageCollected<V0CustomElementUpgradeCandidateMap>(); } V0CustomElementUpgradeCandidateMap::~V0CustomElementUpgradeCandidateMap() = @@ -55,7 +55,8 @@ void V0CustomElementUpgradeCandidateMap::Add( unresolved_definitions_.find(descriptor); ElementSet* elements; if (it == unresolved_definitions_.end()) - elements = unresolved_definitions_.insert(descriptor, new ElementSet()) + elements = unresolved_definitions_ + .insert(descriptor, MakeGarbageCollected<ElementSet>()) .stored_value->value.Get(); else elements = it->value.Get(); diff --git a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_upgrade_candidate_map.h b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_upgrade_candidate_map.h index df4169720f4..de500414000 100644 --- a/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_upgrade_candidate_map.h +++ b/chromium/third_party/blink/renderer/core/html/custom/v0_custom_element_upgrade_candidate_map.h @@ -44,6 +44,8 @@ class V0CustomElementUpgradeCandidateMap final : public V0CustomElementObserver { public: static V0CustomElementUpgradeCandidateMap* Create(); + + V0CustomElementUpgradeCandidateMap() = default; ~V0CustomElementUpgradeCandidateMap() override; // API for V0CustomElementRegistrationContext to save and take candidates @@ -56,8 +58,6 @@ class V0CustomElementUpgradeCandidateMap final void Trace(blink::Visitor*) override; private: - V0CustomElementUpgradeCandidateMap() = default; - void ElementWasDestroyed(Element*) override; typedef HeapHashMap<WeakMember<Element>, V0CustomElementDescriptor> |