| 45 | } |
| 46 | |
| 47 | void TableLayouter::computeIntrinsicWidths() { |
| 48 | if ( !mIntrinsicWidthsDirty ) |
| 49 | return; |
| 50 | |
| 51 | mRows.clear(); |
| 52 | mHead = nullptr; |
| 53 | mBody = nullptr; |
| 54 | mFooter = nullptr; |
| 55 | mCells.clear(); |
| 56 | mRowCellOffsets.clear(); |
| 57 | |
| 58 | auto collectRows = [&]( auto&& self, Node* node ) -> void { |
| 59 | for ( Node* child = node->getFirstChild(); child; child = child->getNextNode() ) { |
| 60 | if ( child->getType() == UI_TYPE_HTML_TABLE_ROW ) { |
| 61 | mRows.push_back( child->asType<UIHTMLTableRow>() ); |
| 62 | } else if ( child->getType() != UI_TYPE_HTML_TABLE ) { |
| 63 | if ( child->getType() == UI_TYPE_HTML_TABLE_HEAD ) |
| 64 | mHead = child->asType<UIHTMLTableHead>(); |
| 65 | else if ( child->getType() == UI_TYPE_HTML_TABLE_BODY ) |
| 66 | mBody = child->asType<UIHTMLTableBody>(); |
| 67 | else if ( child->getType() == UI_TYPE_HTML_TABLE_FOOTER ) |
| 68 | mFooter = child->asType<UIHTMLTableFooter>(); |
| 69 | |
| 70 | self( self, child ); |
| 71 | } |
| 72 | } |
| 73 | }; |
| 74 | collectRows( collectRows, mContainer ); |
| 75 | |
| 76 | auto getRecursiveSpecifiedWidth = [&]( auto&& self, Node* node ) -> Float { |
| 77 | if ( !node->isWidget() ) |
| 78 | return 0.f; |
| 79 | UIWidget* widget = node->asType<UIWidget>(); |
| 80 | Float spec = 0.f; |
| 81 | if ( widget->getLayoutWidthPolicy() == SizePolicy::Fixed ) |
| 82 | spec = sanitizeFloat( widget->getPropertyWidth() ); |
| 83 | for ( Node* child = node->getFirstChild(); child; child = child->getNextNode() ) |
| 84 | spec = std::max( spec, self( self, child ) ); |
| 85 | return spec; |
| 86 | }; |
| 87 | |
| 88 | if ( mRows.empty() ) { |
| 89 | mMinIntrinsicWidth = mMaxIntrinsicWidth = |
| 90 | mContainer->getPixelsPadding().Left + mContainer->getPixelsPadding().Right; |
| 91 | mIntrinsicWidthsDirty = false; |
| 92 | return; |
| 93 | } |
| 94 | |
| 95 | mRowCellOffsets.push_back( 0 ); |
| 96 | size_t maxCols = 0; |
| 97 | for ( auto* row : mRows ) { |
| 98 | size_t colCount = 0; |
| 99 | for ( Node* child = row->getFirstChild(); child; child = child->getNextNode() ) { |
| 100 | if ( child->getType() == UI_TYPE_HTML_TABLE_CELL ) { |
| 101 | auto* cell = child->asType<UIHTMLTableCell>(); |
| 102 | mCells.push_back( cell ); |
| 103 | colCount += cell->getColspan(); |
| 104 | if ( mCellpadding > 0 && cell->getPadding() == Rectf::Zero ) { |
nothing calls this directly
no test coverage detected