| 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" |
| 16 #include "core/paint/LineLayoutPaintShim.h" | 17 #include "core/paint/LineLayoutPaintShim.h" |
| 17 #include "core/paint/PaintInfo.h" | 18 #include "core/paint/PaintInfo.h" |
| 18 #include "platform/graphics/GraphicsContextStateSaver.h" | 19 #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 DisplayItem::Type displayItemType = DisplayItem::paintPhaseToDrawingType
(paintInfo.phase); | 35 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.c
ontext, m_inlineFlowBox, paintInfo.phase, paintOffset)) |
| 36 if (DrawingRecorder::useCachedDrawingIfPossible(*paintInfo.context, m_in
lineFlowBox, displayItemType)) | |
| 37 return; | 36 return; |
| 38 DrawingRecorder recorder(*paintInfo.context, m_inlineFlowBox, displayIte
mType, pixelSnappedIntRect(overflowRect)); | 37 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_inlineFlowBox
, paintInfo.phase, pixelSnappedIntRect(overflowRect), paintOffset); |
| 39 paintMask(paintInfo, paintOffset); | 38 paintMask(paintInfo, paintOffset); |
| 40 return; | 39 return; |
| 41 } | 40 } |
| 42 | 41 |
| 43 if (paintInfo.phase == PaintPhaseForeground) { | 42 if (paintInfo.phase == PaintPhaseForeground) { |
| 44 // Paint our background, border and box-shadow. | 43 // Paint our background, border and box-shadow. |
| 45 paintBoxDecorationBackground(paintInfo, paintOffset, overflowRect); | 44 paintBoxDecorationBackground(paintInfo, paintOffset, overflowRect); |
| 46 } | 45 } |
| 47 | 46 |
| 48 // Paint our children. | 47 // Paint our children. |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 const ComputedStyle* styleToUse = m_inlineFlowBox.layoutObject().style(m_inl
ineFlowBox.isFirstLineStyle()); | 192 const ComputedStyle* styleToUse = m_inlineFlowBox.layoutObject().style(m_inl
ineFlowBox.isFirstLineStyle()); |
| 194 bool shouldPaintBoxDecorationBackground; | 193 bool shouldPaintBoxDecorationBackground; |
| 195 if (m_inlineFlowBox.parent()) | 194 if (m_inlineFlowBox.parent()) |
| 196 shouldPaintBoxDecorationBackground = m_inlineFlowBox.layoutObject().hasB
oxDecorationBackground(); | 195 shouldPaintBoxDecorationBackground = m_inlineFlowBox.layoutObject().hasB
oxDecorationBackground(); |
| 197 else | 196 else |
| 198 shouldPaintBoxDecorationBackground = m_inlineFlowBox.isFirstLineStyle()
&& styleToUse != m_inlineFlowBox.layoutObject().style(); | 197 shouldPaintBoxDecorationBackground = m_inlineFlowBox.isFirstLineStyle()
&& styleToUse != m_inlineFlowBox.layoutObject().style(); |
| 199 | 198 |
| 200 if (!shouldPaintBoxDecorationBackground) | 199 if (!shouldPaintBoxDecorationBackground) |
| 201 return; | 200 return; |
| 202 | 201 |
| 203 if (DrawingRecorder::useCachedDrawingIfPossible(*paintInfo.context, m_inline
FlowBox, DisplayItem::BoxDecorationBackground)) | 202 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte
xt, m_inlineFlowBox, DisplayItem::BoxDecorationBackground, paintOffset)) |
| 204 return; | 203 return; |
| 205 | 204 |
| 206 DrawingRecorder recorder(*paintInfo.context, m_inlineFlowBox, DisplayItem::B
oxDecorationBackground, pixelSnappedIntRect(cullRect)); | 205 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_inlineFlowBox, Di
splayItem::BoxDecorationBackground, pixelSnappedIntRect(cullRect), paintOffset); |
| 207 | 206 |
| 208 LayoutRect frameRect = frameRectClampedToLineTopAndBottomIfNeeded(); | 207 LayoutRect frameRect = frameRectClampedToLineTopAndBottomIfNeeded(); |
| 209 | 208 |
| 210 // Move x/y to our coordinates. | 209 // Move x/y to our coordinates. |
| 211 LayoutRect localRect(frameRect); | 210 LayoutRect localRect(frameRect); |
| 212 m_inlineFlowBox.flipForWritingMode(localRect); | 211 m_inlineFlowBox.flipForWritingMode(localRect); |
| 213 LayoutPoint adjustedPaintOffset = paintOffset + localRect.location(); | 212 LayoutPoint adjustedPaintOffset = paintOffset + localRect.location(); |
| 214 | 213 |
| 215 LayoutRect adjustedFrameRect = LayoutRect(adjustedPaintOffset, frameRect.siz
e()); | 214 LayoutRect adjustedFrameRect = LayoutRect(adjustedPaintOffset, frameRect.siz
e()); |
| 216 | 215 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 rect.setHeight(logicalHeight); | 324 rect.setHeight(logicalHeight); |
| 326 } else { | 325 } else { |
| 327 rect.setX(logicalTop); | 326 rect.setX(logicalTop); |
| 328 rect.setWidth(logicalHeight); | 327 rect.setWidth(logicalHeight); |
| 329 } | 328 } |
| 330 } | 329 } |
| 331 return rect; | 330 return rect; |
| 332 } | 331 } |
| 333 | 332 |
| 334 } // namespace blink | 333 } // namespace blink |
| OLD | NEW |