|
1 | 1 | /*
|
2 | 2 | * Copyright (c) 2018-2023, Andreas Kling <[email protected]>
|
3 | 3 | * Copyright (c) 2021-2023, Sam Atkins <[email protected]>
|
| 4 | + * Copyright (c) 2025, Jelle Raaijmakers <[email protected]> |
4 | 5 | *
|
5 | 6 | * SPDX-License-Identifier: BSD-2-Clause
|
6 | 7 | */
|
|
13 | 14 | #include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
|
14 | 15 | #include <LibWeb/CSS/StyleValues/IntegerStyleValue.h>
|
15 | 16 | #include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
|
16 |
| -#include <LibWeb/CSS/StyleValues/MathDepthStyleValue.h> |
17 | 17 | #include <LibWeb/CSS/StyleValues/NumberStyleValue.h>
|
18 | 18 | #include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>
|
19 | 19 | #include <LibWeb/CSS/StyleValues/RatioStyleValue.h>
|
|
30 | 30 | #include <LibWeb/Layout/TableWrapper.h>
|
31 | 31 | #include <LibWeb/Layout/TextNode.h>
|
32 | 32 | #include <LibWeb/Layout/Viewport.h>
|
33 |
| -#include <LibWeb/Platform/FontPlugin.h> |
34 | 33 |
|
35 | 34 | namespace Web::Layout {
|
36 | 35 |
|
@@ -1275,4 +1274,52 @@ CSS::UserSelect Node::user_select_used_value() const
|
1275 | 1274 | return computed_value;
|
1276 | 1275 | }
|
1277 | 1276 |
|
| 1277 | +template<typename Callable> |
| 1278 | +static CSSPixelRect united_rect_for_continuation_chain(NodeWithStyleAndBoxModelMetrics const& start, Callable get_rect) |
| 1279 | +{ |
| 1280 | + // Combine the absolute border box rects of all paintables of all nodes in the continuation chain. Without this, we |
| 1281 | + // calculate the wrong border box rect for inline nodes that were split because of block elements. |
| 1282 | + Optional<CSSPixelRect> result; |
| 1283 | + for (auto* node = &start; node; node = node->continuation_of_node()) { |
| 1284 | + for (auto const& paintable : node->paintables()) { |
| 1285 | + if (!is<Painting::PaintableBox>(paintable)) |
| 1286 | + continue; |
| 1287 | + auto const& paintable_box = static_cast<Painting::PaintableBox const&>(paintable); |
| 1288 | + auto paintable_border_box_rect = get_rect(paintable_box); |
| 1289 | + if (!result.has_value()) |
| 1290 | + result = paintable_border_box_rect; |
| 1291 | + else if (!paintable_border_box_rect.is_empty()) |
| 1292 | + result->unite(paintable_border_box_rect); |
| 1293 | + } |
| 1294 | + } |
| 1295 | + return result.value_or({}); |
| 1296 | +} |
| 1297 | + |
| 1298 | +CSSPixelRect NodeWithStyleAndBoxModelMetrics::absolute_border_box_rect() const |
| 1299 | +{ |
| 1300 | + return united_rect_for_continuation_chain(*this, [](auto const& paintable_box) { |
| 1301 | + return paintable_box.absolute_border_box_rect(); |
| 1302 | + }); |
| 1303 | +} |
| 1304 | + |
| 1305 | +CSSPixelRect NodeWithStyleAndBoxModelMetrics::absolute_content_rect() const |
| 1306 | +{ |
| 1307 | + return united_rect_for_continuation_chain(*this, [](auto const& paintable_box) { |
| 1308 | + return paintable_box.absolute_rect(); |
| 1309 | + }); |
| 1310 | +} |
| 1311 | + |
| 1312 | +CSSPixelRect NodeWithStyleAndBoxModelMetrics::absolute_padding_box_rect() const |
| 1313 | +{ |
| 1314 | + return united_rect_for_continuation_chain(*this, [](auto const& paintable_box) { |
| 1315 | + return paintable_box.absolute_padding_box_rect(); |
| 1316 | + }); |
| 1317 | +} |
| 1318 | + |
| 1319 | +void NodeWithStyleAndBoxModelMetrics::visit_edges(Cell::Visitor& visitor) |
| 1320 | +{ |
| 1321 | + Base::visit_edges(visitor); |
| 1322 | + visitor.visit(m_continuation_of_node); |
| 1323 | +} |
| 1324 | + |
1278 | 1325 | }
|
0 commit comments