TableCellBox.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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() = default;
  19. size_t TableCellBox::colspan() const
  20. {
  21. if (!dom_node())
  22. return 1;
  23. return verify_cast<DOM::Element>(*dom_node()).attribute(HTML::AttributeNames::colspan).to_uint().value_or(1);
  24. }
  25. size_t TableCellBox::rowspan() const
  26. {
  27. if (!dom_node())
  28. return 1;
  29. return verify_cast<DOM::Element>(*dom_node()).attribute(HTML::AttributeNames::rowspan).to_uint().value_or(1);
  30. }
  31. }