mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-27 12:46:06 +00:00
parent
7c8c05ee82
commit
0b998b8379
Notes:
github-actions[bot]
2025-08-11 11:24:22 +00:00
Author: https://github.com/AtkinsSJ
Commit: 0b998b8379
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5763
5 changed files with 36 additions and 4 deletions
|
@ -1158,6 +1158,33 @@ GC::Ptr<HTML::HTMLBaseElement> Document::first_base_element_with_target_in_tree_
|
|||
return m_first_base_element_with_target_in_tree_order;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#respond-to-base-url-changes
|
||||
void Document::respond_to_base_url_changes()
|
||||
{
|
||||
// To respond to base URL changes for a Document document:
|
||||
|
||||
// 1. The user agent should update any user interface elements which are displaying affected URLs, or data derived
|
||||
// from such URLs, to the user. Examples of such user interface elements would be a status bar that displays a
|
||||
// hyperlink's url, or some user interface which displays the URL specified by a q, blockquote, ins, or del
|
||||
// element's cite attribute.
|
||||
// FIXME: Update those UI elements.
|
||||
|
||||
// 2. Ensure that the CSS :link/:visited/etc. pseudo-classes are updated appropriately.
|
||||
invalidate_style(StyleInvalidationReason::BaseURLChanged);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#set-the-url
|
||||
void Document::set_url(URL::URL const& url)
|
||||
{
|
||||
// To set the URL for a Document document to a URL record url:
|
||||
|
||||
// 1. Set document's URL to url.
|
||||
m_url = url;
|
||||
|
||||
// 2. Respond to base URL changes given document.
|
||||
respond_to_base_url_changes();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#fallback-base-url
|
||||
URL::URL Document::fallback_base_url() const
|
||||
{
|
||||
|
@ -1181,12 +1208,12 @@ URL::URL Document::fallback_base_url() const
|
|||
// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#document-base-url
|
||||
URL::URL Document::base_url() const
|
||||
{
|
||||
// 1. If there is no base element that has an href attribute in the Document, then return the Document's fallback base URL.
|
||||
// 1. If document has no descendant base element that has an href attribute, then return document's fallback base URL.
|
||||
auto base_element = first_base_element_with_href_in_tree_order();
|
||||
if (!base_element)
|
||||
return fallback_base_url();
|
||||
|
||||
// 2. Otherwise, return the frozen base URL of the first base element in the Document that has an href attribute, in tree order.
|
||||
// 2. Otherwise, return the frozen base URL of the first base element in document that has an href attribute, in tree order.
|
||||
return base_element->frozen_base_url();
|
||||
}
|
||||
|
||||
|
|
|
@ -222,7 +222,7 @@ public:
|
|||
String referrer() const;
|
||||
void set_referrer(String);
|
||||
|
||||
void set_url(const URL::URL& url) { m_url = url; }
|
||||
void set_url(URL::URL const& url);
|
||||
URL::URL url() const { return m_url; }
|
||||
URL::URL fallback_base_url() const;
|
||||
URL::URL base_url() const;
|
||||
|
@ -230,6 +230,7 @@ public:
|
|||
void update_base_element(Badge<HTML::HTMLBaseElement>);
|
||||
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;
|
||||
void respond_to_base_url_changes();
|
||||
|
||||
String url_string() const { return m_url.to_string(); }
|
||||
String document_uri() const { return url_string(); }
|
||||
|
|
|
@ -50,6 +50,7 @@ enum class ShouldComputeRole {
|
|||
|
||||
#define ENUMERATE_STYLE_INVALIDATION_REASONS(X) \
|
||||
X(AdoptedStyleSheetsList) \
|
||||
X(BaseURLChanged) \
|
||||
X(CSSFontLoaded) \
|
||||
X(CSSImportRule) \
|
||||
X(CSSStylePropertiesRemoveProperty) \
|
||||
|
|
|
@ -95,6 +95,9 @@ void HTMLBaseElement::set_the_frozen_base_url()
|
|||
|
||||
// 4. Set element's frozen base URL to urlRecord.
|
||||
m_frozen_base_url = url_record.release_value();
|
||||
|
||||
// 5. Respond to base URL changes given document.
|
||||
document.respond_to_base_url_changes();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/semantics.html#dom-base-href
|
||||
|
|
|
@ -2286,7 +2286,7 @@ void perform_url_and_history_update_steps(DOM::Document& document, URL::URL new_
|
|||
if (serialized_data.has_value())
|
||||
document.restore_the_history_object_state(new_entry);
|
||||
|
||||
// 8. Set document's URL to newURL.
|
||||
// 8. Set the URL given document to newURL.
|
||||
document.set_url(new_url);
|
||||
|
||||
// 9. Set document's latest entry to newEntry.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue