LineBox.cpp 704 B

1234567891011121314
  1. #include <LibHTML/Layout/LineBox.h>
  2. void LineBox::add_fragment(const LayoutNode& layout_node, int start, int length, int width, int height)
  3. {
  4. if (!m_fragments.is_empty() && &m_fragments.last().layout_node() == &layout_node) {
  5. // The fragment we're adding is from the last LayoutNode on the line.
  6. // Expand the last fragment instead of adding a new one with the same LayoutNode.
  7. m_fragments.last().m_length = (start - m_fragments.last().m_start) + length;
  8. m_fragments.last().m_rect.set_width(m_fragments.last().m_rect.width() + width);
  9. } else {
  10. m_fragments.empend(layout_node, start, length, Rect(m_width, 0, width, height));
  11. }
  12. m_width += width;
  13. }