mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 22:15:07 +00:00
LibWeb: Rename Document::complete_url() => parse_url()
This better matches the spec nomenclature.
This commit is contained in:
parent
0839442da5
commit
e1fb8bef09
12 changed files with 18 additions and 16 deletions
|
@ -50,7 +50,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::href_setter)
|
||||||
auto new_href = vm.argument(0).to_string(global_object);
|
auto new_href = vm.argument(0).to_string(global_object);
|
||||||
if (vm.exception())
|
if (vm.exception())
|
||||||
return {};
|
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()) {
|
if (!href_url.is_valid()) {
|
||||||
vm.throw_exception<JS::URIError>(global_object, String::formatted("Invalid URL '{}'", new_href));
|
vm.throw_exception<JS::URIError>(global_object, String::formatted("Invalid URL '{}'", new_href));
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -381,9 +381,11 @@ CSS::Repeat Document::background_repeat_y() const
|
||||||
return body_layout_node->computed_values().background_repeat_y();
|
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()
|
void Document::invalidate_layout()
|
||||||
|
|
|
@ -69,7 +69,7 @@ public:
|
||||||
|
|
||||||
bool is_scripting_enabled() const { return true; }
|
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; }
|
CSS::StyleResolver& style_resolver() { return *m_style_resolver; }
|
||||||
const CSS::StyleResolver& style_resolver() const { return *m_style_resolver; }
|
const CSS::StyleResolver& style_resolver() const { return *m_style_resolver; }
|
||||||
|
|
|
@ -55,7 +55,7 @@ void HTMLBodyElement::parse_attribute(const FlyString& name, const String& value
|
||||||
if (color.has_value())
|
if (color.has_value())
|
||||||
document().set_visited_link_color(color.value());
|
document().set_visited_link_color(color.value());
|
||||||
} else if (name.equals_ignoring_case("background")) {
|
} 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()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ void HTMLFormElement::submit_form(RefPtr<HTMLElement> submitter, bool from_submi
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
URL url(document().complete_url(action()));
|
URL url(document().parse_url(action()));
|
||||||
|
|
||||||
if (!url.is_valid()) {
|
if (!url.is_valid()) {
|
||||||
dbgln("Failed to submit form: Invalid URL: {}", action());
|
dbgln("Failed to submit form: Invalid URL: {}", action());
|
||||||
|
|
|
@ -49,7 +49,7 @@ void HTMLIFrameElement::load_src(const String& value)
|
||||||
if (value.is_null())
|
if (value.is_null())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto url = document().complete_url(value);
|
auto url = document().parse_url(value);
|
||||||
if (!url.is_valid()) {
|
if (!url.is_valid()) {
|
||||||
dbgln("iframe failed to load URL: Invalid URL: {}", value);
|
dbgln("iframe failed to load URL: Invalid URL: {}", value);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -65,7 +65,7 @@ void HTMLImageElement::parse_attribute(const FlyString& name, const String& valu
|
||||||
HTMLElement::parse_attribute(name, value);
|
HTMLElement::parse_attribute(name, value);
|
||||||
|
|
||||||
if (name == HTML::AttributeNames::src && !value.is_empty())
|
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()
|
RefPtr<Layout::Node> HTMLImageElement::create_layout_node()
|
||||||
|
|
|
@ -32,7 +32,7 @@ void HTMLLinkElement::inserted()
|
||||||
HTMLElement::inserted();
|
HTMLElement::inserted();
|
||||||
|
|
||||||
if (m_relationship & Relationship::Stylesheet && !(m_relationship & Relationship::Alternate)) {
|
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())
|
if (auto sheet = m_css_loader.style_sheet())
|
||||||
document().style_sheets().add_sheet(sheet.release_nonnull());
|
document().style_sheets().add_sheet(sheet.release_nonnull());
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ void HTMLObjectElement::parse_attribute(const FlyString& name, const String& val
|
||||||
HTMLElement::parse_attribute(name, value);
|
HTMLElement::parse_attribute(name, value);
|
||||||
|
|
||||||
if (name == HTML::AttributeNames::data)
|
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()
|
RefPtr<Layout::Node> HTMLObjectElement::create_layout_node()
|
||||||
|
|
|
@ -255,7 +255,7 @@ void HTMLScriptElement::prepare_script()
|
||||||
m_from_an_external_file = true;
|
m_from_an_external_file = true;
|
||||||
|
|
||||||
// 4. Parse src relative to the element's node document.
|
// 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.
|
// 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()) {
|
if (!url.is_valid()) {
|
||||||
dbgln("HTMLScriptElement: Refusing to run script because the src URL '{}' is invalid.", url);
|
dbgln("HTMLScriptElement: Refusing to run script because the src URL '{}' is invalid.", url);
|
||||||
|
|
|
@ -220,7 +220,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt
|
||||||
|
|
||||||
if (button == GUI::MouseButton::Right && is<HTML::HTMLImageElement>(*node)) {
|
if (button == GUI::MouseButton::Right && is<HTML::HTMLImageElement>(*node)) {
|
||||||
auto& image_element = verify_cast<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())
|
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());
|
page->client().page_did_request_image_context_menu(m_frame.to_top_level_position(position), image_url, "", modifiers, image_element.bitmap());
|
||||||
return true;
|
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()) {
|
if (RefPtr<HTML::HTMLAnchorElement> link = node->enclosing_link_element()) {
|
||||||
auto href = link->href();
|
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);
|
dbgln("Web::EventHandler: Clicking on a link to {}", url);
|
||||||
if (button == GUI::MouseButton::Left) {
|
if (button == GUI::MouseButton::Left) {
|
||||||
if (href.starts_with("javascript:")) {
|
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();
|
page->client().page_did_leave_tooltip_area();
|
||||||
}
|
}
|
||||||
if (is_hovering_link)
|
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
|
else
|
||||||
page->client().page_did_unhover_link();
|
page->client().page_did_unhover_link();
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ DOM::ExceptionOr<void> XMLHttpRequest::open(const String& method, const String&
|
||||||
|
|
||||||
auto normalized_method = normalize_method(method);
|
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())
|
if (!parsed_url.is_valid())
|
||||||
return DOM::SyntaxError::create("Invalid URL");
|
return DOM::SyntaxError::create("Invalid URL");
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ DOM::ExceptionOr<void> XMLHttpRequest::send()
|
||||||
|
|
||||||
// FIXME: If body is not null, then:
|
// 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);
|
dbgln("XHR send from {} to {}", m_window->associated_document().url(), request_url);
|
||||||
|
|
||||||
// TODO: Add support for preflight requests to support CORS requests
|
// TODO: Add support for preflight requests to support CORS requests
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue