TableCellBox.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/DOM/Element.h>
  7. #include <LibWeb/Layout/TableCellBox.h>
  8. #include <LibWeb/Layout/TableRowBox.h>
  9. namespace Web::Layout {
  10. TableCellBox::TableCellBox(DOM::Document& document, DOM::Element* element, NonnullRefPtr<CSS::StyleProperties> style)
  11. : Layout::BlockContainer(document, element, move(style))
  12. {
  13. }
  14. TableCellBox::TableCellBox(DOM::Document& document, DOM::Element* element, CSS::ComputedValues computed_values)
  15. : Layout::BlockContainer(document, element, move(computed_values))
  16. {
  17. }
  18. TableCellBox::~TableCellBox()
  19. {
  20. }
  21. size_t TableCellBox::colspan() const
  22. {
  23. if (!dom_node())
  24. return 1;
  25. return verify_cast<DOM::Element>(*dom_node()).attribute(HTML::AttributeNames::colspan).to_uint().value_or(1);
  26. }
  27. float TableCellBox::width_of_logical_containing_block() const
  28. {
  29. if (auto* row = first_ancestor_of_type<TableRowBox>())
  30. return row->width();
  31. return 0;
  32. }
  33. }