OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/BlockFlowPaintInvalidator.h" | 5 #include "core/paint/BlockFlowPaintInvalidator.h" |
6 | 6 |
7 #include "core/layout/LayoutBlockFlow.h" | 7 #include "core/layout/LayoutBlockFlow.h" |
8 #include "core/layout/LayoutInline.h" | 8 #include "core/layout/LayoutInline.h" |
9 #include "core/paint/BoxPaintInvalidator.h" | 9 #include "core/paint/BoxPaintInvalidator.h" |
10 #include "core/paint/PaintInvalidator.h" | 10 #include "core/paint/PaintInvalidator.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 void BlockFlowPaintInvalidator::invalidatePaintForOverhangingFloatsInternal( | 14 void BlockFlowPaintInvalidator::invalidatePaintForOverhangingFloatsInternal( |
15 InvalidateDescendantMode invalidateDescendants) { | 15 InvalidateDescendantMode invalidateDescendants) { |
16 // Invalidate paint of any overhanging floats (if we know we're the one to pai
nt them). | 16 // Invalidate paint of any overhanging floats (if we know we're the one to |
17 // Otherwise, bail out. | 17 // paint them). Otherwise, bail out. |
18 if (!m_blockFlow.hasOverhangingFloats()) | 18 if (!m_blockFlow.hasOverhangingFloats()) |
19 return; | 19 return; |
20 | 20 |
21 for (const auto& floatingObject : m_blockFlow.floatingObjects()->set()) { | 21 for (const auto& floatingObject : m_blockFlow.floatingObjects()->set()) { |
22 // Only issue paint invalidations for the object if it is overhanging, is no
t in its own layer, and | 22 // Only issue paint invalidations for the object if it is overhanging, is |
23 // is our responsibility to paint (m_shouldPaint is set). When paintAllDesce
ndants is true, the latter | 23 // not in its own layer, and is our responsibility to paint (m_shouldPaint |
24 // condition is replaced with being a descendant of us. | 24 // is set). When paintAllDescendants is true, the latter condition is |
| 25 // replaced with being a descendant of us. |
25 if (m_blockFlow.isOverhangingFloat(*floatingObject) && | 26 if (m_blockFlow.isOverhangingFloat(*floatingObject) && |
26 !floatingObject->layoutObject()->hasSelfPaintingLayer() && | 27 !floatingObject->layoutObject()->hasSelfPaintingLayer() && |
27 (floatingObject->shouldPaint() || | 28 (floatingObject->shouldPaint() || |
28 (invalidateDescendants == InvalidateDescendants && | 29 (invalidateDescendants == InvalidateDescendants && |
29 floatingObject->layoutObject()->isDescendantOf(&m_blockFlow)))) { | 30 floatingObject->layoutObject()->isDescendantOf(&m_blockFlow)))) { |
30 LayoutBox* floatingBox = floatingObject->layoutObject(); | 31 LayoutBox* floatingBox = floatingObject->layoutObject(); |
31 floatingBox->setShouldDoFullPaintInvalidation(); | 32 floatingBox->setShouldDoFullPaintInvalidation(); |
32 if (floatingBox->isLayoutBlockFlow()) | 33 if (floatingBox->isLayoutBlockFlow()) |
33 BlockFlowPaintInvalidator(*toLayoutBlockFlow(floatingBox)) | 34 BlockFlowPaintInvalidator(*toLayoutBlockFlow(floatingBox)) |
34 .invalidatePaintForOverhangingFloatsInternal( | 35 .invalidatePaintForOverhangingFloatsInternal( |
35 DontInvalidateDescendants); | 36 DontInvalidateDescendants); |
36 } | 37 } |
37 } | 38 } |
38 } | 39 } |
39 | 40 |
40 void BlockFlowPaintInvalidator::invalidateDisplayItemClients( | 41 void BlockFlowPaintInvalidator::invalidateDisplayItemClients( |
41 PaintInvalidationReason reason) { | 42 PaintInvalidationReason reason) { |
42 ObjectPaintInvalidator objectPaintInvalidator(m_blockFlow); | 43 ObjectPaintInvalidator objectPaintInvalidator(m_blockFlow); |
43 objectPaintInvalidator.invalidateDisplayItemClient(m_blockFlow, reason); | 44 objectPaintInvalidator.invalidateDisplayItemClient(m_blockFlow, reason); |
44 | 45 |
45 // PaintInvalidationRectangle happens when we invalidate the caret. | 46 // PaintInvalidationRectangle happens when we invalidate the caret. |
46 // The later conditions don't apply when we invalidate the caret or the select
ion. | 47 // The later conditions don't apply when we invalidate the caret or the |
| 48 // selection. |
47 if (reason == PaintInvalidationRectangle || | 49 if (reason == PaintInvalidationRectangle || |
48 reason == PaintInvalidationSelection) | 50 reason == PaintInvalidationSelection) |
49 return; | 51 return; |
50 | 52 |
51 // If the block is a continuation or containing block of an inline continuatio
n, invalidate the | 53 // If the block is a continuation or containing block of an inline |
52 // start object of the continuations if it has focus ring because change of co
ntinuation may change | 54 // continuation, invalidate the start object of the continuations if it has |
53 // the shape of the focus ring. | 55 // focus ring because change of continuation may change the shape of the focus |
| 56 // ring. |
54 if (m_blockFlow.isAnonymous()) { | 57 if (m_blockFlow.isAnonymous()) { |
55 LayoutObject* startOfContinuations = nullptr; | 58 LayoutObject* startOfContinuations = nullptr; |
56 if (LayoutInline* inlineElementContinuation = | 59 if (LayoutInline* inlineElementContinuation = |
57 m_blockFlow.inlineElementContinuation()) { | 60 m_blockFlow.inlineElementContinuation()) { |
58 // This block is an anonymous block continuation. | 61 // This block is an anonymous block continuation. |
59 startOfContinuations = inlineElementContinuation->node()->layoutObject(); | 62 startOfContinuations = inlineElementContinuation->node()->layoutObject(); |
60 } else if (LayoutObject* firstChild = m_blockFlow.firstChild()) { | 63 } else if (LayoutObject* firstChild = m_blockFlow.firstChild()) { |
61 // This block is the anonymous containing block of an inline element conti
nuation. | 64 // This block is the anonymous containing block of an inline element |
| 65 // continuation. |
62 if (firstChild->isElementContinuation()) | 66 if (firstChild->isElementContinuation()) |
63 startOfContinuations = firstChild->node()->layoutObject(); | 67 startOfContinuations = firstChild->node()->layoutObject(); |
64 } | 68 } |
65 if (startOfContinuations && | 69 if (startOfContinuations && |
66 startOfContinuations->styleRef().outlineStyleIsAuto()) | 70 startOfContinuations->styleRef().outlineStyleIsAuto()) |
67 ObjectPaintInvalidator(*startOfContinuations) | 71 ObjectPaintInvalidator(*startOfContinuations) |
68 .slowSetPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient( | 72 .slowSetPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient( |
69 *startOfContinuations, reason); | 73 *startOfContinuations, reason); |
70 } | 74 } |
71 | 75 |
72 RootInlineBox* line = m_blockFlow.firstRootBox(); | 76 RootInlineBox* line = m_blockFlow.firstRootBox(); |
73 if (line && line->isFirstLineStyle()) { | 77 if (line && line->isFirstLineStyle()) { |
74 // It's the RootInlineBox that paints the ::first-line background. Note that
since it may be | 78 // It's the RootInlineBox that paints the ::first-line background. Note that |
75 // expensive to figure out if the first line is affected by any ::first-line
selectors at all, | 79 // since it may be expensive to figure out if the first line is affected by |
76 // we just invalidate it unconditionally which is typically cheaper. | 80 // any ::first-line selectors at all, we just invalidate it unconditionally |
| 81 // which is typically cheaper. |
77 objectPaintInvalidator.invalidateDisplayItemClient(*line, reason); | 82 objectPaintInvalidator.invalidateDisplayItemClient(*line, reason); |
78 } | 83 } |
79 | 84 |
80 if (m_blockFlow.multiColumnFlowThread()) { | 85 if (m_blockFlow.multiColumnFlowThread()) { |
81 // Invalidate child LayoutMultiColumnSets which may need to repaint column r
ules after | 86 // Invalidate child LayoutMultiColumnSets which may need to repaint column |
82 // m_blockFlow's column rule style and/or layout changed. | 87 // rules after m_blockFlow's column rule style and/or layout changed. |
83 for (LayoutObject* child = m_blockFlow.firstChild(); child; | 88 for (LayoutObject* child = m_blockFlow.firstChild(); child; |
84 child = child->nextSibling()) { | 89 child = child->nextSibling()) { |
85 if (child->isLayoutMultiColumnSet() && | 90 if (child->isLayoutMultiColumnSet() && |
86 !child->shouldDoFullPaintInvalidation()) | 91 !child->shouldDoFullPaintInvalidation()) |
87 objectPaintInvalidator.invalidateDisplayItemClient(*child, reason); | 92 objectPaintInvalidator.invalidateDisplayItemClient(*child, reason); |
88 } | 93 } |
89 } | 94 } |
90 } | 95 } |
91 | 96 |
92 } // namespace blink | 97 } // namespace blink |
OLD | NEW |