TableFormattingContext.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. /*
  2. * This source file is part of RmlUi, the HTML/CSS Interface Middleware
  3. *
  4. * For the latest information, see http://github.com/mikke89/RmlUi
  5. *
  6. * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
  7. * Copyright (c) 2019-2023 The RmlUi Team, and contributors
  8. *
  9. * Permission is hereby granted, free of charge, to any person obtaining a copy
  10. * of this software and associated documentation files (the "Software"), to deal
  11. * in the Software without restriction, including without limitation the rights
  12. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. * copies of the Software, and to permit persons to whom the Software is
  14. * furnished to do so, subject to the following conditions:
  15. *
  16. * The above copyright notice and this permission notice shall be included in
  17. * all copies or substantial portions of the Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  25. * THE SOFTWARE.
  26. *
  27. */
  28. #include "TableFormattingContext.h"
  29. #include "../../../Include/RmlUi/Core/ComputedValues.h"
  30. #include "../../../Include/RmlUi/Core/Element.h"
  31. #include "../../../Include/RmlUi/Core/Types.h"
  32. #include "ContainerBox.h"
  33. #include "LayoutDetails.h"
  34. #include "LayoutEngine.h"
  35. #include "TableFormattingDetails.h"
  36. #include <algorithm>
  37. #include <numeric>
  38. namespace Rml {
  39. UniquePtr<LayoutBox> TableFormattingContext::Format(ContainerBox* parent_container, Element* element_table, const Box* override_initial_box)
  40. {
  41. auto table_wrapper_box = MakeUnique<TableWrapper>(element_table, parent_container);
  42. if (table_wrapper_box->IsScrollContainer())
  43. {
  44. Log::Message(Log::LT_WARNING, "Table elements can only have 'overflow' property values of 'visible'. Table will not be formatted: %s.",
  45. element_table->GetAddress().c_str());
  46. return table_wrapper_box;
  47. }
  48. const Vector2f containing_block = LayoutDetails::GetContainingBlock(parent_container, element_table->GetPosition()).size;
  49. RMLUI_ASSERT(containing_block.x >= 0.f);
  50. const ComputedValues& computed_table = element_table->GetComputedValues();
  51. // Build the initial box as specified by the table's style, as if it was a normal block element.
  52. Box& box = table_wrapper_box->GetBox();
  53. if (override_initial_box)
  54. box = *override_initial_box;
  55. else
  56. LayoutDetails::BuildBox(box, containing_block, element_table, BuildBoxMode::Block);
  57. TableFormattingContext context;
  58. context.element_table = element_table;
  59. context.table_wrapper_box = table_wrapper_box.get();
  60. LayoutDetails::GetMinMaxWidth(context.table_min_size.x, context.table_max_size.x, computed_table, box, containing_block.x);
  61. LayoutDetails::GetMinMaxHeight(context.table_min_size.y, context.table_max_size.y, computed_table, box, containing_block.y);
  62. // Format the table, this may adjust the box content size.
  63. const Vector2f initial_content_size = box.GetSize();
  64. context.table_auto_height = (initial_content_size.y < 0.0f);
  65. context.table_content_offset = box.GetPosition();
  66. context.table_initial_content_size = Vector2f(initial_content_size.x, Math::Max(0.0f, initial_content_size.y));
  67. // When width or height is set, they act as minimum width or height, just as in CSS.
  68. if (computed_table.width().type != Style::Width::Auto)
  69. context.table_min_size.x = Math::Max(context.table_min_size.x, context.table_initial_content_size.x);
  70. if (computed_table.height().type != Style::Height::Auto)
  71. context.table_min_size.y = Math::Max(context.table_min_size.y, context.table_initial_content_size.y);
  72. context.table_gap = Vector2f(ResolveValue(computed_table.column_gap(), context.table_initial_content_size.x),
  73. ResolveValue(computed_table.row_gap(), context.table_initial_content_size.y));
  74. context.grid.Build(element_table, *table_wrapper_box);
  75. Vector2f table_content_size, table_overflow_size;
  76. float table_baseline = 0.f;
  77. // Format the table and its children.
  78. context.FormatTable(table_content_size, table_overflow_size, table_baseline);
  79. RMLUI_ASSERT(table_content_size.y >= 0);
  80. // Update the box size based on the new table size.
  81. box.SetContent(table_content_size);
  82. if (table_content_size != initial_content_size)
  83. {
  84. // Perform this step to re-evaluate any auto margins.
  85. LayoutDetails::BuildBoxSizeAndMargins(box, context.table_min_size, context.table_max_size, containing_block, element_table,
  86. BuildBoxMode::Block, true);
  87. }
  88. // Change the table baseline coordinates to the element baseline, which is defined as the distance from the element's bottom margin edge.
  89. const float element_baseline =
  90. box.GetSizeAcross(BoxDirection::Vertical, BoxArea::Border) + box.GetEdge(BoxArea::Margin, BoxEdge::Bottom) - table_baseline;
  91. table_wrapper_box->Close(table_overflow_size, box, element_baseline);
  92. return table_wrapper_box;
  93. }
  94. void TableFormattingContext::FormatTable(Vector2f& table_content_size, Vector2f& table_overflow_size, float& table_baseline) const
  95. {
  96. // Defines the boxes for all columns in this table, one entry per table column (spanning columns will add multiple entries).
  97. TrackBoxList columns;
  98. // Defines the boxes for all rows in this table, one entry per table row.
  99. TrackBoxList rows;
  100. // Defines the boxes for all cells in this table.
  101. BoxList cells;
  102. DetermineColumnWidths(columns, table_content_size.x);
  103. InitializeCellBoxes(cells, columns);
  104. DetermineRowHeights(rows, cells, table_content_size.y);
  105. FormatRows(rows, table_content_size.x);
  106. FormatColumns(columns, table_content_size.y);
  107. FormatCells(cells, table_overflow_size, rows, columns, table_baseline);
  108. }
  109. void TableFormattingContext::DetermineColumnWidths(TrackBoxList& columns, float& table_content_width) const
  110. {
  111. // The column widths are determined entirely by any <col> elements preceding the first row, and <td> elements in the first row.
  112. // If <col> has a fixed width, that is used. Otherwise, if <td> has a fixed width, that is used. Otherwise the column is 'flexible' width.
  113. // All flexible widths are then sized to evenly fill the width of the table.
  114. // Both <col> and <colgroup> can have border/padding which extend beyond the size of <td> and <col>, respectively.
  115. // Margins for <td>, <col>, <colgroup> are merged to produce a single left/right margin for each column, located outside <colgroup>.
  116. TrackMetricList column_metrics(grid.columns.size());
  117. TracksSizing sizing(column_metrics, table_initial_content_size.x, table_gap.x);
  118. // Use the <col> and <colgroup> elements for initializing the respective columns.
  119. for (int i = 0; i < (int)column_metrics.size(); i++)
  120. {
  121. if (Element* element_group = grid.columns[i].element_group)
  122. {
  123. const ComputedAxisSize computed = LayoutDetails::BuildComputedHorizontalSize(element_group->GetComputedValues());
  124. const int span = grid.columns[i].group_span;
  125. sizing.ApplyGroupElement(i, span, computed);
  126. }
  127. if (Element* element_column = grid.columns[i].element_column)
  128. {
  129. const ComputedAxisSize computed = LayoutDetails::BuildComputedHorizontalSize(element_column->GetComputedValues());
  130. const int span = grid.columns[i].column_span;
  131. sizing.ApplyTrackElement(i, span, computed);
  132. }
  133. }
  134. // Next, walk through the cells in the first table row, use their size if the column is still auto-sized.
  135. for (int i = 0; i < (int)grid.columns.size(); i++)
  136. {
  137. if (Element* element_cell = grid.columns[i].element_cell)
  138. {
  139. const ComputedAxisSize computed = LayoutDetails::BuildComputedHorizontalSize(element_cell->GetComputedValues());
  140. const int colspan = grid.columns[i].cell_span;
  141. sizing.ApplyCellElement(i, colspan, computed);
  142. }
  143. }
  144. // Convert any auto widths to flexible width.
  145. for (TrackMetric& metric : column_metrics)
  146. {
  147. if (metric.sizing_mode == TrackSizingMode::Auto)
  148. {
  149. metric.sizing_mode = TrackSizingMode::Flexible;
  150. metric.fixed_size = 0.0f;
  151. metric.flex_size = 1.0f;
  152. }
  153. }
  154. // Now all widths should be either fixed or flexible, resolve all flexible widths to fixed.
  155. sizing.ResolveFlexibleSize();
  156. // Generate the column results based on the metrics.
  157. const float columns_full_width = BuildColumnBoxes(columns, column_metrics, grid.columns, table_gap.x);
  158. // Adjust the table content width based on the accumulated column widths and spacing.
  159. table_content_width = Math::Clamp(columns_full_width, table_min_size.x, table_max_size.x);
  160. }
  161. void TableFormattingContext::InitializeCellBoxes(BoxList& cells, const TrackBoxList& columns) const
  162. {
  163. // Requires that column boxes are already generated.
  164. RMLUI_ASSERT(columns.size() == grid.columns.size());
  165. cells.resize(grid.cells.size());
  166. for (int i = 0; i < (int)cells.size(); i++)
  167. {
  168. Box& box = cells[i];
  169. // Determine the cell's box for formatting later, we may get an indefinite (-1) vertical content size.
  170. LayoutDetails::BuildBox(box, table_initial_content_size, grid.cells[i].element_cell, BuildBoxMode::UnalignedBlock);
  171. // Determine the cell's content width. Include any spanning columns in the cell width.
  172. const float cell_border_width = GetSpanningCellBorderSize(columns, grid.cells[i].column_begin, grid.cells[i].column_last);
  173. const float content_width =
  174. Math::Max(0.0f, cell_border_width - box.GetSizeAcross(BoxDirection::Horizontal, BoxArea::Border, BoxArea::Padding));
  175. box.SetContent(Vector2f(content_width, box.GetSize().y));
  176. }
  177. }
  178. void TableFormattingContext::DetermineRowHeights(TrackBoxList& rows, BoxList& cells, float& table_content_height) const
  179. {
  180. /*
  181. The table height algorithm works similar to the table width algorithm. The major difference is that 'auto' row height
  182. will use the height of the largest formatted cell in the row.
  183. Table row height:
  184. auto: Height of largest cell in row.
  185. length: Fixed size.
  186. percentage < 100%: Fixed size, resolved against table initial height.
  187. percentage >= 100%: Flexible size.
  188. Table height:
  189. auto: Height is sum of all rows.
  190. length/percentage: Fixed minimum size. If row height sum is larger, increase table size. If row sum is smaller, try to increase
  191. row heights, but respect max-heights. If table is still larger than row-sum, leave empty space.
  192. */
  193. // Requires that cell boxes have been initialized.
  194. RMLUI_ASSERT(cells.size() == grid.cells.size());
  195. TrackMetricList row_metrics(grid.rows.size());
  196. TracksSizing sizing(row_metrics, table_initial_content_size.y, table_gap.y);
  197. bool percentage_size_used = false;
  198. // First look for any <col> and <colgroup> elements preceding any <tr> elements, use them for initializing the respective columns.
  199. for (int i = 0; i < (int)grid.rows.size(); i++)
  200. {
  201. if (Element* element_group = grid.rows[i].element_group)
  202. {
  203. // The padding/border/margin of column groups are used, but their widths are ignored.
  204. const ComputedAxisSize computed = LayoutDetails::BuildComputedVerticalSize(element_group->GetComputedValues());
  205. const int span = grid.rows[i].group_span;
  206. sizing.ApplyGroupElement(i, span, computed);
  207. }
  208. if (Element* element_row = grid.rows[i].element_row)
  209. {
  210. // The padding/border/margin and widths of columns are used.
  211. const ComputedAxisSize computed = LayoutDetails::BuildComputedVerticalSize(element_row->GetComputedValues());
  212. if (computed.size.type == Style::LengthPercentageAuto::Percentage)
  213. percentage_size_used = true;
  214. sizing.ApplyTrackElement(i, 1, computed);
  215. }
  216. }
  217. if (table_auto_height && percentage_size_used)
  218. {
  219. Log::Message(Log::LT_WARNING,
  220. "Table has one or more rows that use percentages for height. However, initial table height is undefined, thus "
  221. "these rows will become flattened. Set a fixed height on the table, or use fixed or 'auto' row heights. In element: %s.",
  222. element_table->GetAddress().c_str());
  223. }
  224. // Next, find the height of rows that use auto height.
  225. // Auto height rows set their height according to the largest formatted cell size. This differs from the column width algorithm.
  226. for (int i = 0; i < (int)row_metrics.size(); i++)
  227. {
  228. TrackMetric& row_metric = row_metrics[i];
  229. if (row_metric.sizing_mode == TrackSizingMode::Auto)
  230. {
  231. struct CellLastRowComp {
  232. bool operator()(const TableGrid::Cell& cell, int i) const { return cell.row_last < i; }
  233. bool operator()(int i, const TableGrid::Cell& cell) const { return i < cell.row_last; }
  234. };
  235. // Determine which cells end at this row.
  236. const auto it_pair = std::equal_range(grid.cells.begin(), grid.cells.end(), i, CellLastRowComp{});
  237. const int cell_begin = int(it_pair.first - grid.cells.begin());
  238. const int cell_end = int(it_pair.second - grid.cells.begin());
  239. for (int cell_index = cell_begin; cell_index < cell_end; cell_index++)
  240. {
  241. const TableGrid::Cell& grid_cell = grid.cells[cell_index];
  242. Element* element_cell = grid_cell.element_cell;
  243. Box& box = cells[cell_index];
  244. // If both the row and the cell heights are 'auto', we need to format the cell to get its height.
  245. if (box.GetSize().y < 0)
  246. {
  247. FormattingContext::FormatIndependent(table_wrapper_box, element_cell, &box, FormattingContextType::Block);
  248. box.SetContent(element_cell->GetBox().GetSize());
  249. }
  250. // Find the height of the cell which applies only to this row.
  251. // In case it spans multiple rows, we must first subtract the height of any previous rows it spans. It is
  252. // unsupported if any spanning rows are flexibly sized, in which case we consider their size to be zero.
  253. const float gap_from_spanning_rows = table_gap.y * float(grid_cell.row_last - grid_cell.row_begin);
  254. const float height_from_spanning_rows = std::accumulate(row_metrics.begin() + grid_cell.row_begin,
  255. row_metrics.begin() + grid_cell.row_last, gap_from_spanning_rows, [](float acc_height, const TrackMetric& metric) {
  256. return acc_height + metric.fixed_size + metric.column_padding_border_a + metric.column_padding_border_b +
  257. metric.group_padding_border_a + metric.group_padding_border_b + metric.sum_margin_a + metric.sum_margin_b;
  258. });
  259. const float cell_inrow_height = box.GetSizeAcross(BoxDirection::Vertical, BoxArea::Border) - height_from_spanning_rows;
  260. // Now we have the height of the cell, increase the row height to accompany the cell.
  261. row_metric.fixed_size = Math::Max(row_metric.fixed_size, cell_inrow_height);
  262. }
  263. row_metric.sizing_mode = TrackSizingMode::Fixed;
  264. row_metric.flex_size = 0.0f;
  265. row_metric.fixed_size = Math::Clamp(row_metric.fixed_size, row_metric.min_size, row_metric.max_size);
  266. }
  267. }
  268. // Now all heights should be either fixed or flexible, resolve all flexible heights to fixed.
  269. sizing.ResolveFlexibleSize();
  270. // Generate the row boxes based on the metrics.
  271. const float rows_full_height = BuildRowBoxes(rows, row_metrics, grid.rows, table_gap.y);
  272. // Adjust the table content height based on the accumulated row heights and spacing.
  273. table_content_height = Math::Clamp(Math::Max(rows_full_height, table_initial_content_size.y), table_min_size.y, table_max_size.y);
  274. }
  275. void TableFormattingContext::FormatRows(const TrackBoxList& rows, float table_content_width) const
  276. {
  277. RMLUI_ASSERT(rows.size() == grid.rows.size());
  278. // Size and position the row and row group elements.
  279. auto FormatRow = [this, table_content_width](Element* element, float content_height, float offset_y) {
  280. Box box;
  281. // We use inline build mode here because we only care about padding, border, and (non-auto) margin.
  282. LayoutDetails::BuildBox(box, table_initial_content_size, element, BuildBoxMode::Inline);
  283. const Vector2f content_size(table_content_width - box.GetSizeAcross(BoxDirection::Horizontal, BoxArea::Margin, BoxArea::Padding),
  284. content_height);
  285. box.SetContent(content_size);
  286. element->SetBox(box);
  287. element->SetOffset(table_content_offset + Vector2f(box.GetEdge(BoxArea::Margin, BoxEdge::Left), offset_y), element_table);
  288. };
  289. for (int i = 0; i < (int)rows.size(); i++)
  290. {
  291. const TableGrid::Row& grid_row = grid.rows[i];
  292. const TrackBox& box = rows[i];
  293. if (grid_row.element_row)
  294. FormatRow(grid_row.element_row, box.track_size, box.track_offset);
  295. if (grid_row.element_group)
  296. FormatRow(grid_row.element_group, box.group_size, box.group_offset);
  297. }
  298. }
  299. void TableFormattingContext::FormatColumns(const TrackBoxList& columns, float table_content_height) const
  300. {
  301. RMLUI_ASSERT(columns.size() == grid.columns.size());
  302. // Size and position the column and column group elements.
  303. auto FormatColumn = [this, table_content_height](Element* element, float content_width, float offset_x) {
  304. Box box;
  305. // We use inline build mode here because we only care about padding, border, and (non-auto) margin.
  306. LayoutDetails::BuildBox(box, table_initial_content_size, element, BuildBoxMode::Inline);
  307. const Vector2f content_size(content_width,
  308. table_content_height - box.GetSizeAcross(BoxDirection::Vertical, BoxArea::Margin, BoxArea::Padding));
  309. box.SetContent(content_size);
  310. element->SetBox(box);
  311. element->SetOffset(table_content_offset + Vector2f(offset_x, box.GetEdge(BoxArea::Margin, BoxEdge::Top)), element_table);
  312. };
  313. for (int i = 0; i < (int)columns.size(); i++)
  314. {
  315. const TableGrid::Column& grid_column = grid.columns[i];
  316. const TrackBox& box = columns[i];
  317. if (grid_column.element_column)
  318. FormatColumn(grid_column.element_column, box.track_size, box.track_offset);
  319. if (grid_column.element_group)
  320. FormatColumn(grid_column.element_group, box.group_size, box.group_offset);
  321. }
  322. }
  323. void TableFormattingContext::FormatCells(BoxList& cells, Vector2f& table_overflow_size, const TrackBoxList& rows, const TrackBoxList& columns,
  324. float& table_baseline) const
  325. {
  326. RMLUI_ASSERT(cells.size() == grid.cells.size());
  327. bool baseline_set = false;
  328. for (int cell_index = 0; cell_index < (int)cells.size(); cell_index++)
  329. {
  330. const TableGrid::Cell& grid_cell = grid.cells[cell_index];
  331. Element* element_cell = grid_cell.element_cell;
  332. Box& box = cells[cell_index];
  333. Style::VerticalAlign vertical_align = element_cell->GetComputedValues().vertical_align();
  334. const float cell_border_height = GetSpanningCellBorderSize(rows, grid_cell.row_begin, grid_cell.row_last);
  335. const Vector2f cell_offset =
  336. table_content_offset + Vector2f(columns[grid_cell.column_begin].cell_offset, rows[grid_cell.row_begin].cell_offset);
  337. // Determine the height of the cell.
  338. if (box.GetSize().y < 0)
  339. {
  340. const bool is_aligned = (vertical_align.type == Style::VerticalAlign::Middle || vertical_align.type == Style::VerticalAlign::Bottom);
  341. if (is_aligned)
  342. {
  343. // We need to format the cell to know how much padding to add.
  344. FormattingContext::FormatIndependent(table_wrapper_box, element_cell, &box, FormattingContextType::Block);
  345. box.SetContent(element_cell->GetBox().GetSize());
  346. }
  347. else
  348. {
  349. // We don't need to add any padding and can thus avoid formatting, just set the height to the row height.
  350. box.SetContent(Vector2f(box.GetSize().x,
  351. Math::Max(0.0f, cell_border_height - box.GetSizeAcross(BoxDirection::Vertical, BoxArea::Border, BoxArea::Padding))));
  352. }
  353. }
  354. const float available_height = cell_border_height - box.GetSizeAcross(BoxDirection::Vertical, BoxArea::Border);
  355. if (available_height > 0)
  356. {
  357. // Pad the cell for vertical alignment
  358. float add_padding_top;
  359. float add_padding_bottom;
  360. switch (vertical_align.type)
  361. {
  362. case Style::VerticalAlign::Bottom:
  363. add_padding_top = available_height;
  364. add_padding_bottom = 0;
  365. break;
  366. case Style::VerticalAlign::Middle:
  367. add_padding_top = 0.5f * available_height;
  368. add_padding_bottom = 0.5f * available_height;
  369. break;
  370. case Style::VerticalAlign::Top:
  371. default:
  372. add_padding_top = 0.0f;
  373. add_padding_bottom = available_height;
  374. break;
  375. }
  376. box.SetEdge(BoxArea::Padding, BoxEdge::Top, box.GetEdge(BoxArea::Padding, BoxEdge::Top) + add_padding_top);
  377. box.SetEdge(BoxArea::Padding, BoxEdge::Bottom, box.GetEdge(BoxArea::Padding, BoxEdge::Bottom) + add_padding_bottom);
  378. }
  379. // Format the cell in a new block formatting context.
  380. // @performance: We may have already formatted the element during the above procedures without the extra padding. In that case, we may
  381. // instead set the new box and offset all descending elements whose offset parent is the cell, to account for the new padding box.
  382. // That should be faster than formatting the element again, but there may be edge-cases not accounted for.
  383. auto cell_box = FormattingContext::FormatIndependent(table_wrapper_box, element_cell, &box, FormattingContextType::Block);
  384. Vector2f cell_visible_overflow_size = cell_box->GetVisibleOverflowSize();
  385. // Set the position of the element within the table container
  386. element_cell->SetOffset(cell_offset, element_table);
  387. // The table baseline is simply set to the first cell that has a baseline.
  388. if (!baseline_set && cell_box->GetBaselineOfLastLine(table_baseline))
  389. {
  390. table_baseline += cell_offset.y;
  391. baseline_set = true;
  392. }
  393. // The cell contents may overflow, propagate this to the table.
  394. table_overflow_size.x = Math::Max(table_overflow_size.x, cell_offset.x - table_content_offset.x + cell_visible_overflow_size.x);
  395. table_overflow_size.y = Math::Max(table_overflow_size.y, cell_offset.y - table_content_offset.y + cell_visible_overflow_size.y);
  396. }
  397. }
  398. } // namespace Rml