From 3e0849eb4fba52370390ab7ec950c9720265e7d7 Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Mon, 11 Sep 2023 18:23:48 +1200 Subject: [PATCH] LibWeb: Add FlyString variants of get_element_by_id Unfortunately we can't port these functions entirely over to FlyString from DeprecatedString as Document includes NonElementParentNode and has not yet been ported over to new AK string. In the mean time, this should help up in porting over NonElementParentNode itself. --- Userland/Libraries/LibWeb/DOM/NonElementParentNode.h | 11 +++++++++++ Userland/Libraries/LibWeb/SVG/SVGGradientElement.cpp | 2 +- Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/NonElementParentNode.h b/Userland/Libraries/LibWeb/DOM/NonElementParentNode.h index 7f6b166311..0332be2df1 100644 --- a/Userland/Libraries/LibWeb/DOM/NonElementParentNode.h +++ b/Userland/Libraries/LibWeb/DOM/NonElementParentNode.h @@ -6,6 +6,7 @@ #pragma once +#include #include #include #include @@ -17,6 +18,11 @@ namespace Web::DOM { template class NonElementParentNode { public: + JS::GCPtr get_element_by_id(FlyString const& id) const + { + return get_element_by_id(id.to_deprecated_fly_string()); + } + JS::GCPtr get_element_by_id(DeprecatedFlyString const& id) const { JS::GCPtr found_element; @@ -30,6 +36,11 @@ public: return found_element; } + JS::GCPtr get_element_by_id(FlyString const& id) + { + return get_element_by_id(id.to_deprecated_fly_string()); + } + JS::GCPtr get_element_by_id(DeprecatedFlyString const& id) { JS::GCPtr found_element; diff --git a/Userland/Libraries/LibWeb/SVG/SVGGradientElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGGradientElement.cpp index 972986bcca..a4800b5b1e 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGGradientElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGGradientElement.cpp @@ -100,7 +100,7 @@ JS::GCPtr SVGGradientElement::linked_gradient() const auto id = url.fragment(); if (!id.has_value() || id->is_empty()) return {}; - auto element = document().get_element_by_id(id->to_deprecated_string()); + auto element = document().get_element_by_id(id.value()); if (!element) return {}; if (!is(*element)) diff --git a/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp index 23c15d9cca..3145954fa5 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp @@ -49,7 +49,7 @@ Optional SVGGraphicsElement::svg_paint_computed_value_to auto const& url = paint_value->as_url(); if (!url.fragment().has_value()) return {}; - auto gradient = document().get_element_by_id(url.fragment()->to_deprecated_string()); + auto gradient = document().get_element_by_id(url.fragment().value()); if (!gradient) return {}; if (is(*gradient))