StackingContext.cpp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. /*
  2. * Copyright (c) 2020-2022, Andreas Kling <kling@serenityos.org>
  3. * Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #include <AK/Debug.h>
  8. #include <AK/QuickSort.h>
  9. #include <AK/StringBuilder.h>
  10. #include <LibGfx/AffineTransform.h>
  11. #include <LibGfx/Matrix4x4.h>
  12. #include <LibGfx/Rect.h>
  13. #include <LibWeb/CSS/ComputedValues.h>
  14. #include <LibWeb/CSS/StyleValues/TransformationStyleValue.h>
  15. #include <LibWeb/Layout/Box.h>
  16. #include <LibWeb/Layout/ReplacedBox.h>
  17. #include <LibWeb/Layout/Viewport.h>
  18. #include <LibWeb/Painting/PaintableBox.h>
  19. #include <LibWeb/Painting/SVGPaintable.h>
  20. #include <LibWeb/Painting/StackingContext.h>
  21. #include <LibWeb/Painting/TableBordersPainting.h>
  22. #include <LibWeb/SVG/SVGMaskElement.h>
  23. namespace Web::Painting {
  24. static void paint_node(Paintable const& paintable, PaintContext& context, PaintPhase phase)
  25. {
  26. paintable.before_paint(context, phase);
  27. paintable.paint(context, phase);
  28. paintable.after_paint(context, phase);
  29. }
  30. StackingContext::StackingContext(Paintable& paintable, StackingContext* parent, size_t index_in_tree_order)
  31. : m_paintable(paintable)
  32. , m_parent(parent)
  33. , m_index_in_tree_order(index_in_tree_order)
  34. {
  35. VERIFY(m_parent != this);
  36. if (m_parent)
  37. m_parent->m_children.append(this);
  38. }
  39. void StackingContext::sort()
  40. {
  41. quick_sort(m_children, [](auto& a, auto& b) {
  42. auto a_z_index = a->paintable().computed_values().z_index().value_or(0);
  43. auto b_z_index = b->paintable().computed_values().z_index().value_or(0);
  44. if (a_z_index == b_z_index)
  45. return a->m_index_in_tree_order < b->m_index_in_tree_order;
  46. return a_z_index < b_z_index;
  47. });
  48. for (auto* child : m_children)
  49. child->sort();
  50. }
  51. static PaintPhase to_paint_phase(StackingContext::StackingContextPaintPhase phase)
  52. {
  53. // There are not a fully correct mapping since some stacking context phases are combined.
  54. switch (phase) {
  55. case StackingContext::StackingContextPaintPhase::Floats:
  56. case StackingContext::StackingContextPaintPhase::BackgroundAndBordersForInlineLevelAndReplaced:
  57. case StackingContext::StackingContextPaintPhase::BackgroundAndBorders:
  58. return PaintPhase::Background;
  59. case StackingContext::StackingContextPaintPhase::Foreground:
  60. return PaintPhase::Foreground;
  61. case StackingContext::StackingContextPaintPhase::FocusAndOverlay:
  62. return PaintPhase::Overlay;
  63. default:
  64. VERIFY_NOT_REACHED();
  65. }
  66. }
  67. void StackingContext::paint_node_as_stacking_context(Paintable const& paintable, PaintContext& context)
  68. {
  69. paint_node(paintable, context, PaintPhase::Background);
  70. paint_node(paintable, context, PaintPhase::Border);
  71. paint_descendants(context, paintable, StackingContextPaintPhase::BackgroundAndBorders);
  72. paint_descendants(context, paintable, StackingContextPaintPhase::Floats);
  73. paint_descendants(context, paintable, StackingContextPaintPhase::BackgroundAndBordersForInlineLevelAndReplaced);
  74. paint_node(paintable, context, PaintPhase::Foreground);
  75. paint_descendants(context, paintable, StackingContextPaintPhase::Foreground);
  76. paint_node(paintable, context, PaintPhase::Outline);
  77. paint_node(paintable, context, PaintPhase::Overlay);
  78. paint_descendants(context, paintable, StackingContextPaintPhase::FocusAndOverlay);
  79. }
  80. void StackingContext::paint_descendants(PaintContext& context, Paintable const& paintable, StackingContextPaintPhase phase)
  81. {
  82. paintable.before_children_paint(context, to_paint_phase(phase));
  83. paintable.for_each_child([&context, phase](auto& child) {
  84. auto* stacking_context = child.stacking_context();
  85. auto const& z_index = child.computed_values().z_index();
  86. // NOTE: Grid specification https://www.w3.org/TR/css-grid-2/#z-order says that grid items should be treated
  87. // the same way as CSS2 defines for inline-blocks:
  88. // "For each one of these, treat the element as if it created a new stacking context, but any positioned
  89. // descendants and descendants which actually create a new stacking context should be considered part of
  90. // the parent stacking context, not this new one."
  91. auto should_be_treated_as_stacking_context = child.layout_node().is_grid_item() && !z_index.has_value();
  92. if (should_be_treated_as_stacking_context) {
  93. // FIXME: This may not be fully correct with respect to the paint phases.
  94. if (phase == StackingContextPaintPhase::Foreground)
  95. paint_node_as_stacking_context(child, context);
  96. return;
  97. }
  98. if (stacking_context && z_index.has_value())
  99. return;
  100. if (child.is_positioned() && !z_index.has_value())
  101. return;
  102. if (stacking_context) {
  103. // FIXME: This may not be fully correct with respect to the paint phases.
  104. if (phase == StackingContextPaintPhase::Foreground) {
  105. paint_child(context, *stacking_context);
  106. }
  107. // Note: Don't further recurse into descendants as paint_child() will do that.
  108. return;
  109. }
  110. bool child_is_inline_or_replaced = child.is_inline() || is<Layout::ReplacedBox>(child);
  111. switch (phase) {
  112. case StackingContextPaintPhase::BackgroundAndBorders:
  113. if (!child_is_inline_or_replaced && !child.is_floating()) {
  114. paint_node(child, context, PaintPhase::Background);
  115. bool is_table_with_collapsed_borders = child.display().is_table_inside() && child.computed_values().border_collapse() == CSS::BorderCollapse::Collapse;
  116. if (!child.display().is_table_cell() && !is_table_with_collapsed_borders)
  117. paint_node(child, context, PaintPhase::Border);
  118. paint_descendants(context, child, phase);
  119. if (child.display().is_table_inside() || child.computed_values().border_collapse() == CSS::BorderCollapse::Collapse) {
  120. paint_table_borders(context, verify_cast<PaintableBox>(child));
  121. }
  122. }
  123. break;
  124. case StackingContextPaintPhase::Floats:
  125. if (child.is_floating()) {
  126. paint_node(child, context, PaintPhase::Background);
  127. paint_node(child, context, PaintPhase::Border);
  128. paint_descendants(context, child, StackingContextPaintPhase::BackgroundAndBorders);
  129. }
  130. paint_descendants(context, child, phase);
  131. break;
  132. case StackingContextPaintPhase::BackgroundAndBordersForInlineLevelAndReplaced:
  133. if (child_is_inline_or_replaced) {
  134. paint_node(child, context, PaintPhase::Background);
  135. paint_node(child, context, PaintPhase::Border);
  136. if (child.display().is_table_inside() && child.computed_values().border_collapse() == CSS::BorderCollapse::Separate)
  137. paint_table_borders(context, verify_cast<PaintableBox>(child));
  138. paint_descendants(context, child, StackingContextPaintPhase::BackgroundAndBorders);
  139. }
  140. paint_descendants(context, child, phase);
  141. break;
  142. case StackingContextPaintPhase::Foreground:
  143. paint_node(child, context, PaintPhase::Foreground);
  144. paint_descendants(context, child, phase);
  145. break;
  146. case StackingContextPaintPhase::FocusAndOverlay:
  147. paint_node(child, context, PaintPhase::Outline);
  148. paint_node(child, context, PaintPhase::Overlay);
  149. paint_descendants(context, child, phase);
  150. break;
  151. }
  152. });
  153. paintable.after_children_paint(context, to_paint_phase(phase));
  154. }
  155. void StackingContext::paint_child(PaintContext& context, StackingContext const& child)
  156. {
  157. auto parent_paintable = child.paintable().parent();
  158. if (parent_paintable)
  159. parent_paintable->before_children_paint(context, PaintPhase::Foreground);
  160. child.paint(context);
  161. if (parent_paintable)
  162. parent_paintable->after_children_paint(context, PaintPhase::Foreground);
  163. }
  164. void StackingContext::paint_internal(PaintContext& context) const
  165. {
  166. // For a more elaborate description of the algorithm, see CSS 2.1 Appendix E
  167. // Draw the background and borders for the context root (steps 1, 2)
  168. paint_node(paintable(), context, PaintPhase::Background);
  169. paint_node(paintable(), context, PaintPhase::Border);
  170. // Stacking contexts formed by positioned descendants with negative z-indices (excluding 0) in z-index order
  171. // (most negative first) then tree order. (step 3)
  172. // NOTE: This doesn't check if a descendant is positioned as modern CSS allows for alternative methods to establish stacking contexts.
  173. for (auto* child : m_children) {
  174. if (child->paintable().computed_values().z_index().has_value() && child->paintable().computed_values().z_index().value() < 0)
  175. paint_child(context, *child);
  176. }
  177. // Draw the background and borders for block-level children (step 4)
  178. paint_descendants(context, paintable(), StackingContextPaintPhase::BackgroundAndBorders);
  179. // Draw the non-positioned floats (step 5)
  180. paint_descendants(context, paintable(), StackingContextPaintPhase::Floats);
  181. // Draw inline content, replaced content, etc. (steps 6, 7)
  182. paint_descendants(context, paintable(), StackingContextPaintPhase::BackgroundAndBordersForInlineLevelAndReplaced);
  183. paint_node(paintable(), context, PaintPhase::Foreground);
  184. paint_descendants(context, paintable(), StackingContextPaintPhase::Foreground);
  185. // Draw positioned descendants with z-index `0` or `auto` in tree order. (step 8)
  186. // FIXME: There's more to this step that we have yet to understand and implement.
  187. paintable().for_each_in_subtree([&context](Paintable const& paintable) {
  188. auto const& z_index = paintable.computed_values().z_index();
  189. if (!paintable.is_positioned() || (z_index.has_value() && z_index.value() != 0)) {
  190. return paintable.stacking_context()
  191. ? TraversalDecision::SkipChildrenAndContinue
  192. : TraversalDecision::Continue;
  193. }
  194. // At this point, `paintable_box` is a positioned descendant with z-index: auto.
  195. // FIXME: This is basically duplicating logic found elsewhere in this same function. Find a way to make this more elegant.
  196. auto exit_decision = TraversalDecision::Continue;
  197. auto* parent_paintable = paintable.parent();
  198. if (parent_paintable)
  199. parent_paintable->before_children_paint(context, PaintPhase::Foreground);
  200. if (auto* child = paintable.stacking_context()) {
  201. paint_child(context, *child);
  202. exit_decision = TraversalDecision::SkipChildrenAndContinue;
  203. } else {
  204. paint_node_as_stacking_context(paintable, context);
  205. }
  206. if (parent_paintable)
  207. parent_paintable->after_children_paint(context, PaintPhase::Foreground);
  208. return exit_decision;
  209. });
  210. // Stacking contexts formed by positioned descendants with z-indices greater than or equal to 1 in z-index order
  211. // (smallest first) then tree order. (Step 9)
  212. // NOTE: This doesn't check if a descendant is positioned as modern CSS allows for alternative methods to establish stacking contexts.
  213. for (auto* child : m_children) {
  214. if (child->paintable().computed_values().z_index().has_value() && child->paintable().computed_values().z_index().value() >= 1)
  215. paint_child(context, *child);
  216. }
  217. paint_node(paintable(), context, PaintPhase::Outline);
  218. if (context.should_paint_overlay()) {
  219. paint_node(paintable(), context, PaintPhase::Overlay);
  220. paint_descendants(context, paintable(), StackingContextPaintPhase::FocusAndOverlay);
  221. }
  222. }
  223. // FIXME: This extracts the affine 2D part of the full transformation matrix.
  224. // Use the whole matrix when we get better transformation support in LibGfx or use LibGL for drawing the bitmap
  225. Gfx::AffineTransform StackingContext::affine_transform_matrix() const
  226. {
  227. if (paintable().is_paintable_box())
  228. return Gfx::extract_2d_affine_transform(paintable_box().transform());
  229. return Gfx::AffineTransform {};
  230. }
  231. static Gfx::FloatMatrix4x4 matrix_with_scaled_translation(Gfx::FloatMatrix4x4 matrix, float scale)
  232. {
  233. auto* m = matrix.elements();
  234. m[0][3] *= scale;
  235. m[1][3] *= scale;
  236. m[2][3] *= scale;
  237. return matrix;
  238. }
  239. void StackingContext::paint(PaintContext& context) const
  240. {
  241. auto opacity = paintable().computed_values().opacity();
  242. if (opacity == 0.0f)
  243. return;
  244. RecordingPainterStateSaver saver(context.recording_painter());
  245. auto to_device_pixels_scale = float(context.device_pixels_per_css_pixel());
  246. Gfx::IntRect source_paintable_rect;
  247. if (paintable().is_paintable_box()) {
  248. source_paintable_rect = context.enclosing_device_rect(paintable_box().absolute_paint_rect()).to_type<int>();
  249. } else if (paintable().is_inline()) {
  250. source_paintable_rect = context.enclosing_device_rect(inline_paintable().bounding_rect()).to_type<int>();
  251. } else {
  252. VERIFY_NOT_REACHED();
  253. }
  254. auto transform_matrix = Gfx::FloatMatrix4x4::identity();
  255. Gfx::FloatPoint transform_origin;
  256. if (paintable().is_paintable_box()) {
  257. transform_matrix = paintable_box().transform();
  258. transform_origin = paintable_box().transform_origin().to_type<float>();
  259. }
  260. RecordingPainter::PushStackingContextParams push_stacking_context_params {
  261. .opacity = opacity,
  262. .is_fixed_position = paintable().is_fixed_position(),
  263. .source_paintable_rect = source_paintable_rect,
  264. .image_rendering = paintable().computed_values().image_rendering(),
  265. .transform = {
  266. .origin = transform_origin.scaled(to_device_pixels_scale),
  267. .matrix = matrix_with_scaled_translation(transform_matrix, to_device_pixels_scale),
  268. },
  269. };
  270. if (paintable().is_paintable_box()) {
  271. if (auto masking_area = paintable_box().get_masking_area(); masking_area.has_value()) {
  272. if (masking_area->is_empty())
  273. return;
  274. auto mask_bitmap = paintable_box().calculate_mask(context, *masking_area);
  275. if (mask_bitmap) {
  276. auto source_paintable_rect = context.enclosing_device_rect(*masking_area).to_type<int>();
  277. push_stacking_context_params.source_paintable_rect = source_paintable_rect;
  278. push_stacking_context_params.mask = StackingContextMask {
  279. .mask_bitmap = mask_bitmap.release_nonnull(),
  280. .mask_kind = *paintable_box().get_mask_type()
  281. };
  282. }
  283. }
  284. }
  285. context.recording_painter().save();
  286. if (paintable().is_paintable_box() && paintable_box().scroll_frame_id().has_value())
  287. context.recording_painter().set_scroll_frame_id(*paintable_box().scroll_frame_id());
  288. context.recording_painter().push_stacking_context(push_stacking_context_params);
  289. paint_internal(context);
  290. context.recording_painter().pop_stacking_context();
  291. context.recording_painter().restore();
  292. }
  293. template<typename Callback>
  294. static TraversalDecision for_each_in_inclusive_subtree_within_same_stacking_context_in_reverse(Paintable const& paintable, Callback callback)
  295. {
  296. if (paintable.stacking_context()) {
  297. // Note: Include the stacking context (so we can hit test it), but don't recurse into it.
  298. if (auto decision = callback(paintable); decision != TraversalDecision::Continue)
  299. return decision;
  300. return TraversalDecision::SkipChildrenAndContinue;
  301. }
  302. for (auto* child = paintable.last_child(); child; child = child->previous_sibling()) {
  303. if (for_each_in_inclusive_subtree_within_same_stacking_context_in_reverse(*child, callback) == TraversalDecision::Break)
  304. return TraversalDecision::Break;
  305. }
  306. if (auto decision = callback(paintable); decision != TraversalDecision::Continue)
  307. return decision;
  308. return TraversalDecision::Continue;
  309. }
  310. template<typename Callback>
  311. static TraversalDecision for_each_in_subtree_within_same_stacking_context_in_reverse(Paintable const& paintable, Callback callback)
  312. {
  313. for (auto* child = paintable.last_child(); child; child = child->previous_sibling()) {
  314. if (for_each_in_inclusive_subtree_within_same_stacking_context_in_reverse(*child, callback) == TraversalDecision::Break)
  315. return TraversalDecision::Break;
  316. }
  317. return TraversalDecision::Continue;
  318. }
  319. TraversalDecision StackingContext::hit_test(CSSPixelPoint position, HitTestType type, Function<TraversalDecision(HitTestResult)> const& callback) const
  320. {
  321. if (!paintable().is_visible())
  322. return TraversalDecision::Continue;
  323. CSSPixelPoint transform_origin { 0, 0 };
  324. if (paintable().is_paintable_box())
  325. transform_origin = paintable_box().transform_origin();
  326. // NOTE: This CSSPixels -> Float -> CSSPixels conversion is because we can't AffineTransform::map() a CSSPixelPoint.
  327. Gfx::FloatPoint offset_position {
  328. (position.x() - transform_origin.x()).to_float(),
  329. (position.y() - transform_origin.y()).to_float()
  330. };
  331. auto transformed_position = affine_transform_matrix().inverse().value_or({}).map(offset_position).to_type<CSSPixels>() + transform_origin;
  332. if (paintable().is_fixed_position()) {
  333. auto scroll_offset = paintable().document().navigable()->viewport_scroll_offset();
  334. transformed_position.translate_by(-scroll_offset);
  335. }
  336. // NOTE: Hit testing basically happens in reverse painting order.
  337. // https://www.w3.org/TR/CSS22/visuren.html#z-index
  338. // 7. the child stacking contexts with positive stack levels (least positive first).
  339. // NOTE: Hit testing follows reverse painting order, that's why the conditions here are reversed.
  340. for (ssize_t i = m_children.size() - 1; i >= 0; --i) {
  341. auto const& child = *m_children[i];
  342. if (child.paintable().computed_values().z_index().value_or(0) <= 0)
  343. break;
  344. if (child.hit_test(transformed_position, type, callback) == TraversalDecision::Break)
  345. return TraversalDecision::Break;
  346. }
  347. bool should_exit = false;
  348. // 6. the child stacking contexts with stack level 0 and the positioned descendants with stack level 0.
  349. for_each_in_subtree_within_same_stacking_context_in_reverse(paintable(), [&](Paintable const& paintable) {
  350. VERIFY(!should_exit);
  351. if (!paintable.is_paintable_box())
  352. return TraversalDecision::Continue;
  353. auto const& paintable_box = verify_cast<PaintableBox>(paintable);
  354. auto const& z_index = paintable_box.computed_values().z_index();
  355. auto positioned_element_without_stacking_context = paintable_box.is_positioned() && !paintable_box.stacking_context();
  356. if (z_index.value_or(0) == 0 && (positioned_element_without_stacking_context || paintable_box.layout_node().is_grid_item())) {
  357. if (paintable_box.hit_test(transformed_position, type, callback) == TraversalDecision::Break) {
  358. should_exit = true;
  359. return TraversalDecision::Break;
  360. }
  361. }
  362. if (paintable_box.stacking_context()) {
  363. if (z_index.value_or(0) == 0) {
  364. if (paintable_box.stacking_context()->hit_test(transformed_position, type, callback) == TraversalDecision::Break) {
  365. should_exit = true;
  366. return TraversalDecision::Break;
  367. }
  368. }
  369. }
  370. return TraversalDecision::Continue;
  371. });
  372. if (should_exit)
  373. return TraversalDecision::Break;
  374. // 5. the in-flow, inline-level, non-positioned descendants, including inline tables and inline blocks.
  375. if (paintable().layout_node().children_are_inline() && is<Layout::BlockContainer>(paintable().layout_node())) {
  376. if (paintable_box().hit_test(transformed_position, type, callback) == TraversalDecision::Break)
  377. return TraversalDecision::Break;
  378. }
  379. // 4. the non-positioned floats.
  380. for_each_in_subtree_within_same_stacking_context_in_reverse(paintable(), [&](Paintable const& paintable) {
  381. VERIFY(!should_exit);
  382. if (!paintable.is_paintable_box())
  383. return TraversalDecision::Continue;
  384. auto const& paintable_box = verify_cast<PaintableBox>(paintable);
  385. if (paintable_box.is_floating()) {
  386. if (paintable_box.hit_test(transformed_position, type, callback) == TraversalDecision::Break) {
  387. should_exit = true;
  388. return TraversalDecision::Break;
  389. }
  390. }
  391. return TraversalDecision::Continue;
  392. });
  393. if (should_exit)
  394. return TraversalDecision::Break;
  395. // 3. the in-flow, non-inline-level, non-positioned descendants.
  396. if (!paintable().layout_node().children_are_inline()) {
  397. for (auto const* child = paintable().last_child(); child; child = child->previous_sibling()) {
  398. if (!child->is_paintable_box())
  399. continue;
  400. auto const& paintable_box = verify_cast<PaintableBox>(*child);
  401. if (!paintable_box.is_absolutely_positioned() && !paintable_box.is_floating() && !paintable_box.stacking_context()) {
  402. if (paintable_box.hit_test(transformed_position, type, callback) == TraversalDecision::Break)
  403. return TraversalDecision::Break;
  404. }
  405. }
  406. }
  407. // 2. the child stacking contexts with negative stack levels (most negative first).
  408. // NOTE: Hit testing follows reverse painting order, that's why the conditions here are reversed.
  409. for (ssize_t i = m_children.size() - 1; i >= 0; --i) {
  410. auto const& child = *m_children[i];
  411. if (child.paintable().computed_values().z_index().value_or(0) >= 0)
  412. break;
  413. if (child.hit_test(transformed_position, type, callback) == TraversalDecision::Break)
  414. return TraversalDecision::Break;
  415. }
  416. // 1. the background and borders of the element forming the stacking context.
  417. if (paintable().is_paintable_box()) {
  418. if (paintable_box().absolute_border_box_rect().contains(transformed_position.x(), transformed_position.y())) {
  419. auto hit_test_result = HitTestResult { .paintable = const_cast<PaintableBox&>(paintable_box()) };
  420. if (callback(hit_test_result) == TraversalDecision::Break)
  421. return TraversalDecision::Break;
  422. }
  423. }
  424. return TraversalDecision::Continue;
  425. }
  426. void StackingContext::dump(int indent) const
  427. {
  428. StringBuilder builder;
  429. for (int i = 0; i < indent; ++i)
  430. builder.append(' ');
  431. CSSPixelRect rect;
  432. if (paintable().is_paintable_box()) {
  433. rect = paintable_box().absolute_rect();
  434. } else if (paintable().is_inline_paintable()) {
  435. rect = inline_paintable().bounding_rect();
  436. } else {
  437. VERIFY_NOT_REACHED();
  438. }
  439. builder.appendff("SC for {} {} [children: {}] (z-index: ", paintable().layout_node().debug_description(), rect, m_children.size());
  440. if (paintable().computed_values().z_index().has_value())
  441. builder.appendff("{}", paintable().computed_values().z_index().value());
  442. else
  443. builder.append("auto"sv);
  444. builder.append(')');
  445. auto affine_transform = affine_transform_matrix();
  446. if (!affine_transform.is_identity()) {
  447. builder.appendff(", transform: {}", affine_transform);
  448. }
  449. dbgln("{}", builder.string_view());
  450. for (auto& child : m_children)
  451. child->dump(indent + 1);
  452. }
  453. }