TreeBuilder.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. /*
  2. * Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org>
  3. * Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
  4. * Copyright (c) 2022, MacDue <macdue@dueutil.tech>
  5. *
  6. * SPDX-License-Identifier: BSD-2-Clause
  7. */
  8. #include <AK/Optional.h>
  9. #include <AK/TemporaryChange.h>
  10. #include <LibWeb/DOM/Document.h>
  11. #include <LibWeb/DOM/Element.h>
  12. #include <LibWeb/DOM/ParentNode.h>
  13. #include <LibWeb/DOM/ShadowRoot.h>
  14. #include <LibWeb/Dump.h>
  15. #include <LibWeb/HTML/HTMLProgressElement.h>
  16. #include <LibWeb/Layout/InitialContainingBlock.h>
  17. #include <LibWeb/Layout/ListItemBox.h>
  18. #include <LibWeb/Layout/ListItemMarkerBox.h>
  19. #include <LibWeb/Layout/Node.h>
  20. #include <LibWeb/Layout/Progress.h>
  21. #include <LibWeb/Layout/TableBox.h>
  22. #include <LibWeb/Layout/TableCellBox.h>
  23. #include <LibWeb/Layout/TableRowBox.h>
  24. #include <LibWeb/Layout/TextNode.h>
  25. #include <LibWeb/Layout/TreeBuilder.h>
  26. #include <LibWeb/SVG/SVGForeignObjectElement.h>
  27. namespace Web::Layout {
  28. TreeBuilder::TreeBuilder() = default;
  29. static bool has_inline_or_in_flow_block_children(Layout::Node const& layout_node)
  30. {
  31. for (auto child = layout_node.first_child(); child; child = child->next_sibling()) {
  32. if (child->is_inline())
  33. return true;
  34. if (!child->is_floating() && !child->is_absolutely_positioned())
  35. return true;
  36. }
  37. return false;
  38. }
  39. static bool has_in_flow_block_children(Layout::Node const& layout_node)
  40. {
  41. if (layout_node.children_are_inline())
  42. return false;
  43. for (auto child = layout_node.first_child(); child; child = child->next_sibling()) {
  44. if (child->is_inline())
  45. continue;
  46. if (!child->is_floating() && !child->is_absolutely_positioned())
  47. return true;
  48. }
  49. return false;
  50. }
  51. // The insertion_parent_for_*() functions maintain the invariant that the in-flow children of
  52. // block-level boxes must be either all block-level or all inline-level.
  53. static Layout::Node& insertion_parent_for_inline_node(Layout::NodeWithStyle& layout_parent)
  54. {
  55. if (layout_parent.display().is_inline_outside() && layout_parent.display().is_flow_inside())
  56. return layout_parent;
  57. if (layout_parent.display().is_flex_inside()) {
  58. layout_parent.append_child(layout_parent.create_anonymous_wrapper());
  59. return *layout_parent.last_child();
  60. }
  61. if (!has_in_flow_block_children(layout_parent) || layout_parent.children_are_inline())
  62. return layout_parent;
  63. // Parent has block-level children, insert into an anonymous wrapper block (and create it first if needed)
  64. if (!layout_parent.last_child()->is_anonymous() || !layout_parent.last_child()->children_are_inline()) {
  65. layout_parent.append_child(layout_parent.create_anonymous_wrapper());
  66. }
  67. return *layout_parent.last_child();
  68. }
  69. static Layout::Node& insertion_parent_for_block_node(Layout::NodeWithStyle& layout_parent, Layout::Node& layout_node)
  70. {
  71. if (!has_inline_or_in_flow_block_children(layout_parent)) {
  72. // Parent block has no children, insert this block into parent.
  73. return layout_parent;
  74. }
  75. if ((layout_node.is_absolutely_positioned() || layout_node.is_floating()) && layout_parent.last_child()->children_are_inline() && layout_parent.last_child()->is_anonymous()) {
  76. return *layout_parent.last_child();
  77. }
  78. if (!layout_parent.children_are_inline()) {
  79. // Parent block has block-level children, insert this block into parent.
  80. return layout_parent;
  81. }
  82. if (layout_node.is_absolutely_positioned() || layout_node.is_floating()) {
  83. // Block is out-of-flow, it can have inline siblings if necessary.
  84. return layout_parent;
  85. }
  86. // Parent block has inline-level children (our siblings).
  87. // First move these siblings into an anonymous wrapper block.
  88. Vector<JS::Handle<Layout::Node>> children;
  89. while (JS::GCPtr<Layout::Node> child = layout_parent.first_child()) {
  90. layout_parent.remove_child(*child);
  91. children.append(*child);
  92. }
  93. layout_parent.append_child(layout_parent.create_anonymous_wrapper());
  94. layout_parent.set_children_are_inline(false);
  95. for (auto& child : children) {
  96. layout_parent.last_child()->append_child(*child);
  97. }
  98. layout_parent.last_child()->set_children_are_inline(true);
  99. // Then it's safe to insert this block into parent.
  100. return layout_parent;
  101. }
  102. void TreeBuilder::insert_node_into_inline_or_block_ancestor(Layout::Node& node, CSS::Display display, AppendOrPrepend mode)
  103. {
  104. if (display.is_inline_outside()) {
  105. // Inlines can be inserted into the nearest ancestor.
  106. auto& insertion_point = insertion_parent_for_inline_node(m_ancestor_stack.last());
  107. if (mode == AppendOrPrepend::Prepend)
  108. insertion_point.prepend_child(node);
  109. else
  110. insertion_point.append_child(node);
  111. insertion_point.set_children_are_inline(true);
  112. } else {
  113. // Non-inlines can't be inserted into an inline parent, so find the nearest non-inline ancestor.
  114. auto& nearest_non_inline_ancestor = [&]() -> Layout::NodeWithStyle& {
  115. for (auto& ancestor : m_ancestor_stack.in_reverse()) {
  116. if (!ancestor.display().is_inline_outside())
  117. return ancestor;
  118. if (!ancestor.display().is_flow_inside())
  119. return ancestor;
  120. if (ancestor.dom_node() && is<SVG::SVGForeignObjectElement>(*ancestor.dom_node()))
  121. return ancestor;
  122. }
  123. VERIFY_NOT_REACHED();
  124. }();
  125. auto& insertion_point = insertion_parent_for_block_node(nearest_non_inline_ancestor, node);
  126. if (mode == AppendOrPrepend::Prepend)
  127. insertion_point.prepend_child(node);
  128. else
  129. insertion_point.append_child(node);
  130. // After inserting an in-flow block-level box into a parent, mark the parent as having non-inline children.
  131. if (!node.is_floating() && !node.is_absolutely_positioned())
  132. insertion_point.set_children_are_inline(false);
  133. }
  134. }
  135. void TreeBuilder::create_pseudo_element_if_needed(DOM::Element& element, CSS::Selector::PseudoElement pseudo_element, AppendOrPrepend mode)
  136. {
  137. auto& document = element.document();
  138. auto& style_computer = document.style_computer();
  139. auto pseudo_element_style = style_computer.compute_style(element, pseudo_element);
  140. auto pseudo_element_content = pseudo_element_style->content();
  141. auto pseudo_element_display = pseudo_element_style->display();
  142. // ::before and ::after only exist if they have content. `content: normal` computes to `none` for them.
  143. // We also don't create them if they are `display: none`.
  144. if (pseudo_element_display.is_none()
  145. || pseudo_element_content.type == CSS::ContentData::Type::Normal
  146. || pseudo_element_content.type == CSS::ContentData::Type::None)
  147. return;
  148. auto pseudo_element_node = DOM::Element::create_layout_node_for_display_type(document, pseudo_element_display, pseudo_element_style, nullptr);
  149. if (!pseudo_element_node)
  150. return;
  151. pseudo_element_node->set_generated(true);
  152. // FIXME: Handle images, and multiple values
  153. if (pseudo_element_content.type == CSS::ContentData::Type::String) {
  154. auto* text = document.heap().allocate<DOM::Text>(document.realm(), document, pseudo_element_content.data);
  155. auto text_node = document.heap().allocate_without_realm<Layout::TextNode>(document, *text);
  156. text_node->set_generated(true);
  157. push_parent(verify_cast<NodeWithStyle>(*pseudo_element_node));
  158. insert_node_into_inline_or_block_ancestor(*text_node, text_node->display(), AppendOrPrepend::Append);
  159. pop_parent();
  160. } else {
  161. TODO();
  162. }
  163. element.set_pseudo_element_node({}, pseudo_element, pseudo_element_node);
  164. insert_node_into_inline_or_block_ancestor(*pseudo_element_node, pseudo_element_display, mode);
  165. }
  166. void TreeBuilder::create_layout_tree(DOM::Node& dom_node, TreeBuilder::Context& context)
  167. {
  168. // If the parent doesn't have a layout node, we don't need one either.
  169. if (dom_node.parent_or_shadow_host() && !dom_node.parent_or_shadow_host()->layout_node())
  170. return;
  171. Optional<TemporaryChange<bool>> has_svg_root_change;
  172. if (dom_node.is_svg_container()) {
  173. has_svg_root_change.emplace(context.has_svg_root, true);
  174. } else if (dom_node.requires_svg_container() && !context.has_svg_root) {
  175. return;
  176. }
  177. auto& document = dom_node.document();
  178. auto& style_computer = document.style_computer();
  179. JS::GCPtr<Layout::Node> layout_node;
  180. RefPtr<CSS::StyleProperties> style;
  181. CSS::Display display;
  182. if (is<DOM::Element>(dom_node)) {
  183. auto& element = static_cast<DOM::Element&>(dom_node);
  184. element.clear_pseudo_element_nodes({});
  185. VERIFY(!element.needs_style_update());
  186. style = element.computed_css_values();
  187. display = style->display();
  188. if (display.is_none())
  189. return;
  190. layout_node = element.create_layout_node(*style);
  191. } else if (is<DOM::Document>(dom_node)) {
  192. style = style_computer.create_document_style();
  193. display = style->display();
  194. layout_node = document.heap().allocate_without_realm<Layout::InitialContainingBlock>(static_cast<DOM::Document&>(dom_node), *style);
  195. } else if (is<DOM::Text>(dom_node)) {
  196. layout_node = document.heap().allocate_without_realm<Layout::TextNode>(document, static_cast<DOM::Text&>(dom_node));
  197. display = CSS::Display(CSS::Display::Outside::Inline, CSS::Display::Inside::Flow);
  198. } else if (is<DOM::ShadowRoot>(dom_node)) {
  199. layout_node = document.heap().allocate_without_realm<Layout::BlockContainer>(document, &static_cast<DOM::ShadowRoot&>(dom_node), CSS::ComputedValues {});
  200. display = CSS::Display(CSS::Display::Outside::Block, CSS::Display::Inside::FlowRoot);
  201. }
  202. if (!layout_node)
  203. return;
  204. if (!dom_node.parent_or_shadow_host()) {
  205. m_layout_root = layout_node;
  206. } else if (layout_node->is_svg_box()) {
  207. m_ancestor_stack.last().append_child(*layout_node);
  208. } else {
  209. insert_node_into_inline_or_block_ancestor(*layout_node, display, AppendOrPrepend::Append);
  210. }
  211. auto* shadow_root = is<DOM::Element>(dom_node) ? verify_cast<DOM::Element>(dom_node).shadow_root() : nullptr;
  212. if ((dom_node.has_children() || shadow_root) && layout_node->can_have_children()) {
  213. push_parent(verify_cast<NodeWithStyle>(*layout_node));
  214. if (shadow_root)
  215. create_layout_tree(*shadow_root, context);
  216. verify_cast<DOM::ParentNode>(dom_node).for_each_child([&](auto& dom_child) {
  217. create_layout_tree(dom_child, context);
  218. });
  219. pop_parent();
  220. }
  221. // Add nodes for the ::before and ::after pseudo-elements.
  222. if (is<DOM::Element>(dom_node)) {
  223. auto& element = static_cast<DOM::Element&>(dom_node);
  224. push_parent(verify_cast<NodeWithStyle>(*layout_node));
  225. create_pseudo_element_if_needed(element, CSS::Selector::PseudoElement::Before, AppendOrPrepend::Prepend);
  226. create_pseudo_element_if_needed(element, CSS::Selector::PseudoElement::After, AppendOrPrepend::Append);
  227. pop_parent();
  228. }
  229. if (is<ListItemBox>(*layout_node)) {
  230. auto& element = static_cast<DOM::Element&>(dom_node);
  231. int child_index = layout_node->parent()->index_of_child<ListItemBox>(*layout_node).value();
  232. auto marker_style = style_computer.compute_style(element, CSS::Selector::PseudoElement::Marker);
  233. auto list_item_marker = document.heap().allocate_without_realm<ListItemMarkerBox>(document, layout_node->computed_values().list_style_type(), child_index + 1, *marker_style);
  234. static_cast<ListItemBox&>(*layout_node).set_marker(list_item_marker);
  235. element.set_pseudo_element_node({}, CSS::Selector::PseudoElement::Marker, list_item_marker);
  236. layout_node->append_child(*list_item_marker);
  237. }
  238. if (is<HTML::HTMLProgressElement>(dom_node)) {
  239. auto& progress = static_cast<HTML::HTMLProgressElement&>(dom_node);
  240. if (!progress.using_system_appearance()) {
  241. auto bar_style = style_computer.compute_style(progress, CSS::Selector::PseudoElement::ProgressBar);
  242. bar_style->set_property(CSS::PropertyID::Display, CSS::IdentifierStyleValue::create(CSS::ValueID::InlineBlock));
  243. auto value_style = style_computer.compute_style(progress, CSS::Selector::PseudoElement::ProgressValue);
  244. value_style->set_property(CSS::PropertyID::Display, CSS::IdentifierStyleValue::create(CSS::ValueID::Block));
  245. auto position = progress.position();
  246. value_style->set_property(CSS::PropertyID::Width, CSS::PercentageStyleValue::create(CSS::Percentage(position >= 0 ? round_to<int>(100 * position) : 0)));
  247. auto bar_display = bar_style->display();
  248. auto value_display = value_style->display();
  249. auto progress_bar = DOM::Element::create_layout_node_for_display_type(document, bar_display, bar_style, nullptr);
  250. auto progress_value = DOM::Element::create_layout_node_for_display_type(document, value_display, value_style, nullptr);
  251. push_parent(verify_cast<NodeWithStyle>(*layout_node));
  252. push_parent(verify_cast<NodeWithStyle>(*progress_bar));
  253. insert_node_into_inline_or_block_ancestor(*progress_value, value_display, AppendOrPrepend::Append);
  254. pop_parent();
  255. insert_node_into_inline_or_block_ancestor(*progress_bar, bar_display, AppendOrPrepend::Append);
  256. pop_parent();
  257. progress.set_pseudo_element_node({}, CSS::Selector::PseudoElement::ProgressBar, progress_bar);
  258. progress.set_pseudo_element_node({}, CSS::Selector::PseudoElement::ProgressValue, progress_value);
  259. }
  260. }
  261. }
  262. JS::GCPtr<Layout::Node> TreeBuilder::build(DOM::Node& dom_node)
  263. {
  264. VERIFY(dom_node.is_document());
  265. Context context;
  266. create_layout_tree(dom_node, context);
  267. if (auto* root = dom_node.document().layout_node())
  268. fixup_tables(*root);
  269. return move(m_layout_root);
  270. }
  271. template<CSS::Display::Internal internal, typename Callback>
  272. void TreeBuilder::for_each_in_tree_with_internal_display(NodeWithStyle& root, Callback callback)
  273. {
  274. root.for_each_in_inclusive_subtree_of_type<Box>([&](auto& box) {
  275. auto const display = box.display();
  276. if (display.is_internal() && display.internal() == internal)
  277. callback(box);
  278. return IterationDecision::Continue;
  279. });
  280. }
  281. template<CSS::Display::Inside inside, typename Callback>
  282. void TreeBuilder::for_each_in_tree_with_inside_display(NodeWithStyle& root, Callback callback)
  283. {
  284. root.for_each_in_inclusive_subtree_of_type<Box>([&](auto& box) {
  285. auto const display = box.display();
  286. if (display.is_outside_and_inside() && display.inside() == inside)
  287. callback(box);
  288. return IterationDecision::Continue;
  289. });
  290. }
  291. void TreeBuilder::fixup_tables(NodeWithStyle& root)
  292. {
  293. remove_irrelevant_boxes(root);
  294. generate_missing_child_wrappers(root);
  295. generate_missing_parents(root);
  296. }
  297. void TreeBuilder::remove_irrelevant_boxes(NodeWithStyle& root)
  298. {
  299. // The following boxes are discarded as if they were display:none:
  300. Vector<JS::Handle<Node>> to_remove;
  301. // Children of a table-column.
  302. for_each_in_tree_with_internal_display<CSS::Display::Internal::TableColumn>(root, [&](Box& table_column) {
  303. table_column.for_each_child([&](auto& child) {
  304. to_remove.append(child);
  305. });
  306. });
  307. // Children of a table-column-group which are not a table-column.
  308. for_each_in_tree_with_internal_display<CSS::Display::Internal::TableColumnGroup>(root, [&](Box& table_column_group) {
  309. table_column_group.for_each_child([&](auto& child) {
  310. if (child.display().is_table_column())
  311. to_remove.append(child);
  312. });
  313. });
  314. // FIXME:
  315. // Anonymous inline boxes which contain only white space and are between two immediate siblings each of which is a table-non-root box.
  316. // Anonymous inline boxes which meet all of the following criteria:
  317. // - they contain only white space
  318. // - they are the first and/or last child of a tabular container
  319. // - whose immediate sibling, if any, is a table-non-root box
  320. for (auto& box : to_remove)
  321. box->parent()->remove_child(*box);
  322. }
  323. static bool is_table_track(CSS::Display display)
  324. {
  325. return display.is_table_row() || display.is_table_column();
  326. }
  327. static bool is_table_track_group(CSS::Display display)
  328. {
  329. // Unless explicitly mentioned otherwise, mentions of table-row-groups in this spec also encompass the specialized
  330. // table-header-groups and table-footer-groups.
  331. return display.is_table_row_group()
  332. || display.is_table_header_group()
  333. || display.is_table_footer_group()
  334. || display.is_table_column_group();
  335. }
  336. static bool is_not_proper_table_child(Node const& node)
  337. {
  338. if (!node.has_style())
  339. return true;
  340. auto const display = node.display();
  341. return !is_table_track_group(display) && !is_table_track(display) && !display.is_table_caption();
  342. }
  343. static bool is_not_table_row(Node const& node)
  344. {
  345. if (!node.has_style())
  346. return true;
  347. auto const display = node.display();
  348. return !display.is_table_row();
  349. }
  350. static bool is_not_table_cell(Node const& node)
  351. {
  352. if (!node.has_style())
  353. return true;
  354. auto const display = node.display();
  355. return !display.is_table_cell();
  356. }
  357. static bool is_ignorable_whitespace(Layout::Node const& node)
  358. {
  359. if (node.is_text_node() && static_cast<TextNode const&>(node).text_for_rendering().is_whitespace())
  360. return true;
  361. if (node.is_anonymous() && node.is_block_container() && static_cast<BlockContainer const&>(node).children_are_inline()) {
  362. bool contains_only_white_space = true;
  363. node.for_each_in_inclusive_subtree_of_type<TextNode>([&contains_only_white_space](auto& text_node) {
  364. if (!text_node.text_for_rendering().is_whitespace()) {
  365. contains_only_white_space = false;
  366. return IterationDecision::Break;
  367. }
  368. return IterationDecision::Continue;
  369. });
  370. if (contains_only_white_space)
  371. return true;
  372. }
  373. return false;
  374. }
  375. template<typename Matcher, typename Callback>
  376. static void for_each_sequence_of_consecutive_children_matching(NodeWithStyle& parent, Matcher matcher, Callback callback)
  377. {
  378. Vector<JS::Handle<Node>> sequence;
  379. auto sequence_is_all_ignorable_whitespace = [&]() -> bool {
  380. for (auto& node : sequence) {
  381. if (!is_ignorable_whitespace(*node))
  382. return false;
  383. }
  384. return true;
  385. };
  386. Node* next_sibling = nullptr;
  387. for (auto child = parent.first_child(); child; child = next_sibling) {
  388. next_sibling = child->next_sibling();
  389. if (matcher(*child)) {
  390. sequence.append(*child);
  391. } else {
  392. if (!sequence.is_empty()) {
  393. if (!sequence_is_all_ignorable_whitespace())
  394. callback(sequence, next_sibling);
  395. sequence.clear();
  396. }
  397. }
  398. }
  399. if (sequence.is_empty() && !sequence_is_all_ignorable_whitespace())
  400. callback(sequence, nullptr);
  401. }
  402. template<typename WrapperBoxType>
  403. static void wrap_in_anonymous(Vector<JS::Handle<Node>>& sequence, Node* nearest_sibling)
  404. {
  405. VERIFY(!sequence.is_empty());
  406. auto& parent = *sequence.first()->parent();
  407. auto computed_values = parent.computed_values().clone_inherited_values();
  408. static_cast<CSS::MutableComputedValues&>(computed_values).set_display(WrapperBoxType::static_display());
  409. auto wrapper = parent.heap().template allocate_without_realm<WrapperBoxType>(parent.document(), nullptr, move(computed_values));
  410. for (auto& child : sequence) {
  411. parent.remove_child(*child);
  412. wrapper->append_child(*child);
  413. }
  414. if (nearest_sibling)
  415. parent.insert_before(*wrapper, *nearest_sibling);
  416. else
  417. parent.append_child(*wrapper);
  418. }
  419. void TreeBuilder::generate_missing_child_wrappers(NodeWithStyle& root)
  420. {
  421. // An anonymous table-row box must be generated around each sequence of consecutive children of a table-root box which are not proper table child boxes.
  422. for_each_in_tree_with_inside_display<CSS::Display::Inside::Table>(root, [&](auto& parent) {
  423. for_each_sequence_of_consecutive_children_matching(parent, is_not_proper_table_child, [&](auto sequence, auto nearest_sibling) {
  424. wrap_in_anonymous<TableRowBox>(sequence, nearest_sibling);
  425. });
  426. });
  427. // An anonymous table-row box must be generated around each sequence of consecutive children of a table-row-group box which are not table-row boxes.
  428. for_each_in_tree_with_internal_display<CSS::Display::Internal::TableRowGroup>(root, [&](auto& parent) {
  429. for_each_sequence_of_consecutive_children_matching(parent, is_not_table_row, [&](auto& sequence, auto nearest_sibling) {
  430. wrap_in_anonymous<TableRowBox>(sequence, nearest_sibling);
  431. });
  432. });
  433. // Unless explicitly mentioned otherwise, mentions of table-row-groups in this spec also encompass the specialized
  434. // table-header-groups and table-footer-groups.
  435. for_each_in_tree_with_internal_display<CSS::Display::Internal::TableHeaderGroup>(root, [&](auto& parent) {
  436. for_each_sequence_of_consecutive_children_matching(parent, is_not_table_row, [&](auto& sequence, auto nearest_sibling) {
  437. wrap_in_anonymous<TableRowBox>(sequence, nearest_sibling);
  438. });
  439. });
  440. for_each_in_tree_with_internal_display<CSS::Display::Internal::TableFooterGroup>(root, [&](auto& parent) {
  441. for_each_sequence_of_consecutive_children_matching(parent, is_not_table_row, [&](auto& sequence, auto nearest_sibling) {
  442. wrap_in_anonymous<TableRowBox>(sequence, nearest_sibling);
  443. });
  444. });
  445. // An anonymous table-cell box must be generated around each sequence of consecutive children of a table-row box which are not table-cell boxes. !Testcase
  446. for_each_in_tree_with_internal_display<CSS::Display::Internal::TableRow>(root, [&](auto& parent) {
  447. for_each_sequence_of_consecutive_children_matching(parent, is_not_table_cell, [&](auto& sequence, auto nearest_sibling) {
  448. wrap_in_anonymous<TableCellBox>(sequence, nearest_sibling);
  449. });
  450. });
  451. }
  452. void TreeBuilder::generate_missing_parents(NodeWithStyle&)
  453. {
  454. // FIXME: Implement.
  455. }
  456. }