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

Side by Side Diff: third_party/WebKit/Source/core/paint/TableSectionPainter.cpp

Issue 2021703002: Display table header groups at the top of each page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated Created 4 years, 6 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
« no previous file with comments | « third_party/WebKit/Source/core/paint/TableSectionPainter.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/paint/TableSectionPainter.h" 5 #include "core/paint/TableSectionPainter.h"
6 6
7 #include "core/layout/LayoutTableCell.h" 7 #include "core/layout/LayoutTableCell.h"
8 #include "core/layout/LayoutTableCol.h" 8 #include "core/layout/LayoutTableCol.h"
9 #include "core/layout/LayoutTableRow.h" 9 #include "core/layout/LayoutTableRow.h"
10 #include "core/paint/BoxClipper.h" 10 #include "core/paint/BoxClipper.h"
(...skipping 17 matching lines...) Expand all
28 return nullptr; 28 return nullptr;
29 // We have painted (row, column) when painting (row - 1, column). 29 // We have painted (row, column) when painting (row - 1, column).
30 if (row > dirtiedRows.start() && m_layoutTableSection.primaryCellAt(row - 1, column) == cell) 30 if (row > dirtiedRows.start() && m_layoutTableSection.primaryCellAt(row - 1, column) == cell)
31 return nullptr; 31 return nullptr;
32 // We have painted (row, column) when painting (row, column -1). 32 // We have painted (row, column) when painting (row, column -1).
33 if (column > dirtiedColumns.start() && m_layoutTableSection.primaryCellAt(ro w, column - 1) == cell) 33 if (column > dirtiedColumns.start() && m_layoutTableSection.primaryCellAt(ro w, column - 1) == cell)
34 return nullptr; 34 return nullptr;
35 return cell; 35 return cell;
36 } 36 }
37 37
38 void TableSectionPainter::paintRepeatingHeaderGroup(const PaintInfo& paintInfo, const LayoutPoint& paintOffset, const CollapsedBorderValue& currentBorderValue, ItemToPaint itemToPaint)
39 {
40 if (m_layoutTableSection.getPaginationBreakability() == LayoutBox::AllowAnyB reaks)
41 return;
42 // TODO(rhogan): Should we paint a header repeatedly if it's self-painting?
43 if (m_layoutTableSection.hasSelfPaintingLayer())
44 return;
45 LayoutTable* table = m_layoutTableSection.table();
46 LayoutUnit pageHeight = table->pageLogicalHeightForOffset(LayoutUnit());
47 if (!pageHeight)
48 return;
49
50 LayoutPoint paginationOffset = paintOffset;
51 // Move paginationOffset to the top of the second page.
52 paginationOffset.move(0, pageHeight - table->pageLogicalOffset());
53 // Now move paginationOffset to the top of the page the cull rect starts on.
54 if (paintInfo.cullRect().m_rect.y() > paginationOffset.y())
55 paginationOffset.move(0, pageHeight * static_cast<int>((paintInfo.cullRe ct().m_rect.y() - paginationOffset.y()) / pageHeight));
56 LayoutUnit bottomBound = std::min(LayoutUnit(paintInfo.cullRect().m_rect.max Y()), paintOffset.y() + table->logicalHeight());
57 while (paginationOffset.y() < bottomBound) {
58 if (itemToPaint == PaintCollapsedBorders)
59 paintCollapsedSectionBorders(paintInfo, paginationOffset, currentBor derValue);
60 else
61 paintSection(paintInfo, paginationOffset);
62 paginationOffset.move(0, pageHeight);
63 }
64 }
65
38 void TableSectionPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& p aintOffset) 66 void TableSectionPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& p aintOffset)
39 { 67 {
68 paintSection(paintInfo, paintOffset);
69 LayoutTable* table = m_layoutTableSection.table();
70 if (table->header() == m_layoutTableSection)
71 paintRepeatingHeaderGroup(paintInfo, paintOffset, CollapsedBorderValue() , PaintSection);
72 }
73
74 void TableSectionPainter::paintSection(const PaintInfo& paintInfo, const LayoutP oint& paintOffset)
75 {
40 DCHECK(!m_layoutTableSection.needsLayout()); 76 DCHECK(!m_layoutTableSection.needsLayout());
41 // avoid crashing on bugs that cause us to paint with dirty layout 77 // avoid crashing on bugs that cause us to paint with dirty layout
42 if (m_layoutTableSection.needsLayout()) 78 if (m_layoutTableSection.needsLayout())
43 return; 79 return;
44 80
45 unsigned totalRows = m_layoutTableSection.numRows(); 81 unsigned totalRows = m_layoutTableSection.numRows();
46 unsigned totalCols = m_layoutTableSection.table()->numEffectiveColumns(); 82 unsigned totalCols = m_layoutTableSection.table()->numEffectiveColumns();
47 83
48 if (!totalRows || !totalCols) 84 if (!totalRows || !totalCols)
49 return; 85 return;
(...skipping 21 matching lines...) Expand all
71 static inline bool compareCellPositionsWithOverflowingCells(LayoutTableCell* ele m1, LayoutTableCell* elem2) 107 static inline bool compareCellPositionsWithOverflowingCells(LayoutTableCell* ele m1, LayoutTableCell* elem2)
72 { 108 {
73 if (elem1->rowIndex() != elem2->rowIndex()) 109 if (elem1->rowIndex() != elem2->rowIndex())
74 return elem1->rowIndex() < elem2->rowIndex(); 110 return elem1->rowIndex() < elem2->rowIndex();
75 111
76 return elem1->absoluteColumnIndex() < elem2->absoluteColumnIndex(); 112 return elem1->absoluteColumnIndex() < elem2->absoluteColumnIndex();
77 } 113 }
78 114
79 void TableSectionPainter::paintCollapsedBorders(const PaintInfo& paintInfo, cons t LayoutPoint& paintOffset, const CollapsedBorderValue& currentBorderValue) 115 void TableSectionPainter::paintCollapsedBorders(const PaintInfo& paintInfo, cons t LayoutPoint& paintOffset, const CollapsedBorderValue& currentBorderValue)
80 { 116 {
117 paintCollapsedSectionBorders(paintInfo, paintOffset, currentBorderValue);
118 LayoutTable* table = m_layoutTableSection.table();
119 if (table->header() == m_layoutTableSection)
120 paintRepeatingHeaderGroup(paintInfo, paintOffset, currentBorderValue, Pa intCollapsedBorders);
121 }
122
123 void TableSectionPainter::paintCollapsedSectionBorders(const PaintInfo& paintInf o, const LayoutPoint& paintOffset, const CollapsedBorderValue& currentBorderValu e)
124 {
81 if (!m_layoutTableSection.numRows() || !m_layoutTableSection.table()->effect iveColumns().size()) 125 if (!m_layoutTableSection.numRows() || !m_layoutTableSection.table()->effect iveColumns().size())
82 return; 126 return;
83 127
84 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutTableSection.locatio n(); 128 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutTableSection.locatio n();
85 BoxClipper boxClipper(m_layoutTableSection, paintInfo, adjustedPaintOffset, ForceContentsClip); 129 BoxClipper boxClipper(m_layoutTableSection, paintInfo, adjustedPaintOffset, ForceContentsClip);
86 130
87 LayoutRect localPaintInvalidationRect = LayoutRect(paintInfo.cullRect().m_re ct); 131 LayoutRect localPaintInvalidationRect = LayoutRect(paintInfo.cullRect().m_re ct);
88 localPaintInvalidationRect.moveBy(-adjustedPaintOffset); 132 localPaintInvalidationRect.moveBy(-adjustedPaintOffset);
89 133
90 LayoutRect tableAlignedRect = m_layoutTableSection.logicalRectForWritingMode AndDirection(localPaintInvalidationRect); 134 LayoutRect tableAlignedRect = m_layoutTableSection.logicalRectForWritingMode AndDirection(localPaintInvalidationRect);
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 DisplayItem::Type type = shadowStyle == Normal ? DisplayItem::TableSectionBo xShadowNormal : DisplayItem::TableSectionBoxShadowInset; 298 DisplayItem::Type type = shadowStyle == Normal ? DisplayItem::TableSectionBo xShadowNormal : DisplayItem::TableSectionBoxShadowInset;
255 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex t, m_layoutTableSection, type)) 299 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex t, m_layoutTableSection, type))
256 return; 300 return;
257 301
258 LayoutRect bounds = BoxPainter(m_layoutTableSection).boundsForDrawingRecorde r(paintOffset); 302 LayoutRect bounds = BoxPainter(m_layoutTableSection).boundsForDrawingRecorde r(paintOffset);
259 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutTableSection , type, bounds); 303 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutTableSection , type, bounds);
260 BoxPainter::paintBoxShadow(paintInfo, LayoutRect(paintOffset, m_layoutTableS ection.size()), m_layoutTableSection.styleRef(), shadowStyle); 304 BoxPainter::paintBoxShadow(paintInfo, LayoutRect(paintOffset, m_layoutTableS ection.size()), m_layoutTableSection.styleRef(), shadowStyle);
261 } 305 }
262 306
263 } // namespace blink 307 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/TableSectionPainter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698