| 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/paint/BoxPainter.h" | 8 #include "core/paint/BoxPainter.h" |
| 9 #include "core/paint/RenderDrawingRecorder.h" | 9 #include "core/paint/RenderDrawingRecorder.h" |
| 10 #include "core/rendering/InlineFlowBox.h" | 10 #include "core/rendering/InlineFlowBox.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 else | 80 else |
| 81 childInfo.updatePaintingRootForChildren(&m_inlineFlowBox.renderer())
; | 81 childInfo.updatePaintingRootForChildren(&m_inlineFlowBox.renderer())
; |
| 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->renderer().isText() || !curr->boxModelObject()->hasSelfPai
ntingLayer()) |
| 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, CompositeOperator 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, CompositeOperator 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.renderer(), m_inli
neFlowBox.renderer().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.renderer().style()->hasBorderRadius()
) || (!m_inlineFlowBox.prevLineBox() && !m_inlineFlowBox.nextLineBox()) || !m_in
lineFlowBox.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.renderer().style()->boxDecorationBreak() == DCLON
E) { |
| 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 { |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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.renderer().style(
)->maskBoxImage(); |
| 267 StyleImage* maskBoxImage = m_inlineFlowBox.renderer().style()->maskBoxImage(
).image(); | 267 StyleImage* maskBoxImage = m_inlineFlowBox.renderer().style()->maskBoxImage(
).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.renderer().hasLayer() && m_inlineFlowB
ox.boxModelObject()->layer()->hasCompositedMask(); |
| 272 bool flattenCompositingLayers = m_inlineFlowBox.renderer().view()->frameView
() && m_inlineFlowBox.renderer().view()->frameView()->paintBehavior() & PaintBeh
aviorFlattenCompositingLayers; | 272 bool flattenCompositingLayers = m_inlineFlowBox.renderer().view()->frameView
() && m_inlineFlowBox.renderer().view()->frameView()->paintBehavior() & PaintBeh
aviorFlattenCompositingLayers; |
| 273 CompositeOperator compositeOp = CompositeSourceOver; | 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.renderer().style()->maskLayers().ha
sImage()) || m_inlineFlowBox.renderer().style()->maskLayers().next()) |
| 276 pushTransparencyLayer = true; | 276 pushTransparencyLayer = true; |
| 277 | 277 |
| 278 compositeOp = CompositeDestinationIn; | 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 = CompositeSourceOver; | 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.renderer().st
yle()->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.r
enderer(), m_inlineFlowBox.renderer().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(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |