Changeset 18790 in webkit
- Timestamp:
- Jan 11, 2007 8:28:05 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r18788 r18790 1 2007-01-11 Mitz Pettel <mitz@webkit.org> 2 3 Reviewed by Hyatt. 4 5 - updated results for http://bugs.webkit.org/show_bug.cgi?id=12115 6 RTL text is jumbled on display 7 (fixing fixed table layout) 8 9 * tables/mozilla/bugs/bug157890-expected.checksum: 10 * tables/mozilla/bugs/bug157890-expected.png: 11 * tables/mozilla/bugs/bug157890-expected.txt: 12 * tables/mozilla/bugs/bug44505-expected.checksum: 13 * tables/mozilla/bugs/bug44505-expected.png: 14 * tables/mozilla/bugs/bug44505-expected.txt: 15 * tables/mozilla_expected_failures/bugs/bug7243-expected.checksum: 16 * tables/mozilla_expected_failures/bugs/bug7243-expected.png: 17 * tables/mozilla_expected_failures/bugs/bug7243-expected.txt: 18 1 19 2007-01-11 Mitz Pettel <mitz@webkit.org> 2 20 -
trunk/LayoutTests/tables/mozilla/bugs/bug157890-expected.checksum
r14222 r18790 1 94c3e0cdcbd44a143545d5d7131902c1 1 7dd09a4474aae5290b806f3d85feb26f -
trunk/LayoutTests/tables/mozilla/bugs/bug157890-expected.txt
r14684 r18790 43 43 RenderTableSection {TBODY} at (0,0) size 24x0 44 44 RenderTableRow {TR} at (0,0) size 24x0 45 RenderTableCell {TD} at (0,0) size 4x0 [r=0 c=0 rs=1 cs=1]46 RenderTableCell {TD} at ( 4,0) size 4x0 [r=0 c=1 rs=1 cs=1]47 RenderTableCell {TD} at ( 8,0) size 3x0 [r=0 c=2 rs=1 cs=1]48 RenderTableCell {TD} at ( 11,0) size 3x0 [r=0 c=3 rs=1 cs=1]49 RenderTableCell {TD} at ( 14,0) size 10x0 [r=0 c=4 rs=1 cs=1]45 RenderTableCell {TD} at (0,0) size 2x0 [r=0 c=0 rs=1 cs=1] 46 RenderTableCell {TD} at (2,0) size 2x0 [r=0 c=1 rs=1 cs=1] 47 RenderTableCell {TD} at (4,0) size 2x0 [r=0 c=2 rs=1 cs=1] 48 RenderTableCell {TD} at (6,0) size 2x0 [r=0 c=3 rs=1 cs=1] 49 RenderTableCell {TD} at (8,0) size 16x0 [r=0 c=4 rs=1 cs=1] 50 50 RenderTable {TABLE} at (0,0) size 25x0 51 51 RenderTableSection {TBODY} at (0,0) size 25x0 52 52 RenderTableRow {TR} at (0,0) size 25x0 53 RenderTableCell {TD} at (0,0) size 4x0 [r=0 c=0 rs=1 cs=1]54 RenderTableCell {TD} at ( 4,0) size 4x0 [r=0 c=1 rs=1 cs=1]55 RenderTableCell {TD} at ( 8,0) size 4x0 [r=0 c=2 rs=1 cs=1]56 RenderTableCell {TD} at ( 12,0) size 3x0 [r=0 c=3 rs=1 cs=1]57 RenderTableCell {TD} at ( 15,0) size 10x0 [r=0 c=4 rs=1 cs=1]58 RenderTable {TABLE} at (0,0) size 1 00x059 RenderTableSection {TBODY} at (0,0) size 1 00x060 RenderTableRow {TR} at (0,0) size 1 00x061 RenderTableCell {TD} at (0,0) size 10x0 [r=0 c=0 rs=1 cs=1]62 RenderTableCell {TD} at ( 10,0) size 10x0 [r=0 c=1 rs=1 cs=1]63 RenderTableCell {TD} at ( 20,0) size 10x0 [r=0 c=2 rs=1 cs=1]64 RenderTableCell {TD} at ( 30,0) size 10x0 [r=0 c=3 rs=1 cs=1]65 RenderTableCell {TD} at ( 40,0) size 10x0 [r=0 c=4 rs=1 cs=1]66 RenderTableCell {TD} at ( 50,0) size 10x0 [r=0 c=5 rs=1 cs=1]67 RenderTableCell {TD} at ( 60,0) size 10x0 [r=0 c=6 rs=1 cs=1]68 RenderTableCell {TD} at ( 70,0) size 10x0 [r=0 c=7 rs=1 cs=1]69 RenderTableCell {TD} at ( 80,0) size 10x0 [r=0 c=8 rs=1 cs=1]70 RenderTableCell {TD} at ( 90,0) size 10x0 [r=0 c=9 rs=1 cs=1]53 RenderTableCell {TD} at (0,0) size 3x0 [r=0 c=0 rs=1 cs=1] 54 RenderTableCell {TD} at (3,0) size 2x0 [r=0 c=1 rs=1 cs=1] 55 RenderTableCell {TD} at (5,0) size 2x0 [r=0 c=2 rs=1 cs=1] 56 RenderTableCell {TD} at (7,0) size 2x0 [r=0 c=3 rs=1 cs=1] 57 RenderTableCell {TD} at (9,0) size 16x0 [r=0 c=4 rs=1 cs=1] 58 RenderTable {TABLE} at (0,0) size 17x0 59 RenderTableSection {TBODY} at (0,0) size 17x0 60 RenderTableRow {TR} at (0,0) size 17x0 61 RenderTableCell {TD} at (0,0) size 2x0 [r=0 c=0 rs=1 cs=1] 62 RenderTableCell {TD} at (2,0) size 2x0 [r=0 c=1 rs=1 cs=1] 63 RenderTableCell {TD} at (4,0) size 2x0 [r=0 c=2 rs=1 cs=1] 64 RenderTableCell {TD} at (6,0) size 2x0 [r=0 c=3 rs=1 cs=1] 65 RenderTableCell {TD} at (8,0) size 2x0 [r=0 c=4 rs=1 cs=1] 66 RenderTableCell {TD} at (10,0) size 2x0 [r=0 c=5 rs=1 cs=1] 67 RenderTableCell {TD} at (12,0) size 2x0 [r=0 c=6 rs=1 cs=1] 68 RenderTableCell {TD} at (14,0) size 1x0 [r=0 c=7 rs=1 cs=1] 69 RenderTableCell {TD} at (15,0) size 1x0 [r=0 c=8 rs=1 cs=1] 70 RenderTableCell {TD} at (16,0) size 1x0 [r=0 c=9 rs=1 cs=1] 71 71 RenderBlock {PRE} at (0,13) size 784x450 72 72 RenderText {#text} at (0,0) size 216x15 … … 246 246 text run at (0,270) width 168: "Actual TD widths: " 247 247 RenderText {#text} at (168,270) size 32x15 248 text run at (168,270) width 32: " 4px "248 text run at (168,270) width 32: "2px " 249 249 RenderText {#text} at (200,270) size 32x15 250 text run at (200,270) width 32: " 4px "250 text run at (200,270) width 32: "2px " 251 251 RenderText {#text} at (232,270) size 32x15 252 text run at (232,270) width 32: " 3px "252 text run at (232,270) width 32: "2px " 253 253 RenderText {#text} at (264,270) size 32x15 254 text run at (264,270) width 32: " 3px "254 text run at (264,270) width 32: "2px " 255 255 RenderText {#text} at (296,270) size 40x15 256 text run at (296,270) width 40: "1 0px "256 text run at (296,270) width 40: "16px " 257 257 RenderText {#text} at (336,270) size 336x30 258 258 text run at (336,270) width 0: " " … … 281 281 text run at (0,345) width 168: "Actual TD widths: " 282 282 RenderText {#text} at (168,345) size 32x15 283 text run at (168,345) width 32: " 4px "283 text run at (168,345) width 32: "3px " 284 284 RenderText {#text} at (200,345) size 32x15 285 text run at (200,345) width 32: " 4px "285 text run at (200,345) width 32: "2px " 286 286 RenderText {#text} at (232,345) size 32x15 287 text run at (232,345) width 32: " 4px "287 text run at (232,345) width 32: "2px " 288 288 RenderText {#text} at (264,345) size 32x15 289 text run at (264,345) width 32: " 3px "289 text run at (264,345) width 32: "2px " 290 290 RenderText {#text} at (296,345) size 40x15 291 text run at (296,345) width 40: "1 0px "291 text run at (296,345) width 40: "16px " 292 292 RenderText {#text} at (336,345) size 336x30 293 293 text run at (336,345) width 0: " " … … 296 296 text run at (0,375) width 216: "Specified table width: 17px" 297 297 text run at (216,375) width 0: " " 298 RenderText {#text} at (0,390) size 2 24x15299 text run at (0,390) width 2 24: "Actual table width: 100px"300 text run at (2 24,390) width 0: " "298 RenderText {#text} at (0,390) size 216x15 299 text run at (0,390) width 216: "Actual table width: 17px" 300 text run at (216,390) width 0: " " 301 301 RenderText {#text} at (0,405) size 168x15 302 302 text run at (0,405) width 168: "Specified TD widths: " … … 325 325 RenderText {#text} at (0,420) size 168x15 326 326 text run at (0,420) width 168: "Actual TD widths: " 327 RenderText {#text} at (168,420) size 40x15328 text run at (168,420) width 40: "10px "329 RenderText {#text} at (20 8,420) size 40x15330 text run at (20 8,420) width 40: "10px "331 RenderText {#text} at (2 48,420) size 40x15332 text run at (2 48,420) width 40: "10px "333 RenderText {#text} at (2 88,420) size 40x15334 text run at (2 88,420) width 40: "10px "335 RenderText {#text} at ( 328,420) size 40x15336 text run at ( 328,420) width 40: "10px "337 RenderText {#text} at (3 68,420) size 40x15338 text run at (3 68,420) width 40: "10px "339 RenderText {#text} at ( 408,420) size 40x15340 text run at ( 408,420) width 40: "10px "341 RenderText {#text} at ( 448,420) size 40x15342 text run at ( 448,420) width 40: "10px "343 RenderText {#text} at (4 88,420) size 40x15344 text run at (4 88,420) width 40: "10px "345 RenderText {#text} at ( 528,420) size 40x15346 text run at ( 528,420) width 40: "10px "347 RenderText {#text} at ( 568,420) size 568x30348 text run at ( 568,420) width 0: " "327 RenderText {#text} at (168,420) size 32x15 328 text run at (168,420) width 32: "2px " 329 RenderText {#text} at (200,420) size 32x15 330 text run at (200,420) width 32: "2px " 331 RenderText {#text} at (232,420) size 32x15 332 text run at (232,420) width 32: "2px " 333 RenderText {#text} at (264,420) size 32x15 334 text run at (264,420) width 32: "2px " 335 RenderText {#text} at (296,420) size 32x15 336 text run at (296,420) width 32: "2px " 337 RenderText {#text} at (328,420) size 32x15 338 text run at (328,420) width 32: "2px " 339 RenderText {#text} at (360,420) size 32x15 340 text run at (360,420) width 32: "2px " 341 RenderText {#text} at (392,420) size 32x15 342 text run at (392,420) width 32: "1px " 343 RenderText {#text} at (424,420) size 32x15 344 text run at (424,420) width 32: "1px " 345 RenderText {#text} at (456,420) size 32x15 346 text run at (456,420) width 32: "1px " 347 RenderText {#text} at (488,420) size 488x30 348 text run at (488,420) width 0: " " 349 349 text run at (0,435) width 0: " " -
trunk/LayoutTests/tables/mozilla/bugs/bug44505-expected.checksum
r16428 r18790 1 3dc0ee2d6ae1cea2c88defc9405414a2 1 2dddf239d6fc289d8e025d9b6b2a0a50 -
trunk/LayoutTests/tables/mozilla/bugs/bug44505-expected.txt
r14684 r18790 74 74 RenderText {#text} at (2,2) size 4x18 75 75 text run at (2,2) width 4: " " 76 layer at (11,115) size 186x22 clip at (12,116) size 184x2077 RenderTableCell {TD} at (2,2) size 186x22 [bgcolor=#0000FF] [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]78 RenderText {#text} at (2,2) size 4x18 79 text run at (2,2) width 4: " " 80 layer at ( 199,115) size 106x22 clip at (200,116) size 104x2081 RenderTableCell {TD} at ( 190,2) size 106x22 [bgcolor=#0000FF] [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]82 RenderText {#text} at (2,2) size 4x18 83 text run at (2,2) width 4: " " 84 layer at (11,139) size 186x22 clip at (12,140) size 184x2085 RenderTableCell {TD} at (2,26) size 186x22 [bgcolor=#0000FF] [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1]86 RenderText {#text} at (2,2) size 4x18 87 text run at (2,2) width 4: " " 88 layer at ( 199,139) size 106x22 clip at (200,140) size 104x2089 RenderTableCell {TD} at ( 190,26) size 106x22 [bgcolor=#0000FF] [border: (1px inset #808080)] [r=1 c=1 rs=1 cs=1]76 layer at (11,115) size 233x22 clip at (12,116) size 231x20 77 RenderTableCell {TD} at (2,2) size 233x22 [bgcolor=#0000FF] [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1] 78 RenderText {#text} at (2,2) size 4x18 79 text run at (2,2) width 4: " " 80 layer at (246,115) size 59x22 clip at (247,116) size 57x20 81 RenderTableCell {TD} at (237,2) size 59x22 [bgcolor=#0000FF] [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1] 82 RenderText {#text} at (2,2) size 4x18 83 text run at (2,2) width 4: " " 84 layer at (11,139) size 233x22 clip at (12,140) size 231x20 85 RenderTableCell {TD} at (2,26) size 233x22 [bgcolor=#0000FF] [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1] 86 RenderText {#text} at (2,2) size 4x18 87 text run at (2,2) width 4: " " 88 layer at (246,139) size 59x22 clip at (247,140) size 57x20 89 RenderTableCell {TD} at (237,26) size 59x22 [bgcolor=#0000FF] [border: (1px inset #808080)] [r=1 c=1 rs=1 cs=1] 90 90 RenderText {#text} at (2,2) size 4x18 91 91 text run at (2,2) width 4: " " -
trunk/LayoutTests/tables/mozilla_expected_failures/bugs/bug7243-expected.checksum
r16430 r18790 1 cea4667d98e0d80f994bddcf9cc10b3e 1 7be8b6d1e975ddade007fb9f4cb9f53f -
trunk/LayoutTests/tables/mozilla_expected_failures/bugs/bug7243-expected.txt
r16357 r18790 22 22 RenderTableSection {TBODY} at (1,1) size 398x22 23 23 RenderTableRow {TR} at (0,0) size 398x22 24 RenderTableCell {TD} at (0,0) size 1 49x22 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]24 RenderTableCell {TD} at (0,0) size 133x22 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1] 25 25 RenderText {#text} at (2,2) size 21x18 26 26 text run at (2,2) width 21: "foo" 27 RenderTableCell {TD} at (1 49,0) size 249x22 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]27 RenderTableCell {TD} at (133,0) size 265x22 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1] 28 28 RenderText {#text} at (2,2) size 20x18 29 29 text run at (2,2) width 20: "bar" … … 69 69 RenderTableSection {TBODY} at (1,1) size 782x104 70 70 RenderTableRow {TR} at (0,20) size 782x22 71 RenderTableCell {TD} at (20,20) size 422x22 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=2]71 RenderTableCell {TD} at (20,20) size 301x22 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=2] 72 72 RenderText {#text} at (2,2) size 21x18 73 73 text run at (2,2) width 21: "foo" 74 RenderTableCell {TD} at ( 462,20) size 300x22 [border: (1px inset #808080)] [r=0 c=2 rs=1 cs=1]74 RenderTableCell {TD} at (341,20) size 421x22 [border: (1px inset #808080)] [r=0 c=2 rs=1 cs=1] 75 75 RenderText {#text} at (2,2) size 20x18 76 76 text run at (2,2) width 20: "bar" 77 77 RenderTableRow {TR} at (0,62) size 782x22 78 RenderTableCell {TD} at (20,62) size 201x22 [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1]78 RenderTableCell {TD} at (20,62) size 141x22 [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1] 79 79 RenderText {#text} at (2,2) size 21x18 80 80 text run at (2,2) width 21: "foo" 81 RenderTableCell {TD} at ( 241,62) size 201x22 [border: (1px inset #808080)] [r=1 c=1 rs=1 cs=1]81 RenderTableCell {TD} at (181,62) size 140x22 [border: (1px inset #808080)] [r=1 c=1 rs=1 cs=1] 82 82 RenderText {#text} at (2,2) size 20x18 83 83 text run at (2,2) width 20: "bar" 84 RenderTableCell {TD} at ( 462,62) size 300x22 [border: (1px inset #808080)] [r=1 c=2 rs=1 cs=1]84 RenderTableCell {TD} at (341,62) size 421x22 [border: (1px inset #808080)] [r=1 c=2 rs=1 cs=1] 85 85 RenderText {#text} at (2,2) size 20x18 86 86 text run at (2,2) width 20: "bar" … … 105 105 RenderTableSection {TBODY} at (1,1) size 98x42 106 106 RenderTableRow {TR} at (0,10) size 98x22 107 RenderTableCell {TD} at (10,10) size 23x22 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]107 RenderTableCell {TD} at (10,10) size 16x22 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1] 108 108 RenderText {#text} at (2,2) size 21x18 109 109 text run at (2,2) width 21: "foo" 110 RenderTableCell {TD} at ( 43,10) size 34x22 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1]110 RenderTableCell {TD} at (36,10) size 22x22 [border: (1px inset #808080)] [r=0 c=1 rs=1 cs=1] 111 111 RenderText {#text} at (2,2) size 21x18 112 112 text run at (2,2) width 21: "foo" 113 RenderTableCell {TD} at ( 87,10) size 20x22 [border: (1px inset #808080)] [r=0 c=2 rs=1 cs=1]113 RenderTableCell {TD} at (68,10) size 20x22 [border: (1px inset #808080)] [r=0 c=2 rs=1 cs=1] 114 114 RenderText {#text} at (2,2) size 21x18 115 115 text run at (2,2) width 21: "foo" -
trunk/WebCore/ChangeLog
r18788 r18790 1 2007-01-11 Mitz Pettel <mitz@webkit.org> 2 3 Reviewed by Hyatt. 4 5 - fix http://bugs.webkit.org/show_bug.cgi?id=12115 6 RTL text is jumbled on display 7 8 Fixed fixed table layout. Implemented an algorithm that matches the behavior 9 of Firefox, up to rounding errors. 10 11 Fixes three existing table tests. 12 13 * rendering/FixedTableLayout.cpp: 14 Undid accidental search-and-replace of "width" to "m_width" in the comments. 15 Removed an outdated comment, since WebKit no longer honors table-layout:fixed 16 for variable-width tables. 17 (WebCore::FixedTableLayout::calcWidthArray): Fixed the logic that finds the 18 first row. Changed to divide the width specified for a cell that spans multiple 19 columns between the columns rather than assign its entire width to each column. 20 (WebCore::FixedTableLayout::calcMinMaxWidth): 21 (WebCore::FixedTableLayout::layout): Implemented the behavior observed in 22 Firefox. 23 * rendering/FixedTableLayout.h: 24 1 25 2007-01-11 Mitz Pettel <mitz@webkit.org> 2 26 -
trunk/WebCore/rendering/FixedTableLayout.cpp
r18608 r18790 37 37 With this (fast) algorithm, the horizontal layout of the table does 38 38 not depend on the contents of the cells; it only depends on the 39 table's m_width, the m_width of the columns, and borders or cell39 table's width, the width of the columns, and borders or cell 40 40 spacing. 41 41 42 The table's m_width may be specified explicitly with the 'm_width'42 The table's width may be specified explicitly with the 'width' 43 43 property. A value of 'auto' (for both 'display: table' and 'display: 44 44 inline-table') means use the automatic table layout algorithm. 45 45 46 In the fixed table layout algorithm, the m_width of each column is46 In the fixed table layout algorithm, the width of each column is 47 47 determined as follows: 48 48 49 1. A column element with a value other than 'auto' for the ' m_width'50 property sets the m_width for that column.49 1. A column element with a value other than 'auto' for the 'width' 50 property sets the width for that column. 51 51 52 52 2. Otherwise, a cell in the first row with a value other than 53 'auto' for the ' m_width' property sets the m_width for that column. If54 the cell spans more than one column, the m_width is divided over the53 'auto' for the 'width' property sets the width for that column. If 54 the cell spans more than one column, the width is divided over the 55 55 columns. 56 56 … … 58 58 table space (minus borders or cell spacing). 59 59 60 The m_width of the table is then the greater of the value of the61 ' m_width' property for the table element and the sum of the column60 The width of the table is then the greater of the value of the 61 'width' property for the table element and the sum of the column 62 62 widths (plus cell spacing or borders). If the table is wider than 63 63 the columns, the extra space should be distributed over the columns. … … 69 69 uses the 'overflow' property to determine whether to clip the 70 70 overflow content. 71 72 _____________________________________________________73 74 This is not quite true when comparing to IE. IE always honours75 table-layout:fixed and treats a variable table m_width as 100%. Makes76 a lot of sense, and is implemented here the same way.77 78 71 */ 79 72 … … 84 77 FixedTableLayout::FixedTableLayout(RenderTable* table) 85 78 : TableLayout(table) 86 {87 }88 89 FixedTableLayout::~FixedTableLayout()90 79 { 91 80 } … … 128 117 int eSpan = m_table->spanOfEffCol(cCol+i); 129 118 if ((w.isFixed() || w.isPercent()) && w.isPositive()) { 130 m_width[cCol +i].setRawValue(w.type(), w.rawValue() * eSpan);119 m_width[cCol + i].setRawValue(w.type(), w.rawValue() * eSpan); 131 120 usedWidth += effWidth * eSpan; 132 121 } … … 149 138 } 150 139 151 // iterate over the first row in case some are unspecified.140 // Iterate over the first row in case some are unspecified. 152 141 RenderTableSection* section = m_table->header(); 153 142 if (!section) … … 155 144 if (!section) 156 145 section = m_table->footer(); 146 if (!section->numRows()) 147 section = m_table->sectionBelow(section, true); 157 148 if (section) { 158 149 cCol = 0; 159 // FIXME: Technically the first row could be in an arbitrary section (e.g., an nth section160 // if the previous n-1 sections have no rows), so this check isn't good enough.161 // get the first cell in the first row162 150 RenderObject* firstRow = section->firstChild(); 163 child = firstRow ? firstRow->firstChild() : 0;151 child = firstRow->firstChild(); 164 152 while (child) { 165 153 if (child->isTableCell()) { 166 RenderTableCell *cell = static_cast<RenderTableCell*>(child);154 RenderTableCell* cell = static_cast<RenderTableCell*>(child); 167 155 Length w = cell->styleOrColWidth(); 168 156 int span = cell->colSpan(); 169 157 int effWidth = 0; 170 // FIXME: This does not make sense (mixing percentages with absolute length) 171 if ((w.isFixed() || w.isPercent()) && w.isPositive()) 172 effWidth = w.isPercent() ? w.rawValue() / percentScaleFactor : w.value(); 158 if (w.isFixed() && w.isPositive()) 159 effWidth = w.value(); 173 160 174 161 int usedSpan = 0; … … 176 163 while (usedSpan < span) { 177 164 ASSERT(cCol + i < nEffCols); 178 int eSpan = m_table->spanOfEffCol(cCol +i);179 // only set if no col element has already set it.180 if (m_width[cCol +i].isAuto() && w.type() != Auto) {181 m_width[cCol +i].setRawValue(w.type(), w.rawValue() * eSpan);182 usedWidth += effWidth *eSpan;165 int eSpan = m_table->spanOfEffCol(cCol + i); 166 // Only set if no col element has already set it. 167 if (m_width[cCol + i].isAuto() && w.type() != Auto) { 168 m_width[cCol + i].setRawValue(w.type(), w.rawValue() * eSpan / span); 169 usedWidth += effWidth * eSpan / span; 183 170 } 184 171 usedSpan += eSpan; … … 192 179 193 180 return usedWidth; 194 195 181 } 196 182 … … 202 188 // layouting for the first time. 203 189 204 // only need to calculate the minimum m_width as the sum of the205 // cols/cells with a fixed m_width.190 // only need to calculate the minimum width as the sum of the 191 // cols/cells with a fixed width. 206 192 // 207 // The maximum m_width is max(minWidth, tableWidth).193 // The maximum width is max(minWidth, tableWidth). 208 194 int bs = m_table->bordersPaddingAndSpacing(); 209 195 … … 218 204 { 219 205 int tableWidth = m_table->width() - m_table->bordersPaddingAndSpacing(); 220 int available = tableWidth;221 206 int nEffCols = m_table->numEffCols(); 222 int totalPercent = 0; 223 224 Vector<int> calcWidth(nEffCols, -1); 225 226 // assign percent m_width 227 if (available > 0) { 228 for (int i = 0; i < nEffCols; i++) 229 if (m_width[i].isPercent()) 230 totalPercent += m_width[i].rawValue(); 231 232 // calculate how much to distribute to percent cells. 233 int base = tableWidth * totalPercent / (100 * percentScaleFactor); 234 if (base > available) 235 base = available; 236 else 237 totalPercent = 100 * percentScaleFactor; 238 239 for (int i = 0; available > 0 && i < nEffCols; i++) { 240 if (m_width[i].isPercent()) { 241 int w = base * m_width[i].rawValue() / totalPercent; 242 available -= w; 243 calcWidth[i] = w; 244 } 245 } 246 } 247 248 // next assign fixed m_width 207 Vector<int> calcWidth(nEffCols, 0); 208 209 int numAuto = 0; 210 int totalFixedWidth = 0; 211 int totalPercentWidth = 0; 212 int totalRawPercent = 0; 213 214 // Compute requirements and try to satisfy fixed and percent widths. 215 // Percentages are of the table's width, so for example 216 // for a table width of 100px with columns (40px, 10%), the 10% compute 217 // to 10px here, and will scale up to 20px in the final (80px, 20px). 249 218 for (int i = 0; i < nEffCols; i++) { 250 219 if (m_width[i].isFixed()) { 251 220 calcWidth[i] = m_width[i].value(); 252 available -= m_width[i].value(); 253 } 254 } 255 256 // assign variable m_width 257 if (available > 0) { 258 int totalAuto = 0; 259 for (int i = 0; i < nEffCols; i++) 260 if (m_width[i].isAuto()) 261 totalAuto++; 262 263 for (int i = 0; available > 0 && i < nEffCols; i++) { 221 totalFixedWidth += calcWidth[i]; 222 } else if (m_width[i].isPercent()) { 223 calcWidth[i] = m_width[i].calcValue(tableWidth); 224 totalPercentWidth += calcWidth[i]; 225 totalRawPercent += m_width[i].rawValue(); 226 } else if (m_width[i].isAuto()) 227 numAuto++; 228 } 229 230 int totalWidth = totalFixedWidth + totalPercentWidth; 231 if (!numAuto || totalWidth > tableWidth) { 232 // If there are no auto columns, or if the total is too wide, take 233 // what we have and scale it to fit as necessary. 234 if (totalWidth != tableWidth) { 235 // Fixed widths only scale up 236 if (totalFixedWidth && totalWidth < tableWidth) { 237 totalFixedWidth = 0; 238 for (int i = 0; i < nEffCols; i++) { 239 if (m_width[i].isFixed()) { 240 calcWidth[i] = calcWidth[i] * tableWidth / totalWidth; 241 totalFixedWidth += calcWidth[i]; 242 } 243 } 244 } 245 if (totalRawPercent) { 246 totalPercentWidth = 0; 247 for (int i = 0; i < nEffCols; i++) { 248 if (m_width[i].isPercent()) { 249 calcWidth[i] = m_width[i].rawValue() * (tableWidth - totalFixedWidth) / totalRawPercent; 250 totalPercentWidth += calcWidth[i]; 251 } 252 } 253 } 254 totalWidth = totalFixedWidth + totalPercentWidth; 255 } 256 } else { 257 // Divide the remaining width among the auto columns. 258 int remainingWidth = tableWidth - totalFixedWidth - totalPercentWidth; 259 int lastAuto = 0; 260 for (int i = 0; i < nEffCols; i++) { 264 261 if (m_width[i].isAuto()) { 265 int w = available / totalAuto; 266 available -= w; 267 calcWidth[i] = w; 268 totalAuto--; 269 } 270 } 271 } 272 273 for (int i = 0; i < nEffCols; i++) 274 if (calcWidth[i] <= 0) 275 calcWidth[i] = 0; // IE gives min 1 px... 276 277 // spread extra space over columns 278 if (available > 0) { 262 calcWidth[i] = remainingWidth / numAuto; 263 remainingWidth -= calcWidth[i]; 264 if (!remainingWidth) 265 break; 266 lastAuto = i; 267 numAuto--; 268 } 269 } 270 // Last one gets the remainder. 271 if (remainingWidth) 272 calcWidth[lastAuto] += remainingWidth; 273 totalWidth = tableWidth; 274 } 275 276 if (totalWidth < tableWidth) { 277 // Spread extra space over columns. 278 int remainingWidth = tableWidth - totalWidth; 279 279 int total = nEffCols; 280 // still have some m_width to spread 281 int i = nEffCols; 282 while ( i--) { 283 int w = available / total; 284 available -= w; 285 total--; 286 calcWidth[i] += w; 287 } 280 while (total) { 281 int w = remainingWidth / total; 282 remainingWidth -= w; 283 calcWidth[--total] += w; 284 } 285 calcWidth[nEffCols - 1] += remainingWidth; 288 286 } 289 287 … … 294 292 pos += calcWidth[i] + hspacing; 295 293 } 296 m_table->columnPositions()[m_table->columnPositions().size()-1] = pos; 297 } 298 299 #undef DEBUG_LAYOUT 294 m_table->columnPositions()[m_table->columnPositions().size() - 1] = pos; 295 } 300 296 301 297 } // namespace WebCore -
trunk/WebCore/rendering/FixedTableLayout.h
r18608 r18790 21 21 */ 22 22 23 #ifndef FixedTableLayout_ H24 #define FixedTableLayout_ H23 #ifndef FixedTableLayout_h 24 #define FixedTableLayout_h 25 25 26 26 #include "Length.h" … … 35 35 public: 36 36 FixedTableLayout(RenderTable*); 37 ~FixedTableLayout();38 37 39 38 virtual void calcMinMaxWidth(int& minWidth, int& maxWidth); … … 48 47 } // namespace WebCore 49 48 50 #endif // FixedTableLayout_ H49 #endif // FixedTableLayout_h
Note: See TracChangeset
for help on using the changeset viewer.