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 "core/paint/BlockPainter.h" | 5 #include "core/paint/BlockPainter.h" |
6 | 6 |
7 #include "core/editing/DragCaret.h" | 7 #include "core/editing/DragCaret.h" |
8 #include "core/editing/FrameSelection.h" | 8 #include "core/editing/FrameSelection.h" |
9 #include "core/layout/LayoutFlexibleBox.h" | 9 #include "core/layout/LayoutFlexibleBox.h" |
10 #include "core/layout/LayoutInline.h" | 10 #include "core/layout/LayoutInline.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 return; | 36 return; |
37 | 37 |
38 PaintInfo localPaintInfo(paintInfo); | 38 PaintInfo localPaintInfo(paintInfo); |
39 PaintPhase originalPhase = localPaintInfo.phase; | 39 PaintPhase originalPhase = localPaintInfo.phase; |
40 | 40 |
41 // There are some cases where not all clipped visual overflow is accounted | 41 // There are some cases where not all clipped visual overflow is accounted |
42 // for. | 42 // for. |
43 // FIXME: reduce the number of such cases. | 43 // FIXME: reduce the number of such cases. |
44 ContentsClipBehavior contentsClipBehavior = ForceContentsClip; | 44 ContentsClipBehavior contentsClipBehavior = ForceContentsClip; |
45 if (m_layoutBlock.shouldClipOverflow() && !m_layoutBlock.hasControlClip() && | 45 if (m_layoutBlock.shouldClipOverflow() && !m_layoutBlock.hasControlClip() && |
46 !m_layoutBlock.hasCaret()) | 46 !m_layoutBlock.shouldPaintCarets()) |
47 contentsClipBehavior = SkipContentsClipIfPossible; | 47 contentsClipBehavior = SkipContentsClipIfPossible; |
48 | 48 |
49 if (originalPhase == PaintPhaseOutline) { | 49 if (originalPhase == PaintPhaseOutline) { |
50 localPaintInfo.phase = PaintPhaseDescendantOutlinesOnly; | 50 localPaintInfo.phase = PaintPhaseDescendantOutlinesOnly; |
51 } else if (shouldPaintSelfBlockBackground(originalPhase)) { | 51 } else if (shouldPaintSelfBlockBackground(originalPhase)) { |
52 localPaintInfo.phase = PaintPhaseSelfBlockBackgroundOnly; | 52 localPaintInfo.phase = PaintPhaseSelfBlockBackgroundOnly; |
53 m_layoutBlock.paintObject(localPaintInfo, adjustedPaintOffset); | 53 m_layoutBlock.paintObject(localPaintInfo, adjustedPaintOffset); |
54 if (shouldPaintDescendantBlockBackgrounds(originalPhase)) | 54 if (shouldPaintDescendantBlockBackgrounds(originalPhase)) |
55 localPaintInfo.phase = PaintPhaseDescendantBlockBackgroundsOnly; | 55 localPaintInfo.phase = PaintPhaseDescendantBlockBackgroundsOnly; |
56 } | 56 } |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 } else { | 239 } else { |
240 paintContents(contentsPaintInfo, paintOffset); | 240 paintContents(contentsPaintInfo, paintOffset); |
241 } | 241 } |
242 } | 242 } |
243 | 243 |
244 if (shouldPaintSelfOutline(paintPhase)) | 244 if (shouldPaintSelfOutline(paintPhase)) |
245 ObjectPainter(m_layoutBlock).paintOutline(paintInfo, paintOffset); | 245 ObjectPainter(m_layoutBlock).paintOutline(paintInfo, paintOffset); |
246 | 246 |
247 // If the caret's node's layout object's containing block is this block, and | 247 // If the caret's node's layout object's containing block is this block, and |
248 // the paint action is PaintPhaseForeground, then paint the caret. | 248 // the paint action is PaintPhaseForeground, then paint the caret. |
249 if (paintPhase == PaintPhaseForeground && m_layoutBlock.hasCaret()) | 249 if (paintPhase == PaintPhaseForeground && m_layoutBlock.shouldPaintCarets()) |
250 paintCarets(paintInfo, paintOffset); | 250 paintCarets(paintInfo, paintOffset); |
251 } | 251 } |
252 | 252 |
253 void BlockPainter::paintCarets(const PaintInfo& paintInfo, | 253 void BlockPainter::paintCarets(const PaintInfo& paintInfo, |
254 const LayoutPoint& paintOffset) { | 254 const LayoutPoint& paintOffset) { |
255 LocalFrame* frame = m_layoutBlock.frame(); | 255 LocalFrame* frame = m_layoutBlock.frame(); |
256 | 256 |
257 if (m_layoutBlock.hasCursorCaret()) | 257 if (m_layoutBlock.shouldPaintCursorCaret()) |
258 frame->selection().paintCaret(paintInfo.context, paintOffset); | 258 frame->selection().paintCaret(paintInfo.context, paintOffset); |
259 | 259 |
260 if (m_layoutBlock.hasDragCaret()) { | 260 if (m_layoutBlock.shouldPaintDragCaret()) { |
261 frame->page()->dragCaret().paintDragCaret(frame, paintInfo.context, | 261 frame->page()->dragCaret().paintDragCaret(frame, paintInfo.context, |
262 paintOffset); | 262 paintOffset); |
263 } | 263 } |
264 } | 264 } |
265 | 265 |
266 DISABLE_CFI_PERF | 266 DISABLE_CFI_PERF |
267 bool BlockPainter::intersectsPaintRect( | 267 bool BlockPainter::intersectsPaintRect( |
268 const PaintInfo& paintInfo, | 268 const PaintInfo& paintInfo, |
269 const LayoutPoint& adjustedPaintOffset) const { | 269 const LayoutPoint& adjustedPaintOffset) const { |
270 LayoutRect overflowRect; | 270 LayoutRect overflowRect; |
(...skipping 30 matching lines...) Expand all Loading... |
301 } | 301 } |
302 | 302 |
303 void BlockPainter::paintContents(const PaintInfo& paintInfo, | 303 void BlockPainter::paintContents(const PaintInfo& paintInfo, |
304 const LayoutPoint& paintOffset) { | 304 const LayoutPoint& paintOffset) { |
305 DCHECK(!m_layoutBlock.childrenInline()); | 305 DCHECK(!m_layoutBlock.childrenInline()); |
306 PaintInfo paintInfoForDescendants = paintInfo.forDescendants(); | 306 PaintInfo paintInfoForDescendants = paintInfo.forDescendants(); |
307 m_layoutBlock.paintChildren(paintInfoForDescendants, paintOffset); | 307 m_layoutBlock.paintChildren(paintInfoForDescendants, paintOffset); |
308 } | 308 } |
309 | 309 |
310 } // namespace blink | 310 } // namespace blink |
OLD | NEW |