소스 검색

LibWeb: Add LayoutTableCell::colspan()

A convenient function for looking up a cell's colspan attribute.
Andreas Kling 5 년 전
부모
커밋
0061a82be3
2개의 변경된 파일8개의 추가작업 그리고 0개의 파일을 삭제
  1. 6 0
      Libraries/LibWeb/Layout/LayoutTableCell.cpp
  2. 2 0
      Libraries/LibWeb/Layout/LayoutTableCell.h

+ 6 - 0
Libraries/LibWeb/Layout/LayoutTableCell.cpp

@@ -38,4 +38,10 @@ LayoutTableCell::~LayoutTableCell()
 {
 }
 
+size_t LayoutTableCell::colspan() const
+{
+    ASSERT(node());
+    return to<Element>(*node()).attribute(HTML::AttributeNames::colspan).to_uint().value_or(1);
+}
+
 }

+ 2 - 0
Libraries/LibWeb/Layout/LayoutTableCell.h

@@ -38,6 +38,8 @@ public:
     LayoutTableCell* next_cell() { return next_sibling_of_type<LayoutTableCell>(); }
     const LayoutTableCell* next_cell() const { return next_sibling_of_type<LayoutTableCell>(); }
 
+    size_t colspan() const;
+
 private:
     virtual bool is_table_cell() const override { return true; }
     virtual const char* class_name() const override { return "LayoutTableCell"; }