Commit 97597a97 authored by Findit's avatar Findit

Revert "document: Use ElementCreationOptions in Document.createElement()"

This reverts commit 6a1db25d.

Reason for revert:

Findit (https://goo.gl/kROfz5) identified CL at revision 608668 as the
culprit for failures in the build cycles as shown on:
https://findit-for-me.appspot.com/waterfall/culprit?key=ag9zfmZpbmRpdC1mb3ItbWVyRAsSDVdmU3VzcGVjdGVkQ0wiMWNocm9taXVtLzZhMWRiMjVkNmEzZTYzZDE5ZDM1OTFhZjg1OGY2Mzg5ZmUyM2I3ZWUM

Sample Failed Build: https://ci.chromium.org/buildbot/chromium/android-rel/4452

Sample Failed Step: compile

Original change's description:
> document: Use ElementCreationOptions in Document.createElement()
> 
> We used (DOMString or Dictionary) type for |option| parameter,
> but this CL replaces it with (DOMString or ElementCreationOpitons)
> as the spec defined.
> 
> 
> Bug: 904241
> Change-Id: I9416af83168e7c1f7456ffdbd3141fa97b510706
> Reviewed-on: https://chromium-review.googlesource.com/c/1333094
> Commit-Queue: Hitoshi Yoshida <peria@chromium.org>
> Reviewed-by: Yuki Shiino <yukishiino@chromium.org>
> Reviewed-by: Kentaro Hara <haraken@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#608668}

Change-Id: I2e851f9c54e1327f7a0b62446ac8b24c7e7371e8
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 904241
Reviewed-on: https://chromium-review.googlesource.com/c/1339360
Cr-Commit-Position: refs/heads/master@{#608672}
parent 6bb643b6
......@@ -86,8 +86,6 @@ bindings_core_generated_union_type_files = [
"$bindings_core_v8_output_dir/string_or_double.h",
"$bindings_core_v8_output_dir/string_or_double_or_performance_measure_options.cc",
"$bindings_core_v8_output_dir/string_or_double_or_performance_measure_options.h",
"$bindings_core_v8_output_dir/string_or_element_creation_options.cc",
"$bindings_core_v8_output_dir/string_or_element_creation_options.h",
"$bindings_core_v8_output_dir/string_or_string_sequence.cc",
"$bindings_core_v8_output_dir/string_or_string_sequence.h",
"$bindings_core_v8_output_dir/string_or_trusted_html.cc",
......
......@@ -384,13 +384,14 @@ static void ConstructCustomElement(
maybe_type->IsUndefined()) {
return;
}
TOSTRING_VOID(V8StringResource<kTreatNullAsNullString>, type, maybe_type);
TOSTRING_VOID(V8StringResource<>, type, maybe_type);
ExceptionState exception_state(isolate, ExceptionState::kConstructionContext,
"CustomElement");
V0CustomElementProcessingStack::CallbackDeliveryScope delivery_scope;
Element* element = document->createElementNS(
namespace_uri, tag_name, StringOrElementCreationOptions::FromString(type),
namespace_uri, tag_name,
StringOrDictionary::FromString(maybe_type->IsNull() ? g_null_atom : type),
exception_state);
if (element) {
UseCounter::Count(document, WebFeature::kV0CustomElementsConstruct);
......
......@@ -53,7 +53,7 @@
#include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
#include "third_party/blink/renderer/bindings/core/v8/script_value.h"
#include "third_party/blink/renderer/bindings/core/v8/source_location.h"
#include "third_party/blink/renderer/bindings/core/v8/string_or_element_creation_options.h"
#include "third_party/blink/renderer/bindings/core/v8/string_or_dictionary.h"
#include "third_party/blink/renderer/bindings/core/v8/usv_string_or_trusted_url.h"
#include "third_party/blink/renderer/bindings/core/v8/v0_custom_element_constructor_builder.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_element_creation_options.h"
......@@ -948,9 +948,9 @@ Element* Document::CreateElementForBinding(const AtomicString& name,
return Element::Create(QualifiedName(g_null_atom, name, g_null_atom), this);
}
AtomicString GetTypeExtension(
Document* document,
const StringOrElementCreationOptions& string_or_options) {
AtomicString GetTypeExtension(Document* document,
const StringOrDictionary& string_or_options,
ExceptionState& exception_state) {
if (string_or_options.IsNull())
return AtomicString();
......@@ -960,11 +960,12 @@ AtomicString GetTypeExtension(
return AtomicString(string_or_options.GetAsString());
}
if (string_or_options.IsElementCreationOptions()) {
const ElementCreationOptions& options =
*string_or_options.GetAsElementCreationOptions();
if (options.hasIs())
return AtomicString(options.is());
if (string_or_options.IsDictionary()) {
Dictionary dict = string_or_options.GetAsDictionary();
v8::Local<v8::Value> value;
if (dict.HasProperty("is", exception_state) && dict.Get("is", value)) {
return ToCoreAtomicString(v8::Local<v8::String>::Cast(value));
}
}
return AtomicString();
......@@ -973,7 +974,7 @@ AtomicString GetTypeExtension(
// https://dom.spec.whatwg.org/#dom-document-createelement
Element* Document::CreateElementForBinding(
const AtomicString& local_name,
const StringOrElementCreationOptions& string_or_options,
const StringOrDictionary& string_or_options,
ExceptionState& exception_state) {
if (string_or_options.IsNull()) {
return CreateElementForBinding(local_name, exception_state);
......@@ -994,14 +995,14 @@ Element* Document::CreateElementForBinding(
? html_names::xhtmlNamespaceURI
: g_null_atom);
bool is_v1 =
string_or_options.IsElementCreationOptions() || !RegistrationContext();
bool create_v1_builtin = string_or_options.IsElementCreationOptions();
bool is_v1 = string_or_options.IsDictionary() || !RegistrationContext();
bool create_v1_builtin = string_or_options.IsDictionary();
bool should_create_builtin =
create_v1_builtin || string_or_options.IsString();
// 3.
const AtomicString& is = GetTypeExtension(this, string_or_options);
const AtomicString& is =
GetTypeExtension(this, string_or_options, exception_state);
// 5. Let element be the result of creating an element given ...
Element* element =
......@@ -1056,11 +1057,10 @@ Element* Document::createElementNS(const AtomicString& namespace_uri,
}
// https://dom.spec.whatwg.org/#internal-createelementns-steps
Element* Document::createElementNS(
const AtomicString& namespace_uri,
const AtomicString& qualified_name,
const StringOrElementCreationOptions& string_or_options,
ExceptionState& exception_state) {
Element* Document::createElementNS(const AtomicString& namespace_uri,
const AtomicString& qualified_name,
const StringOrDictionary& string_or_options,
ExceptionState& exception_state) {
if (string_or_options.IsNull())
return createElementNS(namespace_uri, qualified_name, exception_state);
......@@ -1070,14 +1070,14 @@ Element* Document::createElementNS(
if (q_name == QualifiedName::Null())
return nullptr;
bool is_v1 =
string_or_options.IsElementCreationOptions() || !RegistrationContext();
bool create_v1_builtin = string_or_options.IsElementCreationOptions();
bool is_v1 = string_or_options.IsDictionary() || !RegistrationContext();
bool create_v1_builtin = string_or_options.IsDictionary();
bool should_create_builtin =
create_v1_builtin || string_or_options.IsString();
// 2.
const AtomicString& is = GetTypeExtension(this, string_or_options);
const AtomicString& is =
GetTypeExtension(this, string_or_options, exception_state);
if (!IsValidElementName(this, qualified_name)) {
exception_state.ThrowDOMException(DOMExceptionCode::kInvalidCharacterError,
......
......@@ -180,7 +180,7 @@ class SerializedScriptValue;
class Settings;
class SlotAssignmentEngine;
class SnapCoordinator;
class StringOrElementCreationOptions;
class StringOrDictionary;
class StyleEngine;
class StyleResolver;
class StylePropertyMapReadOnly;
......@@ -321,14 +321,14 @@ class CORE_EXPORT Document : public ContainerNode,
Element* CreateElementForBinding(const AtomicString& local_name,
ExceptionState& = ASSERT_NO_EXCEPTION);
Element* CreateElementForBinding(const AtomicString& local_name,
const StringOrElementCreationOptions&,
const StringOrDictionary&,
ExceptionState&);
Element* createElementNS(const AtomicString& namespace_uri,
const AtomicString& qualified_name,
ExceptionState&);
Element* createElementNS(const AtomicString& namespace_uri,
const AtomicString& qualified_name,
const StringOrElementCreationOptions&,
const StringOrDictionary&,
ExceptionState&);
DocumentFragment* createDocumentFragment();
Text* createTextNode(const String& data);
......
......@@ -176,8 +176,9 @@ typedef (HTMLScriptElement or SVGScriptElement) HTMLOrSVGScriptElement;
// FIXME: The registerElement return type should be Function.
[RuntimeEnabled=CustomElementsV0, CallWith=ScriptState, CustomElementCallbacks, RaisesException, DeprecateAs=DocumentRegisterElement] any registerElement(DOMString type, optional ElementRegistrationOptions options);
// https://w3c.github.io/webcomponents/spec/custom/#extensions-to-document-interface-to-instantiate
[CustomElementCallbacks, PerWorldBindings, RaisesException, ImplementedAs=CreateElementForBinding] Element createElement(DOMString localName, (DOMString or ElementCreationOptions) options);
[CustomElementCallbacks, RaisesException] Element createElementNS(DOMString? namespaceURI, DOMString qualifiedName, (DOMString or ElementCreationOptions) options);
// FIXME: The typeExtension arguments should not be nullable.
[CustomElementCallbacks, PerWorldBindings, RaisesException, ImplementedAs=CreateElementForBinding] Element createElement(DOMString localName, (DOMString or Dictionary)? options);
[CustomElementCallbacks, RaisesException] Element createElementNS(DOMString? namespaceURI, DOMString qualifiedName, (DOMString or Dictionary)? options);
// Page Visibility
// https://w3c.github.io/page-visibility/#extensions-to-the-document-interface
......
......@@ -6,7 +6,7 @@
#include <memory>
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/bindings/core/v8/string_or_element_creation_options.h"
#include "third_party/blink/renderer/bindings/core/v8/string_or_dictionary.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,7 +28,7 @@ class CustomElementUpgradeSorterTest : public PageTestBase {
Element* CreateElementWithId(const char* local_name, const char* id) {
NonThrowableExceptionState no_exceptions;
Element* element = GetDocument().CreateElementForBinding(
local_name, StringOrElementCreationOptions(), no_exceptions);
local_name, StringOrDictionary(), 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", StringOrElementCreationOptions(), no_exceptions);
"a-a", StringOrDictionary(), 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", StringOrElementCreationOptions(), no_exceptions);
"a-a", StringOrDictionary(), no_exceptions);
GetDocument().documentElement()->AppendChild(element);
CustomElementUpgradeSorter sorter;
......
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