| 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 "core/paint/InlineFlowBoxPainter.h" | 5 #include "core/paint/InlineFlowBoxPainter.h" |
| 6 | 6 |
| 7 #include "core/layout/LayoutBlock.h" | 7 #include "core/layout/LayoutBlock.h" |
| 8 #include "core/layout/LayoutInline.h" | 8 #include "core/layout/LayoutInline.h" |
| 9 #include "core/layout/LayoutView.h" | 9 #include "core/layout/LayoutView.h" |
| 10 #include "core/layout/api/LineLayoutBoxModel.h" | 10 #include "core/layout/api/LineLayoutBoxModel.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 return; | 38 return; |
| 39 } | 39 } |
| 40 | 40 |
| 41 if (paintInfo.phase == PaintPhaseForeground) { | 41 if (paintInfo.phase == PaintPhaseForeground) { |
| 42 // Paint our background, border and box-shadow. | 42 // Paint our background, border and box-shadow. |
| 43 paintBoxDecorationBackground(paintInfo, paintOffset, overflowRect); | 43 paintBoxDecorationBackground(paintInfo, paintOffset, overflowRect); |
| 44 } | 44 } |
| 45 | 45 |
| 46 // Paint our children. | 46 // Paint our children. |
| 47 PaintInfo childInfo(paintInfo); | 47 PaintInfo childInfo(paintInfo); |
| 48 LayoutObject* inlineFlowBoxLayoutObject = LineLayoutPaintShim::layoutObjectF
rom(m_inlineFlowBox.lineLayoutItem()); | |
| 49 if (childInfo.paintingRoot && childInfo.paintingRoot->isDescendantOf(inlineF
lowBoxLayoutObject)) | |
| 50 childInfo.paintingRoot = 0; | |
| 51 else | |
| 52 childInfo.updatePaintingRootForChildren(inlineFlowBoxLayoutObject); | |
| 53 | |
| 54 for (InlineBox* curr = m_inlineFlowBox.firstChild(); curr; curr = curr->next
OnLine()) { | 48 for (InlineBox* curr = m_inlineFlowBox.firstChild(); curr; curr = curr->next
OnLine()) { |
| 55 if (curr->lineLayoutItem().isText() || !curr->boxModelObject().hasSelfPa
intingLayer()) | 49 if (curr->lineLayoutItem().isText() || !curr->boxModelObject().hasSelfPa
intingLayer()) |
| 56 curr->paint(childInfo, paintOffset, lineTop, lineBottom); | 50 curr->paint(childInfo, paintOffset, lineTop, lineBottom); |
| 57 } | 51 } |
| 58 } | 52 } |
| 59 | 53 |
| 60 void InlineFlowBoxPainter::paintFillLayers(const PaintInfo& paintInfo, const Col
or& c, const FillLayer& fillLayer, const LayoutRect& rect, SkXfermode::Mode op) | 54 void InlineFlowBoxPainter::paintFillLayers(const PaintInfo& paintInfo, const Col
or& c, const FillLayer& fillLayer, const LayoutRect& rect, SkXfermode::Mode op) |
| 61 { | 55 { |
| 62 // FIXME: This should be a for loop or similar. It's a little non-trivial to
do so, however, since the layers need to be | 56 // FIXME: This should be a for loop or similar. It's a little non-trivial to
do so, however, since the layers need to be |
| 63 // painted in reverse order. | 57 // painted in reverse order. |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 // We have a border image that spans multiple lines. | 170 // We have a border image that spans multiple lines. |
| 177 adjustedClipRect = pixelSnappedIntRect(clipRectForNinePieceImageStrip(m_
inlineFlowBox, borderImage, adjustedFrameRect)); | 171 adjustedClipRect = pixelSnappedIntRect(clipRectForNinePieceImageStrip(m_
inlineFlowBox, borderImage, adjustedFrameRect)); |
| 178 return PaintBordersWithClip; | 172 return PaintBordersWithClip; |
| 179 } | 173 } |
| 180 return DontPaintBorders; | 174 return DontPaintBorders; |
| 181 } | 175 } |
| 182 | 176 |
| 183 void InlineFlowBoxPainter::paintBoxDecorationBackground(const PaintInfo& paintIn
fo, const LayoutPoint& paintOffset, const LayoutRect& cullRect) | 177 void InlineFlowBoxPainter::paintBoxDecorationBackground(const PaintInfo& paintIn
fo, const LayoutPoint& paintOffset, const LayoutRect& cullRect) |
| 184 { | 178 { |
| 185 ASSERT(paintInfo.phase == PaintPhaseForeground); | 179 ASSERT(paintInfo.phase == PaintPhaseForeground); |
| 186 LayoutObject* inlineFlowBoxLayoutObject = LineLayoutPaintShim::layoutObjectF
rom(m_inlineFlowBox.lineLayoutItem()); | 180 if (m_inlineFlowBox.lineLayoutItem().style()->visibility() != VISIBLE) |
| 187 if (!paintInfo.shouldPaintWithinRoot(inlineFlowBoxLayoutObject) || m_inlineF
lowBox.lineLayoutItem().style()->visibility() != VISIBLE) | |
| 188 return; | 181 return; |
| 189 | 182 |
| 190 // You can use p::first-line to specify a background. If so, the root line b
oxes for | 183 // You can use p::first-line to specify a background. If so, the root line b
oxes for |
| 191 // a line may actually have to paint a background. | 184 // a line may actually have to paint a background. |
| 185 LayoutObject* inlineFlowBoxLayoutObject = LineLayoutPaintShim::layoutObjectF
rom(m_inlineFlowBox.lineLayoutItem()); |
| 192 const ComputedStyle* styleToUse = m_inlineFlowBox.lineLayoutItem().style(m_i
nlineFlowBox.isFirstLineStyle()); | 186 const ComputedStyle* styleToUse = m_inlineFlowBox.lineLayoutItem().style(m_i
nlineFlowBox.isFirstLineStyle()); |
| 193 bool shouldPaintBoxDecorationBackground; | 187 bool shouldPaintBoxDecorationBackground; |
| 194 if (m_inlineFlowBox.parent()) | 188 if (m_inlineFlowBox.parent()) |
| 195 shouldPaintBoxDecorationBackground = inlineFlowBoxLayoutObject->hasBoxDe
corationBackground(); | 189 shouldPaintBoxDecorationBackground = inlineFlowBoxLayoutObject->hasBoxDe
corationBackground(); |
| 196 else | 190 else |
| 197 shouldPaintBoxDecorationBackground = m_inlineFlowBox.isFirstLineStyle()
&& styleToUse != m_inlineFlowBox.lineLayoutItem().style(); | 191 shouldPaintBoxDecorationBackground = m_inlineFlowBox.isFirstLineStyle()
&& styleToUse != m_inlineFlowBox.lineLayoutItem().style(); |
| 198 | 192 |
| 199 if (!shouldPaintBoxDecorationBackground) | 193 if (!shouldPaintBoxDecorationBackground) |
| 200 return; | 194 return; |
| 201 | 195 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 LayoutRect imageStripPaintRect = paintRectForImageStrip(adjustedPaintOff
set, frameRect.size(), LTR); | 230 LayoutRect imageStripPaintRect = paintRectForImageStrip(adjustedPaintOff
set, frameRect.size(), LTR); |
| 237 GraphicsContextStateSaver stateSaver(paintInfo.context); | 231 GraphicsContextStateSaver stateSaver(paintInfo.context); |
| 238 paintInfo.context.clip(adjustedClipRect); | 232 paintInfo.context.clip(adjustedClipRect); |
| 239 BoxPainter::paintBorder(*toLayoutBoxModelObject(LineLayoutPaintShim::lay
outObjectFrom(m_inlineFlowBox.boxModelObject())), paintInfo, imageStripPaintRect
, m_inlineFlowBox.lineLayoutItem().styleRef(m_inlineFlowBox.isFirstLineStyle()))
; | 233 BoxPainter::paintBorder(*toLayoutBoxModelObject(LineLayoutPaintShim::lay
outObjectFrom(m_inlineFlowBox.boxModelObject())), paintInfo, imageStripPaintRect
, m_inlineFlowBox.lineLayoutItem().styleRef(m_inlineFlowBox.isFirstLineStyle()))
; |
| 240 break; | 234 break; |
| 241 } | 235 } |
| 242 } | 236 } |
| 243 | 237 |
| 244 void InlineFlowBoxPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoi
nt& paintOffset) | 238 void InlineFlowBoxPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoi
nt& paintOffset) |
| 245 { | 239 { |
| 246 if (!paintInfo.shouldPaintWithinRoot(LineLayoutPaintShim::layoutObjectFrom(m
_inlineFlowBox.lineLayoutItem())) || m_inlineFlowBox.lineLayoutItem().style()->v
isibility() != VISIBLE || paintInfo.phase != PaintPhaseMask) | 240 if (m_inlineFlowBox.lineLayoutItem().style()->visibility() != VISIBLE || pai
ntInfo.phase != PaintPhaseMask) |
| 247 return; | 241 return; |
| 248 | 242 |
| 249 LayoutRect frameRect = frameRectClampedToLineTopAndBottomIfNeeded(); | 243 LayoutRect frameRect = frameRectClampedToLineTopAndBottomIfNeeded(); |
| 250 | 244 |
| 251 // Move x/y to our coordinates. | 245 // Move x/y to our coordinates. |
| 252 LayoutRect localRect(frameRect); | 246 LayoutRect localRect(frameRect); |
| 253 m_inlineFlowBox.flipForWritingMode(localRect); | 247 m_inlineFlowBox.flipForWritingMode(localRect); |
| 254 LayoutPoint adjustedPaintOffset = paintOffset + localRect.location(); | 248 LayoutPoint adjustedPaintOffset = paintOffset + localRect.location(); |
| 255 | 249 |
| 256 const NinePieceImage& maskNinePieceImage = m_inlineFlowBox.lineLayoutItem().
style()->maskBoxImage(); | 250 const NinePieceImage& maskNinePieceImage = m_inlineFlowBox.lineLayoutItem().
style()->maskBoxImage(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 rect.setHeight(logicalHeight); | 318 rect.setHeight(logicalHeight); |
| 325 } else { | 319 } else { |
| 326 rect.setX(logicalTop); | 320 rect.setX(logicalTop); |
| 327 rect.setWidth(logicalHeight); | 321 rect.setWidth(logicalHeight); |
| 328 } | 322 } |
| 329 } | 323 } |
| 330 return rect; | 324 return rect; |
| 331 } | 325 } |
| 332 | 326 |
| 333 } // namespace blink | 327 } // namespace blink |
| OLD | NEW |