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/LayoutFlexibleBox.h" | 12 #include "core/layout/LayoutFlexibleBox.h" |
12 #include "core/layout/LayoutInline.h" | 13 #include "core/layout/LayoutInline.h" |
13 #include "core/page/Page.h" | 14 #include "core/page/Page.h" |
14 #include "core/paint/BoxClipper.h" | 15 #include "core/paint/BoxClipper.h" |
15 #include "core/paint/BoxPainter.h" | 16 #include "core/paint/BoxPainter.h" |
16 #include "core/paint/DeprecatedPaintLayer.h" | 17 #include "core/paint/DeprecatedPaintLayer.h" |
17 #include "core/paint/InlinePainter.h" | 18 #include "core/paint/InlinePainter.h" |
18 #include "core/paint/LayoutObjectDrawingRecorder.h" | 19 #include "core/paint/LayoutObjectDrawingRecorder.h" |
19 #include "core/paint/LineBoxListPainter.h" | 20 #include "core/paint/LineBoxListPainter.h" |
20 #include "core/paint/PaintInfo.h" | 21 #include "core/paint/PaintInfo.h" |
21 #include "core/paint/ScopeRecorder.h" | 22 #include "core/paint/ScopeRecorder.h" |
22 #include "core/paint/ScrollRecorder.h" | 23 #include "core/paint/ScrollRecorder.h" |
23 #include "core/paint/ScrollableAreaPainter.h" | 24 #include "core/paint/ScrollableAreaPainter.h" |
| 25 #include "core/paint/SubtreeRecorder.h" |
24 #include "platform/graphics/paint/ClipRecorder.h" | 26 #include "platform/graphics/paint/ClipRecorder.h" |
25 #include "wtf/Optional.h" | 27 #include "wtf/Optional.h" |
26 | 28 |
27 namespace blink { | 29 namespace blink { |
28 | 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 |
29 void BlockPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOff
set) | 39 void BlockPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOff
set) |
30 { | 40 { |
| 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 |
31 PaintInfo localPaintInfo(paintInfo); | 48 PaintInfo localPaintInfo(paintInfo); |
32 | 49 |
33 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutBlock.location(); | 50 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutBlock.location(); |
34 | 51 |
35 PaintPhase originalPhase = localPaintInfo.phase; | 52 PaintPhase originalPhase = localPaintInfo.phase; |
36 | 53 |
37 // Check if we need to do anything at all. | 54 // Check if we need to do anything at all. |
38 LayoutRect overflowBox = overflowRectForPaintRejection(); | 55 LayoutRect overflowBox = overflowRectForPaintRejection(); |
39 m_layoutBlock.flipForWritingMode(overflowBox); | 56 m_layoutBlock.flipForWritingMode(overflowBox); |
40 overflowBox.moveBy(adjustedPaintOffset); | 57 overflowBox.moveBy(adjustedPaintOffset); |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 LayoutBlock* block = flow->containingBlock(); | 354 LayoutBlock* block = flow->containingBlock(); |
338 for ( ; block && block != &m_layoutBlock; block = block->containingBlock
()) | 355 for ( ; block && block != &m_layoutBlock; block = block->containingBlock
()) |
339 accumulatedPaintOffset.moveBy(block->location()); | 356 accumulatedPaintOffset.moveBy(block->location()); |
340 ASSERT(block); | 357 ASSERT(block); |
341 InlinePainter(*flow).paintOutline(info, accumulatedPaintOffset); | 358 InlinePainter(*flow).paintOutline(info, accumulatedPaintOffset); |
342 } | 359 } |
343 } | 360 } |
344 | 361 |
345 | 362 |
346 } // namespace blink | 363 } // namespace blink |
OLD | NEW |