summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Layout/AvailableSpace.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-09-27 15:29:17 +0200
committerAndreas Kling <kling@serenityos.org>2022-10-02 21:14:02 +0200
commit9c44634ca58fc940d0661f8c9427043fa5ff3194 (patch)
tree73aaa311b525d16172203433c42563944fdb7436 /Userland/Libraries/LibWeb/Layout/AvailableSpace.cpp
parentb55c4ccdf7b77e137fe4079eb6707a3b801eeaea (diff)
downloadserenity-9c44634ca58fc940d0661f8c9427043fa5ff3194.zip
LibWeb: Reorganize layout algorithms around available space
This is a big and messy change, and here's the gist: - AvaliableSpace is now 2x AvailableSize (width and height) - Layout algorithms are redesigned around the idea of available space - When doing layout across nested formatting contexts, the parent context tells the child context how much space is available for the child's root box in both axes. - "Available space" replaces "containing block width" in most places. - The width and height in a box's UsedValues are considered to be definite after they're assigned to. Marking something as having definite size is no longer a separate step, This probably introduces various regressions, but the big win here is that our layout system now works with available space, just like the specs are written. Fixing issues will be much easier going forward, since you don't need to do nearly as much conversion from "spec logic" to "LibWeb logic" as you previously did.
Diffstat (limited to 'Userland/Libraries/LibWeb/Layout/AvailableSpace.cpp')
-rw-r--r--Userland/Libraries/LibWeb/Layout/AvailableSpace.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/AvailableSpace.cpp b/Userland/Libraries/LibWeb/Layout/AvailableSpace.cpp
index 026fe90311..605da0780c 100644
--- a/Userland/Libraries/LibWeb/Layout/AvailableSpace.cpp
+++ b/Userland/Libraries/LibWeb/Layout/AvailableSpace.cpp
@@ -9,27 +9,27 @@
namespace Web::Layout {
-AvailableSpace AvailableSpace::make_definite(float value)
+AvailableSize AvailableSize::make_definite(float value)
{
- return AvailableSpace { Type::Definite, value };
+ return AvailableSize { Type::Definite, value };
}
-AvailableSpace AvailableSpace::make_indefinite()
+AvailableSize AvailableSize::make_indefinite()
{
- return AvailableSpace { Type::Indefinite, INFINITY };
+ return AvailableSize { Type::Indefinite, INFINITY };
}
-AvailableSpace AvailableSpace::make_min_content()
+AvailableSize AvailableSize::make_min_content()
{
- return AvailableSpace { Type::MinContent, 0 };
+ return AvailableSize { Type::MinContent, 0 };
}
-AvailableSpace AvailableSpace::make_max_content()
+AvailableSize AvailableSize::make_max_content()
{
- return AvailableSpace { Type::MaxContent, INFINITY };
+ return AvailableSize { Type::MaxContent, INFINITY };
}
-String AvailableSpace::to_string() const
+String AvailableSize::to_string() const
{
switch (m_type) {
case Type::Definite:
@@ -44,7 +44,12 @@ String AvailableSpace::to_string() const
VERIFY_NOT_REACHED();
}
-AvailableSpace::AvailableSpace(Type type, float value)
+String AvailableSpace::to_string() const
+{
+ return String::formatted("{} x {}", width, height);
+}
+
+AvailableSize::AvailableSize(Type type, float value)
: m_type(type)
, m_value(value)
{