mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:58:11 +00:00
LibWeb: Add a FrameHostElement for frame/iframe common functionality
A FrameHostElement is an HTML element (<frame> or <iframe>) that may have a content frame that participates in the frame tree. This basically just moves code from <iframe> to a separate base class so we can share it with <frame> once we implement <frame>.
This commit is contained in:
parent
8e3e3a71cb
commit
dcfc357860
5 changed files with 124 additions and 48 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -24,25 +24,16 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/WindowObject.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
#include <LibWeb/DOM/Window.h>
|
||||
#include <LibWeb/Dump.h>
|
||||
#include <LibWeb/HTML/EventNames.h>
|
||||
#include <LibWeb/HTML/HTMLFormElement.h>
|
||||
#include <LibWeb/HTML/HTMLIFrameElement.h>
|
||||
#include <LibWeb/HTML/Parser/HTMLDocumentParser.h>
|
||||
#include <LibWeb/InProcessWebView.h>
|
||||
#include <LibWeb/Layout/FrameBox.h>
|
||||
#include <LibWeb/Loader/ResourceLoader.h>
|
||||
#include <LibWeb/Origin.h>
|
||||
#include <LibWeb/Page/Frame.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
HTMLIFrameElement::HTMLIFrameElement(DOM::Document& document, QualifiedName qualified_name)
|
||||
: HTMLElement(document, move(qualified_name))
|
||||
: FrameHostElement(document, move(qualified_name))
|
||||
{
|
||||
VERIFY(document.frame());
|
||||
m_content_frame = Frame::create_subframe(*this, document.frame()->main_frame());
|
||||
|
@ -81,26 +72,4 @@ void HTMLIFrameElement::load_src(const String& value)
|
|||
m_content_frame->loader().load(url, FrameLoader::Type::IFrame);
|
||||
}
|
||||
|
||||
Origin HTMLIFrameElement::content_origin() const
|
||||
{
|
||||
if (!m_content_frame || !m_content_frame->document())
|
||||
return {};
|
||||
return m_content_frame->document()->origin();
|
||||
}
|
||||
|
||||
bool HTMLIFrameElement::may_access_from_origin(const Origin& origin) const
|
||||
{
|
||||
return origin.is_same(content_origin());
|
||||
}
|
||||
|
||||
const DOM::Document* HTMLIFrameElement::content_document() const
|
||||
{
|
||||
return m_content_frame ? m_content_frame->document() : nullptr;
|
||||
}
|
||||
|
||||
void HTMLIFrameElement::content_frame_did_load(Badge<FrameLoader>)
|
||||
{
|
||||
dispatch_event(DOM::Event::create(EventNames::load));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue