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. All rights
reserved. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
reserved. |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 25 matching lines...) Expand all Loading... |
36 #include "platform/geometry/FloatQuad.h" | 36 #include "platform/geometry/FloatQuad.h" |
37 #include "platform/geometry/TransformState.h" | 37 #include "platform/geometry/TransformState.h" |
38 | 38 |
39 namespace blink { | 39 namespace blink { |
40 | 40 |
41 using namespace HTMLNames; | 41 using namespace HTMLNames; |
42 | 42 |
43 struct SameSizeAsLayoutTableCell : public LayoutBlockFlow { | 43 struct SameSizeAsLayoutTableCell : public LayoutBlockFlow { |
44 unsigned bitfields; | 44 unsigned bitfields; |
45 int paddings[2]; | 45 int paddings[2]; |
| 46 void* pointer; |
46 }; | 47 }; |
47 | 48 |
48 static_assert(sizeof(LayoutTableCell) == sizeof(SameSizeAsLayoutTableCell), "Lay
outTableCell should stay small"); | 49 static_assert(sizeof(LayoutTableCell) == sizeof(SameSizeAsLayoutTableCell), "Lay
outTableCell should stay small"); |
49 static_assert(sizeof(CollapsedBorderValue) == 8, "CollapsedBorderValue should st
ay small"); | 50 static_assert(sizeof(CollapsedBorderValue) == 8, "CollapsedBorderValue should st
ay small"); |
50 | 51 |
51 LayoutTableCell::LayoutTableCell(Element* element) | 52 LayoutTableCell::LayoutTableCell(Element* element) |
52 : LayoutBlockFlow(element) | 53 : LayoutBlockFlow(element) |
53 , m_absoluteColumnIndex(unsetColumnIndex) | 54 , m_absoluteColumnIndex(unsetColumnIndex) |
54 , m_cellWidthChanged(false) | 55 , m_cellWidthChanged(false) |
55 , m_intrinsicPaddingBefore(0) | 56 , m_intrinsicPaddingBefore(0) |
56 , m_intrinsicPaddingAfter(0) | 57 , m_intrinsicPaddingAfter(0) |
57 { | 58 { |
58 // We only update the flags when notified of DOM changes in colSpanOrRowSpan
Changed() | 59 // We only update the flags when notified of DOM changes in colSpanOrRowSpan
Changed() |
59 // so we need to set their initial values here in case something asks for co
lSpan()/rowSpan() before then. | 60 // so we need to set their initial values here in case something asks for co
lSpan()/rowSpan() before then. |
60 updateColAndRowSpanFlags(); | 61 updateColAndRowSpanFlags(); |
61 } | 62 } |
62 | 63 |
63 void LayoutTableCell::willBeRemovedFromTree() | 64 void LayoutTableCell::willBeRemovedFromTree() |
64 { | 65 { |
65 LayoutBlockFlow::willBeRemovedFromTree(); | 66 LayoutBlockFlow::willBeRemovedFromTree(); |
66 | 67 |
67 section()->setNeedsCellRecalc(); | 68 section()->setNeedsCellRecalc(); |
68 section()->removeCachedCollapsedBorders(this); | |
69 } | 69 } |
70 | 70 |
71 unsigned LayoutTableCell::parseColSpanFromDOM() const | 71 unsigned LayoutTableCell::parseColSpanFromDOM() const |
72 { | 72 { |
73 ASSERT(node()); | 73 ASSERT(node()); |
74 if (isHTMLTableCellElement(*node())) | 74 if (isHTMLTableCellElement(*node())) |
75 return std::min<unsigned>(toHTMLTableCellElement(*node()).colSpan(), max
ColumnIndex); | 75 return std::min<unsigned>(toHTMLTableCellElement(*node()).colSpan(), max
ColumnIndex); |
76 return 1; | 76 return 1; |
77 } | 77 } |
78 | 78 |
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 size_t count = borderValues.size(); | 901 size_t count = borderValues.size(); |
902 for (size_t i = 0; i < count; ++i) { | 902 for (size_t i = 0; i < count; ++i) { |
903 if (borderValues[i].isSameIgnoringColor(borderValue)) | 903 if (borderValues[i].isSameIgnoringColor(borderValue)) |
904 return; | 904 return; |
905 } | 905 } |
906 borderValues.append(borderValue); | 906 borderValues.append(borderValue); |
907 } | 907 } |
908 | 908 |
909 void LayoutTableCell::collectBorderValues(LayoutTable::CollapsedBorderValues& bo
rderValues) | 909 void LayoutTableCell::collectBorderValues(LayoutTable::CollapsedBorderValues& bo
rderValues) |
910 { | 910 { |
911 CollapsedBorderValue startBorder = computeCollapsedStartBorder(); | 911 CollapsedBorderValues newValues = { |
912 CollapsedBorderValue endBorder = computeCollapsedEndBorder(); | 912 computeCollapsedStartBorder(), |
913 CollapsedBorderValue beforeBorder = computeCollapsedBeforeBorder(); | 913 computeCollapsedEndBorder(), |
914 CollapsedBorderValue afterBorder = computeCollapsedAfterBorder(); | 914 computeCollapsedBeforeBorder(), |
915 LayoutTableSection* section = this->section(); | 915 computeCollapsedAfterBorder() |
916 bool changed = section->setCachedCollapsedBorder(this, CBSStart, startBorder
); | 916 }; |
917 changed |= section->setCachedCollapsedBorder(this, CBSEnd, endBorder); | |
918 changed |= section->setCachedCollapsedBorder(this, CBSBefore, beforeBorder); | |
919 changed |= section->setCachedCollapsedBorder(this, CBSAfter, afterBorder); | |
920 | 917 |
921 // In slimming paint mode, we need to invalidate all cells with collapsed bo
rder changed. | 918 bool changed = false; |
922 // FIXME: Need a way to invalidate/repaint the borders only. crbug.com/45109
0#c5. | 919 if (!newValues.startBorder.isVisible() && !newValues.endBorder.isVisible() &
& !newValues.beforeBorder.isVisible() && !newValues.afterBorder.isVisible()) { |
| 920 changed = !!m_collapsedBorderValues; |
| 921 m_collapsedBorderValues = nullptr; |
| 922 } else if (!m_collapsedBorderValues) { |
| 923 changed = true; |
| 924 m_collapsedBorderValues = adoptPtr(new CollapsedBorderValues(newValues))
; |
| 925 } else { |
| 926 // We check visuallyEquals so that the table cell is invalidated only if
a changed |
| 927 // collapsed border is visible in the first place. |
| 928 changed = !m_collapsedBorderValues->startBorder.visuallyEquals(newValues
.startBorder) |
| 929 || !m_collapsedBorderValues->endBorder.visuallyEquals(newValues.endB
order) |
| 930 || !m_collapsedBorderValues->beforeBorder.visuallyEquals(newValues.b
eforeBorder) |
| 931 || !m_collapsedBorderValues->afterBorder.visuallyEquals(newValues.af
terBorder); |
| 932 if (changed) |
| 933 *m_collapsedBorderValues = newValues; |
| 934 } |
| 935 |
| 936 // If collapsed borders changed, invalidate the cell's display item client o
n the table's backing. |
| 937 // TODO(crbug.com/451090#c5): Need a way to invalidate/repaint the borders o
nly. |
923 if (changed) | 938 if (changed) |
924 table()->invalidateDisplayItemClient(*this); | 939 table()->invalidateDisplayItemClient(*this); |
925 | 940 |
926 addBorderStyle(borderValues, startBorder); | 941 addBorderStyle(borderValues, newValues.startBorder); |
927 addBorderStyle(borderValues, endBorder); | 942 addBorderStyle(borderValues, newValues.endBorder); |
928 addBorderStyle(borderValues, beforeBorder); | 943 addBorderStyle(borderValues, newValues.beforeBorder); |
929 addBorderStyle(borderValues, afterBorder); | 944 addBorderStyle(borderValues, newValues.afterBorder); |
930 } | 945 } |
931 | 946 |
932 void LayoutTableCell::sortBorderValues(LayoutTable::CollapsedBorderValues& borde
rValues) | 947 void LayoutTableCell::sortBorderValues(LayoutTable::CollapsedBorderValues& borde
rValues) |
933 { | 948 { |
934 std::sort(borderValues.begin(), borderValues.end(), compareBorders); | 949 std::sort(borderValues.begin(), borderValues.end(), compareBorders); |
935 } | 950 } |
936 | 951 |
937 void LayoutTableCell::paintBoxDecorationBackground(const PaintInfo& paintInfo, c
onst LayoutPoint& paintOffset) const | 952 void LayoutTableCell::paintBoxDecorationBackground(const PaintInfo& paintInfo, c
onst LayoutPoint& paintOffset) const |
938 { | 953 { |
939 TableCellPainter(*this).paintBoxDecorationBackground(paintInfo, paintOffset)
; | 954 TableCellPainter(*this).paintBoxDecorationBackground(paintInfo, paintOffset)
; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 bool LayoutTableCell::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localR
ect) const | 1008 bool LayoutTableCell::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localR
ect) const |
994 { | 1009 { |
995 // If this object has layer, the area of collapsed borders should be transpa
rent | 1010 // If this object has layer, the area of collapsed borders should be transpa
rent |
996 // to expose the collapsed borders painted on the underlying layer. | 1011 // to expose the collapsed borders painted on the underlying layer. |
997 if (hasLayer() && table()->collapseBorders()) | 1012 if (hasLayer() && table()->collapseBorders()) |
998 return false; | 1013 return false; |
999 return LayoutBlockFlow::backgroundIsKnownToBeOpaqueInRect(localRect); | 1014 return LayoutBlockFlow::backgroundIsKnownToBeOpaqueInRect(localRect); |
1000 } | 1015 } |
1001 | 1016 |
1002 } // namespace blink | 1017 } // namespace blink |
OLD | NEW |