OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1997 Martin Jones (mjones@kde.org) | 2 * Copyright (C) 1997 Martin Jones (mjones@kde.org) |
3 * (C) 1997 Torben Weis (weis@kde.org) | 3 * (C) 1997 Torben Weis (weis@kde.org) |
4 * (C) 1998 Waldo Bastian (bastian@kde.org) | 4 * (C) 1998 Waldo Bastian (bastian@kde.org) |
5 * (C) 1999 Lars Knoll (knoll@kde.org) | 5 * (C) 1999 Lars Knoll (knoll@kde.org) |
6 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 6 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. |
8 * All rights reserved. | 8 * All rights reserved. |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 if (bottom) { | 441 if (bottom) { |
442 if (LayoutTableCell* below = table()->cellBelow(this)) { | 442 if (LayoutTableCell* below = table()->cellBelow(this)) { |
443 left = std::max(left, below->borderHalfLeft(true)); | 443 left = std::max(left, below->borderHalfLeft(true)); |
444 right = std::max(right, below->borderHalfRight(true)); | 444 right = std::max(right, below->borderHalfRight(true)); |
445 } | 445 } |
446 } | 446 } |
447 | 447 |
448 LayoutRect selfVisualOverflowRect = this->selfVisualOverflowRect(); | 448 LayoutRect selfVisualOverflowRect = this->selfVisualOverflowRect(); |
449 LayoutPoint location(std::max(LayoutUnit(left), -selfVisualOverflowRect.x()), | 449 LayoutPoint location(std::max(LayoutUnit(left), -selfVisualOverflowRect.x()), |
450 std::max(LayoutUnit(top), -selfVisualOverflowRect.y())); | 450 std::max(LayoutUnit(top), -selfVisualOverflowRect.y())); |
451 return LayoutRect(-location.x(), -location.y(), | 451 return LayoutRect( |
452 location.x() + std::max(size().width() + right, | 452 -location.x(), -location.y(), |
453 selfVisualOverflowRect.maxX()), | 453 location.x() + |
454 location.y() + std::max(size().height() + bottom, | 454 std::max(size().width() + right, selfVisualOverflowRect.maxX()), |
455 selfVisualOverflowRect.maxY())); | 455 location.y() + |
| 456 std::max(size().height() + bottom, selfVisualOverflowRect.maxY())); |
456 } | 457 } |
457 | 458 |
458 int LayoutTableCell::cellBaselinePosition() const { | 459 int LayoutTableCell::cellBaselinePosition() const { |
459 // <http://www.w3.org/TR/2007/CR-CSS21-20070719/tables.html#height-layout>: | 460 // <http://www.w3.org/TR/2007/CR-CSS21-20070719/tables.html#height-layout>: |
460 // The baseline of a cell is the baseline of the first in-flow line box in the | 461 // The baseline of a cell is the baseline of the first in-flow line box in the |
461 // cell, or the first in-flow table-row in the cell, whichever comes first. If | 462 // cell, or the first in-flow table-row in the cell, whichever comes first. If |
462 // there is no such line box or table-row, the baseline is the bottom of | 463 // there is no such line box or table-row, the baseline is the bottom of |
463 // content edge of the cell box. | 464 // content edge of the cell box. |
464 int firstLineBaseline = firstLineBoxBaseline(); | 465 int firstLineBaseline = firstLineBoxBaseline(); |
465 if (firstLineBaseline != -1) | 466 if (firstLineBaseline != -1) |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 result, | 664 result, |
664 CollapsedBorderValue( | 665 CollapsedBorderValue( |
665 row()->borderAdjoiningStartCell(this), | 666 row()->borderAdjoiningStartCell(this), |
666 includeColor ? parent()->resolveColor(startColorProperty) : Color(), | 667 includeColor ? parent()->resolveColor(startColorProperty) : Color(), |
667 BorderPrecedenceRow)); | 668 BorderPrecedenceRow)); |
668 if (!result.exists()) | 669 if (!result.exists()) |
669 return result; | 670 return result; |
670 | 671 |
671 // (4) Our row group's start border. | 672 // (4) Our row group's start border. |
672 result = chooseBorder( | 673 result = chooseBorder( |
673 result, CollapsedBorderValue( | 674 result, |
674 section()->borderAdjoiningStartCell(this), | 675 CollapsedBorderValue(section()->borderAdjoiningStartCell(this), |
675 includeColor ? section()->resolveColor(startColorProperty) | 676 includeColor |
| 677 ? section()->resolveColor(startColorProperty) |
676 : Color(), | 678 : Color(), |
677 BorderPrecedenceRowGroup)); | 679 BorderPrecedenceRowGroup)); |
678 if (!result.exists()) | 680 if (!result.exists()) |
679 return result; | 681 return result; |
680 } | 682 } |
681 | 683 |
682 // (5) Our column and column group's start borders. | 684 // (5) Our column and column group's start borders. |
683 LayoutTable::ColAndColGroup colAndColGroup = | 685 LayoutTable::ColAndColGroup colAndColGroup = |
684 table->colElementAtAbsoluteColumn(absoluteColumnIndex()); | 686 table->colElementAtAbsoluteColumn(absoluteColumnIndex()); |
685 if (colAndColGroup.colgroup && colAndColGroup.adjoinsStartBorderOfColGroup) { | 687 if (colAndColGroup.colgroup && colAndColGroup.adjoinsStartBorderOfColGroup) { |
686 // Only apply the colgroup's border if this cell touches the colgroup edge. | 688 // Only apply the colgroup's border if this cell touches the colgroup edge. |
687 result = chooseBorder( | 689 result = chooseBorder( |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 BorderPrecedenceColumnGroup)); | 877 BorderPrecedenceColumnGroup)); |
876 if (!result.exists()) | 878 if (!result.exists()) |
877 return result; | 879 return result; |
878 } | 880 } |
879 if (colAndColGroup.col) { | 881 if (colAndColGroup.col) { |
880 // Always apply the col's border irrespective of whether this cell touches | 882 // Always apply the col's border irrespective of whether this cell touches |
881 // it. This is per HTML5: "For the purposes of the CSS table model, the | 883 // it. This is per HTML5: "For the purposes of the CSS table model, the |
882 // col element is expected to be treated as if it "was present as many | 884 // col element is expected to be treated as if it "was present as many |
883 // times as its span attribute specifies". | 885 // times as its span attribute specifies". |
884 result = chooseBorder( | 886 result = chooseBorder( |
885 result, CollapsedBorderValue( | 887 result, |
886 colAndColGroup.col->borderAdjoiningCellBefore(this), | 888 CollapsedBorderValue( |
887 includeColor | 889 colAndColGroup.col->borderAdjoiningCellBefore(this), |
888 ? colAndColGroup.col->resolveColor(startColorProperty) | 890 includeColor |
889 : Color(), | 891 ? colAndColGroup.col->resolveColor(startColorProperty) |
890 BorderPrecedenceColumn)); | 892 : Color(), |
| 893 BorderPrecedenceColumn)); |
891 if (!result.exists()) | 894 if (!result.exists()) |
892 return result; | 895 return result; |
893 } | 896 } |
894 } | 897 } |
895 | 898 |
896 if (endBorderAdjoinsTable) { | 899 if (endBorderAdjoinsTable) { |
897 // (7) The table's end border. | 900 // (7) The table's end border. |
898 result = chooseBorder( | 901 result = chooseBorder( |
899 result, | 902 result, |
900 CollapsedBorderValue( | 903 CollapsedBorderValue( |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 } | 1007 } |
1005 } | 1008 } |
1006 | 1009 |
1007 if (!currSection) { | 1010 if (!currSection) { |
1008 // (8) Our column and column group's before borders. | 1011 // (8) Our column and column group's before borders. |
1009 LayoutTableCol* colElt = | 1012 LayoutTableCol* colElt = |
1010 table->colElementAtAbsoluteColumn(absoluteColumnIndex()) | 1013 table->colElementAtAbsoluteColumn(absoluteColumnIndex()) |
1011 .innermostColOrColGroup(); | 1014 .innermostColOrColGroup(); |
1012 if (colElt) { | 1015 if (colElt) { |
1013 result = chooseBorder( | 1016 result = chooseBorder( |
1014 result, CollapsedBorderValue( | 1017 result, |
1015 colElt->style()->borderBefore(), | 1018 CollapsedBorderValue(colElt->style()->borderBefore(), |
1016 includeColor ? colElt->resolveColor(beforeColorProperty) | 1019 includeColor |
| 1020 ? colElt->resolveColor(beforeColorProperty) |
1017 : Color(), | 1021 : Color(), |
1018 BorderPrecedenceColumn)); | 1022 BorderPrecedenceColumn)); |
1019 if (!result.exists()) | 1023 if (!result.exists()) |
1020 return result; | 1024 return result; |
1021 if (LayoutTableCol* enclosingColumnGroup = | 1025 if (LayoutTableCol* enclosingColumnGroup = |
1022 colElt->enclosingColumnGroup()) { | 1026 colElt->enclosingColumnGroup()) { |
1023 result = chooseBorder( | 1027 result = chooseBorder( |
1024 result, | 1028 result, |
1025 CollapsedBorderValue( | 1029 CollapsedBorderValue( |
1026 enclosingColumnGroup->style()->borderBefore(), | 1030 enclosingColumnGroup->style()->borderBefore(), |
1027 includeColor | 1031 includeColor |
1028 ? enclosingColumnGroup->resolveColor(beforeColorProperty) | 1032 ? enclosingColumnGroup->resolveColor(beforeColorProperty) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1067 : 0; | 1071 : 0; |
1068 CollapsedBorderValue result = CollapsedBorderValue( | 1072 CollapsedBorderValue result = CollapsedBorderValue( |
1069 style()->borderAfter(), | 1073 style()->borderAfter(), |
1070 includeColor ? resolveColor(afterColorProperty) : Color(), | 1074 includeColor ? resolveColor(afterColorProperty) : Color(), |
1071 BorderPrecedenceCell); | 1075 BorderPrecedenceCell); |
1072 | 1076 |
1073 LayoutTableCell* nextCell = table->cellBelow(this); | 1077 LayoutTableCell* nextCell = table->cellBelow(this); |
1074 if (nextCell) { | 1078 if (nextCell) { |
1075 // (2) An after cell's before border. | 1079 // (2) An after cell's before border. |
1076 result = chooseBorder( | 1080 result = chooseBorder( |
1077 result, CollapsedBorderValue( | 1081 result, |
1078 nextCell->style()->borderBefore(), | 1082 CollapsedBorderValue(nextCell->style()->borderBefore(), |
1079 includeColor ? nextCell->resolveColor(beforeColorProperty) | 1083 includeColor |
| 1084 ? nextCell->resolveColor(beforeColorProperty) |
1080 : Color(), | 1085 : Color(), |
1081 BorderPrecedenceCell)); | 1086 BorderPrecedenceCell)); |
1082 if (!result.exists()) | 1087 if (!result.exists()) |
1083 return result; | 1088 return result; |
1084 } | 1089 } |
1085 | 1090 |
1086 // (3) Our row's after border. (FIXME: Deal with rowspan!) | 1091 // (3) Our row's after border. (FIXME: Deal with rowspan!) |
1087 result = chooseBorder( | 1092 result = chooseBorder( |
1088 result, | 1093 result, |
1089 CollapsedBorderValue( | 1094 CollapsedBorderValue( |
1090 parent()->style()->borderAfter(), | 1095 parent()->style()->borderAfter(), |
1091 includeColor ? parent()->resolveColor(afterColorProperty) : Color(), | 1096 includeColor ? parent()->resolveColor(afterColorProperty) : Color(), |
(...skipping 12 matching lines...) Expand all Loading... |
1104 BorderPrecedenceRow)); | 1109 BorderPrecedenceRow)); |
1105 if (!result.exists()) | 1110 if (!result.exists()) |
1106 return result; | 1111 return result; |
1107 } | 1112 } |
1108 | 1113 |
1109 // Now check row groups. | 1114 // Now check row groups. |
1110 LayoutTableSection* currSection = section(); | 1115 LayoutTableSection* currSection = section(); |
1111 if (rowIndex() + rowSpan() >= currSection->numRows()) { | 1116 if (rowIndex() + rowSpan() >= currSection->numRows()) { |
1112 // (5) Our row group's after border. | 1117 // (5) Our row group's after border. |
1113 result = chooseBorder( | 1118 result = chooseBorder( |
1114 result, CollapsedBorderValue( | 1119 result, |
1115 currSection->style()->borderAfter(), | 1120 CollapsedBorderValue(currSection->style()->borderAfter(), |
1116 includeColor ? currSection->resolveColor(afterColorProperty) | 1121 includeColor |
| 1122 ? currSection->resolveColor(afterColorProperty) |
1117 : Color(), | 1123 : Color(), |
1118 BorderPrecedenceRowGroup)); | 1124 BorderPrecedenceRowGroup)); |
1119 if (!result.exists()) | 1125 if (!result.exists()) |
1120 return result; | 1126 return result; |
1121 | 1127 |
1122 // (6) Following row group's before border. | 1128 // (6) Following row group's before border. |
1123 currSection = table->sectionBelow(currSection, SkipEmptySections); | 1129 currSection = table->sectionBelow(currSection, SkipEmptySections); |
1124 if (currSection) { | 1130 if (currSection) { |
1125 result = chooseBorder( | 1131 result = chooseBorder( |
1126 result, | 1132 result, |
1127 CollapsedBorderValue( | 1133 CollapsedBorderValue( |
1128 currSection->style()->borderBefore(), | 1134 currSection->style()->borderBefore(), |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1498 } | 1504 } |
1499 | 1505 |
1500 bool LayoutTableCell::hasLineIfEmpty() const { | 1506 bool LayoutTableCell::hasLineIfEmpty() const { |
1501 if (node() && hasEditableStyle(*node())) | 1507 if (node() && hasEditableStyle(*node())) |
1502 return true; | 1508 return true; |
1503 | 1509 |
1504 return LayoutBlock::hasLineIfEmpty(); | 1510 return LayoutBlock::hasLineIfEmpty(); |
1505 } | 1511 } |
1506 | 1512 |
1507 } // namespace blink | 1513 } // namespace blink |
OLD | NEW |