Changeset 3952 in webkit
- Timestamp:
- Mar 27, 2003, 6:17:17 PM (22 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog-2003-10-25
r3951 r3952 1 2003-03-27 David Hyatt <hyatt@apple.com> 2 3 A collection of fixes for tables. 4 5 (1) Fixed table layout should only be used if an explicit width 6 is specified on a table. 7 (2) width="0" and height="0" should be ignored on table cells! 8 (3) Fixed table layout wasn't spreading extra space over 9 columns. 10 11 Reviewed by mjs 12 13 * khtml/html/html_tableimpl.cpp: 14 (HTMLTableCellElementImpl::parseAttribute): 15 * khtml/rendering/render_table.cpp: 16 (RenderTable::setStyle): 17 * khtml/rendering/table_layout.cpp: 18 (FixedTableLayout::layout): 19 1 20 2003-03-27 David Hyatt <hyatt@apple.com> 2 21 -
trunk/WebCore/ChangeLog-2005-08-23
r3951 r3952 1 2003-03-27 David Hyatt <hyatt@apple.com> 2 3 A collection of fixes for tables. 4 5 (1) Fixed table layout should only be used if an explicit width 6 is specified on a table. 7 (2) width="0" and height="0" should be ignored on table cells! 8 (3) Fixed table layout wasn't spreading extra space over 9 columns. 10 11 Reviewed by mjs 12 13 * khtml/html/html_tableimpl.cpp: 14 (HTMLTableCellElementImpl::parseAttribute): 15 * khtml/rendering/render_table.cpp: 16 (RenderTable::setStyle): 17 * khtml/rendering/table_layout.cpp: 18 (FixedTableLayout::layout): 19 1 20 2003-03-27 David Hyatt <hyatt@apple.com> 2 21 -
trunk/WebCore/khtml/html/html_tableimpl.cpp
r3869 r3952 855 855 break; 856 856 case ATTR_WIDTH: 857 if (!attr->value().isEmpty()) 858 addCSSLength( CSS_PROP_WIDTH, attr->value() ); 857 if (!attr->value().isEmpty()) { 858 int widthInt = attr->val()->toInt(); 859 if (widthInt > 0) // width="0" is ignored for compatibility with WinIE. 860 addCSSLength( CSS_PROP_WIDTH, attr->value() ); 861 } 859 862 else 860 863 removeCSSProperty(CSS_PROP_WIDTH); 864 break; 865 case ATTR_HEIGHT: 866 if (!attr->value().isEmpty()) { 867 int heightInt = attr->val()->toInt(); 868 if (heightInt > 0) // height="0" is ignored for compatibility with WinIE. 869 addCSSLength( CSS_PROP_HEIGHT, attr->value() ); 870 } 871 else 872 removeCSSProperty(CSS_PROP_HEIGHT); 861 873 break; 862 874 case ATTR_NOSAVE: -
trunk/WebCore/khtml/rendering/render_table.cpp
r3951 r3952 92 92 delete tableLayout; 93 93 94 if (style()->tableLayout() == TFIXED ) { 94 // According to the CSS2 spec, you only use fixed table layout if an 95 // explicit width is specified on the table. Auto width implies auto table layout. 96 if (style()->tableLayout() == TFIXED && !style()->width().isVariable()) { 95 97 tableLayout = new FixedTableLayout(this); 96 98 #ifdef DEBUG_LAYOUT -
trunk/WebCore/khtml/rendering/table_layout.cpp
r3810 r3952 264 264 int available = tableWidth; 265 265 int nEffCols = table->numEffCols(); 266 int totalPercent = 0; 267 266 268 #ifdef DEBUG_LAYOUT 267 269 qDebug("FixedTableLayout::layout: tableWidth=%d, numEffCols=%d", tableWidth, nEffCols); … … 273 275 calcWidth.fill( -1 ); 274 276 275 // first assign fixed width276 for ( int i = 0; i < nEffCols; i++ ) {277 if ( width[i].type == Fixed ) {278 calcWidth[i] = width[i].value;279 available -= width[i].value;280 }281 }282 283 277 // assign percent width 284 278 if ( available > 0 ) { 285 int totalPercent = 0; 286 for ( int i = 0; i < nEffCols; i++ ) 287 if ( width[i].type == Percent ) 288 totalPercent += width[i].value; 289 290 // calculate how much to distribute to percent cells. 291 int base = tableWidth * totalPercent / 100; 292 if ( base > available ) 293 base = available; 294 else 295 totalPercent = 100; 296 297 #ifdef DEBUG_LAYOUT 298 qDebug("FixedTableLayout::layout: assigning percent width, base=%d, totalPercent=%d", base, totalPercent); 279 for ( int i = 0; i < nEffCols; i++ ) 280 if ( width[i].type == Percent ) 281 totalPercent += width[i].value; 282 283 // calculate how much to distribute to percent cells. 284 int base = tableWidth * totalPercent / 100; 285 if ( base > available ) 286 base = available; 287 else 288 totalPercent = 100; 289 290 #ifdef DEBUG_LAYOUT 291 qDebug("FixedTableLayout::layout: assigning percent width, base=%d, totalPercent=%d", base, totalPercent); 299 292 #endif 300 293 for ( int i = 0; available > 0 && i < nEffCols; i++ ) { … … 306 299 } 307 300 } 308 309 // assign variable width 301 302 // next assign fixed width 303 for ( int i = 0; i < nEffCols; i++ ) { 304 if ( width[i].type == Fixed ) { 305 calcWidth[i] = width[i].value; 306 available -= width[i].value; 307 } 308 } 309 310 // assign variable width 310 311 if ( available > 0 ) { 311 312 int totalVariable = 0; … … 328 329 calcWidth[i] = 0; // IE gives min 1 px... 329 330 331 // spread extra space over columns 332 if ( available > 0 ) { 333 int total = nEffCols; 334 // still have some width to spread 335 int i = nEffCols; 336 while ( i-- ) { 337 int w = available / total; 338 available -= w; 339 total--; 340 calcWidth[i] += w; 341 } 342 } 343 330 344 int pos = 0; 331 345 int spacing = table->cellSpacing();
Note:
See TracChangeset
for help on using the changeset viewer.