OLD | NEW |
1 /** | 1 /* |
2 * Copyright (C) 1997 Martin Jones (mjones@kde.org) | 2 * Copyright (C) 1997 Martin Jones (mjones@kde.org) |
3 * (C) 1997 Torben Weis (weis@kde.org) | 3 * (C) 1997 Torben Weis (weis@kde.org) |
4 * (C) 1998 Waldo Bastian (bastian@kde.org) | 4 * (C) 1998 Waldo Bastian (bastian@kde.org) |
5 * (C) 1999 Lars Knoll (knoll@kde.org) | 5 * (C) 1999 Lars Knoll (knoll@kde.org) |
6 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 6 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All r
ights reserved. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc.
All rights reserved. |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
11 * License as published by the Free Software Foundation; either | 11 * License as published by the Free Software Foundation; either |
12 * version 2 of the License, or (at your option) any later version. | 12 * version 2 of the License, or (at your option) any later version. |
13 * | 13 * |
14 * This library is distributed in the hope that it will be useful, | 14 * This library is distributed in the hope that it will be useful, |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
17 * Library General Public License for more details. | 17 * Library General Public License for more details. |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 ASSERT_UNUSED(cell, cell->isFirstOrLastCellInRow()); | 104 ASSERT_UNUSED(cell, cell->isFirstOrLastCellInRow()); |
105 // FIXME: https://webkit.org/b/79272 - Add support for mixed directionality
at the cell level. | 105 // FIXME: https://webkit.org/b/79272 - Add support for mixed directionality
at the cell level. |
106 return style()->borderEnd(); | 106 return style()->borderEnd(); |
107 } | 107 } |
108 | 108 |
109 void RenderTableRow::addChild(RenderObject* child, RenderObject* beforeChild) | 109 void RenderTableRow::addChild(RenderObject* child, RenderObject* beforeChild) |
110 { | 110 { |
111 if (!child->isTableCell()) { | 111 if (!child->isTableCell()) { |
112 RenderObject* last = beforeChild; | 112 RenderObject* last = beforeChild; |
113 if (!last) | 113 if (!last) |
114 last = lastChild(); | 114 last = lastCell(); |
115 if (last && last->isAnonymous() && last->isTableCell() && !last->isBefor
eOrAfterContent()) { | 115 if (last && last->isAnonymous() && last->isTableCell() && !last->isBefor
eOrAfterContent()) { |
116 RenderTableCell* lastCell = toRenderTableCell(last); | 116 RenderTableCell* lastCell = toRenderTableCell(last); |
117 if (beforeChild == lastCell) | 117 if (beforeChild == lastCell) |
118 beforeChild = lastCell->firstChild(); | 118 beforeChild = lastCell->firstChild(); |
119 lastCell->addChild(child, beforeChild); | 119 lastCell->addChild(child, beforeChild); |
120 return; | 120 return; |
121 } | 121 } |
122 | 122 |
123 if (beforeChild && !beforeChild->isAnonymous() && beforeChild->parent()
== this) { | 123 if (beforeChild && !beforeChild->isAnonymous() && beforeChild->parent()
== this) { |
124 RenderObject* cell = beforeChild->previousSibling(); | 124 RenderObject* cell = beforeChild->previousSibling(); |
(...skipping 20 matching lines...) Expand all Loading... |
145 | 145 |
146 RenderTableCell* cell = toRenderTableCell(child); | 146 RenderTableCell* cell = toRenderTableCell(child); |
147 | 147 |
148 // Generated content can result in us having a null section so make sure to
null check our parent. | 148 // Generated content can result in us having a null section so make sure to
null check our parent. |
149 if (parent()) | 149 if (parent()) |
150 section()->addCell(cell, this); | 150 section()->addCell(cell, this); |
151 | 151 |
152 ASSERT(!beforeChild || beforeChild->isTableCell()); | 152 ASSERT(!beforeChild || beforeChild->isTableCell()); |
153 RenderBox::addChild(cell, beforeChild); | 153 RenderBox::addChild(cell, beforeChild); |
154 | 154 |
155 if (beforeChild || nextSibling()) | 155 if (beforeChild || nextRow()) |
156 section()->setNeedsCellRecalc(); | 156 section()->setNeedsCellRecalc(); |
157 } | 157 } |
158 | 158 |
159 void RenderTableRow::layout() | 159 void RenderTableRow::layout() |
160 { | 160 { |
161 ASSERT(needsLayout()); | 161 ASSERT(needsLayout()); |
162 | 162 |
163 // Table rows do not add translation. | 163 // Table rows do not add translation. |
164 LayoutStateMaintainer statePusher(*this, LayoutSize()); | 164 LayoutStateMaintainer statePusher(*this, LayoutSize()); |
165 | 165 |
166 for (RenderObject* child = firstChild(); child; child = child->nextSibling()
) { | 166 for (RenderTableCell* cell = firstCell(); cell; cell = cell->nextCell()) { |
167 if (child->isTableCell()) { | 167 SubtreeLayoutScope layouter(*cell); |
168 SubtreeLayoutScope layouter(*child); | 168 if (!cell->needsLayout()) |
169 RenderTableCell* cell = toRenderTableCell(child); | 169 cell->markForPaginationRelayoutIfNeeded(layouter); |
170 if (!cell->needsLayout()) | 170 if (cell->needsLayout()) { |
171 cell->markForPaginationRelayoutIfNeeded(layouter); | 171 cell->computeAndSetBlockDirectionMargins(table()); |
172 if (cell->needsLayout()) { | 172 cell->layout(); |
173 cell->computeAndSetBlockDirectionMargins(table()); | |
174 cell->layout(); | |
175 } | |
176 } | 173 } |
177 } | 174 } |
178 | 175 |
179 m_overflow.clear(); | 176 m_overflow.clear(); |
180 addVisualEffectOverflow(); | 177 addVisualEffectOverflow(); |
181 | 178 |
182 // We only ever need to repaint if our cells didn't, which means that they d
idn't need | 179 // We only ever need to repaint if our cells didn't, which means that they d
idn't need |
183 // layout, so we know that our bounds didn't change. This code is just makin
g up for | 180 // layout, so we know that our bounds didn't change. This code is just makin
g up for |
184 // the fact that we did not repaint in setStyle() because we had a layout hi
nt. | 181 // the fact that we did not repaint in setStyle() because we had a layout hi
nt. |
185 // We cannot call repaint() because our clippedOverflowRectForRepaint() is t
aken from the | 182 // We cannot call repaint() because our clippedOverflowRectForRepaint() is t
aken from the |
186 // parent table, and being mid-layout, that is invalid. Instead, we repaint
our cells. | 183 // parent table, and being mid-layout, that is invalid. Instead, we repaint
our cells. |
187 if (selfNeedsLayout() && checkForRepaint()) { | 184 if (selfNeedsLayout() && checkForRepaint()) { |
188 for (RenderObject* child = firstChild(); child; child = child->nextSibli
ng()) { | 185 for (RenderTableCell* cell = firstCell(); cell; cell = cell->nextCell())
{ |
189 if (child->isTableCell()) { | 186 if (RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) { |
190 if (RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) { | 187 // FIXME: Is this needed with repaint After Layout? |
191 // FIXME: Is this needed with repaint After Layout? | 188 cell->setShouldDoFullRepaintAfterLayout(true); |
192 child->setShouldDoFullRepaintAfterLayout(true); | 189 } else { |
193 } else { | 190 cell->repaint(); |
194 child->repaint(); | |
195 } | |
196 } | 191 } |
197 } | 192 } |
198 } | 193 } |
199 | 194 |
200 // RenderTableSection::layoutRows will set our logical height and width late
r, so it calls updateLayerTransform(). | 195 // RenderTableSection::layoutRows will set our logical height and width late
r, so it calls updateLayerTransform(). |
201 clearNeedsLayout(); | 196 clearNeedsLayout(); |
202 } | 197 } |
203 | 198 |
204 // Hit Testing | 199 // Hit Testing |
205 bool RenderTableRow::nodeAtPoint(const HitTestRequest& request, HitTestResult& r
esult, const HitTestLocation& locationInContainer, const LayoutPoint& accumulate
dOffset, HitTestAction action) | 200 bool RenderTableRow::nodeAtPoint(const HitTestRequest& request, HitTestResult& r
esult, const HitTestLocation& locationInContainer, const LayoutPoint& accumulate
dOffset, HitTestAction action) |
206 { | 201 { |
207 // Table rows cannot ever be hit tested. Effectively they do not exist. | 202 // Table rows cannot ever be hit tested. Effectively they do not exist. |
208 // Just forward to our children always. | 203 // Just forward to our children always. |
209 for (RenderObject* child = lastChild(); child; child = child->previousSiblin
g()) { | 204 for (RenderTableCell* cell = lastCell(); cell; cell = cell->previousCell())
{ |
210 // FIXME: We have to skip over inline flows, since they can show up insi
de table rows | 205 // FIXME: We have to skip over inline flows, since they can show up insi
de table rows |
211 // at the moment (a demoted inline <form> for example). If we ever imple
ment a | 206 // at the moment (a demoted inline <form> for example). If we ever imple
ment a |
212 // table-specific hit-test method (which we should do for performance re
asons anyway), | 207 // table-specific hit-test method (which we should do for performance re
asons anyway), |
213 // then we can remove this check. | 208 // then we can remove this check. |
214 if (child->isTableCell() && !toRenderBox(child)->hasSelfPaintingLayer())
{ | 209 if (!cell->hasSelfPaintingLayer()) { |
215 LayoutPoint cellPoint = flipForWritingModeForChild(toRenderTableCell
(child), accumulatedOffset); | 210 LayoutPoint cellPoint = flipForWritingModeForChild(cell, accumulated
Offset); |
216 if (child->nodeAtPoint(request, result, locationInContainer, cellPoi
nt, action)) { | 211 if (cell->nodeAtPoint(request, result, locationInContainer, cellPoin
t, action)) { |
217 updateHitTestResult(result, locationInContainer.point() - toLayo
utSize(cellPoint)); | 212 updateHitTestResult(result, locationInContainer.point() - toLayo
utSize(cellPoint)); |
218 return true; | 213 return true; |
219 } | 214 } |
220 } | 215 } |
221 } | 216 } |
222 | 217 |
223 return false; | 218 return false; |
224 } | 219 } |
225 | 220 |
226 void RenderTableRow::paintOutlineForRowIfNeeded(PaintInfo& paintInfo, const Layo
utPoint& paintOffset) | 221 void RenderTableRow::paintOutlineForRowIfNeeded(PaintInfo& paintInfo, const Layo
utPoint& paintOffset) |
227 { | 222 { |
228 LayoutPoint adjustedPaintOffset = paintOffset + location(); | 223 LayoutPoint adjustedPaintOffset = paintOffset + location(); |
229 PaintPhase paintPhase = paintInfo.phase; | 224 PaintPhase paintPhase = paintInfo.phase; |
230 if ((paintPhase == PaintPhaseOutline || paintPhase == PaintPhaseSelfOutline)
&& style()->visibility() == VISIBLE) | 225 if ((paintPhase == PaintPhaseOutline || paintPhase == PaintPhaseSelfOutline)
&& style()->visibility() == VISIBLE) |
231 paintOutline(paintInfo, LayoutRect(adjustedPaintOffset, size())); | 226 paintOutline(paintInfo, LayoutRect(adjustedPaintOffset, size())); |
232 } | 227 } |
233 | 228 |
234 void RenderTableRow::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) | 229 void RenderTableRow::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) |
235 { | 230 { |
236 ASSERT(hasSelfPaintingLayer()); | 231 ASSERT(hasSelfPaintingLayer()); |
237 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this); | 232 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this); |
238 | 233 |
239 paintOutlineForRowIfNeeded(paintInfo, paintOffset); | 234 paintOutlineForRowIfNeeded(paintInfo, paintOffset); |
240 for (RenderObject* child = firstChild(); child; child = child->nextSibling()
) { | 235 for (RenderTableCell* cell = firstCell(); cell; cell = cell->nextCell()) { |
241 if (child->isTableCell()) { | 236 // Paint the row background behind the cell. |
242 // Paint the row background behind the cell. | 237 if (paintInfo.phase == PaintPhaseBlockBackground || paintInfo.phase == P
aintPhaseChildBlockBackground) |
243 if (paintInfo.phase == PaintPhaseBlockBackground || paintInfo.phase
== PaintPhaseChildBlockBackground) { | 238 cell->paintBackgroundsBehindCell(paintInfo, paintOffset, this); |
244 RenderTableCell* cell = toRenderTableCell(child); | 239 if (!cell->hasSelfPaintingLayer()) |
245 cell->paintBackgroundsBehindCell(paintInfo, paintOffset, this); | 240 cell->paint(paintInfo, paintOffset); |
246 } | |
247 if (!toRenderBox(child)->hasSelfPaintingLayer()) | |
248 child->paint(paintInfo, paintOffset); | |
249 } | |
250 } | 241 } |
251 } | 242 } |
252 | 243 |
253 void RenderTableRow::imageChanged(WrappedImagePtr, const IntRect*) | 244 void RenderTableRow::imageChanged(WrappedImagePtr, const IntRect*) |
254 { | 245 { |
255 // FIXME: Examine cells and repaint only the rect the image paints in. | 246 // FIXME: Examine cells and repaint only the rect the image paints in. |
256 repaint(); | 247 repaint(); |
257 } | 248 } |
258 | 249 |
259 RenderTableRow* RenderTableRow::createAnonymous(Document* document) | 250 RenderTableRow* RenderTableRow::createAnonymous(Document* document) |
260 { | 251 { |
261 RenderTableRow* renderer = new RenderTableRow(0); | 252 RenderTableRow* renderer = new RenderTableRow(0); |
262 renderer->setDocumentForAnonymous(document); | 253 renderer->setDocumentForAnonymous(document); |
263 return renderer; | 254 return renderer; |
264 } | 255 } |
265 | 256 |
266 RenderTableRow* RenderTableRow::createAnonymousWithParentRenderer(const RenderOb
ject* parent) | 257 RenderTableRow* RenderTableRow::createAnonymousWithParentRenderer(const RenderOb
ject* parent) |
267 { | 258 { |
268 RenderTableRow* newRow = RenderTableRow::createAnonymous(&parent->document()
); | 259 RenderTableRow* newRow = RenderTableRow::createAnonymous(&parent->document()
); |
269 RefPtr<RenderStyle> newStyle = RenderStyle::createAnonymousStyleWithDisplay(
parent->style(), TABLE_ROW); | 260 RefPtr<RenderStyle> newStyle = RenderStyle::createAnonymousStyleWithDisplay(
parent->style(), TABLE_ROW); |
270 newRow->setStyle(newStyle.release()); | 261 newRow->setStyle(newStyle.release()); |
271 return newRow; | 262 return newRow; |
272 } | 263 } |
273 | 264 |
274 } // namespace WebCore | 265 } // namespace WebCore |
OLD | NEW |