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()) { |
chrishtr
2016/05/04 23:24:18
This is obsolete due to other work?
Xianzhu
2016/05/05 00:15:50
No. Restored.
| |
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 changed = !m_collapsedBorderValues->startBorder.visuallyEquals(newValues .startBorder) | |
927 || !m_collapsedBorderValues->endBorder.visuallyEquals(newValues.endB order) | |
928 || !m_collapsedBorderValues->beforeBorder.visuallyEquals(newValues.b eforeBorder) | |
929 || !m_collapsedBorderValues->afterBorder.visuallyEquals(newValues.af terBorder); | |
930 if (changed) | |
931 *m_collapsedBorderValues = newValues; | |
932 } | |
933 | |
923 if (changed) | 934 if (changed) |
924 table()->invalidateDisplayItemClient(*this); | 935 table()->invalidateDisplayItemClient(*this); |
925 | 936 |
926 addBorderStyle(borderValues, startBorder); | 937 addBorderStyle(borderValues, newValues.startBorder); |
927 addBorderStyle(borderValues, endBorder); | 938 addBorderStyle(borderValues, newValues.endBorder); |
928 addBorderStyle(borderValues, beforeBorder); | 939 addBorderStyle(borderValues, newValues.beforeBorder); |
929 addBorderStyle(borderValues, afterBorder); | 940 addBorderStyle(borderValues, newValues.afterBorder); |
930 } | 941 } |
931 | 942 |
932 void LayoutTableCell::sortBorderValues(LayoutTable::CollapsedBorderValues& borde rValues) | 943 void LayoutTableCell::sortBorderValues(LayoutTable::CollapsedBorderValues& borde rValues) |
933 { | 944 { |
934 std::sort(borderValues.begin(), borderValues.end(), compareBorders); | 945 std::sort(borderValues.begin(), borderValues.end(), compareBorders); |
935 } | 946 } |
936 | 947 |
937 void LayoutTableCell::paintBoxDecorationBackground(const PaintInfo& paintInfo, c onst LayoutPoint& paintOffset) const | 948 void LayoutTableCell::paintBoxDecorationBackground(const PaintInfo& paintInfo, c onst LayoutPoint& paintOffset) const |
938 { | 949 { |
939 TableCellPainter(*this).paintBoxDecorationBackground(paintInfo, paintOffset) ; | 950 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 | 1004 bool LayoutTableCell::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localR ect) const |
994 { | 1005 { |
995 // If this object has layer, the area of collapsed borders should be transpa rent | 1006 // 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. | 1007 // to expose the collapsed borders painted on the underlying layer. |
997 if (hasLayer() && table()->collapseBorders()) | 1008 if (hasLayer() && table()->collapseBorders()) |
998 return false; | 1009 return false; |
999 return LayoutBlockFlow::backgroundIsKnownToBeOpaqueInRect(localRect); | 1010 return LayoutBlockFlow::backgroundIsKnownToBeOpaqueInRect(localRect); |
1000 } | 1011 } |
1001 | 1012 |
1002 } // namespace blink | 1013 } // namespace blink |
OLD | NEW |