mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:27:35 +00:00
LibWeb: Rename Layout::InitialContainingBlock to Layout::Viewport
The name "initial containing block" was wrong for this, as it doesn't correspond to the HTML element, and that's specifically what it's supposed to do! :^)
This commit is contained in:
parent
60f699338d
commit
7e76a51cb0
66 changed files with 121 additions and 128 deletions
|
@ -326,7 +326,7 @@ set(SOURCES
|
|||
Layout/FrameBox.cpp
|
||||
Layout/GridFormattingContext.cpp
|
||||
Layout/ImageBox.cpp
|
||||
Layout/InitialContainingBlock.cpp
|
||||
Layout/Viewport.cpp
|
||||
Layout/InlineFormattingContext.cpp
|
||||
Layout/InlineLevelIterator.cpp
|
||||
Layout/InlineNode.cpp
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <LibWeb/CSS/StyleComputer.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/Element.h>
|
||||
#include <LibWeb/Layout/InitialContainingBlock.h>
|
||||
#include <LibWeb/Layout/Viewport.h>
|
||||
#include <LibWeb/Painting/PaintableBox.h>
|
||||
#include <LibWeb/Painting/StackingContext.h>
|
||||
|
||||
|
@ -493,9 +493,9 @@ RefPtr<StyleValue const> ResolvedCSSStyleDeclaration::style_value_for_property(L
|
|||
return IdentifierStyleValue::create(ValueID::None);
|
||||
|
||||
// The transform matrix is held by the StackingContext, so we need to make sure we have one first.
|
||||
auto* initial_containing_block = layout_node.document().layout_node();
|
||||
VERIFY(initial_containing_block);
|
||||
const_cast<Layout::InitialContainingBlock&>(*initial_containing_block).build_stacking_context_tree_if_needed();
|
||||
auto const* viewport = layout_node.document().layout_node();
|
||||
VERIFY(viewport);
|
||||
const_cast<Layout::Viewport&>(*viewport).build_stacking_context_tree_if_needed();
|
||||
|
||||
VERIFY(layout_node.paintable());
|
||||
auto const& paintable_box = verify_cast<Painting::PaintableBox const>(layout_node.paintable());
|
||||
|
|
|
@ -65,8 +65,8 @@
|
|||
#include <LibWeb/HighResolutionTime/TimeOrigin.h>
|
||||
#include <LibWeb/Infra/Strings.h>
|
||||
#include <LibWeb/Layout/BlockFormattingContext.h>
|
||||
#include <LibWeb/Layout/InitialContainingBlock.h>
|
||||
#include <LibWeb/Layout/TreeBuilder.h>
|
||||
#include <LibWeb/Layout/Viewport.h>
|
||||
#include <LibWeb/Namespace.h>
|
||||
#include <LibWeb/Page/Page.h>
|
||||
#include <LibWeb/Platform/Timer.h>
|
||||
|
@ -849,7 +849,7 @@ void Document::update_layout()
|
|||
if (!m_layout_root) {
|
||||
m_next_layout_node_serial_id = 0;
|
||||
Layout::TreeBuilder tree_builder;
|
||||
m_layout_root = verify_cast<Layout::InitialContainingBlock>(*tree_builder.build(*this));
|
||||
m_layout_root = verify_cast<Layout::Viewport>(*tree_builder.build(*this));
|
||||
}
|
||||
|
||||
Layout::LayoutState layout_state;
|
||||
|
@ -858,10 +858,10 @@ void Document::update_layout()
|
|||
{
|
||||
Layout::BlockFormattingContext root_formatting_context(layout_state, *m_layout_root, nullptr);
|
||||
|
||||
auto& icb = static_cast<Layout::InitialContainingBlock&>(*m_layout_root);
|
||||
auto& icb_state = layout_state.get_mutable(icb);
|
||||
icb_state.set_content_width(viewport_rect.width());
|
||||
icb_state.set_content_height(viewport_rect.height());
|
||||
auto& viewport = static_cast<Layout::Viewport&>(*m_layout_root);
|
||||
auto& viewport_state = layout_state.get_mutable(viewport);
|
||||
viewport_state.set_content_width(viewport_rect.width());
|
||||
viewport_state.set_content_height(viewport_rect.height());
|
||||
|
||||
root_formatting_context.run(
|
||||
*m_layout_root,
|
||||
|
@ -947,14 +947,14 @@ void Document::set_visited_link_color(Color color)
|
|||
m_visited_link_color = color;
|
||||
}
|
||||
|
||||
Layout::InitialContainingBlock const* Document::layout_node() const
|
||||
Layout::Viewport const* Document::layout_node() const
|
||||
{
|
||||
return static_cast<Layout::InitialContainingBlock const*>(Node::layout_node());
|
||||
return static_cast<Layout::Viewport const*>(Node::layout_node());
|
||||
}
|
||||
|
||||
Layout::InitialContainingBlock* Document::layout_node()
|
||||
Layout::Viewport* Document::layout_node()
|
||||
{
|
||||
return static_cast<Layout::InitialContainingBlock*>(Node::layout_node());
|
||||
return static_cast<Layout::Viewport*>(Node::layout_node());
|
||||
}
|
||||
|
||||
void Document::set_inspected_node(Node* node)
|
||||
|
|
|
@ -196,8 +196,8 @@ public:
|
|||
|
||||
virtual bool is_child_allowed(Node const&) const override;
|
||||
|
||||
Layout::InitialContainingBlock const* layout_node() const;
|
||||
Layout::InitialContainingBlock* layout_node();
|
||||
Layout::Viewport const* layout_node() const;
|
||||
Layout::Viewport* layout_node();
|
||||
|
||||
void schedule_style_update();
|
||||
void schedule_layout_update();
|
||||
|
@ -477,7 +477,7 @@ private:
|
|||
|
||||
JS::GCPtr<HTML::Window> m_window;
|
||||
|
||||
JS::GCPtr<Layout::InitialContainingBlock> m_layout_root;
|
||||
JS::GCPtr<Layout::Viewport> m_layout_root;
|
||||
|
||||
Optional<Color> m_link_color;
|
||||
Optional<Color> m_active_link_color;
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include <LibWeb/Infra/CharacterTypes.h>
|
||||
#include <LibWeb/Infra/Strings.h>
|
||||
#include <LibWeb/Layout/BlockContainer.h>
|
||||
#include <LibWeb/Layout/InitialContainingBlock.h>
|
||||
#include <LibWeb/Layout/InlineNode.h>
|
||||
#include <LibWeb/Layout/ListItemBox.h>
|
||||
#include <LibWeb/Layout/TableBox.h>
|
||||
|
@ -46,6 +45,7 @@
|
|||
#include <LibWeb/Layout/TableRowBox.h>
|
||||
#include <LibWeb/Layout/TableRowGroupBox.h>
|
||||
#include <LibWeb/Layout/TreeBuilder.h>
|
||||
#include <LibWeb/Layout/Viewport.h>
|
||||
#include <LibWeb/Namespace.h>
|
||||
#include <LibWeb/Page/Page.h>
|
||||
#include <LibWeb/Painting/PaintableBox.h>
|
||||
|
|
|
@ -35,9 +35,9 @@
|
|||
#include <LibWeb/HTML/Origin.h>
|
||||
#include <LibWeb/HTML/Parser/HTMLParser.h>
|
||||
#include <LibWeb/Infra/CharacterTypes.h>
|
||||
#include <LibWeb/Layout/InitialContainingBlock.h>
|
||||
#include <LibWeb/Layout/Node.h>
|
||||
#include <LibWeb/Layout/TextNode.h>
|
||||
#include <LibWeb/Layout/Viewport.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <LibWeb/DOM/Text.h>
|
||||
#include <LibWeb/Geometry/DOMRect.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/Layout/InitialContainingBlock.h>
|
||||
#include <LibWeb/Layout/Viewport.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
|
|
|
@ -447,7 +447,7 @@ class CheckBox;
|
|||
class FlexFormattingContext;
|
||||
class FormattingContext;
|
||||
struct LayoutState;
|
||||
class InitialContainingBlock;
|
||||
class Viewport;
|
||||
class InlineFormattingContext;
|
||||
class Label;
|
||||
class LabelableNode;
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
#include <LibWeb/HighResolutionTime/TimeOrigin.h>
|
||||
#include <LibWeb/Infra/Strings.h>
|
||||
#include <LibWeb/Layout/BreakNode.h>
|
||||
#include <LibWeb/Layout/InitialContainingBlock.h>
|
||||
#include <LibWeb/Layout/TextNode.h>
|
||||
#include <LibWeb/Layout/Viewport.h>
|
||||
#include <LibWeb/Page/Page.h>
|
||||
#include <LibWeb/URL/URL.h>
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
#include <LibWeb/HighResolutionTime/TimeOrigin.h>
|
||||
#include <LibWeb/Infra/Base64.h>
|
||||
#include <LibWeb/Infra/CharacterTypes.h>
|
||||
#include <LibWeb/Layout/InitialContainingBlock.h>
|
||||
#include <LibWeb/Layout/Viewport.h>
|
||||
#include <LibWeb/Page/Page.h>
|
||||
#include <LibWeb/RequestIdleCallback/IdleDeadline.h>
|
||||
#include <LibWeb/Selection/Selection.h>
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include <LibWeb/Layout/BlockContainer.h>
|
||||
#include <LibWeb/Layout/BlockFormattingContext.h>
|
||||
#include <LibWeb/Layout/Box.h>
|
||||
#include <LibWeb/Layout/InitialContainingBlock.h>
|
||||
#include <LibWeb/Layout/InlineFormattingContext.h>
|
||||
#include <LibWeb/Layout/LineBuilder.h>
|
||||
#include <LibWeb/Layout/ListItemBox.h>
|
||||
|
@ -20,6 +19,7 @@
|
|||
#include <LibWeb/Layout/ReplacedBox.h>
|
||||
#include <LibWeb/Layout/TableBox.h>
|
||||
#include <LibWeb/Layout/TableWrapper.h>
|
||||
#include <LibWeb/Layout/Viewport.h>
|
||||
|
||||
namespace Web::Layout {
|
||||
|
||||
|
@ -38,11 +38,6 @@ BlockFormattingContext::~BlockFormattingContext()
|
|||
}
|
||||
}
|
||||
|
||||
bool BlockFormattingContext::is_initial() const
|
||||
{
|
||||
return is<InitialContainingBlock>(root());
|
||||
}
|
||||
|
||||
CSSPixels BlockFormattingContext::automatic_content_height() const
|
||||
{
|
||||
return compute_auto_height_for_block_formatting_context_root(root());
|
||||
|
@ -50,8 +45,8 @@ CSSPixels BlockFormattingContext::automatic_content_height() const
|
|||
|
||||
void BlockFormattingContext::run(Box const&, LayoutMode layout_mode, AvailableSpace const& available_space)
|
||||
{
|
||||
if (is_initial()) {
|
||||
layout_initial_containing_block(layout_mode, available_space);
|
||||
if (is<Viewport>(root())) {
|
||||
layout_viewport(layout_mode, available_space);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -696,12 +691,12 @@ static void measure_scrollable_overflow(LayoutState const& state, Box const& box
|
|||
});
|
||||
}
|
||||
|
||||
void BlockFormattingContext::layout_initial_containing_block(LayoutMode layout_mode, AvailableSpace const& available_space)
|
||||
void BlockFormattingContext::layout_viewport(LayoutMode layout_mode, AvailableSpace const& available_space)
|
||||
{
|
||||
auto viewport_rect = root().browsing_context().viewport_rect();
|
||||
|
||||
auto& icb = verify_cast<Layout::InitialContainingBlock>(root());
|
||||
auto& icb_state = m_state.get_mutable(icb);
|
||||
auto& viewport = verify_cast<Layout::Viewport>(root());
|
||||
auto& viewport_state = m_state.get_mutable(viewport);
|
||||
|
||||
if (root().children_are_inline())
|
||||
layout_inline_children(root(), layout_mode, available_space);
|
||||
|
@ -710,11 +705,11 @@ void BlockFormattingContext::layout_initial_containing_block(LayoutMode layout_m
|
|||
|
||||
CSSPixels bottom_edge = 0;
|
||||
CSSPixels right_edge = 0;
|
||||
measure_scrollable_overflow(m_state, icb, bottom_edge, right_edge);
|
||||
measure_scrollable_overflow(m_state, viewport, bottom_edge, right_edge);
|
||||
|
||||
if (bottom_edge >= viewport_rect.height() || right_edge >= viewport_rect.width()) {
|
||||
// FIXME: Move overflow data to LayoutState!
|
||||
auto& overflow_data = icb_state.ensure_overflow_data();
|
||||
auto& overflow_data = viewport_state.ensure_overflow_data();
|
||||
overflow_data.scrollable_overflow_rect = viewport_rect;
|
||||
// NOTE: The edges are *within* the rectangle, so we add 1 to get the width and height.
|
||||
overflow_data.scrollable_overflow_rect.set_size(right_edge + 1, bottom_edge + 1);
|
||||
|
|
|
@ -24,8 +24,6 @@ public:
|
|||
virtual void run(Box const&, LayoutMode, AvailableSpace const&) override;
|
||||
virtual CSSPixels automatic_content_height() const override;
|
||||
|
||||
bool is_initial() const;
|
||||
|
||||
auto const& left_side_floats() const { return m_left_floats; }
|
||||
auto const& right_side_floats() const { return m_right_floats; }
|
||||
|
||||
|
@ -61,7 +59,7 @@ private:
|
|||
|
||||
CSSPixels compute_width_for_table_wrapper(Box const&, AvailableSpace const&);
|
||||
|
||||
void layout_initial_containing_block(LayoutMode, AvailableSpace const&);
|
||||
void layout_viewport(LayoutMode, AvailableSpace const&);
|
||||
|
||||
void layout_block_level_children(BlockContainer const&, LayoutMode, AvailableSpace const&);
|
||||
void layout_inline_children(BlockContainer const&, LayoutMode, AvailableSpace const&);
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
#include <LibWeb/Layout/BlockFormattingContext.h>
|
||||
#include <LibWeb/Layout/Box.h>
|
||||
#include <LibWeb/Layout/FlexFormattingContext.h>
|
||||
#include <LibWeb/Layout/InitialContainingBlock.h>
|
||||
#include <LibWeb/Layout/ReplacedBox.h>
|
||||
#include <LibWeb/Layout/TextNode.h>
|
||||
#include <LibWeb/Layout/Viewport.h>
|
||||
|
||||
namespace Web::Layout {
|
||||
|
||||
|
|
|
@ -10,13 +10,13 @@
|
|||
#include <LibWeb/Layout/FlexFormattingContext.h>
|
||||
#include <LibWeb/Layout/FormattingContext.h>
|
||||
#include <LibWeb/Layout/GridFormattingContext.h>
|
||||
#include <LibWeb/Layout/InitialContainingBlock.h>
|
||||
#include <LibWeb/Layout/ReplacedBox.h>
|
||||
#include <LibWeb/Layout/SVGFormattingContext.h>
|
||||
#include <LibWeb/Layout/SVGSVGBox.h>
|
||||
#include <LibWeb/Layout/TableBox.h>
|
||||
#include <LibWeb/Layout/TableCellBox.h>
|
||||
#include <LibWeb/Layout/TableFormattingContext.h>
|
||||
#include <LibWeb/Layout/Viewport.h>
|
||||
|
||||
namespace Web::Layout {
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/HTML/BrowsingContext.h>
|
||||
#include <LibWeb/Layout/FrameBox.h>
|
||||
#include <LibWeb/Layout/InitialContainingBlock.h>
|
||||
#include <LibWeb/Layout/Viewport.h>
|
||||
#include <LibWeb/Painting/NestedBrowsingContextPaintable.h>
|
||||
|
||||
namespace Web::Layout {
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
#include <LibGUI/Event.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/Element.h>
|
||||
#include <LibWeb/Layout/InitialContainingBlock.h>
|
||||
#include <LibWeb/Layout/Label.h>
|
||||
#include <LibWeb/Layout/LabelableNode.h>
|
||||
#include <LibWeb/Layout/TextNode.h>
|
||||
#include <LibWeb/Layout/Viewport.h>
|
||||
#include <LibWeb/Painting/LabelablePaintable.h>
|
||||
|
||||
namespace Web::Layout {
|
||||
|
|
|
@ -26,7 +26,7 @@ LayoutState::UsedValues& LayoutState::get_mutable(NodeWithStyleAndBoxModelMetric
|
|||
}
|
||||
}
|
||||
|
||||
auto const* containing_block_used_values = box.is_initial_containing_block_box() ? nullptr : &get(*box.containing_block());
|
||||
auto const* containing_block_used_values = box.is_viewport() ? nullptr : &get(*box.containing_block());
|
||||
|
||||
used_values_per_layout_node[serial_id] = adopt_own(*new UsedValues);
|
||||
used_values_per_layout_node[serial_id]->set_node(const_cast<NodeWithStyleAndBoxModelMetrics&>(box), containing_block_used_values);
|
||||
|
@ -44,7 +44,7 @@ LayoutState::UsedValues const& LayoutState::get(NodeWithStyleAndBoxModelMetrics
|
|||
return *ancestor->used_values_per_layout_node[serial_id];
|
||||
}
|
||||
|
||||
auto const* containing_block_used_values = box.is_initial_containing_block_box() ? nullptr : &get(*box.containing_block());
|
||||
auto const* containing_block_used_values = box.is_viewport() ? nullptr : &get(*box.containing_block());
|
||||
|
||||
const_cast<LayoutState*>(this)->used_values_per_layout_node[serial_id] = adopt_own(*new UsedValues);
|
||||
const_cast<LayoutState*>(this)->used_values_per_layout_node[serial_id]->set_node(const_cast<NodeWithStyleAndBoxModelMetrics&>(box), containing_block_used_values);
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
|
||||
#include <AK/Utf8View.h>
|
||||
#include <LibWeb/DOM/Range.h>
|
||||
#include <LibWeb/Layout/InitialContainingBlock.h>
|
||||
#include <LibWeb/Layout/LayoutState.h>
|
||||
#include <LibWeb/Layout/LineBoxFragment.h>
|
||||
#include <LibWeb/Layout/TextNode.h>
|
||||
#include <LibWeb/Layout/Viewport.h>
|
||||
#include <ctype.h>
|
||||
|
||||
namespace Web::Layout {
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
#include <LibWeb/HTML/HTMLHtmlElement.h>
|
||||
#include <LibWeb/Layout/BlockContainer.h>
|
||||
#include <LibWeb/Layout/FormattingContext.h>
|
||||
#include <LibWeb/Layout/InitialContainingBlock.h>
|
||||
#include <LibWeb/Layout/Node.h>
|
||||
#include <LibWeb/Layout/TableBox.h>
|
||||
#include <LibWeb/Layout/TextNode.h>
|
||||
#include <LibWeb/Layout/Viewport.h>
|
||||
#include <LibWeb/Platform/FontPlugin.h>
|
||||
|
||||
namespace Web::Layout {
|
||||
|
@ -62,7 +62,7 @@ bool Node::can_contain_boxes_with_position_absolute() const
|
|||
if (computed_values().position() != CSS::Position::Static)
|
||||
return true;
|
||||
|
||||
if (is<InitialContainingBlock>(*this))
|
||||
if (is<Viewport>(*this))
|
||||
return true;
|
||||
|
||||
// https://w3c.github.io/csswg-drafts/css-transforms-1/#propdef-transform
|
||||
|
@ -163,13 +163,13 @@ HTML::BrowsingContext& Node::browsing_context()
|
|||
return *m_browsing_context;
|
||||
}
|
||||
|
||||
InitialContainingBlock const& Node::root() const
|
||||
Viewport const& Node::root() const
|
||||
{
|
||||
VERIFY(document().layout_node());
|
||||
return *document().layout_node();
|
||||
}
|
||||
|
||||
InitialContainingBlock& Node::root()
|
||||
Viewport& Node::root()
|
||||
{
|
||||
VERIFY(document().layout_node());
|
||||
return *document().layout_node();
|
||||
|
|
|
@ -62,8 +62,8 @@ public:
|
|||
HTML::BrowsingContext const& browsing_context() const;
|
||||
HTML::BrowsingContext& browsing_context();
|
||||
|
||||
InitialContainingBlock const& root() const;
|
||||
InitialContainingBlock& root();
|
||||
Viewport const& root() const;
|
||||
Viewport& root();
|
||||
|
||||
bool is_root_element() const;
|
||||
|
||||
|
@ -86,7 +86,7 @@ public:
|
|||
virtual bool is_block_container() const { return false; }
|
||||
virtual bool is_break_node() const { return false; }
|
||||
virtual bool is_text_node() const { return false; }
|
||||
virtual bool is_initial_containing_block_box() const { return false; }
|
||||
virtual bool is_viewport() const { return false; }
|
||||
virtual bool is_svg_box() const { return false; }
|
||||
virtual bool is_svg_geometry_box() const { return false; }
|
||||
virtual bool is_label() const { return false; }
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include <LibWeb/Dump.h>
|
||||
#include <LibWeb/HTML/HTMLInputElement.h>
|
||||
#include <LibWeb/HTML/HTMLProgressElement.h>
|
||||
#include <LibWeb/Layout/InitialContainingBlock.h>
|
||||
#include <LibWeb/Layout/ListItemBox.h>
|
||||
#include <LibWeb/Layout/ListItemMarkerBox.h>
|
||||
#include <LibWeb/Layout/Node.h>
|
||||
|
@ -27,6 +26,7 @@
|
|||
#include <LibWeb/Layout/TableWrapper.h>
|
||||
#include <LibWeb/Layout/TextNode.h>
|
||||
#include <LibWeb/Layout/TreeBuilder.h>
|
||||
#include <LibWeb/Layout/Viewport.h>
|
||||
#include <LibWeb/SVG/SVGForeignObjectElement.h>
|
||||
|
||||
namespace Web::Layout {
|
||||
|
@ -219,7 +219,7 @@ ErrorOr<void> TreeBuilder::create_layout_tree(DOM::Node& dom_node, TreeBuilder::
|
|||
} else if (is<DOM::Document>(dom_node)) {
|
||||
style = style_computer.create_document_style();
|
||||
display = style->display();
|
||||
layout_node = document.heap().allocate_without_realm<Layout::InitialContainingBlock>(static_cast<DOM::Document&>(dom_node), *style);
|
||||
layout_node = document.heap().allocate_without_realm<Layout::Viewport>(static_cast<DOM::Document&>(dom_node), *style);
|
||||
} else if (is<DOM::Text>(dom_node)) {
|
||||
layout_node = document.heap().allocate_without_realm<Layout::TextNode>(document, static_cast<DOM::Text&>(dom_node));
|
||||
display = CSS::Display(CSS::Display::Outside::Inline, CSS::Display::Inside::Flow);
|
||||
|
|
|
@ -1,37 +1,37 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/DOM/Range.h>
|
||||
#include <LibWeb/Dump.h>
|
||||
#include <LibWeb/Layout/InitialContainingBlock.h>
|
||||
#include <LibWeb/Layout/Viewport.h>
|
||||
#include <LibWeb/Painting/PaintableBox.h>
|
||||
#include <LibWeb/Painting/StackingContext.h>
|
||||
|
||||
namespace Web::Layout {
|
||||
|
||||
InitialContainingBlock::InitialContainingBlock(DOM::Document& document, NonnullRefPtr<CSS::StyleProperties> style)
|
||||
Viewport::Viewport(DOM::Document& document, NonnullRefPtr<CSS::StyleProperties> style)
|
||||
: BlockContainer(document, &document, move(style))
|
||||
{
|
||||
}
|
||||
|
||||
InitialContainingBlock::~InitialContainingBlock() = default;
|
||||
Viewport::~Viewport() = default;
|
||||
|
||||
JS::GCPtr<Selection::Selection> InitialContainingBlock::selection() const
|
||||
JS::GCPtr<Selection::Selection> Viewport::selection() const
|
||||
{
|
||||
return const_cast<DOM::Document&>(document()).get_selection();
|
||||
}
|
||||
|
||||
void InitialContainingBlock::build_stacking_context_tree_if_needed()
|
||||
void Viewport::build_stacking_context_tree_if_needed()
|
||||
{
|
||||
if (paint_box()->stacking_context())
|
||||
return;
|
||||
build_stacking_context_tree();
|
||||
}
|
||||
|
||||
void InitialContainingBlock::build_stacking_context_tree()
|
||||
void Viewport::build_stacking_context_tree()
|
||||
{
|
||||
const_cast<Painting::PaintableWithLines*>(paint_box())->set_stacking_context(make<Painting::StackingContext>(*this, nullptr));
|
||||
|
||||
|
@ -52,7 +52,7 @@ void InitialContainingBlock::build_stacking_context_tree()
|
|||
const_cast<Painting::PaintableWithLines*>(paint_box())->stacking_context()->sort();
|
||||
}
|
||||
|
||||
void InitialContainingBlock::paint_all_phases(PaintContext& context)
|
||||
void Viewport::paint_all_phases(PaintContext& context)
|
||||
{
|
||||
build_stacking_context_tree_if_needed();
|
||||
context.painter().fill_rect(context.enclosing_device_rect(paint_box()->absolute_rect()).to_type<int>(), document().background_color(context.palette()));
|
||||
|
@ -60,7 +60,7 @@ void InitialContainingBlock::paint_all_phases(PaintContext& context)
|
|||
paint_box()->stacking_context()->paint(context);
|
||||
}
|
||||
|
||||
void InitialContainingBlock::recompute_selection_states()
|
||||
void Viewport::recompute_selection_states()
|
||||
{
|
||||
// 1. Start by resetting the selection state of all layout nodes to None.
|
||||
for_each_in_inclusive_subtree([&](auto& layout_node) {
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -12,12 +12,12 @@
|
|||
|
||||
namespace Web::Layout {
|
||||
|
||||
class InitialContainingBlock final : public BlockContainer {
|
||||
JS_CELL(InitialContainingBlock, BlockContainer);
|
||||
class Viewport final : public BlockContainer {
|
||||
JS_CELL(Viewport, BlockContainer);
|
||||
|
||||
public:
|
||||
explicit InitialContainingBlock(DOM::Document&, NonnullRefPtr<CSS::StyleProperties>);
|
||||
virtual ~InitialContainingBlock() override;
|
||||
explicit Viewport(DOM::Document&, NonnullRefPtr<CSS::StyleProperties>);
|
||||
virtual ~Viewport() override;
|
||||
|
||||
const DOM::Document& dom_node() const { return static_cast<const DOM::Document&>(*Node::dom_node()); }
|
||||
|
||||
|
@ -30,10 +30,10 @@ public:
|
|||
|
||||
private:
|
||||
void build_stacking_context_tree();
|
||||
virtual bool is_initial_containing_block_box() const override { return true; }
|
||||
virtual bool is_viewport() const override { return true; }
|
||||
};
|
||||
|
||||
template<>
|
||||
inline bool Node::fast_is<InitialContainingBlock>() const { return is_initial_containing_block_box(); }
|
||||
inline bool Node::fast_is<Viewport>() const { return is_viewport(); }
|
||||
|
||||
}
|
|
@ -11,7 +11,7 @@
|
|||
#include <LibWeb/DOM/Range.h>
|
||||
#include <LibWeb/DOM/Text.h>
|
||||
#include <LibWeb/HTML/BrowsingContext.h>
|
||||
#include <LibWeb/Layout/InitialContainingBlock.h>
|
||||
#include <LibWeb/Layout/Viewport.h>
|
||||
#include <LibWeb/Page/EditEventHandler.h>
|
||||
|
||||
namespace Web {
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <LibWeb/HTML/HTMLAnchorElement.h>
|
||||
#include <LibWeb/HTML/HTMLIFrameElement.h>
|
||||
#include <LibWeb/HTML/HTMLImageElement.h>
|
||||
#include <LibWeb/Layout/InitialContainingBlock.h>
|
||||
#include <LibWeb/Layout/Viewport.h>
|
||||
#include <LibWeb/Page/EventHandler.h>
|
||||
#include <LibWeb/Page/Page.h>
|
||||
#include <LibWeb/Painting/PaintableBox.h>
|
||||
|
@ -119,14 +119,14 @@ EventHandler::EventHandler(Badge<HTML::BrowsingContext>, HTML::BrowsingContext&
|
|||
|
||||
EventHandler::~EventHandler() = default;
|
||||
|
||||
Layout::InitialContainingBlock const* EventHandler::layout_root() const
|
||||
Layout::Viewport const* EventHandler::layout_root() const
|
||||
{
|
||||
if (!m_browsing_context.active_document())
|
||||
return nullptr;
|
||||
return m_browsing_context.active_document()->layout_node();
|
||||
}
|
||||
|
||||
Layout::InitialContainingBlock* EventHandler::layout_root()
|
||||
Layout::Viewport* EventHandler::layout_root()
|
||||
{
|
||||
if (!m_browsing_context.active_document())
|
||||
return nullptr;
|
||||
|
|
|
@ -44,8 +44,8 @@ private:
|
|||
CSSPixelPoint compute_mouse_event_client_offset(CSSPixelPoint event_page_position) const;
|
||||
CSSPixelPoint compute_mouse_event_page_offset(CSSPixelPoint event_client_offset) const;
|
||||
|
||||
Layout::InitialContainingBlock* layout_root();
|
||||
Layout::InitialContainingBlock const* layout_root() const;
|
||||
Layout::Viewport* layout_root();
|
||||
Layout::Viewport const* layout_root() const;
|
||||
|
||||
Painting::PaintableBox* paint_root();
|
||||
Painting::PaintableBox const* paint_root() const;
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
#include <LibGfx/AntiAliasingPainter.h>
|
||||
#include <LibGfx/Painter.h>
|
||||
#include <LibWeb/Layout/InitialContainingBlock.h>
|
||||
#include <LibWeb/Layout/Node.h>
|
||||
#include <LibWeb/Layout/Viewport.h>
|
||||
#include <LibWeb/Painting/BackgroundPainting.h>
|
||||
#include <LibWeb/Painting/BorderRadiusCornerClipper.h>
|
||||
#include <LibWeb/Painting/GradientPainting.h>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <AK/Debug.h>
|
||||
#include <LibWeb/HTML/BrowsingContextContainer.h>
|
||||
#include <LibWeb/Layout/FrameBox.h>
|
||||
#include <LibWeb/Layout/InitialContainingBlock.h>
|
||||
#include <LibWeb/Layout/Viewport.h>
|
||||
#include <LibWeb/Painting/BorderRadiusCornerClipper.h>
|
||||
#include <LibWeb/Painting/NestedBrowsingContextPaintable.h>
|
||||
|
||||
|
@ -54,7 +54,7 @@ void NestedBrowsingContextPaintable::paint(PaintContext& context, PaintPhase pha
|
|||
context.painter().translate(absolute_rect.x().value(), absolute_rect.y().value());
|
||||
|
||||
context.set_device_viewport_rect({ {}, context.enclosing_device_size(layout_box().dom_node().nested_browsing_context()->size()) });
|
||||
const_cast<Layout::InitialContainingBlock*>(hosted_layout_tree)->paint_all_phases(context);
|
||||
const_cast<Layout::Viewport*>(hosted_layout_tree)->paint_all_phases(context);
|
||||
|
||||
context.set_device_viewport_rect(old_viewport_rect);
|
||||
context.painter().restore();
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <LibWeb/FontCache.h>
|
||||
#include <LibWeb/HTML/HTMLHtmlElement.h>
|
||||
#include <LibWeb/Layout/BlockContainer.h>
|
||||
#include <LibWeb/Layout/InitialContainingBlock.h>
|
||||
#include <LibWeb/Layout/Viewport.h>
|
||||
#include <LibWeb/Painting/BackgroundPainting.h>
|
||||
#include <LibWeb/Painting/FilterPainting.h>
|
||||
#include <LibWeb/Painting/PaintableBox.h>
|
||||
|
@ -141,7 +141,7 @@ Painting::StackingContext* PaintableBox::enclosing_stacking_context()
|
|||
if (auto* ancestor_paint_box = ancestor_box.paint_box(); ancestor_paint_box && ancestor_paint_box->stacking_context())
|
||||
return const_cast<StackingContext*>(ancestor_paint_box->stacking_context());
|
||||
}
|
||||
// We should always reach the Layout::InitialContainingBlock stacking context.
|
||||
// We should always reach the Layout::Viewport stacking context.
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
|
@ -686,8 +686,8 @@ Optional<HitTestResult> PaintableBox::hit_test(CSSPixelPoint position, HitTestTy
|
|||
if (!is_visible())
|
||||
return {};
|
||||
|
||||
if (layout_box().is_initial_containing_block_box()) {
|
||||
const_cast<Layout::InitialContainingBlock&>(static_cast<Layout::InitialContainingBlock const&>(layout_box())).build_stacking_context_tree_if_needed();
|
||||
if (layout_box().is_viewport()) {
|
||||
const_cast<Layout::Viewport&>(static_cast<Layout::Viewport const&>(layout_box())).build_stacking_context_tree_if_needed();
|
||||
return stacking_context()->hit_test(position, type);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
#include <LibGfx/Painter.h>
|
||||
#include <LibGfx/Rect.h>
|
||||
#include <LibWeb/Layout/Box.h>
|
||||
#include <LibWeb/Layout/InitialContainingBlock.h>
|
||||
#include <LibWeb/Layout/ReplacedBox.h>
|
||||
#include <LibWeb/Layout/Viewport.h>
|
||||
#include <LibWeb/Painting/PaintableBox.h>
|
||||
#include <LibWeb/Painting/StackingContext.h>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue