OLD | NEW |
---|---|
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/Caret.h" | 8 #include "core/editing/Caret.h" |
9 #include "core/editing/FrameSelection.h" | 9 #include "core/editing/FrameSelection.h" |
10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 // Our scrollbar widgets paint exactly when we tell them to, so that they wo rk properly with | 80 // Our scrollbar widgets paint exactly when we tell them to, so that they wo rk properly with |
81 // z-index. We paint after we painted the background/border, so that the scr ollbars will | 81 // z-index. We paint after we painted the background/border, so that the scr ollbars will |
82 // sit above the background/border. | 82 // sit above the background/border. |
83 paintOverflowControlsIfNeeded(localPaintInfo, adjustedPaintOffset); | 83 paintOverflowControlsIfNeeded(localPaintInfo, adjustedPaintOffset); |
84 } | 84 } |
85 | 85 |
86 void BlockPainter::paintOverflowControlsIfNeeded(const PaintInfo& paintInfo, con st LayoutPoint& paintOffset) | 86 void BlockPainter::paintOverflowControlsIfNeeded(const PaintInfo& paintInfo, con st LayoutPoint& paintOffset) |
87 { | 87 { |
88 PaintPhase phase = paintInfo.phase; | 88 PaintPhase phase = paintInfo.phase; |
89 if (m_renderBlock.hasOverflowClip() && m_renderBlock.style()->visibility() = = VISIBLE && (phase == PaintPhaseBlockBackground || phase == PaintPhaseChildBloc kBackground) && paintInfo.shouldPaintWithinRoot(&m_renderBlock) && !paintInfo.pa intRootBackgroundOnly()) { | 89 if (m_renderBlock.hasOverflowClip() && m_renderBlock.style()->visibility() = = VISIBLE && (phase == PaintPhaseBlockBackground || phase == PaintPhaseChildBloc kBackground) && paintInfo.shouldPaintWithinRoot(&m_renderBlock) && !paintInfo.pa intRootBackgroundOnly()) { |
90 RenderDrawingRecorder recorder(paintInfo.context, &m_renderBlock, paintI nfo.phase, pixelSnappedIntRect(paintOffset, m_renderBlock.visualOverflowRect().s ize())); | 90 RenderDrawingRecorder recorder(paintInfo.context, m_renderBlock, paintIn fo.phase, pixelSnappedIntRect(paintOffset, m_renderBlock.visualOverflowRect().si ze())); |
91 ScrollableAreaPainter(*m_renderBlock.layer()->scrollableArea()).paintOve rflowControls(paintInfo.context, roundedIntPoint(paintOffset), paintInfo.rect, f alse /* paintingOverlayControls */); | 91 if (!recorder.canUseCachedDrawing()) |
92 ScrollableAreaPainter(*m_renderBlock.layer()->scrollableArea()).pain tOverflowControls(paintInfo.context, roundedIntPoint(paintOffset), paintInfo.rec t, false /* paintingOverlayControls */); | |
chrishtr
2014/12/11 20:01:48
Why are these safe? Unless we are very careful, we
Xianzhu
2014/12/11 20:22:16
I think we'll emit DrawingDisplayItems/CachedDispl
chrishtr
2014/12/12 00:18:08
Oh right, it's within a block that has a DrawingRe
| |
92 } | 93 } |
93 } | 94 } |
94 | 95 |
95 void BlockPainter::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& paintOffset) | 96 void BlockPainter::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& paintOffset) |
96 { | 97 { |
97 for (RenderBox* child = m_renderBlock.firstChildBox(); child; child = child- >nextSiblingBox()) | 98 for (RenderBox* child = m_renderBlock.firstChildBox(); child; child = child- >nextSiblingBox()) |
98 paintChild(child, paintInfo, paintOffset); | 99 paintChild(child, paintInfo, paintOffset); |
99 } | 100 } |
100 | 101 |
101 void BlockPainter::paintChild(RenderBox* child, const PaintInfo& paintInfo, cons t LayoutPoint& paintOffset) | 102 void BlockPainter::paintChild(RenderBox* child, const PaintInfo& paintInfo, cons t LayoutPoint& paintOffset) |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 } | 172 } |
172 | 173 |
173 if ((paintPhase == PaintPhaseBlockBackground || paintPhase == PaintPhaseChil dBlockBackground) && m_renderBlock.style()->visibility() == VISIBLE) { | 174 if ((paintPhase == PaintPhaseBlockBackground || paintPhase == PaintPhaseChil dBlockBackground) && m_renderBlock.style()->visibility() == VISIBLE) { |
174 if (m_renderBlock.hasBoxDecorationBackground()) | 175 if (m_renderBlock.hasBoxDecorationBackground()) |
175 m_renderBlock.paintBoxDecorationBackground(paintInfo, paintOffset); | 176 m_renderBlock.paintBoxDecorationBackground(paintInfo, paintOffset); |
176 if (m_renderBlock.hasColumns() && !paintInfo.paintRootBackgroundOnly()) | 177 if (m_renderBlock.hasColumns() && !paintInfo.paintRootBackgroundOnly()) |
177 paintColumnRules(paintInfo, scrolledOffset); | 178 paintColumnRules(paintInfo, scrolledOffset); |
178 } | 179 } |
179 | 180 |
180 if (paintPhase == PaintPhaseMask && m_renderBlock.style()->visibility() == V ISIBLE) { | 181 if (paintPhase == PaintPhaseMask && m_renderBlock.style()->visibility() == V ISIBLE) { |
181 RenderDrawingRecorder recorder(paintInfo.context, &m_renderBlock, paintP hase, bounds); | 182 RenderDrawingRecorder recorder(paintInfo.context, m_renderBlock, paintPh ase, bounds); |
182 m_renderBlock.paintMask(paintInfo, paintOffset); | 183 if (!recorder.canUseCachedDrawing()) |
184 m_renderBlock.paintMask(paintInfo, paintOffset); | |
183 return; | 185 return; |
184 } | 186 } |
185 | 187 |
186 if (paintPhase == PaintPhaseClippingMask && m_renderBlock.style()->visibilit y() == VISIBLE) { | 188 if (paintPhase == PaintPhaseClippingMask && m_renderBlock.style()->visibilit y() == VISIBLE) { |
187 RenderDrawingRecorder recorder(paintInfo.context, &m_renderBlock, paintP hase, bounds); | 189 RenderDrawingRecorder recorder(paintInfo.context, m_renderBlock, paintPh ase, bounds); |
188 m_renderBlock.paintClippingMask(paintInfo, paintOffset); | 190 if (!recorder.canUseCachedDrawing()) |
191 m_renderBlock.paintClippingMask(paintInfo, paintOffset); | |
189 return; | 192 return; |
190 } | 193 } |
191 | 194 |
192 // We're done. We don't bother painting any children. | 195 // We're done. We don't bother painting any children. |
193 if (paintPhase == PaintPhaseBlockBackground || paintInfo.paintRootBackground Only()) | 196 if (paintPhase == PaintPhaseBlockBackground || paintInfo.paintRootBackground Only()) |
194 return; | 197 return; |
195 | 198 |
196 if (paintPhase != PaintPhaseSelfOutline) { | 199 if (paintPhase != PaintPhaseSelfOutline) { |
197 if (m_renderBlock.hasColumns()) | 200 if (m_renderBlock.hasColumns()) |
198 paintColumnContents(paintInfo, scrolledOffset); | 201 paintColumnContents(paintInfo, scrolledOffset); |
(...skipping 19 matching lines...) Expand all Loading... | |
218 if (!m_renderBlock.style()->outlineStyleIsAuto() || !m_renderBlock.isAno nymousBlockContinuation()) | 221 if (!m_renderBlock.style()->outlineStyleIsAuto() || !m_renderBlock.isAno nymousBlockContinuation()) |
219 ObjectPainter(m_renderBlock).paintOutline(paintInfo, LayoutRect(pain tOffset, m_renderBlock.size())); | 222 ObjectPainter(m_renderBlock).paintOutline(paintInfo, LayoutRect(pain tOffset, m_renderBlock.size())); |
220 } | 223 } |
221 | 224 |
222 if (paintPhase == PaintPhaseOutline || paintPhase == PaintPhaseChildOutlines ) | 225 if (paintPhase == PaintPhaseOutline || paintPhase == PaintPhaseChildOutlines ) |
223 paintContinuationOutlines(paintInfo, paintOffset); | 226 paintContinuationOutlines(paintInfo, paintOffset); |
224 | 227 |
225 // If the caret's node's render object's containing block is this block, and the paint action is PaintPhaseForeground, | 228 // If the caret's node's render object's containing block is this block, and the paint action is PaintPhaseForeground, |
226 // then paint the caret. | 229 // then paint the caret. |
227 if (paintPhase == PaintPhaseForeground) { | 230 if (paintPhase == PaintPhaseForeground) { |
228 RenderDrawingRecorder recorder(paintInfo.context, &m_renderBlock, paintP hase, bounds); | 231 RenderDrawingRecorder recorder(paintInfo.context, m_renderBlock, paintPh ase, bounds); |
229 paintCarets(paintInfo, paintOffset); | 232 if (!recorder.canUseCachedDrawing()) |
233 paintCarets(paintInfo, paintOffset); | |
230 } | 234 } |
231 } | 235 } |
232 | 236 |
233 static inline bool caretBrowsingEnabled(const Frame* frame) | 237 static inline bool caretBrowsingEnabled(const Frame* frame) |
234 { | 238 { |
235 Settings* settings = frame->settings(); | 239 Settings* settings = frame->settings(); |
236 return settings && settings->caretBrowsingEnabled(); | 240 return settings && settings->caretBrowsingEnabled(); |
237 } | 241 } |
238 | 242 |
239 static inline bool hasCursorCaret(const FrameSelection& selection, const RenderB lock* block, bool caretBrowsing) | 243 static inline bool hasCursorCaret(const FrameSelection& selection, const RenderB lock* block, bool caretBrowsing) |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
485 RenderBlock* block = flow->containingBlock(); | 489 RenderBlock* block = flow->containingBlock(); |
486 for ( ; block && block != &m_renderBlock; block = block->containingBlock ()) | 490 for ( ; block && block != &m_renderBlock; block = block->containingBlock ()) |
487 accumulatedPaintOffset.moveBy(block->location()); | 491 accumulatedPaintOffset.moveBy(block->location()); |
488 ASSERT(block); | 492 ASSERT(block); |
489 InlinePainter(*flow).paintOutline(info, accumulatedPaintOffset); | 493 InlinePainter(*flow).paintOutline(info, accumulatedPaintOffset); |
490 } | 494 } |
491 } | 495 } |
492 | 496 |
493 | 497 |
494 } // namespace blink | 498 } // namespace blink |
OLD | NEW |