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/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" |
11 #include "core/layout/LayoutBlockFlow.h" | 11 #include "core/layout/LayoutBlockFlow.h" |
12 #include "core/layout/LayoutFlexibleBox.h" | 12 #include "core/layout/LayoutFlexibleBox.h" |
13 #include "core/layout/LayoutInline.h" | 13 #include "core/layout/LayoutInline.h" |
14 #include "core/page/Page.h" | 14 #include "core/page/Page.h" |
15 #include "core/paint/BoxClipper.h" | 15 #include "core/paint/BoxClipper.h" |
16 #include "core/paint/BoxPainter.h" | 16 #include "core/paint/BoxPainter.h" |
17 #include "core/paint/DeprecatedPaintLayer.h" | 17 #include "core/paint/DeprecatedPaintLayer.h" |
18 #include "core/paint/InlinePainter.h" | 18 #include "core/paint/InlinePainter.h" |
19 #include "core/paint/LayoutObjectDrawingRecorder.h" | 19 #include "core/paint/LayoutObjectDrawingRecorder.h" |
20 #include "core/paint/LineBoxListPainter.h" | 20 #include "core/paint/LineBoxListPainter.h" |
21 #include "core/paint/PaintInfo.h" | 21 #include "core/paint/PaintInfo.h" |
22 #include "core/paint/ScopeRecorder.h" | 22 #include "core/paint/ScopeRecorder.h" |
23 #include "core/paint/ScrollRecorder.h" | 23 #include "core/paint/ScrollRecorder.h" |
24 #include "core/paint/ScrollableAreaPainter.h" | 24 #include "core/paint/ScrollableAreaPainter.h" |
| 25 #include "core/paint/SubtreeRecorder.h" |
25 #include "platform/graphics/paint/ClipRecorder.h" | 26 #include "platform/graphics/paint/ClipRecorder.h" |
26 #include "platform/graphics/paint/SubtreeRecorder.h" | |
27 #include "wtf/Optional.h" | 27 #include "wtf/Optional.h" |
28 | 28 |
29 namespace blink { | 29 namespace blink { |
30 | 30 |
31 // We need to balance the benefit of subtree optimization and the cost of subtre
e display items. | |
32 // Only output subtree information if the block has multiple children or multipl
e line boxes. | |
33 static bool needsSubtreeRecorder(const LayoutBlock& layoutBlock) | |
34 { | |
35 return (layoutBlock.firstChild() && layoutBlock.firstChild()->nextSibling()) | |
36 || (layoutBlock.isLayoutBlockFlow() && toLayoutBlockFlow(layoutBlock).fi
rstLineBox() && toLayoutBlockFlow(layoutBlock).firstLineBox()->nextLineBox()); | |
37 } | |
38 | |
39 void BlockPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOff
set) | 31 void BlockPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOff
set) |
40 { | 32 { |
41 Optional<SubtreeRecorder> subtreeRecorder; | |
42 if (needsSubtreeRecorder(m_layoutBlock)) { | |
43 subtreeRecorder.emplace(*paintInfo.context, m_layoutBlock, paintInfo.pha
se); | |
44 if (subtreeRecorder->canUseCache()) | |
45 return; | |
46 } | |
47 | |
48 PaintInfo localPaintInfo(paintInfo); | 33 PaintInfo localPaintInfo(paintInfo); |
49 | 34 |
50 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutBlock.location(); | 35 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutBlock.location(); |
51 | 36 |
52 PaintPhase originalPhase = localPaintInfo.phase; | 37 PaintPhase originalPhase = localPaintInfo.phase; |
53 | 38 |
54 // Check if we need to do anything at all. | 39 // Check if we need to do anything at all. |
55 LayoutRect overflowBox = overflowRectForPaintRejection(); | 40 LayoutRect overflowBox = overflowRectForPaintRejection(); |
56 m_layoutBlock.flipForWritingMode(overflowBox); | 41 m_layoutBlock.flipForWritingMode(overflowBox); |
57 overflowBox.moveBy(adjustedPaintOffset); | 42 overflowBox.moveBy(adjustedPaintOffset); |
58 if (!overflowBox.intersects(LayoutRect(localPaintInfo.rect))) | 43 if (!overflowBox.intersects(LayoutRect(localPaintInfo.rect))) |
59 return; | 44 return; |
60 | 45 |
| 46 SubtreeRecorder subtreeRecorder(*paintInfo.context, m_layoutBlock, paintInfo
.phase); |
| 47 if (subtreeRecorder.canUseCache()) |
| 48 return; |
| 49 |
61 // There are some cases where not all clipped visual overflow is accounted f
or. | 50 // There are some cases where not all clipped visual overflow is accounted f
or. |
62 // FIXME: reduce the number of such cases. | 51 // FIXME: reduce the number of such cases. |
63 ContentsClipBehavior contentsClipBehavior = ForceContentsClip; | 52 ContentsClipBehavior contentsClipBehavior = ForceContentsClip; |
64 if (m_layoutBlock.hasOverflowClip() && !m_layoutBlock.hasControlClip() && !(
m_layoutBlock.shouldPaintSelectionGaps() && originalPhase == PaintPhaseForegroun
d) && !hasCaret()) | 53 if (m_layoutBlock.hasOverflowClip() && !m_layoutBlock.hasControlClip() && !(
m_layoutBlock.shouldPaintSelectionGaps() && originalPhase == PaintPhaseForegroun
d) && !hasCaret()) |
65 contentsClipBehavior = SkipContentsClipIfPossible; | 54 contentsClipBehavior = SkipContentsClipIfPossible; |
66 | 55 |
67 if (localPaintInfo.phase == PaintPhaseOutline) { | 56 if (localPaintInfo.phase == PaintPhaseOutline) { |
68 localPaintInfo.phase = PaintPhaseChildOutlines; | 57 localPaintInfo.phase = PaintPhaseChildOutlines; |
69 } else if (localPaintInfo.phase == PaintPhaseChildBlockBackground) { | 58 } else if (localPaintInfo.phase == PaintPhaseChildBlockBackground) { |
70 localPaintInfo.phase = PaintPhaseBlockBackground; | 59 localPaintInfo.phase = PaintPhaseBlockBackground; |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 LayoutBlock* block = flow->containingBlock(); | 343 LayoutBlock* block = flow->containingBlock(); |
355 for ( ; block && block != &m_layoutBlock; block = block->containingBlock
()) | 344 for ( ; block && block != &m_layoutBlock; block = block->containingBlock
()) |
356 accumulatedPaintOffset.moveBy(block->location()); | 345 accumulatedPaintOffset.moveBy(block->location()); |
357 ASSERT(block); | 346 ASSERT(block); |
358 InlinePainter(*flow).paintOutline(info, accumulatedPaintOffset); | 347 InlinePainter(*flow).paintOutline(info, accumulatedPaintOffset); |
359 } | 348 } |
360 } | 349 } |
361 | 350 |
362 | 351 |
363 } // namespace blink | 352 } // namespace blink |
OLD | NEW |