Selaa lähdekoodia

LibWeb: Update `Location::reload()` to use navigables

Aliaksandr Kalenik 1 vuosi sitten
vanhempi
commit
083e4a3f30

+ 11 - 2
Userland/Libraries/LibWeb/HTML/Location.cpp

@@ -359,8 +359,17 @@ WebIDL::ExceptionOr<void> Location::set_hash(String const& value)
 // https://html.spec.whatwg.org/multipage/history.html#dom-location-reload
 // https://html.spec.whatwg.org/multipage/history.html#dom-location-reload
 void Location::reload() const
 void Location::reload() const
 {
 {
-    auto& window = verify_cast<HTML::Window>(HTML::current_global_object());
-    window.did_call_location_reload({});
+    // 1. Let document be this's relevant Document.
+    auto document = relevant_document();
+
+    // 2. If document is null, then return.
+    if (!document)
+        return;
+    
+    // FIXME: 3. If document's origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
+
+    // 4. Reload document's node navigable.
+    document->navigable()->reload();
 }
 }
 
 
 // https://html.spec.whatwg.org/multipage/history.html#dom-location-replace
 // https://html.spec.whatwg.org/multipage/history.html#dom-location-replace

+ 0 - 8
Userland/Libraries/LibWeb/HTML/Window.cpp

@@ -429,14 +429,6 @@ void Window::did_set_location_href(Badge<Location>, AK::URL const& new_href)
     browsing_context->loader().load(new_href, FrameLoader::Type::Navigation);
     browsing_context->loader().load(new_href, FrameLoader::Type::Navigation);
 }
 }
 
 
-void Window::did_call_location_reload(Badge<Location>)
-{
-    auto* browsing_context = associated_document().browsing_context();
-    if (!browsing_context)
-        return;
-    browsing_context->loader().load(associated_document().url(), FrameLoader::Type::Reload);
-}
-
 void Window::did_call_location_replace(Badge<Location>, DeprecatedString url)
 void Window::did_call_location_replace(Badge<Location>, DeprecatedString url)
 {
 {
     auto* browsing_context = associated_document().browsing_context();
     auto* browsing_context = associated_document().browsing_context();

+ 0 - 1
Userland/Libraries/LibWeb/HTML/Window.h

@@ -96,7 +96,6 @@ public:
     bool has_animation_frame_callbacks() const { return m_animation_frame_callback_driver.has_callbacks(); }
     bool has_animation_frame_callbacks() const { return m_animation_frame_callback_driver.has_callbacks(); }
 
 
     void did_set_location_href(Badge<Location>, AK::URL const& new_href);
     void did_set_location_href(Badge<Location>, AK::URL const& new_href);
-    void did_call_location_reload(Badge<Location>);
     void did_call_location_replace(Badge<Location>, DeprecatedString url);
     void did_call_location_replace(Badge<Location>, DeprecatedString url);
 
 
     DOM::Event* current_event() { return m_current_event.ptr(); }
     DOM::Event* current_event() { return m_current_event.ptr(); }