mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-14 10:20:36 +00:00
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.
This commit is contained in:
parent
b2f3aa1c76
commit
3e0849eb4f
Notes:
sideshowbarker
2024-07-17 07:09:53 +09:00
Author: https://github.com/shannonbooth Commit: https://github.com/SerenityOS/serenity/commit/3e0849eb4f Pull-request: https://github.com/SerenityOS/serenity/pull/21024 Reviewed-by: https://github.com/AtkinsSJ ✅
3 changed files with 13 additions and 2 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/FlyString.h>
|
||||
#include <AK/Forward.h>
|
||||
#include <LibJS/Heap/GCPtr.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
@ -17,6 +18,11 @@ namespace Web::DOM {
|
|||
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;
|
||||
|
@ -30,6 +36,11 @@ public:
|
|||
return found_element;
|
||||
}
|
||||
|
||||
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;
|
||||
|
|
|
@ -100,7 +100,7 @@ JS::GCPtr<SVGGradientElement const> 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<SVGGradientElement>(*element))
|
||||
|
|
|
@ -49,7 +49,7 @@ Optional<Gfx::PaintStyle const&> 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<SVG::SVGGradientElement>(*gradient))
|
||||
|
|
Loading…
Reference in a new issue