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

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

Issue 1584903002: Improvement handling of background and outline paint phases (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@PaintPhaseRename
Patch Set: Created 4 years, 11 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 // 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"
11 #include "core/paint/BoxPainter.h" 11 #include "core/paint/BoxPainter.h"
12 #include "core/paint/LayoutObjectDrawingRecorder.h" 12 #include "core/paint/LayoutObjectDrawingRecorder.h"
13 #include "core/paint/ObjectPainter.h" 13 #include "core/paint/ObjectPainter.h"
14 #include "core/paint/PaintInfo.h" 14 #include "core/paint/PaintInfo.h"
15 #include "core/paint/ScopeRecorder.h" 15 #include "core/paint/ScopeRecorder.h"
16 #include "core/paint/TableSectionPainter.h" 16 #include "core/paint/TableSectionPainter.h"
17 17
18 namespace blink { 18 namespace blink {
19 19
20 void TablePainter::paintObject(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) 20 void TablePainter::paintObject(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset)
21 { 21 {
22 PaintPhase paintPhase = paintInfo.phase; 22 PaintPhase paintPhase = paintInfo.phase;
23 if ((paintPhase == PaintPhaseSelfBlockBackground || paintPhase == PaintPhase BlockBackground) && m_layoutTable.hasBoxDecorationBackground() && m_layoutTable. style()->visibility() == VISIBLE) 23
24 paintBoxDecorationBackground(paintInfo, paintOffset); 24 if (shouldPaintSelfBlockBackground(paintPhase)) {
25 if (m_layoutTable.hasBoxDecorationBackground() && m_layoutTable.style()- >visibility() == VISIBLE)
pdr. 2016/01/14 19:51:50 Can this check be moved into paintBoxDecorationBac
Xianzhu 2016/01/15 01:05:33 Done.
26 paintBoxDecorationBackground(paintInfo, paintOffset);
27 if (paintPhase == PaintPhaseSelfBlockBackgroundOnly)
28 return;
29 }
25 30
26 if (paintPhase == PaintPhaseMask) { 31 if (paintPhase == PaintPhaseMask) {
27 paintMask(paintInfo, paintOffset); 32 paintMask(paintInfo, paintOffset);
28 return; 33 return;
29 } 34 }
30 35
31 // We're done. We don't bother painting any children. 36 PaintInfo paintInfoForDescendants = paintInfo.forDescendants();
32 if (paintPhase == PaintPhaseSelfBlockBackground) 37 paintInfoForDescendants.updatePaintingRootForChildren(&m_layoutTable);
33 return;
34
35 // We don't paint our own background, but we do let the kids paint their bac kgrounds.
36 if (paintPhase == PaintPhaseDescendantBlockBackgrounds)
37 paintPhase = PaintPhaseBlockBackground;
38
39 PaintInfo info(paintInfo);
40 info.phase = paintPhase;
41 info.updatePaintingRootForChildren(&m_layoutTable);
42 38
43 for (LayoutObject* child = m_layoutTable.firstChild(); child; child = child- >nextSibling()) { 39 for (LayoutObject* child = m_layoutTable.firstChild(); child; child = child- >nextSibling()) {
44 if (child->isBox() && !toLayoutBox(child)->hasSelfPaintingLayer() && (ch ild->isTableSection() || child->isTableCaption())) { 40 if (child->isBox() && !toLayoutBox(child)->hasSelfPaintingLayer() && (ch ild->isTableSection() || child->isTableCaption())) {
45 LayoutPoint childPoint = m_layoutTable.flipForWritingModeForChild(to LayoutBox(child), paintOffset); 41 LayoutPoint childPoint = m_layoutTable.flipForWritingModeForChild(to LayoutBox(child), paintOffset);
46 child->paint(info, childPoint); 42 child->paint(paintInfoForDescendants, childPoint);
47 } 43 }
48 } 44 }
49 45
50 if (m_layoutTable.collapseBorders() && paintPhase == PaintPhaseBlockBackgrou nd && m_layoutTable.style()->visibility() == VISIBLE) { 46 if (m_layoutTable.collapseBorders() && shouldPaintDescendantBlockBackgrounds (paintPhase) && m_layoutTable.style()->visibility() == VISIBLE) {
51 // Using our cached sorted styles, we then do individual passes, 47 // Using our cached sorted styles, we then do individual passes,
52 // painting each style of border from lowest precedence to highest prece dence. 48 // painting each style of border from lowest precedence to highest prece dence.
53 LayoutTable::CollapsedBorderValues collapsedBorders = m_layoutTable.coll apsedBorders(); 49 LayoutTable::CollapsedBorderValues collapsedBorders = m_layoutTable.coll apsedBorders();
54 size_t count = collapsedBorders.size(); 50 size_t count = collapsedBorders.size();
55 for (size_t i = 0; i < count; ++i) { 51 for (size_t i = 0; i < count; ++i) {
56 for (LayoutTableSection* section = m_layoutTable.bottomSection(); se ction; section = m_layoutTable.sectionAbove(section)) { 52 for (LayoutTableSection* section = m_layoutTable.bottomSection(); se ction; section = m_layoutTable.sectionAbove(section)) {
57 LayoutPoint childPoint = m_layoutTable.flipForWritingModeForChil d(section, paintOffset); 53 LayoutPoint childPoint = m_layoutTable.flipForWritingModeForChil d(section, paintOffset);
58 TableSectionPainter(*section).paintCollapsedBorders(info, childP oint, collapsedBorders[i]); 54 TableSectionPainter(*section).paintCollapsedBorders(paintInfoFor Descendants, childPoint, collapsedBorders[i]);
59 } 55 }
60 } 56 }
61 } 57 }
62 58
63 // Paint outline. 59 if (shouldPaintSelfOutline(paintPhase))
64 if ((paintPhase == PaintPhaseOutline || paintPhase == PaintPhaseSelfOutline) && m_layoutTable.style()->hasOutline() && m_layoutTable.style()->visibility() = = VISIBLE)
65 ObjectPainter(m_layoutTable).paintOutline(paintInfo, paintOffset); 60 ObjectPainter(m_layoutTable).paintOutline(paintInfo, paintOffset);
66 } 61 }
67 62
68 void TablePainter::paintBoxDecorationBackground(const PaintInfo& paintInfo, cons t LayoutPoint& paintOffset) 63 void TablePainter::paintBoxDecorationBackground(const PaintInfo& paintInfo, cons t LayoutPoint& paintOffset)
69 { 64 {
70 if (!paintInfo.shouldPaintWithinRoot(&m_layoutTable)) 65 if (!paintInfo.shouldPaintWithinRoot(&m_layoutTable))
71 return; 66 return;
72 67
73 LayoutRect rect(paintOffset, m_layoutTable.size()); 68 LayoutRect rect(paintOffset, m_layoutTable.size());
74 m_layoutTable.subtractCaptionRect(rect); 69 m_layoutTable.subtractCaptionRect(rect);
75 BoxPainter(m_layoutTable).paintBoxDecorationBackgroundWithRect(paintInfo, pa intOffset, rect); 70 BoxPainter(m_layoutTable).paintBoxDecorationBackgroundWithRect(paintInfo, pa intOffset, rect);
76 } 71 }
77 72
78 void TablePainter::paintMask(const PaintInfo& paintInfo, const LayoutPoint& pain tOffset) 73 void TablePainter::paintMask(const PaintInfo& paintInfo, const LayoutPoint& pain tOffset)
79 { 74 {
80 if (m_layoutTable.style()->visibility() != VISIBLE || paintInfo.phase != Pai ntPhaseMask) 75 if (m_layoutTable.style()->visibility() != VISIBLE || paintInfo.phase != Pai ntPhaseMask)
81 return; 76 return;
82 77
83 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex t, m_layoutTable, paintInfo.phase, paintOffset)) 78 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex t, m_layoutTable, paintInfo.phase, paintOffset))
84 return; 79 return;
85 80
86 LayoutRect rect(paintOffset, m_layoutTable.size()); 81 LayoutRect rect(paintOffset, m_layoutTable.size());
87 m_layoutTable.subtractCaptionRect(rect); 82 m_layoutTable.subtractCaptionRect(rect);
88 83
89 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutTable, paint Info.phase, rect, paintOffset); 84 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutTable, paint Info.phase, rect, paintOffset);
90 BoxPainter(m_layoutTable).paintMaskImages(paintInfo, rect); 85 BoxPainter(m_layoutTable).paintMaskImages(paintInfo, rect);
91 } 86 }
92 87
93 } // namespace blink 88 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698