TableFormattingContext.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Forward.h>
  8. #include <LibWeb/Layout/FormattingContext.h>
  9. namespace Web::Layout {
  10. class TableFormattingContext final : public FormattingContext {
  11. public:
  12. explicit TableFormattingContext(LayoutState&, BlockContainer const&, FormattingContext* parent);
  13. ~TableFormattingContext();
  14. virtual void run(Box const&, LayoutMode, AvailableSpace const&) override;
  15. virtual CSSPixels automatic_content_height() const override;
  16. private:
  17. void calculate_row_column_grid(Box const&);
  18. void compute_table_measures();
  19. void compute_table_width();
  20. void distribute_width_to_columns();
  21. void determine_intrisic_size_of_table_container(AvailableSpace const& available_space);
  22. CSSPixels m_automatic_content_height { 0 };
  23. Optional<AvailableSpace> m_available_space;
  24. enum class ColumnType {
  25. Percent,
  26. Pixel,
  27. Auto
  28. };
  29. struct Column {
  30. ColumnType type { ColumnType::Auto };
  31. CSSPixels left_offset { 0 };
  32. CSSPixels min_width { 0 };
  33. CSSPixels max_width { 0 };
  34. CSSPixels used_width { 0 };
  35. float percentage_width { 0 };
  36. };
  37. struct Row {
  38. Box& box;
  39. CSSPixels used_width { 0 };
  40. CSSPixels baseline { 0 };
  41. };
  42. struct Cell {
  43. Box& box;
  44. size_t column_index;
  45. size_t row_index;
  46. size_t column_span;
  47. size_t row_span;
  48. CSSPixels baseline { 0 };
  49. };
  50. Vector<Cell> m_cells;
  51. Vector<Column> m_columns;
  52. Vector<Row> m_rows;
  53. };
  54. }