| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1997 Martin Jones (mjones@kde.org) | 2 * Copyright (C) 1997 Martin Jones (mjones@kde.org) |
| 3 * (C) 1997 Torben Weis (weis@kde.org) | 3 * (C) 1997 Torben Weis (weis@kde.org) |
| 4 * (C) 1998 Waldo Bastian (bastian@kde.org) | 4 * (C) 1998 Waldo Bastian (bastian@kde.org) |
| 5 * (C) 1999 Lars Knoll (knoll@kde.org) | 5 * (C) 1999 Lars Knoll (knoll@kde.org) |
| 6 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 6 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
reserved. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. |
| 8 * All rights reserved. |
| 8 * | 9 * |
| 9 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 11 * modify it under the terms of the GNU Library General Public |
| 11 * License as published by the Free Software Foundation; either | 12 * License as published by the Free Software Foundation; either |
| 12 * version 2 of the License, or (at your option) any later version. | 13 * version 2 of the License, or (at your option) any later version. |
| 13 * | 14 * |
| 14 * This library is distributed in the hope that it will be useful, | 15 * This library is distributed in the hope that it will be useful, |
| 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 * Library General Public License for more details. | 18 * Library General Public License for more details. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 "LayoutTableCell should stay small"); | 52 "LayoutTableCell should stay small"); |
| 52 static_assert(sizeof(CollapsedBorderValue) == 8, | 53 static_assert(sizeof(CollapsedBorderValue) == 8, |
| 53 "CollapsedBorderValue should stay small"); | 54 "CollapsedBorderValue should stay small"); |
| 54 | 55 |
| 55 LayoutTableCell::LayoutTableCell(Element* element) | 56 LayoutTableCell::LayoutTableCell(Element* element) |
| 56 : LayoutBlockFlow(element), | 57 : LayoutBlockFlow(element), |
| 57 m_absoluteColumnIndex(unsetColumnIndex), | 58 m_absoluteColumnIndex(unsetColumnIndex), |
| 58 m_cellWidthChanged(false), | 59 m_cellWidthChanged(false), |
| 59 m_intrinsicPaddingBefore(0), | 60 m_intrinsicPaddingBefore(0), |
| 60 m_intrinsicPaddingAfter(0) { | 61 m_intrinsicPaddingAfter(0) { |
| 61 // We only update the flags when notified of DOM changes in colSpanOrRowSpanCh
anged() | 62 // We only update the flags when notified of DOM changes in |
| 62 // so we need to set their initial values here in case something asks for colS
pan()/rowSpan() before then. | 63 // colSpanOrRowSpanChanged() so we need to set their initial values here in |
| 64 // case something asks for colSpan()/rowSpan() before then. |
| 63 updateColAndRowSpanFlags(); | 65 updateColAndRowSpanFlags(); |
| 64 } | 66 } |
| 65 | 67 |
| 66 void LayoutTableCell::willBeRemovedFromTree() { | 68 void LayoutTableCell::willBeRemovedFromTree() { |
| 67 LayoutBlockFlow::willBeRemovedFromTree(); | 69 LayoutBlockFlow::willBeRemovedFromTree(); |
| 68 | 70 |
| 69 section()->setNeedsCellRecalc(); | 71 section()->setNeedsCellRecalc(); |
| 70 | 72 |
| 71 // When borders collapse, removing a cell can affect the the width of neighbor
ing cells. | 73 // When borders collapse, removing a cell can affect the the width of |
| 74 // neighboring cells. |
| 72 LayoutTable* enclosingTable = table(); | 75 LayoutTable* enclosingTable = table(); |
| 73 DCHECK(enclosingTable); | 76 DCHECK(enclosingTable); |
| 74 if (!enclosingTable->collapseBorders()) | 77 if (!enclosingTable->collapseBorders()) |
| 75 return; | 78 return; |
| 76 if (previousCell()) { | 79 if (previousCell()) { |
| 77 // TODO(dgrogan): Should this be setChildNeedsLayout or setNeedsLayout? | 80 // TODO(dgrogan): Should this be setChildNeedsLayout or setNeedsLayout? |
| 78 // remove-cell-with-border-box.html only passes with setNeedsLayout but othe
r places | 81 // remove-cell-with-border-box.html only passes with setNeedsLayout but |
| 79 // use setChildNeedsLayout. | 82 // other places use setChildNeedsLayout. |
| 80 previousCell()->setNeedsLayout(LayoutInvalidationReason::TableChanged); | 83 previousCell()->setNeedsLayout(LayoutInvalidationReason::TableChanged); |
| 81 previousCell()->setPreferredLogicalWidthsDirty(); | 84 previousCell()->setPreferredLogicalWidthsDirty(); |
| 82 } | 85 } |
| 83 if (nextCell()) { | 86 if (nextCell()) { |
| 84 // TODO(dgrogan): Same as above re: setChildNeedsLayout vs setNeedsLayout. | 87 // TODO(dgrogan): Same as above re: setChildNeedsLayout vs setNeedsLayout. |
| 85 nextCell()->setNeedsLayout(LayoutInvalidationReason::TableChanged); | 88 nextCell()->setNeedsLayout(LayoutInvalidationReason::TableChanged); |
| 86 nextCell()->setPreferredLogicalWidthsDirty(); | 89 nextCell()->setPreferredLogicalWidthsDirty(); |
| 87 } | 90 } |
| 88 } | 91 } |
| 89 | 92 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 // Percentage value should be returned only for colSpan == 1. | 143 // Percentage value should be returned only for colSpan == 1. |
| 141 // Otherwise we return original width for the cell. | 144 // Otherwise we return original width for the cell. |
| 142 if (!colWidth.isFixed()) { | 145 if (!colWidth.isFixed()) { |
| 143 if (colSpanCount > 1) | 146 if (colSpanCount > 1) |
| 144 return widthFromStyle; | 147 return widthFromStyle; |
| 145 return colWidth; | 148 return colWidth; |
| 146 } | 149 } |
| 147 | 150 |
| 148 colWidthSum += colWidth.value(); | 151 colWidthSum += colWidth.value(); |
| 149 tableCol = tableCol->nextColumn(); | 152 tableCol = tableCol->nextColumn(); |
| 150 // If no next <col> tag found for the span we just return what we have for n
ow. | 153 // If no next <col> tag found for the span we just return what we have for |
| 154 // now. |
| 151 if (!tableCol) | 155 if (!tableCol) |
| 152 break; | 156 break; |
| 153 } | 157 } |
| 154 | 158 |
| 155 // Column widths specified on <col> apply to the border box of the cell, see b
ug 8126. | 159 // Column widths specified on <col> apply to the border box of the cell, see |
| 160 // bug 8126. |
| 156 // FIXME: Why is border/padding ignored in the negative width case? | 161 // FIXME: Why is border/padding ignored in the negative width case? |
| 157 if (colWidthSum > 0) | 162 if (colWidthSum > 0) |
| 158 return Length( | 163 return Length( |
| 159 std::max(0, colWidthSum - borderAndPaddingLogicalWidth().ceil()), | 164 std::max(0, colWidthSum - borderAndPaddingLogicalWidth().ceil()), |
| 160 Fixed); | 165 Fixed); |
| 161 return Length(colWidthSum, Fixed); | 166 return Length(colWidthSum, Fixed); |
| 162 } | 167 } |
| 163 | 168 |
| 164 void LayoutTableCell::computePreferredLogicalWidths() { | 169 void LayoutTableCell::computePreferredLogicalWidths() { |
| 165 // The child cells rely on the grids up in the sections to do their computePre
ferredLogicalWidths work. Normally the sections are set up early, as table | 170 // The child cells rely on the grids up in the sections to do their |
| 166 // cells are added, but relayout can cause the cells to be freed, leaving stal
e pointers in the sections' | 171 // computePreferredLogicalWidths work. Normally the sections are set up |
| 167 // grids. We must refresh those grids before the child cells try to use them. | 172 // early, as table cells are added, but relayout can cause the cells to be |
| 173 // freed, leaving stale pointers in the sections' grids. We must refresh those |
| 174 // grids before the child cells try to use them. |
| 168 table()->recalcSectionsIfNeeded(); | 175 table()->recalcSectionsIfNeeded(); |
| 169 | 176 |
| 170 LayoutBlockFlow::computePreferredLogicalWidths(); | 177 LayoutBlockFlow::computePreferredLogicalWidths(); |
| 171 if (node() && style()->autoWrap()) { | 178 if (node() && style()->autoWrap()) { |
| 172 // See if nowrap was set. | 179 // See if nowrap was set. |
| 173 Length w = styleOrColLogicalWidth(); | 180 Length w = styleOrColLogicalWidth(); |
| 174 const AtomicString& nowrap = toElement(node())->getAttribute(nowrapAttr); | 181 const AtomicString& nowrap = toElement(node())->getAttribute(nowrapAttr); |
| 175 if (!nowrap.isNull() && w.isFixed()) { | 182 if (!nowrap.isNull() && w.isFixed()) { |
| 176 // Nowrap is set, but we didn't actually use it because of the | 183 // Nowrap is set, but we didn't actually use it because of the fixed width |
| 177 // fixed width set on the cell. Even so, it is a WinIE/Moz trait | 184 // set on the cell. Even so, it is a WinIE/Moz trait to make the minwidth |
| 178 // to make the minwidth of the cell into the fixed width. They do this | 185 // of the cell into the fixed width. They do this even in strict mode, so |
| 179 // even in strict mode, so do not make this a quirk. Affected the top | 186 // do not make this a quirk. Affected the top of hiptop.com. |
| 180 // of hiptop.com. | |
| 181 m_minPreferredLogicalWidth = | 187 m_minPreferredLogicalWidth = |
| 182 std::max(LayoutUnit(w.value()), m_minPreferredLogicalWidth); | 188 std::max(LayoutUnit(w.value()), m_minPreferredLogicalWidth); |
| 183 } | 189 } |
| 184 } | 190 } |
| 185 } | 191 } |
| 186 | 192 |
| 187 void LayoutTableCell::addLayerHitTestRects( | 193 void LayoutTableCell::addLayerHitTestRects( |
| 188 LayerHitTestRects& layerRects, | 194 LayerHitTestRects& layerRects, |
| 189 const PaintLayer* currentLayer, | 195 const PaintLayer* currentLayer, |
| 190 const LayoutPoint& layerOffset, | 196 const LayoutPoint& layerOffset, |
| 191 const LayoutRect& containerRect) const { | 197 const LayoutRect& containerRect) const { |
| 192 LayoutPoint adjustedLayerOffset = layerOffset; | 198 LayoutPoint adjustedLayerOffset = layerOffset; |
| 193 // LayoutTableCell's location includes the offset of it's containing LayoutTab
leRow, so | 199 // LayoutTableCell's location includes the offset of it's containing |
| 194 // we need to subtract that again here (as for LayoutTableCell::offsetFromCont
ainer. | 200 // LayoutTableRow, so we need to subtract that again here (as for |
| 201 // LayoutTableCell::offsetFromContainer. |
| 195 if (parent()) | 202 if (parent()) |
| 196 adjustedLayerOffset -= parentBox()->locationOffset(); | 203 adjustedLayerOffset -= parentBox()->locationOffset(); |
| 197 LayoutBox::addLayerHitTestRects(layerRects, currentLayer, adjustedLayerOffset, | 204 LayoutBox::addLayerHitTestRects(layerRects, currentLayer, adjustedLayerOffset, |
| 198 containerRect); | 205 containerRect); |
| 199 } | 206 } |
| 200 | 207 |
| 201 void LayoutTableCell::computeIntrinsicPadding(int rowHeight, | 208 void LayoutTableCell::computeIntrinsicPadding(int rowHeight, |
| 202 SubtreeLayoutScope& layouter) { | 209 SubtreeLayoutScope& layouter) { |
| 203 int oldIntrinsicPaddingBefore = intrinsicPaddingBefore(); | 210 int oldIntrinsicPaddingBefore = intrinsicPaddingBefore(); |
| 204 int oldIntrinsicPaddingAfter = intrinsicPaddingAfter(); | 211 int oldIntrinsicPaddingAfter = intrinsicPaddingAfter(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 231 break; | 238 break; |
| 232 case VerticalAlignBaselineMiddle: | 239 case VerticalAlignBaselineMiddle: |
| 233 break; | 240 break; |
| 234 } | 241 } |
| 235 | 242 |
| 236 int intrinsicPaddingAfter = | 243 int intrinsicPaddingAfter = |
| 237 rowHeight - logicalHeightWithoutIntrinsicPadding - intrinsicPaddingBefore; | 244 rowHeight - logicalHeightWithoutIntrinsicPadding - intrinsicPaddingBefore; |
| 238 setIntrinsicPaddingBefore(intrinsicPaddingBefore); | 245 setIntrinsicPaddingBefore(intrinsicPaddingBefore); |
| 239 setIntrinsicPaddingAfter(intrinsicPaddingAfter); | 246 setIntrinsicPaddingAfter(intrinsicPaddingAfter); |
| 240 | 247 |
| 241 // FIXME: Changing an intrinsic padding shouldn't trigger a relayout as it onl
y shifts the cell inside the row but | 248 // FIXME: Changing an intrinsic padding shouldn't trigger a relayout as it |
| 242 // doesn't change the logical height. | 249 // only shifts the cell inside the row but doesn't change the logical height. |
| 243 if (intrinsicPaddingBefore != oldIntrinsicPaddingBefore || | 250 if (intrinsicPaddingBefore != oldIntrinsicPaddingBefore || |
| 244 intrinsicPaddingAfter != oldIntrinsicPaddingAfter) | 251 intrinsicPaddingAfter != oldIntrinsicPaddingAfter) |
| 245 layouter.setNeedsLayout(this, LayoutInvalidationReason::PaddingChanged); | 252 layouter.setNeedsLayout(this, LayoutInvalidationReason::PaddingChanged); |
| 246 } | 253 } |
| 247 | 254 |
| 248 void LayoutTableCell::updateLogicalWidth() {} | 255 void LayoutTableCell::updateLogicalWidth() {} |
| 249 | 256 |
| 250 void LayoutTableCell::setCellLogicalWidth(int tableLayoutLogicalWidth, | 257 void LayoutTableCell::setCellLogicalWidth(int tableLayoutLogicalWidth, |
| 251 SubtreeLayoutScope& layouter) { | 258 SubtreeLayoutScope& layouter) { |
| 252 if (tableLayoutLogicalWidth == logicalWidth()) | 259 if (tableLayoutLogicalWidth == logicalWidth()) |
| 253 return; | 260 return; |
| 254 | 261 |
| 255 layouter.setNeedsLayout(this, LayoutInvalidationReason::SizeChanged); | 262 layouter.setNeedsLayout(this, LayoutInvalidationReason::SizeChanged); |
| 256 | 263 |
| 257 setLogicalWidth(LayoutUnit(tableLayoutLogicalWidth)); | 264 setLogicalWidth(LayoutUnit(tableLayoutLogicalWidth)); |
| 258 setCellWidthChanged(true); | 265 setCellWidthChanged(true); |
| 259 } | 266 } |
| 260 | 267 |
| 261 void LayoutTableCell::layout() { | 268 void LayoutTableCell::layout() { |
| 262 ASSERT(needsLayout()); | 269 ASSERT(needsLayout()); |
| 263 LayoutAnalyzer::Scope analyzer(*this); | 270 LayoutAnalyzer::Scope analyzer(*this); |
| 264 | 271 |
| 265 int oldCellBaseline = cellBaselinePosition(); | 272 int oldCellBaseline = cellBaselinePosition(); |
| 266 layoutBlock(cellWidthChanged()); | 273 layoutBlock(cellWidthChanged()); |
| 267 | 274 |
| 268 // If we have replaced content, the intrinsic height of our content may have c
hanged since the last time we laid out. If that's the case the intrinsic padding
we used | 275 // If we have replaced content, the intrinsic height of our content may have |
| 269 // for layout (the padding required to push the contents of the cell down to t
he row's baseline) is included in our new height and baseline and makes both | 276 // changed since the last time we laid out. If that's the case the intrinsic |
| 270 // of them wrong. So if our content's intrinsic height has changed push the ne
w content up into the intrinsic padding and relayout so that the rest of | 277 // padding we used for layout (the padding required to push the contents of |
| 271 // table and row layout can use the correct baseline and height for this cell. | 278 // the cell down to the row's baseline) is included in our new height and |
| 279 // baseline and makes both of them wrong. So if our content's intrinsic height |
| 280 // has changed push the new content up into the intrinsic padding and relayout |
| 281 // so that the rest of table and row layout can use the correct baseline and |
| 282 // height for this cell. |
| 272 if (isBaselineAligned() && section()->rowBaseline(rowIndex()) && | 283 if (isBaselineAligned() && section()->rowBaseline(rowIndex()) && |
| 273 cellBaselinePosition() > section()->rowBaseline(rowIndex())) { | 284 cellBaselinePosition() > section()->rowBaseline(rowIndex())) { |
| 274 int newIntrinsicPaddingBefore = | 285 int newIntrinsicPaddingBefore = |
| 275 std::max(intrinsicPaddingBefore() - | 286 std::max(intrinsicPaddingBefore() - |
| 276 std::max(cellBaselinePosition() - oldCellBaseline, 0), | 287 std::max(cellBaselinePosition() - oldCellBaseline, 0), |
| 277 0); | 288 0); |
| 278 setIntrinsicPaddingBefore(newIntrinsicPaddingBefore); | 289 setIntrinsicPaddingBefore(newIntrinsicPaddingBefore); |
| 279 SubtreeLayoutScope layouter(*this); | 290 SubtreeLayoutScope layouter(*this); |
| 280 layouter.setNeedsLayout(this, LayoutInvalidationReason::TableChanged); | 291 layouter.setNeedsLayout(this, LayoutInvalidationReason::TableChanged); |
| 281 layoutBlock(cellWidthChanged()); | 292 layoutBlock(cellWidthChanged()); |
| 282 } | 293 } |
| 283 | 294 |
| 284 // FIXME: This value isn't the intrinsic content logical height, but we need | 295 // FIXME: This value isn't the intrinsic content logical height, but we need |
| 285 // to update the value as its used by flexbox layout. crbug.com/367324 | 296 // to update the value as its used by flexbox layout. crbug.com/367324 |
| 286 setIntrinsicContentLogicalHeight(contentLogicalHeight()); | 297 setIntrinsicContentLogicalHeight(contentLogicalHeight()); |
| 287 | 298 |
| 288 setCellWidthChanged(false); | 299 setCellWidthChanged(false); |
| 289 } | 300 } |
| 290 | 301 |
| 291 LayoutUnit LayoutTableCell::paddingTop() const { | 302 LayoutUnit LayoutTableCell::paddingTop() const { |
| 292 LayoutUnit result = computedCSSPaddingTop(); | 303 LayoutUnit result = computedCSSPaddingTop(); |
| 293 if (isHorizontalWritingMode()) | 304 if (isHorizontalWritingMode()) |
| 294 result += (style()->getWritingMode() == TopToBottomWritingMode | 305 result += (style()->getWritingMode() == TopToBottomWritingMode |
| 295 ? intrinsicPaddingBefore() | 306 ? intrinsicPaddingBefore() |
| 296 : intrinsicPaddingAfter()); | 307 : intrinsicPaddingAfter()); |
| 297 // TODO(leviw): The floor call should be removed when Table is sub-pixel aware
. crbug.com/377847 | 308 // TODO(leviw): The floor call should be removed when Table is sub-pixel |
| 309 // aware. crbug.com/377847 |
| 298 return LayoutUnit(result.floor()); | 310 return LayoutUnit(result.floor()); |
| 299 } | 311 } |
| 300 | 312 |
| 301 LayoutUnit LayoutTableCell::paddingBottom() const { | 313 LayoutUnit LayoutTableCell::paddingBottom() const { |
| 302 LayoutUnit result = computedCSSPaddingBottom(); | 314 LayoutUnit result = computedCSSPaddingBottom(); |
| 303 if (isHorizontalWritingMode()) | 315 if (isHorizontalWritingMode()) |
| 304 result += (style()->getWritingMode() == TopToBottomWritingMode | 316 result += (style()->getWritingMode() == TopToBottomWritingMode |
| 305 ? intrinsicPaddingAfter() | 317 ? intrinsicPaddingAfter() |
| 306 : intrinsicPaddingBefore()); | 318 : intrinsicPaddingBefore()); |
| 307 // TODO(leviw): The floor call should be removed when Table is sub-pixel aware
. crbug.com/377847 | 319 // TODO(leviw): The floor call should be removed when Table is sub-pixel |
| 320 // aware. crbug.com/377847 |
| 308 return LayoutUnit(result.floor()); | 321 return LayoutUnit(result.floor()); |
| 309 } | 322 } |
| 310 | 323 |
| 311 LayoutUnit LayoutTableCell::paddingLeft() const { | 324 LayoutUnit LayoutTableCell::paddingLeft() const { |
| 312 LayoutUnit result = computedCSSPaddingLeft(); | 325 LayoutUnit result = computedCSSPaddingLeft(); |
| 313 if (!isHorizontalWritingMode()) | 326 if (!isHorizontalWritingMode()) |
| 314 result += (style()->getWritingMode() == LeftToRightWritingMode | 327 result += (style()->getWritingMode() == LeftToRightWritingMode |
| 315 ? intrinsicPaddingBefore() | 328 ? intrinsicPaddingBefore() |
| 316 : intrinsicPaddingAfter()); | 329 : intrinsicPaddingAfter()); |
| 317 // TODO(leviw): The floor call should be removed when Table is sub-pixel aware
. crbug.com/377847 | 330 // TODO(leviw): The floor call should be removed when Table is sub-pixel |
| 331 // aware. crbug.com/377847 |
| 318 return LayoutUnit(result.floor()); | 332 return LayoutUnit(result.floor()); |
| 319 } | 333 } |
| 320 | 334 |
| 321 LayoutUnit LayoutTableCell::paddingRight() const { | 335 LayoutUnit LayoutTableCell::paddingRight() const { |
| 322 LayoutUnit result = computedCSSPaddingRight(); | 336 LayoutUnit result = computedCSSPaddingRight(); |
| 323 if (!isHorizontalWritingMode()) | 337 if (!isHorizontalWritingMode()) |
| 324 result += (style()->getWritingMode() == LeftToRightWritingMode | 338 result += (style()->getWritingMode() == LeftToRightWritingMode |
| 325 ? intrinsicPaddingAfter() | 339 ? intrinsicPaddingAfter() |
| 326 : intrinsicPaddingBefore()); | 340 : intrinsicPaddingBefore()); |
| 327 // TODO(leviw): The floor call should be removed when Table is sub-pixel aware
. crbug.com/377847 | 341 // TODO(leviw): The floor call should be removed when Table is sub-pixel |
| 342 // aware. crbug.com/377847 |
| 328 return LayoutUnit(result.floor()); | 343 return LayoutUnit(result.floor()); |
| 329 } | 344 } |
| 330 | 345 |
| 331 LayoutUnit LayoutTableCell::paddingBefore() const { | 346 LayoutUnit LayoutTableCell::paddingBefore() const { |
| 332 return LayoutUnit(computedCSSPaddingBefore().floor() + | 347 return LayoutUnit(computedCSSPaddingBefore().floor() + |
| 333 intrinsicPaddingBefore()); | 348 intrinsicPaddingBefore()); |
| 334 } | 349 } |
| 335 | 350 |
| 336 LayoutUnit LayoutTableCell::paddingAfter() const { | 351 LayoutUnit LayoutTableCell::paddingAfter() const { |
| 337 return LayoutUnit(computedCSSPaddingAfter().floor() + | 352 return LayoutUnit(computedCSSPaddingAfter().floor() + |
| (...skipping 11 matching lines...) Expand all Loading... |
| 349 ASSERT(o == container()); | 364 ASSERT(o == container()); |
| 350 | 365 |
| 351 LayoutSize offset = LayoutBlockFlow::offsetFromContainer(o); | 366 LayoutSize offset = LayoutBlockFlow::offsetFromContainer(o); |
| 352 if (parent()) | 367 if (parent()) |
| 353 offset -= parentBox()->locationOffset(); | 368 offset -= parentBox()->locationOffset(); |
| 354 | 369 |
| 355 return offset; | 370 return offset; |
| 356 } | 371 } |
| 357 | 372 |
| 358 LayoutRect LayoutTableCell::localOverflowRectForPaintInvalidation() const { | 373 LayoutRect LayoutTableCell::localOverflowRectForPaintInvalidation() const { |
| 359 // If the table grid is dirty, we cannot get reliable information about adjoin
ing cells, | 374 // If the table grid is dirty, we cannot get reliable information about |
| 360 // so we ignore outside borders. This should not be a problem because it means
that | 375 // adjoining cells, so we ignore outside borders. This should not be a problem |
| 361 // the table is going to recalculate the grid, relayout and issue a paint inva
lidation of its current rect, which | 376 // because it means that the table is going to recalculate the grid, relayout |
| 362 // includes any outside borders of this cell. | 377 // and issue a paint invalidation of its current rect, which includes any |
| 378 // outside borders of this cell. |
| 363 if (!table()->collapseBorders() || table()->needsSectionRecalc()) | 379 if (!table()->collapseBorders() || table()->needsSectionRecalc()) |
| 364 return LayoutBlockFlow::localOverflowRectForPaintInvalidation(); | 380 return LayoutBlockFlow::localOverflowRectForPaintInvalidation(); |
| 365 | 381 |
| 366 bool rtl = !styleForCellFlow().isLeftToRightDirection(); | 382 bool rtl = !styleForCellFlow().isLeftToRightDirection(); |
| 367 int outlineOutset = style()->outlineOutsetExtent(); | 383 int outlineOutset = style()->outlineOutsetExtent(); |
| 368 int left = std::max(borderHalfLeft(true), outlineOutset); | 384 int left = std::max(borderHalfLeft(true), outlineOutset); |
| 369 int right = std::max(borderHalfRight(true), outlineOutset); | 385 int right = std::max(borderHalfRight(true), outlineOutset); |
| 370 int top = std::max(borderHalfTop(true), outlineOutset); | 386 int top = std::max(borderHalfTop(true), outlineOutset); |
| 371 int bottom = std::max(borderHalfBottom(true), outlineOutset); | 387 int bottom = std::max(borderHalfBottom(true), outlineOutset); |
| 372 if ((left && !rtl) || (right && rtl)) { | 388 if ((left && !rtl) || (right && rtl)) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 398 LayoutPoint location(std::max(LayoutUnit(left), -selfVisualOverflowRect.x()), | 414 LayoutPoint location(std::max(LayoutUnit(left), -selfVisualOverflowRect.x()), |
| 399 std::max(LayoutUnit(top), -selfVisualOverflowRect.y())); | 415 std::max(LayoutUnit(top), -selfVisualOverflowRect.y())); |
| 400 return LayoutRect(-location.x(), -location.y(), | 416 return LayoutRect(-location.x(), -location.y(), |
| 401 location.x() + std::max(size().width() + right, | 417 location.x() + std::max(size().width() + right, |
| 402 selfVisualOverflowRect.maxX()), | 418 selfVisualOverflowRect.maxX()), |
| 403 location.y() + std::max(size().height() + bottom, | 419 location.y() + std::max(size().height() + bottom, |
| 404 selfVisualOverflowRect.maxY())); | 420 selfVisualOverflowRect.maxY())); |
| 405 } | 421 } |
| 406 | 422 |
| 407 int LayoutTableCell::cellBaselinePosition() const { | 423 int LayoutTableCell::cellBaselinePosition() const { |
| 408 // <http://www.w3.org/TR/2007/CR-CSS21-20070719/tables.html#height-layout>: Th
e baseline of a cell is the baseline of | 424 // <http://www.w3.org/TR/2007/CR-CSS21-20070719/tables.html#height-layout>: |
| 409 // the first in-flow line box in the cell, or the first in-flow table-row in t
he cell, whichever comes first. If there | 425 // The baseline of a cell is the baseline of the first in-flow line box in the |
| 410 // is no such line box or table-row, the baseline is the bottom of content edg
e of the cell box. | 426 // cell, or the first in-flow table-row in the cell, whichever comes first. If |
| 427 // there is no such line box or table-row, the baseline is the bottom of |
| 428 // content edge of the cell box. |
| 411 int firstLineBaseline = firstLineBoxBaseline(); | 429 int firstLineBaseline = firstLineBoxBaseline(); |
| 412 if (firstLineBaseline != -1) | 430 if (firstLineBaseline != -1) |
| 413 return firstLineBaseline; | 431 return firstLineBaseline; |
| 414 return (borderBefore() + paddingBefore() + contentLogicalHeight()).toInt(); | 432 return (borderBefore() + paddingBefore() + contentLogicalHeight()).toInt(); |
| 415 } | 433 } |
| 416 | 434 |
| 417 void LayoutTableCell::styleDidChange(StyleDifference diff, | 435 void LayoutTableCell::styleDidChange(StyleDifference diff, |
| 418 const ComputedStyle* oldStyle) { | 436 const ComputedStyle* oldStyle) { |
| 419 DCHECK_EQ(style()->display(), EDisplay::TableCell); | 437 DCHECK_EQ(style()->display(), EDisplay::TableCell); |
| 420 | 438 |
| 421 LayoutBlockFlow::styleDidChange(diff, oldStyle); | 439 LayoutBlockFlow::styleDidChange(diff, oldStyle); |
| 422 setHasBoxDecorationBackground(true); | 440 setHasBoxDecorationBackground(true); |
| 423 | 441 |
| 424 if (parent() && section() && oldStyle && | 442 if (parent() && section() && oldStyle && |
| 425 style()->height() != oldStyle->height()) | 443 style()->height() != oldStyle->height()) |
| 426 section()->rowLogicalHeightChanged(row()); | 444 section()->rowLogicalHeightChanged(row()); |
| 427 | 445 |
| 428 // Our intrinsic padding pushes us down to align with the baseline of other ce
lls on the row. If our vertical-align | 446 // Our intrinsic padding pushes us down to align with the baseline of other |
| 429 // has changed then so will the padding needed to align with other cells - cle
ar it so we can recalculate it from scratch. | 447 // cells on the row. If our vertical-align has changed then so will the |
| 448 // padding needed to align with other cells - clear it so we can recalculate |
| 449 // it from scratch. |
| 430 if (oldStyle && style()->verticalAlign() != oldStyle->verticalAlign()) | 450 if (oldStyle && style()->verticalAlign() != oldStyle->verticalAlign()) |
| 431 clearIntrinsicPadding(); | 451 clearIntrinsicPadding(); |
| 432 | 452 |
| 433 // If border was changed, notify table. | 453 // If border was changed, notify table. |
| 434 if (!parent()) | 454 if (!parent()) |
| 435 return; | 455 return; |
| 436 LayoutTable* table = this->table(); | 456 LayoutTable* table = this->table(); |
| 437 if (!table) | 457 if (!table) |
| 438 return; | 458 return; |
| 439 if (!table->selfNeedsLayout() && !table->normalChildNeedsLayout() && | 459 if (!table->selfNeedsLayout() && !table->normalChildNeedsLayout() && |
| 440 oldStyle && oldStyle->border() != style()->border()) | 460 oldStyle && oldStyle->border() != style()->border()) |
| 441 table->invalidateCollapsedBorders(); | 461 table->invalidateCollapsedBorders(); |
| 442 | 462 |
| 443 if (LayoutTableBoxComponent::doCellsHaveDirtyWidth(*this, *table, diff, | 463 if (LayoutTableBoxComponent::doCellsHaveDirtyWidth(*this, *table, diff, |
| 444 *oldStyle)) { | 464 *oldStyle)) { |
| 445 if (previousCell()) { | 465 if (previousCell()) { |
| 446 // TODO(dgrogan) Add a layout test showing that setChildNeedsLayout is nee
ded instead of setNeedsLayout. | 466 // TODO(dgrogan) Add a layout test showing that setChildNeedsLayout is |
| 467 // needed instead of setNeedsLayout. |
| 447 previousCell()->setChildNeedsLayout(); | 468 previousCell()->setChildNeedsLayout(); |
| 448 previousCell()->setPreferredLogicalWidthsDirty(MarkOnlyThis); | 469 previousCell()->setPreferredLogicalWidthsDirty(MarkOnlyThis); |
| 449 } | 470 } |
| 450 if (nextCell()) { | 471 if (nextCell()) { |
| 451 // TODO(dgrogan) Add a layout test showing that setChildNeedsLayout is nee
ded instead of setNeedsLayout. | 472 // TODO(dgrogan) Add a layout test showing that setChildNeedsLayout is |
| 473 // needed instead of setNeedsLayout. |
| 452 nextCell()->setChildNeedsLayout(); | 474 nextCell()->setChildNeedsLayout(); |
| 453 nextCell()->setPreferredLogicalWidthsDirty(MarkOnlyThis); | 475 nextCell()->setPreferredLogicalWidthsDirty(MarkOnlyThis); |
| 454 } | 476 } |
| 455 } | 477 } |
| 456 } | 478 } |
| 457 | 479 |
| 458 // The following rules apply for resolving conflicts and figuring out which bord
er | 480 // The following rules apply for resolving conflicts and figuring out which |
| 459 // to use. | 481 // border to use. |
| 460 // (1) Borders with the 'border-style' of 'hidden' take precedence over all othe
r conflicting | 482 // (1) Borders with the 'border-style' of 'hidden' take precedence over all |
| 461 // borders. Any border with this value suppresses all borders at this location. | 483 // other conflicting borders. Any border with this value suppresses all |
| 462 // (2) Borders with a style of 'none' have the lowest priority. Only if the bord
er properties of all | 484 // borders at this location. |
| 463 // the elements meeting at this edge are 'none' will the border be omitted (but
note that 'none' is | 485 // (2) Borders with a style of 'none' have the lowest priority. Only if the |
| 464 // the default value for the border style.) | 486 // border properties of all the elements meeting at this edge are 'none' |
| 465 // (3) If none of the styles are 'hidden' and at least one of them is not 'none'
, then narrow borders | 487 // will the border be omitted (but note that 'none' is the default value for |
| 466 // are discarded in favor of wider ones. If several have the same 'border-width'
then styles are preferred | 488 // the border style.) |
| 467 // in this order: 'double', 'solid', 'dashed', 'dotted', 'ridge', 'outset', 'gro
ove', and the lowest: 'inset'. | 489 // (3) If none of the styles are 'hidden' and at least one of them is not |
| 468 // (4) If border styles differ only in color, then a style set on a cell wins ov
er one on a row, | 490 // 'none', then narrow borders are discarded in favor of wider ones. If |
| 469 // which wins over a row group, column, column group and, lastly, table. It is u
ndefined which color | 491 // several have the same 'border-width' then styles are preferred in this |
| 470 // is used when two elements of the same type disagree. | 492 // order: 'double', 'solid', 'dashed', 'dotted', 'ridge', 'outset', |
| 493 // 'groove', and the lowest: 'inset'. |
| 494 // (4) If border styles differ only in color, then a style set on a cell wins |
| 495 // over one on a row, which wins over a row group, column, column group and, |
| 496 // lastly, table. It is undefined which color is used when two elements of |
| 497 // the same type disagree. |
| 471 static bool compareBorders(const CollapsedBorderValue& border1, | 498 static bool compareBorders(const CollapsedBorderValue& border1, |
| 472 const CollapsedBorderValue& border2) { | 499 const CollapsedBorderValue& border2) { |
| 473 // Sanity check the values passed in. The null border have lowest priority. | 500 // Sanity check the values passed in. The null border have lowest priority. |
| 474 if (!border2.exists()) | 501 if (!border2.exists()) |
| 475 return false; | 502 return false; |
| 476 if (!border1.exists()) | 503 if (!border1.exists()) |
| 477 return true; | 504 return true; |
| 478 | 505 |
| 479 // Rule #1 above. | 506 // Rule #1 above. |
| 480 if (border1.style() == BorderStyleHidden) | 507 if (border1.style() == BorderStyleHidden) |
| 481 return false; | 508 return false; |
| 482 if (border2.style() == BorderStyleHidden) | 509 if (border2.style() == BorderStyleHidden) |
| 483 return true; | 510 return true; |
| 484 | 511 |
| 485 // Rule #2 above. A style of 'none' has lowest priority and always loses to a
ny other border. | 512 // Rule #2 above. A style of 'none' has lowest priority and always loses to |
| 513 // any other border. |
| 486 if (border2.style() == BorderStyleNone) | 514 if (border2.style() == BorderStyleNone) |
| 487 return false; | 515 return false; |
| 488 if (border1.style() == BorderStyleNone) | 516 if (border1.style() == BorderStyleNone) |
| 489 return true; | 517 return true; |
| 490 | 518 |
| 491 // The first part of rule #3 above. Wider borders win. | 519 // The first part of rule #3 above. Wider borders win. |
| 492 if (border1.width() != border2.width()) | 520 if (border1.width() != border2.width()) |
| 493 return border1.width() < border2.width(); | 521 return border1.width() < border2.width(); |
| 494 | 522 |
| 495 // The borders have equal width. Sort by border style. | 523 // The borders have equal width. Sort by border style. |
| 496 if (border1.style() != border2.style()) | 524 if (border1.style() != border2.style()) |
| 497 return border1.style() < border2.style(); | 525 return border1.style() < border2.style(); |
| 498 | 526 |
| 499 // The border have the same width and style. Rely on precedence (cell over ro
w over row group, etc.) | 527 // The border have the same width and style. Rely on precedence (cell over |
| 528 // row over row group, etc.) |
| 500 return border1.precedence() < border2.precedence(); | 529 return border1.precedence() < border2.precedence(); |
| 501 } | 530 } |
| 502 | 531 |
| 503 static CollapsedBorderValue chooseBorder(const CollapsedBorderValue& border1, | 532 static CollapsedBorderValue chooseBorder(const CollapsedBorderValue& border1, |
| 504 const CollapsedBorderValue& border2) { | 533 const CollapsedBorderValue& border2) { |
| 505 return compareBorders(border1, border2) ? border2 : border1; | 534 return compareBorders(border1, border2) ? border2 : border1; |
| 506 } | 535 } |
| 507 | 536 |
| 508 bool LayoutTableCell::hasStartBorderAdjoiningTable() const { | 537 bool LayoutTableCell::hasStartBorderAdjoiningTable() const { |
| 509 bool isStartColumn = !absoluteColumnIndex(); | 538 bool isStartColumn = !absoluteColumnIndex(); |
| 510 bool isEndColumn = table()->absoluteColumnToEffectiveColumn( | 539 bool isEndColumn = table()->absoluteColumnToEffectiveColumn( |
| 511 absoluteColumnIndex() + colSpan() - 1) == | 540 absoluteColumnIndex() + colSpan() - 1) == |
| 512 table()->numEffectiveColumns() - 1; | 541 table()->numEffectiveColumns() - 1; |
| 513 bool hasSameDirectionAsTable = hasSameDirectionAs(table()); | 542 bool hasSameDirectionAsTable = hasSameDirectionAs(table()); |
| 514 | 543 |
| 515 // The table direction determines the row direction. In mixed directionality,
we cannot guarantee that | 544 // The table direction determines the row direction. In mixed directionality, |
| 516 // we have a common border with the table (think a ltr table with rtl start ce
ll). | 545 // we cannot guarantee that we have a common border with the table (think a |
| 546 // ltr table with rtl start cell). |
| 517 return (isStartColumn && hasSameDirectionAsTable) || | 547 return (isStartColumn && hasSameDirectionAsTable) || |
| 518 (isEndColumn && !hasSameDirectionAsTable); | 548 (isEndColumn && !hasSameDirectionAsTable); |
| 519 } | 549 } |
| 520 | 550 |
| 521 bool LayoutTableCell::hasEndBorderAdjoiningTable() const { | 551 bool LayoutTableCell::hasEndBorderAdjoiningTable() const { |
| 522 bool isStartColumn = !absoluteColumnIndex(); | 552 bool isStartColumn = !absoluteColumnIndex(); |
| 523 bool isEndColumn = table()->absoluteColumnToEffectiveColumn( | 553 bool isEndColumn = table()->absoluteColumnToEffectiveColumn( |
| 524 absoluteColumnIndex() + colSpan() - 1) == | 554 absoluteColumnIndex() + colSpan() - 1) == |
| 525 table()->numEffectiveColumns() - 1; | 555 table()->numEffectiveColumns() - 1; |
| 526 bool hasSameDirectionAsTable = hasSameDirectionAs(table()); | 556 bool hasSameDirectionAsTable = hasSameDirectionAs(table()); |
| 527 | 557 |
| 528 // The table direction determines the row direction. In mixed directionality,
we cannot guarantee that | 558 // The table direction determines the row direction. In mixed directionality, |
| 529 // we have a common border with the table (think a ltr table with ltr end cell
). | 559 // we cannot guarantee that we have a common border with the table (think a |
| 560 // ltr table with ltr end cell). |
| 530 return (isStartColumn && !hasSameDirectionAsTable) || | 561 return (isStartColumn && !hasSameDirectionAsTable) || |
| 531 (isEndColumn && hasSameDirectionAsTable); | 562 (isEndColumn && hasSameDirectionAsTable); |
| 532 } | 563 } |
| 533 | 564 |
| 534 CollapsedBorderValue LayoutTableCell::computeCollapsedStartBorder( | 565 CollapsedBorderValue LayoutTableCell::computeCollapsedStartBorder( |
| 535 IncludeBorderColorOrNot includeColor) const { | 566 IncludeBorderColorOrNot includeColor) const { |
| 536 LayoutTable* table = this->table(); | 567 LayoutTable* table = this->table(); |
| 537 | 568 |
| 538 // For the start border, we need to check, in order of precedence: | 569 // For the start border, we need to check, in order of precedence: |
| 539 // (1) Our start border. | 570 // (1) Our start border. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 554 includeColor ? resolveColor(startColorProperty) : Color(), | 585 includeColor ? resolveColor(startColorProperty) : Color(), |
| 555 BorderPrecedenceCell); | 586 BorderPrecedenceCell); |
| 556 | 587 |
| 557 // (2) The end border of the preceding cell. | 588 // (2) The end border of the preceding cell. |
| 558 LayoutTableCell* cellBefore = table->cellBefore(this); | 589 LayoutTableCell* cellBefore = table->cellBefore(this); |
| 559 if (cellBefore) { | 590 if (cellBefore) { |
| 560 CollapsedBorderValue cellBeforeAdjoiningBorder = CollapsedBorderValue( | 591 CollapsedBorderValue cellBeforeAdjoiningBorder = CollapsedBorderValue( |
| 561 cellBefore->borderAdjoiningCellAfter(this), | 592 cellBefore->borderAdjoiningCellAfter(this), |
| 562 includeColor ? cellBefore->resolveColor(endColorProperty) : Color(), | 593 includeColor ? cellBefore->resolveColor(endColorProperty) : Color(), |
| 563 BorderPrecedenceCell); | 594 BorderPrecedenceCell); |
| 564 // |result| should be the 2nd argument as |cellBefore| should win in case of
equality per CSS 2.1 (Border conflict resolution, point 4). | 595 // |result| should be the 2nd argument as |cellBefore| should win in case of |
| 596 // equality per CSS 2.1 (Border conflict resolution, point 4). |
| 565 result = chooseBorder(cellBeforeAdjoiningBorder, result); | 597 result = chooseBorder(cellBeforeAdjoiningBorder, result); |
| 566 if (!result.exists()) | 598 if (!result.exists()) |
| 567 return result; | 599 return result; |
| 568 } | 600 } |
| 569 | 601 |
| 570 bool startBorderAdjoinsTable = hasStartBorderAdjoiningTable(); | 602 bool startBorderAdjoinsTable = hasStartBorderAdjoiningTable(); |
| 571 if (startBorderAdjoinsTable) { | 603 if (startBorderAdjoinsTable) { |
| 572 // (3) Our row's start border. | 604 // (3) Our row's start border. |
| 573 result = chooseBorder( | 605 result = chooseBorder( |
| 574 result, | 606 result, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 600 CollapsedBorderValue( | 632 CollapsedBorderValue( |
| 601 colAndColGroup.colgroup->borderAdjoiningCellStartBorder(this), | 633 colAndColGroup.colgroup->borderAdjoiningCellStartBorder(this), |
| 602 includeColor | 634 includeColor |
| 603 ? colAndColGroup.colgroup->resolveColor(startColorProperty) | 635 ? colAndColGroup.colgroup->resolveColor(startColorProperty) |
| 604 : Color(), | 636 : Color(), |
| 605 BorderPrecedenceColumnGroup)); | 637 BorderPrecedenceColumnGroup)); |
| 606 if (!result.exists()) | 638 if (!result.exists()) |
| 607 return result; | 639 return result; |
| 608 } | 640 } |
| 609 if (colAndColGroup.col) { | 641 if (colAndColGroup.col) { |
| 610 // Always apply the col's border irrespective of whether this cell touches i
t. This is per HTML5: | 642 // Always apply the col's border irrespective of whether this cell touches |
| 611 // "For the purposes of the CSS table model, the col element is expected to
be treated as if it | 643 // it. This is per HTML5: "For the purposes of the CSS table model, the col |
| 612 // "was present as many times as its span attribute specifies". | 644 // element is expected to be treated as if it "was present as many times as |
| 645 // its span attribute specifies". |
| 613 result = chooseBorder( | 646 result = chooseBorder( |
| 614 result, | 647 result, |
| 615 CollapsedBorderValue( | 648 CollapsedBorderValue( |
| 616 colAndColGroup.col->borderAdjoiningCellStartBorder(this), | 649 colAndColGroup.col->borderAdjoiningCellStartBorder(this), |
| 617 includeColor ? colAndColGroup.col->resolveColor(startColorProperty) | 650 includeColor ? colAndColGroup.col->resolveColor(startColorProperty) |
| 618 : Color(), | 651 : Color(), |
| 619 BorderPrecedenceColumn)); | 652 BorderPrecedenceColumn)); |
| 620 if (!result.exists()) | 653 if (!result.exists()) |
| 621 return result; | 654 return result; |
| 622 } | 655 } |
| 623 | 656 |
| 624 // (6) The end border of the preceding column. | 657 // (6) The end border of the preceding column. |
| 625 if (cellBefore) { | 658 if (cellBefore) { |
| 626 LayoutTable::ColAndColGroup colAndColGroup = | 659 LayoutTable::ColAndColGroup colAndColGroup = |
| 627 table->colElementAtAbsoluteColumn(absoluteColumnIndex() - 1); | 660 table->colElementAtAbsoluteColumn(absoluteColumnIndex() - 1); |
| 628 // Only apply the colgroup's border if this cell touches the colgroup edge. | 661 // Only apply the colgroup's border if this cell touches the colgroup edge. |
| 629 if (colAndColGroup.colgroup && colAndColGroup.adjoinsEndBorderOfColGroup) { | 662 if (colAndColGroup.colgroup && colAndColGroup.adjoinsEndBorderOfColGroup) { |
| 630 result = chooseBorder( | 663 result = chooseBorder( |
| 631 CollapsedBorderValue( | 664 CollapsedBorderValue( |
| 632 colAndColGroup.colgroup->borderAdjoiningCellEndBorder(this), | 665 colAndColGroup.colgroup->borderAdjoiningCellEndBorder(this), |
| 633 includeColor | 666 includeColor |
| 634 ? colAndColGroup.colgroup->resolveColor(endColorProperty) | 667 ? colAndColGroup.colgroup->resolveColor(endColorProperty) |
| 635 : Color(), | 668 : Color(), |
| 636 BorderPrecedenceColumnGroup), | 669 BorderPrecedenceColumnGroup), |
| 637 result); | 670 result); |
| 638 if (!result.exists()) | 671 if (!result.exists()) |
| 639 return result; | 672 return result; |
| 640 } | 673 } |
| 641 // Always apply the col's border irrespective of whether this cell touches i
t. This is per HTML5: | 674 // Always apply the col's border irrespective of whether this cell touches |
| 642 // "For the purposes of the CSS table model, the col element is expected to
be treated as if it | 675 // it. This is per HTML5: "For the purposes of the CSS table model, the col |
| 643 // "was present as many times as its span attribute specifies". | 676 // element is expected to be treated as if it "was present as many times as |
| 677 // its span attribute specifies". |
| 644 if (colAndColGroup.col) { | 678 if (colAndColGroup.col) { |
| 645 result = chooseBorder( | 679 result = chooseBorder( |
| 646 CollapsedBorderValue( | 680 CollapsedBorderValue( |
| 647 colAndColGroup.col->borderAdjoiningCellAfter(this), | 681 colAndColGroup.col->borderAdjoiningCellAfter(this), |
| 648 includeColor ? colAndColGroup.col->resolveColor(endColorProperty) | 682 includeColor ? colAndColGroup.col->resolveColor(endColorProperty) |
| 649 : Color(), | 683 : Color(), |
| 650 BorderPrecedenceColumn), | 684 BorderPrecedenceColumn), |
| 651 result); | 685 result); |
| 652 if (!result.exists()) | 686 if (!result.exists()) |
| 653 return result; | 687 return result; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 665 if (!result.exists()) | 699 if (!result.exists()) |
| 666 return result; | 700 return result; |
| 667 } | 701 } |
| 668 | 702 |
| 669 return result; | 703 return result; |
| 670 } | 704 } |
| 671 | 705 |
| 672 CollapsedBorderValue LayoutTableCell::computeCollapsedEndBorder( | 706 CollapsedBorderValue LayoutTableCell::computeCollapsedEndBorder( |
| 673 IncludeBorderColorOrNot includeColor) const { | 707 IncludeBorderColorOrNot includeColor) const { |
| 674 LayoutTable* table = this->table(); | 708 LayoutTable* table = this->table(); |
| 675 // Note: We have to use the effective column information instead of whether we
have a cell after as a table doesn't | 709 // Note: We have to use the effective column information instead of whether we |
| 676 // have to be regular (any row can have less cells than the total cell count). | 710 // have a cell after as a table doesn't have to be regular (any row can have |
| 711 // less cells than the total cell count). |
| 677 bool isEndColumn = table->absoluteColumnToEffectiveColumn( | 712 bool isEndColumn = table->absoluteColumnToEffectiveColumn( |
| 678 absoluteColumnIndex() + colSpan() - 1) == | 713 absoluteColumnIndex() + colSpan() - 1) == |
| 679 table->numEffectiveColumns() - 1; | 714 table->numEffectiveColumns() - 1; |
| 680 | 715 |
| 681 // For end border, we need to check, in order of precedence: | 716 // For end border, we need to check, in order of precedence: |
| 682 // (1) Our end border. | 717 // (1) Our end border. |
| 683 int startColorProperty = includeColor | 718 int startColorProperty = includeColor |
| 684 ? CSSProperty::resolveDirectionAwareProperty( | 719 ? CSSProperty::resolveDirectionAwareProperty( |
| 685 CSSPropertyWebkitBorderStartColor, | 720 CSSPropertyWebkitBorderStartColor, |
| 686 styleForCellFlow().direction(), | 721 styleForCellFlow().direction(), |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 CollapsedBorderValue( | 778 CollapsedBorderValue( |
| 744 colAndColGroup.colgroup->borderAdjoiningCellEndBorder(this), | 779 colAndColGroup.colgroup->borderAdjoiningCellEndBorder(this), |
| 745 includeColor | 780 includeColor |
| 746 ? colAndColGroup.colgroup->resolveColor(endColorProperty) | 781 ? colAndColGroup.colgroup->resolveColor(endColorProperty) |
| 747 : Color(), | 782 : Color(), |
| 748 BorderPrecedenceColumnGroup)); | 783 BorderPrecedenceColumnGroup)); |
| 749 if (!result.exists()) | 784 if (!result.exists()) |
| 750 return result; | 785 return result; |
| 751 } | 786 } |
| 752 if (colAndColGroup.col) { | 787 if (colAndColGroup.col) { |
| 753 // Always apply the col's border irrespective of whether this cell touches i
t. This is per HTML5: | 788 // Always apply the col's border irrespective of whether this cell touches |
| 754 // "For the purposes of the CSS table model, the col element is expected to
be treated as if it | 789 // it. This is per HTML5: "For the purposes of the CSS table model, the col |
| 755 // "was present as many times as its span attribute specifies". | 790 // element is expected to be treated as if it "was present as many times as |
| 791 // its span attribute specifies". |
| 756 result = chooseBorder( | 792 result = chooseBorder( |
| 757 result, | 793 result, |
| 758 CollapsedBorderValue( | 794 CollapsedBorderValue( |
| 759 colAndColGroup.col->borderAdjoiningCellEndBorder(this), | 795 colAndColGroup.col->borderAdjoiningCellEndBorder(this), |
| 760 includeColor ? colAndColGroup.col->resolveColor(endColorProperty) | 796 includeColor ? colAndColGroup.col->resolveColor(endColorProperty) |
| 761 : Color(), | 797 : Color(), |
| 762 BorderPrecedenceColumn)); | 798 BorderPrecedenceColumn)); |
| 763 if (!result.exists()) | 799 if (!result.exists()) |
| 764 return result; | 800 return result; |
| 765 } | 801 } |
| 766 | 802 |
| 767 // (6) The start border of the next column. | 803 // (6) The start border of the next column. |
| 768 if (!isEndColumn) { | 804 if (!isEndColumn) { |
| 769 LayoutTable::ColAndColGroup colAndColGroup = | 805 LayoutTable::ColAndColGroup colAndColGroup = |
| 770 table->colElementAtAbsoluteColumn(absoluteColumnIndex() + colSpan()); | 806 table->colElementAtAbsoluteColumn(absoluteColumnIndex() + colSpan()); |
| 771 if (colAndColGroup.colgroup && | 807 if (colAndColGroup.colgroup && |
| 772 colAndColGroup.adjoinsStartBorderOfColGroup) { | 808 colAndColGroup.adjoinsStartBorderOfColGroup) { |
| 773 // Only apply the colgroup's border if this cell touches the colgroup edge
. | 809 // Only apply the colgroup's border if this cell touches the colgroup |
| 810 // edge. |
| 774 result = chooseBorder( | 811 result = chooseBorder( |
| 775 result, | 812 result, |
| 776 CollapsedBorderValue( | 813 CollapsedBorderValue( |
| 777 colAndColGroup.colgroup->borderAdjoiningCellStartBorder(this), | 814 colAndColGroup.colgroup->borderAdjoiningCellStartBorder(this), |
| 778 includeColor | 815 includeColor |
| 779 ? colAndColGroup.colgroup->resolveColor(startColorProperty) | 816 ? colAndColGroup.colgroup->resolveColor(startColorProperty) |
| 780 : Color(), | 817 : Color(), |
| 781 BorderPrecedenceColumnGroup)); | 818 BorderPrecedenceColumnGroup)); |
| 782 if (!result.exists()) | 819 if (!result.exists()) |
| 783 return result; | 820 return result; |
| 784 } | 821 } |
| 785 if (colAndColGroup.col) { | 822 if (colAndColGroup.col) { |
| 786 // Always apply the col's border irrespective of whether this cell touches
it. This is per HTML5: | 823 // Always apply the col's border irrespective of whether this cell touches |
| 787 // "For the purposes of the CSS table model, the col element is expected t
o be treated as if it | 824 // it. This is per HTML5: "For the purposes of the CSS table model, the |
| 788 // "was present as many times as its span attribute specifies". | 825 // col element is expected to be treated as if it "was present as many |
| 826 // times as its span attribute specifies". |
| 789 result = chooseBorder( | 827 result = chooseBorder( |
| 790 result, CollapsedBorderValue( | 828 result, CollapsedBorderValue( |
| 791 colAndColGroup.col->borderAdjoiningCellBefore(this), | 829 colAndColGroup.col->borderAdjoiningCellBefore(this), |
| 792 includeColor | 830 includeColor |
| 793 ? colAndColGroup.col->resolveColor(startColorProperty) | 831 ? colAndColGroup.col->resolveColor(startColorProperty) |
| 794 : Color(), | 832 : Color(), |
| 795 BorderPrecedenceColumn)); | 833 BorderPrecedenceColumn)); |
| 796 if (!result.exists()) | 834 if (!result.exists()) |
| 797 return result; | 835 return result; |
| 798 } | 836 } |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1095 int LayoutTableCell::borderTop() const { | 1133 int LayoutTableCell::borderTop() const { |
| 1096 return table()->collapseBorders() ? borderHalfTop(false) | 1134 return table()->collapseBorders() ? borderHalfTop(false) |
| 1097 : LayoutBlockFlow::borderTop(); | 1135 : LayoutBlockFlow::borderTop(); |
| 1098 } | 1136 } |
| 1099 | 1137 |
| 1100 int LayoutTableCell::borderBottom() const { | 1138 int LayoutTableCell::borderBottom() const { |
| 1101 return table()->collapseBorders() ? borderHalfBottom(false) | 1139 return table()->collapseBorders() ? borderHalfBottom(false) |
| 1102 : LayoutBlockFlow::borderBottom(); | 1140 : LayoutBlockFlow::borderBottom(); |
| 1103 } | 1141 } |
| 1104 | 1142 |
| 1105 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=46191, make the collapsed bord
er drawing | 1143 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=46191, make the collapsed |
| 1106 // work with different block flow values instead of being hard-coded to top-to-b
ottom. | 1144 // border drawing work with different block flow values instead of being |
| 1145 // hard-coded to top-to-bottom. |
| 1107 int LayoutTableCell::borderStart() const { | 1146 int LayoutTableCell::borderStart() const { |
| 1108 return table()->collapseBorders() ? borderHalfStart(false) | 1147 return table()->collapseBorders() ? borderHalfStart(false) |
| 1109 : LayoutBlockFlow::borderStart(); | 1148 : LayoutBlockFlow::borderStart(); |
| 1110 } | 1149 } |
| 1111 | 1150 |
| 1112 int LayoutTableCell::borderEnd() const { | 1151 int LayoutTableCell::borderEnd() const { |
| 1113 return table()->collapseBorders() ? borderHalfEnd(false) | 1152 return table()->collapseBorders() ? borderHalfEnd(false) |
| 1114 : LayoutBlockFlow::borderEnd(); | 1153 : LayoutBlockFlow::borderEnd(); |
| 1115 } | 1154 } |
| 1116 | 1155 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1231 bool changed = false; | 1270 bool changed = false; |
| 1232 if (!newValues.startBorder.isVisible() && !newValues.endBorder.isVisible() && | 1271 if (!newValues.startBorder.isVisible() && !newValues.endBorder.isVisible() && |
| 1233 !newValues.beforeBorder.isVisible() && | 1272 !newValues.beforeBorder.isVisible() && |
| 1234 !newValues.afterBorder.isVisible()) { | 1273 !newValues.afterBorder.isVisible()) { |
| 1235 changed = !!m_collapsedBorderValues; | 1274 changed = !!m_collapsedBorderValues; |
| 1236 m_collapsedBorderValues = nullptr; | 1275 m_collapsedBorderValues = nullptr; |
| 1237 } else if (!m_collapsedBorderValues) { | 1276 } else if (!m_collapsedBorderValues) { |
| 1238 changed = true; | 1277 changed = true; |
| 1239 m_collapsedBorderValues = wrapUnique(new CollapsedBorderValues(newValues)); | 1278 m_collapsedBorderValues = wrapUnique(new CollapsedBorderValues(newValues)); |
| 1240 } else { | 1279 } else { |
| 1241 // We check visuallyEquals so that the table cell is invalidated only if a c
hanged | 1280 // We check visuallyEquals so that the table cell is invalidated only if a |
| 1242 // collapsed border is visible in the first place. | 1281 // changed collapsed border is visible in the first place. |
| 1243 changed = !m_collapsedBorderValues->startBorder.visuallyEquals( | 1282 changed = !m_collapsedBorderValues->startBorder.visuallyEquals( |
| 1244 newValues.startBorder) || | 1283 newValues.startBorder) || |
| 1245 !m_collapsedBorderValues->endBorder.visuallyEquals( | 1284 !m_collapsedBorderValues->endBorder.visuallyEquals( |
| 1246 newValues.endBorder) || | 1285 newValues.endBorder) || |
| 1247 !m_collapsedBorderValues->beforeBorder.visuallyEquals( | 1286 !m_collapsedBorderValues->beforeBorder.visuallyEquals( |
| 1248 newValues.beforeBorder) || | 1287 newValues.beforeBorder) || |
| 1249 !m_collapsedBorderValues->afterBorder.visuallyEquals( | 1288 !m_collapsedBorderValues->afterBorder.visuallyEquals( |
| 1250 newValues.afterBorder); | 1289 newValues.afterBorder); |
| 1251 if (changed) | 1290 if (changed) |
| 1252 *m_collapsedBorderValues = newValues; | 1291 *m_collapsedBorderValues = newValues; |
| 1253 } | 1292 } |
| 1254 | 1293 |
| 1255 // If collapsed borders changed, invalidate the cell's display item client on
the table's backing. | 1294 // If collapsed borders changed, invalidate the cell's display item client on |
| 1256 // TODO(crbug.com/451090#c5): Need a way to invalidate/repaint the borders onl
y. | 1295 // the table's backing. |
| 1296 // TODO(crbug.com/451090#c5): Need a way to invalidate/repaint the borders |
| 1297 // only. |
| 1257 if (changed) | 1298 if (changed) |
| 1258 ObjectPaintInvalidator(*table()) | 1299 ObjectPaintInvalidator(*table()) |
| 1259 .slowSetPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient( | 1300 .slowSetPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient( |
| 1260 *this, PaintInvalidationStyleChange); | 1301 *this, PaintInvalidationStyleChange); |
| 1261 | 1302 |
| 1262 addBorderStyle(borderValues, newValues.startBorder); | 1303 addBorderStyle(borderValues, newValues.startBorder); |
| 1263 addBorderStyle(borderValues, newValues.endBorder); | 1304 addBorderStyle(borderValues, newValues.endBorder); |
| 1264 addBorderStyle(borderValues, newValues.beforeBorder); | 1305 addBorderStyle(borderValues, newValues.beforeBorder); |
| 1265 addBorderStyle(borderValues, newValues.afterBorder); | 1306 addBorderStyle(borderValues, newValues.afterBorder); |
| 1266 } | 1307 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1285 BackgroundBleedAvoidance, | 1326 BackgroundBleedAvoidance, |
| 1286 const InlineFlowBox*) const { | 1327 const InlineFlowBox*) const { |
| 1287 return false; | 1328 return false; |
| 1288 } | 1329 } |
| 1289 | 1330 |
| 1290 void LayoutTableCell::scrollbarsChanged(bool horizontalScrollbarChanged, | 1331 void LayoutTableCell::scrollbarsChanged(bool horizontalScrollbarChanged, |
| 1291 bool verticalScrollbarChanged) { | 1332 bool verticalScrollbarChanged) { |
| 1292 LayoutBlock::scrollbarsChanged(horizontalScrollbarChanged, | 1333 LayoutBlock::scrollbarsChanged(horizontalScrollbarChanged, |
| 1293 verticalScrollbarChanged); | 1334 verticalScrollbarChanged); |
| 1294 int scrollbarHeight = scrollbarLogicalHeight(); | 1335 int scrollbarHeight = scrollbarLogicalHeight(); |
| 1336 // Not sure if we should be doing something when a scrollbar goes away or not. |
| 1295 if (!scrollbarHeight) | 1337 if (!scrollbarHeight) |
| 1296 return; // Not sure if we should be doing something when a scrollbar goes a
way or not. | 1338 return; |
| 1297 | 1339 |
| 1298 // We only care if the scrollbar that affects our intrinsic padding has been a
dded. | 1340 // We only care if the scrollbar that affects our intrinsic padding has been |
| 1341 // added. |
| 1299 if ((isHorizontalWritingMode() && !horizontalScrollbarChanged) || | 1342 if ((isHorizontalWritingMode() && !horizontalScrollbarChanged) || |
| 1300 (!isHorizontalWritingMode() && !verticalScrollbarChanged)) | 1343 (!isHorizontalWritingMode() && !verticalScrollbarChanged)) |
| 1301 return; | 1344 return; |
| 1302 | 1345 |
| 1303 // Shrink our intrinsic padding as much as possible to accommodate the scrollb
ar. | 1346 // Shrink our intrinsic padding as much as possible to accommodate the |
| 1347 // scrollbar. |
| 1304 if (style()->verticalAlign() == VerticalAlignMiddle) { | 1348 if (style()->verticalAlign() == VerticalAlignMiddle) { |
| 1305 LayoutUnit totalHeight = logicalHeight(); | 1349 LayoutUnit totalHeight = logicalHeight(); |
| 1306 LayoutUnit heightWithoutIntrinsicPadding = | 1350 LayoutUnit heightWithoutIntrinsicPadding = |
| 1307 totalHeight - intrinsicPaddingBefore() - intrinsicPaddingAfter(); | 1351 totalHeight - intrinsicPaddingBefore() - intrinsicPaddingAfter(); |
| 1308 totalHeight -= scrollbarHeight; | 1352 totalHeight -= scrollbarHeight; |
| 1309 LayoutUnit newBeforePadding = | 1353 LayoutUnit newBeforePadding = |
| 1310 (totalHeight - heightWithoutIntrinsicPadding) / 2; | 1354 (totalHeight - heightWithoutIntrinsicPadding) / 2; |
| 1311 LayoutUnit newAfterPadding = | 1355 LayoutUnit newAfterPadding = |
| 1312 totalHeight - heightWithoutIntrinsicPadding - newBeforePadding; | 1356 totalHeight - heightWithoutIntrinsicPadding - newBeforePadding; |
| 1313 setIntrinsicPaddingBefore(newBeforePadding.toInt()); | 1357 setIntrinsicPaddingBefore(newBeforePadding.toInt()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1329 LayoutTableCell::createAnonymous(&parent->document()); | 1373 LayoutTableCell::createAnonymous(&parent->document()); |
| 1330 RefPtr<ComputedStyle> newStyle = | 1374 RefPtr<ComputedStyle> newStyle = |
| 1331 ComputedStyle::createAnonymousStyleWithDisplay(parent->styleRef(), | 1375 ComputedStyle::createAnonymousStyleWithDisplay(parent->styleRef(), |
| 1332 EDisplay::TableCell); | 1376 EDisplay::TableCell); |
| 1333 newCell->setStyle(newStyle.release()); | 1377 newCell->setStyle(newStyle.release()); |
| 1334 return newCell; | 1378 return newCell; |
| 1335 } | 1379 } |
| 1336 | 1380 |
| 1337 bool LayoutTableCell::backgroundIsKnownToBeOpaqueInRect( | 1381 bool LayoutTableCell::backgroundIsKnownToBeOpaqueInRect( |
| 1338 const LayoutRect& localRect) const { | 1382 const LayoutRect& localRect) const { |
| 1339 // If this object has layer, the area of collapsed borders should be transpare
nt | 1383 // If this object has layer, the area of collapsed borders should be |
| 1340 // to expose the collapsed borders painted on the underlying layer. | 1384 // transparent to expose the collapsed borders painted on the underlying |
| 1385 // layer. |
| 1341 if (hasLayer() && table()->collapseBorders()) | 1386 if (hasLayer() && table()->collapseBorders()) |
| 1342 return false; | 1387 return false; |
| 1343 return LayoutBlockFlow::backgroundIsKnownToBeOpaqueInRect(localRect); | 1388 return LayoutBlockFlow::backgroundIsKnownToBeOpaqueInRect(localRect); |
| 1344 } | 1389 } |
| 1345 | 1390 |
| 1346 // TODO(lunalu): Deliberately dump the "inner" box of table cells, since that | 1391 // TODO(lunalu): Deliberately dump the "inner" box of table cells, since that |
| 1347 // is what current results reflect. We'd like to clean up the results to dump | 1392 // is what current results reflect. We'd like to clean up the results to dump |
| 1348 // both the outer box and the intrinsic padding so that both bits of | 1393 // both the outer box and the intrinsic padding so that both bits of information |
| 1349 // information are captured by the results. | 1394 // are captured by the results. |
| 1350 LayoutRect LayoutTableCell::debugRect() const { | 1395 LayoutRect LayoutTableCell::debugRect() const { |
| 1351 LayoutRect rect = LayoutRect( | 1396 LayoutRect rect = LayoutRect( |
| 1352 location().x(), location().y() + intrinsicPaddingBefore(), size().width(), | 1397 location().x(), location().y() + intrinsicPaddingBefore(), size().width(), |
| 1353 size().height() - intrinsicPaddingBefore() - intrinsicPaddingAfter()); | 1398 size().height() - intrinsicPaddingBefore() - intrinsicPaddingAfter()); |
| 1354 | 1399 |
| 1355 LayoutBlock* cb = containingBlock(); | 1400 LayoutBlock* cb = containingBlock(); |
| 1356 if (cb) | 1401 if (cb) |
| 1357 cb->adjustChildDebugRect(rect); | 1402 cb->adjustChildDebugRect(rect); |
| 1358 | 1403 |
| 1359 return rect; | 1404 return rect; |
| 1360 } | 1405 } |
| 1361 | 1406 |
| 1362 void LayoutTableCell::adjustChildDebugRect(LayoutRect& r) const { | 1407 void LayoutTableCell::adjustChildDebugRect(LayoutRect& r) const { |
| 1363 r.move(0, -intrinsicPaddingBefore()); | 1408 r.move(0, -intrinsicPaddingBefore()); |
| 1364 } | 1409 } |
| 1365 | 1410 |
| 1366 } // namespace blink | 1411 } // namespace blink |
| OLD | NEW |