mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:17:35 +00:00
LibWeb: Rename Web::Frame to Web::BrowsingContext
Our "frame" concept very closely matches what the web specs call a "browsing context", so let's rename it to that. :^) The "main frame" becomes the "top-level browsing context", and "sub-frames" are now "nested browsing contexts".
This commit is contained in:
parent
8be98af77c
commit
4190fd2199
43 changed files with 241 additions and 241 deletions
|
@ -31,7 +31,7 @@
|
||||||
#include <LibWeb/Layout/InitialContainingBlockBox.h>
|
#include <LibWeb/Layout/InitialContainingBlockBox.h>
|
||||||
#include <LibWeb/Loader/ResourceLoader.h>
|
#include <LibWeb/Loader/ResourceLoader.h>
|
||||||
#include <LibWeb/OutOfProcessWebView.h>
|
#include <LibWeb/OutOfProcessWebView.h>
|
||||||
#include <LibWeb/Page/Frame.h>
|
#include <LibWeb/Page/BrowsingContext.h>
|
||||||
|
|
||||||
namespace Browser {
|
namespace Browser {
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#include <LibWeb/DOM/Event.h>
|
#include <LibWeb/DOM/Event.h>
|
||||||
#include <LibWeb/DOM/Window.h>
|
#include <LibWeb/DOM/Window.h>
|
||||||
#include <LibWeb/Origin.h>
|
#include <LibWeb/Origin.h>
|
||||||
#include <LibWeb/Page/Frame.h>
|
#include <LibWeb/Page/BrowsingContext.h>
|
||||||
#include <LibWeb/WebAssembly/WebAssemblyObject.h>
|
#include <LibWeb/WebAssembly/WebAssemblyObject.h>
|
||||||
|
|
||||||
#include <LibWeb/Bindings/WindowObjectHelper.h>
|
#include <LibWeb/Bindings/WindowObjectHelper.h>
|
||||||
|
@ -344,10 +344,10 @@ JS_DEFINE_NATIVE_GETTER(WindowObject::top_getter)
|
||||||
auto* impl = impl_from(vm, global_object);
|
auto* impl = impl_from(vm, global_object);
|
||||||
if (!impl)
|
if (!impl)
|
||||||
return {};
|
return {};
|
||||||
auto* this_frame = impl->document().frame();
|
auto* this_browsing_context = impl->document().browsing_context();
|
||||||
VERIFY(this_frame);
|
VERIFY(this_browsing_context);
|
||||||
VERIFY(this_frame->main_frame().document());
|
VERIFY(this_browsing_context->top_level_browsing_context().document());
|
||||||
auto& top_window = this_frame->main_frame().document()->window();
|
auto& top_window = this_browsing_context->top_level_browsing_context().document()->window();
|
||||||
return top_window.wrapper();
|
return top_window.wrapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,14 +356,14 @@ JS_DEFINE_NATIVE_GETTER(WindowObject::parent_getter)
|
||||||
auto* impl = impl_from(vm, global_object);
|
auto* impl = impl_from(vm, global_object);
|
||||||
if (!impl)
|
if (!impl)
|
||||||
return {};
|
return {};
|
||||||
auto* this_frame = impl->document().frame();
|
auto* this_browsing_context = impl->document().browsing_context();
|
||||||
VERIFY(this_frame);
|
VERIFY(this_browsing_context);
|
||||||
if (this_frame->parent()) {
|
if (this_browsing_context->parent()) {
|
||||||
VERIFY(this_frame->parent()->document());
|
VERIFY(this_browsing_context->parent()->document());
|
||||||
auto& parent_window = this_frame->parent()->document()->window();
|
auto& parent_window = this_browsing_context->parent()->document()->window();
|
||||||
return parent_window.wrapper();
|
return parent_window.wrapper();
|
||||||
}
|
}
|
||||||
VERIFY(this_frame == &this_frame->main_frame());
|
VERIFY(this_browsing_context == &this_browsing_context->top_level_browsing_context());
|
||||||
return impl->wrapper();
|
return impl->wrapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -205,9 +205,9 @@ set(SOURCES
|
||||||
Namespace.cpp
|
Namespace.cpp
|
||||||
NavigationTiming/PerformanceTiming.cpp
|
NavigationTiming/PerformanceTiming.cpp
|
||||||
OutOfProcessWebView.cpp
|
OutOfProcessWebView.cpp
|
||||||
|
Page/BrowsingContext.cpp
|
||||||
Page/EditEventHandler.cpp
|
Page/EditEventHandler.cpp
|
||||||
Page/EventHandler.cpp
|
Page/EventHandler.cpp
|
||||||
Page/Frame.cpp
|
|
||||||
Page/Page.cpp
|
Page/Page.cpp
|
||||||
Painting/BorderPainting.cpp
|
Painting/BorderPainting.cpp
|
||||||
Painting/StackingContext.cpp
|
Painting/StackingContext.cpp
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include <LibWeb/CSS/Length.h>
|
#include <LibWeb/CSS/Length.h>
|
||||||
#include <LibWeb/DOM/Document.h>
|
#include <LibWeb/DOM/Document.h>
|
||||||
#include <LibWeb/HTML/HTMLHtmlElement.h>
|
#include <LibWeb/HTML/HTMLHtmlElement.h>
|
||||||
#include <LibWeb/Page/Frame.h>
|
#include <LibWeb/Page/BrowsingContext.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
@ -21,16 +21,16 @@ float Length::relative_length_to_px(const Layout::Node& layout_node) const
|
||||||
case Type::Rem:
|
case Type::Rem:
|
||||||
return m_value * layout_node.document().document_element()->layout_node()->font_size();
|
return m_value * layout_node.document().document_element()->layout_node()->font_size();
|
||||||
case Type::Vw:
|
case Type::Vw:
|
||||||
return layout_node.document().frame()->viewport_rect().width() * (m_value / 100);
|
return layout_node.document().browsing_context()->viewport_rect().width() * (m_value / 100);
|
||||||
case Type::Vh:
|
case Type::Vh:
|
||||||
return layout_node.document().frame()->viewport_rect().height() * (m_value / 100);
|
return layout_node.document().browsing_context()->viewport_rect().height() * (m_value / 100);
|
||||||
case Type::Vmin: {
|
case Type::Vmin: {
|
||||||
auto viewport = layout_node.document().frame()->viewport_rect();
|
auto viewport = layout_node.document().browsing_context()->viewport_rect();
|
||||||
|
|
||||||
return min(viewport.width(), viewport.height()) * (m_value / 100);
|
return min(viewport.width(), viewport.height()) * (m_value / 100);
|
||||||
}
|
}
|
||||||
case Type::Vmax: {
|
case Type::Vmax: {
|
||||||
auto viewport = layout_node.document().frame()->viewport_rect();
|
auto viewport = layout_node.document().browsing_context()->viewport_rect();
|
||||||
|
|
||||||
return max(viewport.width(), viewport.height()) * (m_value / 100);
|
return max(viewport.width(), viewport.height()) * (m_value / 100);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include <LibWeb/InProcessWebView.h>
|
#include <LibWeb/InProcessWebView.h>
|
||||||
#include <LibWeb/Loader/LoadRequest.h>
|
#include <LibWeb/Loader/LoadRequest.h>
|
||||||
#include <LibWeb/Loader/ResourceLoader.h>
|
#include <LibWeb/Loader/ResourceLoader.h>
|
||||||
#include <LibWeb/Page/Frame.h>
|
#include <LibWeb/Page/BrowsingContext.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
@ -165,8 +165,8 @@ void ImageStyleValue::resource_did_load()
|
||||||
return;
|
return;
|
||||||
m_bitmap = resource()->bitmap();
|
m_bitmap = resource()->bitmap();
|
||||||
// FIXME: Do less than a full repaint if possible?
|
// FIXME: Do less than a full repaint if possible?
|
||||||
if (m_document->frame())
|
if (m_document->browsing_context())
|
||||||
m_document->frame()->set_needs_display({});
|
m_document->browsing_context()->set_needs_display({});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
#include <LibWeb/Layout/TreeBuilder.h>
|
#include <LibWeb/Layout/TreeBuilder.h>
|
||||||
#include <LibWeb/Namespace.h>
|
#include <LibWeb/Namespace.h>
|
||||||
#include <LibWeb/Origin.h>
|
#include <LibWeb/Origin.h>
|
||||||
#include <LibWeb/Page/Frame.h>
|
#include <LibWeb/Page/BrowsingContext.h>
|
||||||
#include <LibWeb/SVG/TagNames.h>
|
#include <LibWeb/SVG/TagNames.h>
|
||||||
#include <LibWeb/UIEvents/MouseEvent.h>
|
#include <LibWeb/UIEvents/MouseEvent.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
@ -281,22 +281,22 @@ void Document::set_title(const String& title)
|
||||||
title_element->append_child(adopt_ref(*new Text(*this, title)));
|
title_element->append_child(adopt_ref(*new Text(*this, title)));
|
||||||
|
|
||||||
if (auto* page = this->page()) {
|
if (auto* page = this->page()) {
|
||||||
if (frame() == &page->main_frame())
|
if (browsing_context() == &page->top_level_browsing_context())
|
||||||
page->client().page_did_change_title(title);
|
page->client().page_did_change_title(title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Document::attach_to_frame(Badge<Frame>, Frame& frame)
|
void Document::attach_to_browsing_context(Badge<BrowsingContext>, BrowsingContext& browsing_context)
|
||||||
{
|
{
|
||||||
m_frame = frame;
|
m_browsing_context = browsing_context;
|
||||||
update_layout();
|
update_layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Document::detach_from_frame(Badge<Frame>, Frame& frame)
|
void Document::detach_from_browsing_context(Badge<BrowsingContext>, BrowsingContext& browsing_context)
|
||||||
{
|
{
|
||||||
VERIFY(&frame == m_frame);
|
VERIFY(&browsing_context == m_browsing_context);
|
||||||
tear_down_layout_tree();
|
tear_down_layout_tree();
|
||||||
m_frame = nullptr;
|
m_browsing_context = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Document::tear_down_layout_tree()
|
void Document::tear_down_layout_tree()
|
||||||
|
@ -399,7 +399,7 @@ void Document::force_layout()
|
||||||
|
|
||||||
void Document::update_layout()
|
void Document::update_layout()
|
||||||
{
|
{
|
||||||
if (!frame())
|
if (!browsing_context())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!m_layout_root) {
|
if (!m_layout_root) {
|
||||||
|
@ -412,7 +412,7 @@ void Document::update_layout()
|
||||||
|
|
||||||
m_layout_root->set_needs_display();
|
m_layout_root->set_needs_display();
|
||||||
|
|
||||||
if (frame()->is_main_frame()) {
|
if (browsing_context()->is_top_level()) {
|
||||||
if (auto* page = this->page())
|
if (auto* page = this->page())
|
||||||
page->client().page_did_layout();
|
page->client().page_did_layout();
|
||||||
}
|
}
|
||||||
|
@ -881,12 +881,12 @@ void Document::set_ready_state(const String& ready_state)
|
||||||
|
|
||||||
Page* Document::page()
|
Page* Document::page()
|
||||||
{
|
{
|
||||||
return m_frame ? m_frame->page() : nullptr;
|
return m_browsing_context ? m_browsing_context->page() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Page* Document::page() const
|
const Page* Document::page() const
|
||||||
{
|
{
|
||||||
return m_frame ? m_frame->page() : nullptr;
|
return m_browsing_context ? m_browsing_context->page() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
EventTarget* Document::get_parent(const Event& event)
|
EventTarget* Document::get_parent(const Event& event)
|
||||||
|
|
|
@ -115,11 +115,11 @@ public:
|
||||||
String title() const;
|
String title() const;
|
||||||
void set_title(const String&);
|
void set_title(const String&);
|
||||||
|
|
||||||
void attach_to_frame(Badge<Frame>, Frame&);
|
void attach_to_browsing_context(Badge<BrowsingContext>, BrowsingContext&);
|
||||||
void detach_from_frame(Badge<Frame>, Frame&);
|
void detach_from_browsing_context(Badge<BrowsingContext>, BrowsingContext&);
|
||||||
|
|
||||||
Frame* frame() { return m_frame.ptr(); }
|
BrowsingContext* browsing_context() { return m_browsing_context.ptr(); }
|
||||||
const Frame* frame() const { return m_frame.ptr(); }
|
const BrowsingContext* browsing_context() const { return m_browsing_context.ptr(); }
|
||||||
|
|
||||||
Page* page();
|
Page* page();
|
||||||
const Page* page() const;
|
const Page* page() const;
|
||||||
|
@ -297,7 +297,7 @@ private:
|
||||||
RefPtr<CSS::StyleSheetList> m_style_sheets;
|
RefPtr<CSS::StyleSheetList> m_style_sheets;
|
||||||
RefPtr<Node> m_hovered_node;
|
RefPtr<Node> m_hovered_node;
|
||||||
RefPtr<Node> m_inspected_node;
|
RefPtr<Node> m_inspected_node;
|
||||||
WeakPtr<Frame> m_frame;
|
WeakPtr<BrowsingContext> m_browsing_context;
|
||||||
URL m_url;
|
URL m_url;
|
||||||
|
|
||||||
RefPtr<Window> m_window;
|
RefPtr<Window> m_window;
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#include <LibWeb/HighResolutionTime/Performance.h>
|
#include <LibWeb/HighResolutionTime/Performance.h>
|
||||||
#include <LibWeb/InProcessWebView.h>
|
#include <LibWeb/InProcessWebView.h>
|
||||||
#include <LibWeb/Layout/InitialContainingBlockBox.h>
|
#include <LibWeb/Layout/InitialContainingBlockBox.h>
|
||||||
#include <LibWeb/Page/Frame.h>
|
#include <LibWeb/Page/BrowsingContext.h>
|
||||||
|
|
||||||
namespace Web::DOM {
|
namespace Web::DOM {
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ void Window::cancel_animation_frame(i32 id)
|
||||||
|
|
||||||
void Window::did_set_location_href(Badge<Bindings::LocationObject>, const URL& new_href)
|
void Window::did_set_location_href(Badge<Bindings::LocationObject>, const URL& new_href)
|
||||||
{
|
{
|
||||||
auto* frame = document().frame();
|
auto* frame = document().browsing_context();
|
||||||
if (!frame)
|
if (!frame)
|
||||||
return;
|
return;
|
||||||
frame->loader().load(new_href, FrameLoader::Type::Navigation);
|
frame->loader().load(new_href, FrameLoader::Type::Navigation);
|
||||||
|
@ -147,7 +147,7 @@ void Window::did_set_location_href(Badge<Bindings::LocationObject>, const URL& n
|
||||||
|
|
||||||
void Window::did_call_location_reload(Badge<Bindings::LocationObject>)
|
void Window::did_call_location_reload(Badge<Bindings::LocationObject>)
|
||||||
{
|
{
|
||||||
auto* frame = document().frame();
|
auto* frame = document().browsing_context();
|
||||||
if (!frame)
|
if (!frame)
|
||||||
return;
|
return;
|
||||||
frame->loader().load(document().url(), FrameLoader::Type::Reload);
|
frame->loader().load(document().url(), FrameLoader::Type::Reload);
|
||||||
|
|
|
@ -179,7 +179,7 @@ class TextNode;
|
||||||
namespace Web {
|
namespace Web {
|
||||||
class EventHandler;
|
class EventHandler;
|
||||||
class EditEventHandler;
|
class EditEventHandler;
|
||||||
class Frame;
|
class BrowsingContext;
|
||||||
class FrameLoader;
|
class FrameLoader;
|
||||||
class InProcessWebView;
|
class InProcessWebView;
|
||||||
class LoadRequest;
|
class LoadRequest;
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include <LibWeb/DOM/Event.h>
|
#include <LibWeb/DOM/Event.h>
|
||||||
#include <LibWeb/HTML/FrameHostElement.h>
|
#include <LibWeb/HTML/FrameHostElement.h>
|
||||||
#include <LibWeb/Origin.h>
|
#include <LibWeb/Origin.h>
|
||||||
#include <LibWeb/Page/Frame.h>
|
#include <LibWeb/Page/BrowsingContext.h>
|
||||||
|
|
||||||
namespace Web::HTML {
|
namespace Web::HTML {
|
||||||
|
|
||||||
|
@ -26,18 +26,18 @@ void FrameHostElement::inserted()
|
||||||
HTMLElement::inserted();
|
HTMLElement::inserted();
|
||||||
if (!is_connected())
|
if (!is_connected())
|
||||||
return;
|
return;
|
||||||
if (auto* frame = document().frame()) {
|
if (auto* frame = document().browsing_context()) {
|
||||||
m_content_frame = Frame::create_subframe(*this, frame->main_frame());
|
m_nested_browsing_context = BrowsingContext::create_nested(*this, frame->top_level_browsing_context());
|
||||||
m_content_frame->set_frame_nesting_levels(frame->frame_nesting_levels());
|
m_nested_browsing_context->set_frame_nesting_levels(frame->frame_nesting_levels());
|
||||||
m_content_frame->register_frame_nesting(document().url());
|
m_nested_browsing_context->register_frame_nesting(document().url());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Origin FrameHostElement::content_origin() const
|
Origin FrameHostElement::content_origin() const
|
||||||
{
|
{
|
||||||
if (!m_content_frame || !m_content_frame->document())
|
if (!m_nested_browsing_context || !m_nested_browsing_context->document())
|
||||||
return {};
|
return {};
|
||||||
return m_content_frame->document()->origin();
|
return m_nested_browsing_context->document()->origin();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FrameHostElement::may_access_from_origin(const Origin& origin) const
|
bool FrameHostElement::may_access_from_origin(const Origin& origin) const
|
||||||
|
@ -47,10 +47,10 @@ bool FrameHostElement::may_access_from_origin(const Origin& origin) const
|
||||||
|
|
||||||
const DOM::Document* FrameHostElement::content_document() const
|
const DOM::Document* FrameHostElement::content_document() const
|
||||||
{
|
{
|
||||||
return m_content_frame ? m_content_frame->document() : nullptr;
|
return m_nested_browsing_context ? m_nested_browsing_context->document() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FrameHostElement::content_frame_did_load(Badge<FrameLoader>)
|
void FrameHostElement::nested_browsing_context_did_load(Badge<FrameLoader>)
|
||||||
{
|
{
|
||||||
dispatch_event(DOM::Event::create(EventNames::load));
|
dispatch_event(DOM::Event::create(EventNames::load));
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,20 +15,20 @@ public:
|
||||||
FrameHostElement(DOM::Document&, QualifiedName);
|
FrameHostElement(DOM::Document&, QualifiedName);
|
||||||
virtual ~FrameHostElement() override;
|
virtual ~FrameHostElement() override;
|
||||||
|
|
||||||
Frame* content_frame() { return m_content_frame; }
|
BrowsingContext* nested_browsing_context() { return m_nested_browsing_context; }
|
||||||
const Frame* content_frame() const { return m_content_frame; }
|
const BrowsingContext* nested_browsing_context() const { return m_nested_browsing_context; }
|
||||||
|
|
||||||
const DOM::Document* content_document() const;
|
const DOM::Document* content_document() const;
|
||||||
|
|
||||||
Origin content_origin() const;
|
Origin content_origin() const;
|
||||||
bool may_access_from_origin(const Origin&) const;
|
bool may_access_from_origin(const Origin&) const;
|
||||||
|
|
||||||
void content_frame_did_load(Badge<FrameLoader>);
|
void nested_browsing_context_did_load(Badge<FrameLoader>);
|
||||||
|
|
||||||
virtual void inserted() override;
|
virtual void inserted() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
RefPtr<Frame> m_content_frame;
|
RefPtr<BrowsingContext> m_nested_browsing_context;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include <LibWeb/HTML/HTMLInputElement.h>
|
#include <LibWeb/HTML/HTMLInputElement.h>
|
||||||
#include <LibWeb/HTML/SubmitEvent.h>
|
#include <LibWeb/HTML/SubmitEvent.h>
|
||||||
#include <LibWeb/InProcessWebView.h>
|
#include <LibWeb/InProcessWebView.h>
|
||||||
#include <LibWeb/Page/Frame.h>
|
#include <LibWeb/Page/BrowsingContext.h>
|
||||||
#include <LibWeb/URLEncoder.h>
|
#include <LibWeb/URLEncoder.h>
|
||||||
|
|
||||||
namespace Web::HTML {
|
namespace Web::HTML {
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include <LibWeb/HTML/HTMLIFrameElement.h>
|
#include <LibWeb/HTML/HTMLIFrameElement.h>
|
||||||
#include <LibWeb/Layout/FrameBox.h>
|
#include <LibWeb/Layout/FrameBox.h>
|
||||||
#include <LibWeb/Origin.h>
|
#include <LibWeb/Origin.h>
|
||||||
#include <LibWeb/Page/Frame.h>
|
#include <LibWeb/Page/BrowsingContext.h>
|
||||||
|
|
||||||
namespace Web::HTML {
|
namespace Web::HTML {
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ void HTMLIFrameElement::inserted()
|
||||||
|
|
||||||
void HTMLIFrameElement::load_src(const String& value)
|
void HTMLIFrameElement::load_src(const String& value)
|
||||||
{
|
{
|
||||||
if (!m_content_frame)
|
if (!m_nested_browsing_context)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (value.is_null())
|
if (value.is_null())
|
||||||
|
@ -60,7 +60,7 @@ void HTMLIFrameElement::load_src(const String& value)
|
||||||
}
|
}
|
||||||
|
|
||||||
dbgln("Loading iframe document from {}", value);
|
dbgln("Loading iframe document from {}", value);
|
||||||
m_content_frame->loader().load(url, FrameLoader::Type::IFrame);
|
m_nested_browsing_context->loader().load(url, FrameLoader::Type::IFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include <LibWeb/Layout/ButtonBox.h>
|
#include <LibWeb/Layout/ButtonBox.h>
|
||||||
#include <LibWeb/Layout/CheckBox.h>
|
#include <LibWeb/Layout/CheckBox.h>
|
||||||
#include <LibWeb/Layout/RadioButton.h>
|
#include <LibWeb/Layout/RadioButton.h>
|
||||||
#include <LibWeb/Page/Frame.h>
|
#include <LibWeb/Page/BrowsingContext.h>
|
||||||
|
|
||||||
namespace Web::HTML {
|
namespace Web::HTML {
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ void HTMLTitleElement::children_changed()
|
||||||
{
|
{
|
||||||
HTMLElement::children_changed();
|
HTMLElement::children_changed();
|
||||||
if (auto* page = document().page()) {
|
if (auto* page = document().page()) {
|
||||||
if (document().frame() == &page->main_frame())
|
if (document().browsing_context() == &page->top_level_browsing_context())
|
||||||
page->client().page_did_change_title(document().title());
|
page->client().page_did_change_title(document().title());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,8 @@
|
||||||
#include <LibWeb/Layout/Node.h>
|
#include <LibWeb/Layout/Node.h>
|
||||||
#include <LibWeb/Layout/TextNode.h>
|
#include <LibWeb/Layout/TextNode.h>
|
||||||
#include <LibWeb/Loader/ResourceLoader.h>
|
#include <LibWeb/Loader/ResourceLoader.h>
|
||||||
|
#include <LibWeb/Page/BrowsingContext.h>
|
||||||
#include <LibWeb/Page/EventHandler.h>
|
#include <LibWeb/Page/EventHandler.h>
|
||||||
#include <LibWeb/Page/Frame.h>
|
|
||||||
#include <LibWeb/Painting/PaintContext.h>
|
#include <LibWeb/Painting/PaintContext.h>
|
||||||
#include <LibWeb/UIEvents/MouseEvent.h>
|
#include <LibWeb/UIEvents/MouseEvent.h>
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ void InProcessWebView::select_all()
|
||||||
|
|
||||||
String InProcessWebView::selected_text() const
|
String InProcessWebView::selected_text() const
|
||||||
{
|
{
|
||||||
return page().focused_frame().selected_text();
|
return page().focused_context().selected_text();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InProcessWebView::page_did_layout()
|
void InProcessWebView::page_did_layout()
|
||||||
|
@ -104,7 +104,7 @@ void InProcessWebView::page_did_change_title(const String& title)
|
||||||
on_title_change(title);
|
on_title_change(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InProcessWebView::page_did_set_document_in_main_frame(DOM::Document* document)
|
void InProcessWebView::page_did_set_document_in_top_level_browsing_context(DOM::Document* document)
|
||||||
{
|
{
|
||||||
if (on_set_document)
|
if (on_set_document)
|
||||||
on_set_document(document);
|
on_set_document(document);
|
||||||
|
@ -210,17 +210,17 @@ void InProcessWebView::layout_and_sync_size()
|
||||||
bool had_vertical_scrollbar = vertical_scrollbar().is_visible();
|
bool had_vertical_scrollbar = vertical_scrollbar().is_visible();
|
||||||
bool had_horizontal_scrollbar = horizontal_scrollbar().is_visible();
|
bool had_horizontal_scrollbar = horizontal_scrollbar().is_visible();
|
||||||
|
|
||||||
page().main_frame().set_size(available_size());
|
page().top_level_browsing_context().set_size(available_size());
|
||||||
set_content_size(layout_root()->size().to_type<int>());
|
set_content_size(layout_root()->size().to_type<int>());
|
||||||
|
|
||||||
// NOTE: If layout caused us to gain or lose scrollbars, we have to lay out again
|
// NOTE: If layout caused us to gain or lose scrollbars, we have to lay out again
|
||||||
// since the scrollbars now take up some of the available space.
|
// since the scrollbars now take up some of the available space.
|
||||||
if (had_vertical_scrollbar != vertical_scrollbar().is_visible() || had_horizontal_scrollbar != horizontal_scrollbar().is_visible()) {
|
if (had_vertical_scrollbar != vertical_scrollbar().is_visible() || had_horizontal_scrollbar != horizontal_scrollbar().is_visible()) {
|
||||||
page().main_frame().set_size(available_size());
|
page().top_level_browsing_context().set_size(available_size());
|
||||||
set_content_size(layout_root()->size().to_type<int>());
|
set_content_size(layout_root()->size().to_type<int>());
|
||||||
}
|
}
|
||||||
|
|
||||||
page().main_frame().set_viewport_scroll_offset({ horizontal_scrollbar().value(), vertical_scrollbar().value() });
|
page().top_level_browsing_context().set_viewport_scroll_offset({ horizontal_scrollbar().value(), vertical_scrollbar().value() });
|
||||||
}
|
}
|
||||||
|
|
||||||
void InProcessWebView::resize_event(GUI::ResizeEvent& event)
|
void InProcessWebView::resize_event(GUI::ResizeEvent& event)
|
||||||
|
@ -319,9 +319,9 @@ void InProcessWebView::keydown_event(GUI::KeyEvent& event)
|
||||||
|
|
||||||
URL InProcessWebView::url() const
|
URL InProcessWebView::url() const
|
||||||
{
|
{
|
||||||
if (!page().main_frame().document())
|
if (!page().top_level_browsing_context().document())
|
||||||
return {};
|
return {};
|
||||||
return page().main_frame().document()->url();
|
return page().top_level_browsing_context().document()->url();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InProcessWebView::reload()
|
void InProcessWebView::reload()
|
||||||
|
@ -331,13 +331,13 @@ void InProcessWebView::reload()
|
||||||
|
|
||||||
void InProcessWebView::load_html(const StringView& html, const URL& url)
|
void InProcessWebView::load_html(const StringView& html, const URL& url)
|
||||||
{
|
{
|
||||||
page().main_frame().loader().load_html(html, url);
|
page().top_level_browsing_context().loader().load_html(html, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InProcessWebView::load(const URL& url)
|
bool InProcessWebView::load(const URL& url)
|
||||||
{
|
{
|
||||||
set_override_cursor(Gfx::StandardCursor::None);
|
set_override_cursor(Gfx::StandardCursor::None);
|
||||||
return page().main_frame().loader().load(url, FrameLoader::Type::Navigation);
|
return page().top_level_browsing_context().loader().load(url, FrameLoader::Type::Navigation);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Layout::InitialContainingBlockBox* InProcessWebView::layout_root() const
|
const Layout::InitialContainingBlockBox* InProcessWebView::layout_root() const
|
||||||
|
@ -360,27 +360,27 @@ void InProcessWebView::page_did_request_scroll_into_view(const Gfx::IntRect& rec
|
||||||
|
|
||||||
void InProcessWebView::load_empty_document()
|
void InProcessWebView::load_empty_document()
|
||||||
{
|
{
|
||||||
page().main_frame().set_document(nullptr);
|
page().top_level_browsing_context().set_document(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
DOM::Document* InProcessWebView::document()
|
DOM::Document* InProcessWebView::document()
|
||||||
{
|
{
|
||||||
return page().main_frame().document();
|
return page().top_level_browsing_context().document();
|
||||||
}
|
}
|
||||||
|
|
||||||
const DOM::Document* InProcessWebView::document() const
|
const DOM::Document* InProcessWebView::document() const
|
||||||
{
|
{
|
||||||
return page().main_frame().document();
|
return page().top_level_browsing_context().document();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InProcessWebView::set_document(DOM::Document* document)
|
void InProcessWebView::set_document(DOM::Document* document)
|
||||||
{
|
{
|
||||||
page().main_frame().set_document(document);
|
page().top_level_browsing_context().set_document(document);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InProcessWebView::did_scroll()
|
void InProcessWebView::did_scroll()
|
||||||
{
|
{
|
||||||
page().main_frame().set_viewport_scroll_offset({ horizontal_scrollbar().value(), vertical_scrollbar().value() });
|
page().top_level_browsing_context().set_viewport_scroll_offset({ horizontal_scrollbar().value(), vertical_scrollbar().value() });
|
||||||
}
|
}
|
||||||
|
|
||||||
void InProcessWebView::drop_event(GUI::DropEvent& event)
|
void InProcessWebView::drop_event(GUI::DropEvent& event)
|
||||||
|
|
|
@ -70,7 +70,7 @@ private:
|
||||||
virtual Gfx::Palette palette() const override { return GUI::AbstractScrollableWidget::palette(); }
|
virtual Gfx::Palette palette() const override { return GUI::AbstractScrollableWidget::palette(); }
|
||||||
virtual Gfx::IntRect screen_rect() const override { return GUI::Desktop::the().rect(); }
|
virtual Gfx::IntRect screen_rect() const override { return GUI::Desktop::the().rect(); }
|
||||||
virtual void page_did_change_title(const String&) override;
|
virtual void page_did_change_title(const String&) override;
|
||||||
virtual void page_did_set_document_in_main_frame(DOM::Document*) override;
|
virtual void page_did_set_document_in_top_level_browsing_context(DOM::Document*) override;
|
||||||
virtual void page_did_start_loading(const URL&) override;
|
virtual void page_did_start_loading(const URL&) override;
|
||||||
virtual void page_did_finish_loading(const URL&) override;
|
virtual void page_did_finish_loading(const URL&) override;
|
||||||
virtual void page_did_change_selection() override;
|
virtual void page_did_change_selection() override;
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#include <LibWeb/Layout/InlineFormattingContext.h>
|
#include <LibWeb/Layout/InlineFormattingContext.h>
|
||||||
#include <LibWeb/Layout/ListItemBox.h>
|
#include <LibWeb/Layout/ListItemBox.h>
|
||||||
#include <LibWeb/Layout/ReplacedBox.h>
|
#include <LibWeb/Layout/ReplacedBox.h>
|
||||||
#include <LibWeb/Page/Frame.h>
|
#include <LibWeb/Page/BrowsingContext.h>
|
||||||
|
|
||||||
namespace Web::Layout {
|
namespace Web::Layout {
|
||||||
|
|
||||||
|
@ -516,7 +516,7 @@ void BlockFormattingContext::place_block_level_non_replaced_element_in_normal_fl
|
||||||
|
|
||||||
void BlockFormattingContext::layout_initial_containing_block(LayoutMode layout_mode)
|
void BlockFormattingContext::layout_initial_containing_block(LayoutMode layout_mode)
|
||||||
{
|
{
|
||||||
auto viewport_rect = context_box().frame().viewport_rect();
|
auto viewport_rect = context_box().browsing_context().viewport_rect();
|
||||||
|
|
||||||
auto& icb = downcast<Layout::InitialContainingBlockBox>(context_box());
|
auto& icb = downcast<Layout::InitialContainingBlockBox>(context_box());
|
||||||
icb.build_stacking_context_tree();
|
icb.build_stacking_context_tree();
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include <LibWeb/HTML/HTMLHtmlElement.h>
|
#include <LibWeb/HTML/HTMLHtmlElement.h>
|
||||||
#include <LibWeb/Layout/BlockBox.h>
|
#include <LibWeb/Layout/BlockBox.h>
|
||||||
#include <LibWeb/Layout/Box.h>
|
#include <LibWeb/Layout/Box.h>
|
||||||
#include <LibWeb/Page/Frame.h>
|
#include <LibWeb/Page/BrowsingContext.h>
|
||||||
#include <LibWeb/Painting/BorderPainting.h>
|
#include <LibWeb/Painting/BorderPainting.h>
|
||||||
|
|
||||||
namespace Web::Layout {
|
namespace Web::Layout {
|
||||||
|
@ -293,7 +293,7 @@ HitTestResult Box::hit_test(const Gfx::IntPoint& position, HitTestType type) con
|
||||||
void Box::set_needs_display()
|
void Box::set_needs_display()
|
||||||
{
|
{
|
||||||
if (!is_inline()) {
|
if (!is_inline()) {
|
||||||
frame().set_needs_display(enclosing_int_rect(absolute_rect()));
|
browsing_context().set_needs_display(enclosing_int_rect(absolute_rect()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include <LibWeb/DOM/Document.h>
|
#include <LibWeb/DOM/Document.h>
|
||||||
#include <LibWeb/Layout/ButtonBox.h>
|
#include <LibWeb/Layout/ButtonBox.h>
|
||||||
#include <LibWeb/Layout/Label.h>
|
#include <LibWeb/Layout/Label.h>
|
||||||
#include <LibWeb/Page/Frame.h>
|
#include <LibWeb/Page/BrowsingContext.h>
|
||||||
|
|
||||||
namespace Web::Layout {
|
namespace Web::Layout {
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ void ButtonBox::handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint&, unsi
|
||||||
set_needs_display();
|
set_needs_display();
|
||||||
|
|
||||||
m_tracking_mouse = true;
|
m_tracking_mouse = true;
|
||||||
frame().event_handler().set_mouse_event_tracking_layout_node(this);
|
browsing_context().event_handler().set_mouse_event_tracking_layout_node(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ButtonBox::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned button, unsigned)
|
void ButtonBox::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned button, unsigned)
|
||||||
|
@ -73,7 +73,7 @@ void ButtonBox::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& positio
|
||||||
|
|
||||||
// NOTE: Handling the click may run arbitrary JS, which could disappear this node.
|
// NOTE: Handling the click may run arbitrary JS, which could disappear this node.
|
||||||
NonnullRefPtr protected_this = *this;
|
NonnullRefPtr protected_this = *this;
|
||||||
NonnullRefPtr protected_frame = frame();
|
NonnullRefPtr protected_frame = browsing_context();
|
||||||
|
|
||||||
bool is_inside_node_or_label = enclosing_int_rect(absolute_rect()).contains(position);
|
bool is_inside_node_or_label = enclosing_int_rect(absolute_rect()).contains(position);
|
||||||
if (!is_inside_node_or_label)
|
if (!is_inside_node_or_label)
|
||||||
|
@ -114,7 +114,7 @@ void ButtonBox::handle_associated_label_mouseup(Badge<Label>)
|
||||||
{
|
{
|
||||||
// NOTE: Handling the click may run arbitrary JS, which could disappear this node.
|
// NOTE: Handling the click may run arbitrary JS, which could disappear this node.
|
||||||
NonnullRefPtr protected_this = *this;
|
NonnullRefPtr protected_this = *this;
|
||||||
NonnullRefPtr protected_frame = frame();
|
NonnullRefPtr protected_frame = browsing_context();
|
||||||
|
|
||||||
dom_node().did_click_button({});
|
dom_node().did_click_button({});
|
||||||
m_being_pressed = false;
|
m_being_pressed = false;
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include <LibGfx/StylePainter.h>
|
#include <LibGfx/StylePainter.h>
|
||||||
#include <LibWeb/Layout/CheckBox.h>
|
#include <LibWeb/Layout/CheckBox.h>
|
||||||
#include <LibWeb/Layout/Label.h>
|
#include <LibWeb/Layout/Label.h>
|
||||||
#include <LibWeb/Page/Frame.h>
|
#include <LibWeb/Page/BrowsingContext.h>
|
||||||
|
|
||||||
namespace Web::Layout {
|
namespace Web::Layout {
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ void CheckBox::handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint&, unsig
|
||||||
set_needs_display();
|
set_needs_display();
|
||||||
|
|
||||||
m_tracking_mouse = true;
|
m_tracking_mouse = true;
|
||||||
frame().event_handler().set_mouse_event_tracking_layout_node(this);
|
browsing_context().event_handler().set_mouse_event_tracking_layout_node(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckBox::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned button, unsigned)
|
void CheckBox::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned button, unsigned)
|
||||||
|
@ -68,7 +68,7 @@ void CheckBox::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& position
|
||||||
|
|
||||||
m_being_pressed = false;
|
m_being_pressed = false;
|
||||||
m_tracking_mouse = false;
|
m_tracking_mouse = false;
|
||||||
frame().event_handler().set_mouse_event_tracking_layout_node(nullptr);
|
browsing_context().event_handler().set_mouse_event_tracking_layout_node(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckBox::handle_mousemove(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned, unsigned)
|
void CheckBox::handle_mousemove(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned, unsigned)
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include <LibWeb/InProcessWebView.h>
|
#include <LibWeb/InProcessWebView.h>
|
||||||
#include <LibWeb/Layout/FrameBox.h>
|
#include <LibWeb/Layout/FrameBox.h>
|
||||||
#include <LibWeb/Layout/InitialContainingBlockBox.h>
|
#include <LibWeb/Layout/InitialContainingBlockBox.h>
|
||||||
#include <LibWeb/Page/Frame.h>
|
#include <LibWeb/Page/BrowsingContext.h>
|
||||||
|
|
||||||
namespace Web::Layout {
|
namespace Web::Layout {
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ FrameBox::~FrameBox()
|
||||||
|
|
||||||
void FrameBox::prepare_for_replaced_layout()
|
void FrameBox::prepare_for_replaced_layout()
|
||||||
{
|
{
|
||||||
VERIFY(dom_node().content_frame());
|
VERIFY(dom_node().nested_browsing_context());
|
||||||
|
|
||||||
set_has_intrinsic_width(true);
|
set_has_intrinsic_width(true);
|
||||||
set_has_intrinsic_height(true);
|
set_has_intrinsic_height(true);
|
||||||
|
@ -52,14 +52,14 @@ void FrameBox::paint(PaintContext& context, PaintPhase phase)
|
||||||
context.painter().add_clip_rect(enclosing_int_rect(absolute_rect()));
|
context.painter().add_clip_rect(enclosing_int_rect(absolute_rect()));
|
||||||
context.painter().translate(absolute_x(), absolute_y());
|
context.painter().translate(absolute_x(), absolute_y());
|
||||||
|
|
||||||
context.set_viewport_rect({ {}, dom_node().content_frame()->size() });
|
context.set_viewport_rect({ {}, dom_node().nested_browsing_context()->size() });
|
||||||
const_cast<Layout::InitialContainingBlockBox*>(hosted_layout_tree)->paint_all_phases(context);
|
const_cast<Layout::InitialContainingBlockBox*>(hosted_layout_tree)->paint_all_phases(context);
|
||||||
|
|
||||||
context.set_viewport_rect(old_viewport_rect);
|
context.set_viewport_rect(old_viewport_rect);
|
||||||
context.painter().restore();
|
context.painter().restore();
|
||||||
|
|
||||||
if constexpr (HIGHLIGHT_FOCUSED_FRAME_DEBUG) {
|
if constexpr (HIGHLIGHT_FOCUSED_FRAME_DEBUG) {
|
||||||
if (dom_node().content_frame()->is_focused_frame()) {
|
if (dom_node().nested_browsing_context()->is_focused_context()) {
|
||||||
context.painter().draw_rect(absolute_rect().to_type<int>(), Color::Cyan);
|
context.painter().draw_rect(absolute_rect().to_type<int>(), Color::Cyan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,8 +70,8 @@ void FrameBox::did_set_rect()
|
||||||
{
|
{
|
||||||
ReplacedBox::did_set_rect();
|
ReplacedBox::did_set_rect();
|
||||||
|
|
||||||
VERIFY(dom_node().content_frame());
|
VERIFY(dom_node().nested_browsing_context());
|
||||||
dom_node().content_frame()->set_size(size().to_type<int>());
|
dom_node().nested_browsing_context()->set_size(size().to_type<int>());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include <LibGfx/Painter.h>
|
#include <LibGfx/Painter.h>
|
||||||
#include <LibGfx/StylePainter.h>
|
#include <LibGfx/StylePainter.h>
|
||||||
#include <LibWeb/Layout/ImageBox.h>
|
#include <LibWeb/Layout/ImageBox.h>
|
||||||
#include <LibWeb/Page/Frame.h>
|
#include <LibWeb/Page/BrowsingContext.h>
|
||||||
|
|
||||||
namespace Web::Layout {
|
namespace Web::Layout {
|
||||||
|
|
||||||
|
@ -16,12 +16,12 @@ ImageBox::ImageBox(DOM::Document& document, DOM::Element& element, NonnullRefPtr
|
||||||
: ReplacedBox(document, element, move(style))
|
: ReplacedBox(document, element, move(style))
|
||||||
, m_image_loader(image_loader)
|
, m_image_loader(image_loader)
|
||||||
{
|
{
|
||||||
frame().register_viewport_client(*this);
|
browsing_context().register_viewport_client(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageBox::~ImageBox()
|
ImageBox::~ImageBox()
|
||||||
{
|
{
|
||||||
frame().unregister_viewport_client(*this);
|
browsing_context().unregister_viewport_client(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ImageBox::preferred_width() const
|
int ImageBox::preferred_width() const
|
||||||
|
|
|
@ -8,13 +8,13 @@
|
||||||
|
|
||||||
#include <LibWeb/HTML/HTMLImageElement.h>
|
#include <LibWeb/HTML/HTMLImageElement.h>
|
||||||
#include <LibWeb/Layout/ReplacedBox.h>
|
#include <LibWeb/Layout/ReplacedBox.h>
|
||||||
#include <LibWeb/Page/Frame.h>
|
#include <LibWeb/Page/BrowsingContext.h>
|
||||||
|
|
||||||
namespace Web::Layout {
|
namespace Web::Layout {
|
||||||
|
|
||||||
class ImageBox
|
class ImageBox
|
||||||
: public ReplacedBox
|
: public ReplacedBox
|
||||||
, public Frame::ViewportClient {
|
, public BrowsingContext::ViewportClient {
|
||||||
public:
|
public:
|
||||||
ImageBox(DOM::Document&, DOM::Element&, NonnullRefPtr<CSS::StyleProperties>, const ImageLoader&);
|
ImageBox(DOM::Document&, DOM::Element&, NonnullRefPtr<CSS::StyleProperties>, const ImageLoader&);
|
||||||
virtual ~ImageBox() override;
|
virtual ~ImageBox() override;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include <LibGfx/Painter.h>
|
#include <LibGfx/Painter.h>
|
||||||
#include <LibWeb/Dump.h>
|
#include <LibWeb/Dump.h>
|
||||||
#include <LibWeb/Layout/InitialContainingBlockBox.h>
|
#include <LibWeb/Layout/InitialContainingBlockBox.h>
|
||||||
#include <LibWeb/Page/Frame.h>
|
#include <LibWeb/Page/BrowsingContext.h>
|
||||||
#include <LibWeb/Painting/StackingContext.h>
|
#include <LibWeb/Painting/StackingContext.h>
|
||||||
|
|
||||||
namespace Web::Layout {
|
namespace Web::Layout {
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#include <LibWeb/Layout/Label.h>
|
#include <LibWeb/Layout/Label.h>
|
||||||
#include <LibWeb/Layout/LabelableNode.h>
|
#include <LibWeb/Layout/LabelableNode.h>
|
||||||
#include <LibWeb/Layout/TextNode.h>
|
#include <LibWeb/Layout/TextNode.h>
|
||||||
#include <LibWeb/Page/Frame.h>
|
#include <LibWeb/Page/BrowsingContext.h>
|
||||||
|
|
||||||
namespace Web::Layout {
|
namespace Web::Layout {
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include <LibWeb/Layout/InitialContainingBlockBox.h>
|
#include <LibWeb/Layout/InitialContainingBlockBox.h>
|
||||||
#include <LibWeb/Layout/Node.h>
|
#include <LibWeb/Layout/Node.h>
|
||||||
#include <LibWeb/Layout/TextNode.h>
|
#include <LibWeb/Layout/TextNode.h>
|
||||||
#include <LibWeb/Page/Frame.h>
|
#include <LibWeb/Page/BrowsingContext.h>
|
||||||
|
|
||||||
namespace Web::Layout {
|
namespace Web::Layout {
|
||||||
|
|
||||||
|
@ -104,16 +104,16 @@ HitTestResult Node::hit_test(const Gfx::IntPoint& position, HitTestType type) co
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Frame& Node::frame() const
|
const BrowsingContext& Node::browsing_context() const
|
||||||
{
|
{
|
||||||
VERIFY(document().frame());
|
VERIFY(document().browsing_context());
|
||||||
return *document().frame();
|
return *document().browsing_context();
|
||||||
}
|
}
|
||||||
|
|
||||||
Frame& Node::frame()
|
BrowsingContext& Node::browsing_context()
|
||||||
{
|
{
|
||||||
VERIFY(document().frame());
|
VERIFY(document().browsing_context());
|
||||||
return *document().frame();
|
return *document().browsing_context();
|
||||||
}
|
}
|
||||||
|
|
||||||
const InitialContainingBlockBox& Node::root() const
|
const InitialContainingBlockBox& Node::root() const
|
||||||
|
@ -140,7 +140,7 @@ void Node::set_needs_display()
|
||||||
if (auto* block = containing_block()) {
|
if (auto* block = containing_block()) {
|
||||||
block->for_each_fragment([&](auto& fragment) {
|
block->for_each_fragment([&](auto& fragment) {
|
||||||
if (&fragment.layout_node() == this || is_ancestor_of(fragment.layout_node())) {
|
if (&fragment.layout_node() == this || is_ancestor_of(fragment.layout_node())) {
|
||||||
frame().set_needs_display(enclosing_int_rect(fragment.absolute_rect()));
|
browsing_context().set_needs_display(enclosing_int_rect(fragment.absolute_rect()));
|
||||||
}
|
}
|
||||||
return IterationDecision::Continue;
|
return IterationDecision::Continue;
|
||||||
});
|
});
|
||||||
|
|
|
@ -65,8 +65,8 @@ public:
|
||||||
DOM::Document& document() { return m_document; }
|
DOM::Document& document() { return m_document; }
|
||||||
const DOM::Document& document() const { return m_document; }
|
const DOM::Document& document() const { return m_document; }
|
||||||
|
|
||||||
const Frame& frame() const;
|
const BrowsingContext& browsing_context() const;
|
||||||
Frame& frame();
|
BrowsingContext& browsing_context();
|
||||||
|
|
||||||
const InitialContainingBlockBox& root() const;
|
const InitialContainingBlockBox& root() const;
|
||||||
InitialContainingBlockBox& root();
|
InitialContainingBlockBox& root();
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include <LibWeb/DOM/Document.h>
|
#include <LibWeb/DOM/Document.h>
|
||||||
#include <LibWeb/Layout/Label.h>
|
#include <LibWeb/Layout/Label.h>
|
||||||
#include <LibWeb/Layout/RadioButton.h>
|
#include <LibWeb/Layout/RadioButton.h>
|
||||||
#include <LibWeb/Page/Frame.h>
|
#include <LibWeb/Page/BrowsingContext.h>
|
||||||
|
|
||||||
namespace Web::Layout {
|
namespace Web::Layout {
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ void RadioButton::handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint&, un
|
||||||
set_needs_display();
|
set_needs_display();
|
||||||
|
|
||||||
m_tracking_mouse = true;
|
m_tracking_mouse = true;
|
||||||
frame().event_handler().set_mouse_event_tracking_layout_node(this);
|
browsing_context().event_handler().set_mouse_event_tracking_layout_node(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RadioButton::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned button, unsigned)
|
void RadioButton::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned button, unsigned)
|
||||||
|
@ -68,7 +68,7 @@ void RadioButton::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& posit
|
||||||
|
|
||||||
m_being_pressed = false;
|
m_being_pressed = false;
|
||||||
m_tracking_mouse = false;
|
m_tracking_mouse = false;
|
||||||
frame().event_handler().set_mouse_event_tracking_layout_node(nullptr);
|
browsing_context().event_handler().set_mouse_event_tracking_layout_node(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RadioButton::handle_mousemove(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned, unsigned)
|
void RadioButton::handle_mousemove(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned, unsigned)
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#include <LibWeb/Layout/TableFormattingContext.h>
|
#include <LibWeb/Layout/TableFormattingContext.h>
|
||||||
#include <LibWeb/Layout/TableRowBox.h>
|
#include <LibWeb/Layout/TableRowBox.h>
|
||||||
#include <LibWeb/Layout/TableRowGroupBox.h>
|
#include <LibWeb/Layout/TableRowGroupBox.h>
|
||||||
#include <LibWeb/Page/Frame.h>
|
#include <LibWeb/Page/BrowsingContext.h>
|
||||||
|
|
||||||
namespace Web::Layout {
|
namespace Web::Layout {
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#include <LibWeb/Layout/InlineFormattingContext.h>
|
#include <LibWeb/Layout/InlineFormattingContext.h>
|
||||||
#include <LibWeb/Layout/Label.h>
|
#include <LibWeb/Layout/Label.h>
|
||||||
#include <LibWeb/Layout/TextNode.h>
|
#include <LibWeb/Layout/TextNode.h>
|
||||||
#include <LibWeb/Page/Frame.h>
|
#include <LibWeb/Page/BrowsingContext.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
namespace Web::Layout {
|
namespace Web::Layout {
|
||||||
|
@ -77,17 +77,17 @@ void TextNode::paint_fragment(PaintContext& context, const LineBoxFragment& frag
|
||||||
|
|
||||||
void TextNode::paint_cursor_if_needed(PaintContext& context, const LineBoxFragment& fragment) const
|
void TextNode::paint_cursor_if_needed(PaintContext& context, const LineBoxFragment& fragment) const
|
||||||
{
|
{
|
||||||
if (!frame().is_focused_frame())
|
if (!browsing_context().is_focused_context())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!frame().cursor_blink_state())
|
if (!browsing_context().cursor_blink_state())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (frame().cursor_position().node() != &dom_node())
|
if (browsing_context().cursor_position().node() != &dom_node())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// NOTE: This checks if the cursor is before the start or after the end of the fragment. If it is at the end, after all text, it should still be painted.
|
// NOTE: This checks if the cursor is before the start or after the end of the fragment. If it is at the end, after all text, it should still be painted.
|
||||||
if (frame().cursor_position().offset() < (unsigned)fragment.start() || frame().cursor_position().offset() > (unsigned)(fragment.start() + fragment.length()))
|
if (browsing_context().cursor_position().offset() < (unsigned)fragment.start() || browsing_context().cursor_position().offset() > (unsigned)(fragment.start() + fragment.length()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!fragment.layout_node().dom_node() || !fragment.layout_node().dom_node()->is_editable())
|
if (!fragment.layout_node().dom_node() || !fragment.layout_node().dom_node()->is_editable())
|
||||||
|
@ -95,7 +95,7 @@ void TextNode::paint_cursor_if_needed(PaintContext& context, const LineBoxFragme
|
||||||
|
|
||||||
auto fragment_rect = fragment.absolute_rect();
|
auto fragment_rect = fragment.absolute_rect();
|
||||||
|
|
||||||
float cursor_x = fragment_rect.x() + font().width(fragment.text().substring_view(0, frame().cursor_position().offset() - fragment.start()));
|
float cursor_x = fragment_rect.x() + font().width(fragment.text().substring_view(0, browsing_context().cursor_position().offset() - fragment.start()));
|
||||||
float cursor_top = fragment_rect.top();
|
float cursor_top = fragment_rect.top();
|
||||||
float cursor_height = fragment_rect.height();
|
float cursor_height = fragment_rect.height();
|
||||||
Gfx::IntRect cursor_rect(cursor_x, cursor_top, 1, cursor_height);
|
Gfx::IntRect cursor_rect(cursor_x, cursor_top, 1, cursor_height);
|
||||||
|
@ -234,7 +234,7 @@ void TextNode::handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint& positi
|
||||||
if (!parent() || !is<Label>(*parent()))
|
if (!parent() || !is<Label>(*parent()))
|
||||||
return;
|
return;
|
||||||
downcast<Label>(*parent()).handle_mousedown_on_label({}, position, button);
|
downcast<Label>(*parent()).handle_mousedown_on_label({}, position, button);
|
||||||
frame().event_handler().set_mouse_event_tracking_layout_node(this);
|
browsing_context().event_handler().set_mouse_event_tracking_layout_node(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextNode::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned button, unsigned)
|
void TextNode::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned button, unsigned)
|
||||||
|
@ -246,7 +246,7 @@ void TextNode::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& position
|
||||||
NonnullRefPtr protect = *this;
|
NonnullRefPtr protect = *this;
|
||||||
|
|
||||||
downcast<Label>(*parent()).handle_mouseup_on_label({}, position, button);
|
downcast<Label>(*parent()).handle_mouseup_on_label({}, position, button);
|
||||||
frame().event_handler().set_mouse_event_tracking_layout_node(nullptr);
|
browsing_context().event_handler().set_mouse_event_tracking_layout_node(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextNode::handle_mousemove(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned button, unsigned)
|
void TextNode::handle_mousemove(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned button, unsigned)
|
||||||
|
|
|
@ -18,13 +18,13 @@
|
||||||
#include <LibWeb/Loader/FrameLoader.h>
|
#include <LibWeb/Loader/FrameLoader.h>
|
||||||
#include <LibWeb/Loader/ResourceLoader.h>
|
#include <LibWeb/Loader/ResourceLoader.h>
|
||||||
#include <LibWeb/Namespace.h>
|
#include <LibWeb/Namespace.h>
|
||||||
#include <LibWeb/Page/Frame.h>
|
#include <LibWeb/Page/BrowsingContext.h>
|
||||||
#include <LibWeb/Page/Page.h>
|
#include <LibWeb/Page/Page.h>
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
FrameLoader::FrameLoader(Frame& frame)
|
FrameLoader::FrameLoader(BrowsingContext& browsing_context)
|
||||||
: m_frame(frame)
|
: m_browsing_context(browsing_context)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ bool FrameLoader::load(const LoadRequest& request, Type type)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_frame.is_frame_nesting_allowed(request.url())) {
|
if (!m_browsing_context.is_frame_nesting_allowed(request.url())) {
|
||||||
dbgln("No further recursion is allowed for the frame, abort load!");
|
dbgln("No further recursion is allowed for the frame, abort load!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ bool FrameLoader::load(const LoadRequest& request, Type type)
|
||||||
auto& url = request.url();
|
auto& url = request.url();
|
||||||
|
|
||||||
if (type == Type::Navigation || type == Type::Reload) {
|
if (type == Type::Navigation || type == Type::Reload) {
|
||||||
if (auto* page = frame().page())
|
if (auto* page = browsing_context().page())
|
||||||
page->client().page_did_start_loading(url);
|
page->client().page_did_start_loading(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ bool FrameLoader::load(const LoadRequest& request, Type type)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbgln("Decoded favicon, {}", bitmap->size());
|
dbgln("Decoded favicon, {}", bitmap->size());
|
||||||
if (auto* page = frame().page())
|
if (auto* page = browsing_context().page())
|
||||||
page->client().page_did_change_favicon(*bitmap);
|
page->client().page_did_change_favicon(*bitmap);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@ bool FrameLoader::load(const URL& url, Type type)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto request = LoadRequest::create_for_url_on_page(url, frame().page());
|
auto request = LoadRequest::create_for_url_on_page(url, browsing_context().page());
|
||||||
return load(request, type);
|
return load(request, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ void FrameLoader::load_html(const StringView& html, const URL& url)
|
||||||
auto document = DOM::Document::create(url);
|
auto document = DOM::Document::create(url);
|
||||||
HTML::HTMLDocumentParser parser(document, html, "utf-8");
|
HTML::HTMLDocumentParser parser(document, html, "utf-8");
|
||||||
parser.run(url);
|
parser.run(url);
|
||||||
frame().set_document(&parser.document());
|
browsing_context().set_document(&parser.document());
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Use an actual templating engine (our own one when it's built, preferably
|
// FIXME: Use an actual templating engine (our own one when it's built, preferably
|
||||||
|
@ -217,7 +217,7 @@ void FrameLoader::load_error_page(const URL& failed_url, const String& error)
|
||||||
generator.append(data);
|
generator.append(data);
|
||||||
auto document = HTML::parse_html_document(generator.as_string_view(), failed_url, "utf-8");
|
auto document = HTML::parse_html_document(generator.as_string_view(), failed_url, "utf-8");
|
||||||
VERIFY(document);
|
VERIFY(document);
|
||||||
frame().set_document(document);
|
browsing_context().set_document(document);
|
||||||
},
|
},
|
||||||
[](auto& error, auto) {
|
[](auto& error, auto) {
|
||||||
dbgln("Failed to load error page: {}", error);
|
dbgln("Failed to load error page: {}", error);
|
||||||
|
@ -259,7 +259,7 @@ void FrameLoader::resource_did_load()
|
||||||
document->set_encoding(resource()->encoding());
|
document->set_encoding(resource()->encoding());
|
||||||
document->set_content_type(resource()->mime_type());
|
document->set_content_type(resource()->mime_type());
|
||||||
|
|
||||||
frame().set_document(document);
|
browsing_context().set_document(document);
|
||||||
|
|
||||||
if (!parse_document(*document, resource()->encoded_data())) {
|
if (!parse_document(*document, resource()->encoded_data())) {
|
||||||
load_error_page(url, "Failed to parse content.");
|
load_error_page(url, "Failed to parse content.");
|
||||||
|
@ -272,15 +272,15 @@ void FrameLoader::resource_did_load()
|
||||||
document->set_cookie(set_cookie.value(), Cookie::Source::Http);
|
document->set_cookie(set_cookie.value(), Cookie::Source::Http);
|
||||||
|
|
||||||
if (!url.fragment().is_empty())
|
if (!url.fragment().is_empty())
|
||||||
frame().scroll_to_anchor(url.fragment());
|
browsing_context().scroll_to_anchor(url.fragment());
|
||||||
|
|
||||||
if (auto* host_element = frame().host_element()) {
|
if (auto* host_element = browsing_context().host_element()) {
|
||||||
// FIXME: Perhaps in the future we'll have a better common base class for <frame> and <iframe>
|
// FIXME: Perhaps in the future we'll have a better common base class for <frame> and <iframe>
|
||||||
VERIFY(is<HTML::HTMLIFrameElement>(*host_element));
|
VERIFY(is<HTML::HTMLIFrameElement>(*host_element));
|
||||||
downcast<HTML::HTMLIFrameElement>(*host_element).content_frame_did_load({});
|
downcast<HTML::HTMLIFrameElement>(*host_element).nested_browsing_context_did_load({});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto* page = frame().page())
|
if (auto* page = browsing_context().page())
|
||||||
page->client().page_did_finish_loading(url);
|
page->client().page_did_finish_loading(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ public:
|
||||||
IFrame,
|
IFrame,
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit FrameLoader(Frame&);
|
explicit FrameLoader(BrowsingContext&);
|
||||||
~FrameLoader();
|
~FrameLoader();
|
||||||
|
|
||||||
bool load(const URL&, Type);
|
bool load(const URL&, Type);
|
||||||
|
@ -31,8 +31,8 @@ public:
|
||||||
|
|
||||||
void load_html(const StringView&, const URL&);
|
void load_html(const StringView&, const URL&);
|
||||||
|
|
||||||
Frame& frame() { return m_frame; }
|
BrowsingContext& browsing_context() { return m_browsing_context; }
|
||||||
const Frame& frame() const { return m_frame; }
|
const BrowsingContext& browsing_context() const { return m_browsing_context; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// ^ResourceClient
|
// ^ResourceClient
|
||||||
|
@ -42,7 +42,7 @@ private:
|
||||||
void load_error_page(const URL& failed_url, const String& error_message);
|
void load_error_page(const URL& failed_url, const String& error_message);
|
||||||
bool parse_document(DOM::Document&, const ByteBuffer& data);
|
bool parse_document(DOM::Document&, const ByteBuffer& data);
|
||||||
|
|
||||||
Frame& m_frame;
|
BrowsingContext& m_browsing_context;
|
||||||
size_t m_redirects_count { 0 };
|
size_t m_redirects_count { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,14 +13,14 @@
|
||||||
#include <LibWeb/Layout/BreakNode.h>
|
#include <LibWeb/Layout/BreakNode.h>
|
||||||
#include <LibWeb/Layout/InitialContainingBlockBox.h>
|
#include <LibWeb/Layout/InitialContainingBlockBox.h>
|
||||||
#include <LibWeb/Layout/TextNode.h>
|
#include <LibWeb/Layout/TextNode.h>
|
||||||
#include <LibWeb/Page/Frame.h>
|
#include <LibWeb/Page/BrowsingContext.h>
|
||||||
#include <LibWeb/UIEvents/EventNames.h>
|
#include <LibWeb/UIEvents/EventNames.h>
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
Frame::Frame(DOM::Element& host_element, Frame& main_frame)
|
BrowsingContext::BrowsingContext(DOM::Element& host_element, BrowsingContext& top_level_browsing_context)
|
||||||
: m_page(*main_frame.page())
|
: m_page(*top_level_browsing_context.page())
|
||||||
, m_main_frame(main_frame)
|
, m_top_level_browsing_context(top_level_browsing_context)
|
||||||
, m_loader(*this)
|
, m_loader(*this)
|
||||||
, m_event_handler({}, *this)
|
, m_event_handler({}, *this)
|
||||||
, m_host_element(host_element)
|
, m_host_element(host_element)
|
||||||
|
@ -28,23 +28,23 @@ Frame::Frame(DOM::Element& host_element, Frame& main_frame)
|
||||||
setup();
|
setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
Frame::Frame(Page& page)
|
BrowsingContext::BrowsingContext(Page& page)
|
||||||
: m_page(page)
|
: m_page(page)
|
||||||
, m_main_frame(*this)
|
, m_top_level_browsing_context(*this)
|
||||||
, m_loader(*this)
|
, m_loader(*this)
|
||||||
, m_event_handler({}, *this)
|
, m_event_handler({}, *this)
|
||||||
{
|
{
|
||||||
setup();
|
setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
Frame::~Frame()
|
BrowsingContext::~BrowsingContext()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Frame::setup()
|
void BrowsingContext::setup()
|
||||||
{
|
{
|
||||||
m_cursor_blink_timer = Core::Timer::construct(500, [this] {
|
m_cursor_blink_timer = Core::Timer::construct(500, [this] {
|
||||||
if (!is_focused_frame())
|
if (!is_focused_context())
|
||||||
return;
|
return;
|
||||||
if (m_cursor_position.node() && m_cursor_position.node()->layout_node()) {
|
if (m_cursor_position.node() && m_cursor_position.node()->layout_node()) {
|
||||||
m_cursor_blink_state = !m_cursor_blink_state;
|
m_cursor_blink_state = !m_cursor_blink_state;
|
||||||
|
@ -53,24 +53,24 @@ void Frame::setup()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Frame::did_edit(Badge<EditEventHandler>)
|
void BrowsingContext::did_edit(Badge<EditEventHandler>)
|
||||||
{
|
{
|
||||||
reset_cursor_blink_cycle();
|
reset_cursor_blink_cycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Frame::reset_cursor_blink_cycle()
|
void BrowsingContext::reset_cursor_blink_cycle()
|
||||||
{
|
{
|
||||||
m_cursor_blink_state = true;
|
m_cursor_blink_state = true;
|
||||||
m_cursor_blink_timer->restart();
|
m_cursor_blink_timer->restart();
|
||||||
m_cursor_position.node()->layout_node()->set_needs_display();
|
m_cursor_position.node()->layout_node()->set_needs_display();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Frame::is_focused_frame() const
|
bool BrowsingContext::is_focused_context() const
|
||||||
{
|
{
|
||||||
return m_page && &m_page->focused_frame() == this;
|
return m_page && &m_page->focused_context() == this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Frame::set_document(DOM::Document* document)
|
void BrowsingContext::set_document(DOM::Document* document)
|
||||||
{
|
{
|
||||||
if (m_document == document)
|
if (m_document == document)
|
||||||
return;
|
return;
|
||||||
|
@ -78,21 +78,21 @@ void Frame::set_document(DOM::Document* document)
|
||||||
m_cursor_position = {};
|
m_cursor_position = {};
|
||||||
|
|
||||||
if (m_document)
|
if (m_document)
|
||||||
m_document->detach_from_frame({}, *this);
|
m_document->detach_from_browsing_context({}, *this);
|
||||||
|
|
||||||
m_document = document;
|
m_document = document;
|
||||||
|
|
||||||
if (m_document) {
|
if (m_document) {
|
||||||
m_document->attach_to_frame({}, *this);
|
m_document->attach_to_browsing_context({}, *this);
|
||||||
if (m_page && is_main_frame())
|
if (m_page && is_top_level())
|
||||||
m_page->client().page_did_change_title(m_document->title());
|
m_page->client().page_did_change_title(m_document->title());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_page)
|
if (m_page)
|
||||||
m_page->client().page_did_set_document_in_main_frame(m_document);
|
m_page->client().page_did_set_document_in_top_level_browsing_context(m_document);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Frame::set_viewport_rect(const Gfx::IntRect& rect)
|
void BrowsingContext::set_viewport_rect(const Gfx::IntRect& rect)
|
||||||
{
|
{
|
||||||
bool did_change = false;
|
bool did_change = false;
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ void Frame::set_viewport_rect(const Gfx::IntRect& rect)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Frame::set_size(const Gfx::IntSize& size)
|
void BrowsingContext::set_size(const Gfx::IntSize& size)
|
||||||
{
|
{
|
||||||
if (m_size == size)
|
if (m_size == size)
|
||||||
return;
|
return;
|
||||||
|
@ -130,7 +130,7 @@ void Frame::set_size(const Gfx::IntSize& size)
|
||||||
client->frame_did_set_viewport_rect(viewport_rect());
|
client->frame_did_set_viewport_rect(viewport_rect());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Frame::set_viewport_scroll_offset(const Gfx::IntPoint& offset)
|
void BrowsingContext::set_viewport_scroll_offset(const Gfx::IntPoint& offset)
|
||||||
{
|
{
|
||||||
if (m_viewport_scroll_offset == offset)
|
if (m_viewport_scroll_offset == offset)
|
||||||
return;
|
return;
|
||||||
|
@ -140,14 +140,14 @@ void Frame::set_viewport_scroll_offset(const Gfx::IntPoint& offset)
|
||||||
client->frame_did_set_viewport_rect(viewport_rect());
|
client->frame_did_set_viewport_rect(viewport_rect());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Frame::set_needs_display(const Gfx::IntRect& rect)
|
void BrowsingContext::set_needs_display(const Gfx::IntRect& rect)
|
||||||
{
|
{
|
||||||
if (!viewport_rect().intersects(rect))
|
if (!viewport_rect().intersects(rect))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (is_main_frame()) {
|
if (is_top_level()) {
|
||||||
if (m_page)
|
if (m_page)
|
||||||
m_page->client().page_did_invalidate(to_main_frame_rect(rect));
|
m_page->client().page_did_invalidate(to_top_level_rect(rect));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ void Frame::set_needs_display(const Gfx::IntRect& rect)
|
||||||
host_element()->layout_node()->set_needs_display();
|
host_element()->layout_node()->set_needs_display();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Frame::scroll_to_anchor(const String& fragment)
|
void BrowsingContext::scroll_to_anchor(const String& fragment)
|
||||||
{
|
{
|
||||||
if (!document())
|
if (!document())
|
||||||
return;
|
return;
|
||||||
|
@ -190,18 +190,18 @@ void Frame::scroll_to_anchor(const String& fragment)
|
||||||
m_page->client().page_did_request_scroll_into_view(enclosing_int_rect(float_rect));
|
m_page->client().page_did_request_scroll_into_view(enclosing_int_rect(float_rect));
|
||||||
}
|
}
|
||||||
|
|
||||||
Gfx::IntRect Frame::to_main_frame_rect(const Gfx::IntRect& a_rect)
|
Gfx::IntRect BrowsingContext::to_top_level_rect(const Gfx::IntRect& a_rect)
|
||||||
{
|
{
|
||||||
auto rect = a_rect;
|
auto rect = a_rect;
|
||||||
rect.set_location(to_main_frame_position(a_rect.location()));
|
rect.set_location(to_top_level_position(a_rect.location()));
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
Gfx::IntPoint Frame::to_main_frame_position(const Gfx::IntPoint& a_position)
|
Gfx::IntPoint BrowsingContext::to_top_level_position(const Gfx::IntPoint& a_position)
|
||||||
{
|
{
|
||||||
auto position = a_position;
|
auto position = a_position;
|
||||||
for (auto* ancestor = parent(); ancestor; ancestor = ancestor->parent()) {
|
for (auto* ancestor = parent(); ancestor; ancestor = ancestor->parent()) {
|
||||||
if (ancestor->is_main_frame())
|
if (ancestor->is_top_level())
|
||||||
break;
|
break;
|
||||||
if (!ancestor->host_element())
|
if (!ancestor->host_element())
|
||||||
return {};
|
return {};
|
||||||
|
@ -212,7 +212,7 @@ Gfx::IntPoint Frame::to_main_frame_position(const Gfx::IntPoint& a_position)
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Frame::set_cursor_position(DOM::Position position)
|
void BrowsingContext::set_cursor_position(DOM::Position position)
|
||||||
{
|
{
|
||||||
if (m_cursor_position == position)
|
if (m_cursor_position == position)
|
||||||
return;
|
return;
|
||||||
|
@ -228,7 +228,7 @@ void Frame::set_cursor_position(DOM::Position position)
|
||||||
reset_cursor_blink_cycle();
|
reset_cursor_blink_cycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
String Frame::selected_text() const
|
String BrowsingContext::selected_text() const
|
||||||
{
|
{
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
if (!m_document)
|
if (!m_document)
|
||||||
|
@ -275,29 +275,29 @@ String Frame::selected_text() const
|
||||||
return builder.to_string();
|
return builder.to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Frame::register_viewport_client(ViewportClient& client)
|
void BrowsingContext::register_viewport_client(ViewportClient& client)
|
||||||
{
|
{
|
||||||
auto result = m_viewport_clients.set(&client);
|
auto result = m_viewport_clients.set(&client);
|
||||||
VERIFY(result == AK::HashSetResult::InsertedNewEntry);
|
VERIFY(result == AK::HashSetResult::InsertedNewEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Frame::unregister_viewport_client(ViewportClient& client)
|
void BrowsingContext::unregister_viewport_client(ViewportClient& client)
|
||||||
{
|
{
|
||||||
bool was_removed = m_viewport_clients.remove(&client);
|
bool was_removed = m_viewport_clients.remove(&client);
|
||||||
VERIFY(was_removed);
|
VERIFY(was_removed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Frame::register_frame_nesting(URL const& url)
|
void BrowsingContext::register_frame_nesting(URL const& url)
|
||||||
{
|
{
|
||||||
m_frame_nesting_levels.ensure(url)++;
|
m_frame_nesting_levels.ensure(url)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Frame::is_frame_nesting_allowed(URL const& url) const
|
bool BrowsingContext::is_frame_nesting_allowed(URL const& url) const
|
||||||
{
|
{
|
||||||
return m_frame_nesting_levels.get(url).value_or(0) < 3;
|
return m_frame_nesting_levels.get(url).value_or(0) < 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Frame::increment_cursor_position_offset()
|
bool BrowsingContext::increment_cursor_position_offset()
|
||||||
{
|
{
|
||||||
if (!m_cursor_position.increment_offset())
|
if (!m_cursor_position.increment_offset())
|
||||||
return false;
|
return false;
|
||||||
|
@ -305,7 +305,7 @@ bool Frame::increment_cursor_position_offset()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Frame::decrement_cursor_position_offset()
|
bool BrowsingContext::decrement_cursor_position_offset()
|
||||||
{
|
{
|
||||||
if (!m_cursor_position.decrement_offset())
|
if (!m_cursor_position.decrement_offset())
|
||||||
return false;
|
return false;
|
|
@ -21,11 +21,11 @@
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
class Frame : public TreeNode<Frame> {
|
class BrowsingContext : public TreeNode<BrowsingContext> {
|
||||||
public:
|
public:
|
||||||
static NonnullRefPtr<Frame> create_subframe(DOM::Element& host_element, Frame& main_frame) { return adopt_ref(*new Frame(host_element, main_frame)); }
|
static NonnullRefPtr<BrowsingContext> create_nested(DOM::Element& host_element, BrowsingContext& top_level_browsing_context) { return adopt_ref(*new BrowsingContext(host_element, top_level_browsing_context)); }
|
||||||
static NonnullRefPtr<Frame> create(Page& page) { return adopt_ref(*new Frame(page)); }
|
static NonnullRefPtr<BrowsingContext> create(Page& page) { return adopt_ref(*new BrowsingContext(page)); }
|
||||||
~Frame();
|
~BrowsingContext();
|
||||||
|
|
||||||
class ViewportClient {
|
class ViewportClient {
|
||||||
public:
|
public:
|
||||||
|
@ -35,8 +35,8 @@ public:
|
||||||
void register_viewport_client(ViewportClient&);
|
void register_viewport_client(ViewportClient&);
|
||||||
void unregister_viewport_client(ViewportClient&);
|
void unregister_viewport_client(ViewportClient&);
|
||||||
|
|
||||||
bool is_main_frame() const { return this == &m_main_frame; }
|
bool is_top_level() const { return this == &m_top_level_browsing_context; }
|
||||||
bool is_focused_frame() const;
|
bool is_focused_context() const;
|
||||||
|
|
||||||
const DOM::Document* document() const { return m_document; }
|
const DOM::Document* document() const { return m_document; }
|
||||||
DOM::Document* document() { return m_document; }
|
DOM::Document* document() { return m_document; }
|
||||||
|
@ -63,14 +63,14 @@ public:
|
||||||
|
|
||||||
void scroll_to_anchor(const String&);
|
void scroll_to_anchor(const String&);
|
||||||
|
|
||||||
Frame& main_frame() { return m_main_frame; }
|
BrowsingContext& top_level_browsing_context() { return m_top_level_browsing_context; }
|
||||||
const Frame& main_frame() const { return m_main_frame; }
|
BrowsingContext const& top_level_browsing_context() const { return m_top_level_browsing_context; }
|
||||||
|
|
||||||
DOM::Element* host_element() { return m_host_element; }
|
DOM::Element* host_element() { return m_host_element; }
|
||||||
const DOM::Element* host_element() const { return m_host_element; }
|
const DOM::Element* host_element() const { return m_host_element; }
|
||||||
|
|
||||||
Gfx::IntPoint to_main_frame_position(const Gfx::IntPoint&);
|
Gfx::IntPoint to_top_level_position(const Gfx::IntPoint&);
|
||||||
Gfx::IntRect to_main_frame_rect(const Gfx::IntRect&);
|
Gfx::IntRect to_top_level_rect(const Gfx::IntRect&);
|
||||||
|
|
||||||
const DOM::Position& cursor_position() const { return m_cursor_position; }
|
const DOM::Position& cursor_position() const { return m_cursor_position; }
|
||||||
void set_cursor_position(DOM::Position);
|
void set_cursor_position(DOM::Position);
|
||||||
|
@ -90,15 +90,15 @@ public:
|
||||||
HashMap<URL, size_t> const& frame_nesting_levels() const { return m_frame_nesting_levels; }
|
HashMap<URL, size_t> const& frame_nesting_levels() const { return m_frame_nesting_levels; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit Frame(DOM::Element& host_element, Frame& main_frame);
|
explicit BrowsingContext(DOM::Element& host_element, BrowsingContext& top_level_browsing_context);
|
||||||
explicit Frame(Page&);
|
explicit BrowsingContext(Page&);
|
||||||
|
|
||||||
void reset_cursor_blink_cycle();
|
void reset_cursor_blink_cycle();
|
||||||
|
|
||||||
void setup();
|
void setup();
|
||||||
|
|
||||||
WeakPtr<Page> m_page;
|
WeakPtr<Page> m_page;
|
||||||
Frame& m_main_frame;
|
BrowsingContext& m_top_level_browsing_context;
|
||||||
|
|
||||||
FrameLoader m_loader;
|
FrameLoader m_loader;
|
||||||
EventHandler m_event_handler;
|
EventHandler m_event_handler;
|
|
@ -12,8 +12,8 @@
|
||||||
#include <LibWeb/DOM/Text.h>
|
#include <LibWeb/DOM/Text.h>
|
||||||
#include <LibWeb/Layout/InitialContainingBlockBox.h>
|
#include <LibWeb/Layout/InitialContainingBlockBox.h>
|
||||||
#include <LibWeb/Layout/LayoutPosition.h>
|
#include <LibWeb/Layout/LayoutPosition.h>
|
||||||
|
#include <LibWeb/Page/BrowsingContext.h>
|
||||||
#include <LibWeb/Page/EditEventHandler.h>
|
#include <LibWeb/Page/EditEventHandler.h>
|
||||||
#include <LibWeb/Page/Frame.h>
|
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace Web {
|
||||||
|
|
||||||
class EditEventHandler {
|
class EditEventHandler {
|
||||||
public:
|
public:
|
||||||
explicit EditEventHandler(Frame& frame)
|
explicit EditEventHandler(BrowsingContext& frame)
|
||||||
: m_frame(frame)
|
: m_frame(frame)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ public:
|
||||||
virtual void handle_insert(DOM::Position, u32 code_point);
|
virtual void handle_insert(DOM::Position, u32 code_point);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Frame& m_frame;
|
BrowsingContext& m_frame;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
#include <LibWeb/HTML/HTMLImageElement.h>
|
#include <LibWeb/HTML/HTMLImageElement.h>
|
||||||
#include <LibWeb/InProcessWebView.h>
|
#include <LibWeb/InProcessWebView.h>
|
||||||
#include <LibWeb/Layout/InitialContainingBlockBox.h>
|
#include <LibWeb/Layout/InitialContainingBlockBox.h>
|
||||||
|
#include <LibWeb/Page/BrowsingContext.h>
|
||||||
#include <LibWeb/Page/EventHandler.h>
|
#include <LibWeb/Page/EventHandler.h>
|
||||||
#include <LibWeb/Page/Frame.h>
|
|
||||||
#include <LibWeb/UIEvents/EventNames.h>
|
#include <LibWeb/UIEvents/EventNames.h>
|
||||||
#include <LibWeb/UIEvents/MouseEvent.h>
|
#include <LibWeb/UIEvents/MouseEvent.h>
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ static Gfx::IntPoint compute_mouse_event_offset(const Gfx::IntPoint& position, c
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
EventHandler::EventHandler(Badge<Frame>, Frame& frame)
|
EventHandler::EventHandler(Badge<BrowsingContext>, BrowsingContext& frame)
|
||||||
: m_frame(frame)
|
: m_frame(frame)
|
||||||
, m_edit_event_handler(make<EditEventHandler>(frame))
|
, m_edit_event_handler(make<EditEventHandler>(frame))
|
||||||
{
|
{
|
||||||
|
@ -158,7 +158,7 @@ bool EventHandler::handle_mouseup(const Gfx::IntPoint& position, unsigned button
|
||||||
if (result.layout_node && result.layout_node->dom_node()) {
|
if (result.layout_node && result.layout_node->dom_node()) {
|
||||||
RefPtr<DOM::Node> node = result.layout_node->dom_node();
|
RefPtr<DOM::Node> node = result.layout_node->dom_node();
|
||||||
if (is<HTML::HTMLIFrameElement>(*node)) {
|
if (is<HTML::HTMLIFrameElement>(*node)) {
|
||||||
if (auto* subframe = downcast<HTML::HTMLIFrameElement>(*node).content_frame())
|
if (auto* subframe = downcast<HTML::HTMLIFrameElement>(*node).nested_browsing_context())
|
||||||
return subframe->event_handler().handle_mouseup(position.translated(compute_mouse_event_offset({}, *result.layout_node)), button, modifiers);
|
return subframe->event_handler().handle_mouseup(position.translated(compute_mouse_event_offset({}, *result.layout_node)), button, modifiers);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -202,13 +202,13 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (is<HTML::HTMLIFrameElement>(*node)) {
|
if (is<HTML::HTMLIFrameElement>(*node)) {
|
||||||
if (auto* subframe = downcast<HTML::HTMLIFrameElement>(*node).content_frame())
|
if (auto* subframe = downcast<HTML::HTMLIFrameElement>(*node).nested_browsing_context())
|
||||||
return subframe->event_handler().handle_mousedown(position.translated(compute_mouse_event_offset({}, *result.layout_node)), button, modifiers);
|
return subframe->event_handler().handle_mousedown(position.translated(compute_mouse_event_offset({}, *result.layout_node)), button, modifiers);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto* page = m_frame.page())
|
if (auto* page = m_frame.page())
|
||||||
page->set_focused_frame({}, m_frame);
|
page->set_focused_browsing_context({}, m_frame);
|
||||||
|
|
||||||
auto offset = compute_mouse_event_offset(position, *result.layout_node);
|
auto offset = compute_mouse_event_offset(position, *result.layout_node);
|
||||||
node->dispatch_event(UIEvents::MouseEvent::create(UIEvents::EventNames::mousedown, offset.x(), offset.y(), position.x(), position.y()));
|
node->dispatch_event(UIEvents::MouseEvent::create(UIEvents::EventNames::mousedown, offset.x(), offset.y(), position.x(), position.y()));
|
||||||
|
@ -222,7 +222,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt
|
||||||
auto& image_element = downcast<HTML::HTMLImageElement>(*node);
|
auto& image_element = downcast<HTML::HTMLImageElement>(*node);
|
||||||
auto image_url = image_element.document().complete_url(image_element.src());
|
auto image_url = image_element.document().complete_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_main_frame_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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt
|
||||||
auto anchor = href.substring_view(1, href.length() - 1);
|
auto anchor = href.substring_view(1, href.length() - 1);
|
||||||
m_frame.scroll_to_anchor(anchor);
|
m_frame.scroll_to_anchor(anchor);
|
||||||
} else {
|
} else {
|
||||||
if (m_frame.is_main_frame()) {
|
if (m_frame.is_top_level()) {
|
||||||
if (auto* page = m_frame.page())
|
if (auto* page = m_frame.page())
|
||||||
page->client().page_did_click_link(url, link->target(), modifiers);
|
page->client().page_did_click_link(url, link->target(), modifiers);
|
||||||
} else {
|
} else {
|
||||||
|
@ -247,7 +247,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt
|
||||||
}
|
}
|
||||||
} else if (button == GUI::MouseButton::Right) {
|
} else if (button == GUI::MouseButton::Right) {
|
||||||
if (auto* page = m_frame.page())
|
if (auto* page = m_frame.page())
|
||||||
page->client().page_did_request_link_context_menu(m_frame.to_main_frame_position(position), url, link->target(), modifiers);
|
page->client().page_did_request_link_context_menu(m_frame.to_top_level_position(position), url, link->target(), modifiers);
|
||||||
} else if (button == GUI::MouseButton::Middle) {
|
} else if (button == GUI::MouseButton::Middle) {
|
||||||
if (auto* page = m_frame.page())
|
if (auto* page = m_frame.page())
|
||||||
page->client().page_did_middle_click_link(url, link->target(), modifiers);
|
page->client().page_did_middle_click_link(url, link->target(), modifiers);
|
||||||
|
@ -262,7 +262,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt
|
||||||
}
|
}
|
||||||
} else if (button == GUI::MouseButton::Right) {
|
} else if (button == GUI::MouseButton::Right) {
|
||||||
if (auto* page = m_frame.page())
|
if (auto* page = m_frame.page())
|
||||||
page->client().page_did_request_context_menu(m_frame.to_main_frame_position(position));
|
page->client().page_did_request_context_menu(m_frame.to_top_level_position(position));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -299,7 +299,7 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt
|
||||||
RefPtr<DOM::Node> node = result.layout_node->dom_node();
|
RefPtr<DOM::Node> node = result.layout_node->dom_node();
|
||||||
|
|
||||||
if (node && is<HTML::HTMLIFrameElement>(*node)) {
|
if (node && is<HTML::HTMLIFrameElement>(*node)) {
|
||||||
if (auto* subframe = downcast<HTML::HTMLIFrameElement>(*node).content_frame())
|
if (auto* subframe = downcast<HTML::HTMLIFrameElement>(*node).nested_browsing_context())
|
||||||
return subframe->event_handler().handle_mousemove(position.translated(compute_mouse_event_offset({}, *result.layout_node)), buttons, modifiers);
|
return subframe->event_handler().handle_mousemove(position.translated(compute_mouse_event_offset({}, *result.layout_node)), buttons, modifiers);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -340,7 +340,7 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt
|
||||||
if (hovered_node_changed) {
|
if (hovered_node_changed) {
|
||||||
RefPtr<HTML::HTMLElement> hovered_html_element = document.hovered_node() ? document.hovered_node()->enclosing_html_element_with_attribute(HTML::AttributeNames::title) : nullptr;
|
RefPtr<HTML::HTMLElement> hovered_html_element = document.hovered_node() ? document.hovered_node()->enclosing_html_element_with_attribute(HTML::AttributeNames::title) : nullptr;
|
||||||
if (hovered_html_element && !hovered_html_element->title().is_null()) {
|
if (hovered_html_element && !hovered_html_element->title().is_null()) {
|
||||||
page->client().page_did_enter_tooltip_area(m_frame.to_main_frame_position(position), hovered_html_element->title());
|
page->client().page_did_enter_tooltip_area(m_frame.to_top_level_position(position), hovered_html_element->title());
|
||||||
} else {
|
} else {
|
||||||
page->client().page_did_leave_tooltip_area();
|
page->client().page_did_leave_tooltip_area();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,11 +17,11 @@
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
class Frame;
|
class BrowsingContext;
|
||||||
|
|
||||||
class EventHandler {
|
class EventHandler {
|
||||||
public:
|
public:
|
||||||
explicit EventHandler(Badge<Frame>, Frame&);
|
explicit EventHandler(Badge<BrowsingContext>, BrowsingContext&);
|
||||||
~EventHandler();
|
~EventHandler();
|
||||||
|
|
||||||
bool handle_mouseup(const Gfx::IntPoint&, unsigned button, unsigned modifiers);
|
bool handle_mouseup(const Gfx::IntPoint&, unsigned button, unsigned modifiers);
|
||||||
|
@ -42,7 +42,7 @@ private:
|
||||||
Layout::InitialContainingBlockBox* layout_root();
|
Layout::InitialContainingBlockBox* layout_root();
|
||||||
const Layout::InitialContainingBlockBox* layout_root() const;
|
const Layout::InitialContainingBlockBox* layout_root() const;
|
||||||
|
|
||||||
Frame& m_frame;
|
BrowsingContext& m_frame;
|
||||||
|
|
||||||
bool m_in_mouse_selection { false };
|
bool m_in_mouse_selection { false };
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <LibWeb/InProcessWebView.h>
|
#include <LibWeb/InProcessWebView.h>
|
||||||
#include <LibWeb/Page/Frame.h>
|
#include <LibWeb/Page/BrowsingContext.h>
|
||||||
#include <LibWeb/Page/Page.h>
|
#include <LibWeb/Page/Page.h>
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
@ -13,38 +13,38 @@ namespace Web {
|
||||||
Page::Page(PageClient& client)
|
Page::Page(PageClient& client)
|
||||||
: m_client(client)
|
: m_client(client)
|
||||||
{
|
{
|
||||||
m_main_frame = Frame::create(*this);
|
m_top_level_browsing_context = BrowsingContext::create(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Page::~Page()
|
Page::~Page()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Frame& Page::focused_frame()
|
BrowsingContext& Page::focused_context()
|
||||||
{
|
{
|
||||||
if (m_focused_frame)
|
if (m_focused_context)
|
||||||
return *m_focused_frame;
|
return *m_focused_context;
|
||||||
return main_frame();
|
return top_level_browsing_context();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Page::set_focused_frame(Badge<EventHandler>, Frame& frame)
|
void Page::set_focused_browsing_context(Badge<EventHandler>, BrowsingContext& browsing_context)
|
||||||
{
|
{
|
||||||
m_focused_frame = frame.make_weak_ptr();
|
m_focused_context = browsing_context.make_weak_ptr();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Page::load(const URL& url)
|
void Page::load(const URL& url)
|
||||||
{
|
{
|
||||||
main_frame().loader().load(url, FrameLoader::Type::Navigation);
|
top_level_browsing_context().loader().load(url, FrameLoader::Type::Navigation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Page::load(const LoadRequest& request)
|
void Page::load(const LoadRequest& request)
|
||||||
{
|
{
|
||||||
main_frame().loader().load(request, FrameLoader::Type::Navigation);
|
top_level_browsing_context().loader().load(request, FrameLoader::Type::Navigation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Page::load_html(const StringView& html, const URL& url)
|
void Page::load_html(const StringView& html, const URL& url)
|
||||||
{
|
{
|
||||||
main_frame().loader().load_html(html, url);
|
top_level_browsing_context().loader().load_html(html, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
Gfx::Palette Page::palette() const
|
Gfx::Palette Page::palette() const
|
||||||
|
@ -59,27 +59,27 @@ Gfx::IntRect Page::screen_rect() const
|
||||||
|
|
||||||
bool Page::handle_mousewheel(const Gfx::IntPoint& position, unsigned button, unsigned modifiers, int wheel_delta)
|
bool Page::handle_mousewheel(const Gfx::IntPoint& position, unsigned button, unsigned modifiers, int wheel_delta)
|
||||||
{
|
{
|
||||||
return main_frame().event_handler().handle_mousewheel(position, button, modifiers, wheel_delta);
|
return top_level_browsing_context().event_handler().handle_mousewheel(position, button, modifiers, wheel_delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Page::handle_mouseup(const Gfx::IntPoint& position, unsigned button, unsigned modifiers)
|
bool Page::handle_mouseup(const Gfx::IntPoint& position, unsigned button, unsigned modifiers)
|
||||||
{
|
{
|
||||||
return main_frame().event_handler().handle_mouseup(position, button, modifiers);
|
return top_level_browsing_context().event_handler().handle_mouseup(position, button, modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Page::handle_mousedown(const Gfx::IntPoint& position, unsigned button, unsigned modifiers)
|
bool Page::handle_mousedown(const Gfx::IntPoint& position, unsigned button, unsigned modifiers)
|
||||||
{
|
{
|
||||||
return main_frame().event_handler().handle_mousedown(position, button, modifiers);
|
return top_level_browsing_context().event_handler().handle_mousedown(position, button, modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Page::handle_mousemove(const Gfx::IntPoint& position, unsigned buttons, unsigned modifiers)
|
bool Page::handle_mousemove(const Gfx::IntPoint& position, unsigned buttons, unsigned modifiers)
|
||||||
{
|
{
|
||||||
return main_frame().event_handler().handle_mousemove(position, buttons, modifiers);
|
return top_level_browsing_context().event_handler().handle_mousemove(position, buttons, modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Page::handle_keydown(KeyCode key, unsigned modifiers, u32 code_point)
|
bool Page::handle_keydown(KeyCode key, unsigned modifiers, u32 code_point)
|
||||||
{
|
{
|
||||||
return focused_frame().event_handler().handle_keydown(key, modifiers, code_point);
|
return focused_context().event_handler().handle_keydown(key, modifiers, code_point);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,13 +33,13 @@ public:
|
||||||
PageClient& client() { return m_client; }
|
PageClient& client() { return m_client; }
|
||||||
const PageClient& client() const { return m_client; }
|
const PageClient& client() const { return m_client; }
|
||||||
|
|
||||||
Web::Frame& main_frame() { return *m_main_frame; }
|
Web::BrowsingContext& top_level_browsing_context() { return *m_top_level_browsing_context; }
|
||||||
const Web::Frame& main_frame() const { return *m_main_frame; }
|
const Web::BrowsingContext& top_level_browsing_context() const { return *m_top_level_browsing_context; }
|
||||||
|
|
||||||
Web::Frame& focused_frame();
|
Web::BrowsingContext& focused_context();
|
||||||
const Web::Frame& focused_frame() const { return const_cast<Page*>(this)->focused_frame(); }
|
const Web::BrowsingContext& focused_context() const { return const_cast<Page*>(this)->focused_context(); }
|
||||||
|
|
||||||
void set_focused_frame(Badge<EventHandler>, Frame&);
|
void set_focused_browsing_context(Badge<EventHandler>, BrowsingContext&);
|
||||||
|
|
||||||
void load(const URL&);
|
void load(const URL&);
|
||||||
void load(const LoadRequest&);
|
void load(const LoadRequest&);
|
||||||
|
@ -59,8 +59,8 @@ public:
|
||||||
private:
|
private:
|
||||||
PageClient& m_client;
|
PageClient& m_client;
|
||||||
|
|
||||||
RefPtr<Frame> m_main_frame;
|
RefPtr<BrowsingContext> m_top_level_browsing_context;
|
||||||
WeakPtr<Frame> m_focused_frame;
|
WeakPtr<BrowsingContext> m_focused_context;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PageClient {
|
class PageClient {
|
||||||
|
@ -68,7 +68,7 @@ public:
|
||||||
virtual bool is_multi_process() const = 0;
|
virtual bool is_multi_process() const = 0;
|
||||||
virtual Gfx::Palette palette() const = 0;
|
virtual Gfx::Palette palette() const = 0;
|
||||||
virtual Gfx::IntRect screen_rect() const = 0;
|
virtual Gfx::IntRect screen_rect() const = 0;
|
||||||
virtual void page_did_set_document_in_main_frame(DOM::Document*) { }
|
virtual void page_did_set_document_in_top_level_browsing_context(DOM::Document*) { }
|
||||||
virtual void page_did_change_title(const String&) { }
|
virtual void page_did_change_title(const String&) { }
|
||||||
virtual void page_did_start_loading(const URL&) { }
|
virtual void page_did_start_loading(const URL&) { }
|
||||||
virtual void page_did_finish_loading(const URL&) { }
|
virtual void page_did_finish_loading(const URL&) { }
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include <LibWeb/Dump.h>
|
#include <LibWeb/Dump.h>
|
||||||
#include <LibWeb/Layout/InitialContainingBlockBox.h>
|
#include <LibWeb/Layout/InitialContainingBlockBox.h>
|
||||||
#include <LibWeb/Loader/ResourceLoader.h>
|
#include <LibWeb/Loader/ResourceLoader.h>
|
||||||
#include <LibWeb/Page/Frame.h>
|
#include <LibWeb/Page/BrowsingContext.h>
|
||||||
#include <WebContent/ClientConnection.h>
|
#include <WebContent/ClientConnection.h>
|
||||||
#include <WebContent/PageHost.h>
|
#include <WebContent/PageHost.h>
|
||||||
#include <WebContent/WebContentClientEndpoint.h>
|
#include <WebContent/WebContentClientEndpoint.h>
|
||||||
|
@ -171,19 +171,19 @@ void ClientConnection::key_down(i32 key, unsigned int modifiers, u32 code_point)
|
||||||
void ClientConnection::debug_request(const String& request, const String& argument)
|
void ClientConnection::debug_request(const String& request, const String& argument)
|
||||||
{
|
{
|
||||||
if (request == "dump-dom-tree") {
|
if (request == "dump-dom-tree") {
|
||||||
if (auto* doc = page().main_frame().document())
|
if (auto* doc = page().top_level_browsing_context().document())
|
||||||
Web::dump_tree(*doc);
|
Web::dump_tree(*doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request == "dump-layout-tree") {
|
if (request == "dump-layout-tree") {
|
||||||
if (auto* doc = page().main_frame().document()) {
|
if (auto* doc = page().top_level_browsing_context().document()) {
|
||||||
if (auto* icb = doc->layout_node())
|
if (auto* icb = doc->layout_node())
|
||||||
Web::dump_tree(*icb);
|
Web::dump_tree(*icb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request == "dump-style-sheets") {
|
if (request == "dump-style-sheets") {
|
||||||
if (auto* doc = page().main_frame().document()) {
|
if (auto* doc = page().top_level_browsing_context().document()) {
|
||||||
for (auto& sheet : doc->style_sheets().sheets()) {
|
for (auto& sheet : doc->style_sheets().sheets()) {
|
||||||
Web::dump_sheet(sheet);
|
Web::dump_sheet(sheet);
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ void ClientConnection::debug_request(const String& request, const String& argume
|
||||||
if (request == "set-line-box-borders") {
|
if (request == "set-line-box-borders") {
|
||||||
bool state = argument == "on";
|
bool state = argument == "on";
|
||||||
m_page_host->set_should_show_line_box_borders(state);
|
m_page_host->set_should_show_line_box_borders(state);
|
||||||
page().main_frame().set_needs_display(page().main_frame().viewport_rect());
|
page().top_level_browsing_context().set_needs_display(page().top_level_browsing_context().viewport_rect());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request == "clear-cache") {
|
if (request == "clear-cache") {
|
||||||
|
@ -211,14 +211,14 @@ void ClientConnection::debug_request(const String& request, const String& argume
|
||||||
|
|
||||||
void ClientConnection::get_source()
|
void ClientConnection::get_source()
|
||||||
{
|
{
|
||||||
if (auto* doc = page().main_frame().document()) {
|
if (auto* doc = page().top_level_browsing_context().document()) {
|
||||||
async_did_get_source(doc->url(), doc->source());
|
async_did_get_source(doc->url(), doc->source());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientConnection::js_console_initialize()
|
void ClientConnection::js_console_initialize()
|
||||||
{
|
{
|
||||||
if (auto* document = page().main_frame().document()) {
|
if (auto* document = page().top_level_browsing_context().document()) {
|
||||||
auto interpreter = document->interpreter().make_weak_ptr();
|
auto interpreter = document->interpreter().make_weak_ptr();
|
||||||
if (m_interpreter.ptr() == interpreter.ptr())
|
if (m_interpreter.ptr() == interpreter.ptr())
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include <LibGfx/SystemTheme.h>
|
#include <LibGfx/SystemTheme.h>
|
||||||
#include <LibWeb/Cookie/ParsedCookie.h>
|
#include <LibWeb/Cookie/ParsedCookie.h>
|
||||||
#include <LibWeb/Layout/InitialContainingBlockBox.h>
|
#include <LibWeb/Layout/InitialContainingBlockBox.h>
|
||||||
#include <LibWeb/Page/Frame.h>
|
#include <LibWeb/Page/BrowsingContext.h>
|
||||||
#include <WebContent/WebContentClientEndpoint.h>
|
#include <WebContent/WebContentClientEndpoint.h>
|
||||||
|
|
||||||
namespace WebContent {
|
namespace WebContent {
|
||||||
|
@ -48,7 +48,7 @@ void PageHost::set_palette_impl(const Gfx::PaletteImpl& impl)
|
||||||
|
|
||||||
Web::Layout::InitialContainingBlockBox* PageHost::layout_root()
|
Web::Layout::InitialContainingBlockBox* PageHost::layout_root()
|
||||||
{
|
{
|
||||||
auto* document = page().main_frame().document();
|
auto* document = page().top_level_browsing_context().document();
|
||||||
if (!document)
|
if (!document)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return document->layout_node();
|
return document->layout_node();
|
||||||
|
@ -73,7 +73,7 @@ void PageHost::paint(const Gfx::IntRect& content_rect, Gfx::Bitmap& target)
|
||||||
|
|
||||||
void PageHost::set_viewport_rect(const Gfx::IntRect& rect)
|
void PageHost::set_viewport_rect(const Gfx::IntRect& rect)
|
||||||
{
|
{
|
||||||
page().main_frame().set_viewport_rect(rect);
|
page().top_level_browsing_context().set_viewport_rect(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PageHost::page_did_invalidate(const Gfx::IntRect& content_rect)
|
void PageHost::page_did_invalidate(const Gfx::IntRect& content_rect)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue