| 
									
										
										
										
											2020-01-18 09:38:21 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2018-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. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2019-09-25 12:44:22 +03:00
										 |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-05 10:16:27 +02:00
										 |  |  | #include <AK/URL.h>
 | 
					
						
							| 
									
										
										
										
											2020-02-06 20:33:02 +01:00
										 |  |  | #include <LibGUI/ScrollableWidget.h>
 | 
					
						
							| 
									
										
										
										
											2020-03-07 10:32:51 +01:00
										 |  |  | #include <LibWeb/DOM/Document.h>
 | 
					
						
							| 
									
										
										
										
											2019-09-25 12:44:22 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-07 10:27:02 +01:00
										 |  |  | namespace Web { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-04 15:50:04 +02:00
										 |  |  | class Frame; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-02 15:07:41 +01:00
										 |  |  | class HtmlView : public GUI::ScrollableWidget { | 
					
						
							| 
									
										
										
										
											2019-09-25 12:44:22 +03:00
										 |  |  |     C_OBJECT(HtmlView) | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2019-10-04 15:50:04 +02:00
										 |  |  |     virtual ~HtmlView() override; | 
					
						
							| 
									
										
										
										
											2019-09-25 12:44:22 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-27 21:57:30 +02:00
										 |  |  |     // FIXME: Remove this once the new parser is ready.
 | 
					
						
							|  |  |  |     void set_use_new_parser(bool use_new_parser) { m_use_new_parser = use_new_parser; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-20 10:36:14 +02:00
										 |  |  |     Document* document(); | 
					
						
							|  |  |  |     const Document* document() const; | 
					
						
							| 
									
										
										
										
											2019-09-25 12:44:22 +03:00
										 |  |  |     void set_document(Document*); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-13 12:34:25 +02:00
										 |  |  |     const LayoutDocument* layout_root() const; | 
					
						
							|  |  |  |     LayoutDocument* layout_root(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-07 10:27:02 +01:00
										 |  |  |     Web::Frame& main_frame() { return *m_main_frame; } | 
					
						
							|  |  |  |     const Web::Frame& main_frame() const { return *m_main_frame; } | 
					
						
							| 
									
										
										
										
											2019-10-04 15:50:04 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-05 10:16:27 +02:00
										 |  |  |     void reload(); | 
					
						
							|  |  |  |     void load(const URL&); | 
					
						
							| 
									
										
										
										
											2020-03-31 23:59:11 +01:00
										 |  |  |     void load_error_page(const URL&, const String& error); | 
					
						
							| 
									
										
										
										
											2019-10-20 09:14:12 +02:00
										 |  |  |     void scroll_to_anchor(const StringView&); | 
					
						
							| 
									
										
										
										
											2019-10-05 10:16:27 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     URL url() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-12 15:02:53 +02:00
										 |  |  |     void set_should_show_line_box_borders(bool value) { m_should_show_line_box_borders = value; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-24 14:43:56 +02:00
										 |  |  |     Function<void(const String& href, const String& target, unsigned modifiers)> on_link_click; | 
					
						
							| 
									
										
										
										
											2020-05-05 22:42:21 +02:00
										 |  |  |     Function<void(const String& href, const Gfx::Point& screen_position)> on_link_context_menu_request; | 
					
						
							| 
									
										
										
										
											2020-05-06 15:33:01 -04:00
										 |  |  |     Function<void(const String& href)> on_link_middle_click; | 
					
						
							| 
									
										
										
										
											2019-10-19 21:21:29 +02:00
										 |  |  |     Function<void(const String&)> on_link_hover; | 
					
						
							| 
									
										
										
										
											2019-09-29 16:24:57 +02:00
										 |  |  |     Function<void(const String&)> on_title_change; | 
					
						
							| 
									
										
										
										
											2019-10-05 10:16:27 +02:00
										 |  |  |     Function<void(const URL&)> on_load_start; | 
					
						
							| 
									
										
										
										
											2020-04-24 22:26:53 +02:00
										 |  |  |     Function<void(const Gfx::Bitmap&)> on_favicon_change; | 
					
						
							| 
									
										
										
										
											2020-05-10 21:03:37 +02:00
										 |  |  |     Function<void(const URL&)> on_url_drop; | 
					
						
							| 
									
										
										
										
											2020-05-23 13:03:13 -04:00
										 |  |  |     Function<void(Document*)> on_set_document; | 
					
						
							| 
									
										
										
										
											2019-09-29 12:04:02 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-17 21:36:22 +02:00
										 |  |  |     virtual bool accepts_focus() const override { return true; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-25 12:44:22 +03:00
										 |  |  | protected: | 
					
						
							| 
									
										
										
										
											2020-02-23 10:57:42 +01:00
										 |  |  |     HtmlView(); | 
					
						
							| 
									
										
										
										
											2019-09-25 12:44:22 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-02 15:07:41 +01:00
										 |  |  |     virtual void resize_event(GUI::ResizeEvent&) override; | 
					
						
							|  |  |  |     virtual void paint_event(GUI::PaintEvent&) override; | 
					
						
							|  |  |  |     virtual void mousemove_event(GUI::MouseEvent&) override; | 
					
						
							|  |  |  |     virtual void mousedown_event(GUI::MouseEvent&) override; | 
					
						
							|  |  |  |     virtual void mouseup_event(GUI::MouseEvent&) override; | 
					
						
							|  |  |  |     virtual void keydown_event(GUI::KeyEvent&) override; | 
					
						
							| 
									
										
										
										
											2020-05-10 21:03:37 +02:00
										 |  |  |     virtual void drop_event(GUI::DropEvent&) override; | 
					
						
							| 
									
										
										
										
											2019-09-25 12:44:22 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2019-12-18 20:54:23 +01:00
										 |  |  |     virtual void did_scroll() override; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-27 21:57:30 +02:00
										 |  |  |     RefPtr<Document> create_document_from_mime_type(const ByteBuffer& data, const URL& url, const String& mime_type, const String& encoding); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-04 22:12:37 +02:00
										 |  |  |     void run_javascript_url(const String& url); | 
					
						
							| 
									
										
										
										
											2019-09-25 12:44:22 +03:00
										 |  |  |     void layout_and_sync_size(); | 
					
						
							| 
									
										
										
										
											2019-11-05 22:13:26 +01:00
										 |  |  |     void dump_selection(const char* event_name); | 
					
						
							| 
									
										
										
										
											2020-03-21 18:27:06 +01:00
										 |  |  |     Gfx::Point compute_mouse_event_offset(const Gfx::Point&, const LayoutNode&) const; | 
					
						
							| 
									
										
										
										
											2019-09-25 12:44:22 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-07 10:27:02 +01:00
										 |  |  |     RefPtr<Web::Frame> m_main_frame; | 
					
						
							| 
									
										
										
										
											2019-10-12 15:02:53 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     bool m_should_show_line_box_borders { false }; | 
					
						
							| 
									
										
										
										
											2019-11-05 22:13:26 +01:00
										 |  |  |     bool m_in_mouse_selection { false }; | 
					
						
							| 
									
										
										
										
											2020-05-27 21:57:30 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     bool m_use_new_parser { false }; | 
					
						
							| 
									
										
										
										
											2019-09-25 12:44:22 +03:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2020-03-07 10:27:02 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | } |