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_column(unsetColumnIndex) | 54 , m_column(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 } | 901 } |
902 | 902 |
903 void LayoutTableCell::paint(const PaintInfo& paintInfo, const LayoutPoint& paint Offset) const | 903 void LayoutTableCell::paint(const PaintInfo& paintInfo, const LayoutPoint& paint Offset) const |
904 { | 904 { |
905 TableCellPainter(*this).paint(paintInfo, paintOffset); | 905 TableCellPainter(*this).paint(paintInfo, paintOffset); |
906 } | 906 } |
907 | 907 |
908 static void addBorderStyle(LayoutTable::CollapsedBorderValues& borderValues, | 908 static void addBorderStyle(LayoutTable::CollapsedBorderValues& borderValues, |
909 CollapsedBorderValue borderValue) | 909 CollapsedBorderValue borderValue) |
910 { | 910 { |
911 if (!borderValue.exists()) | 911 if (!borderValue.isVisible()) |
912 return; | 912 return; |
913 size_t count = borderValues.size(); | 913 size_t count = borderValues.size(); |
914 for (size_t i = 0; i < count; ++i) { | 914 for (size_t i = 0; i < count; ++i) { |
915 if (borderValues[i].isSameIgnoringColor(borderValue)) | 915 if (borderValues[i].isSameIgnoringColor(borderValue)) |
916 return; | 916 return; |
917 } | 917 } |
918 borderValues.append(borderValue); | 918 borderValues.append(borderValue); |
919 } | 919 } |
920 | 920 |
921 void LayoutTableCell::collectBorderValues(LayoutTable::CollapsedBorderValues& bo rderValues) | 921 void LayoutTableCell::collectBorderValues(LayoutTable::CollapsedBorderValues& bo rderValues) |
922 { | 922 { |
923 CollapsedBorderValue startBorder = computeCollapsedStartBorder(); | 923 LayoutTableCell::CollapsedBorderValues newValues = { |
924 CollapsedBorderValue endBorder = computeCollapsedEndBorder(); | 924 computeCollapsedStartBorder(), |
925 CollapsedBorderValue beforeBorder = computeCollapsedBeforeBorder(); | 925 computeCollapsedEndBorder(), |
926 CollapsedBorderValue afterBorder = computeCollapsedAfterBorder(); | 926 computeCollapsedBeforeBorder(), |
927 LayoutTableSection* section = this->section(); | 927 computeCollapsedAfterBorder() |
928 bool changed = section->setCachedCollapsedBorder(this, CBSStart, startBorder ); | 928 }; |
929 changed |= section->setCachedCollapsedBorder(this, CBSEnd, endBorder); | |
930 changed |= section->setCachedCollapsedBorder(this, CBSBefore, beforeBorder); | |
931 changed |= section->setCachedCollapsedBorder(this, CBSAfter, afterBorder); | |
932 | 929 |
933 // In slimming paint mode, we need to invalidate all cells with collapsed bo rder changed. | 930 bool changed; |
934 // FIXME: Need a way to invalidate/repaint the borders only. crbug.com/45109 0#c5. | 931 if (!newValues.startBorder.isVisible() && !newValues.endBorder.isVisible() & & !newValues.beforeBorder.isVisible() && !newValues.afterBorder.isVisible()) { |
Julien - ping for review
2016/01/08 14:18:15
How frequent is this case? It seems like a corner-
Xianzhu
2016/01/08 17:50:45
This optimization does improve performance of Perf
Julien - ping for review
2016/01/11 18:11:36
This really should have a comment about what it's
| |
932 changed = m_collapsedBorderValues; | |
933 m_collapsedBorderValues = nullptr; | |
934 } else if (!m_collapsedBorderValues) { | |
935 changed = true; | |
Julien - ping for review
2016/01/08 14:18:15
Do we really need that for the first this code run
Xianzhu
2016/01/08 17:50:45
Sorry I'm not sure, do you mean I should comment o
Julien - ping for review
2016/01/11 18:11:36
m_collapsedBorderValue will be nullptr the first t
| |
936 m_collapsedBorderValues = adoptPtr(new CollapsedBorderValues(newValues)) ; | |
937 } else { | |
938 changed = !m_collapsedBorderValues->startBorder.isEquivalentForPainting( newValues.startBorder) | |
939 || !m_collapsedBorderValues->endBorder.isEquivalentForPainting(newVa lues.endBorder) | |
940 || !m_collapsedBorderValues->beforeBorder.isEquivalentForPainting(ne wValues.beforeBorder) | |
941 || !m_collapsedBorderValues->afterBorder.isEquivalentForPainting(new Values.afterBorder); | |
942 if (changed) | |
943 *m_collapsedBorderValues = newValues; | |
944 } | |
945 | |
935 if (changed) | 946 if (changed) |
936 table()->invalidateDisplayItemClient(*this); | 947 table()->invalidateDisplayItemClient(*this); |
937 | 948 |
938 addBorderStyle(borderValues, startBorder); | 949 addBorderStyle(borderValues, newValues.startBorder); |
939 addBorderStyle(borderValues, endBorder); | 950 addBorderStyle(borderValues, newValues.endBorder); |
940 addBorderStyle(borderValues, beforeBorder); | 951 addBorderStyle(borderValues, newValues.beforeBorder); |
941 addBorderStyle(borderValues, afterBorder); | 952 addBorderStyle(borderValues, newValues.afterBorder); |
942 } | 953 } |
943 | 954 |
944 static int compareBorderValuesForQSort(const void* pa, const void* pb) | 955 static int compareBorderValuesForQSort(const void* pa, const void* pb) |
945 { | 956 { |
946 const CollapsedBorderValue* a = static_cast<const CollapsedBorderValue*>(pa) ; | 957 const CollapsedBorderValue* a = static_cast<const CollapsedBorderValue*>(pa) ; |
947 const CollapsedBorderValue* b = static_cast<const CollapsedBorderValue*>(pb) ; | 958 const CollapsedBorderValue* b = static_cast<const CollapsedBorderValue*>(pb) ; |
948 if (a->isSameIgnoringColor(*b)) | 959 if (a->isSameIgnoringColor(*b)) |
949 return 0; | 960 return 0; |
950 return compareBorders(*a, *b); | 961 return compareBorders(*a, *b); |
951 } | 962 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1005 | 1016 |
1006 LayoutTableCell* LayoutTableCell::createAnonymousWithParent(const LayoutObject* parent) | 1017 LayoutTableCell* LayoutTableCell::createAnonymousWithParent(const LayoutObject* parent) |
1007 { | 1018 { |
1008 LayoutTableCell* newCell = LayoutTableCell::createAnonymous(&parent->documen t()); | 1019 LayoutTableCell* newCell = LayoutTableCell::createAnonymous(&parent->documen t()); |
1009 RefPtr<ComputedStyle> newStyle = ComputedStyle::createAnonymousStyleWithDisp lay(parent->styleRef(), TABLE_CELL); | 1020 RefPtr<ComputedStyle> newStyle = ComputedStyle::createAnonymousStyleWithDisp lay(parent->styleRef(), TABLE_CELL); |
1010 newCell->setStyle(newStyle.release()); | 1021 newCell->setStyle(newStyle.release()); |
1011 return newCell; | 1022 return newCell; |
1012 } | 1023 } |
1013 | 1024 |
1014 } // namespace blink | 1025 } // namespace blink |
OLD | NEW |