mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-08 23:42:53 +03:00
LibWeb: Remove DOM element deprecated_get_attribute()
This commit is contained in:
parent
c477f90df7
commit
a681429dff
Notes:
sideshowbarker
2024-07-17 18:49:10 +09:00
Author: https://github.com/bplaat Commit: https://github.com/SerenityOS/serenity/commit/a681429dff Pull-request: https://github.com/SerenityOS/serenity/pull/22777 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/AtkinsSJ Reviewed-by: https://github.com/shannonbooth ✅
@ -68,8 +68,7 @@ DOMTokenList::DOMTokenList(Element& associated_element, FlyString associated_att
|
||||
{
|
||||
m_legacy_platform_object_flags = LegacyPlatformObjectFlags { .supports_indexed_properties = 1 };
|
||||
|
||||
auto value = associated_element.deprecated_get_attribute(m_associated_attribute);
|
||||
associated_attribute_changed(value);
|
||||
associated_attribute_changed(associated_element.get_attribute_value(m_associated_attribute));
|
||||
}
|
||||
|
||||
void DOMTokenList::initialize(JS::Realm& realm)
|
||||
|
@ -134,15 +134,6 @@ Optional<String> Element::get_attribute_ns(Optional<FlyString> const& namespace_
|
||||
return attribute->value();
|
||||
}
|
||||
|
||||
ByteString Element::deprecated_get_attribute(FlyString const& name) const
|
||||
{
|
||||
auto maybe_attribute = get_attribute(name);
|
||||
if (!maybe_attribute.has_value())
|
||||
return ByteString::empty();
|
||||
|
||||
return maybe_attribute->to_byte_string();
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-element-attributes-get-value
|
||||
String Element::get_attribute_value(FlyString const& local_name, Optional<FlyString> const& namespace_) const
|
||||
{
|
||||
@ -1051,7 +1042,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(deprecated_attribute(HTML::AttributeNames::tabindex));
|
||||
auto maybe_table_index = Web::HTML::parse_integer(get_attribute_value(HTML::AttributeNames::tabindex));
|
||||
|
||||
if (!maybe_table_index.has_value())
|
||||
return default_tab_index_value();
|
||||
@ -2038,10 +2029,10 @@ void Element::for_each_attribute(Function<void(Attr const&)> callback) const
|
||||
callback(*m_attributes->item(i));
|
||||
}
|
||||
|
||||
void Element::for_each_attribute(Function<void(FlyString const&, ByteString const&)> callback) const
|
||||
void Element::for_each_attribute(Function<void(FlyString const&, String const&)> callback) const
|
||||
{
|
||||
for_each_attribute([&callback](Attr const& attr) {
|
||||
callback(attr.name(), attr.value().to_byte_string());
|
||||
callback(attr.name(), attr.value());
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -93,12 +93,10 @@ public:
|
||||
bool has_attribute_ns(Optional<FlyString> const& namespace_, FlyString const& name) const;
|
||||
bool has_attributes() const;
|
||||
|
||||
ByteString deprecated_attribute(FlyString const& name) const { return deprecated_get_attribute(name); }
|
||||
Optional<String> attribute(FlyString const& name) const { return get_attribute(name); }
|
||||
|
||||
Optional<String> get_attribute(FlyString const& name) const;
|
||||
Optional<String> get_attribute_ns(Optional<FlyString> const& namespace_, FlyString const& name) const;
|
||||
ByteString deprecated_get_attribute(FlyString const& name) const;
|
||||
String get_attribute_value(FlyString const& local_name, Optional<FlyString> const& namespace_ = {}) const;
|
||||
|
||||
WebIDL::ExceptionOr<void> set_attribute(FlyString const& name, String const& value);
|
||||
@ -135,7 +133,7 @@ public:
|
||||
|
||||
void for_each_attribute(Function<void(Attr const&)>) const;
|
||||
|
||||
void for_each_attribute(Function<void(FlyString const&, ByteString const&)>) const;
|
||||
void for_each_attribute(Function<void(FlyString const&, String const&)>) const;
|
||||
|
||||
bool has_class(FlyString const&, CaseSensitivity = CaseSensitivity::CaseSensitive) const;
|
||||
Vector<FlyString> const& class_names() const { return m_classes; }
|
||||
|
@ -825,7 +825,7 @@ JS::NonnullGCPtr<Node> Node::clone_node(Document* document, bool clone_children)
|
||||
element.for_each_attribute([&](auto& name, auto& value) {
|
||||
// 1. Let copyAttribute be a clone of attribute.
|
||||
// 2. Append copyAttribute to copy.
|
||||
MUST(element_copy->set_attribute(name, MUST(String::from_byte_string(value))));
|
||||
MUST(element_copy->set_attribute(name, value));
|
||||
});
|
||||
copy = move(element_copy);
|
||||
|
||||
@ -1396,7 +1396,7 @@ bool Node::is_equal_node(Node const* other_node) const
|
||||
// If A is an element, each attribute in its attribute list has an attribute that equals an attribute in B’s attribute list.
|
||||
bool has_same_attributes = true;
|
||||
this_element.for_each_attribute([&](auto& name, auto& value) {
|
||||
if (other_element.deprecated_get_attribute(name) != value)
|
||||
if (other_element.get_attribute(name) != value)
|
||||
has_same_attributes = false;
|
||||
});
|
||||
if (!has_same_attributes)
|
||||
|
@ -88,7 +88,7 @@ Vector<DOMStringMap::NameValuePair> DOMStringMap::get_name_value_pairs() const
|
||||
builder.append(current_character);
|
||||
}
|
||||
|
||||
list.append({ MUST(builder.to_string()), MUST(String::from_byte_string(value)) });
|
||||
list.append({ MUST(builder.to_string()), value });
|
||||
});
|
||||
|
||||
// 4. Return list.
|
||||
|
@ -20,9 +20,9 @@ class HTMLAnchorElement final
|
||||
public:
|
||||
virtual ~HTMLAnchorElement() override;
|
||||
|
||||
ByteString rel() const { return deprecated_attribute(HTML::AttributeNames::rel); }
|
||||
ByteString target() const { return deprecated_attribute(HTML::AttributeNames::target); }
|
||||
ByteString download() const { return deprecated_attribute(HTML::AttributeNames::download); }
|
||||
String rel() const { return get_attribute_value(HTML::AttributeNames::rel); }
|
||||
String target() const { return get_attribute_value(HTML::AttributeNames::target); }
|
||||
String download() const { return get_attribute_value(HTML::AttributeNames::download); }
|
||||
|
||||
String text() const;
|
||||
void set_text(String const&);
|
||||
|
@ -68,7 +68,7 @@ void HTMLBaseElement::set_the_frozen_base_url()
|
||||
auto& document = this->document();
|
||||
|
||||
// 2. Let urlRecord be the result of parsing the value of element's href content attribute with document's fallback base URL, and document's character encoding. (Thus, the base element isn't affected by itself.)
|
||||
auto href = deprecated_attribute(AttributeNames::href);
|
||||
auto href = get_attribute_value(AttributeNames::href);
|
||||
auto url_record = document.fallback_base_url().complete_url(href);
|
||||
|
||||
// 3. Set element's frozen base URL to document's fallback base URL, if urlRecord is failure or running Is base allowed for Document? on the resulting URL record and document returns "Blocked", and to urlRecord otherwise.
|
||||
|
@ -63,17 +63,17 @@ void HTMLBodyElement::attribute_changed(FlyString const& name, Optional<String>
|
||||
HTMLElement::attribute_changed(name, value);
|
||||
if (name.equals_ignoring_ascii_case("link"sv)) {
|
||||
// https://html.spec.whatwg.org/multipage/rendering.html#the-page:rules-for-parsing-a-legacy-colour-value-3
|
||||
auto color = parse_legacy_color_value(value.value_or(String {}).to_byte_string());
|
||||
auto color = parse_legacy_color_value(value.value_or(String {}));
|
||||
if (color.has_value())
|
||||
document().set_link_color(color.value());
|
||||
} else if (name.equals_ignoring_ascii_case("alink"sv)) {
|
||||
// https://html.spec.whatwg.org/multipage/rendering.html#the-page:rules-for-parsing-a-legacy-colour-value-5
|
||||
auto color = parse_legacy_color_value(value.value_or(String {}).to_byte_string());
|
||||
auto color = parse_legacy_color_value(value.value_or(String {}));
|
||||
if (color.has_value())
|
||||
document().set_active_link_color(color.value());
|
||||
} else if (name.equals_ignoring_ascii_case("vlink"sv)) {
|
||||
// https://html.spec.whatwg.org/multipage/rendering.html#the-page:rules-for-parsing-a-legacy-colour-value-4
|
||||
auto color = parse_legacy_color_value(value.value_or(String {}).to_byte_string());
|
||||
auto color = parse_legacy_color_value(value.value_or(String {}));
|
||||
if (color.has_value())
|
||||
document().set_visited_link_color(color.value());
|
||||
} else if (name.equals_ignoring_ascii_case("background"sv)) {
|
||||
|
@ -27,7 +27,7 @@ void HTMLButtonElement::initialize(JS::Realm& realm)
|
||||
|
||||
HTMLButtonElement::TypeAttributeState HTMLButtonElement::type_state() const
|
||||
{
|
||||
auto value = deprecated_attribute(HTML::AttributeNames::type);
|
||||
auto value = get_attribute_value(HTML::AttributeNames::type);
|
||||
|
||||
#define __ENUMERATE_HTML_BUTTON_TYPE_ATTRIBUTE(keyword, state) \
|
||||
if (value.equals_ignoring_ascii_case(#keyword##sv)) \
|
||||
|
@ -66,8 +66,8 @@ void HTMLCanvasElement::apply_presentational_hints(CSS::StyleProperties& style)
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/rendering.html#map-to-the-aspect-ratio-property
|
||||
// if element has both attributes w and h, and parsing those attributes' values using the rules for parsing non-negative integers doesn't generate an error for either
|
||||
auto w = parse_non_negative_integer(deprecated_attribute(HTML::AttributeNames::width));
|
||||
auto h = parse_non_negative_integer(deprecated_attribute(HTML::AttributeNames::height));
|
||||
auto w = parse_non_negative_integer(get_attribute_value(HTML::AttributeNames::width));
|
||||
auto h = parse_non_negative_integer(get_attribute_value(HTML::AttributeNames::height));
|
||||
|
||||
if (w.has_value() && h.has_value())
|
||||
// then the user agent is expected to use the parsed integers as a presentational hint for the 'aspect-ratio' property of the form auto w / h.
|
||||
@ -85,7 +85,7 @@ unsigned HTMLCanvasElement::width() const
|
||||
// The rules for parsing non-negative integers must be used to obtain their numeric values.
|
||||
// If an attribute is missing, or if parsing its value returns an error, then the default value must be used instead.
|
||||
// The width attribute defaults to 300
|
||||
return parse_non_negative_integer(deprecated_attribute(HTML::AttributeNames::width)).value_or(300);
|
||||
return parse_non_negative_integer(get_attribute_value(HTML::AttributeNames::width)).value_or(300);
|
||||
}
|
||||
|
||||
unsigned HTMLCanvasElement::height() const
|
||||
@ -94,7 +94,7 @@ unsigned HTMLCanvasElement::height() const
|
||||
// The rules for parsing non-negative integers must be used to obtain their numeric values.
|
||||
// If an attribute is missing, or if parsing its value returns an error, then the default value must be used instead.
|
||||
// the height attribute defaults to 150
|
||||
return parse_non_negative_integer(deprecated_attribute(HTML::AttributeNames::height)).value_or(150);
|
||||
return parse_non_negative_integer(get_attribute_value(HTML::AttributeNames::height)).value_or(150);
|
||||
}
|
||||
|
||||
void HTMLCanvasElement::reset_context_to_default_state()
|
||||
|
@ -64,7 +64,7 @@ StringView HTMLElement::dir() const
|
||||
{
|
||||
// FIXME: This should probably be `Reflect` in the IDL.
|
||||
// The dir IDL attribute on an element must reflect the dir content attribute of that element, limited to only known values.
|
||||
auto dir = deprecated_attribute(HTML::AttributeNames::dir);
|
||||
auto dir = get_attribute_value(HTML::AttributeNames::dir);
|
||||
#define __ENUMERATE_HTML_ELEMENT_DIR_ATTRIBUTE(keyword) \
|
||||
if (dir.equals_ignoring_ascii_case(#keyword##sv)) \
|
||||
return #keyword##sv;
|
||||
@ -526,8 +526,8 @@ String HTMLElement::get_an_elements_target() const
|
||||
TokenizedFeature::NoOpener HTMLElement::get_an_elements_noopener(StringView target) const
|
||||
{
|
||||
// To get an element's noopener, given an a, area, or form element element and a string target:
|
||||
auto rel = deprecated_attribute(HTML::AttributeNames::rel).to_lowercase();
|
||||
auto link_types = rel.view().split_view_if(Infra::is_ascii_whitespace);
|
||||
auto rel = MUST(get_attribute_value(HTML::AttributeNames::rel).to_lowercase());
|
||||
auto link_types = rel.bytes_as_string_view().split_view_if(Infra::is_ascii_whitespace);
|
||||
|
||||
// 1. If element's link types include the noopener or noreferrer keyword, then return true.
|
||||
if (link_types.contains_slow("noopener"sv) || link_types.contains_slow("noreferrer"sv))
|
||||
|
@ -807,8 +807,8 @@ void HTMLFormElement::plan_to_navigate_to(AK::URL url, Variant<Empty, String, PO
|
||||
ReferrerPolicy::ReferrerPolicy referrer_policy = ReferrerPolicy::ReferrerPolicy::EmptyString;
|
||||
|
||||
// 2. If the form element's link types include the noreferrer keyword, then set referrerPolicy to "no-referrer".
|
||||
auto rel = deprecated_attribute(HTML::AttributeNames::rel).to_lowercase();
|
||||
auto link_types = rel.view().split_view_if(Infra::is_ascii_whitespace);
|
||||
auto rel = MUST(get_attribute_value(HTML::AttributeNames::rel).to_lowercase());
|
||||
auto link_types = rel.bytes_as_string_view().split_view_if(Infra::is_ascii_whitespace);
|
||||
if (link_types.contains_slow("noreferrer"sv))
|
||||
referrer_policy = ReferrerPolicy::ReferrerPolicy::NoReferrer;
|
||||
|
||||
|
@ -175,9 +175,10 @@ 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 = deprecated_get_attribute(HTML::AttributeNames::width);
|
||||
if (auto converted = width_attr.to_number<unsigned>(); converted.has_value())
|
||||
return *converted;
|
||||
if (auto width_attr = get_attribute(HTML::AttributeNames::width); width_attr.has_value()) {
|
||||
if (auto converted = width_attr->to_number<unsigned>(); converted.has_value())
|
||||
return *converted;
|
||||
}
|
||||
|
||||
// ...or else the density-corrected intrinsic width and height of the image, in CSS pixels,
|
||||
// if the image has intrinsic dimensions and is available but not being rendered.
|
||||
@ -203,9 +204,10 @@ 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 = deprecated_get_attribute(HTML::AttributeNames::height);
|
||||
if (auto converted = height_attr.to_number<unsigned>(); converted.has_value())
|
||||
return *converted;
|
||||
if (auto height_attr = get_attribute(HTML::AttributeNames::height); height_attr.has_value()) {
|
||||
if (auto converted = height_attr->to_number<unsigned>(); converted.has_value())
|
||||
return *converted;
|
||||
}
|
||||
|
||||
// ...or else the density-corrected intrinsic height and height of the image, in CSS pixels,
|
||||
// if the image has intrinsic dimensions and is available but not being rendered.
|
||||
@ -554,7 +556,7 @@ after_step_7:
|
||||
request->set_initiator(Fetch::Infrastructure::Request::Initiator::ImageSet);
|
||||
|
||||
// 21. Set request's referrer policy to the current state of the element's referrerpolicy attribute.
|
||||
request->set_referrer_policy(ReferrerPolicy::from_string(deprecated_attribute(HTML::AttributeNames::referrerpolicy)));
|
||||
request->set_referrer_policy(ReferrerPolicy::from_string(get_attribute_value(HTML::AttributeNames::referrerpolicy)));
|
||||
|
||||
// FIXME: 22. Set request's priority to the current state of the element's fetchpriority attribute.
|
||||
|
||||
@ -769,7 +771,7 @@ void HTMLImageElement::react_to_changes_in_the_environment()
|
||||
request->set_initiator(Fetch::Infrastructure::Request::Initiator::ImageSet);
|
||||
|
||||
// 3. Set request's referrer policy to the current state of the element's referrerpolicy attribute.
|
||||
request->set_referrer_policy(ReferrerPolicy::from_string(deprecated_attribute(HTML::AttributeNames::referrerpolicy)));
|
||||
request->set_referrer_policy(ReferrerPolicy::from_string(get_attribute_value(HTML::AttributeNames::referrerpolicy)));
|
||||
|
||||
// FIXME: 4. Set request's priority to the current state of the element's fetchpriority attribute.
|
||||
|
||||
@ -926,7 +928,7 @@ static void update_the_source_set(DOM::Element& element)
|
||||
continue;
|
||||
|
||||
// 4. Parse child's srcset attribute and let the returned source set be source set.
|
||||
auto source_set = parse_a_srcset_attribute(child->deprecated_attribute(HTML::AttributeNames::srcset));
|
||||
auto source_set = parse_a_srcset_attribute(child->get_attribute_value(HTML::AttributeNames::srcset));
|
||||
|
||||
// 5. If source set has zero image sources, continue to the next child.
|
||||
if (source_set.is_empty())
|
||||
@ -935,14 +937,14 @@ static void update_the_source_set(DOM::Element& element)
|
||||
// 6. If child has a media attribute, and its value does not match the environment, continue to the next child.
|
||||
if (child->has_attribute(HTML::AttributeNames::media)) {
|
||||
auto media_query = parse_media_query(CSS::Parser::ParsingContext { element.document() },
|
||||
child->deprecated_attribute(HTML::AttributeNames::media));
|
||||
child->get_attribute_value(HTML::AttributeNames::media));
|
||||
if (!media_query || !media_query->evaluate(element.document().window())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 7. Parse child's sizes attribute, and let source set's source size be the returned value.
|
||||
source_set.m_source_size = parse_a_sizes_attribute(element.document(), child->deprecated_attribute(HTML::AttributeNames::sizes));
|
||||
source_set.m_source_size = parse_a_sizes_attribute(element.document(), child->get_attribute_value(HTML::AttributeNames::sizes));
|
||||
|
||||
// FIXME: 8. If child has a type attribute, and its value is an unknown or unsupported MIME type, continue to the next child.
|
||||
if (child->has_attribute(HTML::AttributeNames::type)) {
|
||||
|
@ -39,8 +39,8 @@ public:
|
||||
|
||||
virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
|
||||
|
||||
ByteString alt() const { return deprecated_attribute(HTML::AttributeNames::alt); }
|
||||
ByteString src() const { return deprecated_attribute(HTML::AttributeNames::src); }
|
||||
String alt() const { return get_attribute_value(HTML::AttributeNames::alt); }
|
||||
String src() const { return get_attribute_value(HTML::AttributeNames::src); }
|
||||
|
||||
RefPtr<Gfx::ImmutableBitmap> immutable_bitmap() const;
|
||||
RefPtr<Gfx::Bitmap const> bitmap() const;
|
||||
|
@ -369,7 +369,7 @@ String 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 get_attribute(AttributeNames::value).value_or(String {});
|
||||
return get_attribute_value(AttributeNames::value);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/input.html#range-state-(type=range):attr-input-value
|
||||
@ -1015,7 +1015,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 = get_attribute(AttributeNames::value).value_or(String {});
|
||||
m_value = get_attribute_value(AttributeNames::value);
|
||||
|
||||
// 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);
|
||||
|
@ -64,7 +64,7 @@ public:
|
||||
TypeAttributeState type_state() const { return m_type; }
|
||||
WebIDL::ExceptionOr<void> set_type(String const&);
|
||||
|
||||
ByteString default_value() const { return deprecated_attribute(HTML::AttributeNames::value); }
|
||||
String default_value() const { return get_attribute_value(HTML::AttributeNames::value); }
|
||||
|
||||
virtual String value() const override;
|
||||
WebIDL::ExceptionOr<void> set_value(String const&);
|
||||
|
@ -62,12 +62,12 @@ void HTMLLinkElement::inserted()
|
||||
if (m_relationship & Relationship::Preload) {
|
||||
// FIXME: Respect the "as" attribute.
|
||||
LoadRequest request;
|
||||
request.set_url(document().parse_url(deprecated_attribute(HTML::AttributeNames::href)));
|
||||
request.set_url(document().parse_url(get_attribute_value(HTML::AttributeNames::href)));
|
||||
set_resource(ResourceLoader::the().load_resource(Resource::Type::Generic, request));
|
||||
} else if (m_relationship & Relationship::DNSPrefetch) {
|
||||
ResourceLoader::the().prefetch_dns(document().parse_url(deprecated_attribute(HTML::AttributeNames::href)));
|
||||
ResourceLoader::the().prefetch_dns(document().parse_url(get_attribute_value(HTML::AttributeNames::href)));
|
||||
} else if (m_relationship & Relationship::Preconnect) {
|
||||
ResourceLoader::the().preconnect(document().parse_url(deprecated_attribute(HTML::AttributeNames::href)));
|
||||
ResourceLoader::the().preconnect(document().parse_url(get_attribute_value(HTML::AttributeNames::href)));
|
||||
} else if (m_relationship & Relationship::Icon) {
|
||||
auto favicon_url = document().parse_url(href());
|
||||
auto favicon_request = LoadRequest::create_for_url_on_page(favicon_url, &document().page());
|
||||
|
@ -29,9 +29,9 @@ public:
|
||||
|
||||
virtual void inserted() override;
|
||||
|
||||
ByteString rel() const { return deprecated_attribute(HTML::AttributeNames::rel); }
|
||||
ByteString type() const { return deprecated_attribute(HTML::AttributeNames::type); }
|
||||
ByteString href() const { return deprecated_attribute(HTML::AttributeNames::href); }
|
||||
String rel() const { return get_attribute_value(HTML::AttributeNames::rel); }
|
||||
String type() const { return get_attribute_value(HTML::AttributeNames::type); }
|
||||
String href() const { return get_attribute_value(HTML::AttributeNames::href); }
|
||||
|
||||
bool has_loaded_icon() const;
|
||||
bool load_favicon_and_use_if_window_is_active();
|
||||
|
@ -578,8 +578,8 @@ public:
|
||||
// 2. ⌛ Process candidate: If candidate does not have a src attribute, or if its src attribute's value is the
|
||||
// empty string, then end the synchronous section, and jump down to the failed with elements step below.
|
||||
String candiate_src;
|
||||
if (m_candidate->has_attribute(HTML::AttributeNames::src))
|
||||
candiate_src = TRY_OR_THROW_OOM(vm, String::from_byte_string(m_candidate->deprecated_attribute(HTML::AttributeNames::src)));
|
||||
if (auto maybe_src = m_candidate->get_attribute(HTML::AttributeNames::src); maybe_src.has_value())
|
||||
candiate_src = *maybe_src;
|
||||
|
||||
if (candiate_src.is_empty()) {
|
||||
TRY(failed_with_elements());
|
||||
@ -826,7 +826,7 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::select_resource()
|
||||
};
|
||||
|
||||
// 1. ⌛ If the src attribute's value is the empty string, then end the synchronous section, and jump down to the failed with attribute step below.
|
||||
auto source = deprecated_attribute(HTML::AttributeNames::src);
|
||||
auto source = get_attribute_value(HTML::AttributeNames::src);
|
||||
if (source.is_empty()) {
|
||||
failed_with_attribute("The 'src' attribute is empty"_string);
|
||||
return {};
|
||||
|
@ -34,7 +34,7 @@ void HTMLMetaElement::initialize(JS::Realm& realm)
|
||||
|
||||
Optional<HTMLMetaElement::HttpEquivAttributeState> HTMLMetaElement::http_equiv_state() const
|
||||
{
|
||||
auto value = deprecated_attribute(HTML::AttributeNames::http_equiv);
|
||||
auto value = get_attribute_value(HTML::AttributeNames::http_equiv);
|
||||
|
||||
#define __ENUMERATE_HTML_META_HTTP_EQUIV_ATTRIBUTE(keyword, state) \
|
||||
if (value.equals_ignoring_ascii_case(#keyword##sv)) \
|
||||
@ -96,7 +96,7 @@ void HTMLMetaElement::inserted()
|
||||
if (!has_attribute(AttributeNames::content))
|
||||
break;
|
||||
|
||||
auto input = deprecated_attribute(AttributeNames::content);
|
||||
auto input = get_attribute_value(AttributeNames::content);
|
||||
if (input.is_empty())
|
||||
break;
|
||||
|
||||
@ -105,7 +105,7 @@ void HTMLMetaElement::inserted()
|
||||
break;
|
||||
}
|
||||
default:
|
||||
dbgln("FIXME: Implement '{}' http-equiv state", deprecated_attribute(AttributeNames::http_equiv));
|
||||
dbgln("FIXME: Implement '{}' http-equiv state", get_attribute_value(AttributeNames::http_equiv));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ void HTMLObjectElement::attribute_changed(FlyString const& name, Optional<String
|
||||
// https://html.spec.whatwg.org/multipage/iframe-embed-object.html#attr-object-data
|
||||
String HTMLObjectElement::data() const
|
||||
{
|
||||
auto data = deprecated_attribute(HTML::AttributeNames::data);
|
||||
auto data = get_attribute_value(HTML::AttributeNames::data);
|
||||
return MUST(document().parse_url(data).to_string());
|
||||
}
|
||||
|
||||
@ -125,11 +125,11 @@ void HTMLObjectElement::queue_element_task_to_run_object_representation_steps()
|
||||
// FIXME: 3. If the classid attribute is present, and has a value that isn't the empty string, then: if the user agent can find a plugin suitable according to the value of the classid attribute, and plugins aren't being sandboxed, then that plugin should be used, and the value of the data attribute, if any, should be passed to the plugin. If no suitable plugin can be found, or if the plugin reports an error, jump to the step below labeled fallback.
|
||||
|
||||
// 4. If the data attribute is present and its value is not the empty string, then:
|
||||
if (auto data = deprecated_attribute(HTML::AttributeNames::data); !data.is_empty()) {
|
||||
if (auto maybe_data = get_attribute(HTML::AttributeNames::data); maybe_data.has_value() && !maybe_data->is_empty()) {
|
||||
// 1. If the type attribute is present and its value is not a type that the user agent supports, and is not a type that the user agent can find a plugin for, then the user agent may jump to the step below labeled fallback without fetching the content to examine its real type.
|
||||
|
||||
// 2. Parse a URL given the data attribute, relative to the element's node document.
|
||||
auto url = document().parse_url(data);
|
||||
auto url = document().parse_url(*maybe_data);
|
||||
|
||||
// 3. If that failed, fire an event named error at the element, then jump to the step below labeled fallback.
|
||||
if (!url.is_valid()) {
|
||||
@ -170,7 +170,7 @@ void HTMLObjectElement::resource_did_load()
|
||||
// 4.8. Determine the resource type, as follows:
|
||||
|
||||
// 1. Let the resource type be unknown.
|
||||
Optional<ByteString> resource_type;
|
||||
Optional<String> resource_type;
|
||||
|
||||
// FIXME: 2. If the user agent is configured to strictly obey Content-Type headers for this resource, and the resource has associated Content-Type metadata, then let the resource type be the type specified in the resource's Content-Type metadata, and jump to the step below labeled handler.
|
||||
// FIXME: 3. If there is a type attribute present on the object element, and that attribute's value is not a type that the user agent supports, but it is a type that a plugin supports, then let the resource type be the type specified in that type attribute, and jump to the step below labeled handler.
|
||||
@ -195,7 +195,7 @@ void HTMLObjectElement::resource_did_load()
|
||||
if (auto type = this->type(); !type.is_empty() && (type != "application/octet-stream"sv)) {
|
||||
// 1. If the attribute's value is a type that a plugin supports, or the attribute's value is a type that starts with "image/" that is not also an XML MIME type, then let the resource type be the type specified in that type attribute.
|
||||
// FIXME: This only partially implements this step.
|
||||
if (type.starts_with("image/"sv))
|
||||
if (type.starts_with_bytes("image/"sv))
|
||||
resource_type = move(type);
|
||||
|
||||
// 2. Jump to the step below labeled handler.
|
||||
@ -203,7 +203,7 @@ void HTMLObjectElement::resource_did_load()
|
||||
}
|
||||
// * Otherwise, if the resource does not have associated Content-Type metadata
|
||||
else {
|
||||
Optional<ByteString> tentative_type;
|
||||
Optional<String> tentative_type;
|
||||
|
||||
// 1. If there is a type attribute present on the object element, then let the tentative type be the type specified in that type attribute.
|
||||
// Otherwise, let tentative type be the computed type of the resource.
|
||||
@ -213,7 +213,7 @@ void HTMLObjectElement::resource_did_load()
|
||||
// FIXME: For now, ignore application/ MIME types as we cannot render yet them anyways. We will need to implement the MIME type sniffing
|
||||
// algorithm in order to map all unknown MIME types to "application/octet-stream".
|
||||
else if (auto type = resource()->mime_type(); !type.starts_with("application/"sv))
|
||||
tentative_type = move(type);
|
||||
tentative_type = MUST(String::from_byte_string(type));
|
||||
|
||||
// 2. If tentative type is not application/octet-stream, then let resource type be tentative type and jump to the step below labeled handler.
|
||||
if (tentative_type.has_value() && tentative_type != "application/octet-stream"sv)
|
||||
@ -221,8 +221,7 @@ void HTMLObjectElement::resource_did_load()
|
||||
}
|
||||
|
||||
// FIXME: 5. If applying the URL parser algorithm to the URL of the specified resource (after any redirects) results in a URL record whose path component matches a pattern that a plugin supports, then let resource type be the type that that plugin can handle.
|
||||
|
||||
run_object_representation_handler_steps(move(resource_type));
|
||||
run_object_representation_handler_steps(resource_type.has_value() ? resource_type->to_byte_string() : ByteString::empty());
|
||||
}
|
||||
|
||||
static bool is_xml_mime_type(StringView resource_type)
|
||||
@ -314,7 +313,7 @@ void HTMLObjectElement::run_object_representation_fallback_steps()
|
||||
void HTMLObjectElement::load_image()
|
||||
{
|
||||
// NOTE: This currently reloads the image instead of reusing the resource we've already downloaded.
|
||||
auto data = deprecated_attribute(HTML::AttributeNames::data);
|
||||
auto data = get_attribute_value(HTML::AttributeNames::data);
|
||||
auto url = document().parse_url(data);
|
||||
m_image_request = HTML::SharedImageRequest::get_or_create(realm(), document().page(), url);
|
||||
m_image_request->add_callbacks(
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
String data() const;
|
||||
void set_data(String const& data) { MUST(set_attribute(HTML::AttributeNames::data, data)); }
|
||||
|
||||
ByteString type() const { return deprecated_attribute(HTML::AttributeNames::type); }
|
||||
String type() const { return get_attribute_value(HTML::AttributeNames::type); }
|
||||
|
||||
// ^FormAssociatedElement
|
||||
// https://html.spec.whatwg.org/multipage/forms.html#category-listed
|
||||
|
@ -259,14 +259,14 @@ void HTMLScriptElement::prepare_script()
|
||||
// 20. If el has an event attribute and a for attribute, and el's type is "classic", then:
|
||||
if (m_script_type == ScriptType::Classic && has_attribute(HTML::AttributeNames::event) && has_attribute(HTML::AttributeNames::for_)) {
|
||||
// 1. Let for be the value of el's' for attribute.
|
||||
auto for_ = deprecated_attribute(HTML::AttributeNames::for_);
|
||||
auto for_ = get_attribute_value(HTML::AttributeNames::for_);
|
||||
|
||||
// 2. Let event be the value of el's event attribute.
|
||||
auto event = deprecated_attribute(HTML::AttributeNames::event);
|
||||
auto event = get_attribute_value(HTML::AttributeNames::event);
|
||||
|
||||
// 3. Strip leading and trailing ASCII whitespace from event and for.
|
||||
for_ = for_.trim(Infra::ASCII_WHITESPACE);
|
||||
event = event.trim(Infra::ASCII_WHITESPACE);
|
||||
for_ = MUST(for_.trim(Infra::ASCII_WHITESPACE));
|
||||
event = MUST(event.trim(Infra::ASCII_WHITESPACE));
|
||||
|
||||
// 4. If for is not an ASCII case-insensitive match for the string "window", then return.
|
||||
if (!Infra::is_ascii_case_insensitive_match(for_, "window"sv)) {
|
||||
@ -287,7 +287,7 @@ void HTMLScriptElement::prepare_script()
|
||||
Optional<String> encoding;
|
||||
|
||||
if (has_attribute(HTML::AttributeNames::charset)) {
|
||||
auto charset = TextCodec::get_standardized_encoding(deprecated_attribute(HTML::AttributeNames::charset));
|
||||
auto charset = TextCodec::get_standardized_encoding(get_attribute_value(HTML::AttributeNames::charset));
|
||||
if (charset.has_value())
|
||||
encoding = String::from_utf8(*charset).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
@ -309,9 +309,8 @@ void HTMLScriptElement::prepare_script()
|
||||
// 25. If el has an integrity attribute, then let integrity metadata be that attribute's value.
|
||||
// Otherwise, let integrity metadata be the empty string.
|
||||
String integrity_metadata;
|
||||
if (has_attribute(HTML::AttributeNames::integrity)) {
|
||||
auto integrity = deprecated_attribute(HTML::AttributeNames::integrity);
|
||||
integrity_metadata = String::from_byte_string(integrity).release_value_but_fixme_should_propagate_errors();
|
||||
if (auto maybe_integrity = attribute(HTML::AttributeNames::integrity); maybe_integrity.has_value()) {
|
||||
integrity_metadata = *maybe_integrity;
|
||||
}
|
||||
|
||||
// 26. Let referrer policy be the current state of el's referrerpolicy content attribute.
|
||||
@ -348,7 +347,7 @@ void HTMLScriptElement::prepare_script()
|
||||
}
|
||||
|
||||
// 2. Let src be the value of el's src attribute.
|
||||
auto src = deprecated_attribute(HTML::AttributeNames::src);
|
||||
auto src = get_attribute_value(HTML::AttributeNames::src);
|
||||
|
||||
// 3. If src is the empty string, then queue an element task on the DOM manipulation task source given el to fire an event named error at el, and return.
|
||||
if (src.is_empty()) {
|
||||
|
@ -193,9 +193,10 @@ Optional<ARIA::Role> HTMLSelectElement::default_role() const
|
||||
if (has_attribute(AttributeNames::multiple))
|
||||
return ARIA::Role::listbox;
|
||||
if (has_attribute(AttributeNames::size)) {
|
||||
auto size_attribute = deprecated_attribute(AttributeNames::size).to_number<int>();
|
||||
if (size_attribute.has_value() && size_attribute.value() > 1)
|
||||
return ARIA::Role::listbox;
|
||||
if (auto size_string = get_attribute(HTML::AttributeNames::size); size_string.has_value()) {
|
||||
if (auto size = size_string->to_number<int>(); size.has_value() && *size > 1)
|
||||
return ARIA::Role::listbox;
|
||||
}
|
||||
}
|
||||
// https://www.w3.org/TR/html-aria/#el-select
|
||||
return ARIA::Role::combobox;
|
||||
|
@ -53,7 +53,7 @@ void HTMLTableCellElement::apply_presentational_hints(CSS::StyleProperties& styl
|
||||
return;
|
||||
}
|
||||
if (name == HTML::AttributeNames::valign) {
|
||||
if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value.view(), CSS::PropertyID::VerticalAlign))
|
||||
if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value, CSS::PropertyID::VerticalAlign))
|
||||
style.set_property(CSS::PropertyID::VerticalAlign, parsed_value.release_nonnull());
|
||||
return;
|
||||
}
|
||||
@ -65,7 +65,7 @@ void HTMLTableCellElement::apply_presentational_hints(CSS::StyleProperties& styl
|
||||
} else if (value.equals_ignoring_ascii_case("right"sv)) {
|
||||
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::LibwebRight));
|
||||
} else {
|
||||
if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value.view(), CSS::PropertyID::TextAlign))
|
||||
if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value, CSS::PropertyID::TextAlign))
|
||||
style.set_property(CSS::PropertyID::TextAlign, parsed_value.release_nonnull());
|
||||
}
|
||||
return;
|
||||
@ -112,7 +112,7 @@ void HTMLTableCellElement::apply_presentational_hints(CSS::StyleProperties& styl
|
||||
// https://html.spec.whatwg.org/multipage/tables.html#algorithm-for-processing-rows
|
||||
unsigned int HTMLTableCellElement::col_span() const
|
||||
{
|
||||
auto optional_value = Web::HTML::parse_non_negative_integer(deprecated_attribute(HTML::AttributeNames::colspan));
|
||||
auto optional_value = Web::HTML::parse_non_negative_integer(get_attribute_value(HTML::AttributeNames::colspan));
|
||||
|
||||
// If parsing that value failed, or returned zero, or if the attribute is absent, then let colspan be 1, instead.
|
||||
if (!optional_value.has_value() || optional_value.value() == 0) {
|
||||
@ -139,7 +139,7 @@ WebIDL::ExceptionOr<void> HTMLTableCellElement::set_col_span(unsigned int value)
|
||||
unsigned int HTMLTableCellElement::row_span() const
|
||||
{
|
||||
// If parsing that value failed or if the attribute is absent, then let rowspan be 1, instead.
|
||||
auto value = Web::HTML::parse_non_negative_integer(deprecated_attribute(HTML::AttributeNames::rowspan)).value_or(1);
|
||||
auto value = Web::HTML::parse_non_negative_integer(get_attribute_value(HTML::AttributeNames::rowspan)).value_or(1);
|
||||
|
||||
// If rowspan is greater than 65534, let it be 65534 instead.
|
||||
if (value > 65534) {
|
||||
|
@ -44,7 +44,7 @@ void HTMLTableElement::visit_edges(Cell::Visitor& visitor)
|
||||
visitor.visit(m_t_bodies);
|
||||
}
|
||||
|
||||
static unsigned parse_border(ByteString const& value)
|
||||
static unsigned parse_border(StringView value)
|
||||
{
|
||||
return value.to_number<unsigned>().value_or(0);
|
||||
}
|
||||
@ -66,7 +66,7 @@ void HTMLTableElement::apply_presentational_hints(CSS::StyleProperties& style) c
|
||||
if (value.equals_ignoring_ascii_case("center"sv)) {
|
||||
style.set_property(CSS::PropertyID::MarginLeft, CSS::IdentifierStyleValue::create(CSS::ValueID::Auto));
|
||||
style.set_property(CSS::PropertyID::MarginRight, CSS::IdentifierStyleValue::create(CSS::ValueID::Auto));
|
||||
} else if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value.view(), CSS::PropertyID::Float)) {
|
||||
} else if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value, CSS::PropertyID::Float)) {
|
||||
style.set_property(CSS::PropertyID::Float, parsed_value.release_nonnull());
|
||||
}
|
||||
return;
|
||||
@ -435,7 +435,7 @@ WebIDL::ExceptionOr<void> HTMLTableElement::delete_row(long index)
|
||||
|
||||
unsigned int HTMLTableElement::border() const
|
||||
{
|
||||
return parse_border(deprecated_attribute(HTML::AttributeNames::border));
|
||||
return parse_border(get_attribute_value(HTML::AttributeNames::border));
|
||||
}
|
||||
|
||||
unsigned int HTMLTableElement::padding() const
|
||||
|
@ -53,7 +53,7 @@ void HTMLTableRowElement::apply_presentational_hints(CSS::StyleProperties& style
|
||||
style.set_property(CSS::PropertyID::BackgroundImage, CSS::ImageStyleValue::create(parsed_value));
|
||||
return;
|
||||
} else if (name == HTML::AttributeNames::valign) {
|
||||
if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value.view(), CSS::PropertyID::VerticalAlign))
|
||||
if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value, CSS::PropertyID::VerticalAlign))
|
||||
style.set_property(CSS::PropertyID::VerticalAlign, parsed_value.release_nonnull());
|
||||
return;
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ void HTMLTextAreaElement::create_shadow_tree_if_needed()
|
||||
MUST(element->append_child(*m_placeholder_element));
|
||||
|
||||
m_placeholder_text_node = heap().allocate<DOM::Text>(realm(), document(), String {});
|
||||
m_placeholder_text_node->set_data(get_attribute(HTML::AttributeNames::placeholder).value_or(String {}));
|
||||
m_placeholder_text_node->set_data(get_attribute_value(HTML::AttributeNames::placeholder));
|
||||
m_placeholder_text_node->set_editable_text_node_owner(Badge<HTMLTextAreaElement> {}, *this);
|
||||
MUST(m_placeholder_element->append_child(*m_placeholder_text_node));
|
||||
|
||||
|
@ -196,7 +196,7 @@ Optional<AK::URL> NavigableContainer::shared_attribute_processing_steps_for_ifra
|
||||
// 2. If element has a src attribute specified, and its value is not the empty string,
|
||||
// then parse the value of that attribute relative to element's node document.
|
||||
// If this is successful, then set url to the resulting URL record.
|
||||
auto src_attribute_value = deprecated_attribute(HTML::AttributeNames::src);
|
||||
auto src_attribute_value = get_attribute_value(HTML::AttributeNames::src);
|
||||
if (!src_attribute_value.is_empty()) {
|
||||
auto parsed_src = document().parse_url(src_attribute_value);
|
||||
if (parsed_src.is_valid())
|
||||
|
@ -4555,9 +4555,11 @@ RefPtr<CSS::StyleValue> parse_nonzero_dimension_value(StringView string)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#rules-for-parsing-a-legacy-colour-value
|
||||
Optional<Color> parse_legacy_color_value(ByteString input)
|
||||
Optional<Color> parse_legacy_color_value(StringView string)
|
||||
{
|
||||
// 1. Let input be the string being parsed
|
||||
ByteString input = MUST(ByteString::from_utf8(string));
|
||||
|
||||
// 2. If input is the empty string, then return an error.
|
||||
if (input.is_empty())
|
||||
return {};
|
||||
|
@ -202,6 +202,6 @@ private:
|
||||
|
||||
RefPtr<CSS::StyleValue> parse_dimension_value(StringView);
|
||||
RefPtr<CSS::StyleValue> parse_nonzero_dimension_value(StringView);
|
||||
Optional<Color> parse_legacy_color_value(ByteString input);
|
||||
Optional<Color> parse_legacy_color_value(StringView);
|
||||
|
||||
}
|
||||
|
@ -24,8 +24,8 @@ void FrameBox::prepare_for_replaced_layout()
|
||||
VERIFY(dom_node().nested_browsing_context());
|
||||
|
||||
// FIXME: Do proper error checking, etc.
|
||||
set_natural_width(dom_node().deprecated_attribute(HTML::AttributeNames::width).to_number<int>().value_or(300));
|
||||
set_natural_height(dom_node().deprecated_attribute(HTML::AttributeNames::height).to_number<int>().value_or(150));
|
||||
set_natural_width(dom_node().get_attribute_value(HTML::AttributeNames::width).to_number<int>().value_or(300));
|
||||
set_natural_height(dom_node().get_attribute_value(HTML::AttributeNames::height).to_number<int>().value_or(150));
|
||||
}
|
||||
|
||||
void FrameBox::did_set_content_size()
|
||||
|
@ -72,7 +72,7 @@ void TableFormattingContext::compute_constrainedness()
|
||||
m_columns[column_index].is_constrained = true;
|
||||
}
|
||||
auto const& col_node = static_cast<HTML::HTMLTableColElement const&>(*column_box.dom_node());
|
||||
unsigned span = col_node.deprecated_attribute(HTML::AttributeNames::span).to_number<unsigned>().value_or(1);
|
||||
unsigned span = col_node.get_attribute_value(HTML::AttributeNames::span).to_number<unsigned>().value_or(1);
|
||||
column_index += span;
|
||||
});
|
||||
});
|
||||
@ -189,7 +189,7 @@ void TableFormattingContext::compute_outer_content_sizes()
|
||||
// The outer max-content width of a table-column or table-column-group is max(min-width, min(max-width, width)).
|
||||
m_columns[column_index].max_size = max(min_width, min(max_width, width));
|
||||
auto const& col_node = static_cast<HTML::HTMLTableColElement const&>(*column_box.dom_node());
|
||||
unsigned span = col_node.deprecated_attribute(HTML::AttributeNames::span).to_number<unsigned>().value_or(1);
|
||||
unsigned span = col_node.get_attribute_value(HTML::AttributeNames::span).to_number<unsigned>().value_or(1);
|
||||
column_index += span;
|
||||
});
|
||||
});
|
||||
@ -1380,7 +1380,7 @@ void TableFormattingContext::BorderConflictFinder::collect_conflicting_col_eleme
|
||||
for (auto* child_of_column_group = child->first_child(); child_of_column_group; child_of_column_group = child_of_column_group->next_sibling()) {
|
||||
VERIFY(child_of_column_group->display().is_table_column());
|
||||
auto const& col_node = static_cast<HTML::HTMLTableColElement const&>(*child_of_column_group->dom_node());
|
||||
unsigned span = col_node.deprecated_attribute(HTML::AttributeNames::span).to_number<unsigned>().value_or(1);
|
||||
unsigned span = col_node.get_attribute_value(HTML::AttributeNames::span).to_number<unsigned>().value_or(1);
|
||||
for (size_t i = column_index; i < column_index + span; ++i) {
|
||||
m_col_elements_by_index[i] = child_of_column_group;
|
||||
}
|
||||
@ -1744,7 +1744,7 @@ void TableFormattingContext::initialize_intrinsic_percentages_from_rows_or_colum
|
||||
m_columns[column_index].has_intrinsic_percentage = computed_values.max_width().is_percentage() || computed_values.width().is_percentage();
|
||||
m_columns[column_index].intrinsic_percentage = min(width_percentage, max_width_percentage);
|
||||
auto const& col_node = static_cast<HTML::HTMLTableColElement const&>(*column_box.dom_node());
|
||||
unsigned span = col_node.deprecated_attribute(HTML::AttributeNames::span).to_number<unsigned>().value_or(1);
|
||||
unsigned span = col_node.get_attribute_value(HTML::AttributeNames::span).to_number<unsigned>().value_or(1);
|
||||
column_index += span;
|
||||
});
|
||||
});
|
||||
|
@ -285,9 +285,9 @@ bool EventHandler::handle_mouseup(CSSPixelPoint position, CSSPixelPoint screen_p
|
||||
auto url = document->parse_url(href);
|
||||
dbgln("Web::EventHandler: Clicking on a link to {}", url);
|
||||
if (button == GUI::MouseButton::Middle) {
|
||||
m_browsing_context->page().client().page_did_middle_click_link(url, link->target(), modifiers);
|
||||
m_browsing_context->page().client().page_did_middle_click_link(url, link->target().to_byte_string(), modifiers);
|
||||
} else if (button == GUI::MouseButton::Secondary) {
|
||||
m_browsing_context->page().client().page_did_request_link_context_menu(m_browsing_context->to_top_level_position(position), url, link->target(), modifiers);
|
||||
m_browsing_context->page().client().page_did_request_link_context_menu(m_browsing_context->to_top_level_position(position), url, link->target().to_byte_string(), modifiers);
|
||||
}
|
||||
} else if (button == GUI::MouseButton::Secondary) {
|
||||
if (is<HTML::HTMLImageElement>(*node)) {
|
||||
|
@ -54,10 +54,10 @@ void SVGForeignObjectElement::apply_presentational_hints(CSS::StyleProperties& s
|
||||
{
|
||||
Base::apply_presentational_hints(style);
|
||||
auto parsing_context = CSS::Parser::ParsingContext { document() };
|
||||
if (auto width_value = parse_css_value(parsing_context, deprecated_attribute(Web::HTML::AttributeNames::width), CSS::PropertyID::Width))
|
||||
if (auto width_value = parse_css_value(parsing_context, get_attribute_value(Web::HTML::AttributeNames::width), CSS::PropertyID::Width))
|
||||
style.set_property(CSS::PropertyID::Width, width_value.release_nonnull());
|
||||
|
||||
if (auto height_value = parse_css_value(parsing_context, deprecated_attribute(Web::HTML::AttributeNames::height), CSS::PropertyID::Height))
|
||||
if (auto height_value = parse_css_value(parsing_context, get_attribute_value(Web::HTML::AttributeNames::height), CSS::PropertyID::Height))
|
||||
style.set_property(CSS::PropertyID::Height, height_value.release_nonnull());
|
||||
}
|
||||
|
||||
|
@ -94,9 +94,9 @@ JS::GCPtr<SVGGradientElement const> SVGGradientElement::linked_gradient() const
|
||||
// FIXME: This entire function is an ad-hoc hack!
|
||||
// It can only resolve #<ids> in the same document.
|
||||
|
||||
auto link = has_attribute(AttributeNames::href) ? deprecated_get_attribute(AttributeNames::href) : deprecated_get_attribute("xlink:href"_fly_string);
|
||||
if (auto href = link; !href.is_empty()) {
|
||||
auto url = document().parse_url(href);
|
||||
auto link = has_attribute(AttributeNames::href) ? get_attribute(AttributeNames::href) : get_attribute("xlink:href"_fly_string);
|
||||
if (auto href = link; href.has_value() && !link->is_empty()) {
|
||||
auto url = document().parse_url(*href);
|
||||
auto id = url.fragment();
|
||||
if (!id.has_value() || id->is_empty())
|
||||
return {};
|
||||
|
@ -42,7 +42,7 @@ void SVGSVGElement::apply_presentational_hints(CSS::StyleProperties& style) cons
|
||||
|
||||
auto width_attribute = attribute(SVG::AttributeNames::width);
|
||||
auto parsing_context = CSS::Parser::ParsingContext { document(), CSS::Parser::ParsingContext::Mode::SVGPresentationAttribute };
|
||||
if (auto width_value = parse_css_value(parsing_context, deprecated_attribute(Web::HTML::AttributeNames::width), CSS::PropertyID::Width)) {
|
||||
if (auto width_value = parse_css_value(parsing_context, width_attribute.value_or(String {}), CSS::PropertyID::Width)) {
|
||||
style.set_property(CSS::PropertyID::Width, width_value.release_nonnull());
|
||||
} else if (width_attribute == "") {
|
||||
// If the `width` attribute is an empty string, it defaults to 100%.
|
||||
@ -53,7 +53,7 @@ void SVGSVGElement::apply_presentational_hints(CSS::StyleProperties& style) cons
|
||||
|
||||
// Height defaults to 100%
|
||||
auto height_attribute = attribute(SVG::AttributeNames::height);
|
||||
if (auto height_value = parse_css_value(parsing_context, deprecated_attribute(Web::HTML::AttributeNames::height), CSS::PropertyID::Height)) {
|
||||
if (auto height_value = parse_css_value(parsing_context, height_attribute.value_or(String {}), CSS::PropertyID::Height)) {
|
||||
style.set_property(CSS::PropertyID::Height, height_value.release_nonnull());
|
||||
} else if (height_attribute == "") {
|
||||
// If the `height` attribute is an empty string, it defaults to 100%.
|
||||
@ -84,15 +84,15 @@ void SVGSVGElement::update_fallback_view_box_for_svg_as_image()
|
||||
Optional<double> width;
|
||||
Optional<double> height;
|
||||
|
||||
auto width_attribute = deprecated_attribute(SVG::AttributeNames::width);
|
||||
auto width_attribute = get_attribute_value(SVG::AttributeNames::width);
|
||||
auto parsing_context = CSS::Parser::ParsingContext { document() };
|
||||
if (auto width_value = parse_css_value(parsing_context, deprecated_attribute(Web::HTML::AttributeNames::width), CSS::PropertyID::Width)) {
|
||||
if (auto width_value = parse_css_value(parsing_context, width_attribute, CSS::PropertyID::Width)) {
|
||||
if (width_value->is_length() && width_value->as_length().length().is_absolute())
|
||||
width = width_value->as_length().length().absolute_length_to_px().to_double();
|
||||
}
|
||||
|
||||
auto height_attribute = deprecated_attribute(SVG::AttributeNames::height);
|
||||
if (auto height_value = parse_css_value(parsing_context, deprecated_attribute(Web::HTML::AttributeNames::height), CSS::PropertyID::Height)) {
|
||||
auto height_attribute = get_attribute_value(SVG::AttributeNames::height);
|
||||
if (auto height_value = parse_css_value(parsing_context, height_attribute, CSS::PropertyID::Height)) {
|
||||
if (height_value->is_length() && height_value->as_length().length().is_absolute())
|
||||
height = height_value->as_length().length().absolute_length_to_px().to_double();
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ void SVGUseElement::svg_element_removed(SVGElement& svg_element)
|
||||
return;
|
||||
}
|
||||
|
||||
if (svg_element.deprecated_attribute("id"_fly_string).matches(m_referenced_id.value())) {
|
||||
if (AK::StringUtils::matches(svg_element.get_attribute_value("id"_fly_string), m_referenced_id.value())) {
|
||||
shadow_root()->remove_all_children();
|
||||
}
|
||||
}
|
||||
|
@ -457,7 +457,7 @@ void ConnectionFromClient::debug_request(ByteString const& request, ByteString c
|
||||
load_html("<h1>Failed to find <link rel="match" /> in ref test page!</h1> Make sure you added it.");
|
||||
} else {
|
||||
auto link = maybe_link.release_value();
|
||||
auto url = document->parse_url(link->deprecated_get_attribute(Web::HTML::AttributeNames::href));
|
||||
auto url = document->parse_url(link->get_attribute_value(Web::HTML::AttributeNames::href));
|
||||
load_url(url);
|
||||
}
|
||||
}
|
||||
|
@ -1073,7 +1073,8 @@ Messages::WebDriverClient::GetElementAttributeResponse WebDriverConnection::get_
|
||||
// -> Otherwise
|
||||
else {
|
||||
// The result of getting an attribute by name name.
|
||||
result = element->deprecated_get_attribute(name);
|
||||
if (auto attr = element->get_attribute(name); attr.has_value())
|
||||
result = attr->to_byte_string();
|
||||
}
|
||||
|
||||
// 5. Return success with data result.
|
||||
|
Loading…
Reference in New Issue
Block a user