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