| 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" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 paintInfo.outlineObjects()->add(&inlineFlow); | 60 paintInfo.outlineObjects()->add(&inlineFlow); |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 } else if (paintInfo.phase == PaintPhaseMask) { | 63 } else if (paintInfo.phase == PaintPhaseMask) { |
| 64 DrawingRecorder recorder(*paintInfo.context, m_inlineFlowBox, DisplayIte
m::paintPhaseToDrawingType(paintInfo.phase), pixelSnappedIntRect(overflowRect)); | 64 DrawingRecorder recorder(*paintInfo.context, m_inlineFlowBox, DisplayIte
m::paintPhaseToDrawingType(paintInfo.phase), pixelSnappedIntRect(overflowRect)); |
| 65 if (!recorder.canUseCachedDrawing()) | 65 if (!recorder.canUseCachedDrawing()) |
| 66 paintMask(paintInfo, paintOffset); | 66 paintMask(paintInfo, paintOffset); |
| 67 return; | 67 return; |
| 68 } else if (paintInfo.phase == PaintPhaseForeground) { | 68 } else if (paintInfo.phase == PaintPhaseForeground) { |
| 69 // Paint our background, border and box-shadow. | 69 // Paint our background, border and box-shadow. |
| 70 paintBoxDecorationBackground(paintInfo, paintOffset); | 70 paintBoxDecorationBackground(paintInfo, paintOffset, overflowRect); |
| 71 } | 71 } |
| 72 | 72 |
| 73 // Paint our children. | 73 // Paint our children. |
| 74 if (paintInfo.phase != PaintPhaseSelfOutline) { | 74 if (paintInfo.phase != PaintPhaseSelfOutline) { |
| 75 PaintInfo childInfo(paintInfo); | 75 PaintInfo childInfo(paintInfo); |
| 76 childInfo.phase = paintInfo.phase == PaintPhaseChildOutlines ? PaintPhas
eOutline : paintInfo.phase; | 76 childInfo.phase = paintInfo.phase == PaintPhaseChildOutlines ? PaintPhas
eOutline : paintInfo.phase; |
| 77 | 77 |
| 78 if (childInfo.paintingRoot && childInfo.paintingRoot->isDescendantOf(&m_
inlineFlowBox.layoutObject())) | 78 if (childInfo.paintingRoot && childInfo.paintingRoot->isDescendantOf(&m_
inlineFlowBox.layoutObject())) |
| 79 childInfo.paintingRoot = 0; | 79 childInfo.paintingRoot = 0; |
| 80 else | 80 else |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 if (!hasBorderImage || (!m_inlineFlowBox.prevLineBox() && !m_inlineFlowB
ox.nextLineBox())) | 203 if (!hasBorderImage || (!m_inlineFlowBox.prevLineBox() && !m_inlineFlowB
ox.nextLineBox())) |
| 204 return PaintBordersWithoutClip; | 204 return PaintBordersWithoutClip; |
| 205 | 205 |
| 206 // We have a border image that spans multiple lines. | 206 // We have a border image that spans multiple lines. |
| 207 adjustedClipRect = clipRectForNinePieceImageStrip(&m_inlineFlowBox, bord
erImage, adjustedFrameRect); | 207 adjustedClipRect = clipRectForNinePieceImageStrip(&m_inlineFlowBox, bord
erImage, adjustedFrameRect); |
| 208 return PaintBordersWithClip; | 208 return PaintBordersWithClip; |
| 209 } | 209 } |
| 210 return DontPaintBorders; | 210 return DontPaintBorders; |
| 211 } | 211 } |
| 212 | 212 |
| 213 void InlineFlowBoxPainter::paintBoxDecorationBackground(const PaintInfo& paintIn
fo, const LayoutPoint& paintOffset) | 213 void InlineFlowBoxPainter::paintBoxDecorationBackground(const PaintInfo& paintIn
fo, const LayoutPoint& paintOffset, const LayoutRect& cullRect) |
| 214 { | 214 { |
| 215 ASSERT(paintInfo.phase == PaintPhaseForeground); | 215 ASSERT(paintInfo.phase == PaintPhaseForeground); |
| 216 if (!paintInfo.shouldPaintWithinRoot(&m_inlineFlowBox.layoutObject()) || m_i
nlineFlowBox.layoutObject().style()->visibility() != VISIBLE) | 216 if (!paintInfo.shouldPaintWithinRoot(&m_inlineFlowBox.layoutObject()) || m_i
nlineFlowBox.layoutObject().style()->visibility() != VISIBLE) |
| 217 return; | 217 return; |
| 218 | 218 |
| 219 // You can use p::first-line to specify a background. If so, the root line b
oxes for | 219 // You can use p::first-line to specify a background. If so, the root line b
oxes for |
| 220 // a line may actually have to paint a background. | 220 // a line may actually have to paint a background. |
| 221 const ComputedStyle* styleToUse = m_inlineFlowBox.layoutObject().style(m_inl
ineFlowBox.isFirstLineStyle()); | 221 const ComputedStyle* styleToUse = m_inlineFlowBox.layoutObject().style(m_inl
ineFlowBox.isFirstLineStyle()); |
| 222 bool shouldPaintBoxDecorationBackground; | 222 bool shouldPaintBoxDecorationBackground; |
| 223 if (m_inlineFlowBox.parent()) | 223 if (m_inlineFlowBox.parent()) |
| 224 shouldPaintBoxDecorationBackground = m_inlineFlowBox.layoutObject().hasB
oxDecorationBackground(); | 224 shouldPaintBoxDecorationBackground = m_inlineFlowBox.layoutObject().hasB
oxDecorationBackground(); |
| 225 else | 225 else |
| 226 shouldPaintBoxDecorationBackground = m_inlineFlowBox.isFirstLineStyle()
&& styleToUse != m_inlineFlowBox.layoutObject().style(); | 226 shouldPaintBoxDecorationBackground = m_inlineFlowBox.isFirstLineStyle()
&& styleToUse != m_inlineFlowBox.layoutObject().style(); |
| 227 | 227 |
| 228 if (!shouldPaintBoxDecorationBackground) | 228 if (!shouldPaintBoxDecorationBackground) |
| 229 return; | 229 return; |
| 230 | 230 |
| 231 LayoutRect frameRect = roundedFrameRectClampedToLineTopAndBottomIfNeeded(); | 231 LayoutRect frameRect = roundedFrameRectClampedToLineTopAndBottomIfNeeded(); |
| 232 | 232 |
| 233 // Move x/y to our coordinates. | 233 // Move x/y to our coordinates. |
| 234 LayoutRect localRect(frameRect); | 234 LayoutRect localRect(frameRect); |
| 235 m_inlineFlowBox.flipForWritingMode(localRect); | 235 m_inlineFlowBox.flipForWritingMode(localRect); |
| 236 LayoutPoint adjustedPaintOffset = paintOffset + localRect.location(); | 236 LayoutPoint adjustedPaintOffset = paintOffset + localRect.location(); |
| 237 | 237 |
| 238 LayoutRect adjustedFrameRect = LayoutRect(adjustedPaintOffset, frameRect.siz
e()); | 238 LayoutRect adjustedFrameRect = LayoutRect(adjustedPaintOffset, frameRect.siz
e()); |
| 239 | 239 |
| 240 LayoutRect adjustedClipRect; | 240 LayoutRect adjustedClipRect; |
| 241 BorderPaintingType borderPaintingType = getBorderPaintType(adjustedFrameRect
, adjustedClipRect); | 241 BorderPaintingType borderPaintingType = getBorderPaintType(adjustedFrameRect
, adjustedClipRect); |
| 242 | 242 |
| 243 DrawingRecorder recorder(*paintInfo.context, m_inlineFlowBox, DisplayItem::B
oxDecorationBackground, pixelSnappedIntRect(adjustedClipRect)); | 243 DrawingRecorder recorder(*paintInfo.context, m_inlineFlowBox, DisplayItem::B
oxDecorationBackground, pixelSnappedIntRect(cullRect)); |
| 244 if (recorder.canUseCachedDrawing()) | 244 if (recorder.canUseCachedDrawing()) |
| 245 return; | 245 return; |
| 246 | 246 |
| 247 // Shadow comes first and is behind the background and border. | 247 // Shadow comes first and is behind the background and border. |
| 248 if (!m_inlineFlowBox.boxModelObject()->boxShadowShouldBeAppliedToBackground(
BackgroundBleedNone, &m_inlineFlowBox)) | 248 if (!m_inlineFlowBox.boxModelObject()->boxShadowShouldBeAppliedToBackground(
BackgroundBleedNone, &m_inlineFlowBox)) |
| 249 paintBoxShadow(paintInfo, *styleToUse, Normal, adjustedFrameRect); | 249 paintBoxShadow(paintInfo, *styleToUse, Normal, adjustedFrameRect); |
| 250 | 250 |
| 251 Color backgroundColor = m_inlineFlowBox.layoutObject().resolveColor(*styleTo
Use, CSSPropertyBackgroundColor); | 251 Color backgroundColor = m_inlineFlowBox.layoutObject().resolveColor(*styleTo
Use, CSSPropertyBackgroundColor); |
| 252 paintFillLayers(paintInfo, backgroundColor, styleToUse->backgroundLayers(),
adjustedFrameRect); | 252 paintFillLayers(paintInfo, backgroundColor, styleToUse->backgroundLayers(),
adjustedFrameRect); |
| 253 paintBoxShadow(paintInfo, *styleToUse, Inset, adjustedFrameRect); | 253 paintBoxShadow(paintInfo, *styleToUse, Inset, adjustedFrameRect); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 rect.setHeight(logicalHeight); | 351 rect.setHeight(logicalHeight); |
| 352 } else { | 352 } else { |
| 353 rect.setX(logicalTop); | 353 rect.setX(logicalTop); |
| 354 rect.setWidth(logicalHeight); | 354 rect.setWidth(logicalHeight); |
| 355 } | 355 } |
| 356 } | 356 } |
| 357 return rect; | 357 return rect; |
| 358 } | 358 } |
| 359 | 359 |
| 360 } // namespace blink | 360 } // namespace blink |
| OLD | NEW |