mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-17 07:50:04 +00:00
LibWeb/HTML: Correctly set base elements frozen base url
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, Clang (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, Clang (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
This commit implements the fallback to the documents fallback base url if the href of the first base element is a data or javascript url. Additionally the frozen base url is set, if a base element becomes the first base element with an href content attribute because the previous one got removed.
This commit is contained in:
parent
4ed9f6fcc0
commit
6b84cd8d11
Notes:
github-actions[bot]
2025-06-23 06:57:47 +00:00
Author: https://github.com/skyz1
Commit: 6b84cd8d11
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4558
Reviewed-by: https://github.com/shannonbooth ✅
7 changed files with 103 additions and 12 deletions
|
@ -1135,10 +1135,10 @@ Vector<CSS::BackgroundLayerData> const* Document::background_layers() const
|
|||
|
||||
void Document::update_base_element(Badge<HTML::HTMLBaseElement>)
|
||||
{
|
||||
GC::Ptr<HTML::HTMLBaseElement const> base_element_with_href = nullptr;
|
||||
GC::Ptr<HTML::HTMLBaseElement const> base_element_with_target = nullptr;
|
||||
GC::Ptr<HTML::HTMLBaseElement> base_element_with_href = nullptr;
|
||||
GC::Ptr<HTML::HTMLBaseElement> base_element_with_target = nullptr;
|
||||
|
||||
for_each_in_subtree_of_type<HTML::HTMLBaseElement>([&base_element_with_href, &base_element_with_target](HTML::HTMLBaseElement const& base_element_in_tree) {
|
||||
for_each_in_subtree_of_type<HTML::HTMLBaseElement>([&base_element_with_href, &base_element_with_target](HTML::HTMLBaseElement& base_element_in_tree) {
|
||||
if (!base_element_with_href && base_element_in_tree.has_attribute(HTML::AttributeNames::href)) {
|
||||
base_element_with_href = &base_element_in_tree;
|
||||
if (base_element_with_target)
|
||||
|
@ -1157,12 +1157,12 @@ void Document::update_base_element(Badge<HTML::HTMLBaseElement>)
|
|||
m_first_base_element_with_target_in_tree_order = base_element_with_target;
|
||||
}
|
||||
|
||||
GC::Ptr<HTML::HTMLBaseElement const> Document::first_base_element_with_href_in_tree_order() const
|
||||
GC::Ptr<HTML::HTMLBaseElement> Document::first_base_element_with_href_in_tree_order() const
|
||||
{
|
||||
return m_first_base_element_with_href_in_tree_order;
|
||||
}
|
||||
|
||||
GC::Ptr<HTML::HTMLBaseElement const> Document::first_base_element_with_target_in_tree_order() const
|
||||
GC::Ptr<HTML::HTMLBaseElement> Document::first_base_element_with_target_in_tree_order() const
|
||||
{
|
||||
return m_first_base_element_with_target_in_tree_order;
|
||||
}
|
||||
|
|
|
@ -223,8 +223,8 @@ public:
|
|||
URL::URL base_url() const;
|
||||
|
||||
void update_base_element(Badge<HTML::HTMLBaseElement>);
|
||||
GC::Ptr<HTML::HTMLBaseElement const> first_base_element_with_href_in_tree_order() const;
|
||||
GC::Ptr<HTML::HTMLBaseElement const> first_base_element_with_target_in_tree_order() const;
|
||||
GC::Ptr<HTML::HTMLBaseElement> first_base_element_with_href_in_tree_order() const;
|
||||
GC::Ptr<HTML::HTMLBaseElement> first_base_element_with_target_in_tree_order() const;
|
||||
|
||||
String url_string() const { return m_url.to_string(); }
|
||||
String document_uri() const { return url_string(); }
|
||||
|
@ -1135,8 +1135,8 @@ private:
|
|||
GC::Ptr<Selection::Selection> m_selection;
|
||||
|
||||
// NOTE: This is a cache to make finding the first <base href> or <base target> element O(1).
|
||||
GC::Ptr<HTML::HTMLBaseElement const> m_first_base_element_with_href_in_tree_order;
|
||||
GC::Ptr<HTML::HTMLBaseElement const> m_first_base_element_with_target_in_tree_order;
|
||||
GC::Ptr<HTML::HTMLBaseElement> m_first_base_element_with_href_in_tree_order;
|
||||
GC::Ptr<HTML::HTMLBaseElement> m_first_base_element_with_target_in_tree_order;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/images.html#list-of-available-images
|
||||
GC::Ptr<HTML::ListOfAvailableImages> m_list_of_available_images;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue