TableFormattingContext.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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/BlockFormattingContext.h>
  9. namespace Web::Layout {
  10. class TableFormattingContext final : public BlockFormattingContext {
  11. public:
  12. explicit TableFormattingContext(LayoutState&, BlockContainer const&, FormattingContext* parent);
  13. ~TableFormattingContext();
  14. virtual void run(Box const&, LayoutMode, AvailableSpace const&) override;
  15. virtual float 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(float&);
  20. void distribute_width_to_columns(float extra_width);
  21. void determine_intrisic_size_of_table_container(AvailableSpace const& available_space);
  22. float m_automatic_content_height { 0 };
  23. struct Column {
  24. float left_offset { 0 };
  25. float min_width { 0 };
  26. float max_width { 0 };
  27. float used_width { 0 };
  28. };
  29. struct Row {
  30. Box& box;
  31. float used_width { 0 };
  32. };
  33. struct Cell {
  34. Box& box;
  35. size_t column_index;
  36. size_t row_index;
  37. size_t column_span;
  38. size_t raw_span;
  39. };
  40. Vector<Cell> m_cells;
  41. Vector<Column> m_columns;
  42. Vector<Row> m_rows;
  43. };
  44. }