Changeset 106479 in webkit
- Timestamp:
- Feb 1, 2012 11:38:23 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 14 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r106477 r106479 1 2012-02-01 Max Vujovic <mvujovic@adobe.com> 2 3 Add support for min-width on the table element. 4 5 min-width is not implemented on <table> for table-layout: auto 6 https://bugs.webkit.org/show_bug.cgi?id=76553 7 8 Reviewed by Julien Chaffraix. 9 10 * fast/table/min-width-css-block-table.html: Added. 11 * fast/table/min-width-css-block-table-expected.txt: Added. 12 * fast/table/min-width-css-inline-table.html: Added. 13 * fast/table/min-width-css-inline-table-expected.txt: Added. 14 * fast/table/min-width-html-block-table.html: Added. 15 * fast/table/min-width-html-block-table-expected.txt: Added. 16 * fast/table/min-width-html-inline-table.html: Added. 17 * fast/table/min-width-html-inline-table-expected.txt: Added. 18 * fast/table/script-tests/min-width-css-block-table.js: Added. 19 (computeLogicalWidth): 20 * fast/table/script-tests/min-width-css-inline-table.js: Added. 21 (computeLogicalWidth): 22 * fast/table/script-tests/min-width-helpers.js: Added. 23 (runTests): 24 (createTableStyle): 25 (computeLogicalWidthHelper): 26 (createSpan): 27 * fast/table/script-tests/min-width-html-block-table.js: Added. 28 (computeLogicalWidth): 29 * fast/table/script-tests/min-width-html-inline-table.js: Added. 30 (computeLogicalWidth): 31 1 32 2012-02-01 Brian Salomon <bsalomon@google.com> 2 33 -
trunk/Source/WebCore/ChangeLog
r106477 r106479 1 2012-02-01 Max Vujovic <mvujovic@adobe.com> 2 3 Add support for fixed and percent min-width on the table element for table-layout: auto to 4 match Firefox and Opera's behavior. 5 6 In FixedTableLayout.cpp, the computePreferredLogicalWidths method looks like it has 7 issues based on the comment: "FIXME: This entire calculation is incorrect for both 8 minwidth and maxwidth." (minwidth and maxwidth refer to the preferred widths, not the 9 min-width and max-width styles). I have not implemented min-width for FixedTableLayout 10 in this patch since it requires some more research around that comment. 11 12 min-width and max-width on the table element was discussed on the www-style list: 13 http://lists.w3.org/Archives/Public/www-style/2012Jan/0684.html 14 15 min-width is not implemented on <table> for table-layout: auto 16 https://bugs.webkit.org/show_bug.cgi?id=76553 17 18 Reviewed by Julien Chaffraix. 19 20 Test: fast/table/min-width.html 21 22 * rendering/AutoTableLayout.cpp: 23 (WebCore::AutoTableLayout::computePreferredLogicalWidths): 24 25 If the min or max preferred logical width is less than a fixed min width style, it is 26 set to the fixed min width style. Like a percent width style, a percent min-width style 27 does not affect the min or max preferred logical widths computed by the table layout 28 algorithm. RenderTable's computeLogicalWidth method handles percent min-width styles. 29 30 min-width for the table-layout: fixed case has been split out into this bug: 31 https://bugs.webkit.org/show_bug.cgi?id=76948 32 33 * rendering/RenderTable.cpp: 34 (WebCore::RenderTable::computeLogicalWidth): 35 36 If the RenderStyle's logical min width is defined and greater than the logical width 37 calculation, this method sets the logical width to the logical min width. 38 39 (WebCore::RenderTable::convertStyleWidthToComputedWidth): 40 41 This new method generalizes and factors out logic from RenderTable::computeLogicalWidth 42 that converted the width style to a computed value in the fixed and percent case. 43 RenderTable::computeLogicalWidth now calls this method to determine the computed values 44 for both the width style and the min-width style. In the future, it can also be used for 45 the max-width style. 46 47 Note that this method handles the special CSS table case, which requires borders and 48 paddings to be included in the computed width calculation. This applies to all width 49 styles, including width, min-width, and max-width. Before, this special case was handled 50 in RenderTable::computeLogicalWidth. 51 52 * rendering/RenderTable.h: 53 1 54 2012-02-01 Brian Salomon <bsalomon@google.com> 2 55 -
trunk/Source/WebCore/rendering/AutoTableLayout.cpp
r105775 r106479 263 263 264 264 Length tableLogicalWidth = m_table->style()->logicalWidth(); 265 if (tableLogicalWidth.isFixed() && tableLogicalWidth. value() > 0) {265 if (tableLogicalWidth.isFixed() && tableLogicalWidth.isPositive()) { 266 266 minWidth = max<int>(minWidth, tableLogicalWidth.value()); 267 267 maxWidth = minWidth; … … 269 269 // if there was no remaining percent, maxWidth is invalid. 270 270 maxWidth = intMaxForLength; 271 } 272 273 Length tableLogicalMinWidth = m_table->style()->logicalMinWidth(); 274 if (tableLogicalMinWidth.isFixed() && tableLogicalMinWidth.isPositive()) { 275 minWidth = max<int>(minWidth, tableLogicalMinWidth.value()); 276 maxWidth = max<int>(minWidth, maxWidth); 271 277 } 272 278 } -
trunk/Source/WebCore/rendering/RenderTable.cpp
r105768 r106479 228 228 LayoutUnit containerWidthInInlineDirection = hasPerpendicularContainingBlock ? perpendicularContainingBlockLogicalHeight() : availableLogicalWidth; 229 229 230 LengthType logicalWidthType = style()->logicalWidth().type(); 231 if (logicalWidthType > Relative && style()->logicalWidth().isPositive()) { 232 // Percent or fixed table 233 // HTML tables size as though CSS width includes border/padding, CSS tables do not. 234 LayoutUnit borders = 0; 235 if (logicalWidthType != Percent && (!node() || !node()->hasTagName(tableTag))) { 236 recalcBordersInRowDirection(); 237 borders = borderStart() + borderEnd() + (collapseBorders() ? 0 : paddingStart() + paddingEnd()); 238 } 239 setLogicalWidth(style()->logicalWidth().calcMinValue(containerWidthInInlineDirection) + borders); 240 setLogicalWidth(max(minPreferredLogicalWidth(), logicalWidth())); 241 } else { 230 Length styleLogicalWidth = style()->logicalWidth(); 231 if (styleLogicalWidth.isSpecified() && styleLogicalWidth.isPositive()) 232 setLogicalWidth(convertStyleLogicalWidthToComputedWidth(styleLogicalWidth, containerWidthInInlineDirection)); 233 else { 242 234 // Subtract out any fixed margins from our available width for auto width tables. 243 235 LayoutUnit marginTotal = 0; … … 246 238 if (!style()->marginEnd().isAuto()) 247 239 marginTotal += style()->marginEnd().calcValue(availableLogicalWidth); 248 240 249 241 // Subtract out our margins to get the available content width. 250 242 LayoutUnit availableContentLogicalWidth = max<LayoutUnit>(0, containerWidthInInlineDirection - marginTotal); 251 252 // Ensure we aren't bigger than our max width or smaller than our minwidth.243 244 // Ensure we aren't bigger than our available width. 253 245 setLogicalWidth(min(availableContentLogicalWidth, maxPreferredLogicalWidth())); 254 246 } 255 247 248 // Ensure we aren't smaller than our min preferred width. 256 249 setLogicalWidth(max(logicalWidth(), minPreferredLogicalWidth())); 250 251 // Ensure we aren't smaller than our min-width style. 252 Length styleMinLogicalWidth = style()->logicalMinWidth(); 253 if (styleMinLogicalWidth.isSpecified() && styleMinLogicalWidth.isPositive()) 254 setLogicalWidth(max(logicalWidth(), convertStyleLogicalWidthToComputedWidth(styleMinLogicalWidth, availableLogicalWidth))); 257 255 258 256 // Finally, with our true width determined, compute our margins for real. … … 265 263 setMarginEnd(style()->marginEnd().calcMinValue(availableLogicalWidth)); 266 264 } 265 } 266 267 // This method takes a RenderStyle's logical width, min-width, or max-width length and computes its actual value. 268 LayoutUnit RenderTable::convertStyleLogicalWidthToComputedWidth(const Length& styleLogicalWidth, LayoutUnit availableWidth) 269 { 270 // HTML tables' width styles already include borders and paddings, but CSS tables' width styles do not. 271 LayoutUnit borders = 0; 272 bool isCSSTable = !node() || !node()->hasTagName(tableTag); 273 if (isCSSTable && styleLogicalWidth.isFixed() && styleLogicalWidth.isPositive()) { 274 recalcBordersInRowDirection(); 275 borders = borderStart() + borderEnd() + (collapseBorders() ? 0 : paddingStart() + paddingEnd()); 276 } 277 return styleLogicalWidth.calcMinValue(availableWidth) + borders; 267 278 } 268 279 -
trunk/Source/WebCore/rendering/RenderTable.h
r105768 r106479 241 241 virtual void computeLogicalWidth(); 242 242 243 LayoutUnit convertStyleLogicalWidthToComputedWidth(const Length& styleLogicalWidth, LayoutUnit availableWidth); 244 243 245 virtual LayoutRect overflowClipRect(const LayoutPoint& location, RenderRegion*, OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize); 244 246
Note: See TracChangeset
for help on using the changeset viewer.