2019-09-25 12:44:22 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
2019-10-05 10:16:27 +02:00
|
|
|
#include <AK/URL.h>
|
2019-09-25 12:44:22 +03:00
|
|
|
#include <LibGUI/GScrollableWidget.h>
|
|
|
|
|
#include <LibHTML/DOM/Document.h>
|
|
|
|
|
|
2019-10-04 15:50:04 +02:00
|
|
|
class Frame;
|
|
|
|
|
|
2019-09-25 12:44:22 +03:00
|
|
|
class HtmlView : public GScrollableWidget {
|
|
|
|
|
C_OBJECT(HtmlView)
|
|
|
|
|
public:
|
2019-10-04 15:50:04 +02:00
|
|
|
virtual ~HtmlView() override;
|
2019-09-25 12:44:22 +03:00
|
|
|
|
|
|
|
|
Document* document() { return m_document; }
|
|
|
|
|
const Document* document() const { return m_document; }
|
|
|
|
|
void set_document(Document*);
|
|
|
|
|
|
2019-10-13 12:34:25 +02:00
|
|
|
const LayoutDocument* layout_root() const;
|
|
|
|
|
LayoutDocument* layout_root();
|
|
|
|
|
|
2019-10-04 15:50:04 +02:00
|
|
|
Frame& main_frame() { return *m_main_frame; }
|
|
|
|
|
const Frame& main_frame() const { return *m_main_frame; }
|
|
|
|
|
|
2019-10-05 10:16:27 +02:00
|
|
|
void reload();
|
|
|
|
|
void load(const URL&);
|
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; }
|
|
|
|
|
|
2019-09-29 12:04:02 +02:00
|
|
|
Function<void(const String&)> on_link_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;
|
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:
|
|
|
|
|
HtmlView(GWidget* parent = nullptr);
|
|
|
|
|
|
|
|
|
|
virtual void resize_event(GResizeEvent&) override;
|
|
|
|
|
virtual void paint_event(GPaintEvent&) override;
|
2019-09-28 23:02:22 +02:00
|
|
|
virtual void mousemove_event(GMouseEvent&) override;
|
2019-09-29 12:04:02 +02:00
|
|
|
virtual void mousedown_event(GMouseEvent&) override;
|
2019-10-17 21:36:22 +02:00
|
|
|
virtual void keydown_event(GKeyEvent&) override;
|
2019-09-25 12:44:22 +03:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void layout_and_sync_size();
|
|
|
|
|
|
2019-10-04 15:50:04 +02:00
|
|
|
RefPtr<Frame> m_main_frame;
|
2019-09-25 12:44:22 +03:00
|
|
|
RefPtr<Document> m_document;
|
2019-10-12 15:02:53 +02:00
|
|
|
|
|
|
|
|
bool m_should_show_line_box_borders { false };
|
2019-09-25 12:44:22 +03:00
|
|
|
};
|