mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:37:45 +00:00
LibWeb: Rename Element::attribute to Element::deprecated_attribute
This should allow us to add a Element::attribute which returns an Optional<String>. Eventually all callers should be ported to switch from the DeprecatedString version, but in the meantime, this should allow us to port some more IDL interfaces away from DeprecatedString.
This commit is contained in:
parent
da637a527d
commit
0f6782fae6
42 changed files with 141 additions and 141 deletions
|
@ -943,7 +943,7 @@ i32 Element::default_tab_index_value() const
|
|||
// https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex
|
||||
i32 Element::tab_index() const
|
||||
{
|
||||
auto maybe_table_index = Web::HTML::parse_integer(attribute(HTML::AttributeNames::tabindex));
|
||||
auto maybe_table_index = Web::HTML::parse_integer(deprecated_attribute(HTML::AttributeNames::tabindex));
|
||||
|
||||
if (!maybe_table_index.has_value())
|
||||
return default_tab_index_value();
|
||||
|
|
|
@ -91,7 +91,7 @@ public:
|
|||
bool has_attribute_ns(DeprecatedFlyString namespace_, DeprecatedFlyString const& name) const;
|
||||
bool has_attributes() const;
|
||||
|
||||
DeprecatedString attribute(DeprecatedFlyString const& name) const { return get_attribute(name); }
|
||||
DeprecatedString deprecated_attribute(DeprecatedFlyString const& name) const { return get_attribute(name); }
|
||||
DeprecatedString get_attribute(DeprecatedFlyString const& name) const;
|
||||
DeprecatedString get_attribute_value(DeprecatedFlyString const& local_name, DeprecatedFlyString const& namespace_ = {}) const;
|
||||
|
||||
|
@ -158,7 +158,7 @@ public:
|
|||
Layout::NodeWithStyle* layout_node();
|
||||
Layout::NodeWithStyle const* layout_node() const;
|
||||
|
||||
DeprecatedString name() const { return attribute(HTML::AttributeNames::name); }
|
||||
DeprecatedString name() const { return deprecated_attribute(HTML::AttributeNames::name); }
|
||||
|
||||
CSS::StyleProperties* computed_css_values() { return m_computed_css_values.ptr(); }
|
||||
CSS::StyleProperties const* computed_css_values() const { return m_computed_css_values.ptr(); }
|
||||
|
|
|
@ -87,7 +87,7 @@ Element* HTMLCollection::named_item(FlyString const& name_) const
|
|||
auto elements = collect_matching_elements();
|
||||
// 2. Return the first element in the collection for which at least one of the following is true:
|
||||
// - it has an ID which is key;
|
||||
if (auto it = elements.find_if([&](auto& entry) { return entry->attribute(HTML::AttributeNames::id) == name; }); it != elements.end())
|
||||
if (auto it = elements.find_if([&](auto& entry) { return entry->deprecated_attribute(HTML::AttributeNames::id) == name; }); it != elements.end())
|
||||
return *it;
|
||||
// - it is in the HTML namespace and has a name attribute whose value is key;
|
||||
if (auto it = elements.find_if([&](auto& entry) { return entry->namespace_() == Namespace::HTML && entry->name() == name; }); it != elements.end())
|
||||
|
@ -108,7 +108,7 @@ Vector<DeprecatedString> HTMLCollection::supported_property_names() const
|
|||
for (auto& element : elements) {
|
||||
// 1. If element has an ID which is not in result, append element’s ID to result.
|
||||
if (element->has_attribute(HTML::AttributeNames::id)) {
|
||||
auto id = element->attribute(HTML::AttributeNames::id);
|
||||
auto id = element->deprecated_attribute(HTML::AttributeNames::id);
|
||||
|
||||
if (!result.contains_slow(id))
|
||||
result.append(id);
|
||||
|
@ -116,7 +116,7 @@ Vector<DeprecatedString> HTMLCollection::supported_property_names() const
|
|||
|
||||
// 2. If element is in the HTML namespace and has a name attribute whose value is neither the empty string nor is in result, append element’s name attribute value to result.
|
||||
if (element->namespace_() == Namespace::HTML && element->has_attribute(HTML::AttributeNames::name)) {
|
||||
auto name = element->attribute(HTML::AttributeNames::name);
|
||||
auto name = element->deprecated_attribute(HTML::AttributeNames::name);
|
||||
|
||||
if (!name.is_empty() && !result.contains_slow(name))
|
||||
result.append(name);
|
||||
|
|
|
@ -46,7 +46,7 @@ Variant<Empty, Element*, JS::Handle<RadioNodeList>> HTMLFormControlsCollection::
|
|||
|
||||
auto collection = collect_matching_elements();
|
||||
for (auto const& element : collection) {
|
||||
if (element->attribute(HTML::AttributeNames::id) != deprecated_name && element->name() != deprecated_name)
|
||||
if (element->deprecated_attribute(HTML::AttributeNames::id) != deprecated_name && element->name() != deprecated_name)
|
||||
continue;
|
||||
|
||||
if (matching_element) {
|
||||
|
@ -71,7 +71,7 @@ Variant<Empty, Element*, JS::Handle<RadioNodeList>> HTMLFormControlsCollection::
|
|||
return false;
|
||||
|
||||
auto const& element = verify_cast<Element>(node);
|
||||
return element.attribute(HTML::AttributeNames::id) == deprecated_name || element.name() == deprecated_name;
|
||||
return element.deprecated_attribute(HTML::AttributeNames::id) == deprecated_name || element.name() == deprecated_name;
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
{
|
||||
JS::GCPtr<Element const> found_element;
|
||||
static_cast<NodeType const*>(this)->template for_each_in_inclusive_subtree_of_type<Element>([&](auto& element) {
|
||||
if (element.attribute(HTML::AttributeNames::id) == id) {
|
||||
if (element.deprecated_attribute(HTML::AttributeNames::id) == id) {
|
||||
found_element = &element;
|
||||
return IterationDecision::Break;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public:
|
|||
{
|
||||
JS::GCPtr<Element> found_element;
|
||||
static_cast<NodeType*>(this)->template for_each_in_inclusive_subtree_of_type<Element>([&](auto& element) {
|
||||
if (element.attribute(HTML::AttributeNames::id) == id) {
|
||||
if (element.deprecated_attribute(HTML::AttributeNames::id) == id) {
|
||||
found_element = &element;
|
||||
return IterationDecision::Break;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ void StyleElementUtils::update_a_style_block(DOM::Element& style_element)
|
|||
return;
|
||||
|
||||
// 4. If element's type attribute is present and its value is neither the empty string nor an ASCII case-insensitive match for "text/css", then return.
|
||||
auto type_attribute = style_element.attribute(HTML::AttributeNames::type);
|
||||
auto type_attribute = style_element.deprecated_attribute(HTML::AttributeNames::type);
|
||||
if (!type_attribute.is_null() && !type_attribute.is_empty() && !Infra::is_ascii_case_insensitive_match(type_attribute, "text/css"sv))
|
||||
return;
|
||||
|
||||
|
@ -63,8 +63,8 @@ void StyleElementUtils::update_a_style_block(DOM::Element& style_element)
|
|||
style_element.document(),
|
||||
"text/css"sv,
|
||||
&style_element,
|
||||
style_element.attribute(HTML::AttributeNames::media),
|
||||
style_element.in_a_document_tree() ? style_element.attribute(HTML::AttributeNames::title) : DeprecatedString::empty(),
|
||||
style_element.deprecated_attribute(HTML::AttributeNames::media),
|
||||
style_element.in_a_document_tree() ? style_element.deprecated_attribute(HTML::AttributeNames::title) : DeprecatedString::empty(),
|
||||
false,
|
||||
true,
|
||||
{},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue