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

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

Issue 2430313004: Paint collapsed borders of a table as one display item (Closed)
Patch Set: Rebaseline-cl Created 4 years, 1 month 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 // 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/TablePainter.h" 5 #include "core/paint/TablePainter.h"
6 6
7 #include "core/layout/LayoutTable.h" 7 #include "core/layout/LayoutTable.h"
8 #include "core/layout/LayoutTableSection.h" 8 #include "core/layout/LayoutTableSection.h"
9 #include "core/style/CollapsedBorderValue.h" 9 #include "core/style/CollapsedBorderValue.h"
10 #include "core/paint/BoxClipper.h" 10 #include "core/paint/BoxClipper.h"
(...skipping 26 matching lines...) Expand all
37 for (LayoutObject* child = m_layoutTable.firstChild(); child; 37 for (LayoutObject* child = m_layoutTable.firstChild(); child;
38 child = child->nextSibling()) { 38 child = child->nextSibling()) {
39 if (child->isBox() && !toLayoutBox(child)->hasSelfPaintingLayer() && 39 if (child->isBox() && !toLayoutBox(child)->hasSelfPaintingLayer() &&
40 (child->isTableSection() || child->isTableCaption())) { 40 (child->isTableSection() || child->isTableCaption())) {
41 LayoutPoint childPoint = m_layoutTable.flipForWritingModeForChild( 41 LayoutPoint childPoint = m_layoutTable.flipForWritingModeForChild(
42 toLayoutBox(child), paintOffset); 42 toLayoutBox(child), paintOffset);
43 child->paint(paintInfoForDescendants, childPoint); 43 child->paint(paintInfoForDescendants, childPoint);
44 } 44 }
45 } 45 }
46 46
47 if (m_layoutTable.collapseBorders() && 47 if (shouldPaintDescendantBlockBackgrounds(paintPhase))
48 shouldPaintDescendantBlockBackgrounds(paintPhase) && 48 paintCollapsedBorders(paintInfoForDescendants, paintOffset);
49 m_layoutTable.style()->visibility() == EVisibility::Visible) {
50 // Using our cached sorted styles, we then do individual passes,
51 // painting each style of border from lowest precedence to highest
52 // precedence.
53 LayoutTable::CollapsedBorderValues collapsedBorders =
54 m_layoutTable.collapsedBorders();
55 size_t count = collapsedBorders.size();
56 for (size_t i = 0; i < count; ++i) {
57 for (LayoutTableSection* section = m_layoutTable.bottomSection();
58 section; section = m_layoutTable.sectionAbove(section)) {
59 LayoutPoint childPoint =
60 m_layoutTable.flipForWritingModeForChild(section, paintOffset);
61 TableSectionPainter(*section).paintCollapsedBorders(
62 paintInfoForDescendants, childPoint, collapsedBorders[i]);
63 }
64 }
65 }
66 } 49 }
67 50
68 if (shouldPaintSelfOutline(paintPhase)) 51 if (shouldPaintSelfOutline(paintPhase))
69 ObjectPainter(m_layoutTable).paintOutline(paintInfo, paintOffset); 52 ObjectPainter(m_layoutTable).paintOutline(paintInfo, paintOffset);
70 } 53 }
71 54
55 void TablePainter::paintCollapsedBorders(const PaintInfo& paintInfo,
56 const LayoutPoint& paintOffset) {
57 if (!m_layoutTable.hasCollapsedBorders() ||
58 m_layoutTable.style()->visibility() != EVisibility::Visible)
59 return;
60
61 LayoutTable::CollapsedBordersInfo& collapsedBorders =
62 m_layoutTable.getCollapsedBordersInfo();
63
64 // Normally we don't clip individual display items by paint dirty rect
chrishtr 2016/11/03 21:16:29 Is such an optimization already implemented in the
Xianzhu 2016/11/03 21:26:55 Yes, in TableSectionPainter, to skip painting coll
65 // (aka interest rect), to keep display items independent with paint dirty
66 // rect so we can just depend on paint invalidation status to repaint them.
67 // However, the collapsed border display item may be too big to contain all
68 // collapsed borders in a huge table, so we clip it to paint dirty rect.
69 // We need to invalidate the display item if the previous paint is clipped
70 // and the paint dirty rect changed.
71 if (collapsedBorders.lastPaintResult != FullyPainted &&
72 collapsedBorders.lastPaintRect != paintInfo.cullRect())
73 m_layoutTable.setDisplayItemsUncached();
74
75 if (!DrawingRecorder::useCachedDrawingIfPossible(
chrishtr 2016/11/03 21:16:29 if (DrawingRecorder::useCachedDrawingIfPossible(..
Xianzhu 2016/11/03 21:26:55 Done.
76 paintInfo.context, m_layoutTable,
77 DisplayItem::kTableCollapsedBorders)) {
78 DrawingRecorder recorder(
79 paintInfo.context, m_layoutTable, DisplayItem::kTableCollapsedBorders,
80 FloatRect(LayoutRect(paintOffset, m_layoutTable.size())));
81
82 // Using our cached sorted styles, we then do individual passes, painting
83 // each style of border from lowest precedence to highest precedence.
84 PaintResult paintResult = FullyPainted;
85 for (const auto& borderValue : collapsedBorders.values) {
86 for (LayoutTableSection* section = m_layoutTable.bottomSection(); section;
87 section = m_layoutTable.sectionAbove(section)) {
88 LayoutPoint childPoint =
89 m_layoutTable.flipForWritingModeForChild(section, paintOffset);
90 if (TableSectionPainter(*section).paintCollapsedBorders(
91 paintInfo, childPoint, borderValue) ==
92 MayBeClippedByPaintDirtyRect)
93 paintResult = MayBeClippedByPaintDirtyRect;
94 }
95 }
96 collapsedBorders.lastPaintResult = paintResult;
97 collapsedBorders.lastPaintRect = paintInfo.cullRect();
98 }
99 }
100
72 void TablePainter::paintBoxDecorationBackground( 101 void TablePainter::paintBoxDecorationBackground(
73 const PaintInfo& paintInfo, 102 const PaintInfo& paintInfo,
74 const LayoutPoint& paintOffset) { 103 const LayoutPoint& paintOffset) {
75 if (!m_layoutTable.hasBoxDecorationBackground() || 104 if (!m_layoutTable.hasBoxDecorationBackground() ||
76 m_layoutTable.style()->visibility() != EVisibility::Visible) 105 m_layoutTable.style()->visibility() != EVisibility::Visible)
77 return; 106 return;
78 107
79 LayoutRect rect(paintOffset, m_layoutTable.size()); 108 LayoutRect rect(paintOffset, m_layoutTable.size());
80 m_layoutTable.subtractCaptionRect(rect); 109 m_layoutTable.subtractCaptionRect(rect);
81 BoxPainter(m_layoutTable) 110 BoxPainter(m_layoutTable)
(...skipping 12 matching lines...) Expand all
94 123
95 LayoutRect rect(paintOffset, m_layoutTable.size()); 124 LayoutRect rect(paintOffset, m_layoutTable.size());
96 m_layoutTable.subtractCaptionRect(rect); 125 m_layoutTable.subtractCaptionRect(rect);
97 126
98 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutTable, 127 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutTable,
99 paintInfo.phase, rect); 128 paintInfo.phase, rect);
100 BoxPainter(m_layoutTable).paintMaskImages(paintInfo, rect); 129 BoxPainter(m_layoutTable).paintMaskImages(paintInfo, rect);
101 } 130 }
102 131
103 } // namespace blink 132 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698