Chromium Code Reviews| Index: third_party/WebKit/Source/core/layout/LayoutTableSection.cpp |
| diff --git a/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp b/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp |
| index 89b925af6f41a1551f1d609cd14bd23c85fada16..c1b7f242e64dff22bf96ede4555ec74f425a9260 100644 |
| --- a/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp |
| +++ b/third_party/WebKit/Source/core/layout/LayoutTableSection.cpp |
| @@ -1647,4 +1647,81 @@ void LayoutTableSection::setLogicalPositionForCell(LayoutTableCell* cell, unsign |
| cell->setLogicalLocation(cellLocation); |
| } |
| +// Returns position ideal cell relative to section |
| +// Ideal cell is a cell that spans single row/column. |
| +// It is used to calculate position of colgroup/col/row |
| +// It is needed because actual cells can be arbitrary rectangles, or non-existent |
| +// 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.
|
| +LayoutRect LayoutTableSection::positionOfIdealCell(unsigned row, unsigned effectiveCol) const |
| +{ |
| + LayoutTable * table = this->table(); |
| + |
| + LayoutUnit left = LayoutUnit(table->effectiveColumnPositions()[effectiveCol]); |
| + LayoutUnit top = LayoutUnit(m_rowPos[row]); |
| + LayoutUnit right = LayoutUnit(table->effectiveColumnPositions()[effectiveCol+1]); |
| + LayoutUnit bottom = LayoutUnit(m_rowPos[row+1]); |
| + left += LayoutUnit(table->hBorderSpacing()); |
| + |
| + 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.
|
| + |
| + // we get mode/position from row |
| + const LayoutTableRow* rowLayout = rowLayoutObjectAt(row); |
| + 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
|
| + bool isLTR = style()->isLeftToRightDirection(); |
|
Xianzhu
2016/03/09 18:40:56
The code below can be simplified by reusing existi
|
| + |
| + // LOG(INFO) << "ideal [" << row << ", " << col << "] " << |
| + // position.x().toInt() << ", " << position.y().toInt() << " " << |
| + // position.width().toInt() << " x " << position.height().toInt(); |
| + |
| + if (blink::isHorizontalWritingMode(writingMode)) { |
| + if (isLTR) { |
| + position.setLocation(LayoutPoint(left, top)); |
| + position.setSize(LayoutSize(right - left, bottom - top)); |
| + } else { |
| + LayoutUnit width = size().width(); |
| + left = width - left; |
| + right = width - right; |
| + std::swap(left, right); |
| + position.setLocation(LayoutPoint(left, top)); |
| + position.setSize(LayoutSize(right - left, bottom - top)); |
| + } |
| + } else if (isFlippedLinesWritingMode(writingMode)) { |
| + if (isLTR) { |
| + position = position.transposedRect(); |
| + } else { |
| + LayoutUnit height = size().height(); |
| + auto tmpTop = top; |
| + auto tmpBottom = bottom; |
| + top = height - right; |
| + bottom = height -left; |
| + left = tmpTop; |
| + right = tmpBottom; |
| + position.setLocation(LayoutPoint(left, top)); |
| + position.setSize(LayoutSize(right - left, bottom - top)); |
| + } |
| + } else if (isFlippedBlocksWritingMode(writingMode)) { |
| + if (isLTR) { |
| + LayoutUnit width = size().width(); |
| + position.setLocation(LayoutPoint(width - bottom, left)); |
| + position.setSize(LayoutSize(bottom - top, right - left)); |
| + } else { |
| + LayoutUnit width = size().width(); |
| + LayoutUnit height = size().height(); |
| + auto tmpLeft = left; |
| + auto tmpRight = right; |
| + left = width - bottom; |
| + right = width - top; |
| + top = height - tmpRight; |
| + bottom = height - tmpLeft; |
| + position.setLocation(LayoutPoint(left, top)); |
| + position.setSize(LayoutSize(right - left, bottom - top)); |
| + } |
| + } |
| + |
| + // LOG(INFO) << "after [" << row << ", " << col << "] " << |
| + // position.x().toInt() << ", " << position.y().toInt() << " " << |
| + // 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.
|
| + return position; |
| +} |
| + |
| } // namespace blink |