blob: 66a44672055659088a35e9838c7b9a3b6b11d20b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
/*
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Event.h>
#include <LibWeb/HTML/FrameHostElement.h>
#include <LibWeb/Origin.h>
#include <LibWeb/Page/BrowsingContext.h>
namespace Web::HTML {
FrameHostElement::FrameHostElement(DOM::Document& document, QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
{
}
FrameHostElement::~FrameHostElement()
{
}
void FrameHostElement::inserted()
{
HTMLElement::inserted();
if (!is_connected())
return;
if (auto* frame = document().browsing_context()) {
m_nested_browsing_context = BrowsingContext::create_nested(*this, frame->top_level_browsing_context());
m_nested_browsing_context->set_frame_nesting_levels(frame->frame_nesting_levels());
m_nested_browsing_context->register_frame_nesting(document().url());
}
}
Origin FrameHostElement::content_origin() const
{
if (!m_nested_browsing_context || !m_nested_browsing_context->document())
return {};
return m_nested_browsing_context->document()->origin();
}
bool FrameHostElement::may_access_from_origin(const Origin& origin) const
{
return origin.is_same(content_origin());
}
const DOM::Document* FrameHostElement::content_document() const
{
return m_nested_browsing_context ? m_nested_browsing_context->document() : nullptr;
}
void FrameHostElement::nested_browsing_context_did_load(Badge<FrameLoader>)
{
dispatch_event(DOM::Event::create(EventNames::load));
}
}
|