mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 00:32:45 +00:00 
			
		
		
		
	 92392398a2
			
		
	
	
		92392398a2
		
	
	
	
	
		
			
			* A PageView is a view onto a Page object. * A Page always has a main Frame (root of Frame tree.) * Page has a PageClient. PageView is a PageClient. The goal here is to allow building another kind of view onto a Page while keeping the rest of LibWeb intact.
		
			
				
	
	
		
			78 lines
		
	
	
	
		
			2.6 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			78 lines
		
	
	
	
		
			2.6 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * 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.
 | |
|  */
 | |
| 
 | |
| #include <LibWeb/Frame/Frame.h>
 | |
| #include <LibWeb/Page.h>
 | |
| #include <LibWeb/PageView.h>
 | |
| 
 | |
| namespace Web {
 | |
| 
 | |
| Page::Page(PageClient& client)
 | |
|     : m_client(client)
 | |
| {
 | |
|     m_main_frame = Frame::create(*this);
 | |
| 
 | |
|     main_frame().on_set_document = [this](auto* document) {
 | |
|         m_client.page_did_set_document_in_main_frame(document);
 | |
|     };
 | |
|     main_frame().on_title_change = [this](auto& title) {
 | |
|         m_client.page_did_change_title(title);
 | |
|     };
 | |
|     main_frame().on_load_start = [this](auto& url) {
 | |
|         m_client.page_did_start_loading(url);
 | |
|     };
 | |
| }
 | |
| 
 | |
| Page::~Page()
 | |
| {
 | |
| }
 | |
| 
 | |
| void Page::load(const URL& url)
 | |
| {
 | |
|     main_frame().loader().load(url);
 | |
| }
 | |
| 
 | |
| Gfx::Palette Page::palette() const
 | |
| {
 | |
|     return static_cast<const PageView&>(m_client).palette();
 | |
| }
 | |
| 
 | |
| bool Page::handle_mouseup(const Gfx::Point& position, unsigned button, unsigned modifiers)
 | |
| {
 | |
|     return main_frame().event_handler().handle_mouseup(position, button, modifiers);
 | |
| }
 | |
| 
 | |
| bool Page::handle_mousedown(const Gfx::Point& position, unsigned button, unsigned modifiers)
 | |
| {
 | |
|     return main_frame().event_handler().handle_mousedown(position, button, modifiers);
 | |
| }
 | |
| 
 | |
| bool Page::handle_mousemove(const Gfx::Point& position, unsigned buttons, unsigned modifiers)
 | |
| {
 | |
|     return main_frame().event_handler().handle_mousemove(position, buttons, modifiers);
 | |
| }
 | |
| 
 | |
| }
 |