summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-09-09 18:08:56 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-09 21:25:10 +0200
commite1fb8bef0907f2da74f81ea0f61457e77451a79f (patch)
tree0caaf09f0343ab077709234a04f1a5c74fb69429
parent0839442da5b5bf03a02b295278f996a07c08e57c (diff)
downloadserenity-e1fb8bef0907f2da74f81ea0f61457e77451a79f.zip
LibWeb: Rename Document::complete_url() => parse_url()
This better matches the spec nomenclature.
-rw-r--r--Userland/Libraries/LibWeb/Bindings/LocationObject.cpp2
-rw-r--r--Userland/Libraries/LibWeb/DOM/Document.cpp6
-rw-r--r--Userland/Libraries/LibWeb/DOM/Document.h2
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLBodyElement.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Page/EventHandler.cpp6
-rw-r--r--Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp4
12 files changed, 18 insertions, 16 deletions
diff --git a/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp b/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp
index 1d819baa44..9a9cdf7b84 100644
--- a/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp
+++ b/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp
@@ -50,7 +50,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::href_setter)
auto new_href = vm.argument(0).to_string(global_object);
if (vm.exception())
return {};
- auto href_url = window.impl().associated_document().complete_url(new_href);
+ auto href_url = window.impl().associated_document().parse_url(new_href);
if (!href_url.is_valid()) {
vm.throw_exception<JS::URIError>(global_object, String::formatted("Invalid URL '{}'", new_href));
return {};
diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp
index c6d8d29e3b..68cb32f1de 100644
--- a/Userland/Libraries/LibWeb/DOM/Document.cpp
+++ b/Userland/Libraries/LibWeb/DOM/Document.cpp
@@ -381,9 +381,11 @@ CSS::Repeat Document::background_repeat_y() const
return body_layout_node->computed_values().background_repeat_y();
}
-URL Document::complete_url(const String& string) const
+// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#parse-a-url
+URL Document::parse_url(String const& url) const
{
- return m_url.complete_url(string);
+ // FIXME: Make sure we do this according to spec.
+ return m_url.complete_url(url);
}
void Document::invalidate_layout()
diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h
index db9a7ea77f..9c59f25fdb 100644
--- a/Userland/Libraries/LibWeb/DOM/Document.h
+++ b/Userland/Libraries/LibWeb/DOM/Document.h
@@ -69,7 +69,7 @@ public:
bool is_scripting_enabled() const { return true; }
- URL complete_url(const String&) const;
+ URL parse_url(String const&) const;
CSS::StyleResolver& style_resolver() { return *m_style_resolver; }
const CSS::StyleResolver& style_resolver() const { return *m_style_resolver; }
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.cpp
index 1b80d1f3e7..5517f48fff 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.cpp
@@ -55,7 +55,7 @@ void HTMLBodyElement::parse_attribute(const FlyString& name, const String& value
if (color.has_value())
document().set_visited_link_color(color.value());
} else if (name.equals_ignoring_case("background")) {
- m_background_style_value = CSS::ImageStyleValue::create(document().complete_url(value), const_cast<DOM::Document&>(document()));
+ m_background_style_value = CSS::ImageStyleValue::create(document().parse_url(value), const_cast<DOM::Document&>(document()));
}
}
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp
index 19756f201b..dbca33611c 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp
@@ -75,7 +75,7 @@ void HTMLFormElement::submit_form(RefPtr<HTMLElement> submitter, bool from_submi
return;
}
- URL url(document().complete_url(action()));
+ URL url(document().parse_url(action()));
if (!url.is_valid()) {
dbgln("Failed to submit form: Invalid URL: {}", action());
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp
index f58b01ea9c..1b5edea58c 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp
@@ -49,7 +49,7 @@ void HTMLIFrameElement::load_src(const String& value)
if (value.is_null())
return;
- auto url = document().complete_url(value);
+ auto url = document().parse_url(value);
if (!url.is_valid()) {
dbgln("iframe failed to load URL: Invalid URL: {}", value);
return;
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp
index e34442cea5..3cbcca10b7 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp
@@ -65,7 +65,7 @@ void HTMLImageElement::parse_attribute(const FlyString& name, const String& valu
HTMLElement::parse_attribute(name, value);
if (name == HTML::AttributeNames::src && !value.is_empty())
- m_image_loader.load(document().complete_url(value));
+ m_image_loader.load(document().parse_url(value));
}
RefPtr<Layout::Node> HTMLImageElement::create_layout_node()
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp
index a2b7b4e6a2..1d3d24da6f 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp
@@ -32,7 +32,7 @@ void HTMLLinkElement::inserted()
HTMLElement::inserted();
if (m_relationship & Relationship::Stylesheet && !(m_relationship & Relationship::Alternate)) {
- m_css_loader.load_from_url(document().complete_url(href()));
+ m_css_loader.load_from_url(document().parse_url(href()));
if (auto sheet = m_css_loader.style_sheet())
document().style_sheets().add_sheet(sheet.release_nonnull());
}
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp
index 1908feb99e..620955ddf8 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp
@@ -38,7 +38,7 @@ void HTMLObjectElement::parse_attribute(const FlyString& name, const String& val
HTMLElement::parse_attribute(name, value);
if (name == HTML::AttributeNames::data)
- m_image_loader.load(document().complete_url(value));
+ m_image_loader.load(document().parse_url(value));
}
RefPtr<Layout::Node> HTMLObjectElement::create_layout_node()
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp
index 1eb80393ce..f92b38fc74 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp
@@ -255,7 +255,7 @@ void HTMLScriptElement::prepare_script()
m_from_an_external_file = true;
// 4. Parse src relative to the element's node document.
- auto url = document().complete_url(src);
+ auto url = document().parse_url(src);
// 5. If the previous step failed, queue a task to fire an event named error at the element, and return. Otherwise, let url be the resulting URL record.
if (!url.is_valid()) {
dbgln("HTMLScriptElement: Refusing to run script because the src URL '{}' is invalid.", url);
diff --git a/Userland/Libraries/LibWeb/Page/EventHandler.cpp b/Userland/Libraries/LibWeb/Page/EventHandler.cpp
index a2da6c10b3..43322fff05 100644
--- a/Userland/Libraries/LibWeb/Page/EventHandler.cpp
+++ b/Userland/Libraries/LibWeb/Page/EventHandler.cpp
@@ -220,7 +220,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt
if (button == GUI::MouseButton::Right && is<HTML::HTMLImageElement>(*node)) {
auto& image_element = verify_cast<HTML::HTMLImageElement>(*node);
- auto image_url = image_element.document().complete_url(image_element.src());
+ auto image_url = image_element.document().parse_url(image_element.src());
if (auto* page = m_frame.page())
page->client().page_did_request_image_context_menu(m_frame.to_top_level_position(position), image_url, "", modifiers, image_element.bitmap());
return true;
@@ -228,7 +228,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt
if (RefPtr<HTML::HTMLAnchorElement> link = node->enclosing_link_element()) {
auto href = link->href();
- auto url = document->complete_url(href);
+ auto url = document->parse_url(href);
dbgln("Web::EventHandler: Clicking on a link to {}", url);
if (button == GUI::MouseButton::Left) {
if (href.starts_with("javascript:")) {
@@ -346,7 +346,7 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt
page->client().page_did_leave_tooltip_area();
}
if (is_hovering_link)
- page->client().page_did_hover_link(document.complete_url(hovered_link_element->href()));
+ page->client().page_did_hover_link(document.parse_url(hovered_link_element->href()));
else
page->client().page_did_unhover_link();
}
diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp
index 2261f58a09..36fbec1182 100644
--- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp
+++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp
@@ -119,7 +119,7 @@ DOM::ExceptionOr<void> XMLHttpRequest::open(const String& method, const String&
auto normalized_method = normalize_method(method);
- auto parsed_url = m_window->associated_document().complete_url(url);
+ auto parsed_url = m_window->associated_document().parse_url(url);
if (!parsed_url.is_valid())
return DOM::SyntaxError::create("Invalid URL");
@@ -166,7 +166,7 @@ DOM::ExceptionOr<void> XMLHttpRequest::send()
// FIXME: If body is not null, then:
- URL request_url = m_window->associated_document().complete_url(m_url.to_string());
+ URL request_url = m_window->associated_document().parse_url(m_url.to_string());
dbgln("XHR send from {} to {}", m_window->associated_document().url(), request_url);
// TODO: Add support for preflight requests to support CORS requests