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

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

Issue 576823004: Move painting code for tables into *Paint classes. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix. Created 6 years, 3 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "core/paint/TablePainter.h"
7
8 #include "core/paint/BoxPainter.h"
9 #include "core/rendering/GraphicsContextAnnotator.h"
10 #include "core/rendering/PaintInfo.h"
11 #include "core/rendering/RenderTable.h"
12 #include "core/rendering/RenderTableSection.h"
13 #include "core/rendering/style/CollapsedBorderValue.h"
14
15 namespace blink {
16
17 void TablePainter::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
18 {
19 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, &m_renderTable);
20
21 LayoutPoint adjustedPaintOffset = paintOffset + m_renderTable.location();
22
23 PaintPhase paintPhase = paintInfo.phase;
24
25 if (!m_renderTable.isDocumentElement()) {
26 LayoutRect overflowBox = m_renderTable.visualOverflowRect();
27 m_renderTable.flipForWritingMode(overflowBox);
28 overflowBox.moveBy(adjustedPaintOffset);
29 if (!overflowBox.intersects(paintInfo.rect))
30 return;
31 }
32
33 bool pushedClip = m_renderTable.pushContentsClip(paintInfo, adjustedPaintOff set, ForceContentsClip);
34 paintObject(paintInfo, adjustedPaintOffset);
35 if (pushedClip)
36 m_renderTable.popContentsClip(paintInfo, paintPhase, adjustedPaintOffset );
37 }
38
39 void TablePainter::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOff set)
40 {
41 PaintPhase paintPhase = paintInfo.phase;
42 if ((paintPhase == PaintPhaseBlockBackground || paintPhase == PaintPhaseChil dBlockBackground) && m_renderTable.hasBoxDecorationBackground() && m_renderTable .style()->visibility() == VISIBLE)
43 paintBoxDecorationBackground(paintInfo, paintOffset);
44
45 if (paintPhase == PaintPhaseMask) {
46 m_renderTable.paintMask(paintInfo, paintOffset);
47 return;
48 }
49
50 // We're done. We don't bother painting any children.
51 if (paintPhase == PaintPhaseBlockBackground)
52 return;
53
54 // We don't paint our own background, but we do let the kids paint their bac kgrounds.
55 if (paintPhase == PaintPhaseChildBlockBackgrounds)
56 paintPhase = PaintPhaseChildBlockBackground;
57
58 PaintInfo info(paintInfo);
59 info.phase = paintPhase;
60 info.updatePaintingRootForChildren(&m_renderTable);
61
62 for (RenderObject* child = m_renderTable.firstChild(); child; child = child- >nextSibling()) {
63 if (child->isBox() && !toRenderBox(child)->hasSelfPaintingLayer() && (ch ild->isTableSection() || child->isTableCaption())) {
64 LayoutPoint childPoint = m_renderTable.flipForWritingModeForChild(to RenderBox(child), paintOffset);
65 child->paint(info, childPoint);
66 }
67 }
68
69 if (m_renderTable.collapseBorders() && paintPhase == PaintPhaseChildBlockBac kground && m_renderTable.style()->visibility() == VISIBLE) {
70 m_renderTable.recalcCollapsedBorders();
71 // Using our cached sorted styles, we then do individual passes,
72 // painting each style of border from lowest precedence to highest prece dence.
73 info.phase = PaintPhaseCollapsedTableBorders;
74 RenderTable::CollapsedBorderValues collapsedBorders = m_renderTable.coll apsedBorders();
75 size_t count = collapsedBorders.size();
76 for (size_t i = 0; i < count; ++i) {
77 // FIXME: pass this value into children rather than storing temporar ily on the RenderTable object.
78 m_renderTable.setCurrentBorderValue(&collapsedBorders[i]);
79 for (RenderTableSection* section = m_renderTable.bottomSection(); se ction; section = m_renderTable.sectionAbove(section)) {
80 LayoutPoint childPoint = m_renderTable.flipForWritingModeForChil d(section, paintOffset);
81 section->paint(info, childPoint);
82 }
83 }
84 m_renderTable.setCurrentBorderValue(0);
85 }
86
87 // Paint outline.
88 if ((paintPhase == PaintPhaseOutline || paintPhase == PaintPhaseSelfOutline) && m_renderTable.style()->hasOutline() && m_renderTable.style()->visibility() = = VISIBLE)
89 m_renderTable.paintOutline(paintInfo, LayoutRect(paintOffset, m_renderTa ble.size()));
90 }
91
92 void TablePainter::paintBoxDecorationBackground(PaintInfo& paintInfo, const Layo utPoint& paintOffset)
93 {
94 if (!paintInfo.shouldPaintWithinRoot(&m_renderTable))
95 return;
96
97 LayoutRect rect(paintOffset, m_renderTable.size());
98 m_renderTable.subtractCaptionRect(rect);
99 BoxPainter(m_renderTable).paintBoxDecorationBackgroundWithRect(paintInfo, pa intOffset, rect);
100 }
101
102 void TablePainter::paintMask(PaintInfo& paintInfo, const LayoutPoint& paintOffse t)
103 {
104 if (m_renderTable.style()->visibility() != VISIBLE || paintInfo.phase != Pai ntPhaseMask)
105 return;
106
107 LayoutRect rect(paintOffset, m_renderTable.size());
108 m_renderTable.subtractCaptionRect(rect);
109
110 BoxPainter(m_renderTable).paintMaskImages(paintInfo, rect);
111 }
112
mstensho (USE GERRIT) 2014/09/19 10:50:11 Double blank line.
chrishtr 2014/09/19 16:35:24 Done.
113
114 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698