| 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/Layer.h" | 8 #include "core/layout/Layer.h" |
| 9 #include "core/layout/LayoutBlock.h" | 9 #include "core/layout/LayoutBlock.h" |
| 10 #include "core/layout/LayoutInline.h" | 10 #include "core/layout/LayoutInline.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 LayoutRect overflowRect(m_inlineFlowBox.visualOverflowRect(lineTop, lineBott
om)); | 22 LayoutRect overflowRect(m_inlineFlowBox.visualOverflowRect(lineTop, lineBott
om)); |
| 23 m_inlineFlowBox.flipForWritingMode(overflowRect); | 23 m_inlineFlowBox.flipForWritingMode(overflowRect); |
| 24 overflowRect.moveBy(paintOffset); | 24 overflowRect.moveBy(paintOffset); |
| 25 | 25 |
| 26 if (!paintInfo.rect.intersects(pixelSnappedIntRect(overflowRect))) | 26 if (!paintInfo.rect.intersects(pixelSnappedIntRect(overflowRect))) |
| 27 return; | 27 return; |
| 28 | 28 |
| 29 if (paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSel
fOutline) { | 29 if (paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSel
fOutline) { |
| 30 // Add ourselves to the paint info struct's list of inlines that need to
paint their | 30 // Add ourselves to the paint info struct's list of inlines that need to
paint their |
| 31 // outlines. | 31 // outlines. |
| 32 if (m_inlineFlowBox.renderer().style()->visibility() == VISIBLE && m_inl
ineFlowBox.renderer().style()->hasOutline() && !m_inlineFlowBox.isRootInlineBox(
)) { | 32 if (m_inlineFlowBox.layoutObject().style()->visibility() == VISIBLE && m
_inlineFlowBox.layoutObject().style()->hasOutline() && !m_inlineFlowBox.isRootIn
lineBox()) { |
| 33 LayoutInline& inlineFlow = toLayoutInline(m_inlineFlowBox.renderer()
); | 33 LayoutInline& inlineFlow = toLayoutInline(m_inlineFlowBox.layoutObje
ct()); |
| 34 | 34 |
| 35 LayoutBlock* cb = 0; | 35 LayoutBlock* cb = 0; |
| 36 bool containingBlockPaintsContinuationOutline = inlineFlow.continuat
ion() || inlineFlow.isInlineElementContinuation(); | 36 bool containingBlockPaintsContinuationOutline = inlineFlow.continuat
ion() || inlineFlow.isInlineElementContinuation(); |
| 37 if (containingBlockPaintsContinuationOutline) { | 37 if (containingBlockPaintsContinuationOutline) { |
| 38 // FIXME: See https://bugs.webkit.org/show_bug.cgi?id=54690. We
currently don't reconnect inline continuations | 38 // FIXME: See https://bugs.webkit.org/show_bug.cgi?id=54690. We
currently don't reconnect inline continuations |
| 39 // after a child removal. As a result, those merged inlines do n
ot get seperated and hence not get enclosed by | 39 // after a child removal. As a result, those merged inlines do n
ot get seperated and hence not get enclosed by |
| 40 // anonymous blocks. In this case, it is better to bail out and
paint it ourself. | 40 // anonymous blocks. In this case, it is better to bail out and
paint it ourself. |
| 41 LayoutBlock* enclosingAnonymousBlock = m_inlineFlowBox.renderer(
).containingBlock(); | 41 LayoutBlock* enclosingAnonymousBlock = m_inlineFlowBox.layoutObj
ect().containingBlock(); |
| 42 if (!enclosingAnonymousBlock->isAnonymousBlock()) { | 42 if (!enclosingAnonymousBlock->isAnonymousBlock()) { |
| 43 containingBlockPaintsContinuationOutline = false; | 43 containingBlockPaintsContinuationOutline = false; |
| 44 } else { | 44 } else { |
| 45 cb = enclosingAnonymousBlock->containingBlock(); | 45 cb = enclosingAnonymousBlock->containingBlock(); |
| 46 for (LayoutBoxModelObject* box = m_inlineFlowBox.boxModelObj
ect(); box != cb; box = box->parent()->enclosingBoxModelObject()) { | 46 for (LayoutBoxModelObject* box = m_inlineFlowBox.boxModelObj
ect(); box != cb; box = box->parent()->enclosingBoxModelObject()) { |
| 47 if (box->hasSelfPaintingLayer()) { | 47 if (box->hasSelfPaintingLayer()) { |
| 48 containingBlockPaintsContinuationOutline = false; | 48 containingBlockPaintsContinuationOutline = false; |
| 49 break; | 49 break; |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 | 54 |
| 55 if (containingBlockPaintsContinuationOutline) { | 55 if (containingBlockPaintsContinuationOutline) { |
| 56 // Add ourselves to the containing block of the entire continuat
ion so that it can | 56 // Add ourselves to the containing block of the entire continuat
ion so that it can |
| 57 // paint us atomically. | 57 // paint us atomically. |
| 58 cb->addContinuationWithOutline(toLayoutInline(m_inlineFlowBox.re
nderer().node()->renderer())); | 58 cb->addContinuationWithOutline(toLayoutInline(m_inlineFlowBox.la
youtObject().node()->layoutObject())); |
| 59 } else if (!inlineFlow.isInlineElementContinuation()) { | 59 } else if (!inlineFlow.isInlineElementContinuation()) { |
| 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.displayItemC
lient(), DisplayItem::paintPhaseToDrawingType(paintInfo.phase), pixelSnappedIntR
ect(overflowRect)); | 64 DrawingRecorder recorder(paintInfo.context, m_inlineFlowBox.displayItemC
lient(), DisplayItem::paintPhaseToDrawingType(paintInfo.phase), pixelSnappedIntR
ect(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); |
| 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.renderer())) | 78 if (childInfo.paintingRoot && childInfo.paintingRoot->isDescendantOf(&m_
inlineFlowBox.layoutObject())) |
| 79 childInfo.paintingRoot = 0; | 79 childInfo.paintingRoot = 0; |
| 80 else | 80 else |
| 81 childInfo.updatePaintingRootForChildren(&m_inlineFlowBox.renderer())
; | 81 childInfo.updatePaintingRootForChildren(&m_inlineFlowBox.layoutObjec
t()); |
| 82 | 82 |
| 83 for (InlineBox* curr = m_inlineFlowBox.firstChild(); curr; curr = curr->
nextOnLine()) { | 83 for (InlineBox* curr = m_inlineFlowBox.firstChild(); curr; curr = curr->
nextOnLine()) { |
| 84 if (curr->renderer().isText() || !curr->boxModelObject()->hasSelfPai
ntingLayer()) | 84 if (curr->layoutObject().isText() || !curr->boxModelObject()->hasSel
fPaintingLayer()) |
| 85 curr->paint(childInfo, paintOffset, lineTop, lineBottom); | 85 curr->paint(childInfo, paintOffset, lineTop, lineBottom); |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 | 89 |
| 90 void InlineFlowBoxPainter::paintFillLayers(const PaintInfo& paintInfo, const Col
or& c, const FillLayer& fillLayer, const LayoutRect& rect, SkXfermode::Mode op) | 90 void InlineFlowBoxPainter::paintFillLayers(const PaintInfo& paintInfo, const Col
or& c, const FillLayer& fillLayer, const LayoutRect& rect, SkXfermode::Mode op) |
| 91 { | 91 { |
| 92 // 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 | 92 // 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 |
| 93 // painted in reverse order. | 93 // painted in reverse order. |
| 94 if (fillLayer.next()) | 94 if (fillLayer.next()) |
| 95 paintFillLayers(paintInfo, c, *fillLayer.next(), rect, op); | 95 paintFillLayers(paintInfo, c, *fillLayer.next(), rect, op); |
| 96 paintFillLayer(paintInfo, c, fillLayer, rect, op); | 96 paintFillLayer(paintInfo, c, fillLayer, rect, op); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void InlineFlowBoxPainter::paintFillLayer(const PaintInfo& paintInfo, const Colo
r& c, const FillLayer& fillLayer, const LayoutRect& rect, SkXfermode::Mode op) | 99 void InlineFlowBoxPainter::paintFillLayer(const PaintInfo& paintInfo, const Colo
r& c, const FillLayer& fillLayer, const LayoutRect& rect, SkXfermode::Mode op) |
| 100 { | 100 { |
| 101 StyleImage* img = fillLayer.image(); | 101 StyleImage* img = fillLayer.image(); |
| 102 bool hasFillImage = img && img->canRender(m_inlineFlowBox.renderer(), m_inli
neFlowBox.renderer().style()->effectiveZoom()); | 102 bool hasFillImage = img && img->canRender(m_inlineFlowBox.layoutObject(), m_
inlineFlowBox.layoutObject().style()->effectiveZoom()); |
| 103 if ((!hasFillImage && !m_inlineFlowBox.renderer().style()->hasBorderRadius()
) || (!m_inlineFlowBox.prevLineBox() && !m_inlineFlowBox.nextLineBox()) || !m_in
lineFlowBox.parent()) { | 103 if ((!hasFillImage && !m_inlineFlowBox.layoutObject().style()->hasBorderRadi
us()) || (!m_inlineFlowBox.prevLineBox() && !m_inlineFlowBox.nextLineBox()) || !
m_inlineFlowBox.parent()) { |
| 104 BoxPainter::paintFillLayerExtended(*m_inlineFlowBox.boxModelObject(), pa
intInfo, c, fillLayer, rect, BackgroundBleedNone, &m_inlineFlowBox, rect.size(),
op); | 104 BoxPainter::paintFillLayerExtended(*m_inlineFlowBox.boxModelObject(), pa
intInfo, c, fillLayer, rect, BackgroundBleedNone, &m_inlineFlowBox, rect.size(),
op); |
| 105 } else if (m_inlineFlowBox.renderer().style()->boxDecorationBreak() == DCLON
E) { | 105 } else if (m_inlineFlowBox.layoutObject().style()->boxDecorationBreak() == D
CLONE) { |
| 106 GraphicsContextStateSaver stateSaver(*paintInfo.context); | 106 GraphicsContextStateSaver stateSaver(*paintInfo.context); |
| 107 paintInfo.context->clip(LayoutRect(rect.x(), rect.y(), m_inlineFlowBox.w
idth(), m_inlineFlowBox.height())); | 107 paintInfo.context->clip(LayoutRect(rect.x(), rect.y(), m_inlineFlowBox.w
idth(), m_inlineFlowBox.height())); |
| 108 BoxPainter::paintFillLayerExtended(*m_inlineFlowBox.boxModelObject(), pa
intInfo, c, fillLayer, rect, BackgroundBleedNone, &m_inlineFlowBox, rect.size(),
op); | 108 BoxPainter::paintFillLayerExtended(*m_inlineFlowBox.boxModelObject(), pa
intInfo, c, fillLayer, rect, BackgroundBleedNone, &m_inlineFlowBox, rect.size(),
op); |
| 109 } else { | 109 } else { |
| 110 // We have a fill image that spans multiple lines. | 110 // We have a fill image that spans multiple lines. |
| 111 // FIXME: frameSize ought to be the same as rect.size(). | 111 // FIXME: frameSize ought to be the same as rect.size(). |
| 112 LayoutSize frameSize(m_inlineFlowBox.width().toLayoutUnit(), m_inlineFlo
wBox.height().toLayoutUnit()); | 112 LayoutSize frameSize(m_inlineFlowBox.width().toLayoutUnit(), m_inlineFlo
wBox.height().toLayoutUnit()); |
| 113 LayoutRect imageStripPaintRect = paintRectForImageStrip(rect.location(),
frameSize, m_inlineFlowBox.renderer().style()->direction()); | 113 LayoutRect imageStripPaintRect = paintRectForImageStrip(rect.location(),
frameSize, m_inlineFlowBox.layoutObject().style()->direction()); |
| 114 GraphicsContextStateSaver stateSaver(*paintInfo.context); | 114 GraphicsContextStateSaver stateSaver(*paintInfo.context); |
| 115 paintInfo.context->clip(LayoutRect(rect.x(), rect.y(), m_inlineFlowBox.w
idth(), m_inlineFlowBox.height())); | 115 paintInfo.context->clip(LayoutRect(rect.x(), rect.y(), m_inlineFlowBox.w
idth(), m_inlineFlowBox.height())); |
| 116 BoxPainter::paintFillLayerExtended(*m_inlineFlowBox.boxModelObject(), pa
intInfo, c, fillLayer, imageStripPaintRect, BackgroundBleedNone, &m_inlineFlowBo
x, rect.size(), op); | 116 BoxPainter::paintFillLayerExtended(*m_inlineFlowBox.boxModelObject(), pa
intInfo, c, fillLayer, imageStripPaintRect, BackgroundBleedNone, &m_inlineFlowBo
x, rect.size(), op); |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 | 119 |
| 120 void InlineFlowBoxPainter::paintBoxShadow(const PaintInfo& info, const LayoutSty
le& s, ShadowStyle shadowStyle, const LayoutRect& paintRect) | 120 void InlineFlowBoxPainter::paintBoxShadow(const PaintInfo& info, const LayoutSty
le& s, ShadowStyle shadowStyle, const LayoutRect& paintRect) |
| 121 { | 121 { |
| 122 if ((!m_inlineFlowBox.prevLineBox() && !m_inlineFlowBox.nextLineBox()) || !m
_inlineFlowBox.parent()) { | 122 if ((!m_inlineFlowBox.prevLineBox() && !m_inlineFlowBox.nextLineBox()) || !m
_inlineFlowBox.parent()) { |
| 123 BoxPainter::paintBoxShadow(info, paintRect, s, shadowStyle); | 123 BoxPainter::paintBoxShadow(info, paintRect, s, shadowStyle); |
| 124 } else { | 124 } else { |
| 125 // FIXME: We can do better here in the multi-line case. We want to push
a clip so that the shadow doesn't | 125 // FIXME: We can do better here in the multi-line case. We want to push
a clip so that the shadow doesn't |
| 126 // protrude incorrectly at the edges, and we want to possibly include sh
adows cast from the previous/following lines | 126 // protrude incorrectly at the edges, and we want to possibly include sh
adows cast from the previous/following lines |
| 127 BoxPainter::paintBoxShadow(info, paintRect, s, shadowStyle, m_inlineFlow
Box.includeLogicalLeftEdge(), m_inlineFlowBox.includeLogicalRightEdge()); | 127 BoxPainter::paintBoxShadow(info, paintRect, s, shadowStyle, m_inlineFlow
Box.includeLogicalLeftEdge(), m_inlineFlowBox.includeLogicalRightEdge()); |
| 128 } | 128 } |
| 129 } | 129 } |
| 130 | 130 |
| 131 | 131 |
| 132 static LayoutRect clipRectForNinePieceImageStrip(InlineFlowBox* box, const NineP
ieceImage& image, const LayoutRect& paintRect) | 132 static LayoutRect clipRectForNinePieceImageStrip(InlineFlowBox* box, const NineP
ieceImage& image, const LayoutRect& paintRect) |
| 133 { | 133 { |
| 134 LayoutRect clipRect(paintRect); | 134 LayoutRect clipRect(paintRect); |
| 135 const LayoutStyle& style = box->renderer().styleRef(); | 135 const LayoutStyle& style = box->layoutObject().styleRef(); |
| 136 LayoutRectOutsets outsets = style.imageOutsets(image); | 136 LayoutRectOutsets outsets = style.imageOutsets(image); |
| 137 if (box->isHorizontal()) { | 137 if (box->isHorizontal()) { |
| 138 clipRect.setY(paintRect.y() - outsets.top()); | 138 clipRect.setY(paintRect.y() - outsets.top()); |
| 139 clipRect.setHeight(paintRect.height() + outsets.top() + outsets.bottom()
); | 139 clipRect.setHeight(paintRect.height() + outsets.top() + outsets.bottom()
); |
| 140 if (box->includeLogicalLeftEdge()) { | 140 if (box->includeLogicalLeftEdge()) { |
| 141 clipRect.setX(paintRect.x() - outsets.left()); | 141 clipRect.setX(paintRect.x() - outsets.left()); |
| 142 clipRect.setWidth(paintRect.width() + outsets.left()); | 142 clipRect.setWidth(paintRect.width() + outsets.left()); |
| 143 } | 143 } |
| 144 if (box->includeLogicalRightEdge()) | 144 if (box->includeLogicalRightEdge()) |
| 145 clipRect.setWidth(clipRect.width() + outsets.right()); | 145 clipRect.setWidth(clipRect.width() + outsets.right()); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 LayoutUnit stripX = paintOffset.x() - (m_inlineFlowBox.isHorizontal() ? logi
calOffsetOnLine : LayoutUnit()); | 182 LayoutUnit stripX = paintOffset.x() - (m_inlineFlowBox.isHorizontal() ? logi
calOffsetOnLine : LayoutUnit()); |
| 183 LayoutUnit stripY = paintOffset.y() - (m_inlineFlowBox.isHorizontal() ? Layo
utUnit() : logicalOffsetOnLine); | 183 LayoutUnit stripY = paintOffset.y() - (m_inlineFlowBox.isHorizontal() ? Layo
utUnit() : logicalOffsetOnLine); |
| 184 LayoutUnit stripWidth = m_inlineFlowBox.isHorizontal() ? totalLogicalWidth :
frameSize.width(); | 184 LayoutUnit stripWidth = m_inlineFlowBox.isHorizontal() ? totalLogicalWidth :
frameSize.width(); |
| 185 LayoutUnit stripHeight = m_inlineFlowBox.isHorizontal() ? frameSize.height()
: totalLogicalWidth; | 185 LayoutUnit stripHeight = m_inlineFlowBox.isHorizontal() ? frameSize.height()
: totalLogicalWidth; |
| 186 return LayoutRect(stripX, stripY, stripWidth, stripHeight); | 186 return LayoutRect(stripX, stripY, stripWidth, stripHeight); |
| 187 } | 187 } |
| 188 | 188 |
| 189 void InlineFlowBoxPainter::paintBoxDecorationBackground(const PaintInfo& paintIn
fo, const LayoutPoint& paintOffset) | 189 void InlineFlowBoxPainter::paintBoxDecorationBackground(const PaintInfo& paintIn
fo, const LayoutPoint& paintOffset) |
| 190 { | 190 { |
| 191 ASSERT(paintInfo.phase == PaintPhaseForeground); | 191 ASSERT(paintInfo.phase == PaintPhaseForeground); |
| 192 if (!paintInfo.shouldPaintWithinRoot(&m_inlineFlowBox.renderer()) || m_inlin
eFlowBox.renderer().style()->visibility() != VISIBLE) | 192 if (!paintInfo.shouldPaintWithinRoot(&m_inlineFlowBox.layoutObject()) || m_i
nlineFlowBox.layoutObject().style()->visibility() != VISIBLE) |
| 193 return; | 193 return; |
| 194 | 194 |
| 195 // You can use p::first-line to specify a background. If so, the root line b
oxes for | 195 // You can use p::first-line to specify a background. If so, the root line b
oxes for |
| 196 // a line may actually have to paint a background. | 196 // a line may actually have to paint a background. |
| 197 const LayoutStyle* styleToUse = m_inlineFlowBox.renderer().style(m_inlineFlo
wBox.isFirstLineStyle()); | 197 const LayoutStyle* styleToUse = m_inlineFlowBox.layoutObject().style(m_inlin
eFlowBox.isFirstLineStyle()); |
| 198 bool shouldPaintBoxDecorationBackground; | 198 bool shouldPaintBoxDecorationBackground; |
| 199 if (m_inlineFlowBox.parent()) | 199 if (m_inlineFlowBox.parent()) |
| 200 shouldPaintBoxDecorationBackground = m_inlineFlowBox.renderer().hasBoxDe
corationBackground(); | 200 shouldPaintBoxDecorationBackground = m_inlineFlowBox.layoutObject().hasB
oxDecorationBackground(); |
| 201 else | 201 else |
| 202 shouldPaintBoxDecorationBackground = m_inlineFlowBox.isFirstLineStyle()
&& styleToUse != m_inlineFlowBox.renderer().style(); | 202 shouldPaintBoxDecorationBackground = m_inlineFlowBox.isFirstLineStyle()
&& styleToUse != m_inlineFlowBox.layoutObject().style(); |
| 203 | 203 |
| 204 if (!shouldPaintBoxDecorationBackground) | 204 if (!shouldPaintBoxDecorationBackground) |
| 205 return; | 205 return; |
| 206 | 206 |
| 207 LayoutRect frameRect = roundedFrameRectClampedToLineTopAndBottomIfNeeded(); | 207 LayoutRect frameRect = roundedFrameRectClampedToLineTopAndBottomIfNeeded(); |
| 208 | 208 |
| 209 // Move x/y to our coordinates. | 209 // Move x/y to our coordinates. |
| 210 LayoutRect localRect(frameRect); | 210 LayoutRect localRect(frameRect); |
| 211 m_inlineFlowBox.flipForWritingMode(localRect); | 211 m_inlineFlowBox.flipForWritingMode(localRect); |
| 212 LayoutPoint adjustedPaintOffset = paintOffset + localRect.location(); | 212 LayoutPoint adjustedPaintOffset = paintOffset + localRect.location(); |
| 213 | 213 |
| 214 LayoutRect paintRect = LayoutRect(adjustedPaintOffset, frameRect.size()); | 214 LayoutRect paintRect = LayoutRect(adjustedPaintOffset, frameRect.size()); |
| 215 | 215 |
| 216 DrawingRecorder recorder(paintInfo.context, m_inlineFlowBox.displayItemClien
t(), DisplayItem::BoxDecorationBackground, pixelSnappedIntRect(paintRect)); | 216 DrawingRecorder recorder(paintInfo.context, m_inlineFlowBox.displayItemClien
t(), DisplayItem::BoxDecorationBackground, pixelSnappedIntRect(paintRect)); |
| 217 if (recorder.canUseCachedDrawing()) | 217 if (recorder.canUseCachedDrawing()) |
| 218 return; | 218 return; |
| 219 | 219 |
| 220 // Shadow comes first and is behind the background and border. | 220 // Shadow comes first and is behind the background and border. |
| 221 if (!m_inlineFlowBox.boxModelObject()->boxShadowShouldBeAppliedToBackground(
BackgroundBleedNone, &m_inlineFlowBox)) | 221 if (!m_inlineFlowBox.boxModelObject()->boxShadowShouldBeAppliedToBackground(
BackgroundBleedNone, &m_inlineFlowBox)) |
| 222 paintBoxShadow(paintInfo, *styleToUse, Normal, paintRect); | 222 paintBoxShadow(paintInfo, *styleToUse, Normal, paintRect); |
| 223 | 223 |
| 224 Color backgroundColor = m_inlineFlowBox.renderer().resolveColor(*styleToUse,
CSSPropertyBackgroundColor); | 224 Color backgroundColor = m_inlineFlowBox.layoutObject().resolveColor(*styleTo
Use, CSSPropertyBackgroundColor); |
| 225 paintFillLayers(paintInfo, backgroundColor, styleToUse->backgroundLayers(),
paintRect); | 225 paintFillLayers(paintInfo, backgroundColor, styleToUse->backgroundLayers(),
paintRect); |
| 226 paintBoxShadow(paintInfo, *styleToUse, Inset, paintRect); | 226 paintBoxShadow(paintInfo, *styleToUse, Inset, paintRect); |
| 227 | 227 |
| 228 // :first-line cannot be used to put borders on a line. Always paint borders
with our | 228 // :first-line cannot be used to put borders on a line. Always paint borders
with our |
| 229 // non-first-line style. | 229 // non-first-line style. |
| 230 if (m_inlineFlowBox.parent() && m_inlineFlowBox.renderer().style()->hasBorde
r()) { | 230 if (m_inlineFlowBox.parent() && m_inlineFlowBox.layoutObject().style()->hasB
order()) { |
| 231 const NinePieceImage& borderImage = m_inlineFlowBox.renderer().style()->
borderImage(); | 231 const NinePieceImage& borderImage = m_inlineFlowBox.layoutObject().style
()->borderImage(); |
| 232 StyleImage* borderImageSource = borderImage.image(); | 232 StyleImage* borderImageSource = borderImage.image(); |
| 233 bool hasBorderImage = borderImageSource && borderImageSource->canRender(
m_inlineFlowBox.renderer(), styleToUse->effectiveZoom()); | 233 bool hasBorderImage = borderImageSource && borderImageSource->canRender(
m_inlineFlowBox.layoutObject(), styleToUse->effectiveZoom()); |
| 234 if (hasBorderImage && !borderImageSource->isLoaded()) | 234 if (hasBorderImage && !borderImageSource->isLoaded()) |
| 235 return; // Don't paint anything while we wait for the image to load. | 235 return; // Don't paint anything while we wait for the image to load. |
| 236 | 236 |
| 237 // The simple case is where we either have no border image or we are the
only box for this object. | 237 // The simple case is where we either have no border image or we are the
only box for this object. |
| 238 // In those cases only a single call to draw is required. | 238 // In those cases only a single call to draw is required. |
| 239 if (!hasBorderImage || (!m_inlineFlowBox.prevLineBox() && !m_inlineFlowB
ox.nextLineBox())) { | 239 if (!hasBorderImage || (!m_inlineFlowBox.prevLineBox() && !m_inlineFlowB
ox.nextLineBox())) { |
| 240 BoxPainter::paintBorder(*m_inlineFlowBox.boxModelObject(), paintInfo
, paintRect, m_inlineFlowBox.renderer().styleRef(m_inlineFlowBox.isFirstLineStyl
e()), BackgroundBleedNone, m_inlineFlowBox.includeLogicalLeftEdge(), m_inlineFlo
wBox.includeLogicalRightEdge()); | 240 BoxPainter::paintBorder(*m_inlineFlowBox.boxModelObject(), paintInfo
, paintRect, m_inlineFlowBox.layoutObject().styleRef(m_inlineFlowBox.isFirstLine
Style()), BackgroundBleedNone, m_inlineFlowBox.includeLogicalLeftEdge(), m_inlin
eFlowBox.includeLogicalRightEdge()); |
| 241 } else { | 241 } else { |
| 242 // We have a border image that spans multiple lines. | 242 // We have a border image that spans multiple lines. |
| 243 // FIXME: What the heck do we do with RTL here? The math we're using
is obviously not right, | 243 // FIXME: What the heck do we do with RTL here? The math we're using
is obviously not right, |
| 244 // but it isn't even clear how this should work at all. | 244 // but it isn't even clear how this should work at all. |
| 245 LayoutRect imageStripPaintRect = paintRectForImageStrip(adjustedPain
tOffset, frameRect.size(), LTR); | 245 LayoutRect imageStripPaintRect = paintRectForImageStrip(adjustedPain
tOffset, frameRect.size(), LTR); |
| 246 LayoutRect clipRect = clipRectForNinePieceImageStrip(&m_inlineFlowBo
x, borderImage, paintRect); | 246 LayoutRect clipRect = clipRectForNinePieceImageStrip(&m_inlineFlowBo
x, borderImage, paintRect); |
| 247 GraphicsContextStateSaver stateSaver(*paintInfo.context); | 247 GraphicsContextStateSaver stateSaver(*paintInfo.context); |
| 248 paintInfo.context->clip(clipRect); | 248 paintInfo.context->clip(clipRect); |
| 249 BoxPainter::paintBorder(*m_inlineFlowBox.boxModelObject(), paintInfo
, imageStripPaintRect, m_inlineFlowBox.renderer().styleRef(m_inlineFlowBox.isFir
stLineStyle())); | 249 BoxPainter::paintBorder(*m_inlineFlowBox.boxModelObject(), paintInfo
, imageStripPaintRect, m_inlineFlowBox.layoutObject().styleRef(m_inlineFlowBox.i
sFirstLineStyle())); |
| 250 } | 250 } |
| 251 } | 251 } |
| 252 } | 252 } |
| 253 | 253 |
| 254 void InlineFlowBoxPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoi
nt& paintOffset) | 254 void InlineFlowBoxPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoi
nt& paintOffset) |
| 255 { | 255 { |
| 256 if (!paintInfo.shouldPaintWithinRoot(&m_inlineFlowBox.renderer()) || m_inlin
eFlowBox.renderer().style()->visibility() != VISIBLE || paintInfo.phase != Paint
PhaseMask) | 256 if (!paintInfo.shouldPaintWithinRoot(&m_inlineFlowBox.layoutObject()) || m_i
nlineFlowBox.layoutObject().style()->visibility() != VISIBLE || paintInfo.phase
!= PaintPhaseMask) |
| 257 return; | 257 return; |
| 258 | 258 |
| 259 LayoutRect frameRect = roundedFrameRectClampedToLineTopAndBottomIfNeeded(); | 259 LayoutRect frameRect = roundedFrameRectClampedToLineTopAndBottomIfNeeded(); |
| 260 | 260 |
| 261 // Move x/y to our coordinates. | 261 // Move x/y to our coordinates. |
| 262 LayoutRect localRect(frameRect); | 262 LayoutRect localRect(frameRect); |
| 263 m_inlineFlowBox.flipForWritingMode(localRect); | 263 m_inlineFlowBox.flipForWritingMode(localRect); |
| 264 LayoutPoint adjustedPaintOffset = paintOffset + localRect.location(); | 264 LayoutPoint adjustedPaintOffset = paintOffset + localRect.location(); |
| 265 | 265 |
| 266 const NinePieceImage& maskNinePieceImage = m_inlineFlowBox.renderer().style(
)->maskBoxImage(); | 266 const NinePieceImage& maskNinePieceImage = m_inlineFlowBox.layoutObject().st
yle()->maskBoxImage(); |
| 267 StyleImage* maskBoxImage = m_inlineFlowBox.renderer().style()->maskBoxImage(
).image(); | 267 StyleImage* maskBoxImage = m_inlineFlowBox.layoutObject().style()->maskBoxIm
age().image(); |
| 268 | 268 |
| 269 // Figure out if we need to push a transparency layer to render our mask. | 269 // Figure out if we need to push a transparency layer to render our mask. |
| 270 bool pushTransparencyLayer = false; | 270 bool pushTransparencyLayer = false; |
| 271 bool compositedMask = m_inlineFlowBox.renderer().hasLayer() && m_inlineFlowB
ox.boxModelObject()->layer()->hasCompositedMask(); | 271 bool compositedMask = m_inlineFlowBox.layoutObject().hasLayer() && m_inlineF
lowBox.boxModelObject()->layer()->hasCompositedMask(); |
| 272 bool flattenCompositingLayers = m_inlineFlowBox.renderer().view()->frameView
() && m_inlineFlowBox.renderer().view()->frameView()->paintBehavior() & PaintBeh
aviorFlattenCompositingLayers; | 272 bool flattenCompositingLayers = m_inlineFlowBox.layoutObject().view()->frame
View() && m_inlineFlowBox.layoutObject().view()->frameView()->paintBehavior() &
PaintBehaviorFlattenCompositingLayers; |
| 273 SkXfermode::Mode compositeOp = SkXfermode::kSrcOver_Mode; | 273 SkXfermode::Mode compositeOp = SkXfermode::kSrcOver_Mode; |
| 274 if (!compositedMask || flattenCompositingLayers) { | 274 if (!compositedMask || flattenCompositingLayers) { |
| 275 if ((maskBoxImage && m_inlineFlowBox.renderer().style()->maskLayers().ha
sImage()) || m_inlineFlowBox.renderer().style()->maskLayers().next()) | 275 if ((maskBoxImage && m_inlineFlowBox.layoutObject().style()->maskLayers(
).hasImage()) || m_inlineFlowBox.layoutObject().style()->maskLayers().next()) |
| 276 pushTransparencyLayer = true; | 276 pushTransparencyLayer = true; |
| 277 | 277 |
| 278 compositeOp = SkXfermode::kDstIn_Mode; | 278 compositeOp = SkXfermode::kDstIn_Mode; |
| 279 if (pushTransparencyLayer) { | 279 if (pushTransparencyLayer) { |
| 280 paintInfo.context->setCompositeOperation(SkXfermode::kDstIn_Mode); | 280 paintInfo.context->setCompositeOperation(SkXfermode::kDstIn_Mode); |
| 281 paintInfo.context->beginTransparencyLayer(1.0f); | 281 paintInfo.context->beginTransparencyLayer(1.0f); |
| 282 compositeOp = SkXfermode::kSrcOver_Mode; | 282 compositeOp = SkXfermode::kSrcOver_Mode; |
| 283 } | 283 } |
| 284 } | 284 } |
| 285 | 285 |
| 286 LayoutRect paintRect = LayoutRect(adjustedPaintOffset, frameRect.size()); | 286 LayoutRect paintRect = LayoutRect(adjustedPaintOffset, frameRect.size()); |
| 287 paintFillLayers(paintInfo, Color::transparent, m_inlineFlowBox.renderer().st
yle()->maskLayers(), paintRect, compositeOp); | 287 paintFillLayers(paintInfo, Color::transparent, m_inlineFlowBox.layoutObject(
).style()->maskLayers(), paintRect, compositeOp); |
| 288 | 288 |
| 289 bool hasBoxImage = maskBoxImage && maskBoxImage->canRender(m_inlineFlowBox.r
enderer(), m_inlineFlowBox.renderer().style()->effectiveZoom()); | 289 bool hasBoxImage = maskBoxImage && maskBoxImage->canRender(m_inlineFlowBox.l
ayoutObject(), m_inlineFlowBox.layoutObject().style()->effectiveZoom()); |
| 290 if (!hasBoxImage || !maskBoxImage->isLoaded()) { | 290 if (!hasBoxImage || !maskBoxImage->isLoaded()) { |
| 291 if (pushTransparencyLayer) | 291 if (pushTransparencyLayer) |
| 292 paintInfo.context->endLayer(); | 292 paintInfo.context->endLayer(); |
| 293 return; // Don't paint anything while we wait for the image to load. | 293 return; // Don't paint anything while we wait for the image to load. |
| 294 } | 294 } |
| 295 | 295 |
| 296 // The simple case is where we are the only box for this object. In those | 296 // The simple case is where we are the only box for this object. In those |
| 297 // cases only a single call to draw is required. | 297 // cases only a single call to draw is required. |
| 298 if (!m_inlineFlowBox.prevLineBox() && !m_inlineFlowBox.nextLineBox()) { | 298 if (!m_inlineFlowBox.prevLineBox() && !m_inlineFlowBox.nextLineBox()) { |
| 299 BoxPainter::paintNinePieceImage(*m_inlineFlowBox.boxModelObject(), paint
Info.context, paintRect, m_inlineFlowBox.renderer().styleRef(), maskNinePieceIma
ge, compositeOp); | 299 BoxPainter::paintNinePieceImage(*m_inlineFlowBox.boxModelObject(), paint
Info.context, paintRect, m_inlineFlowBox.layoutObject().styleRef(), maskNinePiec
eImage, compositeOp); |
| 300 } else { | 300 } else { |
| 301 // We have a mask image that spans multiple lines. | 301 // We have a mask image that spans multiple lines. |
| 302 // FIXME: What the heck do we do with RTL here? The math we're using is
obviously not right, | 302 // FIXME: What the heck do we do with RTL here? The math we're using is
obviously not right, |
| 303 // but it isn't even clear how this should work at all. | 303 // but it isn't even clear how this should work at all. |
| 304 LayoutRect imageStripPaintRect = paintRectForImageStrip(adjustedPaintOff
set, frameRect.size(), LTR); | 304 LayoutRect imageStripPaintRect = paintRectForImageStrip(adjustedPaintOff
set, frameRect.size(), LTR); |
| 305 LayoutRect clipRect = clipRectForNinePieceImageStrip(&m_inlineFlowBox, m
askNinePieceImage, paintRect); | 305 LayoutRect clipRect = clipRectForNinePieceImageStrip(&m_inlineFlowBox, m
askNinePieceImage, paintRect); |
| 306 GraphicsContextStateSaver stateSaver(*paintInfo.context); | 306 GraphicsContextStateSaver stateSaver(*paintInfo.context); |
| 307 paintInfo.context->clip(clipRect); | 307 paintInfo.context->clip(clipRect); |
| 308 BoxPainter::paintNinePieceImage(*m_inlineFlowBox.boxModelObject(), paint
Info.context, imageStripPaintRect, m_inlineFlowBox.renderer().styleRef(), maskNi
nePieceImage, compositeOp); | 308 BoxPainter::paintNinePieceImage(*m_inlineFlowBox.boxModelObject(), paint
Info.context, imageStripPaintRect, m_inlineFlowBox.layoutObject().styleRef(), ma
skNinePieceImage, compositeOp); |
| 309 } | 309 } |
| 310 | 310 |
| 311 if (pushTransparencyLayer) | 311 if (pushTransparencyLayer) |
| 312 paintInfo.context->endLayer(); | 312 paintInfo.context->endLayer(); |
| 313 } | 313 } |
| 314 | 314 |
| 315 LayoutRect InlineFlowBoxPainter::roundedFrameRectClampedToLineTopAndBottomIfNeed
ed() const | 315 LayoutRect InlineFlowBoxPainter::roundedFrameRectClampedToLineTopAndBottomIfNeed
ed() const |
| 316 { | 316 { |
| 317 // Pixel snap rect painting. | 317 // Pixel snap rect painting. |
| 318 LayoutRect rect(m_inlineFlowBox.roundedFrameRect()); | 318 LayoutRect rect(m_inlineFlowBox.roundedFrameRect()); |
| 319 | 319 |
| 320 bool noQuirksMode = m_inlineFlowBox.renderer().document().inNoQuirksMode(); | 320 bool noQuirksMode = m_inlineFlowBox.layoutObject().document().inNoQuirksMode
(); |
| 321 if (!noQuirksMode && !m_inlineFlowBox.hasTextChildren() && !(m_inlineFlowBox
.descendantsHaveSameLineHeightAndBaseline() && m_inlineFlowBox.hasTextDescendant
s())) { | 321 if (!noQuirksMode && !m_inlineFlowBox.hasTextChildren() && !(m_inlineFlowBox
.descendantsHaveSameLineHeightAndBaseline() && m_inlineFlowBox.hasTextDescendant
s())) { |
| 322 const RootInlineBox& rootBox = m_inlineFlowBox.root(); | 322 const RootInlineBox& rootBox = m_inlineFlowBox.root(); |
| 323 LayoutUnit logicalTop = m_inlineFlowBox.isHorizontal() ? rect.y() : rect
.x(); | 323 LayoutUnit logicalTop = m_inlineFlowBox.isHorizontal() ? rect.y() : rect
.x(); |
| 324 LayoutUnit logicalHeight = m_inlineFlowBox.isHorizontal() ? rect.height(
) : rect.width(); | 324 LayoutUnit logicalHeight = m_inlineFlowBox.isHorizontal() ? rect.height(
) : rect.width(); |
| 325 LayoutUnit bottom = std::min(rootBox.lineBottom(), logicalTop + logicalH
eight); | 325 LayoutUnit bottom = std::min(rootBox.lineBottom(), logicalTop + logicalH
eight); |
| 326 logicalTop = std::max(rootBox.lineTop(), logicalTop); | 326 logicalTop = std::max(rootBox.lineTop(), logicalTop); |
| 327 logicalHeight = bottom - logicalTop; | 327 logicalHeight = bottom - logicalTop; |
| 328 if (m_inlineFlowBox.isHorizontal()) { | 328 if (m_inlineFlowBox.isHorizontal()) { |
| 329 rect.setY(logicalTop); | 329 rect.setY(logicalTop); |
| 330 rect.setHeight(logicalHeight); | 330 rect.setHeight(logicalHeight); |
| 331 } else { | 331 } else { |
| 332 rect.setX(logicalTop); | 332 rect.setX(logicalTop); |
| 333 rect.setWidth(logicalHeight); | 333 rect.setWidth(logicalHeight); |
| 334 } | 334 } |
| 335 } | 335 } |
| 336 return rect; | 336 return rect; |
| 337 } | 337 } |
| 338 | 338 |
| 339 } // namespace blink | 339 } // namespace blink |
| OLD | NEW |