Ver código fonte

LibWeb: Call process_the_iframe_attributes if iframe attribute changed

Replaces `load_src()` with `process_the_iframe_attributes()`. Both load
document of iframe but the latter is defined in spec.
Aliaksandr Kalenik 1 ano atrás
pai
commit
d8cfe79a20

+ 2 - 24
Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp

@@ -35,8 +35,8 @@ JS::GCPtr<Layout::Node> HTMLIFrameElement::create_layout_node(NonnullRefPtr<CSS:
 void HTMLIFrameElement::attribute_changed(DeprecatedFlyString const& name, DeprecatedString const& value)
 {
     HTMLElement::attribute_changed(name, value);
-    if (name == HTML::AttributeNames::src)
-        load_src(value);
+    if (m_nested_browsing_context)
+        process_the_iframe_attributes();
 }
 
 // https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-iframe-element:the-iframe-element-6
@@ -109,28 +109,6 @@ void HTMLIFrameElement::removed_from(DOM::Node* node)
     }
 }
 
-void HTMLIFrameElement::load_src(DeprecatedString const& value)
-{
-    if (!m_nested_browsing_context)
-        return;
-
-    if (value.is_null())
-        return;
-
-    auto url = document().parse_url(value);
-    if (!url.is_valid()) {
-        dbgln("iframe failed to load URL: Invalid URL: {}", value);
-        return;
-    }
-    if (url.scheme() == "file" && document().origin().scheme() != "file") {
-        dbgln("iframe failed to load URL: Security violation: {} may not load {}", document().url(), url);
-        return;
-    }
-
-    dbgln("Loading iframe document from {}", value);
-    m_nested_browsing_context->loader().load(url, FrameLoader::Type::IFrame);
-}
-
 // https://html.spec.whatwg.org/multipage/rendering.html#attributes-for-embedded-content-and-images
 void HTMLIFrameElement::apply_presentational_hints(CSS::StyleProperties& style) const
 {

+ 0 - 2
Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.h

@@ -39,8 +39,6 @@ private:
     // https://html.spec.whatwg.org/multipage/iframe-embed-object.html#process-the-iframe-attributes
     void process_the_iframe_attributes(bool initial_insertion = false);
 
-    void load_src(DeprecatedString const&);
-
     // https://html.spec.whatwg.org/multipage/iframe-embed-object.html#current-navigation-was-lazy-loaded
     bool m_current_navigation_was_lazy_loaded { false };
 };