2020-06-08 20:31:49 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
|
|
* list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
}
|