mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 17: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:
parent
8be98af77c
commit
4190fd2199
43 changed files with 241 additions and 241 deletions
|
@ -13,7 +13,7 @@
|
|||
#include <LibWeb/Layout/InlineFormattingContext.h>
|
||||
#include <LibWeb/Layout/ListItemBox.h>
|
||||
#include <LibWeb/Layout/ReplacedBox.h>
|
||||
#include <LibWeb/Page/Frame.h>
|
||||
#include <LibWeb/Page/BrowsingContext.h>
|
||||
|
||||
namespace Web::Layout {
|
||||
|
||||
|
@ -516,7 +516,7 @@ void BlockFormattingContext::place_block_level_non_replaced_element_in_normal_fl
|
|||
|
||||
void BlockFormattingContext::layout_initial_containing_block(LayoutMode layout_mode)
|
||||
{
|
||||
auto viewport_rect = context_box().frame().viewport_rect();
|
||||
auto viewport_rect = context_box().browsing_context().viewport_rect();
|
||||
|
||||
auto& icb = downcast<Layout::InitialContainingBlockBox>(context_box());
|
||||
icb.build_stacking_context_tree();
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <LibWeb/HTML/HTMLHtmlElement.h>
|
||||
#include <LibWeb/Layout/BlockBox.h>
|
||||
#include <LibWeb/Layout/Box.h>
|
||||
#include <LibWeb/Page/Frame.h>
|
||||
#include <LibWeb/Page/BrowsingContext.h>
|
||||
#include <LibWeb/Painting/BorderPainting.h>
|
||||
|
||||
namespace Web::Layout {
|
||||
|
@ -293,7 +293,7 @@ HitTestResult Box::hit_test(const Gfx::IntPoint& position, HitTestType type) con
|
|||
void Box::set_needs_display()
|
||||
{
|
||||
if (!is_inline()) {
|
||||
frame().set_needs_display(enclosing_int_rect(absolute_rect()));
|
||||
browsing_context().set_needs_display(enclosing_int_rect(absolute_rect()));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/Layout/ButtonBox.h>
|
||||
#include <LibWeb/Layout/Label.h>
|
||||
#include <LibWeb/Page/Frame.h>
|
||||
#include <LibWeb/Page/BrowsingContext.h>
|
||||
|
||||
namespace Web::Layout {
|
||||
|
||||
|
@ -63,7 +63,7 @@ void ButtonBox::handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint&, unsi
|
|||
set_needs_display();
|
||||
|
||||
m_tracking_mouse = true;
|
||||
frame().event_handler().set_mouse_event_tracking_layout_node(this);
|
||||
browsing_context().event_handler().set_mouse_event_tracking_layout_node(this);
|
||||
}
|
||||
|
||||
void ButtonBox::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned button, unsigned)
|
||||
|
@ -73,7 +73,7 @@ void ButtonBox::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& positio
|
|||
|
||||
// NOTE: Handling the click may run arbitrary JS, which could disappear this node.
|
||||
NonnullRefPtr protected_this = *this;
|
||||
NonnullRefPtr protected_frame = frame();
|
||||
NonnullRefPtr protected_frame = browsing_context();
|
||||
|
||||
bool is_inside_node_or_label = enclosing_int_rect(absolute_rect()).contains(position);
|
||||
if (!is_inside_node_or_label)
|
||||
|
@ -114,7 +114,7 @@ void ButtonBox::handle_associated_label_mouseup(Badge<Label>)
|
|||
{
|
||||
// NOTE: Handling the click may run arbitrary JS, which could disappear this node.
|
||||
NonnullRefPtr protected_this = *this;
|
||||
NonnullRefPtr protected_frame = frame();
|
||||
NonnullRefPtr protected_frame = browsing_context();
|
||||
|
||||
dom_node().did_click_button({});
|
||||
m_being_pressed = false;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <LibGfx/StylePainter.h>
|
||||
#include <LibWeb/Layout/CheckBox.h>
|
||||
#include <LibWeb/Layout/Label.h>
|
||||
#include <LibWeb/Page/Frame.h>
|
||||
#include <LibWeb/Page/BrowsingContext.h>
|
||||
|
||||
namespace Web::Layout {
|
||||
|
||||
|
@ -48,7 +48,7 @@ void CheckBox::handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint&, unsig
|
|||
set_needs_display();
|
||||
|
||||
m_tracking_mouse = true;
|
||||
frame().event_handler().set_mouse_event_tracking_layout_node(this);
|
||||
browsing_context().event_handler().set_mouse_event_tracking_layout_node(this);
|
||||
}
|
||||
|
||||
void CheckBox::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned button, unsigned)
|
||||
|
@ -68,7 +68,7 @@ void CheckBox::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& position
|
|||
|
||||
m_being_pressed = false;
|
||||
m_tracking_mouse = false;
|
||||
frame().event_handler().set_mouse_event_tracking_layout_node(nullptr);
|
||||
browsing_context().event_handler().set_mouse_event_tracking_layout_node(nullptr);
|
||||
}
|
||||
|
||||
void CheckBox::handle_mousemove(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned, unsigned)
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <LibWeb/InProcessWebView.h>
|
||||
#include <LibWeb/Layout/FrameBox.h>
|
||||
#include <LibWeb/Layout/InitialContainingBlockBox.h>
|
||||
#include <LibWeb/Page/Frame.h>
|
||||
#include <LibWeb/Page/BrowsingContext.h>
|
||||
|
||||
namespace Web::Layout {
|
||||
|
||||
|
@ -25,7 +25,7 @@ FrameBox::~FrameBox()
|
|||
|
||||
void FrameBox::prepare_for_replaced_layout()
|
||||
{
|
||||
VERIFY(dom_node().content_frame());
|
||||
VERIFY(dom_node().nested_browsing_context());
|
||||
|
||||
set_has_intrinsic_width(true);
|
||||
set_has_intrinsic_height(true);
|
||||
|
@ -52,14 +52,14 @@ void FrameBox::paint(PaintContext& context, PaintPhase phase)
|
|||
context.painter().add_clip_rect(enclosing_int_rect(absolute_rect()));
|
||||
context.painter().translate(absolute_x(), absolute_y());
|
||||
|
||||
context.set_viewport_rect({ {}, dom_node().content_frame()->size() });
|
||||
context.set_viewport_rect({ {}, dom_node().nested_browsing_context()->size() });
|
||||
const_cast<Layout::InitialContainingBlockBox*>(hosted_layout_tree)->paint_all_phases(context);
|
||||
|
||||
context.set_viewport_rect(old_viewport_rect);
|
||||
context.painter().restore();
|
||||
|
||||
if constexpr (HIGHLIGHT_FOCUSED_FRAME_DEBUG) {
|
||||
if (dom_node().content_frame()->is_focused_frame()) {
|
||||
if (dom_node().nested_browsing_context()->is_focused_context()) {
|
||||
context.painter().draw_rect(absolute_rect().to_type<int>(), Color::Cyan);
|
||||
}
|
||||
}
|
||||
|
@ -70,8 +70,8 @@ void FrameBox::did_set_rect()
|
|||
{
|
||||
ReplacedBox::did_set_rect();
|
||||
|
||||
VERIFY(dom_node().content_frame());
|
||||
dom_node().content_frame()->set_size(size().to_type<int>());
|
||||
VERIFY(dom_node().nested_browsing_context());
|
||||
dom_node().nested_browsing_context()->set_size(size().to_type<int>());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <LibGfx/Painter.h>
|
||||
#include <LibGfx/StylePainter.h>
|
||||
#include <LibWeb/Layout/ImageBox.h>
|
||||
#include <LibWeb/Page/Frame.h>
|
||||
#include <LibWeb/Page/BrowsingContext.h>
|
||||
|
||||
namespace Web::Layout {
|
||||
|
||||
|
@ -16,12 +16,12 @@ ImageBox::ImageBox(DOM::Document& document, DOM::Element& element, NonnullRefPtr
|
|||
: ReplacedBox(document, element, move(style))
|
||||
, m_image_loader(image_loader)
|
||||
{
|
||||
frame().register_viewport_client(*this);
|
||||
browsing_context().register_viewport_client(*this);
|
||||
}
|
||||
|
||||
ImageBox::~ImageBox()
|
||||
{
|
||||
frame().unregister_viewport_client(*this);
|
||||
browsing_context().unregister_viewport_client(*this);
|
||||
}
|
||||
|
||||
int ImageBox::preferred_width() const
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
|
||||
#include <LibWeb/HTML/HTMLImageElement.h>
|
||||
#include <LibWeb/Layout/ReplacedBox.h>
|
||||
#include <LibWeb/Page/Frame.h>
|
||||
#include <LibWeb/Page/BrowsingContext.h>
|
||||
|
||||
namespace Web::Layout {
|
||||
|
||||
class ImageBox
|
||||
: public ReplacedBox
|
||||
, public Frame::ViewportClient {
|
||||
, public BrowsingContext::ViewportClient {
|
||||
public:
|
||||
ImageBox(DOM::Document&, DOM::Element&, NonnullRefPtr<CSS::StyleProperties>, const ImageLoader&);
|
||||
virtual ~ImageBox() override;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <LibGfx/Painter.h>
|
||||
#include <LibWeb/Dump.h>
|
||||
#include <LibWeb/Layout/InitialContainingBlockBox.h>
|
||||
#include <LibWeb/Page/Frame.h>
|
||||
#include <LibWeb/Page/BrowsingContext.h>
|
||||
#include <LibWeb/Painting/StackingContext.h>
|
||||
|
||||
namespace Web::Layout {
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <LibWeb/Layout/Label.h>
|
||||
#include <LibWeb/Layout/LabelableNode.h>
|
||||
#include <LibWeb/Layout/TextNode.h>
|
||||
#include <LibWeb/Page/Frame.h>
|
||||
#include <LibWeb/Page/BrowsingContext.h>
|
||||
|
||||
namespace Web::Layout {
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include <LibWeb/Layout/InitialContainingBlockBox.h>
|
||||
#include <LibWeb/Layout/Node.h>
|
||||
#include <LibWeb/Layout/TextNode.h>
|
||||
#include <LibWeb/Page/Frame.h>
|
||||
#include <LibWeb/Page/BrowsingContext.h>
|
||||
|
||||
namespace Web::Layout {
|
||||
|
||||
|
@ -104,16 +104,16 @@ HitTestResult Node::hit_test(const Gfx::IntPoint& position, HitTestType type) co
|
|||
return result;
|
||||
}
|
||||
|
||||
const Frame& Node::frame() const
|
||||
const BrowsingContext& Node::browsing_context() const
|
||||
{
|
||||
VERIFY(document().frame());
|
||||
return *document().frame();
|
||||
VERIFY(document().browsing_context());
|
||||
return *document().browsing_context();
|
||||
}
|
||||
|
||||
Frame& Node::frame()
|
||||
BrowsingContext& Node::browsing_context()
|
||||
{
|
||||
VERIFY(document().frame());
|
||||
return *document().frame();
|
||||
VERIFY(document().browsing_context());
|
||||
return *document().browsing_context();
|
||||
}
|
||||
|
||||
const InitialContainingBlockBox& Node::root() const
|
||||
|
@ -140,7 +140,7 @@ void Node::set_needs_display()
|
|||
if (auto* block = containing_block()) {
|
||||
block->for_each_fragment([&](auto& fragment) {
|
||||
if (&fragment.layout_node() == this || is_ancestor_of(fragment.layout_node())) {
|
||||
frame().set_needs_display(enclosing_int_rect(fragment.absolute_rect()));
|
||||
browsing_context().set_needs_display(enclosing_int_rect(fragment.absolute_rect()));
|
||||
}
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
|
|
@ -65,8 +65,8 @@ public:
|
|||
DOM::Document& document() { return m_document; }
|
||||
const DOM::Document& document() const { return m_document; }
|
||||
|
||||
const Frame& frame() const;
|
||||
Frame& frame();
|
||||
const BrowsingContext& browsing_context() const;
|
||||
BrowsingContext& browsing_context();
|
||||
|
||||
const InitialContainingBlockBox& root() const;
|
||||
InitialContainingBlockBox& root();
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/Layout/Label.h>
|
||||
#include <LibWeb/Layout/RadioButton.h>
|
||||
#include <LibWeb/Page/Frame.h>
|
||||
#include <LibWeb/Page/BrowsingContext.h>
|
||||
|
||||
namespace Web::Layout {
|
||||
|
||||
|
@ -48,7 +48,7 @@ void RadioButton::handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint&, un
|
|||
set_needs_display();
|
||||
|
||||
m_tracking_mouse = true;
|
||||
frame().event_handler().set_mouse_event_tracking_layout_node(this);
|
||||
browsing_context().event_handler().set_mouse_event_tracking_layout_node(this);
|
||||
}
|
||||
|
||||
void RadioButton::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned button, unsigned)
|
||||
|
@ -68,7 +68,7 @@ void RadioButton::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& posit
|
|||
|
||||
m_being_pressed = false;
|
||||
m_tracking_mouse = false;
|
||||
frame().event_handler().set_mouse_event_tracking_layout_node(nullptr);
|
||||
browsing_context().event_handler().set_mouse_event_tracking_layout_node(nullptr);
|
||||
}
|
||||
|
||||
void RadioButton::handle_mousemove(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned, unsigned)
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <LibWeb/Layout/TableFormattingContext.h>
|
||||
#include <LibWeb/Layout/TableRowBox.h>
|
||||
#include <LibWeb/Layout/TableRowGroupBox.h>
|
||||
#include <LibWeb/Page/Frame.h>
|
||||
#include <LibWeb/Page/BrowsingContext.h>
|
||||
|
||||
namespace Web::Layout {
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <LibWeb/Layout/InlineFormattingContext.h>
|
||||
#include <LibWeb/Layout/Label.h>
|
||||
#include <LibWeb/Layout/TextNode.h>
|
||||
#include <LibWeb/Page/Frame.h>
|
||||
#include <LibWeb/Page/BrowsingContext.h>
|
||||
#include <ctype.h>
|
||||
|
||||
namespace Web::Layout {
|
||||
|
@ -77,17 +77,17 @@ void TextNode::paint_fragment(PaintContext& context, const LineBoxFragment& frag
|
|||
|
||||
void TextNode::paint_cursor_if_needed(PaintContext& context, const LineBoxFragment& fragment) const
|
||||
{
|
||||
if (!frame().is_focused_frame())
|
||||
if (!browsing_context().is_focused_context())
|
||||
return;
|
||||
|
||||
if (!frame().cursor_blink_state())
|
||||
if (!browsing_context().cursor_blink_state())
|
||||
return;
|
||||
|
||||
if (frame().cursor_position().node() != &dom_node())
|
||||
if (browsing_context().cursor_position().node() != &dom_node())
|
||||
return;
|
||||
|
||||
// NOTE: This checks if the cursor is before the start or after the end of the fragment. If it is at the end, after all text, it should still be painted.
|
||||
if (frame().cursor_position().offset() < (unsigned)fragment.start() || frame().cursor_position().offset() > (unsigned)(fragment.start() + fragment.length()))
|
||||
if (browsing_context().cursor_position().offset() < (unsigned)fragment.start() || browsing_context().cursor_position().offset() > (unsigned)(fragment.start() + fragment.length()))
|
||||
return;
|
||||
|
||||
if (!fragment.layout_node().dom_node() || !fragment.layout_node().dom_node()->is_editable())
|
||||
|
@ -95,7 +95,7 @@ void TextNode::paint_cursor_if_needed(PaintContext& context, const LineBoxFragme
|
|||
|
||||
auto fragment_rect = fragment.absolute_rect();
|
||||
|
||||
float cursor_x = fragment_rect.x() + font().width(fragment.text().substring_view(0, frame().cursor_position().offset() - fragment.start()));
|
||||
float cursor_x = fragment_rect.x() + font().width(fragment.text().substring_view(0, browsing_context().cursor_position().offset() - fragment.start()));
|
||||
float cursor_top = fragment_rect.top();
|
||||
float cursor_height = fragment_rect.height();
|
||||
Gfx::IntRect cursor_rect(cursor_x, cursor_top, 1, cursor_height);
|
||||
|
@ -234,7 +234,7 @@ void TextNode::handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint& positi
|
|||
if (!parent() || !is<Label>(*parent()))
|
||||
return;
|
||||
downcast<Label>(*parent()).handle_mousedown_on_label({}, position, button);
|
||||
frame().event_handler().set_mouse_event_tracking_layout_node(this);
|
||||
browsing_context().event_handler().set_mouse_event_tracking_layout_node(this);
|
||||
}
|
||||
|
||||
void TextNode::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned button, unsigned)
|
||||
|
@ -246,7 +246,7 @@ void TextNode::handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint& position
|
|||
NonnullRefPtr protect = *this;
|
||||
|
||||
downcast<Label>(*parent()).handle_mouseup_on_label({}, position, button);
|
||||
frame().event_handler().set_mouse_event_tracking_layout_node(nullptr);
|
||||
browsing_context().event_handler().set_mouse_event_tracking_layout_node(nullptr);
|
||||
}
|
||||
|
||||
void TextNode::handle_mousemove(Badge<EventHandler>, const Gfx::IntPoint& position, unsigned button, unsigned)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue