InlineFormattingContext.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright (c) 2020-2022, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Types.h>
  8. #include <LibWeb/Forward.h>
  9. #include <LibWeb/Layout/BlockContainer.h>
  10. #include <LibWeb/Layout/FormattingContext.h>
  11. namespace Web::Layout {
  12. class InlineFormattingContext final : public FormattingContext {
  13. public:
  14. InlineFormattingContext(LayoutState&, BlockContainer const& containing_block, BlockFormattingContext& parent);
  15. ~InlineFormattingContext();
  16. BlockFormattingContext& parent();
  17. BlockFormattingContext const& parent() const;
  18. BlockContainer const& containing_block() const { return static_cast<BlockContainer const&>(context_box()); }
  19. virtual void run(Box const&, LayoutMode, AvailableSpace const&) override;
  20. virtual CSSPixels automatic_content_height() const override;
  21. virtual CSSPixels automatic_content_width() const override;
  22. void dimension_box_on_line(Box const&, LayoutMode);
  23. CSSPixels leftmost_x_offset_at(CSSPixels y) const;
  24. CSSPixels available_space_for_line(CSSPixels y) const;
  25. bool any_floats_intrude_at_y(CSSPixels y) const;
  26. bool can_fit_new_line_at_y(CSSPixels y) const;
  27. private:
  28. void generate_line_boxes(LayoutMode);
  29. void apply_justification_to_fragments(CSS::TextJustify, LineBox&, bool is_last_line);
  30. LayoutState::UsedValues const& m_containing_block_state;
  31. Optional<AvailableSpace> m_available_space;
  32. CSSPixels m_automatic_content_width { 0 };
  33. CSSPixels m_automatic_content_height { 0 };
  34. };
  35. }