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

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

Issue 1512803004: Use refs for GraphicsContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ScrollbarTheme
Patch Set: Created 5 years 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 "config.h" 5 #include "config.h"
6 #include "core/paint/BlockPainter.h" 6 #include "core/paint/BlockPainter.h"
7 7
8 #include "core/editing/DragCaretController.h" 8 #include "core/editing/DragCaretController.h"
9 #include "core/editing/FrameSelection.h" 9 #include "core/editing/FrameSelection.h"
10 #include "core/frame/Settings.h" 10 #include "core/frame/Settings.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 71 }
72 72
73 void BlockPainter::paintOverflowControlsIfNeeded(const PaintInfo& paintInfo, con st LayoutPoint& paintOffset) 73 void BlockPainter::paintOverflowControlsIfNeeded(const PaintInfo& paintInfo, con st LayoutPoint& paintOffset)
74 { 74 {
75 PaintPhase phase = paintInfo.phase; 75 PaintPhase phase = paintInfo.phase;
76 if (m_layoutBlock.hasOverflowClip() && m_layoutBlock.style()->visibility() = = VISIBLE && (phase == PaintPhaseBlockBackground || phase == PaintPhaseChildBloc kBackground) && paintInfo.shouldPaintWithinRoot(&m_layoutBlock) && !paintInfo.pa intRootBackgroundOnly()) { 76 if (m_layoutBlock.hasOverflowClip() && m_layoutBlock.style()->visibility() = = VISIBLE && (phase == PaintPhaseBlockBackground || phase == PaintPhaseChildBloc kBackground) && paintInfo.shouldPaintWithinRoot(&m_layoutBlock) && !paintInfo.pa intRootBackgroundOnly()) {
77 Optional<ClipRecorder> clipRecorder; 77 Optional<ClipRecorder> clipRecorder;
78 if (!m_layoutBlock.layer()->isSelfPaintingLayer()) { 78 if (!m_layoutBlock.layer()->isSelfPaintingLayer()) {
79 LayoutRect clipRect = m_layoutBlock.borderBoxRect(); 79 LayoutRect clipRect = m_layoutBlock.borderBoxRect();
80 clipRect.moveBy(paintOffset); 80 clipRect.moveBy(paintOffset);
81 clipRecorder.emplace(*paintInfo.context, m_layoutBlock, DisplayItem: :ClipScrollbarsToBoxBounds, clipRect); 81 clipRecorder.emplace(paintInfo.context, m_layoutBlock, DisplayItem:: ClipScrollbarsToBoxBounds, clipRect);
82 } 82 }
83 ScrollableAreaPainter(*m_layoutBlock.layer()->scrollableArea()).paintOve rflowControls(*paintInfo.context, roundedIntPoint(paintOffset), paintInfo.cullRe ct(), false /* paintingOverlayControls */); 83 ScrollableAreaPainter(*m_layoutBlock.layer()->scrollableArea()).paintOve rflowControls(paintInfo.context, roundedIntPoint(paintOffset), paintInfo.cullRec t(), false /* paintingOverlayControls */);
84 } 84 }
85 } 85 }
86 86
87 void BlockPainter::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& paintOffset) 87 void BlockPainter::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
88 { 88 {
89 for (LayoutBox* child = m_layoutBlock.firstChildBox(); child; child = child- >nextSiblingBox()) 89 for (LayoutBox* child = m_layoutBlock.firstChildBox(); child; child = child- >nextSiblingBox())
90 paintChild(*child, paintInfo, paintOffset); 90 paintChild(*child, paintInfo, paintOffset);
91 } 91 }
92 92
93 void BlockPainter::paintChild(const LayoutBox& child, const PaintInfo& paintInfo , const LayoutPoint& paintOffset) 93 void BlockPainter::paintChild(const LayoutBox& child, const PaintInfo& paintInfo , const LayoutPoint& paintOffset)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 layoutObject.paint(info, childPoint); 142 layoutObject.paint(info, childPoint);
143 info.phase = PaintPhaseForeground; 143 info.phase = PaintPhaseForeground;
144 layoutObject.paint(info, childPoint); 144 layoutObject.paint(info, childPoint);
145 info.phase = PaintPhaseOutline; 145 info.phase = PaintPhaseOutline;
146 layoutObject.paint(info, childPoint); 146 layoutObject.paint(info, childPoint);
147 } 147 }
148 } 148 }
149 149
150 void BlockPainter::paintObject(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) 150 void BlockPainter::paintObject(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset)
151 { 151 {
152 if (RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled() && m_layoutB lock.childrenInline() && !paintInfo.context->paintController().skippingCache()) { 152 if (RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled() && m_layoutB lock.childrenInline() && !paintInfo.context.paintController().skippingCache()) {
153 if (m_layoutBlock.paintOffsetChanged(paintOffset)) { 153 if (m_layoutBlock.paintOffsetChanged(paintOffset)) {
154 LineBoxListPainter(m_layoutBlock.lineBoxes()).invalidateLineBoxPaint Offsets(paintInfo); 154 LineBoxListPainter(m_layoutBlock.lineBoxes()).invalidateLineBoxPaint Offsets(paintInfo);
155 paintInfo.context->paintController().invalidatePaintOffset(m_layoutB lock); 155 paintInfo.context.paintController().invalidatePaintOffset(m_layoutBl ock);
156 } 156 }
157 // Set previousPaintOffset here in case that m_layoutBlock paints nothin g and no 157 // Set previousPaintOffset here in case that m_layoutBlock paints nothin g and no
158 // LayoutObjectDrawingRecorder updates its previousPaintOffset. 158 // LayoutObjectDrawingRecorder updates its previousPaintOffset.
159 // TODO(wangxianzhu): Integrate paint offset checking into new paint inv alidation. 159 // TODO(wangxianzhu): Integrate paint offset checking into new paint inv alidation.
160 m_layoutBlock.mutableForPainting().setPreviousPaintOffset(paintOffset); 160 m_layoutBlock.mutableForPainting().setPreviousPaintOffset(paintOffset);
161 } 161 }
162 162
163 const PaintPhase paintPhase = paintInfo.phase; 163 const PaintPhase paintPhase = paintInfo.phase;
164 164
165 if ((paintPhase == PaintPhaseBlockBackground || paintPhase == PaintPhaseChil dBlockBackground) 165 if ((paintPhase == PaintPhaseBlockBackground || paintPhase == PaintPhaseChil dBlockBackground)
(...skipping 15 matching lines...) Expand all
181 // this rect may be covered by foreground and descendant drawings. Then we m ay need a dedicated paint phase. 181 // this rect may be covered by foreground and descendant drawings. Then we m ay need a dedicated paint phase.
182 if (paintPhase == PaintPhaseForeground && paintInfo.isPrinting()) 182 if (paintPhase == PaintPhaseForeground && paintInfo.isPrinting())
183 ObjectPainter(m_layoutBlock).addPDFURLRectIfNeeded(paintInfo, paintOffse t); 183 ObjectPainter(m_layoutBlock).addPDFURLRectIfNeeded(paintInfo, paintOffse t);
184 184
185 { 185 {
186 Optional<ScrollRecorder> scrollRecorder; 186 Optional<ScrollRecorder> scrollRecorder;
187 Optional<PaintInfo> scrolledPaintInfo; 187 Optional<PaintInfo> scrolledPaintInfo;
188 if (m_layoutBlock.hasOverflowClip()) { 188 if (m_layoutBlock.hasOverflowClip()) {
189 IntSize scrollOffset = m_layoutBlock.scrolledContentOffset(); 189 IntSize scrollOffset = m_layoutBlock.scrolledContentOffset();
190 if (m_layoutBlock.layer()->scrollsOverflow() || !scrollOffset.isZero ()) { 190 if (m_layoutBlock.layer()->scrollsOverflow() || !scrollOffset.isZero ()) {
191 scrollRecorder.emplace(*paintInfo.context, m_layoutBlock, paintP hase, scrollOffset); 191 scrollRecorder.emplace(paintInfo.context, m_layoutBlock, paintPh ase, scrollOffset);
192 scrolledPaintInfo.emplace(paintInfo); 192 scrolledPaintInfo.emplace(paintInfo);
193 AffineTransform transform; 193 AffineTransform transform;
194 transform.translate(-scrollOffset.width(), -scrollOffset.height( )); 194 transform.translate(-scrollOffset.width(), -scrollOffset.height( ));
195 scrolledPaintInfo->updateCullRect(transform); 195 scrolledPaintInfo->updateCullRect(transform);
196 } 196 }
197 } 197 }
198 198
199 // We're done. We don't bother painting any children. 199 // We're done. We don't bother painting any children.
200 if (paintPhase == PaintPhaseBlockBackground || paintInfo.paintRootBackgr oundOnly()) 200 if (paintPhase == PaintPhaseBlockBackground || paintInfo.paintRootBackgr oundOnly())
201 return; 201 return;
202 202
203 const PaintInfo& contentsPaintInfo = scrolledPaintInfo ? *scrolledPaintI nfo : paintInfo; 203 const PaintInfo& contentsPaintInfo = scrolledPaintInfo ? *scrolledPaintI nfo : paintInfo;
204 204
205 if (paintPhase != PaintPhaseSelfOutline) 205 if (paintPhase != PaintPhaseSelfOutline)
206 paintContents(contentsPaintInfo, paintOffset); 206 paintContents(contentsPaintInfo, paintOffset);
207 207
208 if (paintPhase == PaintPhaseForeground && !paintInfo.isPrinting()) 208 if (paintPhase == PaintPhaseForeground && !paintInfo.isPrinting())
209 m_layoutBlock.paintSelection(contentsPaintInfo, paintOffset); // Fil l in gaps in selection on lines and between blocks. 209 m_layoutBlock.paintSelection(contentsPaintInfo, paintOffset); // Fil l in gaps in selection on lines and between blocks.
210 210
211 if (paintPhase == PaintPhaseFloat || paintPhase == PaintPhaseSelection | | paintPhase == PaintPhaseTextClip) 211 if (paintPhase == PaintPhaseFloat || paintPhase == PaintPhaseSelection | | paintPhase == PaintPhaseTextClip)
212 m_layoutBlock.paintFloats(contentsPaintInfo, paintOffset, paintPhase == PaintPhaseSelection || paintPhase == PaintPhaseTextClip); 212 m_layoutBlock.paintFloats(contentsPaintInfo, paintOffset, paintPhase == PaintPhaseSelection || paintPhase == PaintPhaseTextClip);
213 } 213 }
214 214
215 if ((paintPhase == PaintPhaseOutline || paintPhase == PaintPhaseSelfOutline) && m_layoutBlock.style()->hasOutline() && m_layoutBlock.style()->visibility() = = VISIBLE) 215 if ((paintPhase == PaintPhaseOutline || paintPhase == PaintPhaseSelfOutline) && m_layoutBlock.style()->hasOutline() && m_layoutBlock.style()->visibility() = = VISIBLE)
216 ObjectPainter(m_layoutBlock).paintOutline(paintInfo, paintOffset); 216 ObjectPainter(m_layoutBlock).paintOutline(paintInfo, paintOffset);
217 217
218 // If the caret's node's layout object's containing block is this block, and the paint action is PaintPhaseForeground, 218 // If the caret's node's layout object's containing block is this block, and the paint action is PaintPhaseForeground,
219 // then paint the caret. 219 // then paint the caret.
220 if (paintPhase == PaintPhaseForeground && m_layoutBlock.hasCaret() && !Layou tObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.context, m_layoutB lock, DisplayItem::Caret, paintOffset)) { 220 if (paintPhase == PaintPhaseForeground && m_layoutBlock.hasCaret() && !Layou tObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.context, m_layoutBl ock, DisplayItem::Caret, paintOffset)) {
221 LayoutRect bounds = m_layoutBlock.visualOverflowRect(); 221 LayoutRect bounds = m_layoutBlock.visualOverflowRect();
222 bounds.moveBy(paintOffset); 222 bounds.moveBy(paintOffset);
223 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutBlock, DisplayItem::Caret, bounds, paintOffset); 223 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutBlock, D isplayItem::Caret, bounds, paintOffset);
224 paintCarets(paintInfo, paintOffset); 224 paintCarets(paintInfo, paintOffset);
225 } 225 }
226 } 226 }
227 227
228 void BlockPainter::paintCarets(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) 228 void BlockPainter::paintCarets(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset)
229 { 229 {
230 LocalFrame* frame = m_layoutBlock.frame(); 230 LocalFrame* frame = m_layoutBlock.frame();
231 231
232 if (m_layoutBlock.hasCursorCaret()) 232 if (m_layoutBlock.hasCursorCaret())
233 frame->selection().paintCaret(paintInfo.context, paintOffset); 233 frame->selection().paintCaret(paintInfo.context, paintOffset);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 267
268 // We don't paint our own background, but we do let the kids paint their backgrounds. 268 // We don't paint our own background, but we do let the kids paint their backgrounds.
269 PaintInfo paintInfoForChild(paintInfo); 269 PaintInfo paintInfoForChild(paintInfo);
270 paintInfoForChild.phase = newPhase; 270 paintInfoForChild.phase = newPhase;
271 paintInfoForChild.updatePaintingRootForChildren(&m_layoutBlock); 271 paintInfoForChild.updatePaintingRootForChildren(&m_layoutBlock);
272 m_layoutBlock.paintChildren(paintInfoForChild, paintOffset); 272 m_layoutBlock.paintChildren(paintInfoForChild, paintOffset);
273 } 273 }
274 } 274 }
275 275
276 } // namespace blink 276 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/BlockFlowPainter.cpp ('k') | third_party/WebKit/Source/core/paint/BoxBorderPainter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698