mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-11 17:37:33 +02:00
LibWeb: Only invalidate style for relevant links on navigation
This commit is contained in:
committed by
Sam Atkins
parent
f29bc0c996
commit
e211c3dcd5
Notes:
github-actions[bot]
2026-05-08 11:31:32 +00:00
Author: https://github.com/tcl3 Commit: https://github.com/LadybirdBrowser/ladybird/commit/e211c3dcd5e Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/9274 Reviewed-by: https://github.com/AtkinsSJ ✅
@@ -30,6 +30,7 @@ void HTMLBaseElement::inserted()
|
||||
{
|
||||
HTMLElement::inserted();
|
||||
|
||||
auto old_base_url = document().base_url();
|
||||
document().update_base_element({});
|
||||
|
||||
// The frozen base URL must be immediately set for an element whenever any of the following situations occur:
|
||||
@@ -38,20 +39,21 @@ void HTMLBaseElement::inserted()
|
||||
// NOTE: inserted() is called after this element has been inserted into the document.
|
||||
auto first_base_element_with_href_in_document = document().first_base_element_with_href_in_tree_order();
|
||||
if (first_base_element_with_href_in_document.ptr() == this)
|
||||
set_the_frozen_base_url();
|
||||
set_the_frozen_base_url(old_base_url);
|
||||
}
|
||||
|
||||
void HTMLBaseElement::removed_from(IsSubtreeRoot is_subtree_root, Node* old_ancestor, Node& old_root)
|
||||
{
|
||||
HTMLElement::removed_from(is_subtree_root, old_ancestor, old_root);
|
||||
auto old_first_base_element_with_href_in_tree_order = document().first_base_element_with_href_in_tree_order();
|
||||
auto old_base_url = document().base_url();
|
||||
document().update_base_element({});
|
||||
|
||||
// The frozen base URL must be immediately set for an element whenever any of the following situations occur:
|
||||
// - The base element becomes the first base element in tree order with an href content attribute in its Document.
|
||||
auto first_base_element_with_href_in_document = document().first_base_element_with_href_in_tree_order();
|
||||
if (first_base_element_with_href_in_document && first_base_element_with_href_in_document != old_first_base_element_with_href_in_tree_order)
|
||||
first_base_element_with_href_in_document->set_the_frozen_base_url();
|
||||
first_base_element_with_href_in_document->set_the_frozen_base_url(old_base_url);
|
||||
}
|
||||
|
||||
void HTMLBaseElement::attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_)
|
||||
@@ -63,15 +65,16 @@ void HTMLBaseElement::attribute_changed(FlyString const& name, Optional<String>
|
||||
if (name != AttributeNames::href)
|
||||
return;
|
||||
|
||||
auto old_base_url = document().base_url();
|
||||
document().update_base_element({});
|
||||
|
||||
auto first_base_element_with_href_in_document = document().first_base_element_with_href_in_tree_order();
|
||||
if (first_base_element_with_href_in_document.ptr() == this)
|
||||
set_the_frozen_base_url();
|
||||
set_the_frozen_base_url(old_base_url);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/semantics.html#set-the-frozen-base-url
|
||||
void HTMLBaseElement::set_the_frozen_base_url()
|
||||
void HTMLBaseElement::set_the_frozen_base_url(URL::URL const& old_base_url)
|
||||
{
|
||||
// 1. Let document be element's node document.
|
||||
auto& document = this->document();
|
||||
@@ -97,7 +100,7 @@ void HTMLBaseElement::set_the_frozen_base_url()
|
||||
m_frozen_base_url = url_record.release_value();
|
||||
|
||||
// 5. Respond to base URL changes given document.
|
||||
document.respond_to_base_url_changes();
|
||||
document.respond_to_base_url_changes(document.url(), old_base_url);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/semantics.html#dom-base-href
|
||||
|
||||
Reference in New Issue
Block a user