darin@apple.com | 8383315 | 2008-01-14 17:51:10 +0000 | [diff] [blame] | 1 | /* |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 2 | * Copyright (C) 1997 Martin Jones (mjones@kde.org) |
| 3 | * (C) 1997 Torben Weis (weis@kde.org) |
| 4 | * (C) 1998 Waldo Bastian (bastian@kde.org) |
| 5 | * (C) 1999 Lars Knoll (knoll@kde.org) |
| 6 | * (C) 1999 Antti Koivisto (koivisto@kde.org) |
mitz@apple.com | 8010bba | 2010-11-05 02:43:17 +0000 | [diff] [blame] | 7 | * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights reserved. |
ap | 50b5835 | 2006-01-22 20:32:36 +0000 | [diff] [blame] | 8 | * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 9 | * |
| 10 | * This library is free software; you can redistribute it and/or |
| 11 | * modify it under the terms of the GNU Library General Public |
| 12 | * License as published by the Free Software Foundation; either |
| 13 | * version 2 of the License, or (at your option) any later version. |
| 14 | * |
| 15 | * This library is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 18 | * Library General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU Library General Public License |
| 21 | * along with this library; see the file COPYING.LIB. If not, write to |
ddkilzer | c8eccec | 2007-09-26 02:29:57 +0000 | [diff] [blame] | 22 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 23 | * Boston, MA 02110-1301, USA. |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 24 | */ |
| 25 | |
| 26 | #include "config.h" |
| 27 | #include "RenderTableSection.h" |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 28 | #include "Document.h" |
tonikitoo@webkit.org | 81c027d | 2010-07-29 13:19:43 +0000 | [diff] [blame] | 29 | #include "HitTestResult.h" |
darin | 98fa8b8 | 2006-03-20 08:03:57 +0000 | [diff] [blame] | 30 | #include "HTMLNames.h" |
tonyg@chromium.org | b138b1e | 2011-01-15 00:27:07 +0000 | [diff] [blame] | 31 | #include "PaintInfo.h" |
cdumez@apple.com | 6962695 | 2016-05-17 22:39:00 +0000 | [diff] [blame] | 32 | #include "RenderChildIterator.h" |
abucur@adobe.com | 7f9668a | 2014-05-16 13:22:00 +0000 | [diff] [blame] | 33 | #include "RenderNamedFlowFragment.h" |
darin | 91298e5 | 2006-06-12 01:10:17 +0000 | [diff] [blame] | 34 | #include "RenderTableCell.h" |
| 35 | #include "RenderTableCol.h" |
| 36 | #include "RenderTableRow.h" |
cdumez@apple.com | 8faf772 | 2014-10-13 18:21:11 +0000 | [diff] [blame] | 37 | #include "RenderTextControl.h" |
weinig | fef1363 | 2007-04-29 20:09:08 +0000 | [diff] [blame] | 38 | #include "RenderView.h" |
commit-queue@webkit.org | d0c076d | 2012-08-22 22:25:59 +0000 | [diff] [blame] | 39 | #include "StyleInheritedData.h" |
darin | 91298e5 | 2006-06-12 01:10:17 +0000 | [diff] [blame] | 40 | #include <limits> |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 41 | #include <wtf/HashSet.h> |
andersca@apple.com | a5fb7da | 2013-04-16 19:57:36 +0000 | [diff] [blame] | 42 | #include <wtf/StackStats.h> |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 43 | |
| 44 | namespace WebCore { |
| 45 | |
| 46 | using namespace HTMLNames; |
| 47 | |
jchaffraix@webkit.org | f4ce050 | 2011-08-18 20:20:57 +0000 | [diff] [blame] | 48 | // Those 2 variables are used to balance the memory consumption vs the repaint time on big tables. |
cdumez@apple.com | 4bf983a | 2015-05-19 07:22:36 +0000 | [diff] [blame] | 49 | static const unsigned gMinTableSizeToUseFastPaintPathWithOverflowingCell = 75 * 75; |
| 50 | static const float gMaxAllowedOverflowingCellRatioForFastPaintPath = 0.1f; |
jchaffraix@webkit.org | f4ce050 | 2011-08-18 20:20:57 +0000 | [diff] [blame] | 51 | |
jchaffraix@webkit.org | 9fb8075 | 2011-10-28 18:04:14 +0000 | [diff] [blame] | 52 | static inline void setRowLogicalHeightToRowStyleLogicalHeightIfNotRelative(RenderTableSection::RowStruct& row) |
dbates@webkit.org | e113183 | 2009-11-19 00:05:57 +0000 | [diff] [blame] | 53 | { |
jchaffraix@webkit.org | 9fb8075 | 2011-10-28 18:04:14 +0000 | [diff] [blame] | 54 | ASSERT(row.rowRenderer); |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 55 | row.logicalHeight = row.rowRenderer->style().logicalHeight(); |
jchaffraix@webkit.org | 9fb8075 | 2011-10-28 18:04:14 +0000 | [diff] [blame] | 56 | if (row.logicalHeight.isRelative()) |
| 57 | row.logicalHeight = Length(); |
dbates@webkit.org | e113183 | 2009-11-19 00:05:57 +0000 | [diff] [blame] | 58 | } |
| 59 | |
jchaffraix@webkit.org | 74857b4 | 2011-12-20 14:08:52 +0000 | [diff] [blame] | 60 | static inline void updateLogicalHeightForCell(RenderTableSection::RowStruct& row, const RenderTableCell* cell) |
| 61 | { |
| 62 | // We ignore height settings on rowspan cells. |
| 63 | if (cell->rowSpan() != 1) |
| 64 | return; |
| 65 | |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 66 | Length logicalHeight = cell->style().logicalHeight(); |
jchaffraix@webkit.org | 74857b4 | 2011-12-20 14:08:52 +0000 | [diff] [blame] | 67 | if (logicalHeight.isPositive() || (logicalHeight.isRelative() && logicalHeight.value() >= 0)) { |
| 68 | Length cRowLogicalHeight = row.logicalHeight; |
| 69 | switch (logicalHeight.type()) { |
| 70 | case Percent: |
commit-queue@webkit.org | 2a67f68 | 2015-05-10 21:43:26 +0000 | [diff] [blame] | 71 | if (!cRowLogicalHeight.isPercent() || cRowLogicalHeight.percent() < logicalHeight.percent()) |
jchaffraix@webkit.org | 74857b4 | 2011-12-20 14:08:52 +0000 | [diff] [blame] | 72 | row.logicalHeight = logicalHeight; |
| 73 | break; |
| 74 | case Fixed: |
darin@apple.com | b432608 | 2014-04-08 08:58:43 +0000 | [diff] [blame] | 75 | if (cRowLogicalHeight.isAuto() || cRowLogicalHeight.isRelative() |
jchaffraix@webkit.org | 74857b4 | 2011-12-20 14:08:52 +0000 | [diff] [blame] | 76 | || (cRowLogicalHeight.isFixed() && cRowLogicalHeight.value() < logicalHeight.value())) |
| 77 | row.logicalHeight = logicalHeight; |
| 78 | break; |
| 79 | case Relative: |
| 80 | default: |
| 81 | break; |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | |
antti@apple.com | 454418f | 2016-04-25 19:49:23 +0000 | [diff] [blame] | 86 | RenderTableSection::RenderTableSection(Element& element, RenderStyle&& style) |
aestes@apple.com | 13aae08 | 2016-01-02 08:03:08 +0000 | [diff] [blame] | 87 | : RenderBox(element, WTFMove(style), 0) |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 88 | { |
akling@apple.com | 42e1063 | 2013-10-14 17:55:52 +0000 | [diff] [blame] | 89 | setInline(false); |
| 90 | } |
| 91 | |
antti@apple.com | 454418f | 2016-04-25 19:49:23 +0000 | [diff] [blame] | 92 | RenderTableSection::RenderTableSection(Document& document, RenderStyle&& style) |
aestes@apple.com | 13aae08 | 2016-01-02 08:03:08 +0000 | [diff] [blame] | 93 | : RenderBox(document, WTFMove(style), 0) |
akling@apple.com | 42e1063 | 2013-10-14 17:55:52 +0000 | [diff] [blame] | 94 | { |
| 95 | setInline(false); |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | RenderTableSection::~RenderTableSection() |
| 99 | { |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 100 | } |
| 101 | |
inferno@chromium.org | a7f719f | 2011-09-06 01:45:39 +0000 | [diff] [blame] | 102 | void RenderTableSection::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle) |
| 103 | { |
| 104 | RenderBox::styleDidChange(diff, oldStyle); |
antti@apple.com | cf4adae | 2013-09-24 00:55:44 +0000 | [diff] [blame] | 105 | propagateStyleToAnonymousChildren(PropagateToAllChildren); |
jchaffraix@webkit.org | 38e74af | 2011-09-23 19:56:21 +0000 | [diff] [blame] | 106 | |
| 107 | // If border was changed, notify table. |
| 108 | RenderTable* table = this->table(); |
zalan@apple.com | 4214662 | 2015-04-01 15:56:34 +0000 | [diff] [blame] | 109 | if (table && oldStyle && oldStyle->border() != style().border()) |
jchaffraix@webkit.org | 38e74af | 2011-09-23 19:56:21 +0000 | [diff] [blame] | 110 | table->invalidateCollapsedBorders(); |
inferno@chromium.org | a7f719f | 2011-09-06 01:45:39 +0000 | [diff] [blame] | 111 | } |
| 112 | |
jchaffraix@webkit.org | 54b0e09 | 2012-08-22 02:16:02 +0000 | [diff] [blame] | 113 | void RenderTableSection::willBeRemovedFromTree() |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 114 | { |
jchaffraix@webkit.org | 54b0e09 | 2012-08-22 02:16:02 +0000 | [diff] [blame] | 115 | RenderBox::willBeRemovedFromTree(); |
| 116 | |
| 117 | // Preventively invalidate our cells as we may be re-inserted into |
| 118 | // a new table which would require us to rebuild our structure. |
| 119 | setNeedsCellRecalc(); |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 120 | } |
| 121 | |
darin | 316ed06 | 2006-01-23 05:29:14 +0000 | [diff] [blame] | 122 | void RenderTableSection::addChild(RenderObject* child, RenderObject* beforeChild) |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 123 | { |
cdumez@apple.com | 8faf772 | 2014-10-13 18:21:11 +0000 | [diff] [blame] | 124 | if (!is<RenderTableRow>(*child)) { |
darin | 316ed06 | 2006-01-23 05:29:14 +0000 | [diff] [blame] | 125 | RenderObject* last = beforeChild; |
| 126 | if (!last) |
antti@apple.com | 7f9196b | 2013-09-24 20:47:01 +0000 | [diff] [blame] | 127 | last = lastRow(); |
inferno@chromium.org | a7f719f | 2011-09-06 01:45:39 +0000 | [diff] [blame] | 128 | if (last && last->isAnonymous() && !last->isBeforeOrAfterContent()) { |
cdumez@apple.com | 8faf772 | 2014-10-13 18:21:11 +0000 | [diff] [blame] | 129 | RenderTableRow& row = downcast<RenderTableRow>(*last); |
| 130 | if (beforeChild == &row) |
| 131 | beforeChild = row.firstCell(); |
| 132 | row.addChild(child, beforeChild); |
darin | 316ed06 | 2006-01-23 05:29:14 +0000 | [diff] [blame] | 133 | return; |
| 134 | } |
| 135 | |
inferno@chromium.org | b1ffad7 | 2011-10-10 18:58:12 +0000 | [diff] [blame] | 136 | if (beforeChild && !beforeChild->isAnonymous() && beforeChild->parent() == this) { |
| 137 | RenderObject* row = beforeChild->previousSibling(); |
cdumez@apple.com | 8faf772 | 2014-10-13 18:21:11 +0000 | [diff] [blame] | 138 | if (is<RenderTableRow>(row) && row->isAnonymous()) { |
| 139 | downcast<RenderTableRow>(*row).addChild(child); |
inferno@chromium.org | b1ffad7 | 2011-10-10 18:58:12 +0000 | [diff] [blame] | 140 | return; |
| 141 | } |
| 142 | } |
| 143 | |
darin | 10ab135 | 2006-01-29 01:29:33 +0000 | [diff] [blame] | 144 | // If beforeChild is inside an anonymous cell/row, insert into the cell or into |
| 145 | // the anonymous row containing it, if there is one. |
darin | 316ed06 | 2006-01-23 05:29:14 +0000 | [diff] [blame] | 146 | RenderObject* lastBox = last; |
cdumez@apple.com | 8faf772 | 2014-10-13 18:21:11 +0000 | [diff] [blame] | 147 | while (lastBox && lastBox->parent()->isAnonymous() && !is<RenderTableRow>(*lastBox)) |
darin | 316ed06 | 2006-01-23 05:29:14 +0000 | [diff] [blame] | 148 | lastBox = lastBox->parent(); |
inferno@chromium.org | a7f719f | 2011-09-06 01:45:39 +0000 | [diff] [blame] | 149 | if (lastBox && lastBox->isAnonymous() && !lastBox->isBeforeOrAfterContent()) { |
cdumez@apple.com | 8faf772 | 2014-10-13 18:21:11 +0000 | [diff] [blame] | 150 | downcast<RenderTableRow>(*lastBox).addChild(child, beforeChild); |
darin | 316ed06 | 2006-01-23 05:29:14 +0000 | [diff] [blame] | 151 | return; |
| 152 | } |
| 153 | |
zalan@apple.com | cda46e4 | 2016-07-26 02:40:04 +0000 | [diff] [blame] | 154 | auto* row = RenderTableRow::createAnonymousWithParentRenderer(*this).release(); |
darin | 316ed06 | 2006-01-23 05:29:14 +0000 | [diff] [blame] | 155 | addChild(row, beforeChild); |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 156 | row->addChild(child); |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 157 | return; |
| 158 | } |
| 159 | |
| 160 | if (beforeChild) |
ddkilzer | 260f3d2 | 2007-01-05 05:56:31 +0000 | [diff] [blame] | 161 | setNeedsCellRecalc(); |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 162 | |
jchaffraix@webkit.org | 369c5d3 | 2011-10-28 01:28:58 +0000 | [diff] [blame] | 163 | unsigned insertionRow = m_cRow; |
ddkilzer | 260f3d2 | 2007-01-05 05:56:31 +0000 | [diff] [blame] | 164 | ++m_cRow; |
| 165 | m_cCol = 0; |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 166 | |
jchaffraix@webkit.org | e98e3e5 | 2011-11-11 01:41:26 +0000 | [diff] [blame] | 167 | ensureRows(m_cRow); |
lars | b5288ad | 2007-01-13 18:48:29 +0000 | [diff] [blame] | 168 | |
cdumez@apple.com | 8faf772 | 2014-10-13 18:21:11 +0000 | [diff] [blame] | 169 | RenderTableRow& row = downcast<RenderTableRow>(*child); |
| 170 | m_grid[insertionRow].rowRenderer = &row; |
| 171 | row.setRowIndex(insertionRow); |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 172 | |
dbates@webkit.org | e113183 | 2009-11-19 00:05:57 +0000 | [diff] [blame] | 173 | if (!beforeChild) |
jchaffraix@webkit.org | 9fb8075 | 2011-10-28 18:04:14 +0000 | [diff] [blame] | 174 | setRowLogicalHeightToRowStyleLogicalHeightIfNotRelative(m_grid[insertionRow]); |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 175 | |
inferno@chromium.org | a8d7192 | 2012-04-09 16:03:46 +0000 | [diff] [blame] | 176 | if (beforeChild && beforeChild->parent() != this) |
| 177 | beforeChild = splitAnonymousBoxesAroundChild(beforeChild); |
mjs | 6666eee7 | 2006-07-14 07:45:13 +0000 | [diff] [blame] | 178 | |
cdumez@apple.com | 8faf772 | 2014-10-13 18:21:11 +0000 | [diff] [blame] | 179 | ASSERT(!beforeChild || is<RenderTableRow>(*beforeChild)); |
hyatt@apple.com | f073d9b | 2009-02-05 00:53:38 +0000 | [diff] [blame] | 180 | RenderBox::addChild(child, beforeChild); |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 181 | } |
| 182 | |
jchaffraix@webkit.org | e98e3e5 | 2011-11-11 01:41:26 +0000 | [diff] [blame] | 183 | void RenderTableSection::ensureRows(unsigned numRows) |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 184 | { |
jchaffraix@webkit.org | e98e3e5 | 2011-11-11 01:41:26 +0000 | [diff] [blame] | 185 | if (numRows <= m_grid.size()) |
| 186 | return; |
jchaffraix@webkit.org | 68d3b57 | 2011-10-27 19:12:39 +0000 | [diff] [blame] | 187 | |
jchaffraix@webkit.org | e98e3e5 | 2011-11-11 01:41:26 +0000 | [diff] [blame] | 188 | unsigned oldSize = m_grid.size(); |
| 189 | m_grid.grow(numRows); |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 190 | |
andersca@apple.com | 8629863 | 2013-11-10 19:32:33 +0000 | [diff] [blame] | 191 | unsigned effectiveColumnCount = std::max(1u, table()->numEffCols()); |
jchaffraix@webkit.org | e98e3e5 | 2011-11-11 01:41:26 +0000 | [diff] [blame] | 192 | for (unsigned row = oldSize; row < m_grid.size(); ++row) |
akling@apple.com | 194ce1d | 2013-11-13 11:46:51 +0000 | [diff] [blame] | 193 | m_grid[row].row.resizeToFit(effectiveColumnCount); |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 194 | } |
| 195 | |
hyatt@apple.com | d885df7 | 2009-01-22 02:31:52 +0000 | [diff] [blame] | 196 | void RenderTableSection::addCell(RenderTableCell* cell, RenderTableRow* row) |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 197 | { |
jchaffraix@webkit.org | b86b64e | 2011-11-14 21:21:43 +0000 | [diff] [blame] | 198 | // We don't insert the cell if we need cell recalc as our internal columns' representation |
| 199 | // will have drifted from the table's representation. Also recalcCells will call addCell |
| 200 | // at a later time after sync'ing our columns' with the table's. |
| 201 | if (needsCellRecalc()) |
| 202 | return; |
| 203 | |
jchaffraix@webkit.org | fb2a860 | 2011-11-16 02:03:54 +0000 | [diff] [blame] | 204 | unsigned rSpan = cell->rowSpan(); |
| 205 | unsigned cSpan = cell->colSpan(); |
jchaffraix@webkit.org | b87ce75 | 2012-10-15 21:52:22 +0000 | [diff] [blame] | 206 | const Vector<RenderTable::ColumnStruct>& columns = table()->columns(); |
jchaffraix@webkit.org | 369c5d3 | 2011-10-28 01:28:58 +0000 | [diff] [blame] | 207 | unsigned nCols = columns.size(); |
jchaffraix@webkit.org | a0177fd | 2012-05-01 03:13:06 +0000 | [diff] [blame] | 208 | unsigned insertionRow = row->rowIndex(); |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 209 | |
| 210 | // ### mozilla still seems to do the old HTML way, even for strict DTD |
| 211 | // (see the annotation on table cell layouting in the CSS specs and the testcase below: |
| 212 | // <TABLE border> |
| 213 | // <TR><TD>1 <TD rowspan="2">2 <TD>3 <TD>4 |
| 214 | // <TR><TD colspan="2">5 |
| 215 | // </TABLE> |
jchaffraix@webkit.org | 369c5d3 | 2011-10-28 01:28:58 +0000 | [diff] [blame] | 216 | while (m_cCol < nCols && (cellAt(insertionRow, m_cCol).hasCells() || cellAt(insertionRow, m_cCol).inColSpan)) |
ddkilzer | 260f3d2 | 2007-01-05 05:56:31 +0000 | [diff] [blame] | 217 | m_cCol++; |
jamesr@google.com | b426623 | 2010-07-28 20:07:19 +0000 | [diff] [blame] | 218 | |
jchaffraix@webkit.org | 74857b4 | 2011-12-20 14:08:52 +0000 | [diff] [blame] | 219 | updateLogicalHeightForCell(m_grid[insertionRow], cell); |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 220 | |
jchaffraix@webkit.org | e98e3e5 | 2011-11-11 01:41:26 +0000 | [diff] [blame] | 221 | ensureRows(insertionRow + rSpan); |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 222 | |
jchaffraix@webkit.org | 369c5d3 | 2011-10-28 01:28:58 +0000 | [diff] [blame] | 223 | m_grid[insertionRow].rowRenderer = row; |
hyatt | d866e59 | 2006-03-17 09:50:35 +0000 | [diff] [blame] | 224 | |
jchaffraix@webkit.org | 369c5d3 | 2011-10-28 01:28:58 +0000 | [diff] [blame] | 225 | unsigned col = m_cCol; |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 226 | // tell the cell where it is |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 227 | bool inColSpan = false; |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 228 | while (cSpan) { |
jchaffraix@webkit.org | fb2a860 | 2011-11-16 02:03:54 +0000 | [diff] [blame] | 229 | unsigned currentSpan; |
jamesr@google.com | b426623 | 2010-07-28 20:07:19 +0000 | [diff] [blame] | 230 | if (m_cCol >= nCols) { |
| 231 | table()->appendColumn(cSpan); |
| 232 | currentSpan = cSpan; |
| 233 | } else { |
jchaffraix@webkit.org | fb2a860 | 2011-11-16 02:03:54 +0000 | [diff] [blame] | 234 | if (cSpan < columns[m_cCol].span) |
jamesr@google.com | b426623 | 2010-07-28 20:07:19 +0000 | [diff] [blame] | 235 | table()->splitColumn(m_cCol, cSpan); |
| 236 | currentSpan = columns[m_cCol].span; |
| 237 | } |
jchaffraix@webkit.org | fb2a860 | 2011-11-16 02:03:54 +0000 | [diff] [blame] | 238 | for (unsigned r = 0; r < rSpan; r++) { |
jchaffraix@webkit.org | 369c5d3 | 2011-10-28 01:28:58 +0000 | [diff] [blame] | 239 | CellStruct& c = cellAt(insertionRow + r, m_cCol); |
jamesr@google.com | b426623 | 2010-07-28 20:07:19 +0000 | [diff] [blame] | 240 | ASSERT(cell); |
| 241 | c.cells.append(cell); |
| 242 | // If cells overlap then we take the slow path for painting. |
| 243 | if (c.cells.size() > 1) |
| 244 | m_hasMultipleCellLevels = true; |
| 245 | if (inColSpan) |
| 246 | c.inColSpan = true; |
| 247 | } |
| 248 | m_cCol++; |
| 249 | cSpan -= currentSpan; |
| 250 | inColSpan = true; |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 251 | } |
eric@webkit.org | 5832ab7 | 2009-03-25 22:15:03 +0000 | [diff] [blame] | 252 | cell->setCol(table()->effColToCol(col)); |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 253 | } |
| 254 | |
zalan@apple.com | e10a9b1 | 2016-08-26 23:25:29 +0000 | [diff] [blame] | 255 | static LayoutUnit resolveLogicalHeightForRow(const Length& rowLogicalHeight) |
| 256 | { |
| 257 | if (rowLogicalHeight.isFixed()) |
| 258 | return rowLogicalHeight.value(); |
| 259 | if (rowLogicalHeight.isCalculated()) |
| 260 | return rowLogicalHeight.nonNanCalculatedValue(0); |
| 261 | return 0; |
| 262 | } |
| 263 | |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 264 | LayoutUnit RenderTableSection::calcRowLogicalHeight() |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 265 | { |
hyatt@apple.com | c93db9b | 2009-02-04 22:29:04 +0000 | [diff] [blame] | 266 | #ifndef NDEBUG |
ojan@chromium.org | ccdc429 | 2013-02-07 00:55:10 +0000 | [diff] [blame] | 267 | SetLayoutNeededForbiddenScope layoutForbiddenScope(this); |
hyatt@apple.com | c93db9b | 2009-02-04 22:29:04 +0000 | [diff] [blame] | 268 | #endif |
| 269 | |
| 270 | ASSERT(!needsLayout()); |
| 271 | |
ddkilzer | 260f3d2 | 2007-01-05 05:56:31 +0000 | [diff] [blame] | 272 | RenderTableCell* cell; |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 273 | |
ossy@webkit.org | cf6bebb | 2013-11-25 14:57:38 +0000 | [diff] [blame] | 274 | // We ignore the border-spacing on any non-top section as it is already included in the previous section's last row position. |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 275 | LayoutUnit spacing = 0; |
ossy@webkit.org | cf6bebb | 2013-11-25 14:57:38 +0000 | [diff] [blame] | 276 | if (this == table()->topSection()) |
| 277 | spacing = table()->vBorderSpacing(); |
akling@apple.com | 691cf5c | 2013-08-24 16:33:15 +0000 | [diff] [blame] | 278 | |
weinig@apple.com | f8d77f3 | 2013-11-18 01:12:17 +0000 | [diff] [blame] | 279 | LayoutStateMaintainer statePusher(view()); |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 280 | |
jchaffraix@webkit.org | 68d3b57 | 2011-10-27 19:12:39 +0000 | [diff] [blame] | 281 | m_rowPos.resize(m_grid.size() + 1); |
ddkilzer | 260f3d2 | 2007-01-05 05:56:31 +0000 | [diff] [blame] | 282 | m_rowPos[0] = spacing; |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 283 | |
commit-queue@webkit.org | 1fdc04c | 2013-04-23 06:36:45 +0000 | [diff] [blame] | 284 | unsigned totalRows = m_grid.size(); |
| 285 | |
| 286 | for (unsigned r = 0; r < totalRows; r++) { |
zimmermann@webkit.org | 14b310a | 2012-02-25 09:27:25 +0000 | [diff] [blame] | 287 | m_grid[r].baseline = 0; |
leviw@chromium.org | 2650e38 | 2012-04-04 10:37:36 +0000 | [diff] [blame] | 288 | LayoutUnit baselineDescent = 0; |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 289 | |
jchaffraix@webkit.org | addd65e | 2012-02-26 00:19:22 +0000 | [diff] [blame] | 290 | // Our base size is the biggest logical height from our cells' styles (excluding row spanning cells). |
zalan@apple.com | e10a9b1 | 2016-08-26 23:25:29 +0000 | [diff] [blame] | 291 | m_rowPos[r + 1] = std::max(m_rowPos[r] + resolveLogicalHeightForRow(m_grid[r].logicalHeight), LayoutUnit::fromPixel(0)); |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 292 | |
jchaffraix@webkit.org | 9fb8075 | 2011-10-28 18:04:14 +0000 | [diff] [blame] | 293 | Row& row = m_grid[r].row; |
| 294 | unsigned totalCols = row.size(); |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 295 | |
jchaffraix@webkit.org | 369c5d3 | 2011-10-28 01:28:58 +0000 | [diff] [blame] | 296 | for (unsigned c = 0; c < totalCols; c++) { |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 297 | CellStruct& current = cellAt(r, c); |
commit-queue@webkit.org | 5ec57ca | 2012-07-12 22:33:36 +0000 | [diff] [blame] | 298 | for (unsigned i = 0; i < current.cells.size(); i++) { |
| 299 | cell = current.cells[i]; |
| 300 | if (current.inColSpan && cell->rowSpan() == 1) |
| 301 | continue; |
jamesr@google.com | b426623 | 2010-07-28 20:07:19 +0000 | [diff] [blame] | 302 | |
commit-queue@webkit.org | bb45481 | 2013-05-14 19:57:51 +0000 | [diff] [blame] | 303 | // FIXME: We are always adding the height of a rowspan to the last rows which doesn't match |
| 304 | // other browsers. See webkit.org/b/52185 for example. |
| 305 | if ((cell->rowIndex() + cell->rowSpan() - 1) != r) { |
| 306 | // We will apply the height of the rowspan to the current row if next row is not valid. |
| 307 | if ((r + 1) < totalRows) { |
| 308 | unsigned col = 0; |
| 309 | CellStruct nextRowCell = cellAt(r + 1, col); |
commit-queue@webkit.org | 1fdc04c | 2013-04-23 06:36:45 +0000 | [diff] [blame] | 310 | |
commit-queue@webkit.org | bb45481 | 2013-05-14 19:57:51 +0000 | [diff] [blame] | 311 | // We are trying to find that next row is valid or not. |
| 312 | while (nextRowCell.cells.size() && nextRowCell.cells[0]->rowSpan() > 1 && nextRowCell.cells[0]->rowIndex() < (r + 1)) { |
| 313 | col++; |
| 314 | if (col < totalCols) |
| 315 | nextRowCell = cellAt(r + 1, col); |
| 316 | else |
| 317 | break; |
commit-queue@webkit.org | 1fdc04c | 2013-04-23 06:36:45 +0000 | [diff] [blame] | 318 | } |
commit-queue@webkit.org | bb45481 | 2013-05-14 19:57:51 +0000 | [diff] [blame] | 319 | |
| 320 | // We are adding the height of the rowspan to the current row if next row is not valid. |
| 321 | if (col < totalCols && nextRowCell.cells.size()) |
| 322 | continue; |
commit-queue@webkit.org | 1fdc04c | 2013-04-23 06:36:45 +0000 | [diff] [blame] | 323 | } |
| 324 | } |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 325 | |
commit-queue@webkit.org | bb45481 | 2013-05-14 19:57:51 +0000 | [diff] [blame] | 326 | // For row spanning cells, |r| is the last row in the span. |
| 327 | unsigned cellStartRow = cell->rowIndex(); |
| 328 | |
rego@igalia.com | f7d624c | 2015-04-22 10:31:24 +0000 | [diff] [blame] | 329 | if (cell->hasOverrideLogicalContentHeight()) { |
commit-queue@webkit.org | 5ec57ca | 2012-07-12 22:33:36 +0000 | [diff] [blame] | 330 | if (!statePusher.didPush()) { |
| 331 | // Technically, we should also push state for the row, but since |
| 332 | // rows don't push a coordinate transform, that's not necessary. |
weinig@apple.com | f8d77f3 | 2013-11-18 01:12:17 +0000 | [diff] [blame] | 333 | statePusher.push(*this, locationOffset()); |
commit-queue@webkit.org | 5ec57ca | 2012-07-12 22:33:36 +0000 | [diff] [blame] | 334 | } |
| 335 | cell->clearIntrinsicPadding(); |
| 336 | cell->clearOverrideSize(); |
antti@apple.com | ca2a8ff | 2013-10-04 04:04:35 +0000 | [diff] [blame] | 337 | cell->setChildNeedsLayout(MarkOnlyThis); |
commit-queue@webkit.org | 5ec57ca | 2012-07-12 22:33:36 +0000 | [diff] [blame] | 338 | cell->layoutIfNeeded(); |
weinig | fef1363 | 2007-04-29 20:09:08 +0000 | [diff] [blame] | 339 | } |
mitz@apple.com | 8010bba | 2010-11-05 02:43:17 +0000 | [diff] [blame] | 340 | |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 341 | LayoutUnit cellLogicalHeight = cell->logicalHeightForRowSizing(); |
andersca@apple.com | 8629863 | 2013-11-10 19:32:33 +0000 | [diff] [blame] | 342 | m_rowPos[r + 1] = std::max(m_rowPos[r + 1], m_rowPos[cellStartRow] + cellLogicalHeight); |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 343 | |
commit-queue@webkit.org | bb45481 | 2013-05-14 19:57:51 +0000 | [diff] [blame] | 344 | // Find out the baseline. The baseline is set on the first row in a rowspan. |
robert@webkit.org | 292be54 | 2013-03-09 06:40:13 +0000 | [diff] [blame] | 345 | if (cell->isBaselineAligned()) { |
zalan@apple.com | df6351f | 2016-01-11 22:03:03 +0000 | [diff] [blame] | 346 | LayoutUnit baselinePosition = cell->cellBaselinePosition() - cell->intrinsicPaddingBefore(); |
| 347 | LayoutUnit borderAndComputedPaddingBefore = cell->borderAndPaddingBefore() - cell->intrinsicPaddingBefore(); |
| 348 | if (baselinePosition > borderAndComputedPaddingBefore) { |
andersca@apple.com | 8629863 | 2013-11-10 19:32:33 +0000 | [diff] [blame] | 349 | m_grid[cellStartRow].baseline = std::max(m_grid[cellStartRow].baseline, baselinePosition); |
commit-queue@webkit.org | bb45481 | 2013-05-14 19:57:51 +0000 | [diff] [blame] | 350 | // The descent of a cell that spans multiple rows does not affect the height of the first row it spans, so don't let it |
| 351 | // become the baseline descent applied to the rest of the row. Also we don't account for the baseline descent of |
| 352 | // non-spanning cells when computing a spanning cell's extent. |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 353 | LayoutUnit cellStartRowBaselineDescent = 0; |
commit-queue@webkit.org | bb45481 | 2013-05-14 19:57:51 +0000 | [diff] [blame] | 354 | if (cell->rowSpan() == 1) { |
zalan@apple.com | df6351f | 2016-01-11 22:03:03 +0000 | [diff] [blame] | 355 | baselineDescent = std::max(baselineDescent, cellLogicalHeight - baselinePosition); |
commit-queue@webkit.org | bb45481 | 2013-05-14 19:57:51 +0000 | [diff] [blame] | 356 | cellStartRowBaselineDescent = baselineDescent; |
| 357 | } |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 358 | m_rowPos[cellStartRow + 1] = std::max(m_rowPos[cellStartRow + 1], m_rowPos[cellStartRow] + m_grid[cellStartRow].baseline + cellStartRowBaselineDescent); |
commit-queue@webkit.org | 5ec57ca | 2012-07-12 22:33:36 +0000 | [diff] [blame] | 359 | } |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 360 | } |
ap | 50b5835 | 2006-01-22 20:32:36 +0000 | [diff] [blame] | 361 | } |
| 362 | } |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 363 | |
jchaffraix@webkit.org | addd65e | 2012-02-26 00:19:22 +0000 | [diff] [blame] | 364 | // Add the border-spacing to our final position. |
ossy@webkit.org | 6d30aa7 | 2013-11-28 17:40:59 +0000 | [diff] [blame] | 365 | // Use table border-spacing even in non-top sections |
| 366 | spacing = table()->vBorderSpacing(); |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 367 | m_rowPos[r + 1] += m_grid[r].rowRenderer ? spacing : LayoutUnit::fromPixel(0); |
andersca@apple.com | 8629863 | 2013-11-10 19:32:33 +0000 | [diff] [blame] | 368 | m_rowPos[r + 1] = std::max(m_rowPos[r + 1], m_rowPos[r]); |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 369 | } |
weinig | fef1363 | 2007-04-29 20:09:08 +0000 | [diff] [blame] | 370 | |
hyatt@apple.com | c93db9b | 2009-02-04 22:29:04 +0000 | [diff] [blame] | 371 | ASSERT(!needsLayout()); |
| 372 | |
simon.fraser@apple.com | feaef2e | 2008-11-07 19:17:08 +0000 | [diff] [blame] | 373 | statePusher.pop(); |
mitz@apple.com | 440ac8c | 2008-04-05 16:05:08 +0000 | [diff] [blame] | 374 | |
jchaffraix@webkit.org | 68d3b57 | 2011-10-27 19:12:39 +0000 | [diff] [blame] | 375 | return m_rowPos[m_grid.size()]; |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 376 | } |
| 377 | |
hyatt@apple.com | bfda0e3 | 2009-01-31 21:20:17 +0000 | [diff] [blame] | 378 | void RenderTableSection::layout() |
| 379 | { |
mark.lam@apple.com | 6df1a80 | 2012-10-19 20:09:36 +0000 | [diff] [blame] | 380 | StackStats::LayoutCheckPoint layoutCheckPoint; |
hyatt@apple.com | bfda0e3 | 2009-01-31 21:20:17 +0000 | [diff] [blame] | 381 | ASSERT(needsLayout()); |
inferno@chromium.org | 7081f50 | 2012-05-26 00:28:23 +0000 | [diff] [blame] | 382 | ASSERT(!needsCellRecalc()); |
| 383 | ASSERT(!table()->needsSectionRecalc()); |
hyatt@apple.com | bfda0e3 | 2009-01-31 21:20:17 +0000 | [diff] [blame] | 384 | |
zalan@apple.com | a2c50dc | 2016-08-23 21:47:20 +0000 | [diff] [blame] | 385 | m_forceSlowPaintPathWithOverflowingCell = false; |
jchaffraix@webkit.org | a9ddfc1 | 2012-06-18 17:11:12 +0000 | [diff] [blame] | 386 | // addChild may over-grow m_grid but we don't want to throw away the memory too early as addChild |
| 387 | // can be called in a loop (e.g during parsing). Doing it now ensures we have a stable-enough structure. |
| 388 | m_grid.shrinkToFit(); |
| 389 | |
weinig@apple.com | f8d77f3 | 2013-11-18 01:12:17 +0000 | [diff] [blame] | 390 | LayoutStateMaintainer statePusher(view(), *this, locationOffset(), hasTransform() || hasReflection() || style().isFlippedBlocksWritingMode()); |
hyatt@apple.com | ccad374 | 2015-02-04 21:39:00 +0000 | [diff] [blame] | 391 | bool paginated = view().layoutState()->isPaginated(); |
| 392 | |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 393 | const Vector<LayoutUnit>& columnPos = table()->columnPositions(); |
hyatt@apple.com | ccad374 | 2015-02-04 21:39:00 +0000 | [diff] [blame] | 394 | |
jchaffraix@webkit.org | a66f108 | 2012-10-16 16:42:02 +0000 | [diff] [blame] | 395 | for (unsigned r = 0; r < m_grid.size(); ++r) { |
| 396 | Row& row = m_grid[r].row; |
| 397 | unsigned cols = row.size(); |
| 398 | // First, propagate our table layout's information to the cells. This will mark the row as needing layout |
| 399 | // if there was a column logical width change. |
| 400 | for (unsigned startColumn = 0; startColumn < cols; ++startColumn) { |
| 401 | CellStruct& current = row[startColumn]; |
| 402 | RenderTableCell* cell = current.primaryCell(); |
| 403 | if (!cell || current.inColSpan) |
| 404 | continue; |
| 405 | |
| 406 | unsigned endCol = startColumn; |
| 407 | unsigned cspan = cell->colSpan(); |
| 408 | while (cspan && endCol < cols) { |
| 409 | ASSERT(endCol < table()->columns().size()); |
| 410 | cspan -= table()->columns()[endCol].span; |
| 411 | endCol++; |
| 412 | } |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 413 | LayoutUnit tableLayoutLogicalWidth = columnPos[endCol] - columnPos[startColumn] - table()->hBorderSpacing(); |
jchaffraix@webkit.org | a66f108 | 2012-10-16 16:42:02 +0000 | [diff] [blame] | 414 | cell->setCellLogicalWidth(tableLayoutLogicalWidth); |
hyatt@apple.com | bfda0e3 | 2009-01-31 21:20:17 +0000 | [diff] [blame] | 415 | } |
jchaffraix@webkit.org | a66f108 | 2012-10-16 16:42:02 +0000 | [diff] [blame] | 416 | |
hyatt@apple.com | ccad374 | 2015-02-04 21:39:00 +0000 | [diff] [blame] | 417 | if (RenderTableRow* rowRenderer = m_grid[r].rowRenderer) { |
| 418 | if (!rowRenderer->needsLayout() && paginated && view().layoutState()->pageLogicalHeightChanged()) |
| 419 | rowRenderer->setChildNeedsLayout(MarkOnlyThis); |
| 420 | |
jchaffraix@webkit.org | a66f108 | 2012-10-16 16:42:02 +0000 | [diff] [blame] | 421 | rowRenderer->layoutIfNeeded(); |
hyatt@apple.com | ccad374 | 2015-02-04 21:39:00 +0000 | [diff] [blame] | 422 | } |
hyatt@apple.com | bfda0e3 | 2009-01-31 21:20:17 +0000 | [diff] [blame] | 423 | } |
jchaffraix@webkit.org | a66f108 | 2012-10-16 16:42:02 +0000 | [diff] [blame] | 424 | |
hyatt@apple.com | bfda0e3 | 2009-01-31 21:20:17 +0000 | [diff] [blame] | 425 | statePusher.pop(); |
antti@apple.com | ca2a8ff | 2013-10-04 04:04:35 +0000 | [diff] [blame] | 426 | clearNeedsLayout(); |
hyatt@apple.com | bfda0e3 | 2009-01-31 21:20:17 +0000 | [diff] [blame] | 427 | } |
| 428 | |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 429 | void RenderTableSection::distributeExtraLogicalHeightToPercentRows(LayoutUnit& extraLogicalHeight, int totalPercent) |
jchaffraix@webkit.org | 3395b97 | 2012-03-09 22:58:05 +0000 | [diff] [blame] | 430 | { |
| 431 | if (!totalPercent) |
jchaffraix@webkit.org | c278898 | 2012-03-20 21:02:34 +0000 | [diff] [blame] | 432 | return; |
jchaffraix@webkit.org | 3395b97 | 2012-03-09 22:58:05 +0000 | [diff] [blame] | 433 | |
| 434 | unsigned totalRows = m_grid.size(); |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 435 | LayoutUnit totalHeight = m_rowPos[totalRows] + extraLogicalHeight; |
| 436 | LayoutUnit totalLogicalHeightAdded = 0; |
andersca@apple.com | 8629863 | 2013-11-10 19:32:33 +0000 | [diff] [blame] | 437 | totalPercent = std::min(totalPercent, 100); |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 438 | LayoutUnit rowHeight = m_rowPos[1] - m_rowPos[0]; |
jchaffraix@webkit.org | 3395b97 | 2012-03-09 22:58:05 +0000 | [diff] [blame] | 439 | for (unsigned r = 0; r < totalRows; ++r) { |
commit-queue@webkit.org | 2a67f68 | 2015-05-10 21:43:26 +0000 | [diff] [blame] | 440 | if (totalPercent > 0 && m_grid[r].logicalHeight.isPercent()) { |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 441 | LayoutUnit toAdd = std::min<LayoutUnit>(extraLogicalHeight, (totalHeight * m_grid[r].logicalHeight.percent() / 100) - rowHeight); |
jchaffraix@webkit.org | 3395b97 | 2012-03-09 22:58:05 +0000 | [diff] [blame] | 442 | // If toAdd is negative, then we don't want to shrink the row (this bug |
| 443 | // affected Outlook Web Access). |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 444 | toAdd = std::max(LayoutUnit::fromPixel(0), toAdd); |
jchaffraix@webkit.org | c278898 | 2012-03-20 21:02:34 +0000 | [diff] [blame] | 445 | totalLogicalHeightAdded += toAdd; |
jchaffraix@webkit.org | 3395b97 | 2012-03-09 22:58:05 +0000 | [diff] [blame] | 446 | extraLogicalHeight -= toAdd; |
| 447 | totalPercent -= m_grid[r].logicalHeight.percent(); |
| 448 | } |
| 449 | ASSERT(totalRows >= 1); |
| 450 | if (r < totalRows - 1) |
| 451 | rowHeight = m_rowPos[r + 2] - m_rowPos[r + 1]; |
jchaffraix@webkit.org | c278898 | 2012-03-20 21:02:34 +0000 | [diff] [blame] | 452 | m_rowPos[r + 1] += totalLogicalHeightAdded; |
jchaffraix@webkit.org | 3395b97 | 2012-03-09 22:58:05 +0000 | [diff] [blame] | 453 | } |
jchaffraix@webkit.org | 3395b97 | 2012-03-09 22:58:05 +0000 | [diff] [blame] | 454 | } |
| 455 | |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 456 | void RenderTableSection::distributeExtraLogicalHeightToAutoRows(LayoutUnit& extraLogicalHeight, unsigned autoRowsCount) |
jchaffraix@webkit.org | 3395b97 | 2012-03-09 22:58:05 +0000 | [diff] [blame] | 457 | { |
| 458 | if (!autoRowsCount) |
jchaffraix@webkit.org | c278898 | 2012-03-20 21:02:34 +0000 | [diff] [blame] | 459 | return; |
jchaffraix@webkit.org | 3395b97 | 2012-03-09 22:58:05 +0000 | [diff] [blame] | 460 | |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 461 | LayoutUnit totalLogicalHeightAdded = 0; |
jchaffraix@webkit.org | 3395b97 | 2012-03-09 22:58:05 +0000 | [diff] [blame] | 462 | for (unsigned r = 0; r < m_grid.size(); ++r) { |
| 463 | if (autoRowsCount > 0 && m_grid[r].logicalHeight.isAuto()) { |
| 464 | // Recomputing |extraLogicalHeightForRow| guarantees that we properly ditribute round |extraLogicalHeight|. |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 465 | LayoutUnit extraLogicalHeightForRow = extraLogicalHeight / autoRowsCount; |
jchaffraix@webkit.org | c278898 | 2012-03-20 21:02:34 +0000 | [diff] [blame] | 466 | totalLogicalHeightAdded += extraLogicalHeightForRow; |
jchaffraix@webkit.org | 3395b97 | 2012-03-09 22:58:05 +0000 | [diff] [blame] | 467 | extraLogicalHeight -= extraLogicalHeightForRow; |
| 468 | --autoRowsCount; |
| 469 | } |
jchaffraix@webkit.org | c278898 | 2012-03-20 21:02:34 +0000 | [diff] [blame] | 470 | m_rowPos[r + 1] += totalLogicalHeightAdded; |
jchaffraix@webkit.org | 3395b97 | 2012-03-09 22:58:05 +0000 | [diff] [blame] | 471 | } |
jchaffraix@webkit.org | 3395b97 | 2012-03-09 22:58:05 +0000 | [diff] [blame] | 472 | } |
| 473 | |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 474 | void RenderTableSection::distributeRemainingExtraLogicalHeight(LayoutUnit& extraLogicalHeight) |
jchaffraix@webkit.org | 3395b97 | 2012-03-09 22:58:05 +0000 | [diff] [blame] | 475 | { |
| 476 | unsigned totalRows = m_grid.size(); |
| 477 | |
| 478 | if (extraLogicalHeight <= 0 || !m_rowPos[totalRows]) |
jchaffraix@webkit.org | c278898 | 2012-03-20 21:02:34 +0000 | [diff] [blame] | 479 | return; |
jchaffraix@webkit.org | 3395b97 | 2012-03-09 22:58:05 +0000 | [diff] [blame] | 480 | |
| 481 | // FIXME: m_rowPos[totalRows] - m_rowPos[0] is the total rows' size. |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 482 | LayoutUnit totalRowSize = m_rowPos[totalRows]; |
| 483 | LayoutUnit totalLogicalHeightAdded = 0; |
| 484 | LayoutUnit previousRowPosition = m_rowPos[0]; |
jchaffraix@webkit.org | 3395b97 | 2012-03-09 22:58:05 +0000 | [diff] [blame] | 485 | for (unsigned r = 0; r < totalRows; r++) { |
| 486 | // weight with the original height |
jchaffraix@webkit.org | c278898 | 2012-03-20 21:02:34 +0000 | [diff] [blame] | 487 | totalLogicalHeightAdded += extraLogicalHeight * (m_rowPos[r + 1] - previousRowPosition) / totalRowSize; |
jchaffraix@webkit.org | 3395b97 | 2012-03-09 22:58:05 +0000 | [diff] [blame] | 488 | previousRowPosition = m_rowPos[r + 1]; |
jchaffraix@webkit.org | c278898 | 2012-03-20 21:02:34 +0000 | [diff] [blame] | 489 | m_rowPos[r + 1] += totalLogicalHeightAdded; |
jchaffraix@webkit.org | 3395b97 | 2012-03-09 22:58:05 +0000 | [diff] [blame] | 490 | } |
| 491 | |
jchaffraix@webkit.org | c278898 | 2012-03-20 21:02:34 +0000 | [diff] [blame] | 492 | extraLogicalHeight -= totalLogicalHeightAdded; |
jchaffraix@webkit.org | 3395b97 | 2012-03-09 22:58:05 +0000 | [diff] [blame] | 493 | } |
| 494 | |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 495 | LayoutUnit RenderTableSection::distributeExtraLogicalHeightToRows(LayoutUnit extraLogicalHeight) |
jchaffraix@webkit.org | 3395b97 | 2012-03-09 22:58:05 +0000 | [diff] [blame] | 496 | { |
| 497 | if (!extraLogicalHeight) |
| 498 | return extraLogicalHeight; |
| 499 | |
| 500 | unsigned totalRows = m_grid.size(); |
| 501 | if (!totalRows) |
| 502 | return extraLogicalHeight; |
| 503 | |
| 504 | if (!m_rowPos[totalRows] && nextSibling()) |
| 505 | return extraLogicalHeight; |
| 506 | |
| 507 | unsigned autoRowsCount = 0; |
| 508 | int totalPercent = 0; |
| 509 | for (unsigned r = 0; r < totalRows; r++) { |
| 510 | if (m_grid[r].logicalHeight.isAuto()) |
| 511 | ++autoRowsCount; |
commit-queue@webkit.org | 2a67f68 | 2015-05-10 21:43:26 +0000 | [diff] [blame] | 512 | else if (m_grid[r].logicalHeight.isPercent()) |
jchaffraix@webkit.org | 3395b97 | 2012-03-09 22:58:05 +0000 | [diff] [blame] | 513 | totalPercent += m_grid[r].logicalHeight.percent(); |
| 514 | } |
| 515 | |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 516 | LayoutUnit remainingExtraLogicalHeight = extraLogicalHeight; |
jchaffraix@webkit.org | c278898 | 2012-03-20 21:02:34 +0000 | [diff] [blame] | 517 | distributeExtraLogicalHeightToPercentRows(remainingExtraLogicalHeight, totalPercent); |
| 518 | distributeExtraLogicalHeightToAutoRows(remainingExtraLogicalHeight, autoRowsCount); |
| 519 | distributeRemainingExtraLogicalHeight(remainingExtraLogicalHeight); |
| 520 | return extraLogicalHeight - remainingExtraLogicalHeight; |
jchaffraix@webkit.org | 3395b97 | 2012-03-09 22:58:05 +0000 | [diff] [blame] | 521 | } |
| 522 | |
jchaffraix@webkit.org | 94f150f | 2012-03-20 04:53:14 +0000 | [diff] [blame] | 523 | void RenderTableSection::layoutRows() |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 524 | { |
hyatt@apple.com | c93db9b | 2009-02-04 22:29:04 +0000 | [diff] [blame] | 525 | #ifndef NDEBUG |
ojan@chromium.org | ccdc429 | 2013-02-07 00:55:10 +0000 | [diff] [blame] | 526 | SetLayoutNeededForbiddenScope layoutForbiddenScope(this); |
hyatt@apple.com | c93db9b | 2009-02-04 22:29:04 +0000 | [diff] [blame] | 527 | #endif |
| 528 | |
| 529 | ASSERT(!needsLayout()); |
| 530 | |
jchaffraix@webkit.org | 369c5d3 | 2011-10-28 01:28:58 +0000 | [diff] [blame] | 531 | unsigned totalRows = m_grid.size(); |
| 532 | |
hyatt | d866e59 | 2006-03-17 09:50:35 +0000 | [diff] [blame] | 533 | // Set the width of our section now. The rows will also be this width. |
mitz@apple.com | 8010bba | 2010-11-05 02:43:17 +0000 | [diff] [blame] | 534 | setLogicalWidth(table()->contentLogicalWidth()); |
jchaffraix@webkit.org | f4ce050 | 2011-08-18 20:20:57 +0000 | [diff] [blame] | 535 | m_forceSlowPaintPathWithOverflowingCell = false; |
adele | ddfe27f | 2007-01-05 23:03:50 +0000 | [diff] [blame] | 536 | |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 537 | LayoutUnit vspacing = table()->vBorderSpacing(); |
jchaffraix@webkit.org | fb2a860 | 2011-11-16 02:03:54 +0000 | [diff] [blame] | 538 | unsigned nEffCols = table()->numEffCols(); |
ddkilzer | 260f3d2 | 2007-01-05 05:56:31 +0000 | [diff] [blame] | 539 | |
weinig@apple.com | f8d77f3 | 2013-11-18 01:12:17 +0000 | [diff] [blame] | 540 | LayoutStateMaintainer statePusher(view(), *this, locationOffset(), hasTransform() || style().isFlippedBlocksWritingMode()); |
weinig | fef1363 | 2007-04-29 20:09:08 +0000 | [diff] [blame] | 541 | |
jchaffraix@webkit.org | 369c5d3 | 2011-10-28 01:28:58 +0000 | [diff] [blame] | 542 | for (unsigned r = 0; r < totalRows; r++) { |
hyatt | d866e59 | 2006-03-17 09:50:35 +0000 | [diff] [blame] | 543 | // Set the row's x/y position and width/height. |
hyatt@apple.com | d885df7 | 2009-01-22 02:31:52 +0000 | [diff] [blame] | 544 | if (RenderTableRow* rowRenderer = m_grid[r].rowRenderer) { |
robert@webkit.org | f9766b1 | 2013-08-27 19:21:00 +0000 | [diff] [blame] | 545 | // FIXME: the x() position of the row should be table()->hBorderSpacing() so that it can |
| 546 | // report the correct offsetLeft. However, that will require a lot of rebaselining of test results. |
leviw@chromium.org | 7353dfd | 2011-08-12 21:01:45 +0000 | [diff] [blame] | 547 | rowRenderer->setLocation(LayoutPoint(0, m_rowPos[r])); |
mitz@apple.com | 8010bba | 2010-11-05 02:43:17 +0000 | [diff] [blame] | 548 | rowRenderer->setLogicalWidth(logicalWidth()); |
| 549 | rowRenderer->setLogicalHeight(m_rowPos[r + 1] - m_rowPos[r] - vspacing); |
simon.fraser@apple.com | 78e3bdb | 2010-11-30 00:53:05 +0000 | [diff] [blame] | 550 | rowRenderer->updateLayerTransform(); |
zalan@apple.com | d423bcc | 2016-02-06 23:07:54 +0000 | [diff] [blame] | 551 | rowRenderer->clearOverflow(); |
| 552 | rowRenderer->addVisualEffectOverflow(); |
hyatt | d866e59 | 2006-03-17 09:50:35 +0000 | [diff] [blame] | 553 | } |
| 554 | |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 555 | LayoutUnit rowHeightIncreaseForPagination = 0; |
mitz@apple.com | 48b3ee8 | 2012-07-12 02:38:38 +0000 | [diff] [blame] | 556 | |
jchaffraix@webkit.org | fb2a860 | 2011-11-16 02:03:54 +0000 | [diff] [blame] | 557 | for (unsigned c = 0; c < nEffCols; c++) { |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 558 | CellStruct& cs = cellAt(r, c); |
| 559 | RenderTableCell* cell = cs.primaryCell(); |
| 560 | |
jamesr@google.com | b426623 | 2010-07-28 20:07:19 +0000 | [diff] [blame] | 561 | if (!cell || cs.inColSpan) |
ap | 50b5835 | 2006-01-22 20:32:36 +0000 | [diff] [blame] | 562 | continue; |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 563 | |
jchaffraix@webkit.org | 83cb391 | 2012-10-05 03:56:17 +0000 | [diff] [blame] | 564 | int rowIndex = cell->rowIndex(); |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 565 | LayoutUnit rHeight = m_rowPos[rowIndex + cell->rowSpan()] - m_rowPos[rowIndex] - vspacing; |
jchaffraix@webkit.org | 83cb391 | 2012-10-05 03:56:17 +0000 | [diff] [blame] | 566 | |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 567 | // Force percent height children to lay themselves out again. |
| 568 | // This will cause these children to grow to fill the cell. |
| 569 | // FIXME: There is still more work to do here to fully match WinIE (should |
| 570 | // it become necessary to do so). In quirks mode, WinIE behaves like we |
| 571 | // do, but it will clip the cells that spill out of the table section. In |
| 572 | // strict mode, Mozilla and WinIE both regrow the table to accommodate the |
| 573 | // new height of the cell (thus letting the percentages cause growth one |
| 574 | // time only). We may also not be handling row-spanning cells correctly. |
| 575 | // |
| 576 | // Note also the oddity where replaced elements always flex, and yet blocks/tables do |
| 577 | // not necessarily flex. WinIE is crazy and inconsistent, and we can't hope to |
| 578 | // match the behavior perfectly, but we'll continue to refine it as we discover new |
| 579 | // bugs. :) |
| 580 | bool cellChildrenFlex = false; |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 581 | bool flexAllChildren = cell->style().logicalHeight().isFixed() |
| 582 | || (!table()->style().logicalHeight().isAuto() && rHeight != cell->logicalHeight()); |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 583 | |
cdumez@apple.com | 6962695 | 2016-05-17 22:39:00 +0000 | [diff] [blame] | 584 | for (auto& renderer : childrenOfType<RenderObject>(*cell)) { |
| 585 | if (!is<RenderText>(renderer) && renderer.style().logicalHeight().isPercentOrCalculated() && (flexAllChildren || ((renderer.isReplaced() || (is<RenderBox>(renderer) && downcast<RenderBox>(renderer).scrollsOverflow())) && !is<RenderTextControl>(renderer)))) { |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 586 | // Tables with no sections do not flex. |
cdumez@apple.com | 6962695 | 2016-05-17 22:39:00 +0000 | [diff] [blame] | 587 | if (!is<RenderTable>(renderer) || downcast<RenderTable>(renderer).hasSections()) { |
| 588 | renderer.setNeedsLayout(MarkOnlyThis); |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 589 | cellChildrenFlex = true; |
| 590 | } |
| 591 | } |
| 592 | } |
mitz@apple.com | 1547c6d | 2009-03-20 23:41:54 +0000 | [diff] [blame] | 593 | |
tony@chromium.org | 05b9d2c | 2012-09-05 01:31:38 +0000 | [diff] [blame] | 594 | if (TrackedRendererListHashSet* percentHeightDescendants = cell->percentHeightDescendants()) { |
| 595 | TrackedRendererListHashSet::iterator end = percentHeightDescendants->end(); |
| 596 | for (TrackedRendererListHashSet::iterator it = percentHeightDescendants->begin(); it != end; ++it) { |
mitz@apple.com | 1547c6d | 2009-03-20 23:41:54 +0000 | [diff] [blame] | 597 | RenderBox* box = *it; |
| 598 | if (!box->isReplaced() && !box->scrollsOverflow() && !flexAllChildren) |
| 599 | continue; |
| 600 | |
| 601 | while (box != cell) { |
| 602 | if (box->normalChildNeedsLayout()) |
| 603 | break; |
antti@apple.com | ca2a8ff | 2013-10-04 04:04:35 +0000 | [diff] [blame] | 604 | box->setChildNeedsLayout(MarkOnlyThis); |
mitz@apple.com | 1547c6d | 2009-03-20 23:41:54 +0000 | [diff] [blame] | 605 | box = box->containingBlock(); |
| 606 | ASSERT(box); |
| 607 | if (!box) |
| 608 | break; |
| 609 | } |
| 610 | cellChildrenFlex = true; |
| 611 | } |
| 612 | } |
| 613 | |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 614 | if (cellChildrenFlex) { |
antti@apple.com | ca2a8ff | 2013-10-04 04:04:35 +0000 | [diff] [blame] | 615 | cell->setChildNeedsLayout(MarkOnlyThis); |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 616 | // Alignment within a cell is based off the calculated |
| 617 | // height, which becomes irrelevant once the cell has |
hyatt@apple.com | 0bf6c84 | 2009-01-23 03:42:12 +0000 | [diff] [blame] | 618 | // been resized based off its percentage. |
ojan@chromium.org | 7a1ce8b | 2012-06-05 18:32:10 +0000 | [diff] [blame] | 619 | cell->setOverrideLogicalContentHeightFromRowHeight(rHeight); |
ap | 7332aaa | 2006-04-28 16:02:45 +0000 | [diff] [blame] | 620 | cell->layoutIfNeeded(); |
mitz@apple.com | 8010bba | 2010-11-05 02:43:17 +0000 | [diff] [blame] | 621 | |
hyatt | 851433b | 2007-05-12 06:40:14 +0000 | [diff] [blame] | 622 | // If the baseline moved, we may have to update the data for our row. Find out the new baseline. |
robert@webkit.org | 292be54 | 2013-03-09 06:40:13 +0000 | [diff] [blame] | 623 | if (cell->isBaselineAligned()) { |
leviw@chromium.org | 2650e38 | 2012-04-04 10:37:36 +0000 | [diff] [blame] | 624 | LayoutUnit baseline = cell->cellBaselinePosition(); |
zoltan@webkit.org | 8e79cc2 | 2013-06-14 00:39:36 +0000 | [diff] [blame] | 625 | if (baseline > cell->borderAndPaddingBefore()) |
andersca@apple.com | 8629863 | 2013-11-10 19:32:33 +0000 | [diff] [blame] | 626 | m_grid[r].baseline = std::max(m_grid[r].baseline, baseline); |
hyatt | 851433b | 2007-05-12 06:40:14 +0000 | [diff] [blame] | 627 | } |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 628 | } |
mitz@apple.com | 8010bba | 2010-11-05 02:43:17 +0000 | [diff] [blame] | 629 | |
jchaffraix@webkit.org | 83cb391 | 2012-10-05 03:56:17 +0000 | [diff] [blame] | 630 | cell->computeIntrinsicPadding(rHeight); |
mitz@apple.com | 8010bba | 2010-11-05 02:43:17 +0000 | [diff] [blame] | 631 | |
eae@chromium.org | 1146f21 | 2012-07-18 22:06:34 +0000 | [diff] [blame] | 632 | LayoutRect oldCellRect = cell->frameRect(); |
mitz@apple.com | 8010bba | 2010-11-05 02:43:17 +0000 | [diff] [blame] | 633 | |
jchaffraix@webkit.org | 4b5292a | 2012-06-06 16:07:16 +0000 | [diff] [blame] | 634 | setLogicalPositionForCell(cell, c); |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 635 | |
akling@apple.com | 691cf5c | 2013-08-24 16:33:15 +0000 | [diff] [blame] | 636 | if (!cell->needsLayout() && view().layoutState()->pageLogicalHeight() && view().layoutState()->pageLogicalOffset(cell, cell->logicalTop()) != cell->pageLogicalOffset()) |
antti@apple.com | ca2a8ff | 2013-10-04 04:04:35 +0000 | [diff] [blame] | 637 | cell->setChildNeedsLayout(MarkOnlyThis); |
mitz@apple.com | 8010bba | 2010-11-05 02:43:17 +0000 | [diff] [blame] | 638 | |
hyatt@apple.com | 1259d73 | 2010-09-20 16:12:58 +0000 | [diff] [blame] | 639 | cell->layoutIfNeeded(); |
mitz@apple.com | 8010bba | 2010-11-05 02:43:17 +0000 | [diff] [blame] | 640 | |
| 641 | // FIXME: Make pagination work with vertical tables. |
akling@apple.com | 691cf5c | 2013-08-24 16:33:15 +0000 | [diff] [blame] | 642 | if (view().layoutState()->pageLogicalHeight() && cell->logicalHeight() != rHeight) { |
hyatt@apple.com | 8403ad2 | 2012-04-10 18:14:20 +0000 | [diff] [blame] | 643 | // FIXME: Pagination might have made us change size. For now just shrink or grow the cell to fit without doing a relayout. |
| 644 | // We'll also do a basic increase of the row height to accommodate the cell if it's bigger, but this isn't quite right |
| 645 | // either. It's at least stable though and won't result in an infinite # of relayouts that may never stabilize. |
mitz@apple.com | 48b3ee8 | 2012-07-12 02:38:38 +0000 | [diff] [blame] | 646 | if (cell->logicalHeight() > rHeight) |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 647 | rowHeightIncreaseForPagination = std::max(rowHeightIncreaseForPagination, cell->logicalHeight() - rHeight); |
mitz@apple.com | 48b3ee8 | 2012-07-12 02:38:38 +0000 | [diff] [blame] | 648 | cell->setLogicalHeight(rHeight); |
hyatt@apple.com | 8403ad2 | 2012-04-10 18:14:20 +0000 | [diff] [blame] | 649 | } |
mitz@apple.com | 8010bba | 2010-11-05 02:43:17 +0000 | [diff] [blame] | 650 | |
leviw@chromium.org | 7353dfd | 2011-08-12 21:01:45 +0000 | [diff] [blame] | 651 | LayoutSize childOffset(cell->location() - oldCellRect.location()); |
hyatt@apple.com | b297b49 | 2010-09-20 20:21:34 +0000 | [diff] [blame] | 652 | if (childOffset.width() || childOffset.height()) { |
akling@apple.com | 691cf5c | 2013-08-24 16:33:15 +0000 | [diff] [blame] | 653 | view().addLayoutDelta(childOffset); |
hyatt@apple.com | 1259d73 | 2010-09-20 16:12:58 +0000 | [diff] [blame] | 654 | |
hyatt@apple.com | b297b49 | 2010-09-20 20:21:34 +0000 | [diff] [blame] | 655 | // If the child moved, we have to repaint it as well as any floating/positioned |
| 656 | // descendants. An exception is if we need a layout. In this case, we know we're going to |
| 657 | // repaint ourselves (and the child) anyway. |
| 658 | if (!table()->selfNeedsLayout() && cell->checkForRepaintDuringLayout()) |
| 659 | cell->repaintDuringLayoutIfMoved(oldCellRect); |
| 660 | } |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 661 | } |
mitz@apple.com | 48b3ee8 | 2012-07-12 02:38:38 +0000 | [diff] [blame] | 662 | if (rowHeightIncreaseForPagination) { |
| 663 | for (unsigned rowIndex = r + 1; rowIndex <= totalRows; rowIndex++) |
| 664 | m_rowPos[rowIndex] += rowHeightIncreaseForPagination; |
| 665 | for (unsigned c = 0; c < nEffCols; ++c) { |
| 666 | Vector<RenderTableCell*, 1>& cells = cellAt(r, c).cells; |
| 667 | for (size_t i = 0; i < cells.size(); ++i) |
| 668 | cells[i]->setLogicalHeight(cells[i]->logicalHeight() + rowHeightIncreaseForPagination); |
| 669 | } |
| 670 | } |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 671 | } |
| 672 | |
hyatt@apple.com | 8b2cd1f | 2009-01-26 03:38:55 +0000 | [diff] [blame] | 673 | ASSERT(!needsLayout()); |
| 674 | |
mitz@apple.com | 8010bba | 2010-11-05 02:43:17 +0000 | [diff] [blame] | 675 | setLogicalHeight(m_rowPos[totalRows]); |
hyatt@apple.com | 7214c6a | 2009-08-19 16:28:51 +0000 | [diff] [blame] | 676 | |
robert@webkit.org | 4c91cc9 | 2013-03-27 23:49:48 +0000 | [diff] [blame] | 677 | computeOverflowFromCells(totalRows, nEffCols); |
| 678 | |
| 679 | statePusher.pop(); |
| 680 | } |
| 681 | |
| 682 | void RenderTableSection::computeOverflowFromCells() |
| 683 | { |
| 684 | unsigned totalRows = m_grid.size(); |
| 685 | unsigned nEffCols = table()->numEffCols(); |
| 686 | computeOverflowFromCells(totalRows, nEffCols); |
| 687 | } |
| 688 | |
| 689 | void RenderTableSection::computeOverflowFromCells(unsigned totalRows, unsigned nEffCols) |
| 690 | { |
abucur@adobe.com | 6585d01 | 2013-09-04 08:26:41 +0000 | [diff] [blame] | 691 | clearOverflow(); |
robert@webkit.org | e4314c4 | 2013-08-08 18:13:22 +0000 | [diff] [blame] | 692 | m_overflowingCells.clear(); |
jchaffraix@webkit.org | f4ce050 | 2011-08-18 20:20:57 +0000 | [diff] [blame] | 693 | unsigned totalCellsCount = nEffCols * totalRows; |
commit-queue@webkit.org | 877bfc3 | 2015-03-10 21:54:21 +0000 | [diff] [blame] | 694 | unsigned maxAllowedOverflowingCellsCount = totalCellsCount < gMinTableSizeToUseFastPaintPathWithOverflowingCell ? 0 : gMaxAllowedOverflowingCellRatioForFastPaintPath * totalCellsCount; |
jchaffraix@webkit.org | f4ce050 | 2011-08-18 20:20:57 +0000 | [diff] [blame] | 695 | |
| 696 | #ifndef NDEBUG |
| 697 | bool hasOverflowingCell = false; |
| 698 | #endif |
hyatt@apple.com | 7214c6a | 2009-08-19 16:28:51 +0000 | [diff] [blame] | 699 | // Now that our height has been determined, add in overflow from cells. |
jchaffraix@webkit.org | 369c5d3 | 2011-10-28 01:28:58 +0000 | [diff] [blame] | 700 | for (unsigned r = 0; r < totalRows; r++) { |
jchaffraix@webkit.org | fb2a860 | 2011-11-16 02:03:54 +0000 | [diff] [blame] | 701 | for (unsigned c = 0; c < nEffCols; c++) { |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 702 | CellStruct& cs = cellAt(r, c); |
| 703 | RenderTableCell* cell = cs.primaryCell(); |
jamesr@google.com | b426623 | 2010-07-28 20:07:19 +0000 | [diff] [blame] | 704 | if (!cell || cs.inColSpan) |
hyatt@apple.com | 7214c6a | 2009-08-19 16:28:51 +0000 | [diff] [blame] | 705 | continue; |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 706 | if (r < totalRows - 1 && cell == primaryCellAt(r + 1, c)) |
hyatt@apple.com | 7214c6a | 2009-08-19 16:28:51 +0000 | [diff] [blame] | 707 | continue; |
| 708 | addOverflowFromChild(cell); |
jchaffraix@webkit.org | f4ce050 | 2011-08-18 20:20:57 +0000 | [diff] [blame] | 709 | #ifndef NDEBUG |
| 710 | hasOverflowingCell |= cell->hasVisualOverflow(); |
| 711 | #endif |
| 712 | if (cell->hasVisualOverflow() && !m_forceSlowPaintPathWithOverflowingCell) { |
| 713 | m_overflowingCells.add(cell); |
| 714 | if (m_overflowingCells.size() > maxAllowedOverflowingCellsCount) { |
| 715 | // We need to set m_forcesSlowPaintPath only if there is a least one overflowing cells as the hit testing code rely on this information. |
| 716 | m_forceSlowPaintPathWithOverflowingCell = true; |
| 717 | // The slow path does not make any use of the overflowing cells info, don't hold on to the memory. |
| 718 | m_overflowingCells.clear(); |
| 719 | } |
| 720 | } |
hyatt@apple.com | 7214c6a | 2009-08-19 16:28:51 +0000 | [diff] [blame] | 721 | } |
| 722 | } |
jchaffraix@webkit.org | f4ce050 | 2011-08-18 20:20:57 +0000 | [diff] [blame] | 723 | ASSERT(hasOverflowingCell == this->hasOverflowingCell()); |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 724 | } |
| 725 | |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 726 | LayoutUnit RenderTableSection::calcOuterBorderBefore() const |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 727 | { |
jchaffraix@webkit.org | fb2a860 | 2011-11-16 02:03:54 +0000 | [diff] [blame] | 728 | unsigned totalCols = table()->numEffCols(); |
jchaffraix@webkit.org | 68d3b57 | 2011-10-27 19:12:39 +0000 | [diff] [blame] | 729 | if (!m_grid.size() || !totalCols) |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 730 | return 0; |
| 731 | |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 732 | LayoutUnit borderWidth = 0; |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 733 | |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 734 | const BorderValue& sb = style().borderBefore(); |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 735 | if (sb.style() == BHIDDEN) |
| 736 | return -1; |
| 737 | if (sb.style() > BHIDDEN) |
hyatt@apple.com | e607db7 | 2010-04-09 20:21:55 +0000 | [diff] [blame] | 738 | borderWidth = sb.width(); |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 739 | |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 740 | const BorderValue& rb = firstRow()->style().borderBefore(); |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 741 | if (rb.style() == BHIDDEN) |
| 742 | return -1; |
hyatt@apple.com | e607db7 | 2010-04-09 20:21:55 +0000 | [diff] [blame] | 743 | if (rb.style() > BHIDDEN && rb.width() > borderWidth) |
| 744 | borderWidth = rb.width(); |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 745 | |
| 746 | bool allHidden = true; |
jchaffraix@webkit.org | fb2a860 | 2011-11-16 02:03:54 +0000 | [diff] [blame] | 747 | for (unsigned c = 0; c < totalCols; c++) { |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 748 | const CellStruct& current = cellAt(0, c); |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 749 | if (current.inColSpan || !current.hasCells()) |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 750 | continue; |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 751 | const BorderValue& cb = current.primaryCell()->style().borderBefore(); // FIXME: Make this work with perpendicular and flipped cells. |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 752 | // FIXME: Don't repeat for the same col group |
| 753 | RenderTableCol* colGroup = table()->colElement(c); |
| 754 | if (colGroup) { |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 755 | const BorderValue& gb = colGroup->style().borderBefore(); |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 756 | if (gb.style() == BHIDDEN || cb.style() == BHIDDEN) |
| 757 | continue; |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 758 | allHidden = false; |
hyatt@apple.com | e607db7 | 2010-04-09 20:21:55 +0000 | [diff] [blame] | 759 | if (gb.style() > BHIDDEN && gb.width() > borderWidth) |
| 760 | borderWidth = gb.width(); |
| 761 | if (cb.style() > BHIDDEN && cb.width() > borderWidth) |
| 762 | borderWidth = cb.width(); |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 763 | } else { |
| 764 | if (cb.style() == BHIDDEN) |
| 765 | continue; |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 766 | allHidden = false; |
hyatt@apple.com | e607db7 | 2010-04-09 20:21:55 +0000 | [diff] [blame] | 767 | if (cb.style() > BHIDDEN && cb.width() > borderWidth) |
| 768 | borderWidth = cb.width(); |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 769 | } |
| 770 | } |
| 771 | if (allHidden) |
| 772 | return -1; |
zalan@apple.com | 6a1fae4a | 2016-03-06 03:10:21 +0000 | [diff] [blame] | 773 | return CollapsedBorderValue::adjustedCollapsedBorderWidth(borderWidth, document().deviceScaleFactor(), false); |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 774 | } |
| 775 | |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 776 | LayoutUnit RenderTableSection::calcOuterBorderAfter() const |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 777 | { |
jchaffraix@webkit.org | fb2a860 | 2011-11-16 02:03:54 +0000 | [diff] [blame] | 778 | unsigned totalCols = table()->numEffCols(); |
jchaffraix@webkit.org | 68d3b57 | 2011-10-27 19:12:39 +0000 | [diff] [blame] | 779 | if (!m_grid.size() || !totalCols) |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 780 | return 0; |
| 781 | |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 782 | LayoutUnit borderWidth = 0; |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 783 | |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 784 | const BorderValue& sb = style().borderAfter(); |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 785 | if (sb.style() == BHIDDEN) |
| 786 | return -1; |
| 787 | if (sb.style() > BHIDDEN) |
hyatt@apple.com | e607db7 | 2010-04-09 20:21:55 +0000 | [diff] [blame] | 788 | borderWidth = sb.width(); |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 789 | |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 790 | const BorderValue& rb = lastRow()->style().borderAfter(); |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 791 | if (rb.style() == BHIDDEN) |
| 792 | return -1; |
hyatt@apple.com | e607db7 | 2010-04-09 20:21:55 +0000 | [diff] [blame] | 793 | if (rb.style() > BHIDDEN && rb.width() > borderWidth) |
| 794 | borderWidth = rb.width(); |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 795 | |
| 796 | bool allHidden = true; |
jchaffraix@webkit.org | fb2a860 | 2011-11-16 02:03:54 +0000 | [diff] [blame] | 797 | for (unsigned c = 0; c < totalCols; c++) { |
jchaffraix@webkit.org | 68d3b57 | 2011-10-27 19:12:39 +0000 | [diff] [blame] | 798 | const CellStruct& current = cellAt(m_grid.size() - 1, c); |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 799 | if (current.inColSpan || !current.hasCells()) |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 800 | continue; |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 801 | const BorderValue& cb = current.primaryCell()->style().borderAfter(); // FIXME: Make this work with perpendicular and flipped cells. |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 802 | // FIXME: Don't repeat for the same col group |
| 803 | RenderTableCol* colGroup = table()->colElement(c); |
| 804 | if (colGroup) { |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 805 | const BorderValue& gb = colGroup->style().borderAfter(); |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 806 | if (gb.style() == BHIDDEN || cb.style() == BHIDDEN) |
| 807 | continue; |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 808 | allHidden = false; |
hyatt@apple.com | e607db7 | 2010-04-09 20:21:55 +0000 | [diff] [blame] | 809 | if (gb.style() > BHIDDEN && gb.width() > borderWidth) |
| 810 | borderWidth = gb.width(); |
| 811 | if (cb.style() > BHIDDEN && cb.width() > borderWidth) |
| 812 | borderWidth = cb.width(); |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 813 | } else { |
| 814 | if (cb.style() == BHIDDEN) |
| 815 | continue; |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 816 | allHidden = false; |
hyatt@apple.com | e607db7 | 2010-04-09 20:21:55 +0000 | [diff] [blame] | 817 | if (cb.style() > BHIDDEN && cb.width() > borderWidth) |
| 818 | borderWidth = cb.width(); |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 819 | } |
| 820 | } |
| 821 | if (allHidden) |
| 822 | return -1; |
zalan@apple.com | 6a1fae4a | 2016-03-06 03:10:21 +0000 | [diff] [blame] | 823 | return CollapsedBorderValue::adjustedCollapsedBorderWidth(borderWidth, document().deviceScaleFactor(), true); |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 824 | } |
| 825 | |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 826 | LayoutUnit RenderTableSection::calcOuterBorderStart() const |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 827 | { |
jchaffraix@webkit.org | fb2a860 | 2011-11-16 02:03:54 +0000 | [diff] [blame] | 828 | unsigned totalCols = table()->numEffCols(); |
jchaffraix@webkit.org | 68d3b57 | 2011-10-27 19:12:39 +0000 | [diff] [blame] | 829 | if (!m_grid.size() || !totalCols) |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 830 | return 0; |
| 831 | |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 832 | LayoutUnit borderWidth = 0; |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 833 | |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 834 | const BorderValue& sb = style().borderStart(); |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 835 | if (sb.style() == BHIDDEN) |
| 836 | return -1; |
| 837 | if (sb.style() > BHIDDEN) |
hyatt@apple.com | e607db7 | 2010-04-09 20:21:55 +0000 | [diff] [blame] | 838 | borderWidth = sb.width(); |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 839 | |
mitz@apple.com | 8010bba | 2010-11-05 02:43:17 +0000 | [diff] [blame] | 840 | if (RenderTableCol* colGroup = table()->colElement(0)) { |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 841 | const BorderValue& gb = colGroup->style().borderStart(); |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 842 | if (gb.style() == BHIDDEN) |
| 843 | return -1; |
hyatt@apple.com | e607db7 | 2010-04-09 20:21:55 +0000 | [diff] [blame] | 844 | if (gb.style() > BHIDDEN && gb.width() > borderWidth) |
| 845 | borderWidth = gb.width(); |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 846 | } |
| 847 | |
| 848 | bool allHidden = true; |
jchaffraix@webkit.org | 68d3b57 | 2011-10-27 19:12:39 +0000 | [diff] [blame] | 849 | for (unsigned r = 0; r < m_grid.size(); r++) { |
mitz@apple.com | 8010bba | 2010-11-05 02:43:17 +0000 | [diff] [blame] | 850 | const CellStruct& current = cellAt(r, 0); |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 851 | if (!current.hasCells()) |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 852 | continue; |
| 853 | // FIXME: Don't repeat for the same cell |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 854 | const BorderValue& cb = current.primaryCell()->style().borderStart(); // FIXME: Make this work with perpendicular and flipped cells. |
| 855 | const BorderValue& rb = current.primaryCell()->parent()->style().borderStart(); |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 856 | if (cb.style() == BHIDDEN || rb.style() == BHIDDEN) |
| 857 | continue; |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 858 | allHidden = false; |
hyatt@apple.com | e607db7 | 2010-04-09 20:21:55 +0000 | [diff] [blame] | 859 | if (cb.style() > BHIDDEN && cb.width() > borderWidth) |
| 860 | borderWidth = cb.width(); |
| 861 | if (rb.style() > BHIDDEN && rb.width() > borderWidth) |
| 862 | borderWidth = rb.width(); |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 863 | } |
| 864 | if (allHidden) |
| 865 | return -1; |
zalan@apple.com | 6a1fae4a | 2016-03-06 03:10:21 +0000 | [diff] [blame] | 866 | return CollapsedBorderValue::adjustedCollapsedBorderWidth(borderWidth, document().deviceScaleFactor(), !table()->style().isLeftToRightDirection()); |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 867 | } |
| 868 | |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 869 | LayoutUnit RenderTableSection::calcOuterBorderEnd() const |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 870 | { |
jchaffraix@webkit.org | fb2a860 | 2011-11-16 02:03:54 +0000 | [diff] [blame] | 871 | unsigned totalCols = table()->numEffCols(); |
jchaffraix@webkit.org | 68d3b57 | 2011-10-27 19:12:39 +0000 | [diff] [blame] | 872 | if (!m_grid.size() || !totalCols) |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 873 | return 0; |
| 874 | |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 875 | LayoutUnit borderWidth = 0; |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 876 | |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 877 | const BorderValue& sb = style().borderEnd(); |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 878 | if (sb.style() == BHIDDEN) |
| 879 | return -1; |
| 880 | if (sb.style() > BHIDDEN) |
hyatt@apple.com | e607db7 | 2010-04-09 20:21:55 +0000 | [diff] [blame] | 881 | borderWidth = sb.width(); |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 882 | |
mitz@apple.com | 8010bba | 2010-11-05 02:43:17 +0000 | [diff] [blame] | 883 | if (RenderTableCol* colGroup = table()->colElement(totalCols - 1)) { |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 884 | const BorderValue& gb = colGroup->style().borderEnd(); |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 885 | if (gb.style() == BHIDDEN) |
| 886 | return -1; |
hyatt@apple.com | e607db7 | 2010-04-09 20:21:55 +0000 | [diff] [blame] | 887 | if (gb.style() > BHIDDEN && gb.width() > borderWidth) |
| 888 | borderWidth = gb.width(); |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 889 | } |
| 890 | |
| 891 | bool allHidden = true; |
jchaffraix@webkit.org | 68d3b57 | 2011-10-27 19:12:39 +0000 | [diff] [blame] | 892 | for (unsigned r = 0; r < m_grid.size(); r++) { |
mitz@apple.com | 8010bba | 2010-11-05 02:43:17 +0000 | [diff] [blame] | 893 | const CellStruct& current = cellAt(r, totalCols - 1); |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 894 | if (!current.hasCells()) |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 895 | continue; |
| 896 | // FIXME: Don't repeat for the same cell |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 897 | const BorderValue& cb = current.primaryCell()->style().borderEnd(); // FIXME: Make this work with perpendicular and flipped cells. |
| 898 | const BorderValue& rb = current.primaryCell()->parent()->style().borderEnd(); |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 899 | if (cb.style() == BHIDDEN || rb.style() == BHIDDEN) |
| 900 | continue; |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 901 | allHidden = false; |
hyatt@apple.com | e607db7 | 2010-04-09 20:21:55 +0000 | [diff] [blame] | 902 | if (cb.style() > BHIDDEN && cb.width() > borderWidth) |
| 903 | borderWidth = cb.width(); |
| 904 | if (rb.style() > BHIDDEN && rb.width() > borderWidth) |
| 905 | borderWidth = rb.width(); |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 906 | } |
| 907 | if (allHidden) |
| 908 | return -1; |
zalan@apple.com | 6a1fae4a | 2016-03-06 03:10:21 +0000 | [diff] [blame] | 909 | return CollapsedBorderValue::adjustedCollapsedBorderWidth(borderWidth, document().deviceScaleFactor(), table()->style().isLeftToRightDirection()); |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 910 | } |
| 911 | |
| 912 | void RenderTableSection::recalcOuterBorder() |
| 913 | { |
mitz@apple.com | 8010bba | 2010-11-05 02:43:17 +0000 | [diff] [blame] | 914 | m_outerBorderBefore = calcOuterBorderBefore(); |
| 915 | m_outerBorderAfter = calcOuterBorderAfter(); |
| 916 | m_outerBorderStart = calcOuterBorderStart(); |
| 917 | m_outerBorderEnd = calcOuterBorderEnd(); |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 918 | } |
| 919 | |
mmaxfield@apple.com | 5f90774 | 2015-03-11 18:22:06 +0000 | [diff] [blame] | 920 | Optional<int> RenderTableSection::firstLineBaseline() const |
mitz@apple.com | 57a2f48 | 2008-08-23 07:16:41 +0000 | [diff] [blame] | 921 | { |
jchaffraix@webkit.org | 68d3b57 | 2011-10-27 19:12:39 +0000 | [diff] [blame] | 922 | if (!m_grid.size()) |
mmaxfield@apple.com | 5f90774 | 2015-03-11 18:22:06 +0000 | [diff] [blame] | 923 | return Optional<int>(); |
mitz@apple.com | 57a2f48 | 2008-08-23 07:16:41 +0000 | [diff] [blame] | 924 | |
eae@chromium.org | 82b9498 | 2012-10-22 18:38:29 +0000 | [diff] [blame] | 925 | int firstLineBaseline = m_grid[0].baseline; |
mitz@apple.com | 57a2f48 | 2008-08-23 07:16:41 +0000 | [diff] [blame] | 926 | if (firstLineBaseline) |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 927 | return firstLineBaseline + roundToInt(m_rowPos[0]); |
mitz@apple.com | 57a2f48 | 2008-08-23 07:16:41 +0000 | [diff] [blame] | 928 | |
mmaxfield@apple.com | 5f90774 | 2015-03-11 18:22:06 +0000 | [diff] [blame] | 929 | Optional<int> result; |
jchaffraix@webkit.org | 9fb8075 | 2011-10-28 18:04:14 +0000 | [diff] [blame] | 930 | const Row& firstRow = m_grid[0].row; |
| 931 | for (size_t i = 0; i < firstRow.size(); ++i) { |
| 932 | const CellStruct& cs = firstRow.at(i); |
| 933 | const RenderTableCell* cell = cs.primaryCell(); |
robert@webkit.org | 3b67b1f | 2012-05-16 21:06:10 +0000 | [diff] [blame] | 934 | // Only cells with content have a baseline |
mmaxfield@apple.com | 5f90774 | 2015-03-11 18:22:06 +0000 | [diff] [blame] | 935 | if (cell && cell->contentLogicalHeight()) { |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 936 | int candidate = roundToInt(cell->logicalTop() + cell->borderAndPaddingBefore() + cell->contentLogicalHeight()); |
mmaxfield@apple.com | 5f90774 | 2015-03-11 18:22:06 +0000 | [diff] [blame] | 937 | result = std::max(result.valueOr(candidate), candidate); |
| 938 | } |
mitz@apple.com | 57a2f48 | 2008-08-23 07:16:41 +0000 | [diff] [blame] | 939 | } |
| 940 | |
mmaxfield@apple.com | 5f90774 | 2015-03-11 18:22:06 +0000 | [diff] [blame] | 941 | return result; |
mitz@apple.com | 57a2f48 | 2008-08-23 07:16:41 +0000 | [diff] [blame] | 942 | } |
darin | 3201110 | 2006-05-15 04:42:09 +0000 | [diff] [blame] | 943 | |
leviw@chromium.org | b375750 | 2011-06-29 21:33:11 +0000 | [diff] [blame] | 944 | void RenderTableSection::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 945 | { |
zalan@apple.com | 5097b11 | 2016-10-06 21:40:38 +0000 | [diff] [blame] | 946 | ASSERT(!needsLayout()); |
inferno@chromium.org | 64a831b | 2012-08-03 19:47:08 +0000 | [diff] [blame] | 947 | // avoid crashing on bugs that cause us to paint with dirty layout |
eric@webkit.org | 5d226dc | 2012-08-02 21:06:06 +0000 | [diff] [blame] | 948 | if (needsLayout()) |
| 949 | return; |
inferno@chromium.org | 64a831b | 2012-08-03 19:47:08 +0000 | [diff] [blame] | 950 | |
jchaffraix@webkit.org | 68d3b57 | 2011-10-27 19:12:39 +0000 | [diff] [blame] | 951 | unsigned totalRows = m_grid.size(); |
ddkilzer | 260f3d2 | 2007-01-05 05:56:31 +0000 | [diff] [blame] | 952 | unsigned totalCols = table()->columns().size(); |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 953 | |
ddkilzer | 260f3d2 | 2007-01-05 05:56:31 +0000 | [diff] [blame] | 954 | if (!totalRows || !totalCols) |
ap | 0e708ba | 2006-05-20 08:47:37 +0000 | [diff] [blame] | 955 | return; |
| 956 | |
leviw@chromium.org | b375750 | 2011-06-29 21:33:11 +0000 | [diff] [blame] | 957 | LayoutPoint adjustedPaintOffset = paintOffset + location(); |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 958 | |
hyatt@apple.com | fe52f5b | 2009-02-25 01:21:03 +0000 | [diff] [blame] | 959 | PaintPhase phase = paintInfo.phase; |
leviw@chromium.org | 61ca137 | 2011-06-07 18:56:41 +0000 | [diff] [blame] | 960 | bool pushedClip = pushContentsClip(paintInfo, adjustedPaintOffset); |
| 961 | paintObject(paintInfo, adjustedPaintOffset); |
hyatt@apple.com | fe52f5b | 2009-02-25 01:21:03 +0000 | [diff] [blame] | 962 | if (pushedClip) |
leviw@chromium.org | 61ca137 | 2011-06-07 18:56:41 +0000 | [diff] [blame] | 963 | popContentsClip(paintInfo, phase, adjustedPaintOffset); |
robert@webkit.org | 87e8d0c | 2012-01-14 19:13:35 +0000 | [diff] [blame] | 964 | |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 965 | if ((phase == PaintPhaseOutline || phase == PaintPhaseSelfOutline) && style().visibility() == VISIBLE) |
wangxianzhu@chromium.org | 64f3829 | 2013-02-28 20:38:23 +0000 | [diff] [blame] | 966 | paintOutline(paintInfo, LayoutRect(adjustedPaintOffset, size())); |
hyatt@apple.com | fe52f5b | 2009-02-25 01:21:03 +0000 | [diff] [blame] | 967 | } |
| 968 | |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 969 | static inline bool compareCellPositions(RenderTableCell* elem1, RenderTableCell* elem2) |
| 970 | { |
jchaffraix@webkit.org | a0177fd | 2012-05-01 03:13:06 +0000 | [diff] [blame] | 971 | return elem1->rowIndex() < elem2->rowIndex(); |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 972 | } |
| 973 | |
jchaffraix@webkit.org | f4ce050 | 2011-08-18 20:20:57 +0000 | [diff] [blame] | 974 | // This comparison is used only when we have overflowing cells as we have an unsorted array to sort. We thus need |
| 975 | // to sort both on rows and columns to properly repaint. |
| 976 | static inline bool compareCellPositionsWithOverflowingCells(RenderTableCell* elem1, RenderTableCell* elem2) |
| 977 | { |
jchaffraix@webkit.org | a0177fd | 2012-05-01 03:13:06 +0000 | [diff] [blame] | 978 | if (elem1->rowIndex() != elem2->rowIndex()) |
| 979 | return elem1->rowIndex() < elem2->rowIndex(); |
jchaffraix@webkit.org | f4ce050 | 2011-08-18 20:20:57 +0000 | [diff] [blame] | 980 | |
| 981 | return elem1->col() < elem2->col(); |
| 982 | } |
| 983 | |
leviw@chromium.org | 890e9b0 | 2011-07-07 23:17:55 +0000 | [diff] [blame] | 984 | void RenderTableSection::paintCell(RenderTableCell* cell, PaintInfo& paintInfo, const LayoutPoint& paintOffset) |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 985 | { |
ojan@chromium.org | 035c88ca | 2011-10-03 22:00:25 +0000 | [diff] [blame] | 986 | LayoutPoint cellPoint = flipForWritingModeForChild(cell, paintOffset); |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 987 | PaintPhase paintPhase = paintInfo.phase; |
cdumez@apple.com | 8faf772 | 2014-10-13 18:21:11 +0000 | [diff] [blame] | 988 | RenderTableRow& row = downcast<RenderTableRow>(*cell->parent()); |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 989 | |
| 990 | if (paintPhase == PaintPhaseBlockBackground || paintPhase == PaintPhaseChildBlockBackground) { |
| 991 | // We need to handle painting a stack of backgrounds. This stack (from bottom to top) consists of |
| 992 | // the column group, column, row group, row, and then the cell. |
jchaffraix@webkit.org | 1ddd9fa | 2012-05-31 16:00:20 +0000 | [diff] [blame] | 993 | RenderTableCol* column = table()->colElement(cell->col()); |
cdumez@apple.com | 8faf772 | 2014-10-13 18:21:11 +0000 | [diff] [blame] | 994 | RenderTableCol* columnGroup = column ? column->enclosingColumnGroup() : nullptr; |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 995 | |
| 996 | // Column groups and columns first. |
| 997 | // FIXME: Columns and column groups do not currently support opacity, and they are being painted "too late" in |
| 998 | // the stack, since we have already opened a transparency layer (potentially) for the table row group. |
| 999 | // Note that we deliberately ignore whether or not the cell has a layer, since these backgrounds paint "behind" the |
| 1000 | // cell. |
jchaffraix@webkit.org | 1ddd9fa | 2012-05-31 16:00:20 +0000 | [diff] [blame] | 1001 | cell->paintBackgroundsBehindCell(paintInfo, cellPoint, columnGroup); |
| 1002 | cell->paintBackgroundsBehindCell(paintInfo, cellPoint, column); |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 1003 | |
| 1004 | // Paint the row group next. |
leviw@chromium.org | 719a45b | 2011-06-03 20:59:40 +0000 | [diff] [blame] | 1005 | cell->paintBackgroundsBehindCell(paintInfo, cellPoint, this); |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 1006 | |
| 1007 | // Paint the row next, but only if it doesn't have a layer. If a row has a layer, it will be responsible for |
| 1008 | // painting the row background for the cell. |
cdumez@apple.com | 8faf772 | 2014-10-13 18:21:11 +0000 | [diff] [blame] | 1009 | if (!row.hasSelfPaintingLayer()) |
| 1010 | cell->paintBackgroundsBehindCell(paintInfo, cellPoint, &row); |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 1011 | } |
cdumez@apple.com | 8faf772 | 2014-10-13 18:21:11 +0000 | [diff] [blame] | 1012 | if ((!cell->hasSelfPaintingLayer() && !row.hasSelfPaintingLayer())) |
leviw@chromium.org | 61ca137 | 2011-06-07 18:56:41 +0000 | [diff] [blame] | 1013 | cell->paint(paintInfo, cellPoint); |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 1014 | } |
| 1015 | |
commit-queue@webkit.org | be3795c | 2012-06-11 09:38:48 +0000 | [diff] [blame] | 1016 | LayoutRect RenderTableSection::logicalRectForWritingModeAndDirection(const LayoutRect& rect) const |
| 1017 | { |
| 1018 | LayoutRect tableAlignedRect(rect); |
| 1019 | |
| 1020 | flipForWritingMode(tableAlignedRect); |
| 1021 | |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1022 | if (!style().isHorizontalWritingMode()) |
commit-queue@webkit.org | be3795c | 2012-06-11 09:38:48 +0000 | [diff] [blame] | 1023 | tableAlignedRect = tableAlignedRect.transposedRect(); |
| 1024 | |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 1025 | const Vector<LayoutUnit>& columnPos = table()->columnPositions(); |
jchaffraix@webkit.org | 6d6c305 | 2012-11-05 07:55:28 +0000 | [diff] [blame] | 1026 | // FIXME: The table's direction should determine our row's direction, not the section's (see bug 96691). |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1027 | if (!style().isLeftToRightDirection()) |
commit-queue@webkit.org | be3795c | 2012-06-11 09:38:48 +0000 | [diff] [blame] | 1028 | tableAlignedRect.setX(columnPos[columnPos.size() - 1] - tableAlignedRect.maxX()); |
| 1029 | |
| 1030 | return tableAlignedRect; |
| 1031 | } |
| 1032 | |
jchaffraix@webkit.org | 7e3f5d4 | 2012-02-28 01:05:10 +0000 | [diff] [blame] | 1033 | CellSpan RenderTableSection::dirtiedRows(const LayoutRect& damageRect) const |
| 1034 | { |
| 1035 | if (m_forceSlowPaintPathWithOverflowingCell) |
| 1036 | return fullTableRowSpan(); |
| 1037 | |
mmaxfield@apple.com | f28245e | 2014-05-20 00:45:52 +0000 | [diff] [blame] | 1038 | CellSpan coveredRows = spannedRows(damageRect, IncludeAllIntersectingCells); |
jchaffraix@webkit.org | 7e3f5d4 | 2012-02-28 01:05:10 +0000 | [diff] [blame] | 1039 | |
commit-queue@webkit.org | 9fa1a35 | 2012-06-19 16:07:00 +0000 | [diff] [blame] | 1040 | // To repaint the border we might need to repaint first or last row even if they are not spanned themselves. |
zalan@apple.com | ec6c110a | 2015-02-17 22:41:25 +0000 | [diff] [blame] | 1041 | if (coveredRows.start >= m_rowPos.size() - 1 && m_rowPos[m_rowPos.size() - 1] + table()->outerBorderAfter() >= damageRect.y()) |
| 1042 | --coveredRows.start; |
jchaffraix@webkit.org | 7e3f5d4 | 2012-02-28 01:05:10 +0000 | [diff] [blame] | 1043 | |
zalan@apple.com | ec6c110a | 2015-02-17 22:41:25 +0000 | [diff] [blame] | 1044 | if (!coveredRows.end && m_rowPos[0] - table()->outerBorderBefore() <= damageRect.maxY()) |
| 1045 | ++coveredRows.end; |
jchaffraix@webkit.org | 7e3f5d4 | 2012-02-28 01:05:10 +0000 | [diff] [blame] | 1046 | |
commit-queue@webkit.org | 9fa1a35 | 2012-06-19 16:07:00 +0000 | [diff] [blame] | 1047 | return coveredRows; |
jchaffraix@webkit.org | 7e3f5d4 | 2012-02-28 01:05:10 +0000 | [diff] [blame] | 1048 | } |
| 1049 | |
jchaffraix@webkit.org | 7e3f5d4 | 2012-02-28 01:05:10 +0000 | [diff] [blame] | 1050 | CellSpan RenderTableSection::dirtiedColumns(const LayoutRect& damageRect) const |
| 1051 | { |
| 1052 | if (m_forceSlowPaintPathWithOverflowingCell) |
| 1053 | return fullTableColumnSpan(); |
| 1054 | |
mmaxfield@apple.com | f28245e | 2014-05-20 00:45:52 +0000 | [diff] [blame] | 1055 | CellSpan coveredColumns = spannedColumns(damageRect, IncludeAllIntersectingCells); |
jchaffraix@webkit.org | 7e3f5d4 | 2012-02-28 01:05:10 +0000 | [diff] [blame] | 1056 | |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 1057 | const Vector<LayoutUnit>& columnPos = table()->columnPositions(); |
commit-queue@webkit.org | 9fa1a35 | 2012-06-19 16:07:00 +0000 | [diff] [blame] | 1058 | // To repaint the border we might need to repaint first or last column even if they are not spanned themselves. |
zalan@apple.com | ec6c110a | 2015-02-17 22:41:25 +0000 | [diff] [blame] | 1059 | if (coveredColumns.start >= columnPos.size() - 1 && columnPos[columnPos.size() - 1] + table()->outerBorderEnd() >= damageRect.x()) |
| 1060 | --coveredColumns.start; |
jchaffraix@webkit.org | 7e3f5d4 | 2012-02-28 01:05:10 +0000 | [diff] [blame] | 1061 | |
zalan@apple.com | ec6c110a | 2015-02-17 22:41:25 +0000 | [diff] [blame] | 1062 | if (!coveredColumns.end && columnPos[0] - table()->outerBorderStart() <= damageRect.maxX()) |
| 1063 | ++coveredColumns.end; |
jchaffraix@webkit.org | 7e3f5d4 | 2012-02-28 01:05:10 +0000 | [diff] [blame] | 1064 | |
commit-queue@webkit.org | 9fa1a35 | 2012-06-19 16:07:00 +0000 | [diff] [blame] | 1065 | return coveredColumns; |
jchaffraix@webkit.org | 7e3f5d4 | 2012-02-28 01:05:10 +0000 | [diff] [blame] | 1066 | } |
| 1067 | |
mmaxfield@apple.com | f28245e | 2014-05-20 00:45:52 +0000 | [diff] [blame] | 1068 | CellSpan RenderTableSection::spannedRows(const LayoutRect& flippedRect, ShouldIncludeAllIntersectingCells shouldIncludeAllIntersectionCells) const |
commit-queue@webkit.org | be3795c | 2012-06-11 09:38:48 +0000 | [diff] [blame] | 1069 | { |
| 1070 | // Find the first row that starts after rect top. |
commit-queue@webkit.org | be3795c | 2012-06-11 09:38:48 +0000 | [diff] [blame] | 1071 | unsigned nextRow = std::upper_bound(m_rowPos.begin(), m_rowPos.end(), flippedRect.y()) - m_rowPos.begin(); |
mmaxfield@apple.com | f28245e | 2014-05-20 00:45:52 +0000 | [diff] [blame] | 1072 | if (shouldIncludeAllIntersectionCells == IncludeAllIntersectingCells && nextRow && m_rowPos[nextRow - 1] == flippedRect.y()) |
| 1073 | --nextRow; |
commit-queue@webkit.org | be3795c | 2012-06-11 09:38:48 +0000 | [diff] [blame] | 1074 | |
| 1075 | if (nextRow == m_rowPos.size()) |
| 1076 | return CellSpan(m_rowPos.size() - 1, m_rowPos.size() - 1); // After all rows. |
| 1077 | |
| 1078 | unsigned startRow = nextRow > 0 ? nextRow - 1 : 0; |
| 1079 | |
| 1080 | // Find the first row that starts after rect bottom. |
| 1081 | unsigned endRow; |
| 1082 | if (m_rowPos[nextRow] >= flippedRect.maxY()) |
| 1083 | endRow = nextRow; |
| 1084 | else { |
andersca@apple.com | 1612395 | 2014-12-06 21:04:35 +0000 | [diff] [blame] | 1085 | endRow = std::upper_bound(m_rowPos.begin() + static_cast<int32_t>(nextRow), m_rowPos.end(), flippedRect.maxY()) - m_rowPos.begin(); |
commit-queue@webkit.org | be3795c | 2012-06-11 09:38:48 +0000 | [diff] [blame] | 1086 | if (endRow == m_rowPos.size()) |
| 1087 | endRow = m_rowPos.size() - 1; |
| 1088 | } |
| 1089 | |
| 1090 | return CellSpan(startRow, endRow); |
| 1091 | } |
| 1092 | |
mmaxfield@apple.com | f28245e | 2014-05-20 00:45:52 +0000 | [diff] [blame] | 1093 | CellSpan RenderTableSection::spannedColumns(const LayoutRect& flippedRect, ShouldIncludeAllIntersectingCells shouldIncludeAllIntersectionCells) const |
commit-queue@webkit.org | be3795c | 2012-06-11 09:38:48 +0000 | [diff] [blame] | 1094 | { |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 1095 | const Vector<LayoutUnit>& columnPos = table()->columnPositions(); |
commit-queue@webkit.org | be3795c | 2012-06-11 09:38:48 +0000 | [diff] [blame] | 1096 | |
commit-queue@webkit.org | 01f6141 | 2012-08-15 18:01:05 +0000 | [diff] [blame] | 1097 | // Find the first column that starts after rect left. |
| 1098 | // lower_bound doesn't handle the edge between two cells properly as it would wrongly return the |
| 1099 | // cell on the logical top/left. |
| 1100 | // upper_bound on the other hand properly returns the cell on the logical bottom/right, which also |
| 1101 | // matches the behavior of other browsers. |
| 1102 | unsigned nextColumn = std::upper_bound(columnPos.begin(), columnPos.end(), flippedRect.x()) - columnPos.begin(); |
mmaxfield@apple.com | f28245e | 2014-05-20 00:45:52 +0000 | [diff] [blame] | 1103 | if (shouldIncludeAllIntersectionCells == IncludeAllIntersectingCells && nextColumn && columnPos[nextColumn - 1] == flippedRect.x()) |
| 1104 | --nextColumn; |
commit-queue@webkit.org | be3795c | 2012-06-11 09:38:48 +0000 | [diff] [blame] | 1105 | |
| 1106 | if (nextColumn == columnPos.size()) |
| 1107 | return CellSpan(columnPos.size() - 1, columnPos.size() - 1); // After all columns. |
| 1108 | |
| 1109 | unsigned startColumn = nextColumn > 0 ? nextColumn - 1 : 0; |
| 1110 | |
commit-queue@webkit.org | 01f6141 | 2012-08-15 18:01:05 +0000 | [diff] [blame] | 1111 | // Find the first column that starts after rect right. |
commit-queue@webkit.org | be3795c | 2012-06-11 09:38:48 +0000 | [diff] [blame] | 1112 | unsigned endColumn; |
| 1113 | if (columnPos[nextColumn] >= flippedRect.maxX()) |
| 1114 | endColumn = nextColumn; |
| 1115 | else { |
andersca@apple.com | 1612395 | 2014-12-06 21:04:35 +0000 | [diff] [blame] | 1116 | endColumn = std::upper_bound(columnPos.begin() + static_cast<int32_t>(nextColumn), columnPos.end(), flippedRect.maxX()) - columnPos.begin(); |
commit-queue@webkit.org | be3795c | 2012-06-11 09:38:48 +0000 | [diff] [blame] | 1117 | if (endColumn == columnPos.size()) |
| 1118 | endColumn = columnPos.size() - 1; |
| 1119 | } |
| 1120 | |
| 1121 | return CellSpan(startColumn, endColumn); |
| 1122 | } |
| 1123 | |
robert@webkit.org | 2d9d64b | 2013-10-17 17:44:20 +0000 | [diff] [blame] | 1124 | void RenderTableSection::paintRowGroupBorder(const PaintInfo& paintInfo, bool antialias, LayoutRect rect, BoxSide side, CSSPropertyID borderColor, EBorderStyle borderStyle, EBorderStyle tableBorderStyle) |
| 1125 | { |
| 1126 | if (tableBorderStyle == BHIDDEN) |
| 1127 | return; |
| 1128 | rect.intersect(paintInfo.rect); |
| 1129 | if (rect.isEmpty()) |
| 1130 | return; |
mmaxfield@apple.com | a93d7ef | 2015-08-29 06:15:28 +0000 | [diff] [blame] | 1131 | drawLineForBoxSide(paintInfo.context(), rect, side, style().visitedDependentColor(borderColor), borderStyle, 0, 0, antialias); |
robert@webkit.org | 2d9d64b | 2013-10-17 17:44:20 +0000 | [diff] [blame] | 1132 | } |
| 1133 | |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 1134 | LayoutUnit RenderTableSection::offsetLeftForRowGroupBorder(RenderTableCell* cell, const LayoutRect& rowGroupRect, unsigned row) |
robert@webkit.org | 2d9d64b | 2013-10-17 17:44:20 +0000 | [diff] [blame] | 1135 | { |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1136 | if (style().isHorizontalWritingMode()) { |
| 1137 | if (style().isLeftToRightDirection()) |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 1138 | return cell ? cell->x() + cell->width() : LayoutUnit::fromPixel(0); |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1139 | return -outerBorderLeft(&style()); |
robert@webkit.org | 2d9d64b | 2013-10-17 17:44:20 +0000 | [diff] [blame] | 1140 | } |
| 1141 | bool isLastRow = row + 1 == m_grid.size(); |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 1142 | return rowGroupRect.width() - m_rowPos[row + 1] + (isLastRow ? -outerBorderLeft(&style()) : LayoutUnit::fromPixel(0)); |
robert@webkit.org | 2d9d64b | 2013-10-17 17:44:20 +0000 | [diff] [blame] | 1143 | } |
| 1144 | |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 1145 | LayoutUnit RenderTableSection::offsetTopForRowGroupBorder(RenderTableCell* cell, BoxSide borderSide, unsigned row) |
robert@webkit.org | 2d9d64b | 2013-10-17 17:44:20 +0000 | [diff] [blame] | 1146 | { |
| 1147 | bool isLastRow = row + 1 == m_grid.size(); |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1148 | if (style().isHorizontalWritingMode()) |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 1149 | return m_rowPos[row] + (!row && borderSide == BSRight ? -outerBorderTop(&style()) : isLastRow && borderSide == BSLeft ? outerBorderTop(&style()) : LayoutUnit::fromPixel(0)); |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1150 | if (style().isLeftToRightDirection()) |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 1151 | return (cell ? cell->y() + cell->height() : LayoutUnit::fromPixel(0)) + (borderSide == BSLeft ? outerBorderTop(&style()) : LayoutUnit::fromPixel(0)); |
| 1152 | return borderSide == BSRight ? -outerBorderTop(&style()) : LayoutUnit::fromPixel(0); |
robert@webkit.org | 2d9d64b | 2013-10-17 17:44:20 +0000 | [diff] [blame] | 1153 | } |
| 1154 | |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 1155 | LayoutUnit RenderTableSection::verticalRowGroupBorderHeight(RenderTableCell* cell, const LayoutRect& rowGroupRect, unsigned row) |
robert@webkit.org | 2d9d64b | 2013-10-17 17:44:20 +0000 | [diff] [blame] | 1156 | { |
| 1157 | bool isLastRow = row + 1 == m_grid.size(); |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1158 | if (style().isHorizontalWritingMode()) |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 1159 | return m_rowPos[row + 1] - m_rowPos[row] + (!row ? outerBorderTop(&style()) : isLastRow ? outerBorderBottom(&style()) : LayoutUnit::fromPixel(0)); |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1160 | if (style().isLeftToRightDirection()) |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 1161 | return rowGroupRect.height() - (cell ? cell->y() + cell->height() : LayoutUnit::fromPixel(0)) + outerBorderBottom(&style()); |
| 1162 | return cell ? rowGroupRect.height() - (cell->y() - cell->height()) : LayoutUnit::fromPixel(0); |
robert@webkit.org | 2d9d64b | 2013-10-17 17:44:20 +0000 | [diff] [blame] | 1163 | } |
| 1164 | |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 1165 | LayoutUnit RenderTableSection::horizontalRowGroupBorderWidth(RenderTableCell* cell, const LayoutRect& rowGroupRect, unsigned row, unsigned column) |
robert@webkit.org | 2d9d64b | 2013-10-17 17:44:20 +0000 | [diff] [blame] | 1166 | { |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1167 | if (style().isHorizontalWritingMode()) { |
| 1168 | if (style().isLeftToRightDirection()) |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 1169 | return rowGroupRect.width() - (cell ? cell->x() + cell->width() : LayoutUnit::fromPixel(0)) + (!column ? outerBorderLeft(&style()) : column == table()->numEffCols() ? outerBorderRight(&style()) : LayoutUnit::fromPixel(0)); |
| 1170 | return cell ? rowGroupRect.width() - (cell->x() - cell->width()) : LayoutUnit::fromPixel(0); |
robert@webkit.org | 2d9d64b | 2013-10-17 17:44:20 +0000 | [diff] [blame] | 1171 | } |
| 1172 | bool isLastRow = row + 1 == m_grid.size(); |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 1173 | return m_rowPos[row + 1] - m_rowPos[row] + (isLastRow ? outerBorderLeft(&style()) : !row ? outerBorderRight(&style()) : LayoutUnit::fromPixel(0)); |
robert@webkit.org | 2d9d64b | 2013-10-17 17:44:20 +0000 | [diff] [blame] | 1174 | } |
| 1175 | |
| 1176 | void RenderTableSection::paintRowGroupBorderIfRequired(const PaintInfo& paintInfo, const LayoutPoint& paintOffset, unsigned row, unsigned column, BoxSide borderSide, RenderTableCell* cell) |
| 1177 | { |
| 1178 | if (table()->currentBorderValue()->precedence() > BROWGROUP) |
| 1179 | return; |
mmaxfield@apple.com | a93d7ef | 2015-08-29 06:15:28 +0000 | [diff] [blame] | 1180 | if (paintInfo.context().paintingDisabled()) |
robert@webkit.org | 2d9d64b | 2013-10-17 17:44:20 +0000 | [diff] [blame] | 1181 | return; |
| 1182 | |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1183 | const RenderStyle& style = this->style(); |
mmaxfield@apple.com | a93d7ef | 2015-08-29 06:15:28 +0000 | [diff] [blame] | 1184 | bool antialias = shouldAntialiasLines(paintInfo.context()); |
robert@webkit.org | 2d9d64b | 2013-10-17 17:44:20 +0000 | [diff] [blame] | 1185 | LayoutRect rowGroupRect = LayoutRect(paintOffset, size()); |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 1186 | rowGroupRect.moveBy(-LayoutPoint(outerBorderLeft(&style), (borderSide == BSRight) ? LayoutUnit::fromPixel(0) : outerBorderTop(&style))); |
robert@webkit.org | 2d9d64b | 2013-10-17 17:44:20 +0000 | [diff] [blame] | 1187 | |
| 1188 | switch (borderSide) { |
| 1189 | case BSTop: |
| 1190 | paintRowGroupBorder(paintInfo, antialias, LayoutRect(paintOffset.x() + offsetLeftForRowGroupBorder(cell, rowGroupRect, row), rowGroupRect.y(), |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1191 | horizontalRowGroupBorderWidth(cell, rowGroupRect, row, column), style.borderTop().width()), BSTop, CSSPropertyBorderTopColor, style.borderTopStyle(), table()->style().borderTopStyle()); |
robert@webkit.org | 2d9d64b | 2013-10-17 17:44:20 +0000 | [diff] [blame] | 1192 | break; |
| 1193 | case BSBottom: |
| 1194 | paintRowGroupBorder(paintInfo, antialias, LayoutRect(paintOffset.x() + offsetLeftForRowGroupBorder(cell, rowGroupRect, row), rowGroupRect.y() + rowGroupRect.height(), |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1195 | horizontalRowGroupBorderWidth(cell, rowGroupRect, row, column), style.borderBottom().width()), BSBottom, CSSPropertyBorderBottomColor, style.borderBottomStyle(), table()->style().borderBottomStyle()); |
robert@webkit.org | 2d9d64b | 2013-10-17 17:44:20 +0000 | [diff] [blame] | 1196 | break; |
| 1197 | case BSLeft: |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1198 | paintRowGroupBorder(paintInfo, antialias, LayoutRect(rowGroupRect.x(), rowGroupRect.y() + offsetTopForRowGroupBorder(cell, borderSide, row), style.borderLeft().width(), |
| 1199 | verticalRowGroupBorderHeight(cell, rowGroupRect, row)), BSLeft, CSSPropertyBorderLeftColor, style.borderLeftStyle(), table()->style().borderLeftStyle()); |
robert@webkit.org | 2d9d64b | 2013-10-17 17:44:20 +0000 | [diff] [blame] | 1200 | break; |
| 1201 | case BSRight: |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1202 | paintRowGroupBorder(paintInfo, antialias, LayoutRect(rowGroupRect.x() + rowGroupRect.width(), rowGroupRect.y() + offsetTopForRowGroupBorder(cell, borderSide, row), style.borderRight().width(), |
| 1203 | verticalRowGroupBorderHeight(cell, rowGroupRect, row)), BSRight, CSSPropertyBorderRightColor, style.borderRightStyle(), table()->style().borderRightStyle()); |
robert@webkit.org | 2d9d64b | 2013-10-17 17:44:20 +0000 | [diff] [blame] | 1204 | break; |
| 1205 | default: |
| 1206 | break; |
| 1207 | } |
| 1208 | |
| 1209 | } |
| 1210 | |
antti@apple.com | 5c4302b | 2016-04-26 18:20:09 +0000 | [diff] [blame] | 1211 | static BoxSide physicalBorderForDirection(const RenderStyle* styleForCellFlow, CollapsedBorderSide side) |
robert@webkit.org | 2d9d64b | 2013-10-17 17:44:20 +0000 | [diff] [blame] | 1212 | { |
| 1213 | |
| 1214 | switch (side) { |
| 1215 | case CBSStart: |
| 1216 | if (styleForCellFlow->isHorizontalWritingMode()) |
| 1217 | return styleForCellFlow->isLeftToRightDirection() ? BSLeft : BSRight; |
| 1218 | return styleForCellFlow->isLeftToRightDirection() ? BSTop : BSBottom; |
| 1219 | case CBSEnd: |
| 1220 | if (styleForCellFlow->isHorizontalWritingMode()) |
| 1221 | return styleForCellFlow->isLeftToRightDirection() ? BSRight : BSLeft; |
| 1222 | return styleForCellFlow->isLeftToRightDirection() ? BSBottom : BSTop; |
| 1223 | case CBSBefore: |
| 1224 | if (styleForCellFlow->isHorizontalWritingMode()) |
| 1225 | return BSTop; |
| 1226 | return styleForCellFlow->isLeftToRightDirection() ? BSRight : BSLeft; |
| 1227 | case CBSAfter: |
| 1228 | if (styleForCellFlow->isHorizontalWritingMode()) |
| 1229 | return BSBottom; |
| 1230 | return styleForCellFlow->isLeftToRightDirection() ? BSLeft : BSRight; |
| 1231 | default: |
| 1232 | ASSERT_NOT_REACHED(); |
| 1233 | return BSLeft; |
| 1234 | } |
| 1235 | } |
commit-queue@webkit.org | be3795c | 2012-06-11 09:38:48 +0000 | [diff] [blame] | 1236 | |
leviw@chromium.org | c491808 | 2011-06-29 01:06:00 +0000 | [diff] [blame] | 1237 | void RenderTableSection::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffset) |
hyatt@apple.com | fe52f5b | 2009-02-25 01:21:03 +0000 | [diff] [blame] | 1238 | { |
leviw@chromium.org | c491808 | 2011-06-29 01:06:00 +0000 | [diff] [blame] | 1239 | LayoutRect localRepaintRect = paintInfo.rect; |
leviw@chromium.org | 43d0c4d | 2011-06-04 02:25:54 +0000 | [diff] [blame] | 1240 | localRepaintRect.moveBy(-paintOffset); |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 1241 | |
commit-queue@webkit.org | 9fa1a35 | 2012-06-19 16:07:00 +0000 | [diff] [blame] | 1242 | LayoutRect tableAlignedRect = logicalRectForWritingModeAndDirection(localRepaintRect); |
| 1243 | |
| 1244 | CellSpan dirtiedRows = this->dirtiedRows(tableAlignedRect); |
| 1245 | CellSpan dirtiedColumns = this->dirtiedColumns(tableAlignedRect); |
jamesr@google.com | f88b258 | 2010-08-17 20:57:15 +0000 | [diff] [blame] | 1246 | |
zalan@apple.com | ec6c110a | 2015-02-17 22:41:25 +0000 | [diff] [blame] | 1247 | if (dirtiedColumns.start < dirtiedColumns.end) { |
jchaffraix@webkit.org | f4ce050 | 2011-08-18 20:20:57 +0000 | [diff] [blame] | 1248 | if (!m_hasMultipleCellLevels && !m_overflowingCells.size()) { |
robert@webkit.org | 2d40827 | 2011-12-19 19:49:27 +0000 | [diff] [blame] | 1249 | if (paintInfo.phase == PaintPhaseCollapsedTableBorders) { |
| 1250 | // Collapsed borders are painted from the bottom right to the top left so that precedence |
robert@webkit.org | c75e767 | 2013-06-11 18:11:31 +0000 | [diff] [blame] | 1251 | // due to cell position is respected. We need to paint one row beyond the topmost dirtied |
| 1252 | // row to calculate its collapsed border value. |
zalan@apple.com | ec6c110a | 2015-02-17 22:41:25 +0000 | [diff] [blame] | 1253 | unsigned startRow = dirtiedRows.start ? dirtiedRows.start - 1 : 0; |
| 1254 | for (unsigned r = dirtiedRows.end; r > startRow; r--) { |
robert@webkit.org | 2d40827 | 2011-12-19 19:49:27 +0000 | [diff] [blame] | 1255 | unsigned row = r - 1; |
robert@webkit.org | 2d9d64b | 2013-10-17 17:44:20 +0000 | [diff] [blame] | 1256 | bool shouldPaintRowGroupBorder = false; |
zalan@apple.com | ec6c110a | 2015-02-17 22:41:25 +0000 | [diff] [blame] | 1257 | for (unsigned c = dirtiedColumns.end; c > dirtiedColumns.start; c--) { |
robert@webkit.org | 2d40827 | 2011-12-19 19:49:27 +0000 | [diff] [blame] | 1258 | unsigned col = c - 1; |
| 1259 | CellStruct& current = cellAt(row, col); |
| 1260 | RenderTableCell* cell = current.primaryCell(); |
robert@webkit.org | 2d9d64b | 2013-10-17 17:44:20 +0000 | [diff] [blame] | 1261 | if (!cell) { |
| 1262 | if (!c) |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1263 | paintRowGroupBorderIfRequired(paintInfo, paintOffset, row, col, physicalBorderForDirection(&style(), CBSStart)); |
robert@webkit.org | 2d9d64b | 2013-10-17 17:44:20 +0000 | [diff] [blame] | 1264 | else if (c == table()->numEffCols()) |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1265 | paintRowGroupBorderIfRequired(paintInfo, paintOffset, row, col, physicalBorderForDirection(&style(), CBSEnd)); |
robert@webkit.org | 2d9d64b | 2013-10-17 17:44:20 +0000 | [diff] [blame] | 1266 | shouldPaintRowGroupBorder = true; |
robert@webkit.org | 2d40827 | 2011-12-19 19:49:27 +0000 | [diff] [blame] | 1267 | continue; |
robert@webkit.org | 2d9d64b | 2013-10-17 17:44:20 +0000 | [diff] [blame] | 1268 | } |
zalan@apple.com | ec6c110a | 2015-02-17 22:41:25 +0000 | [diff] [blame] | 1269 | if ((row > dirtiedRows.start && primaryCellAt(row - 1, col) == cell) || (col > dirtiedColumns.start && primaryCellAt(row, col - 1) == cell)) |
robert@webkit.org | 2d9d64b | 2013-10-17 17:44:20 +0000 | [diff] [blame] | 1270 | continue; |
| 1271 | |
| 1272 | // If we had a run of null cells paint their corresponding section of the row group's border if necessary. Note that |
| 1273 | // this will only happen once within a row as the null cells will always be clustered together on one end of the row. |
| 1274 | if (shouldPaintRowGroupBorder) { |
| 1275 | if (r == m_grid.size()) |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1276 | paintRowGroupBorderIfRequired(paintInfo, paintOffset, row, col, physicalBorderForDirection(&style(), CBSAfter), cell); |
robert@webkit.org | 2d9d64b | 2013-10-17 17:44:20 +0000 | [diff] [blame] | 1277 | else if (!row && !table()->sectionAbove(this)) |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1278 | paintRowGroupBorderIfRequired(paintInfo, paintOffset, row, col, physicalBorderForDirection(&style(), CBSBefore), cell); |
robert@webkit.org | 2d9d64b | 2013-10-17 17:44:20 +0000 | [diff] [blame] | 1279 | shouldPaintRowGroupBorder = false; |
| 1280 | } |
| 1281 | |
robert@webkit.org | 2d40827 | 2011-12-19 19:49:27 +0000 | [diff] [blame] | 1282 | LayoutPoint cellPoint = flipForWritingModeForChild(cell, paintOffset); |
| 1283 | cell->paintCollapsedBorders(paintInfo, cellPoint); |
| 1284 | } |
| 1285 | } |
| 1286 | } else { |
| 1287 | // Draw the dirty cells in the order that they appear. |
zalan@apple.com | ec6c110a | 2015-02-17 22:41:25 +0000 | [diff] [blame] | 1288 | for (unsigned r = dirtiedRows.start; r < dirtiedRows.end; r++) { |
robert@webkit.org | 87e8d0c | 2012-01-14 19:13:35 +0000 | [diff] [blame] | 1289 | RenderTableRow* row = m_grid[r].rowRenderer; |
| 1290 | if (row && !row->hasSelfPaintingLayer()) |
| 1291 | row->paintOutlineForRowIfNeeded(paintInfo, paintOffset); |
zalan@apple.com | ec6c110a | 2015-02-17 22:41:25 +0000 | [diff] [blame] | 1292 | for (unsigned c = dirtiedColumns.start; c < dirtiedColumns.end; c++) { |
robert@webkit.org | 2d40827 | 2011-12-19 19:49:27 +0000 | [diff] [blame] | 1293 | CellStruct& current = cellAt(r, c); |
| 1294 | RenderTableCell* cell = current.primaryCell(); |
zalan@apple.com | ec6c110a | 2015-02-17 22:41:25 +0000 | [diff] [blame] | 1295 | if (!cell || (r > dirtiedRows.start && primaryCellAt(r - 1, c) == cell) || (c > dirtiedColumns.start && primaryCellAt(r, c - 1) == cell)) |
robert@webkit.org | 2d40827 | 2011-12-19 19:49:27 +0000 | [diff] [blame] | 1296 | continue; |
| 1297 | paintCell(cell, paintInfo, paintOffset); |
| 1298 | } |
hyatt | e031dd0 | 2006-03-18 01:01:06 +0000 | [diff] [blame] | 1299 | } |
ap | 50b5835 | 2006-01-22 20:32:36 +0000 | [diff] [blame] | 1300 | } |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 1301 | } else { |
jchaffraix@webkit.org | f4ce050 | 2011-08-18 20:20:57 +0000 | [diff] [blame] | 1302 | // The overflowing cells should be scarce to avoid adding a lot of cells to the HashSet. |
jchaffraix@webkit.org | 7e3f5d4 | 2012-02-28 01:05:10 +0000 | [diff] [blame] | 1303 | #ifndef NDEBUG |
| 1304 | unsigned totalRows = m_grid.size(); |
| 1305 | unsigned totalCols = table()->columns().size(); |
jchaffraix@webkit.org | f4ce050 | 2011-08-18 20:20:57 +0000 | [diff] [blame] | 1306 | ASSERT(m_overflowingCells.size() < totalRows * totalCols * gMaxAllowedOverflowingCellRatioForFastPaintPath); |
jchaffraix@webkit.org | 7e3f5d4 | 2012-02-28 01:05:10 +0000 | [diff] [blame] | 1307 | #endif |
jchaffraix@webkit.org | f4ce050 | 2011-08-18 20:20:57 +0000 | [diff] [blame] | 1308 | |
| 1309 | // To make sure we properly repaint the section, we repaint all the overflowing cells that we collected. |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 1310 | Vector<RenderTableCell*> cells; |
jchaffraix@webkit.org | f4ce050 | 2011-08-18 20:20:57 +0000 | [diff] [blame] | 1311 | copyToVector(m_overflowingCells, cells); |
| 1312 | |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 1313 | HashSet<RenderTableCell*> spanningCells; |
jchaffraix@webkit.org | f4ce050 | 2011-08-18 20:20:57 +0000 | [diff] [blame] | 1314 | |
zalan@apple.com | ec6c110a | 2015-02-17 22:41:25 +0000 | [diff] [blame] | 1315 | for (unsigned r = dirtiedRows.start; r < dirtiedRows.end; r++) { |
robert@webkit.org | 87e8d0c | 2012-01-14 19:13:35 +0000 | [diff] [blame] | 1316 | RenderTableRow* row = m_grid[r].rowRenderer; |
| 1317 | if (row && !row->hasSelfPaintingLayer()) |
| 1318 | row->paintOutlineForRowIfNeeded(paintInfo, paintOffset); |
zalan@apple.com | ec6c110a | 2015-02-17 22:41:25 +0000 | [diff] [blame] | 1319 | for (unsigned c = dirtiedColumns.start; c < dirtiedColumns.end; c++) { |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 1320 | CellStruct& current = cellAt(r, c); |
jamesr@google.com | b426623 | 2010-07-28 20:07:19 +0000 | [diff] [blame] | 1321 | if (!current.hasCells()) |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 1322 | continue; |
| 1323 | for (unsigned i = 0; i < current.cells.size(); ++i) { |
jchaffraix@webkit.org | f4ce050 | 2011-08-18 20:20:57 +0000 | [diff] [blame] | 1324 | if (m_overflowingCells.contains(current.cells[i])) |
| 1325 | continue; |
| 1326 | |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 1327 | if (current.cells[i]->rowSpan() > 1 || current.cells[i]->colSpan() > 1) { |
rafael.lobo@openbossa.org | 61c47ed | 2013-05-31 00:53:31 +0000 | [diff] [blame] | 1328 | if (!spanningCells.add(current.cells[i]).isNewEntry) |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 1329 | continue; |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 1330 | } |
jchaffraix@webkit.org | f4ce050 | 2011-08-18 20:20:57 +0000 | [diff] [blame] | 1331 | |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 1332 | cells.append(current.cells[i]); |
| 1333 | } |
| 1334 | } |
| 1335 | } |
jchaffraix@webkit.org | f4ce050 | 2011-08-18 20:20:57 +0000 | [diff] [blame] | 1336 | |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 1337 | // Sort the dirty cells by paint order. |
jchaffraix@webkit.org | f4ce050 | 2011-08-18 20:20:57 +0000 | [diff] [blame] | 1338 | if (!m_overflowingCells.size()) |
| 1339 | std::stable_sort(cells.begin(), cells.end(), compareCellPositions); |
| 1340 | else |
| 1341 | std::sort(cells.begin(), cells.end(), compareCellPositionsWithOverflowingCells); |
| 1342 | |
robert@webkit.org | 2d40827 | 2011-12-19 19:49:27 +0000 | [diff] [blame] | 1343 | if (paintInfo.phase == PaintPhaseCollapsedTableBorders) { |
| 1344 | for (unsigned i = cells.size(); i > 0; --i) { |
| 1345 | LayoutPoint cellPoint = flipForWritingModeForChild(cells[i - 1], paintOffset); |
| 1346 | cells[i - 1]->paintCollapsedBorders(paintInfo, cellPoint); |
| 1347 | } |
| 1348 | } else { |
| 1349 | for (unsigned i = 0; i < cells.size(); ++i) |
| 1350 | paintCell(cells[i], paintInfo, paintOffset); |
| 1351 | } |
ap | 50b5835 | 2006-01-22 20:32:36 +0000 | [diff] [blame] | 1352 | } |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 1353 | } |
| 1354 | } |
| 1355 | |
darin@apple.com | 98a7ac6 | 2009-01-05 17:26:53 +0000 | [diff] [blame] | 1356 | void RenderTableSection::imageChanged(WrappedImagePtr, const IntRect*) |
bdash | b07ae8d | 2007-02-08 04:56:20 +0000 | [diff] [blame] | 1357 | { |
bdash | b07ae8d | 2007-02-08 04:56:20 +0000 | [diff] [blame] | 1358 | // FIXME: Examine cells and repaint only the rect the image paints in. |
| 1359 | repaint(); |
| 1360 | } |
| 1361 | |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 1362 | void RenderTableSection::recalcCells() |
| 1363 | { |
jchaffraix@webkit.org | b86b64e | 2011-11-14 21:21:43 +0000 | [diff] [blame] | 1364 | ASSERT(m_needsCellRecalc); |
dbates@webkit.org | f04ec0f | 2014-03-18 20:00:47 +0000 | [diff] [blame] | 1365 | // We reset the flag here to ensure that addCell() works. This is safe to do because we clear the grid |
| 1366 | // and update its dimensions to be consistent with the table's column representation before we rebuild |
| 1367 | // the grid using addCell(). |
jchaffraix@webkit.org | b86b64e | 2011-11-14 21:21:43 +0000 | [diff] [blame] | 1368 | m_needsCellRecalc = false; |
| 1369 | |
ddkilzer | 260f3d2 | 2007-01-05 05:56:31 +0000 | [diff] [blame] | 1370 | m_cCol = 0; |
jchaffraix@webkit.org | 369c5d3 | 2011-10-28 01:28:58 +0000 | [diff] [blame] | 1371 | m_cRow = 0; |
jchaffraix@webkit.org | e98e3e5 | 2011-11-11 01:41:26 +0000 | [diff] [blame] | 1372 | m_grid.clear(); |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 1373 | |
antti@apple.com | 7f9196b | 2013-09-24 20:47:01 +0000 | [diff] [blame] | 1374 | for (RenderTableRow* row = firstRow(); row; row = row->nextRow()) { |
| 1375 | unsigned insertionRow = m_cRow; |
| 1376 | m_cRow++; |
| 1377 | m_cCol = 0; |
| 1378 | ensureRows(m_cRow); |
jchaffraix@webkit.org | e98e3e5 | 2011-11-11 01:41:26 +0000 | [diff] [blame] | 1379 | |
antti@apple.com | 7f9196b | 2013-09-24 20:47:01 +0000 | [diff] [blame] | 1380 | m_grid[insertionRow].rowRenderer = row; |
| 1381 | row->setRowIndex(insertionRow); |
| 1382 | setRowLogicalHeightToRowStyleLogicalHeightIfNotRelative(m_grid[insertionRow]); |
eseidel | 05ef043 | 2006-05-25 22:11:36 +0000 | [diff] [blame] | 1383 | |
antti@apple.com | 7f9196b | 2013-09-24 20:47:01 +0000 | [diff] [blame] | 1384 | for (RenderTableCell* cell = row->firstCell(); cell; cell = cell->nextCell()) |
| 1385 | addCell(cell, row); |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 1386 | } |
jchaffraix@webkit.org | 9fb8075 | 2011-10-28 18:04:14 +0000 | [diff] [blame] | 1387 | |
jchaffraix@webkit.org | e98e3e5 | 2011-11-11 01:41:26 +0000 | [diff] [blame] | 1388 | m_grid.shrinkToFit(); |
antti@apple.com | ca2a8ff | 2013-10-04 04:04:35 +0000 | [diff] [blame] | 1389 | setNeedsLayout(); |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 1390 | } |
| 1391 | |
jchaffraix@webkit.org | 74857b4 | 2011-12-20 14:08:52 +0000 | [diff] [blame] | 1392 | // FIXME: This function could be made O(1) in certain cases (like for the non-most-constrainive cells' case). |
jchaffraix@webkit.org | 19bbb72 | 2011-11-03 17:20:01 +0000 | [diff] [blame] | 1393 | void RenderTableSection::rowLogicalHeightChanged(unsigned rowIndex) |
| 1394 | { |
jchaffraix@webkit.org | dd34df4 | 2012-01-24 04:15:06 +0000 | [diff] [blame] | 1395 | if (needsCellRecalc()) |
| 1396 | return; |
| 1397 | |
jchaffraix@webkit.org | 19bbb72 | 2011-11-03 17:20:01 +0000 | [diff] [blame] | 1398 | setRowLogicalHeightToRowStyleLogicalHeightIfNotRelative(m_grid[rowIndex]); |
jchaffraix@webkit.org | 74857b4 | 2011-12-20 14:08:52 +0000 | [diff] [blame] | 1399 | |
antti@apple.com | 7f9196b | 2013-09-24 20:47:01 +0000 | [diff] [blame] | 1400 | for (RenderTableCell* cell = m_grid[rowIndex].rowRenderer->firstCell(); cell; cell = cell->nextCell()) |
| 1401 | updateLogicalHeightForCell(m_grid[rowIndex], cell); |
jchaffraix@webkit.org | 19bbb72 | 2011-11-03 17:20:01 +0000 | [diff] [blame] | 1402 | } |
| 1403 | |
jamesr@google.com | 5ddfb04 | 2011-01-20 21:34:34 +0000 | [diff] [blame] | 1404 | void RenderTableSection::setNeedsCellRecalc() |
| 1405 | { |
| 1406 | m_needsCellRecalc = true; |
dbates@webkit.org | f04ec0f | 2014-03-18 20:00:47 +0000 | [diff] [blame] | 1407 | |
| 1408 | // Clear the grid now to ensure that we don't hold onto any stale pointers (e.g. a cell renderer that is being removed). |
| 1409 | m_grid.clear(); |
| 1410 | |
jamesr@google.com | 5ddfb04 | 2011-01-20 21:34:34 +0000 | [diff] [blame] | 1411 | if (RenderTable* t = table()) |
| 1412 | t->setNeedsSectionRecalc(); |
| 1413 | } |
| 1414 | |
jchaffraix@webkit.org | 369c5d3 | 2011-10-28 01:28:58 +0000 | [diff] [blame] | 1415 | unsigned RenderTableSection::numColumns() const |
ap | 50b5835 | 2006-01-22 20:32:36 +0000 | [diff] [blame] | 1416 | { |
dbates@webkit.org | f04ec0f | 2014-03-18 20:00:47 +0000 | [diff] [blame] | 1417 | ASSERT(!m_needsCellRecalc); |
jchaffraix@webkit.org | 369c5d3 | 2011-10-28 01:28:58 +0000 | [diff] [blame] | 1418 | unsigned result = 0; |
ap | 50b5835 | 2006-01-22 20:32:36 +0000 | [diff] [blame] | 1419 | |
jchaffraix@webkit.org | 68d3b57 | 2011-10-27 19:12:39 +0000 | [diff] [blame] | 1420 | for (unsigned r = 0; r < m_grid.size(); ++r) { |
jchaffraix@webkit.org | 369c5d3 | 2011-10-28 01:28:58 +0000 | [diff] [blame] | 1421 | for (unsigned c = result; c < table()->numEffCols(); ++c) { |
ap | 50b5835 | 2006-01-22 20:32:36 +0000 | [diff] [blame] | 1422 | const CellStruct& cell = cellAt(r, c); |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 1423 | if (cell.hasCells() || cell.inColSpan) |
ap | 50b5835 | 2006-01-22 20:32:36 +0000 | [diff] [blame] | 1424 | result = c; |
| 1425 | } |
| 1426 | } |
| 1427 | |
| 1428 | return result + 1; |
eseidel | a043f3d | 2006-01-20 19:24:53 +0000 | [diff] [blame] | 1429 | } |
| 1430 | |
zalan@apple.com | 1731e36 | 2016-07-24 01:39:13 +0000 | [diff] [blame] | 1431 | const BorderValue& RenderTableSection::borderAdjoiningStartCell(const RenderTableCell& cell) const |
jchaffraix@webkit.org | ec61404 | 2012-09-20 00:58:58 +0000 | [diff] [blame] | 1432 | { |
zalan@apple.com | 1731e36 | 2016-07-24 01:39:13 +0000 | [diff] [blame] | 1433 | ASSERT(cell.isFirstOrLastCellInRow()); |
zalan@apple.com | b2e5272 | 2016-07-26 02:15:56 +0000 | [diff] [blame] | 1434 | return isDirectionSame(this, &cell) ? style().borderStart() : style().borderEnd(); |
jchaffraix@webkit.org | ec61404 | 2012-09-20 00:58:58 +0000 | [diff] [blame] | 1435 | } |
| 1436 | |
zalan@apple.com | 1731e36 | 2016-07-24 01:39:13 +0000 | [diff] [blame] | 1437 | const BorderValue& RenderTableSection::borderAdjoiningEndCell(const RenderTableCell& cell) const |
jchaffraix@webkit.org | ec61404 | 2012-09-20 00:58:58 +0000 | [diff] [blame] | 1438 | { |
zalan@apple.com | 1731e36 | 2016-07-24 01:39:13 +0000 | [diff] [blame] | 1439 | ASSERT(cell.isFirstOrLastCellInRow()); |
zalan@apple.com | b2e5272 | 2016-07-26 02:15:56 +0000 | [diff] [blame] | 1440 | return isDirectionSame(this, &cell) ? style().borderEnd() : style().borderStart(); |
jchaffraix@webkit.org | ec61404 | 2012-09-20 00:58:58 +0000 | [diff] [blame] | 1441 | } |
| 1442 | |
jchaffraix@webkit.org | ceaacec | 2012-06-01 20:15:01 +0000 | [diff] [blame] | 1443 | const RenderTableCell* RenderTableSection::firstRowCellAdjoiningTableStart() const |
| 1444 | { |
zalan@apple.com | b2e5272 | 2016-07-26 02:15:56 +0000 | [diff] [blame] | 1445 | unsigned adjoiningStartCellColumnIndex = isDirectionSame(this, table()) ? 0 : table()->lastColumnIndex(); |
jchaffraix@webkit.org | 4b5292a | 2012-06-06 16:07:16 +0000 | [diff] [blame] | 1446 | return cellAt(0, adjoiningStartCellColumnIndex).primaryCell(); |
jchaffraix@webkit.org | ceaacec | 2012-06-01 20:15:01 +0000 | [diff] [blame] | 1447 | } |
| 1448 | |
| 1449 | const RenderTableCell* RenderTableSection::firstRowCellAdjoiningTableEnd() const |
| 1450 | { |
zalan@apple.com | b2e5272 | 2016-07-26 02:15:56 +0000 | [diff] [blame] | 1451 | unsigned adjoiningEndCellColumnIndex = isDirectionSame(this, table()) ? table()->lastColumnIndex() : 0; |
jchaffraix@webkit.org | 4b5292a | 2012-06-06 16:07:16 +0000 | [diff] [blame] | 1452 | return cellAt(0, adjoiningEndCellColumnIndex).primaryCell(); |
jchaffraix@webkit.org | ceaacec | 2012-06-01 20:15:01 +0000 | [diff] [blame] | 1453 | } |
| 1454 | |
jchaffraix@webkit.org | fb2a860 | 2011-11-16 02:03:54 +0000 | [diff] [blame] | 1455 | void RenderTableSection::appendColumn(unsigned pos) |
ddkilzer | 260f3d2 | 2007-01-05 05:56:31 +0000 | [diff] [blame] | 1456 | { |
jchaffraix@webkit.org | b86b64e | 2011-11-14 21:21:43 +0000 | [diff] [blame] | 1457 | ASSERT(!m_needsCellRecalc); |
| 1458 | |
jchaffraix@webkit.org | 68d3b57 | 2011-10-27 19:12:39 +0000 | [diff] [blame] | 1459 | for (unsigned row = 0; row < m_grid.size(); ++row) |
jchaffraix@webkit.org | 9fb8075 | 2011-10-28 18:04:14 +0000 | [diff] [blame] | 1460 | m_grid[row].row.resize(pos + 1); |
ddkilzer | 260f3d2 | 2007-01-05 05:56:31 +0000 | [diff] [blame] | 1461 | } |
| 1462 | |
jchaffraix@webkit.org | fb2a860 | 2011-11-16 02:03:54 +0000 | [diff] [blame] | 1463 | void RenderTableSection::splitColumn(unsigned pos, unsigned first) |
ddkilzer | 260f3d2 | 2007-01-05 05:56:31 +0000 | [diff] [blame] | 1464 | { |
inferno@chromium.org | b1ffad7 | 2011-10-10 18:58:12 +0000 | [diff] [blame] | 1465 | ASSERT(!m_needsCellRecalc); |
| 1466 | |
ddkilzer | 260f3d2 | 2007-01-05 05:56:31 +0000 | [diff] [blame] | 1467 | if (m_cCol > pos) |
| 1468 | m_cCol++; |
jchaffraix@webkit.org | 68d3b57 | 2011-10-27 19:12:39 +0000 | [diff] [blame] | 1469 | for (unsigned row = 0; row < m_grid.size(); ++row) { |
jchaffraix@webkit.org | 9fb8075 | 2011-10-28 18:04:14 +0000 | [diff] [blame] | 1470 | Row& r = m_grid[row].row; |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 1471 | r.insert(pos + 1, CellStruct()); |
| 1472 | if (r[pos].hasCells()) { |
andersca@apple.com | 9201299 | 2013-05-05 19:03:49 +0000 | [diff] [blame] | 1473 | r[pos + 1].cells.appendVector(r[pos].cells); |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 1474 | RenderTableCell* cell = r[pos].primaryCell(); |
| 1475 | ASSERT(cell); |
commit-queue@webkit.org | 1ee5b34 | 2012-05-08 05:14:07 +0000 | [diff] [blame] | 1476 | ASSERT(cell->colSpan() >= (r[pos].inColSpan ? 1u : 0)); |
jchaffraix@webkit.org | fb2a860 | 2011-11-16 02:03:54 +0000 | [diff] [blame] | 1477 | unsigned colleft = cell->colSpan() - r[pos].inColSpan; |
jamesr@google.com | 36623a3 | 2010-07-23 20:22:29 +0000 | [diff] [blame] | 1478 | if (first > colleft) |
| 1479 | r[pos + 1].inColSpan = 0; |
| 1480 | else |
| 1481 | r[pos + 1].inColSpan = first + r[pos].inColSpan; |
| 1482 | } else { |
| 1483 | r[pos + 1].inColSpan = 0; |
| 1484 | } |
ddkilzer | 260f3d2 | 2007-01-05 05:56:31 +0000 | [diff] [blame] | 1485 | } |
| 1486 | } |
| 1487 | |
hyatt | d866e59 | 2006-03-17 09:50:35 +0000 | [diff] [blame] | 1488 | // Hit Testing |
allan.jensen@nokia.com | 9a9045b | 2012-08-28 09:41:54 +0000 | [diff] [blame] | 1489 | bool RenderTableSection::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction action) |
hyatt | d866e59 | 2006-03-17 09:50:35 +0000 | [diff] [blame] | 1490 | { |
jamesr@google.com | f88b258 | 2010-08-17 20:57:15 +0000 | [diff] [blame] | 1491 | // If we have no children then we have nothing to do. |
antti@apple.com | 7f9196b | 2013-09-24 20:47:01 +0000 | [diff] [blame] | 1492 | if (!firstRow()) |
jamesr@google.com | f88b258 | 2010-08-17 20:57:15 +0000 | [diff] [blame] | 1493 | return false; |
| 1494 | |
hyatt | d866e59 | 2006-03-17 09:50:35 +0000 | [diff] [blame] | 1495 | // Table sections cannot ever be hit tested. Effectively they do not exist. |
| 1496 | // Just forward to our children always. |
eae@chromium.org | e14cd1a | 2011-07-06 23:38:32 +0000 | [diff] [blame] | 1497 | LayoutPoint adjustedLocation = accumulatedOffset + location(); |
hyatt | d866e59 | 2006-03-17 09:50:35 +0000 | [diff] [blame] | 1498 | |
abucur@adobe.com | 7f9668a | 2014-05-16 13:22:00 +0000 | [diff] [blame] | 1499 | if (hasOverflowClip() && !locationInContainer.intersects(overflowClipRect(adjustedLocation, currentRenderNamedFlowFragment()))) |
hyatt@apple.com | fe52f5b | 2009-02-25 01:21:03 +0000 | [diff] [blame] | 1500 | return false; |
| 1501 | |
jchaffraix@webkit.org | f4ce050 | 2011-08-18 20:20:57 +0000 | [diff] [blame] | 1502 | if (hasOverflowingCell()) { |
antti@apple.com | 7f9196b | 2013-09-24 20:47:01 +0000 | [diff] [blame] | 1503 | for (RenderTableRow* row = lastRow(); row; row = row->previousRow()) { |
jamesr@google.com | f88b258 | 2010-08-17 20:57:15 +0000 | [diff] [blame] | 1504 | // FIXME: We have to skip over inline flows, since they can show up inside table rows |
| 1505 | // at the moment (a demoted inline <form> for example). If we ever implement a |
| 1506 | // table-specific hit-test method (which we should do for performance reasons anyway), |
| 1507 | // then we can remove this check. |
antti@apple.com | d04c081 | 2013-09-25 17:45:59 +0000 | [diff] [blame] | 1508 | if (!row->hasSelfPaintingLayer()) { |
antti@apple.com | 7f9196b | 2013-09-24 20:47:01 +0000 | [diff] [blame] | 1509 | LayoutPoint childPoint = flipForWritingModeForChild(row, adjustedLocation); |
| 1510 | if (row->nodeAtPoint(request, result, locationInContainer, childPoint, action)) { |
allan.jensen@nokia.com | 9a9045b | 2012-08-28 09:41:54 +0000 | [diff] [blame] | 1511 | updateHitTestResult(result, toLayoutPoint(locationInContainer.point() - childPoint)); |
mitz@apple.com | 39fb3ae | 2010-11-09 20:46:15 +0000 | [diff] [blame] | 1512 | return true; |
| 1513 | } |
jamesr@google.com | f88b258 | 2010-08-17 20:57:15 +0000 | [diff] [blame] | 1514 | } |
| 1515 | } |
| 1516 | return false; |
| 1517 | } |
| 1518 | |
inferno@chromium.org | 9c8b230 | 2012-02-21 19:10:05 +0000 | [diff] [blame] | 1519 | recalcCellsIfNeeded(); |
| 1520 | |
allan.jensen@nokia.com | 9a9045b | 2012-08-28 09:41:54 +0000 | [diff] [blame] | 1521 | LayoutRect hitTestRect = locationInContainer.boundingBox(); |
commit-queue@webkit.org | be3795c | 2012-06-11 09:38:48 +0000 | [diff] [blame] | 1522 | hitTestRect.moveBy(-adjustedLocation); |
jamesr@google.com | f88b258 | 2010-08-17 20:57:15 +0000 | [diff] [blame] | 1523 | |
commit-queue@webkit.org | be3795c | 2012-06-11 09:38:48 +0000 | [diff] [blame] | 1524 | LayoutRect tableAlignedRect = logicalRectForWritingModeAndDirection(hitTestRect); |
mmaxfield@apple.com | f28245e | 2014-05-20 00:45:52 +0000 | [diff] [blame] | 1525 | CellSpan rowSpan = spannedRows(tableAlignedRect, DoNotIncludeAllIntersectingCells); |
| 1526 | CellSpan columnSpan = spannedColumns(tableAlignedRect, DoNotIncludeAllIntersectingCells); |
jamesr@google.com | f88b258 | 2010-08-17 20:57:15 +0000 | [diff] [blame] | 1527 | |
commit-queue@webkit.org | be3795c | 2012-06-11 09:38:48 +0000 | [diff] [blame] | 1528 | // Now iterate over the spanned rows and columns. |
zalan@apple.com | ec6c110a | 2015-02-17 22:41:25 +0000 | [diff] [blame] | 1529 | for (unsigned hitRow = rowSpan.start; hitRow < rowSpan.end; ++hitRow) { |
| 1530 | for (unsigned hitColumn = columnSpan.start; hitColumn < columnSpan.end; ++hitColumn) { |
commit-queue@webkit.org | be3795c | 2012-06-11 09:38:48 +0000 | [diff] [blame] | 1531 | CellStruct& current = cellAt(hitRow, hitColumn); |
jamesr@google.com | f88b258 | 2010-08-17 20:57:15 +0000 | [diff] [blame] | 1532 | |
commit-queue@webkit.org | be3795c | 2012-06-11 09:38:48 +0000 | [diff] [blame] | 1533 | // If the cell is empty, there's nothing to do |
| 1534 | if (!current.hasCells()) |
| 1535 | continue; |
jamesr@google.com | f88b258 | 2010-08-17 20:57:15 +0000 | [diff] [blame] | 1536 | |
commit-queue@webkit.org | be3795c | 2012-06-11 09:38:48 +0000 | [diff] [blame] | 1537 | for (unsigned i = current.cells.size() ; i; ) { |
| 1538 | --i; |
| 1539 | RenderTableCell* cell = current.cells[i]; |
| 1540 | LayoutPoint cellPoint = flipForWritingModeForChild(cell, adjustedLocation); |
allan.jensen@nokia.com | 9a9045b | 2012-08-28 09:41:54 +0000 | [diff] [blame] | 1541 | if (static_cast<RenderObject*>(cell)->nodeAtPoint(request, result, locationInContainer, cellPoint, action)) { |
| 1542 | updateHitTestResult(result, locationInContainer.point() - toLayoutSize(cellPoint)); |
commit-queue@webkit.org | be3795c | 2012-06-11 09:38:48 +0000 | [diff] [blame] | 1543 | return true; |
| 1544 | } |
| 1545 | } |
| 1546 | if (!result.isRectBasedTest()) |
| 1547 | break; |
hyatt | d866e59 | 2006-03-17 09:50:35 +0000 | [diff] [blame] | 1548 | } |
commit-queue@webkit.org | be3795c | 2012-06-11 09:38:48 +0000 | [diff] [blame] | 1549 | if (!result.isRectBasedTest()) |
| 1550 | break; |
hyatt | d866e59 | 2006-03-17 09:50:35 +0000 | [diff] [blame] | 1551 | } |
jamesr@google.com | f88b258 | 2010-08-17 20:57:15 +0000 | [diff] [blame] | 1552 | |
commit-queue@webkit.org | be3795c | 2012-06-11 09:38:48 +0000 | [diff] [blame] | 1553 | return false; |
hyatt | d866e59 | 2006-03-17 09:50:35 +0000 | [diff] [blame] | 1554 | } |
| 1555 | |
zalan@apple.com | 4214662 | 2015-04-01 15:56:34 +0000 | [diff] [blame] | 1556 | void RenderTableSection::clearCachedCollapsedBorders() |
| 1557 | { |
| 1558 | if (!table()->collapseBorders()) |
| 1559 | return; |
| 1560 | m_cellsCollapsedBorders.clear(); |
| 1561 | } |
| 1562 | |
| 1563 | void RenderTableSection::removeCachedCollapsedBorders(const RenderTableCell& cell) |
robert@webkit.org | 76a7610 | 2012-01-15 13:48:45 +0000 | [diff] [blame] | 1564 | { |
| 1565 | if (!table()->collapseBorders()) |
| 1566 | return; |
| 1567 | |
| 1568 | for (int side = CBSBefore; side <= CBSEnd; ++side) |
zalan@apple.com | 4214662 | 2015-04-01 15:56:34 +0000 | [diff] [blame] | 1569 | m_cellsCollapsedBorders.remove(std::make_pair(&cell, side)); |
robert@webkit.org | 76a7610 | 2012-01-15 13:48:45 +0000 | [diff] [blame] | 1570 | } |
| 1571 | |
zalan@apple.com | 4214662 | 2015-04-01 15:56:34 +0000 | [diff] [blame] | 1572 | void RenderTableSection::setCachedCollapsedBorder(const RenderTableCell& cell, CollapsedBorderSide side, CollapsedBorderValue border) |
robert@webkit.org | 76a7610 | 2012-01-15 13:48:45 +0000 | [diff] [blame] | 1573 | { |
| 1574 | ASSERT(table()->collapseBorders()); |
zalan@apple.com | 4214662 | 2015-04-01 15:56:34 +0000 | [diff] [blame] | 1575 | ASSERT(border.width()); |
| 1576 | m_cellsCollapsedBorders.set(std::make_pair(&cell, side), border); |
robert@webkit.org | 76a7610 | 2012-01-15 13:48:45 +0000 | [diff] [blame] | 1577 | } |
| 1578 | |
zalan@apple.com | 4214662 | 2015-04-01 15:56:34 +0000 | [diff] [blame] | 1579 | CollapsedBorderValue RenderTableSection::cachedCollapsedBorder(const RenderTableCell& cell, CollapsedBorderSide side) |
robert@webkit.org | 76a7610 | 2012-01-15 13:48:45 +0000 | [diff] [blame] | 1580 | { |
zalan@apple.com | 4214662 | 2015-04-01 15:56:34 +0000 | [diff] [blame] | 1581 | ASSERT(table()->collapseBorders() && table()->collapsedBordersAreValid()); |
| 1582 | auto it = m_cellsCollapsedBorders.find(std::make_pair(&cell, side)); |
| 1583 | // Only non-empty collapsed borders are in the hashmap. |
| 1584 | if (it == m_cellsCollapsedBorders.end()) |
| 1585 | return CollapsedBorderValue(BorderValue(), Color(), BCELL); |
benjamin@webkit.org | ee55405 | 2012-10-07 23:12:07 +0000 | [diff] [blame] | 1586 | return it->value; |
robert@webkit.org | 76a7610 | 2012-01-15 13:48:45 +0000 | [diff] [blame] | 1587 | } |
| 1588 | |
zalan@apple.com | cda46e4 | 2016-07-26 02:40:04 +0000 | [diff] [blame] | 1589 | std::unique_ptr<RenderTableSection> RenderTableSection::createTableSectionWithStyle(Document& document, const RenderStyle& style) |
inferno@chromium.org | 2164c61 | 2012-04-04 22:41:56 +0000 | [diff] [blame] | 1590 | { |
zalan@apple.com | cda46e4 | 2016-07-26 02:40:04 +0000 | [diff] [blame] | 1591 | auto section = std::make_unique<RenderTableSection>(document, RenderStyle::createAnonymousStyleWithDisplay(style, TABLE_ROW_GROUP)); |
akling@apple.com | 8f40c5b | 2013-10-27 22:54:07 +0000 | [diff] [blame] | 1592 | section->initializeStyle(); |
| 1593 | return section; |
inferno@chromium.org | 2164c61 | 2012-04-04 22:41:56 +0000 | [diff] [blame] | 1594 | } |
| 1595 | |
zalan@apple.com | cda46e4 | 2016-07-26 02:40:04 +0000 | [diff] [blame] | 1596 | std::unique_ptr<RenderTableSection> RenderTableSection::createAnonymousWithParentRenderer(const RenderTable& parent) |
| 1597 | { |
| 1598 | return RenderTableSection::createTableSectionWithStyle(parent.document(), parent.style()); |
| 1599 | } |
| 1600 | |
jchaffraix@webkit.org | 4b5292a | 2012-06-06 16:07:16 +0000 | [diff] [blame] | 1601 | void RenderTableSection::setLogicalPositionForCell(RenderTableCell* cell, unsigned effectiveColumn) const |
| 1602 | { |
eae@chromium.org | 1146f21 | 2012-07-18 22:06:34 +0000 | [diff] [blame] | 1603 | LayoutPoint oldCellLocation = cell->location(); |
jchaffraix@webkit.org | 4b5292a | 2012-06-06 16:07:16 +0000 | [diff] [blame] | 1604 | |
| 1605 | LayoutPoint cellLocation(0, m_rowPos[cell->rowIndex()]); |
zalan@apple.com | 5471a8d | 2015-10-27 16:38:10 +0000 | [diff] [blame] | 1606 | LayoutUnit horizontalBorderSpacing = table()->hBorderSpacing(); |
jchaffraix@webkit.org | 4b5292a | 2012-06-06 16:07:16 +0000 | [diff] [blame] | 1607 | |
jchaffraix@webkit.org | 6d6c305 | 2012-11-05 07:55:28 +0000 | [diff] [blame] | 1608 | // FIXME: The table's direction should determine our row's direction, not the section's (see bug 96691). |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1609 | if (!style().isLeftToRightDirection()) |
jchaffraix@webkit.org | 4b5292a | 2012-06-06 16:07:16 +0000 | [diff] [blame] | 1610 | cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - table()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing); |
| 1611 | else |
| 1612 | cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizontalBorderSpacing); |
| 1613 | |
| 1614 | cell->setLogicalLocation(cellLocation); |
akling@apple.com | 691cf5c | 2013-08-24 16:33:15 +0000 | [diff] [blame] | 1615 | view().addLayoutDelta(oldCellLocation - cell->location()); |
jchaffraix@webkit.org | 4b5292a | 2012-06-06 16:07:16 +0000 | [diff] [blame] | 1616 | } |
| 1617 | |
ddkilzer | 260f3d2 | 2007-01-05 05:56:31 +0000 | [diff] [blame] | 1618 | } // namespace WebCore |