mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-06 08:10:02 +00:00
LibWeb/CSS: Use CSS::URL for <url>
and <paint>
types
This commit is contained in:
parent
d301510ab2
commit
326933cd93
Notes:
github-actions[bot]
2025-04-30 16:39:41 +00:00
Author: https://github.com/AtkinsSJ
Commit: 326933cd93
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4531
7 changed files with 40 additions and 26 deletions
|
@ -8,6 +8,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <LibGfx/PaintStyle.h>
|
||||
#include <LibWeb/CSS/URL.h>
|
||||
#include <LibWeb/DOM/Node.h>
|
||||
#include <LibWeb/SVG/AttributeParser.h>
|
||||
#include <LibWeb/SVG/SVGAnimatedTransformList.h>
|
||||
|
@ -91,6 +92,21 @@ protected:
|
|||
return {};
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
GC::Ptr<T> try_resolve_url_to(CSS::URL const& url) const
|
||||
{
|
||||
// FIXME: Complete and use the entire URL, not just the fragment.
|
||||
Optional<FlyString> fragment;
|
||||
if (auto fragment_offset = url.url().find_byte_offset('#'); fragment_offset.has_value()) {
|
||||
fragment = MUST(url.url().substring_from_byte_offset_with_shared_superstring(fragment_offset.value() + 1));
|
||||
}
|
||||
if (!fragment.has_value())
|
||||
return {};
|
||||
if (auto node = document().get_element_by_id(*fragment); node && is<T>(*node))
|
||||
return static_cast<T&>(*node);
|
||||
return {};
|
||||
}
|
||||
|
||||
private:
|
||||
virtual bool is_svg_graphics_element() const final { return true; }
|
||||
float resolve_relative_to_viewport_size(CSS::LengthPercentage const& length_percentage) const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue