mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:07:36 +00:00
LibWeb: Add a non-DeprecatedString version of Element::get_attribute
Renaming the DeprecatedString version of this function to Element::get_deprecated_attribute. While performing this rename, port over functions where it is trivial to do so to the Optional<String> version of this function.
This commit is contained in:
parent
ebe01b51c8
commit
50350fb79c
17 changed files with 52 additions and 56 deletions
|
@ -394,7 +394,7 @@ static bool is_form_control(DOM::Element const& element)
|
|||
}
|
||||
|
||||
if (is<HTMLInputElement>(element)
|
||||
&& !element.get_attribute(HTML::AttributeNames::type).equals_ignoring_ascii_case("image"sv)) {
|
||||
&& !element.deprecated_get_attribute(HTML::AttributeNames::type).equals_ignoring_ascii_case("image"sv)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
virtual DeprecatedString aria_level() const override
|
||||
{
|
||||
// TODO: aria-level = the number in the element's tag name
|
||||
return get_attribute("aria-level"sv);
|
||||
return deprecated_get_attribute("aria-level"sv);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -90,7 +90,7 @@ void HTMLIFrameElement::process_the_iframe_attributes(bool initial_insertion)
|
|||
}
|
||||
|
||||
// 3. Navigate to the srcdoc resource: navigate an iframe or frame given element, about:srcdoc, the empty string, and the value of element's srcdoc attribute.
|
||||
navigate_an_iframe_or_frame(AK::URL("about:srcdoc"sv), ReferrerPolicy::ReferrerPolicy::EmptyString, String::from_deprecated_string(get_attribute(HTML::AttributeNames::srcdoc)).release_value_but_fixme_should_propagate_errors());
|
||||
navigate_an_iframe_or_frame(AK::URL("about:srcdoc"sv), ReferrerPolicy::ReferrerPolicy::EmptyString, get_attribute(HTML::AttributeNames::srcdoc));
|
||||
|
||||
// FIXME: The resulting Document must be considered an iframe srcdoc document.
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@ unsigned HTMLImageElement::width() const
|
|||
return paintable_box->content_width().to_int();
|
||||
|
||||
// NOTE: This step seems to not be in the spec, but all browsers do it.
|
||||
auto width_attr = get_attribute(HTML::AttributeNames::width);
|
||||
auto width_attr = deprecated_get_attribute(HTML::AttributeNames::width);
|
||||
if (auto converted = width_attr.to_uint(); converted.has_value())
|
||||
return *converted;
|
||||
|
||||
|
@ -203,7 +203,7 @@ unsigned HTMLImageElement::height() const
|
|||
return paintable_box->content_height().to_int();
|
||||
|
||||
// NOTE: This step seems to not be in the spec, but all browsers do it.
|
||||
auto height_attr = get_attribute(HTML::AttributeNames::height);
|
||||
auto height_attr = deprecated_get_attribute(HTML::AttributeNames::height);
|
||||
if (auto converted = height_attr.to_uint(); converted.has_value())
|
||||
return *converted;
|
||||
|
||||
|
|
|
@ -352,7 +352,7 @@ DeprecatedString HTMLInputElement::value() const
|
|||
// https://html.spec.whatwg.org/multipage/input.html#dom-input-value-default-on
|
||||
if (type_state() == TypeAttributeState::Checkbox || type_state() == TypeAttributeState::RadioButton) {
|
||||
// On getting, if the element has a value content attribute, return that attribute's value; otherwise, return the string "on".
|
||||
return has_attribute(AttributeNames::value) ? get_attribute(AttributeNames::value) : "on";
|
||||
return get_attribute(AttributeNames::value).value_or("on"_string).to_deprecated_string();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/input.html#dom-input-value-default
|
||||
|
@ -362,7 +362,7 @@ DeprecatedString HTMLInputElement::value() const
|
|||
|| type_state() == TypeAttributeState::ResetButton
|
||||
|| type_state() == TypeAttributeState::Button) {
|
||||
// On getting, if the element has a value content attribute, return that attribute's value; otherwise, return the empty string.
|
||||
return has_attribute(AttributeNames::value) ? get_attribute(AttributeNames::value) : DeprecatedString::empty();
|
||||
return get_attribute(AttributeNames::value).value_or(String {}).to_deprecated_string();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/input.html#dom-input-value-value
|
||||
|
@ -934,7 +934,7 @@ void HTMLInputElement::reset_algorithm()
|
|||
m_dirty_checkedness = false;
|
||||
|
||||
// set the value of the element to the value of the value content attribute, if there is one, or the empty string otherwise,
|
||||
m_value = has_attribute(AttributeNames::value) ? get_attribute(AttributeNames::value) : DeprecatedString::empty();
|
||||
m_value = get_attribute(AttributeNames::value).value_or(String {}).to_deprecated_string();
|
||||
|
||||
// set the checkedness of the element to true if the element has a checked content attribute and false if it does not,
|
||||
m_checked = has_attribute(AttributeNames::checked);
|
||||
|
|
|
@ -160,9 +160,7 @@ HTMLLinkElement::LinkProcessingOptions HTMLLinkElement::create_link_options()
|
|||
LinkProcessingOptions options;
|
||||
// FIXME: destination the result of translating the state of el's as attribute
|
||||
// crossorigin the state of el's crossorigin content attribute
|
||||
options.crossorigin = cors_setting_attribute_from_keyword(
|
||||
has_attribute(AttributeNames::crossorigin) ? String::from_deprecated_string(get_attribute(AttributeNames::crossorigin)).release_value_but_fixme_should_propagate_errors()
|
||||
: Optional<String> {});
|
||||
options.crossorigin = cors_setting_attribute_from_keyword(get_attribute(AttributeNames::crossorigin));
|
||||
// FIXME: referrer policy the state of el's referrerpolicy content attribute
|
||||
// FIXME: source set el's source set
|
||||
// base URL document's URL
|
||||
|
@ -178,16 +176,16 @@ HTMLLinkElement::LinkProcessingOptions HTMLLinkElement::create_link_options()
|
|||
// FIXME: cryptographic nonce metadata The current value of el's [[CryptographicNonce]] internal slot
|
||||
|
||||
// 3. If el has an href attribute, then set options's href to the value of el's href attribute.
|
||||
if (has_attribute(AttributeNames::href))
|
||||
options.href = String::from_deprecated_string(get_attribute(AttributeNames::href)).release_value_but_fixme_should_propagate_errors();
|
||||
if (auto maybe_href = get_attribute(AttributeNames::href); maybe_href.has_value())
|
||||
options.href = maybe_href.value();
|
||||
|
||||
// 4. If el has an integrity attribute, then set options's integrity to the value of el's integrity content attribute.
|
||||
if (has_attribute(AttributeNames::integrity))
|
||||
options.integrity = String::from_deprecated_string(get_attribute(AttributeNames::integrity)).release_value_but_fixme_should_propagate_errors();
|
||||
if (auto maybe_integrity = get_attribute(AttributeNames::integrity); maybe_integrity.has_value())
|
||||
options.integrity = maybe_integrity.value();
|
||||
|
||||
// 5. If el has a type attribute, then set options's type to the value of el's type attribute.
|
||||
if (has_attribute(AttributeNames::type))
|
||||
options.type = String::from_deprecated_string(get_attribute(AttributeNames::type)).release_value_but_fixme_should_propagate_errors();
|
||||
if (auto maybe_type = get_attribute(AttributeNames::type); maybe_type.has_value())
|
||||
options.type = maybe_type.value();
|
||||
|
||||
// FIXME: 6. Assert: options's href is not the empty string, or options's source set is not null.
|
||||
// A link element with neither an href or an imagesrcset does not represent a link.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue