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