2020-06-08 20:31:49 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-06-08 20:31:49 +02:00
|
|
|
*/
|
|
|
|
|
2020-09-18 09:49:51 +02:00
|
|
|
#include <LibWeb/InProcessWebView.h>
|
2020-07-28 19:27:41 +02:00
|
|
|
#include <LibWeb/Page/Frame.h>
|
|
|
|
#include <LibWeb/Page/Page.h>
|
2020-06-08 20:31:49 +02:00
|
|
|
|
|
|
|
namespace Web {
|
|
|
|
|
|
|
|
Page::Page(PageClient& client)
|
|
|
|
: m_client(client)
|
|
|
|
{
|
|
|
|
m_main_frame = Frame::create(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
Page::~Page()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-08-14 11:33:20 +02:00
|
|
|
Frame& Page::focused_frame()
|
|
|
|
{
|
|
|
|
if (m_focused_frame)
|
|
|
|
return *m_focused_frame;
|
|
|
|
return main_frame();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Page::set_focused_frame(Badge<EventHandler>, Frame& frame)
|
|
|
|
{
|
|
|
|
m_focused_frame = frame.make_weak_ptr();
|
|
|
|
}
|
|
|
|
|
2020-06-08 20:31:49 +02:00
|
|
|
void Page::load(const URL& url)
|
|
|
|
{
|
2020-07-07 17:25:33 +02:00
|
|
|
main_frame().loader().load(url, FrameLoader::Type::Navigation);
|
2020-06-08 20:31:49 +02:00
|
|
|
}
|
|
|
|
|
2020-09-28 11:55:26 +02:00
|
|
|
void Page::load(const LoadRequest& request)
|
|
|
|
{
|
|
|
|
main_frame().loader().load(request, FrameLoader::Type::Navigation);
|
|
|
|
}
|
|
|
|
|
2020-10-08 21:11:01 +01:00
|
|
|
void Page::load_html(const StringView& html, const URL& url)
|
|
|
|
{
|
|
|
|
main_frame().loader().load_html(html, url);
|
|
|
|
}
|
|
|
|
|
2020-06-08 20:31:49 +02:00
|
|
|
Gfx::Palette Page::palette() const
|
|
|
|
{
|
2020-06-17 20:26:59 +02:00
|
|
|
return m_client.palette();
|
2020-06-08 20:31:49 +02:00
|
|
|
}
|
|
|
|
|
2021-04-04 00:12:37 +02:00
|
|
|
Gfx::IntRect Page::screen_rect() const
|
|
|
|
{
|
|
|
|
return m_client.screen_rect();
|
|
|
|
}
|
|
|
|
|
2021-02-22 19:45:41 +01:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2020-06-10 10:57:59 +02:00
|
|
|
bool Page::handle_mouseup(const Gfx::IntPoint& position, unsigned button, unsigned modifiers)
|
2020-06-08 20:31:49 +02:00
|
|
|
{
|
|
|
|
return main_frame().event_handler().handle_mouseup(position, button, modifiers);
|
|
|
|
}
|
|
|
|
|
2020-06-10 10:57:59 +02:00
|
|
|
bool Page::handle_mousedown(const Gfx::IntPoint& position, unsigned button, unsigned modifiers)
|
2020-06-08 20:31:49 +02:00
|
|
|
{
|
|
|
|
return main_frame().event_handler().handle_mousedown(position, button, modifiers);
|
|
|
|
}
|
|
|
|
|
2020-06-10 10:57:59 +02:00
|
|
|
bool Page::handle_mousemove(const Gfx::IntPoint& position, unsigned buttons, unsigned modifiers)
|
2020-06-08 20:31:49 +02:00
|
|
|
{
|
|
|
|
return main_frame().event_handler().handle_mousemove(position, buttons, modifiers);
|
|
|
|
}
|
|
|
|
|
2020-08-02 12:10:01 +02:00
|
|
|
bool Page::handle_keydown(KeyCode key, unsigned modifiers, u32 code_point)
|
|
|
|
{
|
2020-08-14 11:38:40 +02:00
|
|
|
return focused_frame().event_handler().handle_keydown(key, modifiers, code_point);
|
2020-08-02 12:10:01 +02:00
|
|
|
}
|
|
|
|
|
2020-06-08 20:31:49 +02:00
|
|
|
}
|