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/LineBoxListPainter.h" | 6 #include "core/paint/LineBoxListPainter.h" |
7 | 7 |
8 #include "core/layout/LayoutBoxModelObject.h" | 8 #include "core/layout/LayoutBoxModelObject.h" |
| 9 #include "core/layout/LayoutInline.h" |
9 #include "core/layout/api/LineLayoutBoxModel.h" | 10 #include "core/layout/api/LineLayoutBoxModel.h" |
10 #include "core/layout/line/InlineFlowBox.h" | 11 #include "core/layout/line/InlineFlowBox.h" |
11 #include "core/layout/line/LineBoxList.h" | 12 #include "core/layout/line/LineBoxList.h" |
12 #include "core/layout/line/RootInlineBox.h" | 13 #include "core/layout/line/RootInlineBox.h" |
13 #include "core/paint/InlinePainter.h" | 14 #include "core/paint/InlinePainter.h" |
14 #include "core/paint/ObjectPainter.h" | 15 #include "core/paint/ObjectPainter.h" |
15 #include "core/paint/PaintInfo.h" | 16 #include "core/paint/PaintInfo.h" |
16 | 17 |
17 namespace blink { | 18 namespace blink { |
18 | 19 |
19 static void addPDFURLRectsForInlineChildrenRecursively(LayoutObject* layoutObjec
t, const PaintInfo& paintInfo, const LayoutPoint& paintOffset) | 20 static void addPDFURLRectsForInlineChildrenRecursively(LayoutObject* layoutObjec
t, const PaintInfo& paintInfo, const LayoutPoint& paintOffset) |
20 { | 21 { |
21 for (LayoutObject* child = layoutObject->slowFirstChild(); child; child = ch
ild->nextSibling()) { | 22 for (LayoutObject* child = layoutObject->slowFirstChild(); child; child = ch
ild->nextSibling()) { |
22 if (!child->isLayoutInline() || toLayoutBoxModelObject(child)->hasSelfPa
intingLayer()) | 23 if (!child->isLayoutInline() || toLayoutBoxModelObject(child)->hasSelfPa
intingLayer()) |
23 continue; | 24 continue; |
24 ObjectPainter(*child).addPDFURLRectIfNeeded(paintInfo, paintOffset); | 25 ObjectPainter(*child).addPDFURLRectIfNeeded(paintInfo, paintOffset); |
25 addPDFURLRectsForInlineChildrenRecursively(child, paintInfo, paintOffset
); | 26 addPDFURLRectsForInlineChildrenRecursively(child, paintInfo, paintOffset
); |
26 } | 27 } |
27 } | 28 } |
28 | 29 |
29 void LineBoxListPainter::paint(LayoutBoxModelObject* layoutObject, const PaintIn
fo& paintInfo, const LayoutPoint& paintOffset) const | 30 void LineBoxListPainter::paint(LayoutBoxModelObject* layoutObject, const PaintIn
fo& paintInfo, const LayoutPoint& paintOffset) const |
30 { | 31 { |
| 32 ASSERT(paintInfo.phase != PaintPhaseOutline && paintInfo.phase != PaintPhase
SelfOutline && paintInfo.phase != PaintPhaseChildOutlines); |
| 33 |
31 // Only paint during the foreground/selection phases. | 34 // Only paint during the foreground/selection phases. |
32 if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhase
Selection && paintInfo.phase != PaintPhaseOutline | 35 if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhase
Selection && paintInfo.phase != PaintPhaseTextClip && paintInfo.phase != PaintPh
aseMask) |
33 && paintInfo.phase != PaintPhaseSelfOutline && paintInfo.phase != PaintP
haseChildOutlines && paintInfo.phase != PaintPhaseTextClip | |
34 && paintInfo.phase != PaintPhaseMask) | |
35 return; | 36 return; |
36 | 37 |
37 ASSERT(layoutObject->isLayoutBlock() || (layoutObject->isLayoutInline() && l
ayoutObject->hasLayer())); // The only way an inline could paint like this is if
it has a layer. | 38 ASSERT(layoutObject->isLayoutBlock() || (layoutObject->isLayoutInline() && l
ayoutObject->hasLayer())); // The only way an inline could paint like this is if
it has a layer. |
38 | 39 |
39 // FIXME: When Skia supports annotation rect covering (https://code.google.c
om/p/skia/issues/detail?id=3872), | 40 // FIXME: When Skia supports annotation rect covering (https://code.google.c
om/p/skia/issues/detail?id=3872), |
40 // these rects may be covered line box drawings. Then we may need a dedicate
d paint phase. | 41 // these rects may be covered line box drawings. Then we may need a dedicate
d paint phase. |
41 if (paintInfo.phase == PaintPhaseForeground && paintInfo.isPrinting()) | 42 if (paintInfo.phase == PaintPhaseForeground && paintInfo.isPrinting()) |
42 addPDFURLRectsForInlineChildrenRecursively(layoutObject, paintInfo, pain
tOffset); | 43 addPDFURLRectsForInlineChildrenRecursively(layoutObject, paintInfo, pain
tOffset); |
43 | 44 |
44 // If we have no lines then we have no work to do. | 45 // If we have no lines then we have no work to do. |
45 if (!m_lineBoxList.firstLineBox()) | 46 if (!m_lineBoxList.firstLineBox()) |
46 return; | 47 return; |
47 | 48 |
48 if (!m_lineBoxList.anyLineIntersectsRect(LineLayoutBoxModel(layoutObject), L
ayoutRect(paintInfo.rect), paintOffset)) | 49 if (!m_lineBoxList.anyLineIntersectsRect(LineLayoutBoxModel(layoutObject), L
ayoutRect(paintInfo.rect), paintOffset)) |
49 return; | 50 return; |
50 | 51 |
51 PaintInfo info(paintInfo); | 52 PaintInfo info(paintInfo); |
52 ListHashSet<LayoutInline*> outlineObjects; | |
53 info.setOutlineObjects(&outlineObjects); | |
54 | 53 |
55 // See if our root lines intersect with the dirty rect. If so, then we paint | 54 // See if our root lines intersect with the dirty rect. If so, then we paint |
56 // them. Note that boxes can easily overlap, so we can't make any assumption
s | 55 // them. Note that boxes can easily overlap, so we can't make any assumption
s |
57 // based off positions of our first line box or our last line box. | 56 // based off positions of our first line box or our last line box. |
58 for (InlineFlowBox* curr = m_lineBoxList.firstLineBox(); curr; curr = curr->
nextLineBox()) { | 57 for (InlineFlowBox* curr = m_lineBoxList.firstLineBox(); curr; curr = curr->
nextLineBox()) { |
59 if (m_lineBoxList.lineIntersectsDirtyRect(LineLayoutBoxModel(layoutObjec
t), curr, info, paintOffset)) { | 58 if (m_lineBoxList.lineIntersectsDirtyRect(LineLayoutBoxModel(layoutObjec
t), curr, info, paintOffset)) { |
60 RootInlineBox& root = curr->root(); | 59 RootInlineBox& root = curr->root(); |
61 curr->paint(info, paintOffset, root.lineTop(), root.lineBottom()); | 60 curr->paint(info, paintOffset, root.lineTop(), root.lineBottom()); |
62 } | 61 } |
63 } | 62 } |
64 | |
65 if (info.phase == PaintPhaseOutline || info.phase == PaintPhaseSelfOutline |
| info.phase == PaintPhaseChildOutlines) { | |
66 for (LayoutInline* flow : *info.outlineObjects()) | |
67 InlinePainter(*flow).paintOutline(info, paintOffset); | |
68 info.outlineObjects()->clear(); | |
69 } | |
70 } | 63 } |
71 | 64 |
72 } // namespace blink | 65 } // namespace blink |
OLD | NEW |