| 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/LineLayoutPaintShim.h" | 16 #include "core/paint/LineLayoutPaintShim.h" |
| 17 #include "core/paint/PaintInfo.h" | 17 #include "core/paint/PaintInfo.h" |
| 18 #include "platform/graphics/GraphicsContextStateSaver.h" | 18 #include "platform/graphics/GraphicsContextStateSaver.h" |
| 19 #include "platform/graphics/paint/DrawingRecorder.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); |
| 26 |
| 25 LayoutRect overflowRect(m_inlineFlowBox.visualOverflowRect(lineTop, lineBott
om)); | 27 LayoutRect overflowRect(m_inlineFlowBox.visualOverflowRect(lineTop, lineBott
om)); |
| 26 m_inlineFlowBox.flipForWritingMode(overflowRect); | 28 m_inlineFlowBox.flipForWritingMode(overflowRect); |
| 27 overflowRect.moveBy(paintOffset); | 29 overflowRect.moveBy(paintOffset); |
| 28 | 30 |
| 29 if (!paintInfo.rect.intersects(pixelSnappedIntRect(overflowRect))) | 31 if (!paintInfo.rect.intersects(pixelSnappedIntRect(overflowRect))) |
| 30 return; | 32 return; |
| 31 | 33 |
| 32 if (paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSel
fOutline) { | 34 if (paintInfo.phase == PaintPhaseMask) { |
| 33 // Add ourselves to the paint info struct's list of inlines that need to
paint their | |
| 34 // outlines. | |
| 35 if (m_inlineFlowBox.layoutObject().style()->visibility() == VISIBLE && m
_inlineFlowBox.layoutObject().style()->hasOutline() && !m_inlineFlowBox.isRootIn
lineBox()) { | |
| 36 LayoutInline& inlineFlow = toLayoutInline(m_inlineFlowBox.layoutObje
ct()); | |
| 37 | |
| 38 LayoutBlock* cb = 0; | |
| 39 bool containingBlockPaintsContinuationOutline = inlineFlow.continuat
ion() || inlineFlow.isInlineElementContinuation(); | |
| 40 if (containingBlockPaintsContinuationOutline) { | |
| 41 // FIXME: See https://bugs.webkit.org/show_bug.cgi?id=54690. We
currently don't reconnect inline continuations | |
| 42 // after a child removal. As a result, those merged inlines do n
ot get seperated and hence not get enclosed by | |
| 43 // anonymous blocks. In this case, it is better to bail out and
paint it ourself. | |
| 44 LayoutBlock* enclosingAnonymousBlock = m_inlineFlowBox.layoutObj
ect().containingBlock(); | |
| 45 if (!enclosingAnonymousBlock->isAnonymousBlock()) { | |
| 46 containingBlockPaintsContinuationOutline = false; | |
| 47 } else { | |
| 48 cb = enclosingAnonymousBlock->containingBlock(); | |
| 49 for (LineLayoutBoxModel box = m_inlineFlowBox.boxModelObject
(); box != cb; box = box.parent().enclosingBoxModelObject()) { | |
| 50 if (box.hasSelfPaintingLayer()) { | |
| 51 containingBlockPaintsContinuationOutline = false; | |
| 52 break; | |
| 53 } | |
| 54 } | |
| 55 } | |
| 56 } | |
| 57 | |
| 58 if (containingBlockPaintsContinuationOutline) { | |
| 59 // Add ourselves to the containing block of the entire continuat
ion so that it can | |
| 60 // paint us atomically. | |
| 61 cb->addContinuationWithOutline(toLayoutInline(m_inlineFlowBox.la
youtObject().node()->layoutObject())); | |
| 62 } else if (!inlineFlow.isInlineElementContinuation()) { | |
| 63 paintInfo.outlineObjects()->add(&inlineFlow); | |
| 64 } | |
| 65 } | |
| 66 } else if (paintInfo.phase == PaintPhaseMask) { | |
| 67 DisplayItem::Type displayItemType = DisplayItem::paintPhaseToDrawingType
(paintInfo.phase); | 35 DisplayItem::Type displayItemType = DisplayItem::paintPhaseToDrawingType
(paintInfo.phase); |
| 68 if (DrawingRecorder::useCachedDrawingIfPossible(*paintInfo.context, m_in
lineFlowBox, displayItemType)) | 36 if (DrawingRecorder::useCachedDrawingIfPossible(*paintInfo.context, m_in
lineFlowBox, displayItemType)) |
| 69 return; | 37 return; |
| 70 DrawingRecorder recorder(*paintInfo.context, m_inlineFlowBox, displayIte
mType, pixelSnappedIntRect(overflowRect)); | 38 DrawingRecorder recorder(*paintInfo.context, m_inlineFlowBox, displayIte
mType, pixelSnappedIntRect(overflowRect)); |
| 71 paintMask(paintInfo, paintOffset); | 39 paintMask(paintInfo, paintOffset); |
| 72 return; | 40 return; |
| 73 } else if (paintInfo.phase == PaintPhaseForeground) { | 41 } |
| 42 |
| 43 if (paintInfo.phase == PaintPhaseForeground) { |
| 74 // Paint our background, border and box-shadow. | 44 // Paint our background, border and box-shadow. |
| 75 paintBoxDecorationBackground(paintInfo, paintOffset, overflowRect); | 45 paintBoxDecorationBackground(paintInfo, paintOffset, overflowRect); |
| 76 } | 46 } |
| 77 | 47 |
| 78 // Paint our children. | 48 // Paint our children. |
| 79 if (paintInfo.phase != PaintPhaseSelfOutline) { | 49 PaintInfo childInfo(paintInfo); |
| 80 PaintInfo childInfo(paintInfo); | 50 if (childInfo.paintingRoot && childInfo.paintingRoot->isDescendantOf(&m_inli
neFlowBox.layoutObject())) |
| 81 childInfo.phase = paintInfo.phase == PaintPhaseChildOutlines ? PaintPhas
eOutline : paintInfo.phase; | 51 childInfo.paintingRoot = 0; |
| 52 else |
| 53 childInfo.updatePaintingRootForChildren(&m_inlineFlowBox.layoutObject())
; |
| 82 | 54 |
| 83 if (childInfo.paintingRoot && childInfo.paintingRoot->isDescendantOf(&m_
inlineFlowBox.layoutObject())) | 55 for (InlineBox* curr = m_inlineFlowBox.firstChild(); curr; curr = curr->next
OnLine()) { |
| 84 childInfo.paintingRoot = 0; | 56 if (curr->lineLayoutItem().isText() || !curr->boxModelObject().hasSelfPa
intingLayer()) |
| 85 else | 57 curr->paint(childInfo, paintOffset, lineTop, lineBottom); |
| 86 childInfo.updatePaintingRootForChildren(&m_inlineFlowBox.layoutObjec
t()); | |
| 87 | |
| 88 for (InlineBox* curr = m_inlineFlowBox.firstChild(); curr; curr = curr->
nextOnLine()) { | |
| 89 if (curr->lineLayoutItem().isText() || !curr->boxModelObject().hasSe
lfPaintingLayer()) | |
| 90 curr->paint(childInfo, paintOffset, lineTop, lineBottom); | |
| 91 } | |
| 92 } | 58 } |
| 93 } | 59 } |
| 94 | 60 |
| 95 void InlineFlowBoxPainter::paintFillLayers(const PaintInfo& paintInfo, const Col
or& c, const FillLayer& fillLayer, const LayoutRect& rect, SkXfermode::Mode op) | 61 void InlineFlowBoxPainter::paintFillLayers(const PaintInfo& paintInfo, const Col
or& c, const FillLayer& fillLayer, const LayoutRect& rect, SkXfermode::Mode op) |
| 96 { | 62 { |
| 97 // 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 // 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 |
| 98 // painted in reverse order. | 64 // painted in reverse order. |
| 99 if (fillLayer.next()) | 65 if (fillLayer.next()) |
| 100 paintFillLayers(paintInfo, c, *fillLayer.next(), rect, op); | 66 paintFillLayers(paintInfo, c, *fillLayer.next(), rect, op); |
| 101 paintFillLayer(paintInfo, c, fillLayer, rect, op); | 67 paintFillLayer(paintInfo, c, fillLayer, rect, op); |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 rect.setHeight(logicalHeight); | 327 rect.setHeight(logicalHeight); |
| 362 } else { | 328 } else { |
| 363 rect.setX(logicalTop); | 329 rect.setX(logicalTop); |
| 364 rect.setWidth(logicalHeight); | 330 rect.setWidth(logicalHeight); |
| 365 } | 331 } |
| 366 } | 332 } |
| 367 return rect; | 333 return rect; |
| 368 } | 334 } |
| 369 | 335 |
| 370 } // namespace blink | 336 } // namespace blink |
| OLD | NEW |