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/InlineFlowBoxPainter.h" | 6 #include "core/paint/InlineFlowBoxPainter.h" |
7 | 7 |
8 #include "core/layout/LayoutBlock.h" | 8 #include "core/layout/LayoutBlock.h" |
9 #include "core/layout/LayoutInline.h" | 9 #include "core/layout/LayoutInline.h" |
10 #include "core/layout/LayoutView.h" | 10 #include "core/layout/LayoutView.h" |
11 #include "core/layout/api/LineLayoutBoxModel.h" | 11 #include "core/layout/api/LineLayoutBoxModel.h" |
12 #include "core/layout/api/SelectionState.h" | 12 #include "core/layout/api/SelectionState.h" |
13 #include "core/layout/line/InlineFlowBox.h" | 13 #include "core/layout/line/InlineFlowBox.h" |
14 #include "core/paint/BoxPainter.h" | 14 #include "core/paint/BoxPainter.h" |
15 #include "core/paint/DeprecatedPaintLayer.h" | 15 #include "core/paint/DeprecatedPaintLayer.h" |
16 #include "core/paint/LayoutObjectDrawingRecorder.h" | |
17 #include "core/paint/LineLayoutPaintShim.h" | 16 #include "core/paint/LineLayoutPaintShim.h" |
18 #include "core/paint/PaintInfo.h" | 17 #include "core/paint/PaintInfo.h" |
19 #include "platform/graphics/GraphicsContextStateSaver.h" | 18 #include "platform/graphics/GraphicsContextStateSaver.h" |
| 19 #include "platform/graphics/paint/DrawingRecorder.h" |
20 | 20 |
21 namespace blink { | 21 namespace blink { |
22 | 22 |
23 void InlineFlowBoxPainter::paint(const PaintInfo& paintInfo, const LayoutPoint&
paintOffset, const LayoutUnit lineTop, const LayoutUnit lineBottom) | 23 void InlineFlowBoxPainter::paint(const PaintInfo& paintInfo, const LayoutPoint&
paintOffset, const LayoutUnit lineTop, const LayoutUnit lineBottom) |
24 { | 24 { |
25 ASSERT(paintInfo.phase != PaintPhaseOutline && paintInfo.phase != PaintPhase
SelfOutline && paintInfo.phase != PaintPhaseChildOutlines); | 25 ASSERT(paintInfo.phase != PaintPhaseOutline && paintInfo.phase != PaintPhase
SelfOutline && paintInfo.phase != PaintPhaseChildOutlines); |
26 | 26 |
27 LayoutRect overflowRect(m_inlineFlowBox.visualOverflowRect(lineTop, lineBott
om)); | 27 LayoutRect overflowRect(m_inlineFlowBox.visualOverflowRect(lineTop, lineBott
om)); |
28 m_inlineFlowBox.flipForWritingMode(overflowRect); | 28 m_inlineFlowBox.flipForWritingMode(overflowRect); |
29 overflowRect.moveBy(paintOffset); | 29 overflowRect.moveBy(paintOffset); |
30 | 30 |
31 if (!paintInfo.rect.intersects(pixelSnappedIntRect(overflowRect))) | 31 if (!paintInfo.rect.intersects(pixelSnappedIntRect(overflowRect))) |
32 return; | 32 return; |
33 | 33 |
34 if (paintInfo.phase == PaintPhaseMask) { | 34 if (paintInfo.phase == PaintPhaseMask) { |
35 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.c
ontext, m_inlineFlowBox, paintInfo.phase, paintOffset)) | 35 if (DrawingRecorder::useCachedDrawingIfPossible(*paintInfo.context, m_in
lineFlowBox, DisplayItem::paintPhaseToDrawingType(paintInfo.phase))) |
36 return; | 36 return; |
37 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_inlineFlowBox
, paintInfo.phase, pixelSnappedIntRect(overflowRect), paintOffset); | 37 DrawingRecorder recorder(*paintInfo.context, m_inlineFlowBox, DisplayIte
m::paintPhaseToDrawingType(paintInfo.phase), pixelSnappedIntRect(overflowRect)); |
38 paintMask(paintInfo, paintOffset); | 38 paintMask(paintInfo, paintOffset); |
39 return; | 39 return; |
40 } | 40 } |
41 | 41 |
42 if (paintInfo.phase == PaintPhaseForeground) { | 42 if (paintInfo.phase == PaintPhaseForeground) { |
43 // Paint our background, border and box-shadow. | 43 // Paint our background, border and box-shadow. |
44 paintBoxDecorationBackground(paintInfo, paintOffset, overflowRect); | 44 paintBoxDecorationBackground(paintInfo, paintOffset, overflowRect); |
45 } | 45 } |
46 | 46 |
47 // Paint our children. | 47 // Paint our children. |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 const ComputedStyle* styleToUse = m_inlineFlowBox.layoutObject().style(m_inl
ineFlowBox.isFirstLineStyle()); | 192 const ComputedStyle* styleToUse = m_inlineFlowBox.layoutObject().style(m_inl
ineFlowBox.isFirstLineStyle()); |
193 bool shouldPaintBoxDecorationBackground; | 193 bool shouldPaintBoxDecorationBackground; |
194 if (m_inlineFlowBox.parent()) | 194 if (m_inlineFlowBox.parent()) |
195 shouldPaintBoxDecorationBackground = m_inlineFlowBox.layoutObject().hasB
oxDecorationBackground(); | 195 shouldPaintBoxDecorationBackground = m_inlineFlowBox.layoutObject().hasB
oxDecorationBackground(); |
196 else | 196 else |
197 shouldPaintBoxDecorationBackground = m_inlineFlowBox.isFirstLineStyle()
&& styleToUse != m_inlineFlowBox.layoutObject().style(); | 197 shouldPaintBoxDecorationBackground = m_inlineFlowBox.isFirstLineStyle()
&& styleToUse != m_inlineFlowBox.layoutObject().style(); |
198 | 198 |
199 if (!shouldPaintBoxDecorationBackground) | 199 if (!shouldPaintBoxDecorationBackground) |
200 return; | 200 return; |
201 | 201 |
202 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte
xt, m_inlineFlowBox, DisplayItem::BoxDecorationBackground, paintOffset)) | 202 if (DrawingRecorder::useCachedDrawingIfPossible(*paintInfo.context, m_inline
FlowBox, DisplayItem::BoxDecorationBackground)) |
203 return; | 203 return; |
204 | 204 |
205 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_inlineFlowBox, Di
splayItem::BoxDecorationBackground, pixelSnappedIntRect(cullRect), paintOffset); | 205 DrawingRecorder recorder(*paintInfo.context, m_inlineFlowBox, DisplayItem::B
oxDecorationBackground, pixelSnappedIntRect(cullRect)); |
206 | 206 |
207 LayoutRect frameRect = frameRectClampedToLineTopAndBottomIfNeeded(); | 207 LayoutRect frameRect = frameRectClampedToLineTopAndBottomIfNeeded(); |
208 | 208 |
209 // Move x/y to our coordinates. | 209 // Move x/y to our coordinates. |
210 LayoutRect localRect(frameRect); | 210 LayoutRect localRect(frameRect); |
211 m_inlineFlowBox.flipForWritingMode(localRect); | 211 m_inlineFlowBox.flipForWritingMode(localRect); |
212 LayoutPoint adjustedPaintOffset = paintOffset + localRect.location(); | 212 LayoutPoint adjustedPaintOffset = paintOffset + localRect.location(); |
213 | 213 |
214 LayoutRect adjustedFrameRect = LayoutRect(adjustedPaintOffset, frameRect.siz
e()); | 214 LayoutRect adjustedFrameRect = LayoutRect(adjustedPaintOffset, frameRect.siz
e()); |
215 | 215 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 rect.setHeight(logicalHeight); | 324 rect.setHeight(logicalHeight); |
325 } else { | 325 } else { |
326 rect.setX(logicalTop); | 326 rect.setX(logicalTop); |
327 rect.setWidth(logicalHeight); | 327 rect.setWidth(logicalHeight); |
328 } | 328 } |
329 } | 329 } |
330 return rect; | 330 return rect; |
331 } | 331 } |
332 | 332 |
333 } // namespace blink | 333 } // namespace blink |
OLD | NEW |