| 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, 2013 Apple Inc.
All rights reserved. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc.
All rights reserved. |
| 8 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 8 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
| 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 13 matching lines...) Expand all Loading... |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "core/rendering/RenderTable.h" | 27 #include "core/rendering/RenderTable.h" |
| 28 | 28 |
| 29 #include "core/HTMLNames.h" | 29 #include "core/HTMLNames.h" |
| 30 #include "core/dom/Document.h" | 30 #include "core/dom/Document.h" |
| 31 #include "core/frame/FrameView.h" | 31 #include "core/frame/FrameView.h" |
| 32 #include "core/html/HTMLTableElement.h" | 32 #include "core/html/HTMLTableElement.h" |
| 33 #include "core/paint/BoxPainter.h" | 33 #include "core/paint/BoxPainter.h" |
| 34 #include "core/paint/TablePainter.h" |
| 34 #include "core/rendering/AutoTableLayout.h" | 35 #include "core/rendering/AutoTableLayout.h" |
| 35 #include "core/rendering/FixedTableLayout.h" | 36 #include "core/rendering/FixedTableLayout.h" |
| 36 #include "core/rendering/GraphicsContextAnnotator.h" | 37 #include "core/rendering/GraphicsContextAnnotator.h" |
| 37 #include "core/rendering/HitTestResult.h" | 38 #include "core/rendering/HitTestResult.h" |
| 38 #include "core/rendering/RenderLayer.h" | 39 #include "core/rendering/RenderLayer.h" |
| 39 #include "core/rendering/RenderTableCaption.h" | 40 #include "core/rendering/RenderTableCaption.h" |
| 40 #include "core/rendering/RenderTableCell.h" | 41 #include "core/rendering/RenderTableCell.h" |
| 41 #include "core/rendering/RenderTableCol.h" | 42 #include "core/rendering/RenderTableCol.h" |
| 42 #include "core/rendering/RenderTableSection.h" | 43 #include "core/rendering/RenderTableSection.h" |
| 43 #include "core/rendering/RenderView.h" | 44 #include "core/rendering/RenderView.h" |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 for (RenderTableRow* row = toRenderTableSection(section)->firstRow(); ro
w; row = row->nextRow()) { | 580 for (RenderTableRow* row = toRenderTableSection(section)->firstRow(); ro
w; row = row->nextRow()) { |
| 580 for (RenderTableCell* cell = row->firstCell(); cell; cell = cell->ne
xtCell()) { | 581 for (RenderTableCell* cell = row->firstCell(); cell; cell = cell->ne
xtCell()) { |
| 581 ASSERT(cell->table() == this); | 582 ASSERT(cell->table() == this); |
| 582 cell->collectBorderValues(m_collapsedBorders); | 583 cell->collectBorderValues(m_collapsedBorders); |
| 583 } | 584 } |
| 584 } | 585 } |
| 585 } | 586 } |
| 586 RenderTableCell::sortBorderValues(m_collapsedBorders); | 587 RenderTableCell::sortBorderValues(m_collapsedBorders); |
| 587 } | 588 } |
| 588 | 589 |
| 589 | |
| 590 void RenderTable::addOverflowFromChildren() | 590 void RenderTable::addOverflowFromChildren() |
| 591 { | 591 { |
| 592 // Add overflow from borders. | 592 // Add overflow from borders. |
| 593 // Technically it's odd that we are incorporating the borders into layout ov
erflow, which is only supposed to be about overflow from our | 593 // Technically it's odd that we are incorporating the borders into layout ov
erflow, which is only supposed to be about overflow from our |
| 594 // descendant objects, but since tables don't support overflow:auto, this wo
rks out fine. | 594 // descendant objects, but since tables don't support overflow:auto, this wo
rks out fine. |
| 595 if (collapseBorders()) { | 595 if (collapseBorders()) { |
| 596 int rightBorderOverflow = width() + outerBorderRight() - borderRight(); | 596 int rightBorderOverflow = width() + outerBorderRight() - borderRight(); |
| 597 int leftBorderOverflow = borderLeft() - outerBorderLeft(); | 597 int leftBorderOverflow = borderLeft() - outerBorderLeft(); |
| 598 int bottomBorderOverflow = height() + outerBorderBottom() - borderBottom
(); | 598 int bottomBorderOverflow = height() + outerBorderBottom() - borderBottom
(); |
| 599 int topBorderOverflow = borderTop() - outerBorderTop(); | 599 int topBorderOverflow = borderTop() - outerBorderTop(); |
| 600 IntRect borderOverflowRect(leftBorderOverflow, topBorderOverflow, rightB
orderOverflow - leftBorderOverflow, bottomBorderOverflow - topBorderOverflow); | 600 IntRect borderOverflowRect(leftBorderOverflow, topBorderOverflow, rightB
orderOverflow - leftBorderOverflow, bottomBorderOverflow - topBorderOverflow); |
| 601 if (borderOverflowRect != pixelSnappedBorderBoxRect()) { | 601 if (borderOverflowRect != pixelSnappedBorderBoxRect()) { |
| 602 addLayoutOverflow(borderOverflowRect); | 602 addLayoutOverflow(borderOverflowRect); |
| 603 addVisualOverflow(borderOverflowRect); | 603 addVisualOverflow(borderOverflowRect); |
| 604 } | 604 } |
| 605 } | 605 } |
| 606 | 606 |
| 607 // Add overflow from our caption. | 607 // Add overflow from our caption. |
| 608 for (unsigned i = 0; i < m_captions.size(); i++) | 608 for (unsigned i = 0; i < m_captions.size(); i++) |
| 609 addOverflowFromChild(m_captions[i]); | 609 addOverflowFromChild(m_captions[i]); |
| 610 | 610 |
| 611 // Add overflow from our sections. | 611 // Add overflow from our sections. |
| 612 for (RenderTableSection* section = topSection(); section; section = sectionB
elow(section)) | 612 for (RenderTableSection* section = topSection(); section; section = sectionB
elow(section)) |
| 613 addOverflowFromChild(section); | 613 addOverflowFromChild(section); |
| 614 } | 614 } |
| 615 | 615 |
| 616 void RenderTable::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) | 616 void RenderTable::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) |
| 617 { | 617 { |
| 618 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this); | 618 TablePainter(*this).paint(paintInfo, paintOffset); |
| 619 | |
| 620 LayoutPoint adjustedPaintOffset = paintOffset + location(); | |
| 621 | |
| 622 PaintPhase paintPhase = paintInfo.phase; | |
| 623 | |
| 624 if (!isDocumentElement()) { | |
| 625 LayoutRect overflowBox = visualOverflowRect(); | |
| 626 flipForWritingMode(overflowBox); | |
| 627 overflowBox.moveBy(adjustedPaintOffset); | |
| 628 if (!overflowBox.intersects(paintInfo.rect)) | |
| 629 return; | |
| 630 } | |
| 631 | |
| 632 bool pushedClip = pushContentsClip(paintInfo, adjustedPaintOffset, ForceCont
entsClip); | |
| 633 paintObject(paintInfo, adjustedPaintOffset); | |
| 634 if (pushedClip) | |
| 635 popContentsClip(paintInfo, paintPhase, adjustedPaintOffset); | |
| 636 } | 619 } |
| 637 | 620 |
| 638 void RenderTable::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffs
et) | 621 void RenderTable::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffs
et) |
| 639 { | 622 { |
| 640 PaintPhase paintPhase = paintInfo.phase; | 623 TablePainter(*this).paintObject(paintInfo, paintOffset); |
| 641 if ((paintPhase == PaintPhaseBlockBackground || paintPhase == PaintPhaseChil
dBlockBackground) && hasBoxDecorationBackground() && style()->visibility() == VI
SIBLE) | |
| 642 paintBoxDecorationBackground(paintInfo, paintOffset); | |
| 643 | |
| 644 if (paintPhase == PaintPhaseMask) { | |
| 645 paintMask(paintInfo, paintOffset); | |
| 646 return; | |
| 647 } | |
| 648 | |
| 649 // We're done. We don't bother painting any children. | |
| 650 if (paintPhase == PaintPhaseBlockBackground) | |
| 651 return; | |
| 652 | |
| 653 // We don't paint our own background, but we do let the kids paint their bac
kgrounds. | |
| 654 if (paintPhase == PaintPhaseChildBlockBackgrounds) | |
| 655 paintPhase = PaintPhaseChildBlockBackground; | |
| 656 | |
| 657 PaintInfo info(paintInfo); | |
| 658 info.phase = paintPhase; | |
| 659 info.updatePaintingRootForChildren(this); | |
| 660 | |
| 661 for (RenderObject* child = firstChild(); child; child = child->nextSibling()
) { | |
| 662 if (child->isBox() && !toRenderBox(child)->hasSelfPaintingLayer() && (ch
ild->isTableSection() || child->isTableCaption())) { | |
| 663 LayoutPoint childPoint = flipForWritingModeForChild(toRenderBox(chil
d), paintOffset); | |
| 664 child->paint(info, childPoint); | |
| 665 } | |
| 666 } | |
| 667 | |
| 668 if (collapseBorders() && paintPhase == PaintPhaseChildBlockBackground && sty
le()->visibility() == VISIBLE) { | |
| 669 recalcCollapsedBorders(); | |
| 670 // Using our cached sorted styles, we then do individual passes, | |
| 671 // painting each style of border from lowest precedence to highest prece
dence. | |
| 672 info.phase = PaintPhaseCollapsedTableBorders; | |
| 673 size_t count = m_collapsedBorders.size(); | |
| 674 for (size_t i = 0; i < count; ++i) { | |
| 675 m_currentBorder = &m_collapsedBorders[i]; | |
| 676 for (RenderTableSection* section = bottomSection(); section; section
= sectionAbove(section)) { | |
| 677 LayoutPoint childPoint = flipForWritingModeForChild(section, pai
ntOffset); | |
| 678 section->paint(info, childPoint); | |
| 679 } | |
| 680 } | |
| 681 m_currentBorder = 0; | |
| 682 } | |
| 683 | |
| 684 // Paint outline. | |
| 685 if ((paintPhase == PaintPhaseOutline || paintPhase == PaintPhaseSelfOutline)
&& style()->hasOutline() && style()->visibility() == VISIBLE) | |
| 686 paintOutline(paintInfo, LayoutRect(paintOffset, size())); | |
| 687 } | 624 } |
| 688 | 625 |
| 689 void RenderTable::subtractCaptionRect(LayoutRect& rect) const | 626 void RenderTable::subtractCaptionRect(LayoutRect& rect) const |
| 690 { | 627 { |
| 691 for (unsigned i = 0; i < m_captions.size(); i++) { | 628 for (unsigned i = 0; i < m_captions.size(); i++) { |
| 692 LayoutUnit captionLogicalHeight = m_captions[i]->logicalHeight() + m_cap
tions[i]->marginBefore() + m_captions[i]->marginAfter(); | 629 LayoutUnit captionLogicalHeight = m_captions[i]->logicalHeight() + m_cap
tions[i]->marginBefore() + m_captions[i]->marginAfter(); |
| 693 bool captionIsBefore = (m_captions[i]->style()->captionSide() != CAPBOTT
OM) ^ style()->isFlippedBlocksWritingMode(); | 630 bool captionIsBefore = (m_captions[i]->style()->captionSide() != CAPBOTT
OM) ^ style()->isFlippedBlocksWritingMode(); |
| 694 if (style()->isHorizontalWritingMode()) { | 631 if (style()->isHorizontalWritingMode()) { |
| 695 rect.setHeight(rect.height() - captionLogicalHeight); | 632 rect.setHeight(rect.height() - captionLogicalHeight); |
| 696 if (captionIsBefore) | 633 if (captionIsBefore) |
| 697 rect.move(0, captionLogicalHeight); | 634 rect.move(0, captionLogicalHeight); |
| 698 } else { | 635 } else { |
| 699 rect.setWidth(rect.width() - captionLogicalHeight); | 636 rect.setWidth(rect.width() - captionLogicalHeight); |
| 700 if (captionIsBefore) | 637 if (captionIsBefore) |
| 701 rect.move(captionLogicalHeight, 0); | 638 rect.move(captionLogicalHeight, 0); |
| 702 } | 639 } |
| 703 } | 640 } |
| 704 } | 641 } |
| 705 | 642 |
| 706 void RenderTable::paintBoxDecorationBackground(PaintInfo& paintInfo, const Layou
tPoint& paintOffset) | 643 void RenderTable::paintBoxDecorationBackground(PaintInfo& paintInfo, const Layou
tPoint& paintOffset) |
| 707 { | 644 { |
| 708 if (!paintInfo.shouldPaintWithinRoot(this)) | 645 TablePainter(*this).paintBoxDecorationBackground(paintInfo, paintOffset); |
| 709 return; | |
| 710 | |
| 711 LayoutRect rect(paintOffset, size()); | |
| 712 subtractCaptionRect(rect); | |
| 713 BoxPainter(*this).paintBoxDecorationBackgroundWithRect(paintInfo, paintOffse
t, rect); | |
| 714 } | 646 } |
| 715 | 647 |
| 716 void RenderTable::paintMask(PaintInfo& paintInfo, const LayoutPoint& paintOffset
) | 648 void RenderTable::paintMask(PaintInfo& paintInfo, const LayoutPoint& paintOffset
) |
| 717 { | 649 { |
| 718 if (style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask) | 650 TablePainter(*this).paintMask(paintInfo, paintOffset); |
| 719 return; | |
| 720 | |
| 721 LayoutRect rect(paintOffset, size()); | |
| 722 subtractCaptionRect(rect); | |
| 723 | |
| 724 BoxPainter(*this).paintMaskImages(paintInfo, rect); | |
| 725 } | 651 } |
| 726 | 652 |
| 727 void RenderTable::computeIntrinsicLogicalWidths(LayoutUnit& minWidth, LayoutUnit
& maxWidth) const | 653 void RenderTable::computeIntrinsicLogicalWidths(LayoutUnit& minWidth, LayoutUnit
& maxWidth) const |
| 728 { | 654 { |
| 729 recalcSectionsIfNeeded(); | 655 recalcSectionsIfNeeded(); |
| 730 // FIXME: Do the recalc in borderStart/borderEnd and make those const_cast t
his call. | 656 // FIXME: Do the recalc in borderStart/borderEnd and make those const_cast t
his call. |
| 731 // Then m_borderStart/m_borderEnd will be transparent a cache and it removes
the possibility | 657 // Then m_borderStart/m_borderEnd will be transparent a cache and it removes
the possibility |
| 732 // of reading out stale values. | 658 // of reading out stale values. |
| 733 const_cast<RenderTable*>(this)->recalcBordersInRowDirection(); | 659 const_cast<RenderTable*>(this)->recalcBordersInRowDirection(); |
| 734 // FIXME: Restructure the table layout code so that we can make this method
const. | 660 // FIXME: Restructure the table layout code so that we can make this method
const. |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1418 const BorderValue& RenderTable::tableEndBorderAdjoiningCell(const RenderTableCel
l* cell) const | 1344 const BorderValue& RenderTable::tableEndBorderAdjoiningCell(const RenderTableCel
l* cell) const |
| 1419 { | 1345 { |
| 1420 ASSERT(cell->isFirstOrLastCellInRow()); | 1346 ASSERT(cell->isFirstOrLastCellInRow()); |
| 1421 if (hasSameDirectionAs(cell->row())) | 1347 if (hasSameDirectionAs(cell->row())) |
| 1422 return style()->borderEnd(); | 1348 return style()->borderEnd(); |
| 1423 | 1349 |
| 1424 return style()->borderStart(); | 1350 return style()->borderStart(); |
| 1425 } | 1351 } |
| 1426 | 1352 |
| 1427 } | 1353 } |
| OLD | NEW |