MCPcopy Create free account
hub / github.com/SpartanJ/eepp / computeIntrinsicWidths

Method computeIntrinsicWidths

src/eepp/ui/tablelayouter.cpp:47–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47void 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 ) {

Callers

nothing calls this directly

Calls 15

sanitizeFloatFunction · 0.85
getFirstChildMethod · 0.80
getNextNodeMethod · 0.80
push_backMethod · 0.80
isWidgetMethod · 0.80
getPropertyWidthMethod · 0.80
getColspanMethod · 0.80
assignMethod · 0.80
clearMethod · 0.45
getTypeMethod · 0.45
emptyMethod · 0.45
setPaddingMethod · 0.45

Tested by

no test coverage detected