|
@@ -43,6 +43,7 @@
|
|
#include <LibWeb/HTML/EventNames.h>
|
|
#include <LibWeb/HTML/EventNames.h>
|
|
#include <LibWeb/HTML/HTMLAnchorElement.h>
|
|
#include <LibWeb/HTML/HTMLAnchorElement.h>
|
|
#include <LibWeb/HTML/HTMLAreaElement.h>
|
|
#include <LibWeb/HTML/HTMLAreaElement.h>
|
|
|
|
+#include <LibWeb/HTML/HTMLBaseElement.h>
|
|
#include <LibWeb/HTML/HTMLBodyElement.h>
|
|
#include <LibWeb/HTML/HTMLBodyElement.h>
|
|
#include <LibWeb/HTML/HTMLEmbedElement.h>
|
|
#include <LibWeb/HTML/HTMLEmbedElement.h>
|
|
#include <LibWeb/HTML/HTMLFormElement.h>
|
|
#include <LibWeb/HTML/HTMLFormElement.h>
|
|
@@ -523,11 +524,49 @@ Vector<CSS::BackgroundLayerData> const* Document::background_layers() const
|
|
return &body_layout_node->background_layers();
|
|
return &body_layout_node->background_layers();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+RefPtr<HTML::HTMLBaseElement> Document::first_base_element_with_href_in_tree_order() const
|
|
|
|
+{
|
|
|
|
+ RefPtr<HTML::HTMLBaseElement> base_element;
|
|
|
|
+
|
|
|
|
+ for_each_in_subtree_of_type<HTML::HTMLBaseElement>([&base_element](HTML::HTMLBaseElement const& base_element_in_tree) {
|
|
|
|
+ if (base_element_in_tree.has_attribute(HTML::AttributeNames::href)) {
|
|
|
|
+ base_element = base_element_in_tree;
|
|
|
|
+ return IterationDecision::Break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return IterationDecision::Continue;
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ return base_element;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#fallback-base-url
|
|
|
|
+AK::URL Document::fallback_base_url() const
|
|
|
|
+{
|
|
|
|
+ // FIXME: 1. If document is an iframe srcdoc document, then return the document base URL of document's browsing context's container document.
|
|
|
|
+ // FIXME: 2. If document's URL is about:blank, and document's browsing context's creator base URL is non-null, then return that creator base URL.
|
|
|
|
+
|
|
|
|
+ // 3. Return document's URL.
|
|
|
|
+ return m_url;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#document-base-url
|
|
|
|
+AK::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.
|
|
|
|
+ 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.
|
|
|
|
+ return base_element->frozen_base_url();
|
|
|
|
+}
|
|
|
|
+
|
|
// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#parse-a-url
|
|
// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#parse-a-url
|
|
AK::URL Document::parse_url(String const& url) const
|
|
AK::URL Document::parse_url(String const& url) const
|
|
{
|
|
{
|
|
- // FIXME: Make sure we do this according to spec.
|
|
|
|
- return m_url.complete_url(url);
|
|
|
|
|
|
+ // FIXME: Pass in document's character encoding.
|
|
|
|
+ return base_url().complete_url(url);
|
|
}
|
|
}
|
|
|
|
|
|
void Document::set_needs_layout()
|
|
void Document::set_needs_layout()
|