Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutTableSection.cpp

Issue 1676933004: Table cell background painting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix for LayoutTableCol::clippedOverflowRectForPaintInvalidation Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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, 2008, 2009, 2010, 2013 Apple Inc. All r ights reserved. 7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2013 Apple Inc. All r ights 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 1629 matching lines...) Expand 10 before | Expand all | Expand 10 after
1640 1640
1641 // FIXME: The table's direction should determine our row's direction, not th e section's (see bug 96691). 1641 // FIXME: The table's direction should determine our row's direction, not th e section's (see bug 96691).
1642 if (!style()->isLeftToRightDirection()) 1642 if (!style()->isLeftToRightDirection())
1643 cellLocation.setX(LayoutUnit(table()->effectiveColumnPositions()[table() ->numEffectiveColumns()] - table()->effectiveColumnPositions()[table()->absolute ColumnToEffectiveColumn(cell->absoluteColumnIndex() + cell->colSpan())] + horizo ntalBorderSpacing)); 1643 cellLocation.setX(LayoutUnit(table()->effectiveColumnPositions()[table() ->numEffectiveColumns()] - table()->effectiveColumnPositions()[table()->absolute ColumnToEffectiveColumn(cell->absoluteColumnIndex() + cell->colSpan())] + horizo ntalBorderSpacing));
1644 else 1644 else
1645 cellLocation.setX(LayoutUnit(table()->effectiveColumnPositions()[effecti veColumn] + horizontalBorderSpacing)); 1645 cellLocation.setX(LayoutUnit(table()->effectiveColumnPositions()[effecti veColumn] + horizontalBorderSpacing));
1646 1646
1647 cell->setLogicalLocation(cellLocation); 1647 cell->setLogicalLocation(cellLocation);
1648 } 1648 }
1649 1649
1650 // Returns position ideal cell relative to section
1651 // Ideal cell is a cell that spans single row/column.
1652 // It is used to calculate position of colgroup/col/row
1653 // It is needed because actual cells can be arbitrary rectangles, or non-existen t
1654 // Position is relative to section
Xianzhu 2016/03/09 18:40:56 Move comments into header file.
atotic1 2016/03/15 16:50:48 Done.
1655 LayoutRect LayoutTableSection::positionOfIdealCell(unsigned row, unsigned effect iveCol) const
1656 {
1657 LayoutTable * table = this->table();
1658
1659 LayoutUnit left = LayoutUnit(table->effectiveColumnPositions()[effectiveCol] );
1660 LayoutUnit top = LayoutUnit(m_rowPos[row]);
1661 LayoutUnit right = LayoutUnit(table->effectiveColumnPositions()[effectiveCol +1]);
1662 LayoutUnit bottom = LayoutUnit(m_rowPos[row+1]);
1663 left += LayoutUnit(table->hBorderSpacing());
1664
1665 LayoutRect position(LayoutPoint(left, top), LayoutSize(right - left, bottom - top));
Xianzhu 2016/03/09 18:40:56 Change to: LayoutRect position(left, top, right -
atotic1 2016/03/15 16:50:48 Done.
atotic1 2016/03/15 16:50:48 Done.
1666
1667 // we get mode/position from row
1668 const LayoutTableRow* rowLayout = rowLayoutObjectAt(row);
1669 WritingMode writingMode = rowLayout ? rowLayout->style()->getWritingMode() : TopToBottomWritingMode;
Xianzhu 2016/03/09 18:40:56 Why fallback to TopToBottomWritingMode if there is
atotic1 2016/03/15 16:50:48 Just defensive coding because I have no guarantees
1670 bool isLTR = style()->isLeftToRightDirection();
Xianzhu 2016/03/09 18:40:56 The code below can be simplified by reusing existi
1671
1672 // LOG(INFO) << "ideal [" << row << ", " << col << "] " <<
1673 // position.x().toInt() << ", " << position.y().toInt() << " " <<
1674 // position.width().toInt() << " x " << position.height().toInt();
1675
1676 if (blink::isHorizontalWritingMode(writingMode)) {
1677 if (isLTR) {
1678 position.setLocation(LayoutPoint(left, top));
1679 position.setSize(LayoutSize(right - left, bottom - top));
1680 } else {
1681 LayoutUnit width = size().width();
1682 left = width - left;
1683 right = width - right;
1684 std::swap(left, right);
1685 position.setLocation(LayoutPoint(left, top));
1686 position.setSize(LayoutSize(right - left, bottom - top));
1687 }
1688 } else if (isFlippedLinesWritingMode(writingMode)) {
1689 if (isLTR) {
1690 position = position.transposedRect();
1691 } else {
1692 LayoutUnit height = size().height();
1693 auto tmpTop = top;
1694 auto tmpBottom = bottom;
1695 top = height - right;
1696 bottom = height -left;
1697 left = tmpTop;
1698 right = tmpBottom;
1699 position.setLocation(LayoutPoint(left, top));
1700 position.setSize(LayoutSize(right - left, bottom - top));
1701 }
1702 } else if (isFlippedBlocksWritingMode(writingMode)) {
1703 if (isLTR) {
1704 LayoutUnit width = size().width();
1705 position.setLocation(LayoutPoint(width - bottom, left));
1706 position.setSize(LayoutSize(bottom - top, right - left));
1707 } else {
1708 LayoutUnit width = size().width();
1709 LayoutUnit height = size().height();
1710 auto tmpLeft = left;
1711 auto tmpRight = right;
1712 left = width - bottom;
1713 right = width - top;
1714 top = height - tmpRight;
1715 bottom = height - tmpLeft;
1716 position.setLocation(LayoutPoint(left, top));
1717 position.setSize(LayoutSize(right - left, bottom - top));
1718 }
1719 }
1720
1721 // LOG(INFO) << "after [" << row << ", " << col << "] " <<
1722 // position.x().toInt() << ", " << position.y().toInt() << " " <<
1723 // position.width().toInt() << " x " << position.height().toInt();
Xianzhu 2016/03/09 18:40:56 Please remove temporary debug code before sending
atotic1 2016/03/15 16:50:48 Done. Rewrote as a much simpler version.
1724 return position;
1725 }
1726
1650 } // namespace blink 1727 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698