mirror of
https://github.com/SerenityOS/serenity
synced 2024-07-21 10:05:32 +00:00
LibWeb: Port get_element_by_id from DeprecatedFlyString
We needed to keep the old versions of these functions around before all of the IDL interfaces were ported over to new AK String, but now that is done, we can remove the deprecated versions of these functions.
This commit is contained in:
parent
b37aab1277
commit
48f367adbb
|
@ -1733,7 +1733,7 @@ Document::IndicatedPart Document::determine_the_indicated_part() const
|
|||
return Document::TopOfTheDocument {};
|
||||
|
||||
// 3. Let potentialIndicatedElement be the result of finding a potential indicated element given document and fragment.
|
||||
auto* potential_indicated_element = find_a_potential_indicated_element(fragment.to_deprecated_string());
|
||||
auto* potential_indicated_element = find_a_potential_indicated_element(fragment);
|
||||
|
||||
// 4. If potentialIndicatedElement is not null, then return potentialIndicatedElement.
|
||||
if (potential_indicated_element)
|
||||
|
@ -1744,7 +1744,7 @@ Document::IndicatedPart Document::determine_the_indicated_part() const
|
|||
auto decoded_fragment = AK::URL::percent_decode(fragment);
|
||||
|
||||
// 7. Set potentialIndicatedElement to the result of finding a potential indicated element given document and decodedFragment.
|
||||
potential_indicated_element = find_a_potential_indicated_element(decoded_fragment);
|
||||
potential_indicated_element = find_a_potential_indicated_element(MUST(FlyString::from_deprecated_fly_string(decoded_fragment)));
|
||||
|
||||
// 8. If potentialIndicatedElement is not null, then return potentialIndicatedElement.
|
||||
if (potential_indicated_element)
|
||||
|
@ -1759,7 +1759,7 @@ Document::IndicatedPart Document::determine_the_indicated_part() const
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#find-a-potential-indicated-element
|
||||
Element* Document::find_a_potential_indicated_element(DeprecatedString fragment) const
|
||||
Element* Document::find_a_potential_indicated_element(FlyString const& fragment) const
|
||||
{
|
||||
// To find a potential indicated element given a Document document and a string fragment, run these steps:
|
||||
|
||||
|
@ -1772,7 +1772,7 @@ Element* Document::find_a_potential_indicated_element(DeprecatedString fragment)
|
|||
// whose value is equal to fragment, then return the first such element in tree order.
|
||||
Element* element_with_name;
|
||||
root().for_each_in_subtree_of_type<Element>([&](Element const& element) {
|
||||
if (element.name() == fragment) {
|
||||
if (element.attribute(HTML::AttributeNames::name) == fragment) {
|
||||
element_with_name = const_cast<Element*>(&element);
|
||||
return IterationDecision::Break;
|
||||
}
|
||||
|
|
|
@ -554,7 +554,7 @@ private:
|
|||
void queue_intersection_observer_task();
|
||||
void queue_an_intersection_observer_entry(IntersectionObserver::IntersectionObserver&, HighResolutionTime::DOMHighResTimeStamp time, JS::NonnullGCPtr<Geometry::DOMRectReadOnly> root_bounds, JS::NonnullGCPtr<Geometry::DOMRectReadOnly> bounding_client_rect, JS::NonnullGCPtr<Geometry::DOMRectReadOnly> intersection_rect, bool is_intersecting, double intersection_ratio, JS::NonnullGCPtr<Element> target);
|
||||
|
||||
Element* find_a_potential_indicated_element(DeprecatedString fragment) const;
|
||||
Element* find_a_potential_indicated_element(FlyString const& fragment) const;
|
||||
|
||||
OwnPtr<CSS::StyleComputer> m_style_computer;
|
||||
JS::GCPtr<CSS::StyleSheetList> m_style_sheets;
|
||||
|
|
|
@ -1937,7 +1937,7 @@ void Element::scroll(HTML::ScrollToOptions const&)
|
|||
|
||||
bool Element::id_reference_exists(DeprecatedString const& id_reference) const
|
||||
{
|
||||
return document().get_element_by_id(id_reference);
|
||||
return document().get_element_by_id(MUST(FlyString::from_deprecated_fly_string(id_reference)));
|
||||
}
|
||||
|
||||
void Element::register_intersection_observer(Badge<IntersectionObserver::IntersectionObserver>, IntersectionObserver::IntersectionObserverRegistration registration)
|
||||
|
|
|
@ -1802,7 +1802,7 @@ ErrorOr<String> Node::name_or_description(NameOrDescription target, Document con
|
|||
}
|
||||
// ii. For each IDREF:
|
||||
for (auto const& id_ref : id_list) {
|
||||
auto node = document.get_element_by_id(id_ref);
|
||||
auto node = document.get_element_by_id(MUST(FlyString::from_utf8(id_ref)));
|
||||
if (!node)
|
||||
continue;
|
||||
|
||||
|
@ -1922,7 +1922,7 @@ ErrorOr<String> Node::accessible_description(Document const& document) const
|
|||
StringBuilder builder;
|
||||
auto id_list = described_by->bytes_as_string_view().split_view_if(Infra::is_ascii_whitespace);
|
||||
for (auto const& id : id_list) {
|
||||
if (auto description_element = document.get_element_by_id(id)) {
|
||||
if (auto description_element = document.get_element_by_id(MUST(FlyString::from_utf8(id)))) {
|
||||
auto description = TRY(
|
||||
description_element->name_or_description(NameOrDescription::Description, document,
|
||||
visited_nodes));
|
||||
|
@ -1943,7 +1943,7 @@ Optional<StringView> Node::first_valid_id(DeprecatedString const& value, Documen
|
|||
{
|
||||
auto id_list = value.split_view(Infra::is_ascii_whitespace);
|
||||
for (auto const& id : id_list) {
|
||||
if (document.get_element_by_id(id))
|
||||
if (document.get_element_by_id(MUST(FlyString::from_utf8(id))))
|
||||
return id;
|
||||
}
|
||||
return {};
|
||||
|
|
|
@ -19,15 +19,10 @@ template<typename NodeType>
|
|||
class NonElementParentNode {
|
||||
public:
|
||||
JS::GCPtr<Element const> get_element_by_id(FlyString const& id) const
|
||||
{
|
||||
return get_element_by_id(id.to_deprecated_fly_string());
|
||||
}
|
||||
|
||||
JS::GCPtr<Element const> get_element_by_id(DeprecatedFlyString const& id) const
|
||||
{
|
||||
JS::GCPtr<Element const> found_element;
|
||||
static_cast<NodeType const*>(this)->template for_each_in_inclusive_subtree_of_type<Element>([&](auto& element) {
|
||||
if (element.deprecated_attribute(HTML::AttributeNames::id) == id) {
|
||||
if (element.attribute(HTML::AttributeNames::id) == id) {
|
||||
found_element = &element;
|
||||
return IterationDecision::Break;
|
||||
}
|
||||
|
@ -37,15 +32,10 @@ public:
|
|||
}
|
||||
|
||||
JS::GCPtr<Element> get_element_by_id(FlyString const& id)
|
||||
{
|
||||
return get_element_by_id(id.to_deprecated_fly_string());
|
||||
}
|
||||
|
||||
JS::GCPtr<Element> get_element_by_id(DeprecatedFlyString const& id)
|
||||
{
|
||||
JS::GCPtr<Element> found_element;
|
||||
static_cast<NodeType*>(this)->template for_each_in_inclusive_subtree_of_type<Element>([&](auto& element) {
|
||||
if (element.deprecated_attribute(HTML::AttributeNames::id) == id) {
|
||||
if (element.attribute(HTML::AttributeNames::id) == id) {
|
||||
found_element = &element;
|
||||
return IterationDecision::Break;
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ JS::GCPtr<DOM::Element> SVGUseElement::referenced_element()
|
|||
}
|
||||
|
||||
// FIXME: Support loading of external svg documents
|
||||
return document().get_element_by_id(m_referenced_id.value());
|
||||
return document().get_element_by_id(MUST(FlyString::from_utf8(m_referenced_id.value())));
|
||||
}
|
||||
|
||||
// https://svgwg.org/svg2-draft/struct.html#UseShadowTree
|
||||
|
|
Loading…
Reference in a new issue