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

LibWeb: Rename Web::Frame to Web::BrowsingContext

Our "frame" concept very closely matches what the web specs call a
"browsing context", so let's rename it to that. :^)

The "main frame" becomes the "top-level browsing context",
and "sub-frames" are now "nested browsing contexts".
This commit is contained in:
Andreas Kling 2021-05-30 12:36:53 +02:00
parent 8be98af77c
commit 4190fd2199
43 changed files with 241 additions and 241 deletions

View file

@ -50,7 +50,7 @@
#include <LibWeb/Layout/TreeBuilder.h>
#include <LibWeb/Namespace.h>
#include <LibWeb/Origin.h>
#include <LibWeb/Page/Frame.h>
#include <LibWeb/Page/BrowsingContext.h>
#include <LibWeb/SVG/TagNames.h>
#include <LibWeb/UIEvents/MouseEvent.h>
#include <ctype.h>
@ -281,22 +281,22 @@ void Document::set_title(const String& title)
title_element->append_child(adopt_ref(*new Text(*this, title)));
if (auto* page = this->page()) {
if (frame() == &page->main_frame())
if (browsing_context() == &page->top_level_browsing_context())
page->client().page_did_change_title(title);
}
}
void Document::attach_to_frame(Badge<Frame>, Frame& frame)
void Document::attach_to_browsing_context(Badge<BrowsingContext>, BrowsingContext& browsing_context)
{
m_frame = frame;
m_browsing_context = browsing_context;
update_layout();
}
void Document::detach_from_frame(Badge<Frame>, Frame& frame)
void Document::detach_from_browsing_context(Badge<BrowsingContext>, BrowsingContext& browsing_context)
{
VERIFY(&frame == m_frame);
VERIFY(&browsing_context == m_browsing_context);
tear_down_layout_tree();
m_frame = nullptr;
m_browsing_context = nullptr;
}
void Document::tear_down_layout_tree()
@ -399,7 +399,7 @@ void Document::force_layout()
void Document::update_layout()
{
if (!frame())
if (!browsing_context())
return;
if (!m_layout_root) {
@ -412,7 +412,7 @@ void Document::update_layout()
m_layout_root->set_needs_display();
if (frame()->is_main_frame()) {
if (browsing_context()->is_top_level()) {
if (auto* page = this->page())
page->client().page_did_layout();
}
@ -881,12 +881,12 @@ void Document::set_ready_state(const String& ready_state)
Page* Document::page()
{
return m_frame ? m_frame->page() : nullptr;
return m_browsing_context ? m_browsing_context->page() : nullptr;
}
const Page* Document::page() const
{
return m_frame ? m_frame->page() : nullptr;
return m_browsing_context ? m_browsing_context->page() : nullptr;
}
EventTarget* Document::get_parent(const Event& event)

View file

@ -115,11 +115,11 @@ public:
String title() const;
void set_title(const String&);
void attach_to_frame(Badge<Frame>, Frame&);
void detach_from_frame(Badge<Frame>, Frame&);
void attach_to_browsing_context(Badge<BrowsingContext>, BrowsingContext&);
void detach_from_browsing_context(Badge<BrowsingContext>, BrowsingContext&);
Frame* frame() { return m_frame.ptr(); }
const Frame* frame() const { return m_frame.ptr(); }
BrowsingContext* browsing_context() { return m_browsing_context.ptr(); }
const BrowsingContext* browsing_context() const { return m_browsing_context.ptr(); }
Page* page();
const Page* page() const;
@ -297,7 +297,7 @@ private:
RefPtr<CSS::StyleSheetList> m_style_sheets;
RefPtr<Node> m_hovered_node;
RefPtr<Node> m_inspected_node;
WeakPtr<Frame> m_frame;
WeakPtr<BrowsingContext> m_browsing_context;
URL m_url;
RefPtr<Window> m_window;

View file

@ -14,7 +14,7 @@
#include <LibWeb/HighResolutionTime/Performance.h>
#include <LibWeb/InProcessWebView.h>
#include <LibWeb/Layout/InitialContainingBlockBox.h>
#include <LibWeb/Page/Frame.h>
#include <LibWeb/Page/BrowsingContext.h>
namespace Web::DOM {
@ -139,7 +139,7 @@ void Window::cancel_animation_frame(i32 id)
void Window::did_set_location_href(Badge<Bindings::LocationObject>, const URL& new_href)
{
auto* frame = document().frame();
auto* frame = document().browsing_context();
if (!frame)
return;
frame->loader().load(new_href, FrameLoader::Type::Navigation);
@ -147,7 +147,7 @@ void Window::did_set_location_href(Badge<Bindings::LocationObject>, const URL& n
void Window::did_call_location_reload(Badge<Bindings::LocationObject>)
{
auto* frame = document().frame();
auto* frame = document().browsing_context();
if (!frame)
return;
frame->loader().load(document().url(), FrameLoader::Type::Reload);