1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-23 09:47:41 +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:
Andreas Kling 2023-02-25 11:04:29 +01:00
parent 60f699338d
commit 7e76a51cb0
66 changed files with 121 additions and 128 deletions

View file

@ -1,4 +1,4 @@
InitialContainingBlock <#document> at (0,0) content-size 800x600 children: not-inline Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x16 children: not-inline BlockContainer <html> at (0,0) content-size 800x16 children: not-inline
BlockContainer <(anonymous)> at (0,0) content-size 800x0 children: inline BlockContainer <(anonymous)> at (0,0) content-size 800x0 children: inline
TextNode <#text> TextNode <#text>

View file

@ -1,4 +1,4 @@
InitialContainingBlock <#document> at (0,0) content-size 800x600 children: not-inline Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x157 children: not-inline BlockContainer <html> at (0,0) content-size 800x157 children: not-inline
BlockContainer <body> at (8,8) content-size 784x100 children: not-inline BlockContainer <body> at (8,8) content-size 784x100 children: not-inline
BlockContainer <div> at (8,8) content-size 784x100 children: not-inline BlockContainer <div> at (8,8) content-size 784x100 children: not-inline

View file

@ -1,4 +1,4 @@
InitialContainingBlock <#document> at (0,0) content-size 800x600 children: not-inline Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x120 children: not-inline BlockContainer <html> at (0,0) content-size 800x120 children: not-inline
BlockContainer <body> at (8,8) content-size 784x104 children: not-inline BlockContainer <body> at (8,8) content-size 784x104 children: not-inline
Box <div.container> at (9,9) content-size 500x102 flex-container(row) children: not-inline Box <div.container> at (9,9) content-size 500x102 flex-container(row) children: not-inline

View file

@ -1,4 +1,4 @@
InitialContainingBlock <#document> at (0,0) content-size 800x600 children: not-inline Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x268 children: not-inline BlockContainer <html> at (0,0) content-size 800x268 children: not-inline
BlockContainer <body> at (8,8) content-size 784x252 children: not-inline BlockContainer <body> at (8,8) content-size 784x252 children: not-inline
Box <div.container.column> at (9,9) content-size 250x250 flex-container(column) children: not-inline Box <div.container.column> at (9,9) content-size 250x250 flex-container(column) children: not-inline

View file

@ -1,4 +1,4 @@
InitialContainingBlock <#document> at (0,0) content-size 800x600 children: not-inline Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x268 children: not-inline BlockContainer <html> at (0,0) content-size 800x268 children: not-inline
BlockContainer <body> at (8,8) content-size 784x252 children: not-inline BlockContainer <body> at (8,8) content-size 784x252 children: not-inline
Box <div.container.column> at (9,9) content-size 782x250 flex-container(column) children: not-inline Box <div.container.column> at (9,9) content-size 782x250 flex-container(column) children: not-inline

View file

@ -1,4 +1,4 @@
InitialContainingBlock <#document> at (0,0) content-size 800x600 children: not-inline Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x268 children: not-inline BlockContainer <html> at (0,0) content-size 800x268 children: not-inline
BlockContainer <body> at (8,8) content-size 784x252 children: not-inline BlockContainer <body> at (8,8) content-size 784x252 children: not-inline
Box <div.container.column> at (9,9) content-size 250x250 flex-container(column) children: not-inline Box <div.container.column> at (9,9) content-size 250x250 flex-container(column) children: not-inline

View file

@ -1,4 +1,4 @@
InitialContainingBlock <#document> at (0,0) content-size 800x600 children: not-inline Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x268 children: not-inline BlockContainer <html> at (0,0) content-size 800x268 children: not-inline
BlockContainer <body> at (8,8) content-size 784x252 children: not-inline BlockContainer <body> at (8,8) content-size 784x252 children: not-inline
Box <div.container> at (9,9) content-size 782x250 flex-container(column) children: not-inline Box <div.container> at (9,9) content-size 782x250 flex-container(column) children: not-inline

View file

@ -1,4 +1,4 @@
InitialContainingBlock <#document> at (0,0) content-size 800x600 children: not-inline Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x120 children: not-inline BlockContainer <html> at (0,0) content-size 800x120 children: not-inline
BlockContainer <body> at (8,8) content-size 784x104 children: not-inline BlockContainer <body> at (8,8) content-size 784x104 children: not-inline
Box <div.container> at (9,9) content-size 250x102 flex-container(row) children: not-inline Box <div.container> at (9,9) content-size 250x102 flex-container(row) children: not-inline

View file

@ -1,4 +1,4 @@
InitialContainingBlock <#document> at (0,0) content-size 800x600 children: not-inline Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x222 children: not-inline BlockContainer <html> at (0,0) content-size 800x222 children: not-inline
BlockContainer <body> at (8,8) content-size 784x206 children: not-inline BlockContainer <body> at (8,8) content-size 784x206 children: not-inline
Box <div.container> at (9,9) content-size 250x204 flex-container(row) children: not-inline Box <div.container> at (9,9) content-size 250x204 flex-container(row) children: not-inline

View file

@ -1,4 +1,4 @@
InitialContainingBlock <#document> at (0,0) content-size 800x600 children: not-inline Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x120 children: not-inline BlockContainer <html> at (0,0) content-size 800x120 children: not-inline
BlockContainer <body> at (8,8) content-size 784x104 children: not-inline BlockContainer <body> at (8,8) content-size 784x104 children: not-inline
Box <div.container.width-constrained> at (9,9) content-size 250x102 flex-container(row) children: not-inline Box <div.container.width-constrained> at (9,9) content-size 250x102 flex-container(row) children: not-inline

View file

@ -1,4 +1,4 @@
InitialContainingBlock <#document> at (0,0) content-size 800x600 children: not-inline Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x76.40625 children: not-inline BlockContainer <html> at (0,0) content-size 800x76.40625 children: not-inline
BlockContainer <body> at (8,8) content-size 784x60.40625 children: not-inline BlockContainer <body> at (8,8) content-size 784x60.40625 children: not-inline
Box <div.container> at (9,9) content-size 500x58.40625 flex-container(column) children: not-inline Box <div.container> at (9,9) content-size 500x58.40625 flex-container(column) children: not-inline

View file

@ -1,4 +1,4 @@
InitialContainingBlock <#document> at (0,0) content-size 800x600 children: not-inline Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x120 children: not-inline BlockContainer <html> at (0,0) content-size 800x120 children: not-inline
BlockContainer <body> at (8,8) content-size 784x104 children: not-inline BlockContainer <body> at (8,8) content-size 784x104 children: not-inline
Box <div.container> at (9,9) content-size 500x102 flex-container(row) children: not-inline Box <div.container> at (9,9) content-size 500x102 flex-container(row) children: not-inline

View file

@ -1,4 +1,4 @@
InitialContainingBlock <#document> at (0,0) content-size 800x600 children: not-inline Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x120 children: not-inline BlockContainer <html> at (0,0) content-size 800x120 children: not-inline
BlockContainer <body> at (8,8) content-size 784x104 children: not-inline BlockContainer <body> at (8,8) content-size 784x104 children: not-inline
Box <div.container> at (9,9) content-size 500x102 flex-container(row) children: not-inline Box <div.container> at (9,9) content-size 500x102 flex-container(row) children: not-inline

View file

@ -1,4 +1,4 @@
InitialContainingBlock <#document> at (0,0) content-size 800x600 children: not-inline Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x120 children: not-inline BlockContainer <html> at (0,0) content-size 800x120 children: not-inline
BlockContainer <body> at (8,8) content-size 784x104 children: not-inline BlockContainer <body> at (8,8) content-size 784x104 children: not-inline
Box <div.container> at (9,9) content-size 782x102 flex-container(row) children: not-inline Box <div.container> at (9,9) content-size 782x102 flex-container(row) children: not-inline

View file

@ -1,4 +1,4 @@
InitialContainingBlock <#document> at (0,0) content-size 800x600 children: not-inline Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x120 children: not-inline BlockContainer <html> at (0,0) content-size 800x120 children: not-inline
BlockContainer <body> at (8,8) content-size 784x104 children: not-inline BlockContainer <body> at (8,8) content-size 784x104 children: not-inline
Box <div.container> at (9,9) content-size 250x102 flex-container(row) children: not-inline Box <div.container> at (9,9) content-size 250x102 flex-container(row) children: not-inline

View file

@ -1,4 +1,4 @@
InitialContainingBlock <#document> at (0,0) content-size 800x600 children: not-inline Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x120 children: not-inline BlockContainer <html> at (0,0) content-size 800x120 children: not-inline
BlockContainer <body> at (8,8) content-size 784x104 children: not-inline BlockContainer <body> at (8,8) content-size 784x104 children: not-inline
Box <div.container> at (9,9) content-size 500x102 flex-container(row) children: not-inline Box <div.container> at (9,9) content-size 500x102 flex-container(row) children: not-inline

View file

@ -1,4 +1,4 @@
InitialContainingBlock <#document> at (0,0) content-size 800x600 children: not-inline Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x120 children: not-inline BlockContainer <html> at (0,0) content-size 800x120 children: not-inline
BlockContainer <body> at (8,8) content-size 784x104 children: not-inline BlockContainer <body> at (8,8) content-size 784x104 children: not-inline
Box <div.container> at (9,9) content-size 500x102 flex-container(row) children: not-inline Box <div.container> at (9,9) content-size 500x102 flex-container(row) children: not-inline

View file

@ -1,4 +1,4 @@
InitialContainingBlock <#document> at (0,0) content-size 800x600 children: not-inline Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x348.34375 children: not-inline BlockContainer <html> at (0,0) content-size 800x348.34375 children: not-inline
BlockContainer <body> at (8,8) content-size 784x332.34375 children: not-inline BlockContainer <body> at (8,8) content-size 784x332.34375 children: not-inline
BlockContainer <(anonymous)> at (8,8) content-size 784x0 children: inline BlockContainer <(anonymous)> at (8,8) content-size 784x0 children: inline

View file

@ -1,4 +1,4 @@
InitialContainingBlock <#document> at (0,0) content-size 800x600 children: not-inline Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x60 children: not-inline BlockContainer <html> at (0,0) content-size 800x60 children: not-inline
BlockContainer <(anonymous)> at (0,0) content-size 800x0 children: inline BlockContainer <(anonymous)> at (0,0) content-size 800x0 children: inline
TextNode <#text> TextNode <#text>

View file

@ -1,4 +1,4 @@
InitialContainingBlock <#document> at (0,0) content-size 800x600 children: not-inline Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x135.46875 children: not-inline BlockContainer <html> at (0,0) content-size 800x135.46875 children: not-inline
BlockContainer <body> at (8,8) content-size 780x119.46875 children: not-inline BlockContainer <body> at (8,8) content-size 780x119.46875 children: not-inline
BlockContainer <(anonymous)> at (8,8) content-size 780x0 children: inline BlockContainer <(anonymous)> at (8,8) content-size 780x0 children: inline

View file

@ -1,4 +1,4 @@
InitialContainingBlock <#document> at (0,0) content-size 800x600 children: not-inline Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x268 children: not-inline BlockContainer <html> at (0,0) content-size 800x268 children: not-inline
BlockContainer <body> at (8,8) content-size 784x252 children: not-inline BlockContainer <body> at (8,8) content-size 784x252 children: not-inline
BlockContainer <(anonymous)> at (8,8) content-size 784x0 children: inline BlockContainer <(anonymous)> at (8,8) content-size 784x0 children: inline

View file

@ -1,4 +1,4 @@
InitialContainingBlock <#document> at (0,0) content-size 800x600 children: not-inline Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html.js> at (0,0) content-size 800x200 children: not-inline BlockContainer <html.js> at (0,0) content-size 800x200 children: not-inline
BlockContainer <body> at (0,0) content-size 800x50 children: not-inline BlockContainer <body> at (0,0) content-size 800x50 children: not-inline
BlockContainer <div#page> at (50,50) content-size 750x0 children: not-inline BlockContainer <div#page> at (50,50) content-size 750x0 children: not-inline

View file

@ -1,4 +1,4 @@
InitialContainingBlock <#document> at (0,0) content-size 800x600 children: not-inline Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x268 children: not-inline BlockContainer <html> at (0,0) content-size 800x268 children: not-inline
BlockContainer <body> at (8,8) content-size 784x252 children: not-inline BlockContainer <body> at (8,8) content-size 784x252 children: not-inline
BlockContainer <(anonymous)> at (8,8) content-size 784x0 children: inline BlockContainer <(anonymous)> at (8,8) content-size 784x0 children: inline

View file

@ -1,4 +1,4 @@
InitialContainingBlock <#document> at (0,0) content-size 800x600 children: not-inline Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x262 children: not-inline BlockContainer <html> at (0,0) content-size 800x262 children: not-inline
BlockContainer <body> at (8,25) content-size 784x229 children: not-inline BlockContainer <body> at (8,25) content-size 784x229 children: not-inline
BlockContainer <div#foo> at (34,26) content-size 100x100 children: inline BlockContainer <div#foo> at (34,26) content-size 100x100 children: inline

View file

@ -1,4 +1,4 @@
InitialContainingBlock <#document> at (0,0) content-size 800x600 children: not-inline Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x352 children: not-inline BlockContainer <html> at (0,0) content-size 800x352 children: not-inline
BlockContainer <body> at (8,8) content-size 784x336 children: not-inline BlockContainer <body> at (8,8) content-size 784x336 children: not-inline
BlockContainer <div#foo> at (9,9) content-size 100x100 children: inline BlockContainer <div#foo> at (9,9) content-size 100x100 children: inline

View file

@ -1,4 +1,4 @@
InitialContainingBlock <#document> at (0,0) content-size 800x600 children: not-inline Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x366 children: not-inline BlockContainer <html> at (0,0) content-size 800x366 children: not-inline
BlockContainer <body> at (8,8) content-size 784x350 children: not-inline BlockContainer <body> at (8,8) content-size 784x350 children: not-inline
BlockContainer <div#foo> at (8,8) content-size 100x100 children: not-inline BlockContainer <div#foo> at (8,8) content-size 100x100 children: not-inline

View file

@ -1,4 +1,4 @@
InitialContainingBlock <#document> at (0,0) content-size 800x600 children: not-inline Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x166 children: not-inline BlockContainer <html> at (0,0) content-size 800x166 children: not-inline
BlockContainer <body> at (8,8) content-size 784x150 children: not-inline BlockContainer <body> at (8,8) content-size 784x150 children: not-inline
BlockContainer <div#foo> at (8,8) content-size 100x50 children: not-inline BlockContainer <div#foo> at (8,8) content-size 100x50 children: not-inline

View file

@ -1,4 +1,4 @@
InitialContainingBlock <#document> at (0,0) content-size 800x600 children: not-inline Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x16 children: not-inline BlockContainer <html> at (0,0) content-size 800x16 children: not-inline
BlockContainer <body> at (8,8) content-size 784x0 children: inline BlockContainer <body> at (8,8) content-size 784x0 children: inline
BlockContainer <div#container> at (8,8) content-size 500x400 positioned children: inline BlockContainer <div#container> at (8,8) content-size 500x400 positioned children: inline

View file

@ -1,4 +1,4 @@
InitialContainingBlock <#document> at (0,0) content-size 800x600 children: not-inline Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x616 children: not-inline BlockContainer <html> at (0,0) content-size 800x616 children: not-inline
BlockContainer <(anonymous)> at (0,0) content-size 800x0 children: inline BlockContainer <(anonymous)> at (0,0) content-size 800x0 children: inline
TextNode <#text> TextNode <#text>

View file

@ -1,4 +1,4 @@
InitialContainingBlock <#document> at (0,0) content-size 800x600 children: not-inline Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (1,1) content-size 798x60.9375 children: not-inline BlockContainer <html> at (1,1) content-size 798x60.9375 children: not-inline
BlockContainer <body> at (10,10) content-size 780x42.9375 children: not-inline BlockContainer <body> at (10,10) content-size 780x42.9375 children: not-inline
BlockContainer <div> at (11,11) content-size 778x19.46875 children: not-inline BlockContainer <div> at (11,11) content-size 778x19.46875 children: not-inline

View file

@ -36,7 +36,7 @@
#include <LibJS/Interpreter.h> #include <LibJS/Interpreter.h>
#include <LibWeb/CSS/PreferredColorScheme.h> #include <LibWeb/CSS/PreferredColorScheme.h>
#include <LibWeb/Dump.h> #include <LibWeb/Dump.h>
#include <LibWeb/Layout/InitialContainingBlock.h> #include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Loader/ResourceLoader.h> #include <LibWeb/Loader/ResourceLoader.h>
#include <LibWebView/OutOfProcessWebView.h> #include <LibWebView/OutOfProcessWebView.h>
#include <LibWebView/WebContentClient.h> #include <LibWebView/WebContentClient.h>

View file

@ -37,7 +37,7 @@
#include <LibWeb/HTML/BrowsingContext.h> #include <LibWeb/HTML/BrowsingContext.h>
#include <LibWeb/HTML/SyntaxHighlighter/SyntaxHighlighter.h> #include <LibWeb/HTML/SyntaxHighlighter/SyntaxHighlighter.h>
#include <LibWeb/Layout/BlockContainer.h> #include <LibWeb/Layout/BlockContainer.h>
#include <LibWeb/Layout/InitialContainingBlock.h> #include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Loader/ResourceLoader.h> #include <LibWeb/Loader/ResourceLoader.h>
#include <LibWebView/OutOfProcessWebView.h> #include <LibWebView/OutOfProcessWebView.h>

View file

@ -326,7 +326,7 @@ set(SOURCES
Layout/FrameBox.cpp Layout/FrameBox.cpp
Layout/GridFormattingContext.cpp Layout/GridFormattingContext.cpp
Layout/ImageBox.cpp Layout/ImageBox.cpp
Layout/InitialContainingBlock.cpp Layout/Viewport.cpp
Layout/InlineFormattingContext.cpp Layout/InlineFormattingContext.cpp
Layout/InlineLevelIterator.cpp Layout/InlineLevelIterator.cpp
Layout/InlineNode.cpp Layout/InlineNode.cpp

View file

@ -14,7 +14,7 @@
#include <LibWeb/CSS/StyleComputer.h> #include <LibWeb/CSS/StyleComputer.h>
#include <LibWeb/DOM/Document.h> #include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Element.h> #include <LibWeb/DOM/Element.h>
#include <LibWeb/Layout/InitialContainingBlock.h> #include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Painting/PaintableBox.h> #include <LibWeb/Painting/PaintableBox.h>
#include <LibWeb/Painting/StackingContext.h> #include <LibWeb/Painting/StackingContext.h>
@ -493,9 +493,9 @@ RefPtr<StyleValue const> ResolvedCSSStyleDeclaration::style_value_for_property(L
return IdentifierStyleValue::create(ValueID::None); return IdentifierStyleValue::create(ValueID::None);
// The transform matrix is held by the StackingContext, so we need to make sure we have one first. // 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(); auto const* viewport = layout_node.document().layout_node();
VERIFY(initial_containing_block); VERIFY(viewport);
const_cast<Layout::InitialContainingBlock&>(*initial_containing_block).build_stacking_context_tree_if_needed(); const_cast<Layout::Viewport&>(*viewport).build_stacking_context_tree_if_needed();
VERIFY(layout_node.paintable()); VERIFY(layout_node.paintable());
auto const& paintable_box = verify_cast<Painting::PaintableBox const>(layout_node.paintable()); auto const& paintable_box = verify_cast<Painting::PaintableBox const>(layout_node.paintable());

View file

@ -65,8 +65,8 @@
#include <LibWeb/HighResolutionTime/TimeOrigin.h> #include <LibWeb/HighResolutionTime/TimeOrigin.h>
#include <LibWeb/Infra/Strings.h> #include <LibWeb/Infra/Strings.h>
#include <LibWeb/Layout/BlockFormattingContext.h> #include <LibWeb/Layout/BlockFormattingContext.h>
#include <LibWeb/Layout/InitialContainingBlock.h>
#include <LibWeb/Layout/TreeBuilder.h> #include <LibWeb/Layout/TreeBuilder.h>
#include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Namespace.h> #include <LibWeb/Namespace.h>
#include <LibWeb/Page/Page.h> #include <LibWeb/Page/Page.h>
#include <LibWeb/Platform/Timer.h> #include <LibWeb/Platform/Timer.h>
@ -849,7 +849,7 @@ void Document::update_layout()
if (!m_layout_root) { if (!m_layout_root) {
m_next_layout_node_serial_id = 0; m_next_layout_node_serial_id = 0;
Layout::TreeBuilder tree_builder; 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; Layout::LayoutState layout_state;
@ -858,10 +858,10 @@ void Document::update_layout()
{ {
Layout::BlockFormattingContext root_formatting_context(layout_state, *m_layout_root, nullptr); Layout::BlockFormattingContext root_formatting_context(layout_state, *m_layout_root, nullptr);
auto& icb = static_cast<Layout::InitialContainingBlock&>(*m_layout_root); auto& viewport = static_cast<Layout::Viewport&>(*m_layout_root);
auto& icb_state = layout_state.get_mutable(icb); auto& viewport_state = layout_state.get_mutable(viewport);
icb_state.set_content_width(viewport_rect.width()); viewport_state.set_content_width(viewport_rect.width());
icb_state.set_content_height(viewport_rect.height()); viewport_state.set_content_height(viewport_rect.height());
root_formatting_context.run( root_formatting_context.run(
*m_layout_root, *m_layout_root,
@ -947,14 +947,14 @@ void Document::set_visited_link_color(Color color)
m_visited_link_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) void Document::set_inspected_node(Node* node)

View file

@ -196,8 +196,8 @@ public:
virtual bool is_child_allowed(Node const&) const override; virtual bool is_child_allowed(Node const&) const override;
Layout::InitialContainingBlock const* layout_node() const; Layout::Viewport const* layout_node() const;
Layout::InitialContainingBlock* layout_node(); Layout::Viewport* layout_node();
void schedule_style_update(); void schedule_style_update();
void schedule_layout_update(); void schedule_layout_update();
@ -477,7 +477,7 @@ private:
JS::GCPtr<HTML::Window> m_window; 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_link_color;
Optional<Color> m_active_link_color; Optional<Color> m_active_link_color;

View file

@ -38,7 +38,6 @@
#include <LibWeb/Infra/CharacterTypes.h> #include <LibWeb/Infra/CharacterTypes.h>
#include <LibWeb/Infra/Strings.h> #include <LibWeb/Infra/Strings.h>
#include <LibWeb/Layout/BlockContainer.h> #include <LibWeb/Layout/BlockContainer.h>
#include <LibWeb/Layout/InitialContainingBlock.h>
#include <LibWeb/Layout/InlineNode.h> #include <LibWeb/Layout/InlineNode.h>
#include <LibWeb/Layout/ListItemBox.h> #include <LibWeb/Layout/ListItemBox.h>
#include <LibWeb/Layout/TableBox.h> #include <LibWeb/Layout/TableBox.h>
@ -46,6 +45,7 @@
#include <LibWeb/Layout/TableRowBox.h> #include <LibWeb/Layout/TableRowBox.h>
#include <LibWeb/Layout/TableRowGroupBox.h> #include <LibWeb/Layout/TableRowGroupBox.h>
#include <LibWeb/Layout/TreeBuilder.h> #include <LibWeb/Layout/TreeBuilder.h>
#include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Namespace.h> #include <LibWeb/Namespace.h>
#include <LibWeb/Page/Page.h> #include <LibWeb/Page/Page.h>
#include <LibWeb/Painting/PaintableBox.h> #include <LibWeb/Painting/PaintableBox.h>

View file

@ -35,9 +35,9 @@
#include <LibWeb/HTML/Origin.h> #include <LibWeb/HTML/Origin.h>
#include <LibWeb/HTML/Parser/HTMLParser.h> #include <LibWeb/HTML/Parser/HTMLParser.h>
#include <LibWeb/Infra/CharacterTypes.h> #include <LibWeb/Infra/CharacterTypes.h>
#include <LibWeb/Layout/InitialContainingBlock.h>
#include <LibWeb/Layout/Node.h> #include <LibWeb/Layout/Node.h>
#include <LibWeb/Layout/TextNode.h> #include <LibWeb/Layout/TextNode.h>
#include <LibWeb/Layout/Viewport.h>
namespace Web::DOM { namespace Web::DOM {

View file

@ -17,7 +17,7 @@
#include <LibWeb/DOM/Text.h> #include <LibWeb/DOM/Text.h>
#include <LibWeb/Geometry/DOMRect.h> #include <LibWeb/Geometry/DOMRect.h>
#include <LibWeb/HTML/Window.h> #include <LibWeb/HTML/Window.h>
#include <LibWeb/Layout/InitialContainingBlock.h> #include <LibWeb/Layout/Viewport.h>
namespace Web::DOM { namespace Web::DOM {

View file

@ -447,7 +447,7 @@ class CheckBox;
class FlexFormattingContext; class FlexFormattingContext;
class FormattingContext; class FormattingContext;
struct LayoutState; struct LayoutState;
class InitialContainingBlock; class Viewport;
class InlineFormattingContext; class InlineFormattingContext;
class Label; class Label;
class LabelableNode; class LabelableNode;

View file

@ -24,8 +24,8 @@
#include <LibWeb/HighResolutionTime/TimeOrigin.h> #include <LibWeb/HighResolutionTime/TimeOrigin.h>
#include <LibWeb/Infra/Strings.h> #include <LibWeb/Infra/Strings.h>
#include <LibWeb/Layout/BreakNode.h> #include <LibWeb/Layout/BreakNode.h>
#include <LibWeb/Layout/InitialContainingBlock.h>
#include <LibWeb/Layout/TextNode.h> #include <LibWeb/Layout/TextNode.h>
#include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Page/Page.h> #include <LibWeb/Page/Page.h>
#include <LibWeb/URL/URL.h> #include <LibWeb/URL/URL.h>

View file

@ -53,7 +53,7 @@
#include <LibWeb/HighResolutionTime/TimeOrigin.h> #include <LibWeb/HighResolutionTime/TimeOrigin.h>
#include <LibWeb/Infra/Base64.h> #include <LibWeb/Infra/Base64.h>
#include <LibWeb/Infra/CharacterTypes.h> #include <LibWeb/Infra/CharacterTypes.h>
#include <LibWeb/Layout/InitialContainingBlock.h> #include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Page/Page.h> #include <LibWeb/Page/Page.h>
#include <LibWeb/RequestIdleCallback/IdleDeadline.h> #include <LibWeb/RequestIdleCallback/IdleDeadline.h>
#include <LibWeb/Selection/Selection.h> #include <LibWeb/Selection/Selection.h>

View file

@ -12,7 +12,6 @@
#include <LibWeb/Layout/BlockContainer.h> #include <LibWeb/Layout/BlockContainer.h>
#include <LibWeb/Layout/BlockFormattingContext.h> #include <LibWeb/Layout/BlockFormattingContext.h>
#include <LibWeb/Layout/Box.h> #include <LibWeb/Layout/Box.h>
#include <LibWeb/Layout/InitialContainingBlock.h>
#include <LibWeb/Layout/InlineFormattingContext.h> #include <LibWeb/Layout/InlineFormattingContext.h>
#include <LibWeb/Layout/LineBuilder.h> #include <LibWeb/Layout/LineBuilder.h>
#include <LibWeb/Layout/ListItemBox.h> #include <LibWeb/Layout/ListItemBox.h>
@ -20,6 +19,7 @@
#include <LibWeb/Layout/ReplacedBox.h> #include <LibWeb/Layout/ReplacedBox.h>
#include <LibWeb/Layout/TableBox.h> #include <LibWeb/Layout/TableBox.h>
#include <LibWeb/Layout/TableWrapper.h> #include <LibWeb/Layout/TableWrapper.h>
#include <LibWeb/Layout/Viewport.h>
namespace Web::Layout { namespace Web::Layout {
@ -38,11 +38,6 @@ BlockFormattingContext::~BlockFormattingContext()
} }
} }
bool BlockFormattingContext::is_initial() const
{
return is<InitialContainingBlock>(root());
}
CSSPixels BlockFormattingContext::automatic_content_height() const CSSPixels BlockFormattingContext::automatic_content_height() const
{ {
return compute_auto_height_for_block_formatting_context_root(root()); 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) void BlockFormattingContext::run(Box const&, LayoutMode layout_mode, AvailableSpace const& available_space)
{ {
if (is_initial()) { if (is<Viewport>(root())) {
layout_initial_containing_block(layout_mode, available_space); layout_viewport(layout_mode, available_space);
return; 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 viewport_rect = root().browsing_context().viewport_rect();
auto& icb = verify_cast<Layout::InitialContainingBlock>(root()); auto& viewport = verify_cast<Layout::Viewport>(root());
auto& icb_state = m_state.get_mutable(icb); auto& viewport_state = m_state.get_mutable(viewport);
if (root().children_are_inline()) if (root().children_are_inline())
layout_inline_children(root(), layout_mode, available_space); 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 bottom_edge = 0;
CSSPixels right_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()) { if (bottom_edge >= viewport_rect.height() || right_edge >= viewport_rect.width()) {
// FIXME: Move overflow data to LayoutState! // 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; overflow_data.scrollable_overflow_rect = viewport_rect;
// NOTE: The edges are *within* the rectangle, so we add 1 to get the width and height. // 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); overflow_data.scrollable_overflow_rect.set_size(right_edge + 1, bottom_edge + 1);

View file

@ -24,8 +24,6 @@ public:
virtual void run(Box const&, LayoutMode, AvailableSpace const&) override; virtual void run(Box const&, LayoutMode, AvailableSpace const&) override;
virtual CSSPixels automatic_content_height() 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& left_side_floats() const { return m_left_floats; }
auto const& right_side_floats() const { return m_right_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&); 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_block_level_children(BlockContainer const&, LayoutMode, AvailableSpace const&);
void layout_inline_children(BlockContainer const&, LayoutMode, AvailableSpace const&); void layout_inline_children(BlockContainer const&, LayoutMode, AvailableSpace const&);

View file

@ -13,9 +13,9 @@
#include <LibWeb/Layout/BlockFormattingContext.h> #include <LibWeb/Layout/BlockFormattingContext.h>
#include <LibWeb/Layout/Box.h> #include <LibWeb/Layout/Box.h>
#include <LibWeb/Layout/FlexFormattingContext.h> #include <LibWeb/Layout/FlexFormattingContext.h>
#include <LibWeb/Layout/InitialContainingBlock.h>
#include <LibWeb/Layout/ReplacedBox.h> #include <LibWeb/Layout/ReplacedBox.h>
#include <LibWeb/Layout/TextNode.h> #include <LibWeb/Layout/TextNode.h>
#include <LibWeb/Layout/Viewport.h>
namespace Web::Layout { namespace Web::Layout {

View file

@ -10,13 +10,13 @@
#include <LibWeb/Layout/FlexFormattingContext.h> #include <LibWeb/Layout/FlexFormattingContext.h>
#include <LibWeb/Layout/FormattingContext.h> #include <LibWeb/Layout/FormattingContext.h>
#include <LibWeb/Layout/GridFormattingContext.h> #include <LibWeb/Layout/GridFormattingContext.h>
#include <LibWeb/Layout/InitialContainingBlock.h>
#include <LibWeb/Layout/ReplacedBox.h> #include <LibWeb/Layout/ReplacedBox.h>
#include <LibWeb/Layout/SVGFormattingContext.h> #include <LibWeb/Layout/SVGFormattingContext.h>
#include <LibWeb/Layout/SVGSVGBox.h> #include <LibWeb/Layout/SVGSVGBox.h>
#include <LibWeb/Layout/TableBox.h> #include <LibWeb/Layout/TableBox.h>
#include <LibWeb/Layout/TableCellBox.h> #include <LibWeb/Layout/TableCellBox.h>
#include <LibWeb/Layout/TableFormattingContext.h> #include <LibWeb/Layout/TableFormattingContext.h>
#include <LibWeb/Layout/Viewport.h>
namespace Web::Layout { namespace Web::Layout {

View file

@ -7,7 +7,7 @@
#include <LibWeb/DOM/Document.h> #include <LibWeb/DOM/Document.h>
#include <LibWeb/HTML/BrowsingContext.h> #include <LibWeb/HTML/BrowsingContext.h>
#include <LibWeb/Layout/FrameBox.h> #include <LibWeb/Layout/FrameBox.h>
#include <LibWeb/Layout/InitialContainingBlock.h> #include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Painting/NestedBrowsingContextPaintable.h> #include <LibWeb/Painting/NestedBrowsingContextPaintable.h>
namespace Web::Layout { namespace Web::Layout {

View file

@ -7,10 +7,10 @@
#include <LibGUI/Event.h> #include <LibGUI/Event.h>
#include <LibWeb/DOM/Document.h> #include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Element.h> #include <LibWeb/DOM/Element.h>
#include <LibWeb/Layout/InitialContainingBlock.h>
#include <LibWeb/Layout/Label.h> #include <LibWeb/Layout/Label.h>
#include <LibWeb/Layout/LabelableNode.h> #include <LibWeb/Layout/LabelableNode.h>
#include <LibWeb/Layout/TextNode.h> #include <LibWeb/Layout/TextNode.h>
#include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Painting/LabelablePaintable.h> #include <LibWeb/Painting/LabelablePaintable.h>
namespace Web::Layout { namespace Web::Layout {

View file

@ -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] = adopt_own(*new UsedValues);
used_values_per_layout_node[serial_id]->set_node(const_cast<NodeWithStyleAndBoxModelMetrics&>(box), containing_block_used_values); 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]; 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] = 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); const_cast<LayoutState*>(this)->used_values_per_layout_node[serial_id]->set_node(const_cast<NodeWithStyleAndBoxModelMetrics&>(box), containing_block_used_values);

View file

@ -6,10 +6,10 @@
#include <AK/Utf8View.h> #include <AK/Utf8View.h>
#include <LibWeb/DOM/Range.h> #include <LibWeb/DOM/Range.h>
#include <LibWeb/Layout/InitialContainingBlock.h>
#include <LibWeb/Layout/LayoutState.h> #include <LibWeb/Layout/LayoutState.h>
#include <LibWeb/Layout/LineBoxFragment.h> #include <LibWeb/Layout/LineBoxFragment.h>
#include <LibWeb/Layout/TextNode.h> #include <LibWeb/Layout/TextNode.h>
#include <LibWeb/Layout/Viewport.h>
#include <ctype.h> #include <ctype.h>
namespace Web::Layout { namespace Web::Layout {

View file

@ -11,10 +11,10 @@
#include <LibWeb/HTML/HTMLHtmlElement.h> #include <LibWeb/HTML/HTMLHtmlElement.h>
#include <LibWeb/Layout/BlockContainer.h> #include <LibWeb/Layout/BlockContainer.h>
#include <LibWeb/Layout/FormattingContext.h> #include <LibWeb/Layout/FormattingContext.h>
#include <LibWeb/Layout/InitialContainingBlock.h>
#include <LibWeb/Layout/Node.h> #include <LibWeb/Layout/Node.h>
#include <LibWeb/Layout/TableBox.h> #include <LibWeb/Layout/TableBox.h>
#include <LibWeb/Layout/TextNode.h> #include <LibWeb/Layout/TextNode.h>
#include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Platform/FontPlugin.h> #include <LibWeb/Platform/FontPlugin.h>
namespace Web::Layout { namespace Web::Layout {
@ -62,7 +62,7 @@ bool Node::can_contain_boxes_with_position_absolute() const
if (computed_values().position() != CSS::Position::Static) if (computed_values().position() != CSS::Position::Static)
return true; return true;
if (is<InitialContainingBlock>(*this)) if (is<Viewport>(*this))
return true; return true;
// https://w3c.github.io/csswg-drafts/css-transforms-1/#propdef-transform // https://w3c.github.io/csswg-drafts/css-transforms-1/#propdef-transform
@ -163,13 +163,13 @@ HTML::BrowsingContext& Node::browsing_context()
return *m_browsing_context; return *m_browsing_context;
} }
InitialContainingBlock const& Node::root() const Viewport const& Node::root() const
{ {
VERIFY(document().layout_node()); VERIFY(document().layout_node());
return *document().layout_node(); return *document().layout_node();
} }
InitialContainingBlock& Node::root() Viewport& Node::root()
{ {
VERIFY(document().layout_node()); VERIFY(document().layout_node());
return *document().layout_node(); return *document().layout_node();

View file

@ -62,8 +62,8 @@ public:
HTML::BrowsingContext const& browsing_context() const; HTML::BrowsingContext const& browsing_context() const;
HTML::BrowsingContext& browsing_context(); HTML::BrowsingContext& browsing_context();
InitialContainingBlock const& root() const; Viewport const& root() const;
InitialContainingBlock& root(); Viewport& root();
bool is_root_element() const; bool is_root_element() const;
@ -86,7 +86,7 @@ public:
virtual bool is_block_container() const { return false; } virtual bool is_block_container() const { return false; }
virtual bool is_break_node() const { return false; } virtual bool is_break_node() const { return false; }
virtual bool is_text_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_box() const { return false; }
virtual bool is_svg_geometry_box() const { return false; } virtual bool is_svg_geometry_box() const { return false; }
virtual bool is_label() const { return false; } virtual bool is_label() const { return false; }

View file

@ -16,7 +16,6 @@
#include <LibWeb/Dump.h> #include <LibWeb/Dump.h>
#include <LibWeb/HTML/HTMLInputElement.h> #include <LibWeb/HTML/HTMLInputElement.h>
#include <LibWeb/HTML/HTMLProgressElement.h> #include <LibWeb/HTML/HTMLProgressElement.h>
#include <LibWeb/Layout/InitialContainingBlock.h>
#include <LibWeb/Layout/ListItemBox.h> #include <LibWeb/Layout/ListItemBox.h>
#include <LibWeb/Layout/ListItemMarkerBox.h> #include <LibWeb/Layout/ListItemMarkerBox.h>
#include <LibWeb/Layout/Node.h> #include <LibWeb/Layout/Node.h>
@ -27,6 +26,7 @@
#include <LibWeb/Layout/TableWrapper.h> #include <LibWeb/Layout/TableWrapper.h>
#include <LibWeb/Layout/TextNode.h> #include <LibWeb/Layout/TextNode.h>
#include <LibWeb/Layout/TreeBuilder.h> #include <LibWeb/Layout/TreeBuilder.h>
#include <LibWeb/Layout/Viewport.h>
#include <LibWeb/SVG/SVGForeignObjectElement.h> #include <LibWeb/SVG/SVGForeignObjectElement.h>
namespace Web::Layout { 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)) { } else if (is<DOM::Document>(dom_node)) {
style = style_computer.create_document_style(); style = style_computer.create_document_style();
display = style->display(); 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)) { } else if (is<DOM::Text>(dom_node)) {
layout_node = document.heap().allocate_without_realm<Layout::TextNode>(document, static_cast<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); display = CSS::Display(CSS::Display::Outside::Inline, CSS::Display::Inside::Flow);

View file

@ -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 * SPDX-License-Identifier: BSD-2-Clause
*/ */
#include <LibWeb/DOM/Range.h> #include <LibWeb/DOM/Range.h>
#include <LibWeb/Dump.h> #include <LibWeb/Dump.h>
#include <LibWeb/Layout/InitialContainingBlock.h> #include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Painting/PaintableBox.h> #include <LibWeb/Painting/PaintableBox.h>
#include <LibWeb/Painting/StackingContext.h> #include <LibWeb/Painting/StackingContext.h>
namespace Web::Layout { 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)) : 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(); 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()) if (paint_box()->stacking_context())
return; return;
build_stacking_context_tree(); 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)); 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(); 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(); 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())); 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); 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. // 1. Start by resetting the selection state of all layout nodes to None.
for_each_in_inclusive_subtree([&](auto& layout_node) { for_each_in_inclusive_subtree([&](auto& layout_node) {

View file

@ -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 * SPDX-License-Identifier: BSD-2-Clause
*/ */
@ -12,12 +12,12 @@
namespace Web::Layout { namespace Web::Layout {
class InitialContainingBlock final : public BlockContainer { class Viewport final : public BlockContainer {
JS_CELL(InitialContainingBlock, BlockContainer); JS_CELL(Viewport, BlockContainer);
public: public:
explicit InitialContainingBlock(DOM::Document&, NonnullRefPtr<CSS::StyleProperties>); explicit Viewport(DOM::Document&, NonnullRefPtr<CSS::StyleProperties>);
virtual ~InitialContainingBlock() override; virtual ~Viewport() override;
const DOM::Document& dom_node() const { return static_cast<const DOM::Document&>(*Node::dom_node()); } const DOM::Document& dom_node() const { return static_cast<const DOM::Document&>(*Node::dom_node()); }
@ -30,10 +30,10 @@ public:
private: private:
void build_stacking_context_tree(); 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<> template<>
inline bool Node::fast_is<InitialContainingBlock>() const { return is_initial_containing_block_box(); } inline bool Node::fast_is<Viewport>() const { return is_viewport(); }
} }

View file

@ -11,7 +11,7 @@
#include <LibWeb/DOM/Range.h> #include <LibWeb/DOM/Range.h>
#include <LibWeb/DOM/Text.h> #include <LibWeb/DOM/Text.h>
#include <LibWeb/HTML/BrowsingContext.h> #include <LibWeb/HTML/BrowsingContext.h>
#include <LibWeb/Layout/InitialContainingBlock.h> #include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Page/EditEventHandler.h> #include <LibWeb/Page/EditEventHandler.h>
namespace Web { namespace Web {

View file

@ -13,7 +13,7 @@
#include <LibWeb/HTML/HTMLAnchorElement.h> #include <LibWeb/HTML/HTMLAnchorElement.h>
#include <LibWeb/HTML/HTMLIFrameElement.h> #include <LibWeb/HTML/HTMLIFrameElement.h>
#include <LibWeb/HTML/HTMLImageElement.h> #include <LibWeb/HTML/HTMLImageElement.h>
#include <LibWeb/Layout/InitialContainingBlock.h> #include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Page/EventHandler.h> #include <LibWeb/Page/EventHandler.h>
#include <LibWeb/Page/Page.h> #include <LibWeb/Page/Page.h>
#include <LibWeb/Painting/PaintableBox.h> #include <LibWeb/Painting/PaintableBox.h>
@ -119,14 +119,14 @@ EventHandler::EventHandler(Badge<HTML::BrowsingContext>, HTML::BrowsingContext&
EventHandler::~EventHandler() = default; EventHandler::~EventHandler() = default;
Layout::InitialContainingBlock const* EventHandler::layout_root() const Layout::Viewport const* EventHandler::layout_root() const
{ {
if (!m_browsing_context.active_document()) if (!m_browsing_context.active_document())
return nullptr; return nullptr;
return m_browsing_context.active_document()->layout_node(); return m_browsing_context.active_document()->layout_node();
} }
Layout::InitialContainingBlock* EventHandler::layout_root() Layout::Viewport* EventHandler::layout_root()
{ {
if (!m_browsing_context.active_document()) if (!m_browsing_context.active_document())
return nullptr; return nullptr;

View file

@ -44,8 +44,8 @@ private:
CSSPixelPoint compute_mouse_event_client_offset(CSSPixelPoint event_page_position) const; CSSPixelPoint compute_mouse_event_client_offset(CSSPixelPoint event_page_position) const;
CSSPixelPoint compute_mouse_event_page_offset(CSSPixelPoint event_client_offset) const; CSSPixelPoint compute_mouse_event_page_offset(CSSPixelPoint event_client_offset) const;
Layout::InitialContainingBlock* layout_root(); Layout::Viewport* layout_root();
Layout::InitialContainingBlock const* layout_root() const; Layout::Viewport const* layout_root() const;
Painting::PaintableBox* paint_root(); Painting::PaintableBox* paint_root();
Painting::PaintableBox const* paint_root() const; Painting::PaintableBox const* paint_root() const;

View file

@ -8,8 +8,8 @@
#include <LibGfx/AntiAliasingPainter.h> #include <LibGfx/AntiAliasingPainter.h>
#include <LibGfx/Painter.h> #include <LibGfx/Painter.h>
#include <LibWeb/Layout/InitialContainingBlock.h>
#include <LibWeb/Layout/Node.h> #include <LibWeb/Layout/Node.h>
#include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Painting/BackgroundPainting.h> #include <LibWeb/Painting/BackgroundPainting.h>
#include <LibWeb/Painting/BorderRadiusCornerClipper.h> #include <LibWeb/Painting/BorderRadiusCornerClipper.h>
#include <LibWeb/Painting/GradientPainting.h> #include <LibWeb/Painting/GradientPainting.h>

View file

@ -7,7 +7,7 @@
#include <AK/Debug.h> #include <AK/Debug.h>
#include <LibWeb/HTML/BrowsingContextContainer.h> #include <LibWeb/HTML/BrowsingContextContainer.h>
#include <LibWeb/Layout/FrameBox.h> #include <LibWeb/Layout/FrameBox.h>
#include <LibWeb/Layout/InitialContainingBlock.h> #include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Painting/BorderRadiusCornerClipper.h> #include <LibWeb/Painting/BorderRadiusCornerClipper.h>
#include <LibWeb/Painting/NestedBrowsingContextPaintable.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.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()) }); 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.set_device_viewport_rect(old_viewport_rect);
context.painter().restore(); context.painter().restore();

View file

@ -11,7 +11,7 @@
#include <LibWeb/FontCache.h> #include <LibWeb/FontCache.h>
#include <LibWeb/HTML/HTMLHtmlElement.h> #include <LibWeb/HTML/HTMLHtmlElement.h>
#include <LibWeb/Layout/BlockContainer.h> #include <LibWeb/Layout/BlockContainer.h>
#include <LibWeb/Layout/InitialContainingBlock.h> #include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Painting/BackgroundPainting.h> #include <LibWeb/Painting/BackgroundPainting.h>
#include <LibWeb/Painting/FilterPainting.h> #include <LibWeb/Painting/FilterPainting.h>
#include <LibWeb/Painting/PaintableBox.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()) 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()); 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(); VERIFY_NOT_REACHED();
} }
@ -686,8 +686,8 @@ Optional<HitTestResult> PaintableBox::hit_test(CSSPixelPoint position, HitTestTy
if (!is_visible()) if (!is_visible())
return {}; return {};
if (layout_box().is_initial_containing_block_box()) { if (layout_box().is_viewport()) {
const_cast<Layout::InitialContainingBlock&>(static_cast<Layout::InitialContainingBlock const&>(layout_box())).build_stacking_context_tree_if_needed(); const_cast<Layout::Viewport&>(static_cast<Layout::Viewport const&>(layout_box())).build_stacking_context_tree_if_needed();
return stacking_context()->hit_test(position, type); return stacking_context()->hit_test(position, type);
} }

View file

@ -14,8 +14,8 @@
#include <LibGfx/Painter.h> #include <LibGfx/Painter.h>
#include <LibGfx/Rect.h> #include <LibGfx/Rect.h>
#include <LibWeb/Layout/Box.h> #include <LibWeb/Layout/Box.h>
#include <LibWeb/Layout/InitialContainingBlock.h>
#include <LibWeb/Layout/ReplacedBox.h> #include <LibWeb/Layout/ReplacedBox.h>
#include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Painting/PaintableBox.h> #include <LibWeb/Painting/PaintableBox.h>
#include <LibWeb/Painting/StackingContext.h> #include <LibWeb/Painting/StackingContext.h>

View file

@ -24,7 +24,7 @@
#include <LibWeb/HTML/Scripting/ClassicScript.h> #include <LibWeb/HTML/Scripting/ClassicScript.h>
#include <LibWeb/HTML/Storage.h> #include <LibWeb/HTML/Storage.h>
#include <LibWeb/HTML/Window.h> #include <LibWeb/HTML/Window.h>
#include <LibWeb/Layout/InitialContainingBlock.h> #include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Loader/ContentFilter.h> #include <LibWeb/Loader/ContentFilter.h>
#include <LibWeb/Loader/ProxyMappings.h> #include <LibWeb/Loader/ProxyMappings.h>
#include <LibWeb/Loader/ResourceLoader.h> #include <LibWeb/Loader/ResourceLoader.h>
@ -204,15 +204,15 @@ void ConnectionFromClient::debug_request(DeprecatedString const& request, Deprec
if (request == "dump-layout-tree") { if (request == "dump-layout-tree") {
if (auto* doc = page().top_level_browsing_context().active_document()) { if (auto* doc = page().top_level_browsing_context().active_document()) {
if (auto* icb = doc->layout_node()) if (auto* viewport = doc->layout_node())
Web::dump_tree(*icb); Web::dump_tree(*viewport);
} }
} }
if (request == "dump-stacking-context-tree") { if (request == "dump-stacking-context-tree") {
if (auto* doc = page().top_level_browsing_context().active_document()) { if (auto* doc = page().top_level_browsing_context().active_document()) {
if (auto* icb = doc->layout_node()) { if (auto* viewport = doc->layout_node()) {
if (auto* stacking_context = icb->paint_box()->stacking_context()) if (auto* stacking_context = viewport->paint_box()->stacking_context())
stacking_context->dump(); stacking_context->dump();
} }
} }

View file

@ -12,7 +12,7 @@
#include <LibGfx/SystemTheme.h> #include <LibGfx/SystemTheme.h>
#include <LibWeb/Cookie/ParsedCookie.h> #include <LibWeb/Cookie/ParsedCookie.h>
#include <LibWeb/HTML/BrowsingContext.h> #include <LibWeb/HTML/BrowsingContext.h>
#include <LibWeb/Layout/InitialContainingBlock.h> #include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Painting/PaintableBox.h> #include <LibWeb/Painting/PaintableBox.h>
#include <LibWeb/Platform/Timer.h> #include <LibWeb/Platform/Timer.h>
#include <WebContent/WebContentClientEndpoint.h> #include <WebContent/WebContentClientEndpoint.h>
@ -96,7 +96,7 @@ ErrorOr<void> PageHost::connect_to_webdriver(DeprecatedString const& webdriver_i
return {}; return {};
} }
Web::Layout::InitialContainingBlock* PageHost::layout_root() Web::Layout::Viewport* PageHost::layout_root()
{ {
auto* document = page().top_level_browsing_context().active_document(); auto* document = page().top_level_browsing_context().active_document();
if (!document) if (!document)

View file

@ -101,7 +101,7 @@ private:
explicit PageHost(ConnectionFromClient&); explicit PageHost(ConnectionFromClient&);
Web::Layout::InitialContainingBlock* layout_root(); Web::Layout::Viewport* layout_root();
void setup_palette(); void setup_palette();
ConnectionFromClient& m_client; ConnectionFromClient& m_client;

View file

@ -35,7 +35,7 @@
#include <LibWeb/Cookie/ParsedCookie.h> #include <LibWeb/Cookie/ParsedCookie.h>
#include <LibWeb/DOM/Document.h> #include <LibWeb/DOM/Document.h>
#include <LibWeb/HTML/BrowsingContext.h> #include <LibWeb/HTML/BrowsingContext.h>
#include <LibWeb/Layout/InitialContainingBlock.h> #include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Loader/ResourceLoader.h> #include <LibWeb/Loader/ResourceLoader.h>
#include <LibWeb/Page/Page.h> #include <LibWeb/Page/Page.h>
#include <LibWeb/Painting/PaintableBox.h> #include <LibWeb/Painting/PaintableBox.h>
@ -58,7 +58,7 @@ public:
virtual Web::Page& page() override { return *m_page; } virtual Web::Page& page() override { return *m_page; }
virtual Web::Page const& page() const override { return *m_page; } virtual Web::Page const& page() const override { return *m_page; }
Web::Layout::InitialContainingBlock* layout_root() Web::Layout::Viewport* layout_root()
{ {
auto* document = page().top_level_browsing_context().active_document(); auto* document = page().top_level_browsing_context().active_document();
if (!document) if (!document)