|
From 01acb284c72128f7681a502757165048fe29bb7d Mon Sep 17 00:00:00 2001 |
|
From: Kaleidea |
|
Subject: [PATCH 1/2] [wip-draft] Add <search> element as an alias for <form>: `interfaceName=HTMLFormElement` |
|
|
|
<search> has the same functionality as <form> at this stage. |
|
|
|
html_tag_names.json5: |
|
- generates HTMLFormElement constructor wrapper for HTMLElementFactory::createHTMLElement() |
|
|
|
HTMLFormElement::create(): |
|
- add `const QualifiedName& tag_name` parameter to distinguish between <form> and <search>. |
|
|
|
replace_selection_command.cc::IsProhibitedParagraphChild(), |
|
DocumentAllNameCollection::ElementMatches(), |
|
html_collection.cc::NameShouldBeVisibleInDocumentAll(), |
|
HTMLStackItem::IsSpecialNode(): |
|
- add <search> |
|
|
|
document_statistics_collector.cc::CollectFeatures(), |
|
HTMLTreeBuilder, |
|
AXNodeObject::determineAccessibilityRoleUtil(): |
|
- add <search> besides <form> |
|
--- |
|
.../renderer/core/dom/document_statistics_collector.cc | 3 ++- |
|
.../core/editing/commands/replace_selection_command.cc | 1 + |
|
.../renderer/core/html/document_all_name_collection.cc | 1 + |
|
.../blink/renderer/core/html/forms/html_form_element.cc | 4 ++-- |
|
.../blink/renderer/core/html/forms/html_form_element.h | 2 +- |
|
third_party/blink/renderer/core/html/html_collection.cc | 1 + |
|
.../blink/renderer/core/html/html_tag_names.json5 | 5 +++++ |
|
.../blink/renderer/core/html/parser/html_stack_item.h | 1 + |
|
.../blink/renderer/core/html/parser/html_tree_builder.cc | 9 ++++++--- |
|
.../renderer/modules/accessibility/ax_node_object.cc | 3 +++ |
|
10 files changed, 23 insertions(+), 7 deletions(-) |
|
|
|
diff --git a/third_party/blink/renderer/core/dom/document_statistics_collector.cc b/third_party/blink/renderer/core/dom/document_statistics_collector.cc |
|
index 0c15543566..e96f9ab940 100644 |
|
--- a/third_party/blink/renderer/core/dom/document_statistics_collector.cc |
|
+++ b/third_party/blink/renderer/core/dom/document_statistics_collector.cc |
|
@@ -121,7 +121,8 @@ void CollectFeatures(Element& root, |
|
features.element_count++; |
|
if (element.HasTagName(html_names::kATag)) { |
|
features.anchor_count++; |
|
- } else if (element.HasTagName(html_names::kFormTag)) { |
|
+ } else if (element.HasTagName(html_names::kFormTag) || |
|
+ element.HasTagName(html_names::kSearchTag)) { |
|
features.form_count++; |
|
} else if (element.HasTagName(html_names::kInputTag)) { |
|
const auto& input = To<HTMLInputElement>(element); |
|
diff --git a/third_party/blink/renderer/core/editing/commands/replace_selection_command.cc b/third_party/blink/renderer/core/editing/commands/replace_selection_command.cc |
|
index 3c0090fcd3..58b734904e 100644 |
|
--- a/third_party/blink/renderer/core/editing/commands/replace_selection_command.cc |
|
+++ b/third_party/blink/renderer/core/editing/commands/replace_selection_command.cc |
|
@@ -703,6 +703,7 @@ static bool IsProhibitedParagraphChild(const AtomicString& name) { |
|
html_names::kPTag.LocalName(), |
|
html_names::kPlaintextTag.LocalName(), |
|
html_names::kPreTag.LocalName(), |
|
+ html_names::kSearchTag.LocalName(), |
|
html_names::kSectionTag.LocalName(), |
|
html_names::kSummaryTag.LocalName(), |
|
html_names::kTableTag.LocalName(), |
|
diff --git a/third_party/blink/renderer/core/html/document_all_name_collection.cc b/third_party/blink/renderer/core/html/document_all_name_collection.cc |
|
index 195714c7a7..207b121640 100644 |
|
--- a/third_party/blink/renderer/core/html/document_all_name_collection.cc |
|
+++ b/third_party/blink/renderer/core/html/document_all_name_collection.cc |
|
@@ -33,6 +33,7 @@ bool DocumentAllNameCollection::ElementMatches(const Element& element) const { |
|
element.HasTagName(html_names::kMapTag) || |
|
element.HasTagName(html_names::kMetaTag) || |
|
element.HasTagName(html_names::kObjectTag) || |
|
+ element.HasTagName(html_names::kSearchTag) || |
|
element.HasTagName(html_names::kSelectTag) || |
|
element.HasTagName(html_names::kTextareaTag)) { |
|
if (element.GetNameAttribute() == name_) |
|
diff --git a/third_party/blink/renderer/core/html/forms/html_form_element.cc b/third_party/blink/renderer/core/html/forms/html_form_element.cc |
|
index 95e322da5a..379d039eee 100644 |
|
--- a/third_party/blink/renderer/core/html/forms/html_form_element.cc |
|
+++ b/third_party/blink/renderer/core/html/forms/html_form_element.cc |
|
@@ -90,8 +90,8 @@ bool HasFormInBetween(const Node* root, const Node* descendant) { |
|
|
|
} // namespace |
|
|
|
-HTMLFormElement::HTMLFormElement(Document& document) |
|
- : HTMLElement(html_names::kFormTag, document), |
|
+HTMLFormElement::HTMLFormElement(const QualifiedName& tag_name, Document& document) |
|
+ : HTMLElement(tag_name, document), |
|
listed_elements_are_dirty_(false), |
|
listed_elements_including_shadow_trees_are_dirty_(false), |
|
image_elements_are_dirty_(false), |
|
diff --git a/third_party/blink/renderer/core/html/forms/html_form_element.h b/third_party/blink/renderer/core/html/forms/html_form_element.h |
|
index 0c149bbd0d..8f7a27c9dd 100644 |
|
--- a/third_party/blink/renderer/core/html/forms/html_form_element.h |
|
+++ b/third_party/blink/renderer/core/html/forms/html_form_element.h |
|
@@ -44,7 +44,7 @@ class CORE_EXPORT HTMLFormElement final : public HTMLElement { |
|
DEFINE_WRAPPERTYPEINFO(); |
|
|
|
public: |
|
- explicit HTMLFormElement(Document&); |
|
+ explicit HTMLFormElement(const QualifiedName& tag_name, Document&); |
|
~HTMLFormElement() override; |
|
void Trace(Visitor*) const override; |
|
|
|
diff --git a/third_party/blink/renderer/core/html/html_collection.cc b/third_party/blink/renderer/core/html/html_collection.cc |
|
index d839a92aa4..6ecd9f4da1 100644 |
|
--- a/third_party/blink/renderer/core/html/html_collection.cc |
|
+++ b/third_party/blink/renderer/core/html/html_collection.cc |
|
@@ -345,6 +345,7 @@ static inline bool NameShouldBeVisibleInDocumentAll( |
|
element.HasTagName(html_names::kMapTag) || |
|
element.HasTagName(html_names::kMetaTag) || |
|
element.HasTagName(html_names::kObjectTag) || |
|
+ element.HasTagName(html_names::kSearchTag) || |
|
element.HasTagName(html_names::kSelectTag) || |
|
element.HasTagName(html_names::kTextareaTag); |
|
} |
|
diff --git a/third_party/blink/renderer/core/html/html_tag_names.json5 b/third_party/blink/renderer/core/html/html_tag_names.json5 |
|
index 8961b0a80a..ed8eaf96f4 100644 |
|
--- a/third_party/blink/renderer/core/html/html_tag_names.json5 |
|
+++ b/third_party/blink/renderer/core/html/html_tag_names.json5 |
|
@@ -416,6 +416,11 @@ |
|
name: "script", |
|
constructorNeedsCreateElementFlags: true, |
|
}, |
|
+ { |
|
+ name: "search", |
|
+ interfaceName: "HTMLFormElement", |
|
+ interfaceHeaderDir: "third_party/blink/renderer/core/html/forms", |
|
+ }, |
|
{ |
|
name: "section", |
|
interfaceName: "HTMLElement", |
|
diff --git a/third_party/blink/renderer/core/html/parser/html_stack_item.h b/third_party/blink/renderer/core/html/parser/html_stack_item.h |
|
index 9fcf4500e5..8fca84b1bf 100644 |
|
--- a/third_party/blink/renderer/core/html/parser/html_stack_item.h |
|
+++ b/third_party/blink/renderer/core/html/parser/html_stack_item.h |
|
@@ -191,6 +191,7 @@ class HTMLStackItem final : public GarbageCollected<HTMLStackItem> { |
|
tag_name == html_names::kPlaintextTag || |
|
tag_name == html_names::kPreTag || |
|
tag_name == html_names::kScriptTag || |
|
+ tag_name == html_names::kSearchTag || |
|
tag_name == html_names::kSectionTag || |
|
tag_name == html_names::kSelectTag || |
|
tag_name == html_names::kStyleTag || |
|
diff --git a/third_party/blink/renderer/core/html/parser/html_tree_builder.cc b/third_party/blink/renderer/core/html/parser/html_tree_builder.cc |
|
index e4293630c1..46fc8e2f40 100644 |
|
--- a/third_party/blink/renderer/core/html/parser/html_tree_builder.cc |
|
+++ b/third_party/blink/renderer/core/html/parser/html_tree_builder.cc |
|
@@ -662,7 +662,8 @@ void HTMLTreeBuilder::ProcessStartTagForInBody(AtomicHTMLToken* token) { |
|
frameset_ok_ = false; |
|
return; |
|
} |
|
- if (token->GetName() == html_names::kFormTag) { |
|
+ if (token->GetName() == html_names::kFormTag || |
|
+ token->GetName() == html_names::kSearchTag) { |
|
if (tree_.IsFormElementPointerNonNull() && !IsParsingTemplateContents()) { |
|
ParseError(token); |
|
UseCounter::Count(tree_.CurrentNode()->GetDocument(), |
|
@@ -1111,7 +1112,8 @@ void HTMLTreeBuilder::ProcessStartTagForInTable(AtomicHTMLToken* token) { |
|
} |
|
// Fall through to "anything else" case. |
|
} |
|
- if (token->GetName() == html_names::kFormTag) { |
|
+ if (token->GetName() == html_names::kFormTag|| |
|
+ token->GetName() == html_names::kSearchTag) { |
|
ParseError(token); |
|
if (tree_.IsFormElementPointerNonNull() && !IsParsingTemplateContents()) |
|
return; |
|
@@ -1900,7 +1902,8 @@ void HTMLTreeBuilder::ProcessEndTagForInBody(AtomicHTMLToken* token) { |
|
tree_.OpenElements()->PopUntilPopped(token->GetName()); |
|
return; |
|
} |
|
- if (token->GetName() == html_names::kFormTag && |
|
+ if ((token->GetName() == html_names::kFormTag || |
|
+ token->GetName() == html_names::kSearchTag) && |
|
!IsParsingTemplateContents()) { |
|
Element* node = tree_.TakeForm(); |
|
if (!node || !tree_.OpenElements()->InScope(node)) { |
|
diff --git a/third_party/blink/renderer/modules/accessibility/ax_node_object.cc b/third_party/blink/renderer/modules/accessibility/ax_node_object.cc |
|
index ab85a9e82d..8166b3f660 100644 |
|
--- a/third_party/blink/renderer/modules/accessibility/ax_node_object.cc |
|
+++ b/third_party/blink/renderer/modules/accessibility/ax_node_object.cc |
|
@@ -1160,6 +1160,9 @@ ax::mojom::blink::Role AXNodeObject::NativeRoleIgnoringAria() const { |
|
} |
|
|
|
if (IsA<HTMLFormElement>(*GetNode())) { |
|
+ if (GetNode()->HasTagName(html_names::kSearchTag)) |
|
+ return ax::mojom::blink::Role::kSearch; |
|
+ |
|
// Only treat <form> as role="form" when it has an accessible name, which |
|
// can only occur when the name is assigned by the author via aria-label, |
|
// aria-labelledby, or title. Otherwise, treat as a <section>. |
|
-- |