1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:27:35 +00:00

LibWeb: Rename Web::HtmlView => Web::PageView

This widget doesn't just view HTML, it views a web page. :^)
This commit is contained in:
Andreas Kling 2020-05-28 18:21:22 +02:00
parent 5f8cbe6a1b
commit 42243d2e06
24 changed files with 133 additions and 133 deletions

View file

@ -57,13 +57,12 @@ set(SOURCES
DOM/Node.cpp
DOM/ParentNode.cpp
DOM/Text.cpp
DOMTreeModel.cpp
DOM/Window.cpp
DOM/XMLHttpRequest.cpp
DOMTreeModel.cpp
Dump.cpp
FontCache.cpp
Frame.cpp
HtmlView.cpp
Layout/BoxModelMetrics.cpp
Layout/LayoutBlock.cpp
Layout/LayoutBox.cpp
@ -76,14 +75,15 @@ set(SOURCES
Layout/LayoutListItemMarker.cpp
Layout/LayoutNode.cpp
Layout/LayoutReplaced.cpp
Layout/LayoutTableCell.cpp
Layout/LayoutTable.cpp
Layout/LayoutTableCell.cpp
Layout/LayoutTableRow.cpp
Layout/LayoutText.cpp
Layout/LayoutTreeBuilder.cpp
Layout/LayoutWidget.cpp
Layout/LineBox.cpp
Layout/LineBoxFragment.cpp
PageView.cpp
Parser/CSSParser.cpp
Parser/Entities.cpp
Parser/HTMLDocumentParser.cpp

View file

@ -31,7 +31,7 @@
#include <LibWeb/CSS/StyleValue.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/Frame.h>
#include <LibWeb/HtmlView.h>
#include <LibWeb/PageView.h>
#include <LibWeb/ResourceLoader.h>
namespace Web {
@ -170,7 +170,7 @@ Color IdentifierStyleValue::to_color(const Document& document) const
if (id() == CSS::ValueID::VendorSpecificLink)
return document.link_color();
auto palette = document.frame()->html_view()->palette();
auto palette = document.frame()->page_view()->palette();
switch (id()) {
case CSS::ValueID::VendorSpecificPaletteDesktopBackground:
return palette.color(ColorRole::DesktopBackground);

View file

@ -51,7 +51,7 @@
#include <LibWeb/DOM/Window.h>
#include <LibWeb/Dump.h>
#include <LibWeb/Frame.h>
#include <LibWeb/HtmlView.h>
#include <LibWeb/PageView.h>
#include <LibWeb/Layout/LayoutDocument.h>
#include <LibWeb/Layout/LayoutTreeBuilder.h>
#include <LibWeb/Origin.h>
@ -368,7 +368,7 @@ Color Document::link_color() const
return m_link_color.value();
if (!frame())
return Color::Blue;
return frame()->html_view()->palette().link();
return frame()->page_view()->palette().link();
}
Color Document::active_link_color() const
@ -377,7 +377,7 @@ Color Document::active_link_color() const
return m_active_link_color.value();
if (!frame())
return Color::Red;
return frame()->html_view()->palette().active_link();
return frame()->page_view()->palette().active_link();
}
Color Document::visited_link_color() const
@ -386,7 +386,7 @@ Color Document::visited_link_color() const
return m_visited_link_color.value();
if (!frame())
return Color::Magenta;
return frame()->html_view()->palette().visited_link();
return frame()->page_view()->palette().visited_link();
}
JS::Interpreter& Document::interpreter()

View file

@ -28,7 +28,7 @@
#include <LibWeb/DOM/HTMLFormElement.h>
#include <LibWeb/DOM/HTMLInputElement.h>
#include <LibWeb/Frame.h>
#include <LibWeb/HtmlView.h>
#include <LibWeb/PageView.h>
#include <LibWeb/URLEncoder.h>
namespace Web {
@ -72,7 +72,7 @@ void HTMLFormElement::submit(RefPtr<HTMLInputElement> submitter)
url.set_query(url_encode(parameters));
// FIXME: We shouldn't let the form just do this willy-nilly.
document().frame()->html_view()->load(url);
document().frame()->page_view()->load(url);
}
}

View file

@ -31,7 +31,7 @@
#include <LibWeb/DOM/HTMLFormElement.h>
#include <LibWeb/DOM/HTMLInputElement.h>
#include <LibWeb/Frame.h>
#include <LibWeb/HtmlView.h>
#include <LibWeb/PageView.h>
#include <LibWeb/Layout/LayoutWidget.h>
namespace Web {
@ -49,15 +49,15 @@ RefPtr<LayoutNode> HTMLInputElement::create_layout_node(const StyleProperties*)
{
ASSERT(document().frame());
auto& frame = *document().frame();
ASSERT(frame.html_view());
auto& html_view = const_cast<HtmlView&>(*frame.html_view());
ASSERT(frame.page_view());
auto& page_view = const_cast<PageView&>(*frame.page_view());
if (type() == "hidden")
return nullptr;
RefPtr<GUI::Widget> widget;
if (type() == "submit") {
auto& button = html_view.add<GUI::Button>(value());
auto& button = page_view.add<GUI::Button>(value());
int text_width = Gfx::Font::default_font().width(value());
button.set_relative_rect(0, 0, text_width + 20, 20);
button.on_click = [this](auto) {
@ -68,7 +68,7 @@ RefPtr<LayoutNode> HTMLInputElement::create_layout_node(const StyleProperties*)
};
widget = button;
} else {
auto& text_box = html_view.add<GUI::TextBox>();
auto& text_box = page_view.add<GUI::TextBox>();
text_box.set_text(value());
text_box.on_change = [this] {
auto& widget = to<LayoutWidget>(layout_node())->widget();

View file

@ -33,7 +33,7 @@
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Window.h>
#include <LibWeb/Frame.h>
#include <LibWeb/HtmlView.h>
#include <LibWeb/PageView.h>
namespace Web {
@ -115,7 +115,7 @@ void Window::did_set_location_href(Badge<Bindings::LocationObject>, const String
auto* frame = document().frame();
if (!frame)
return;
auto* view = frame->html_view();
auto* view = frame->page_view();
if (!view)
return;
view->load(new_href);
@ -126,7 +126,7 @@ void Window::did_call_location_reload(Badge<Bindings::LocationObject>)
auto* frame = document().frame();
if (!frame)
return;
auto* view = frame->html_view();
auto* view = frame->page_view();
if (!view)
return;
view->reload();

View file

@ -44,7 +44,7 @@ class HTMLHeadElement;
class HTMLHtmlElement;
class HTMLImageElement;
class HTMLScriptElement;
class HtmlView;
class PageView;
class ImageData;
class LayoutDocument;
class LayoutNode;

View file

@ -26,13 +26,13 @@
#include <LibWeb/DOM/Document.h>
#include <LibWeb/Frame.h>
#include <LibWeb/HtmlView.h>
#include <LibWeb/PageView.h>
#include <LibWeb/Layout/LayoutDocument.h>
namespace Web {
Frame::Frame(HtmlView& html_view)
: m_html_view(html_view.make_weak_ptr())
Frame::Frame(PageView& page_view)
: m_page_view(page_view.make_weak_ptr())
{
}

View file

@ -37,11 +37,11 @@
namespace Web {
class Document;
class HtmlView;
class PageView;
class Frame : public TreeNode<Frame> {
public:
static NonnullRefPtr<Frame> create(HtmlView& html_view) { return adopt(*new Frame(html_view)); }
static NonnullRefPtr<Frame> create(PageView& page_view) { return adopt(*new Frame(page_view)); }
~Frame();
const Document* document() const { return m_document; }
@ -49,8 +49,8 @@ public:
void set_document(Document*);
HtmlView* html_view() { return m_html_view; }
const HtmlView* html_view() const { return m_html_view; }
PageView* page_view() { return m_page_view; }
const PageView* page_view() const { return m_page_view; }
const Gfx::Size& size() const { return m_size; }
void set_size(const Gfx::Size&);
@ -62,9 +62,9 @@ public:
Gfx::Rect viewport_rect() const { return m_viewport_rect; }
private:
explicit Frame(HtmlView&);
explicit Frame(PageView&);
WeakPtr<HtmlView> m_html_view;
WeakPtr<PageView> m_page_view;
RefPtr<Document> m_document;
Gfx::Size m_size;
Gfx::Rect m_viewport_rect;

View file

@ -44,7 +44,7 @@
#include <LibWeb/DOM/Text.h>
#include <LibWeb/Dump.h>
#include <LibWeb/Frame.h>
#include <LibWeb/HtmlView.h>
#include <LibWeb/PageView.h>
#include <LibWeb/Layout/LayoutDocument.h>
#include <LibWeb/Layout/LayoutNode.h>
#include <LibWeb/Parser/HTMLDocumentParser.h>
@ -57,7 +57,7 @@
namespace Web {
HtmlView::HtmlView()
PageView::PageView()
: m_main_frame(Web::Frame::create(*this))
{
main_frame().on_set_needs_display = [this](auto& content_rect) {
@ -74,11 +74,11 @@ HtmlView::HtmlView()
set_background_role(ColorRole::Base);
}
HtmlView::~HtmlView()
PageView::~PageView()
{
}
void HtmlView::set_document(Document* new_document)
void PageView::set_document(Document* new_document)
{
RefPtr<Document> old_document = document();
@ -111,7 +111,7 @@ void HtmlView::set_document(Document* new_document)
update();
}
void HtmlView::layout_and_sync_size()
void PageView::layout_and_sync_size()
{
if (!document())
return;
@ -139,13 +139,13 @@ void HtmlView::layout_and_sync_size()
#endif
}
void HtmlView::resize_event(GUI::ResizeEvent& event)
void PageView::resize_event(GUI::ResizeEvent& event)
{
GUI::ScrollableWidget::resize_event(event);
layout_and_sync_size();
}
void HtmlView::paint_event(GUI::PaintEvent& event)
void PageView::paint_event(GUI::PaintEvent& event)
{
GUI::Frame::paint_event(event);
@ -173,7 +173,7 @@ void HtmlView::paint_event(GUI::PaintEvent& event)
layout_root()->render(context);
}
void HtmlView::mousemove_event(GUI::MouseEvent& event)
void PageView::mousemove_event(GUI::MouseEvent& event)
{
if (!layout_root())
return GUI::ScrollableWidget::mousemove_event(event);
@ -191,7 +191,7 @@ void HtmlView::mousemove_event(GUI::MouseEvent& event)
hovered_link_element = node->enclosing_link_element();
if (hovered_link_element) {
#ifdef HTML_DEBUG
dbg() << "HtmlView: hovering over a link to " << hovered_link_element->href();
dbg() << "PageView: hovering over a link to " << hovered_link_element->href();
#endif
is_hovering_link = true;
}
@ -224,7 +224,7 @@ void HtmlView::mousemove_event(GUI::MouseEvent& event)
event.accept();
}
void HtmlView::mousedown_event(GUI::MouseEvent& event)
void PageView::mousedown_event(GUI::MouseEvent& event)
{
if (!layout_root())
return GUI::ScrollableWidget::mousemove_event(event);
@ -239,7 +239,7 @@ void HtmlView::mousedown_event(GUI::MouseEvent& event)
auto offset = compute_mouse_event_offset(event.position(), *result.layout_node);
node->dispatch_event(MouseEvent::create("mousedown", offset.x(), offset.y()));
if (RefPtr<HTMLAnchorElement> link = node->enclosing_link_element()) {
dbg() << "HtmlView: clicking on a link to " << link->href();
dbg() << "PageView: clicking on a link to " << link->href();
if (event.button() == GUI::MouseButton::Left) {
if (link->href().starts_with("javascript:")) {
@ -270,7 +270,7 @@ void HtmlView::mousedown_event(GUI::MouseEvent& event)
event.accept();
}
void HtmlView::mouseup_event(GUI::MouseEvent& event)
void PageView::mouseup_event(GUI::MouseEvent& event)
{
if (!layout_root())
return GUI::ScrollableWidget::mouseup_event(event);
@ -289,7 +289,7 @@ void HtmlView::mouseup_event(GUI::MouseEvent& event)
}
}
void HtmlView::keydown_event(GUI::KeyEvent& event)
void PageView::keydown_event(GUI::KeyEvent& event)
{
if (event.modifiers() == 0) {
switch (event.key()) {
@ -325,7 +325,7 @@ void HtmlView::keydown_event(GUI::KeyEvent& event)
event.accept();
}
void HtmlView::reload()
void PageView::reload()
{
load(main_frame().document()->url());
}
@ -432,7 +432,7 @@ static String guess_mime_type_based_on_filename(const URL& url)
return "text/plain";
}
RefPtr<Document> HtmlView::create_document_from_mime_type(const ByteBuffer& data, const URL& url, const String& mime_type, const String& encoding)
RefPtr<Document> PageView::create_document_from_mime_type(const ByteBuffer& data, const URL& url, const String& mime_type, const String& encoding)
{
if (mime_type.starts_with("image/"))
return create_image_document(data, url);
@ -453,9 +453,9 @@ RefPtr<Document> HtmlView::create_document_from_mime_type(const ByteBuffer& data
return nullptr;
}
void HtmlView::load(const URL& url)
void PageView::load(const URL& url)
{
dbg() << "HtmlView::load: " << url;
dbg() << "PageView::load: " << url;
if (!url.is_valid()) {
load_error_page(url, "Invalid URL");
@ -537,7 +537,7 @@ void HtmlView::load(const URL& url)
this->scroll_to_top();
}
void HtmlView::load_error_page(const URL& failed_url, const String& error)
void PageView::load_error_page(const URL& failed_url, const String& error)
{
auto error_page_url = "file:///res/html/error.html";
ResourceLoader::the().load(
@ -560,19 +560,19 @@ void HtmlView::load_error_page(const URL& failed_url, const String& error)
});
}
const LayoutDocument* HtmlView::layout_root() const
const LayoutDocument* PageView::layout_root() const
{
return document() ? document()->layout_node() : nullptr;
}
LayoutDocument* HtmlView::layout_root()
LayoutDocument* PageView::layout_root()
{
if (!document())
return nullptr;
return const_cast<LayoutDocument*>(document()->layout_node());
}
void HtmlView::scroll_to_anchor(const StringView& name)
void PageView::scroll_to_anchor(const StringView& name)
{
if (!document())
return;
@ -589,11 +589,11 @@ void HtmlView::scroll_to_anchor(const StringView& name)
}
if (!element) {
dbg() << "HtmlView::scroll_to_anchor(): Anchor not found: '" << name << "'";
dbg() << "PageView::scroll_to_anchor(): Anchor not found: '" << name << "'";
return;
}
if (!element->layout_node()) {
dbg() << "HtmlView::scroll_to_anchor(): Anchor found but without layout node: '" << name << "'";
dbg() << "PageView::scroll_to_anchor(): Anchor found but without layout node: '" << name << "'";
return;
}
auto& layout_node = *element->layout_node();
@ -602,17 +602,17 @@ void HtmlView::scroll_to_anchor(const StringView& name)
window()->set_override_cursor(GUI::StandardCursor::None);
}
Document* HtmlView::document()
Document* PageView::document()
{
return main_frame().document();
}
const Document* HtmlView::document() const
const Document* PageView::document() const
{
return main_frame().document();
}
void HtmlView::dump_selection(const char* event_name)
void PageView::dump_selection(const char* event_name)
{
UNUSED_PARAM(event_name);
#ifdef SELECTION_DEBUG
@ -622,12 +622,12 @@ void HtmlView::dump_selection(const char* event_name)
#endif
}
void HtmlView::did_scroll()
void PageView::did_scroll()
{
main_frame().set_viewport_rect(viewport_rect_in_content_coordinates());
}
Gfx::Point HtmlView::compute_mouse_event_offset(const Gfx::Point& event_position, const LayoutNode& layout_node) const
Gfx::Point PageView::compute_mouse_event_offset(const Gfx::Point& event_position, const LayoutNode& layout_node) const
{
auto content_event_position = to_content_position(event_position);
auto top_left_of_layout_node = layout_node.box_type_agnostic_position();
@ -638,7 +638,7 @@ Gfx::Point HtmlView::compute_mouse_event_offset(const Gfx::Point& event_position
};
}
void HtmlView::run_javascript_url(const String& url)
void PageView::run_javascript_url(const String& url)
{
ASSERT(url.starts_with("javascript:"));
if (!document())
@ -649,7 +649,7 @@ void HtmlView::run_javascript_url(const String& url)
document()->run_javascript(source);
}
void HtmlView::drop_event(GUI::DropEvent& event)
void PageView::drop_event(GUI::DropEvent& event)
{
if (event.mime_data().has_urls()) {
if (on_url_drop) {

View file

@ -33,10 +33,10 @@ namespace Web {
class Frame;
class HtmlView : public GUI::ScrollableWidget {
C_OBJECT(HtmlView)
class PageView : public GUI::ScrollableWidget {
C_OBJECT(PageView)
public:
virtual ~HtmlView() override;
virtual ~PageView() override;
// 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; }
@ -73,7 +73,7 @@ public:
virtual bool accepts_focus() const override { return true; }
protected:
HtmlView();
PageView();
virtual void resize_event(GUI::ResizeEvent&) override;
virtual void paint_event(GUI::PaintEvent&) override;