mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:37:45 +00:00
LibWeb: Port AttributeNames to FlyString
This commit is contained in:
parent
6a3f27509f
commit
e4f8c59210
93 changed files with 148 additions and 149 deletions
|
@ -115,7 +115,7 @@ void Attr::handle_attribute_changes(Element& element, DeprecatedString const& ol
|
|||
}
|
||||
|
||||
// 3. Run the attribute change steps with element, attribute’s local name, oldValue, newValue, and attribute’s namespace.
|
||||
element.run_attribute_change_steps(local_name().to_deprecated_fly_string(), old_value, new_value, deprecated_namespace_uri);
|
||||
element.run_attribute_change_steps(local_name(), old_value, new_value, deprecated_namespace_uri);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ static bool build_image_document(DOM::Document& document, ByteBuffer const& data
|
|||
MUST(html_element->append_child(body_element));
|
||||
|
||||
auto image_element = DOM::create_element(document, HTML::TagNames::img, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
|
||||
MUST(image_element->set_attribute(HTML::AttributeNames::src, document.url().to_deprecated_string()));
|
||||
MUST(image_element->set_attribute(HTML::AttributeNames::src, MUST(document.url().to_string())));
|
||||
MUST(body_element->append_child(image_element));
|
||||
|
||||
return true;
|
||||
|
@ -170,9 +170,9 @@ static bool build_video_document(DOM::Document& document)
|
|||
MUST(html_element->append_child(body_element));
|
||||
|
||||
auto video_element = DOM::create_element(document, HTML::TagNames::video, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
|
||||
MUST(video_element->set_attribute(HTML::AttributeNames::src, document.url().to_deprecated_string()));
|
||||
MUST(video_element->set_attribute(HTML::AttributeNames::autoplay, DeprecatedString::empty()));
|
||||
MUST(video_element->set_attribute(HTML::AttributeNames::controls, DeprecatedString::empty()));
|
||||
MUST(video_element->set_attribute(HTML::AttributeNames::src, MUST(document.url().to_string())));
|
||||
MUST(video_element->set_attribute(HTML::AttributeNames::autoplay, String {}));
|
||||
MUST(video_element->set_attribute(HTML::AttributeNames::controls, String {}));
|
||||
MUST(body_element->append_child(video_element));
|
||||
|
||||
return true;
|
||||
|
@ -190,9 +190,9 @@ static bool build_audio_document(DOM::Document& document)
|
|||
MUST(html_element->append_child(body_element));
|
||||
|
||||
auto video_element = DOM::create_element(document, HTML::TagNames::audio, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
|
||||
MUST(video_element->set_attribute(HTML::AttributeNames::src, document.url().to_deprecated_string()));
|
||||
MUST(video_element->set_attribute(HTML::AttributeNames::autoplay, DeprecatedString::empty()));
|
||||
MUST(video_element->set_attribute(HTML::AttributeNames::controls, DeprecatedString::empty()));
|
||||
MUST(video_element->set_attribute(HTML::AttributeNames::src, MUST(document.url().to_string())));
|
||||
MUST(video_element->set_attribute(HTML::AttributeNames::autoplay, String {}));
|
||||
MUST(video_element->set_attribute(HTML::AttributeNames::controls, String {}));
|
||||
MUST(body_element->append_child(video_element));
|
||||
|
||||
return true;
|
||||
|
|
|
@ -468,7 +468,7 @@ void Element::add_attribute_change_steps(AttributeChangeSteps steps)
|
|||
m_attribute_change_steps.append(move(steps));
|
||||
}
|
||||
|
||||
void Element::run_attribute_change_steps(DeprecatedFlyString const& local_name, DeprecatedString const& old_value, DeprecatedString const& value, DeprecatedFlyString const& namespace_)
|
||||
void Element::run_attribute_change_steps(FlyString const& local_name, DeprecatedString const& old_value, DeprecatedString const& value, DeprecatedFlyString const& namespace_)
|
||||
{
|
||||
for (auto const& attribute_change_steps : m_attribute_change_steps)
|
||||
attribute_change_steps(local_name, old_value, value, namespace_);
|
||||
|
@ -478,7 +478,7 @@ void Element::run_attribute_change_steps(DeprecatedFlyString const& local_name,
|
|||
invalidate_style_after_attribute_change(local_name);
|
||||
}
|
||||
|
||||
void Element::attribute_changed(DeprecatedFlyString const& name, DeprecatedString const& value)
|
||||
void Element::attribute_changed(FlyString const& name, DeprecatedString const& value)
|
||||
{
|
||||
if (name == HTML::AttributeNames::class_) {
|
||||
auto new_classes = value.split_view(Infra::is_ascii_whitespace);
|
||||
|
@ -614,7 +614,7 @@ NonnullRefPtr<CSS::StyleProperties> Element::resolved_css_values()
|
|||
DOMTokenList* Element::class_list()
|
||||
{
|
||||
if (!m_class_list)
|
||||
m_class_list = DOMTokenList::create(*this, FlyString::from_deprecated_fly_string(HTML::AttributeNames::class_).release_value());
|
||||
m_class_list = DOMTokenList::create(*this, HTML::AttributeNames::class_);
|
||||
return m_class_list;
|
||||
}
|
||||
|
||||
|
@ -1026,7 +1026,7 @@ i32 Element::tab_index() const
|
|||
// https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex
|
||||
void Element::set_tab_index(i32 tab_index)
|
||||
{
|
||||
MUST(set_attribute(HTML::AttributeNames::tabindex, DeprecatedString::number(tab_index)));
|
||||
MUST(set_attribute(HTML::AttributeNames::tabindex, MUST(String::number(tab_index))));
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom-view/#potentially-scrollable
|
||||
|
@ -1583,7 +1583,7 @@ ErrorOr<void> Element::scroll_into_view(Optional<Variant<bool, ScrollIntoViewOpt
|
|||
// FIXME: 8. Optionally perform some other action that brings the element to the user’s attention.
|
||||
}
|
||||
|
||||
void Element::invalidate_style_after_attribute_change(DeprecatedFlyString const& attribute_name)
|
||||
void Element::invalidate_style_after_attribute_change(FlyString const& attribute_name)
|
||||
{
|
||||
// FIXME: Only invalidate if the attribute can actually affect style.
|
||||
(void)attribute_name;
|
||||
|
@ -1873,11 +1873,11 @@ void Element::set_prefix(Optional<FlyString> value)
|
|||
m_qualified_name.set_prefix(move(value));
|
||||
}
|
||||
|
||||
void Element::for_each_attribute(Function<void(DeprecatedFlyString const&, DeprecatedString const&)> callback) const
|
||||
void Element::for_each_attribute(Function<void(FlyString const&, DeprecatedString const&)> callback) const
|
||||
{
|
||||
for (size_t i = 0; i < m_attributes->length(); ++i) {
|
||||
auto const* attribute = m_attributes->item(i);
|
||||
callback(attribute->name().to_deprecated_fly_string(), attribute->value().to_deprecated_string());
|
||||
callback(attribute->name(), attribute->value().to_deprecated_string());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ public:
|
|||
int client_width() const;
|
||||
int client_height() const;
|
||||
|
||||
void for_each_attribute(Function<void(DeprecatedFlyString const&, DeprecatedString const&)>) const;
|
||||
void for_each_attribute(Function<void(FlyString const&, DeprecatedString const&)>) const;
|
||||
|
||||
bool has_class(FlyString const&, CaseSensitivity = CaseSensitivity::CaseSensitive) const;
|
||||
Vector<FlyString> const& class_names() const { return m_classes; }
|
||||
|
@ -153,11 +153,11 @@ public:
|
|||
virtual void apply_presentational_hints(CSS::StyleProperties&) const { }
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-element-attributes-change-ext
|
||||
using AttributeChangeSteps = Function<void(DeprecatedFlyString const& /*local_name*/, DeprecatedString const& /*old_value*/, DeprecatedString const& /*value*/, DeprecatedFlyString const& /*namespace_*/)>;
|
||||
using AttributeChangeSteps = Function<void(FlyString const& /*local_name*/, DeprecatedString const& /*old_value*/, DeprecatedString const& /*value*/, DeprecatedFlyString const& /*namespace_*/)>;
|
||||
|
||||
void add_attribute_change_steps(AttributeChangeSteps steps);
|
||||
void run_attribute_change_steps(DeprecatedFlyString const& local_name, DeprecatedString const& old_value, DeprecatedString const& value, DeprecatedFlyString const& namespace_);
|
||||
virtual void attribute_changed(DeprecatedFlyString const& name, DeprecatedString const& value);
|
||||
void run_attribute_change_steps(FlyString const& local_name, DeprecatedString const& old_value, DeprecatedString const& value, DeprecatedFlyString const& namespace_);
|
||||
virtual void attribute_changed(FlyString const& name, DeprecatedString const& value);
|
||||
|
||||
struct [[nodiscard]] RequiredInvalidationAfterStyleChange {
|
||||
bool repaint { false };
|
||||
|
@ -386,7 +386,7 @@ protected:
|
|||
private:
|
||||
void make_html_uppercased_qualified_name();
|
||||
|
||||
void invalidate_style_after_attribute_change(DeprecatedFlyString const& attribute_name);
|
||||
void invalidate_style_after_attribute_change(FlyString const& attribute_name);
|
||||
|
||||
WebIDL::ExceptionOr<JS::GCPtr<Node>> insert_adjacent(DeprecatedString const& where, JS::NonnullGCPtr<Node> node);
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ const HTML::HTMLElement* Node::enclosing_html_element() const
|
|||
return first_ancestor_of_type<HTML::HTMLElement>();
|
||||
}
|
||||
|
||||
const HTML::HTMLElement* Node::enclosing_html_element_with_attribute(DeprecatedFlyString const& attribute) const
|
||||
const HTML::HTMLElement* Node::enclosing_html_element_with_attribute(FlyString const& attribute) const
|
||||
{
|
||||
for (auto* node = this; node; node = node->parent()) {
|
||||
if (is<HTML::HTMLElement>(*node) && verify_cast<HTML::HTMLElement>(*node).has_attribute(attribute))
|
||||
|
@ -815,7 +815,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, value));
|
||||
MUST(element_copy->set_attribute(name, MUST(String::from_deprecated_string(value))));
|
||||
});
|
||||
copy = move(element_copy);
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ public:
|
|||
|
||||
const HTML::HTMLAnchorElement* enclosing_link_element() const;
|
||||
const HTML::HTMLElement* enclosing_html_element() const;
|
||||
const HTML::HTMLElement* enclosing_html_element_with_attribute(DeprecatedFlyString const&) const;
|
||||
const HTML::HTMLElement* enclosing_html_element_with_attribute(FlyString const&) const;
|
||||
|
||||
DeprecatedString child_text_content() const;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue