<col>'s width attribute can drive the preferred width of the table column (trac uses this)
<rdar://problem/56294715>
Created attachment 380994 [details] Patch
Comment on attachment 380994 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=380994&action=review > Source/WebCore/layout/tableformatting/TableFormattingContext.cpp:182 > + const Box* colgroup = nullptr; > + // Table caption is an optional element; if used, it is always the first child of a <table>. > + if (firstChild->isTableCaption()) > + tableCaption = firstChild; > + // The <colgroup> must appear after any optional <caption> element but before any <thead>, <th>, <tbody>, <tfoot> and <tr> element. > + auto* colgroupCandidate = firstChild; > + if (tableCaption) > + colgroupCandidate = tableCaption->nextSibling(); > + if (colgroupCandidate->isTableColumnGroup()) > + colgroup = colgroupCandidate; You might want to factor finding captions and colgroups into functions.
(In reply to Antti Koivisto from comment #3) > Comment on attachment 380994 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=380994&action=review > > > Source/WebCore/layout/tableformatting/TableFormattingContext.cpp:182 > > + const Box* colgroup = nullptr; > > + // Table caption is an optional element; if used, it is always the first child of a <table>. > > + if (firstChild->isTableCaption()) > > + tableCaption = firstChild; > > + // The <colgroup> must appear after any optional <caption> element but before any <thead>, <th>, <tbody>, <tfoot> and <tr> element. > > + auto* colgroupCandidate = firstChild; > > + if (tableCaption) > > + colgroupCandidate = tableCaption->nextSibling(); > > + if (colgroupCandidate->isTableColumnGroup()) > > + colgroup = colgroupCandidate; > > You might want to factor finding captions and colgroups into functions. good idea
(In reply to zalan from comment #4) > (In reply to Antti Koivisto from comment #3) > > Comment on attachment 380994 [details] > > Patch > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=380994&action=review > > > > > Source/WebCore/layout/tableformatting/TableFormattingContext.cpp:182 > > > + const Box* colgroup = nullptr; > > > + // Table caption is an optional element; if used, it is always the first child of a <table>. > > > + if (firstChild->isTableCaption()) > > > + tableCaption = firstChild; > > > + // The <colgroup> must appear after any optional <caption> element but before any <thead>, <th>, <tbody>, <tfoot> and <tr> element. > > > + auto* colgroupCandidate = firstChild; > > > + if (tableCaption) > > > + colgroupCandidate = tableCaption->nextSibling(); > > > + if (colgroupCandidate->isTableColumnGroup()) > > > + colgroup = colgroupCandidate; > > > > You might want to factor finding captions and colgroups into functions. > > good idea Though, as a second thought, this is the only time when we need traverse the layout tree in the table code (layout uses the grid and not the tree).
Comment on attachment 380994 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=380994&action=review >>>> Source/WebCore/layout/tableformatting/TableFormattingContext.cpp:182 >>>> + colgroup = colgroupCandidate; >>> >>> You might want to factor finding captions and colgroups into functions. >> >> good idea > > Though, as a second thought, this is the only time when we need traverse the layout tree in the table code (layout uses the grid and not the tree). Lambdas!
(In reply to Antti Koivisto from comment #6) > Comment on attachment 380994 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=380994&action=review > > >>>> Source/WebCore/layout/tableformatting/TableFormattingContext.cpp:182 > >>>> + colgroup = colgroupCandidate; > >>> > >>> You might want to factor finding captions and colgroups into functions. > >> > >> good idea > > > > Though, as a second thought, this is the only time when we need traverse the layout tree in the table code (layout uses the grid and not the tree). > > Lambdas! I love lambdas!
Comment on attachment 380994 [details] Patch Clearing flags on attachment: 380994 Committed r251147: <https://trac.webkit.org/changeset/251147>
All reviewed patches have been landed. Closing bug.