| 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/SelectionState.h" | 12 #include "core/layout/api/SelectionState.h" |
| 12 #include "core/layout/line/InlineFlowBox.h" | 13 #include "core/layout/line/InlineFlowBox.h" |
| 13 #include "core/paint/BoxPainter.h" | 14 #include "core/paint/BoxPainter.h" |
| 14 #include "core/paint/DeprecatedPaintLayer.h" | 15 #include "core/paint/DeprecatedPaintLayer.h" |
| 15 #include "core/paint/PaintInfo.h" | 16 #include "core/paint/PaintInfo.h" |
| 16 #include "platform/graphics/GraphicsContextStateSaver.h" | 17 #include "platform/graphics/GraphicsContextStateSaver.h" |
| 17 #include "platform/graphics/paint/DrawingRecorder.h" | 18 #include "platform/graphics/paint/DrawingRecorder.h" |
| 18 | 19 |
| 19 namespace blink { | 20 namespace blink { |
| 20 | 21 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 37 bool containingBlockPaintsContinuationOutline = inlineFlow.continuat
ion() || inlineFlow.isInlineElementContinuation(); | 38 bool containingBlockPaintsContinuationOutline = inlineFlow.continuat
ion() || inlineFlow.isInlineElementContinuation(); |
| 38 if (containingBlockPaintsContinuationOutline) { | 39 if (containingBlockPaintsContinuationOutline) { |
| 39 // FIXME: See https://bugs.webkit.org/show_bug.cgi?id=54690. We
currently don't reconnect inline continuations | 40 // FIXME: See https://bugs.webkit.org/show_bug.cgi?id=54690. We
currently don't reconnect inline continuations |
| 40 // after a child removal. As a result, those merged inlines do n
ot get seperated and hence not get enclosed by | 41 // after a child removal. As a result, those merged inlines do n
ot get seperated and hence not get enclosed by |
| 41 // anonymous blocks. In this case, it is better to bail out and
paint it ourself. | 42 // anonymous blocks. In this case, it is better to bail out and
paint it ourself. |
| 42 LayoutBlock* enclosingAnonymousBlock = m_inlineFlowBox.layoutObj
ect().containingBlock(); | 43 LayoutBlock* enclosingAnonymousBlock = m_inlineFlowBox.layoutObj
ect().containingBlock(); |
| 43 if (!enclosingAnonymousBlock->isAnonymousBlock()) { | 44 if (!enclosingAnonymousBlock->isAnonymousBlock()) { |
| 44 containingBlockPaintsContinuationOutline = false; | 45 containingBlockPaintsContinuationOutline = false; |
| 45 } else { | 46 } else { |
| 46 cb = enclosingAnonymousBlock->containingBlock(); | 47 cb = enclosingAnonymousBlock->containingBlock(); |
| 47 for (LayoutBoxModelObject* box = m_inlineFlowBox.deprecatedB
oxModelObject(); box != cb; box = box->parent()->enclosingBoxModelObject()) { | 48 for (LineLayoutBoxModel box = m_inlineFlowBox.boxModelObject
(); box != cb; box = box.parent().enclosingBoxModelObject()) { |
| 48 if (box->hasSelfPaintingLayer()) { | 49 if (box.hasSelfPaintingLayer()) { |
| 49 containingBlockPaintsContinuationOutline = false; | 50 containingBlockPaintsContinuationOutline = false; |
| 50 break; | 51 break; |
| 51 } | 52 } |
| 52 } | 53 } |
| 53 } | 54 } |
| 54 } | 55 } |
| 55 | 56 |
| 56 if (containingBlockPaintsContinuationOutline) { | 57 if (containingBlockPaintsContinuationOutline) { |
| 57 // Add ourselves to the containing block of the entire continuat
ion so that it can | 58 // Add ourselves to the containing block of the entire continuat
ion so that it can |
| 58 // paint us atomically. | 59 // paint us atomically. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 77 if (paintInfo.phase != PaintPhaseSelfOutline) { | 78 if (paintInfo.phase != PaintPhaseSelfOutline) { |
| 78 PaintInfo childInfo(paintInfo); | 79 PaintInfo childInfo(paintInfo); |
| 79 childInfo.phase = paintInfo.phase == PaintPhaseChildOutlines ? PaintPhas
eOutline : paintInfo.phase; | 80 childInfo.phase = paintInfo.phase == PaintPhaseChildOutlines ? PaintPhas
eOutline : paintInfo.phase; |
| 80 | 81 |
| 81 if (childInfo.paintingRoot && childInfo.paintingRoot->isDescendantOf(&m_
inlineFlowBox.layoutObject())) | 82 if (childInfo.paintingRoot && childInfo.paintingRoot->isDescendantOf(&m_
inlineFlowBox.layoutObject())) |
| 82 childInfo.paintingRoot = 0; | 83 childInfo.paintingRoot = 0; |
| 83 else | 84 else |
| 84 childInfo.updatePaintingRootForChildren(&m_inlineFlowBox.layoutObjec
t()); | 85 childInfo.updatePaintingRootForChildren(&m_inlineFlowBox.layoutObjec
t()); |
| 85 | 86 |
| 86 for (InlineBox* curr = m_inlineFlowBox.firstChild(); curr; curr = curr->
nextOnLine()) { | 87 for (InlineBox* curr = m_inlineFlowBox.firstChild(); curr; curr = curr->
nextOnLine()) { |
| 87 if (curr->layoutObject().isText() || !curr->deprecatedBoxModelObject
()->hasSelfPaintingLayer()) | 88 if (curr->lineLayoutItem().isText() || !curr->boxModelObject().hasSe
lfPaintingLayer()) |
| 88 curr->paint(childInfo, paintOffset, lineTop, lineBottom); | 89 curr->paint(childInfo, paintOffset, lineTop, lineBottom); |
| 89 } | 90 } |
| 90 } | 91 } |
| 91 } | 92 } |
| 92 | 93 |
| 93 void InlineFlowBoxPainter::paintFillLayers(const PaintInfo& paintInfo, const Col
or& c, const FillLayer& fillLayer, const LayoutRect& rect, SkXfermode::Mode op) | 94 void InlineFlowBoxPainter::paintFillLayers(const PaintInfo& paintInfo, const Col
or& c, const FillLayer& fillLayer, const LayoutRect& rect, SkXfermode::Mode op) |
| 94 { | 95 { |
| 95 // 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 | 96 // 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 |
| 96 // painted in reverse order. | 97 // painted in reverse order. |
| 97 if (fillLayer.next()) | 98 if (fillLayer.next()) |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 LayoutRect localRect(frameRect); | 243 LayoutRect localRect(frameRect); |
| 243 m_inlineFlowBox.flipForWritingMode(localRect); | 244 m_inlineFlowBox.flipForWritingMode(localRect); |
| 244 LayoutPoint adjustedPaintOffset = paintOffset + localRect.location(); | 245 LayoutPoint adjustedPaintOffset = paintOffset + localRect.location(); |
| 245 | 246 |
| 246 LayoutRect adjustedFrameRect = LayoutRect(adjustedPaintOffset, frameRect.siz
e()); | 247 LayoutRect adjustedFrameRect = LayoutRect(adjustedPaintOffset, frameRect.siz
e()); |
| 247 | 248 |
| 248 LayoutRect adjustedClipRect; | 249 LayoutRect adjustedClipRect; |
| 249 BorderPaintingType borderPaintingType = getBorderPaintType(adjustedFrameRect
, adjustedClipRect); | 250 BorderPaintingType borderPaintingType = getBorderPaintType(adjustedFrameRect
, adjustedClipRect); |
| 250 | 251 |
| 251 // Shadow comes first and is behind the background and border. | 252 // Shadow comes first and is behind the background and border. |
| 252 if (!m_inlineFlowBox.deprecatedBoxModelObject()->boxShadowShouldBeAppliedToB
ackground(BackgroundBleedNone, &m_inlineFlowBox)) | 253 if (!m_inlineFlowBox.boxModelObject().boxShadowShouldBeAppliedToBackground(B
ackgroundBleedNone, &m_inlineFlowBox)) |
| 253 paintBoxShadow(paintInfo, *styleToUse, Normal, adjustedFrameRect); | 254 paintBoxShadow(paintInfo, *styleToUse, Normal, adjustedFrameRect); |
| 254 | 255 |
| 255 Color backgroundColor = m_inlineFlowBox.layoutObject().resolveColor(*styleTo
Use, CSSPropertyBackgroundColor); | 256 Color backgroundColor = m_inlineFlowBox.layoutObject().resolveColor(*styleTo
Use, CSSPropertyBackgroundColor); |
| 256 paintFillLayers(paintInfo, backgroundColor, styleToUse->backgroundLayers(),
adjustedFrameRect); | 257 paintFillLayers(paintInfo, backgroundColor, styleToUse->backgroundLayers(),
adjustedFrameRect); |
| 257 paintBoxShadow(paintInfo, *styleToUse, Inset, adjustedFrameRect); | 258 paintBoxShadow(paintInfo, *styleToUse, Inset, adjustedFrameRect); |
| 258 | 259 |
| 259 switch (borderPaintingType) { | 260 switch (borderPaintingType) { |
| 260 case DontPaintBorders: | 261 case DontPaintBorders: |
| 261 break; | 262 break; |
| 262 case PaintBordersWithoutClip: | 263 case PaintBordersWithoutClip: |
| (...skipping 21 matching lines...) Expand all Loading... |
| 284 // Move x/y to our coordinates. | 285 // Move x/y to our coordinates. |
| 285 LayoutRect localRect(frameRect); | 286 LayoutRect localRect(frameRect); |
| 286 m_inlineFlowBox.flipForWritingMode(localRect); | 287 m_inlineFlowBox.flipForWritingMode(localRect); |
| 287 LayoutPoint adjustedPaintOffset = paintOffset + localRect.location(); | 288 LayoutPoint adjustedPaintOffset = paintOffset + localRect.location(); |
| 288 | 289 |
| 289 const NinePieceImage& maskNinePieceImage = m_inlineFlowBox.layoutObject().st
yle()->maskBoxImage(); | 290 const NinePieceImage& maskNinePieceImage = m_inlineFlowBox.layoutObject().st
yle()->maskBoxImage(); |
| 290 StyleImage* maskBoxImage = m_inlineFlowBox.layoutObject().style()->maskBoxIm
age().image(); | 291 StyleImage* maskBoxImage = m_inlineFlowBox.layoutObject().style()->maskBoxIm
age().image(); |
| 291 | 292 |
| 292 // Figure out if we need to push a transparency layer to render our mask. | 293 // Figure out if we need to push a transparency layer to render our mask. |
| 293 bool pushTransparencyLayer = false; | 294 bool pushTransparencyLayer = false; |
| 294 bool compositedMask = m_inlineFlowBox.layoutObject().hasLayer() && m_inlineF
lowBox.deprecatedBoxModelObject()->layer()->hasCompositedMask(); | 295 bool compositedMask = m_inlineFlowBox.layoutObject().hasLayer() && m_inlineF
lowBox.boxModelObject().layer()->hasCompositedMask(); |
| 295 bool flattenCompositingLayers = paintInfo.globalPaintFlags() & GlobalPaintFl
attenCompositingLayers; | 296 bool flattenCompositingLayers = paintInfo.globalPaintFlags() & GlobalPaintFl
attenCompositingLayers; |
| 296 SkXfermode::Mode compositeOp = SkXfermode::kSrcOver_Mode; | 297 SkXfermode::Mode compositeOp = SkXfermode::kSrcOver_Mode; |
| 297 if (!compositedMask || flattenCompositingLayers) { | 298 if (!compositedMask || flattenCompositingLayers) { |
| 298 if ((maskBoxImage && m_inlineFlowBox.layoutObject().style()->maskLayers(
).hasImage()) || m_inlineFlowBox.layoutObject().style()->maskLayers().next()) { | 299 if ((maskBoxImage && m_inlineFlowBox.layoutObject().style()->maskLayers(
).hasImage()) || m_inlineFlowBox.layoutObject().style()->maskLayers().next()) { |
| 299 pushTransparencyLayer = true; | 300 pushTransparencyLayer = true; |
| 300 paintInfo.context->beginLayer(1.0f, SkXfermode::kDstIn_Mode); | 301 paintInfo.context->beginLayer(1.0f, SkXfermode::kDstIn_Mode); |
| 301 } else { | 302 } else { |
| 302 // TODO(fmalita): passing a dst-in xfer mode down to paintFillLayers
/paintNinePieceImage | 303 // TODO(fmalita): passing a dst-in xfer mode down to paintFillLayers
/paintNinePieceImage |
| 303 // seems dangerous: it is only correct if applied atomically (sing
le draw call). While | 304 // seems dangerous: it is only correct if applied atomically (sing
le draw call). While |
| 304 // the heuristic above presumably ensures that is the case, this a
pproach seems super | 305 // the heuristic above presumably ensures that is the case, this a
pproach seems super |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 rect.setHeight(logicalHeight); | 356 rect.setHeight(logicalHeight); |
| 356 } else { | 357 } else { |
| 357 rect.setX(logicalTop); | 358 rect.setX(logicalTop); |
| 358 rect.setWidth(logicalHeight); | 359 rect.setWidth(logicalHeight); |
| 359 } | 360 } |
| 360 } | 361 } |
| 361 return rect; | 362 return rect; |
| 362 } | 363 } |
| 363 | 364 |
| 364 } // namespace blink | 365 } // namespace blink |
| OLD | NEW |