LibWeb: Add a FlyString version of Element::tag_name
Renaming the DeprecatedString version of this function to deprecated_tag_name. A FlyString is used here as we often need to perform equality checks here, and the HTMLParser already has tag_name as a FlyString. Remove a FIXME while we're at it - we were already following the spec there, and we still are :^)
This commit is contained in:
parent
9303e9e76f
commit
ff72436448
Notes:
sideshowbarker
2024-07-16 18:26:46 +09:00
Author: https://github.com/shannonbooth Commit: https://github.com/SerenityOS/serenity/commit/ff72436448 Pull-request: https://github.com/SerenityOS/serenity/pull/21306
4 changed files with 9 additions and 8 deletions
|
@ -82,7 +82,8 @@ public:
|
|||
FlyString const& local_name() const { return m_qualified_name.local_name(); }
|
||||
|
||||
// NOTE: This is for the JS bindings
|
||||
DeprecatedString const& tag_name() const { return html_uppercased_qualified_name(); }
|
||||
FlyString tag_name() const { return MUST(FlyString::from_deprecated_fly_string(html_uppercased_qualified_name())); }
|
||||
DeprecatedString const& deprecated_tag_name() const { return html_uppercased_qualified_name(); }
|
||||
|
||||
Optional<FlyString> const& prefix() const { return m_qualified_name.prefix(); }
|
||||
DeprecatedFlyString deprecated_prefix() const { return m_qualified_name.deprecated_prefix(); }
|
||||
|
|
|
@ -26,7 +26,7 @@ interface Element : Node {
|
|||
readonly attribute DOMString? namespaceURI;
|
||||
[ImplementedAs=deprecated_prefix] readonly attribute DOMString? prefix;
|
||||
[ImplementedAs=deprecated_local_name] readonly attribute DOMString localName;
|
||||
readonly attribute DOMString tagName;
|
||||
[ImplementedAs=deprecated_tag_name] readonly attribute DOMString tagName;
|
||||
|
||||
[ImplementedAs=deprecated_get_attribute] DOMString? getAttribute(DOMString qualifiedName);
|
||||
[CEReactions] undefined setAttribute(DOMString qualifiedName, DOMString value);
|
||||
|
|
|
@ -3531,7 +3531,7 @@ void HTMLParser::process_using_the_rules_for_foreign_content(HTMLToken& token)
|
|||
}
|
||||
|
||||
// -> An end tag whose tag name is "script", if the current node is an SVG script element
|
||||
if (token.is_end_tag() && current_node().namespace_() == Namespace::SVG && current_node().tag_name() == SVG::TagNames::script) {
|
||||
if (token.is_end_tag() && current_node().namespace_() == Namespace::SVG && current_node().tag_name().to_deprecated_fly_string() == SVG::TagNames::script) {
|
||||
ScriptEndTag:
|
||||
// Pop the current node off the stack of open elements.
|
||||
(void)m_stack_of_open_elements.pop();
|
||||
|
@ -3562,9 +3562,9 @@ void HTMLParser::process_using_the_rules_for_foreign_content(HTMLToken& token)
|
|||
if (token.is_end_tag()) {
|
||||
// 1. Initialize node to be the current node (the bottommost node of the stack).
|
||||
JS::GCPtr<DOM::Element> node = current_node();
|
||||
// FIXME: Not sure if this is the correct to_lowercase, as the specification says "to ASCII lowercase"
|
||||
|
||||
// 2. If node's tag name, converted to ASCII lowercase, is not the same as the tag name of the token, then this is a parse error.
|
||||
if (node->tag_name().to_lowercase() != token.tag_name().to_deprecated_fly_string())
|
||||
if (node->tag_name().equals_ignoring_ascii_case(token.tag_name()))
|
||||
log_parse_error();
|
||||
|
||||
// 3. Loop: If node is the topmost element in the stack of open elements, then return. (fragment case)
|
||||
|
@ -3573,10 +3573,10 @@ void HTMLParser::process_using_the_rules_for_foreign_content(HTMLToken& token)
|
|||
VERIFY(m_parsing_fragment);
|
||||
return;
|
||||
}
|
||||
// FIXME: See the above FIXME
|
||||
|
||||
// 4. If node's tag name, converted to ASCII lowercase, is the same as the tag name of the token, pop elements from the stack
|
||||
// of open elements until node has been popped from the stack, and then return.
|
||||
if (node->tag_name().to_lowercase() == token.tag_name().to_deprecated_fly_string()) {
|
||||
if (node->tag_name().equals_ignoring_ascii_case(token.tag_name())) {
|
||||
while (¤t_node() != node.ptr())
|
||||
(void)m_stack_of_open_elements.pop();
|
||||
(void)m_stack_of_open_elements.pop();
|
||||
|
|
|
@ -1183,7 +1183,7 @@ Messages::WebDriverClient::GetElementTagNameResponse WebDriverConnection::get_el
|
|||
auto qualified_name = element->tag_name();
|
||||
|
||||
// 5. Return success with data qualified name.
|
||||
return qualified_name;
|
||||
return MUST(JsonValue::from_string(qualified_name));
|
||||
}
|
||||
|
||||
// 12.4.7 Get Element Rect, https://w3c.github.io/webdriver/#dfn-get-element-rect
|
||||
|
|
Loading…
Add table
Reference in a new issue