| 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. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. |
| 8 * All rights reserved. | 8 * All rights reserved. |
| 9 * | 9 * |
| 10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 LayoutSize LayoutTableCell::OffsetFromContainer(const LayoutObject* o) const { | 402 LayoutSize LayoutTableCell::OffsetFromContainer(const LayoutObject* o) const { |
| 403 DCHECK_EQ(o, Container()); | 403 DCHECK_EQ(o, Container()); |
| 404 | 404 |
| 405 LayoutSize offset = LayoutBlockFlow::OffsetFromContainer(o); | 405 LayoutSize offset = LayoutBlockFlow::OffsetFromContainer(o); |
| 406 if (Parent()) | 406 if (Parent()) |
| 407 offset -= ParentBox()->PhysicalLocationOffset(); | 407 offset -= ParentBox()->PhysicalLocationOffset(); |
| 408 | 408 |
| 409 return offset; | 409 return offset; |
| 410 } | 410 } |
| 411 | 411 |
| 412 LayoutRect LayoutTableCell::LocalVisualRect() const { | 412 void LayoutTableCell::ComputeOverflow(LayoutUnit old_client_after_edge, |
| 413 // If the table grid is dirty, we cannot get reliable information about | 413 bool recompute_floats) { |
| 414 // adjoining cells, so we ignore outside borders. This should not be a problem | 414 LayoutBlockFlow::ComputeOverflow(old_client_after_edge, recompute_floats); |
| 415 // because it means that the table is going to recalculate the grid, relayout | |
| 416 // and issue a paint invalidation of its current rect, which includes any | |
| 417 // outside borders of this cell. | |
| 418 if (!Table()->ShouldCollapseBorders() || Table()->NeedsSectionRecalc()) | |
| 419 return LayoutBlockFlow::LocalVisualRect(); | |
| 420 | 415 |
| 416 UpdateCollapsedBorderValues(); |
| 417 if (!collapsed_border_values_) |
| 418 return; |
| 419 |
| 420 // Calculate local visual rect of collapsed borders. |
| 421 // Our border rect already includes the inner halves of the collapsed borders, |
| 422 // so here we get the outer halves. |
| 421 bool rtl = !StyleForCellFlow().IsLeftToRightDirection(); | 423 bool rtl = !StyleForCellFlow().IsLeftToRightDirection(); |
| 422 LayoutUnit outline_outset(Style()->OutlineOutsetExtent()); | 424 LayoutUnit left = CollapsedBorderHalfLeft(true); |
| 423 LayoutUnit left(std::max(CollapsedBorderHalfLeft(true), outline_outset)); | 425 LayoutUnit right = CollapsedBorderHalfRight(true); |
| 424 LayoutUnit right(std::max(CollapsedBorderHalfRight(true), outline_outset)); | 426 LayoutUnit top = CollapsedBorderHalfTop(true); |
| 425 LayoutUnit top(std::max(CollapsedBorderHalfTop(true), outline_outset)); | 427 LayoutUnit bottom = CollapsedBorderHalfBottom(true); |
| 426 LayoutUnit bottom(std::max(CollapsedBorderHalfBottom(true), outline_outset)); | 428 |
| 429 // This cell's borders may be lengthened to match the widths of orthogonal |
| 430 // borders of adjacent cells. Expand visual overflow to cover the lengthened |
| 431 // parts. |
| 427 if ((left && !rtl) || (right && rtl)) { | 432 if ((left && !rtl) || (right && rtl)) { |
| 428 if (LayoutTableCell* before = Table()->CellBefore(this)) { | 433 if (LayoutTableCell* before = Table()->CellBefore(this)) { |
| 429 top = std::max(top, before->CollapsedBorderHalfTop(true)); | 434 top = std::max(top, before->CollapsedBorderHalfTop(true)); |
| 430 bottom = std::max(bottom, before->CollapsedBorderHalfBottom(true)); | 435 bottom = std::max(bottom, before->CollapsedBorderHalfBottom(true)); |
| 431 } | 436 } |
| 432 } | 437 } |
| 433 if ((left && rtl) || (right && !rtl)) { | 438 if ((left && rtl) || (right && !rtl)) { |
| 434 if (LayoutTableCell* after = Table()->CellAfter(this)) { | 439 if (LayoutTableCell* after = Table()->CellAfter(this)) { |
| 435 top = std::max(top, after->CollapsedBorderHalfTop(true)); | 440 top = std::max(top, after->CollapsedBorderHalfTop(true)); |
| 436 bottom = std::max(bottom, after->CollapsedBorderHalfBottom(true)); | 441 bottom = std::max(bottom, after->CollapsedBorderHalfBottom(true)); |
| 437 } | 442 } |
| 438 } | 443 } |
| 439 if (top) { | 444 if (top) { |
| 440 if (LayoutTableCell* above = Table()->CellAbove(this)) { | 445 if (LayoutTableCell* above = Table()->CellAbove(this)) { |
| 441 left = std::max(left, above->CollapsedBorderHalfLeft(true)); | 446 left = std::max(left, above->CollapsedBorderHalfLeft(true)); |
| 442 right = std::max(right, above->CollapsedBorderHalfRight(true)); | 447 right = std::max(right, above->CollapsedBorderHalfRight(true)); |
| 443 } | 448 } |
| 444 } | 449 } |
| 445 if (bottom) { | 450 if (bottom) { |
| 446 if (LayoutTableCell* below = Table()->CellBelow(this)) { | 451 if (LayoutTableCell* below = Table()->CellBelow(this)) { |
| 447 left = std::max(left, below->CollapsedBorderHalfLeft(true)); | 452 left = std::max(left, below->CollapsedBorderHalfLeft(true)); |
| 448 right = std::max(right, below->CollapsedBorderHalfRight(true)); | 453 right = std::max(right, below->CollapsedBorderHalfRight(true)); |
| 449 } | 454 } |
| 450 } | 455 } |
| 451 | 456 |
| 452 LayoutRect self_visual_overflow_rect = this->SelfVisualOverflowRect(); | 457 LayoutRect rect = BorderBoxRect(); |
| 453 LayoutPoint location( | 458 rect.ExpandEdges(top, right, bottom, left); |
| 454 std::max(LayoutUnit(left), -self_visual_overflow_rect.X()), | 459 collapsed_border_values_->SetLocalVisualRect(rect); |
| 455 std::max(LayoutUnit(top), -self_visual_overflow_rect.Y())); | 460 } |
| 456 return LayoutRect(-location.X(), -location.Y(), | 461 |
| 457 location.X() + std::max(Size().Width() + right, | 462 LayoutRect LayoutTableCell::LocalVisualRect() const { |
| 458 self_visual_overflow_rect.MaxX()), | 463 LayoutRect rect = SelfVisualOverflowRect(); |
| 459 location.Y() + std::max(Size().Height() + bottom, | 464 if (collapsed_border_values_) |
| 460 self_visual_overflow_rect.MaxY())); | 465 rect.Unite(collapsed_border_values_->LocalVisualRect()); |
| 466 return rect; |
| 461 } | 467 } |
| 462 | 468 |
| 463 int LayoutTableCell::CellBaselinePosition() const { | 469 int LayoutTableCell::CellBaselinePosition() const { |
| 464 // <http://www.w3.org/TR/2007/CR-CSS21-20070719/tables.html#height-layout>: | 470 // <http://www.w3.org/TR/2007/CR-CSS21-20070719/tables.html#height-layout>: |
| 465 // The baseline of a cell is the baseline of the first in-flow line box in the | 471 // The baseline of a cell is the baseline of the first in-flow line box in the |
| 466 // cell, or the first in-flow table-row in the cell, whichever comes first. If | 472 // cell, or the first in-flow table-row in the cell, whichever comes first. If |
| 467 // there is no such line box or table-row, the baseline is the bottom of | 473 // there is no such line box or table-row, the baseline is the bottom of |
| 468 // content edge of the cell box. | 474 // content edge of the cell box. |
| 469 int first_line_baseline = FirstLineBoxBaseline(); | 475 int first_line_baseline = FirstLineBoxBaseline(); |
| 470 if (first_line_baseline != -1) | 476 if (first_line_baseline != -1) |
| (...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1255 } | 1261 } |
| 1256 return LayoutUnit(); | 1262 return LayoutUnit(); |
| 1257 } | 1263 } |
| 1258 | 1264 |
| 1259 void LayoutTableCell::Paint(const PaintInfo& paint_info, | 1265 void LayoutTableCell::Paint(const PaintInfo& paint_info, |
| 1260 const LayoutPoint& paint_offset) const { | 1266 const LayoutPoint& paint_offset) const { |
| 1261 TableCellPainter(*this).Paint(paint_info, paint_offset); | 1267 TableCellPainter(*this).Paint(paint_info, paint_offset); |
| 1262 } | 1268 } |
| 1263 | 1269 |
| 1264 void LayoutTableCell::UpdateCollapsedBorderValues() const { | 1270 void LayoutTableCell::UpdateCollapsedBorderValues() const { |
| 1265 Table()->InvalidateCollapsedBordersForAllCellsIfNeeded(); | |
| 1266 if (collapsed_border_values_valid_) | |
| 1267 return; | |
| 1268 | |
| 1269 collapsed_border_values_valid_ = true; | |
| 1270 | |
| 1271 if (!Table()->ShouldCollapseBorders()) { | 1271 if (!Table()->ShouldCollapseBorders()) { |
| 1272 if (collapsed_border_values_) { | 1272 if (collapsed_border_values_) { |
| 1273 collapsed_borders_visually_changed_ = true; | 1273 collapsed_borders_visually_changed_ = true; |
| 1274 collapsed_border_values_ = nullptr; | 1274 collapsed_border_values_ = nullptr; |
| 1275 } | 1275 } |
| 1276 return; | 1276 return; |
| 1277 } | 1277 } |
| 1278 | 1278 |
| 1279 Table()->InvalidateCollapsedBordersForAllCellsIfNeeded(); |
| 1280 if (collapsed_border_values_valid_) |
| 1281 return; |
| 1282 |
| 1283 collapsed_border_values_valid_ = true; |
| 1284 |
| 1279 CollapsedBorderValues new_values( | 1285 CollapsedBorderValues new_values( |
| 1280 *this, ComputeCollapsedStartBorder(), ComputeCollapsedEndBorder(), | 1286 *this, ComputeCollapsedStartBorder(), ComputeCollapsedEndBorder(), |
| 1281 ComputeCollapsedBeforeBorder(), ComputeCollapsedAfterBorder()); | 1287 ComputeCollapsedBeforeBorder(), ComputeCollapsedAfterBorder()); |
| 1282 | 1288 |
| 1283 // We need to save collapsed border if has a non-zero width even if it's | 1289 // We need to save collapsed border if has a non-zero width even if it's |
| 1284 // invisible because the width affects table layout. | 1290 // invisible because the width affects table layout. |
| 1285 if (!new_values.StartBorder().Width() && !new_values.EndBorder().Width() && | 1291 if (!new_values.StartBorder().Width() && !new_values.EndBorder().Width() && |
| 1286 !new_values.BeforeBorder().Width() && !new_values.AfterBorder().Width()) { | 1292 !new_values.BeforeBorder().Width() && !new_values.AfterBorder().Width()) { |
| 1287 if (collapsed_border_values_) { | 1293 if (collapsed_border_values_) { |
| 1288 collapsed_borders_visually_changed_ = true; | 1294 collapsed_borders_visually_changed_ = true; |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1477 | 1483 |
| 1478 return LayoutBlock::HasLineIfEmpty(); | 1484 return LayoutBlock::HasLineIfEmpty(); |
| 1479 } | 1485 } |
| 1480 | 1486 |
| 1481 PaintInvalidationReason LayoutTableCell::InvalidatePaint( | 1487 PaintInvalidationReason LayoutTableCell::InvalidatePaint( |
| 1482 const PaintInvalidatorContext& context) const { | 1488 const PaintInvalidatorContext& context) const { |
| 1483 return TableCellPaintInvalidator(*this, context).InvalidatePaint(); | 1489 return TableCellPaintInvalidator(*this, context).InvalidatePaint(); |
| 1484 } | 1490 } |
| 1485 | 1491 |
| 1486 } // namespace blink | 1492 } // namespace blink |
| OLD | NEW |