| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/EmbeddedObjectPainter.h" | 6 #include "core/paint/EmbeddedObjectPainter.h" |
| 7 | 7 |
| 8 #include "core/frame/Settings.h" | 8 #include "core/frame/Settings.h" |
| 9 #include "core/layout/LayoutEmbeddedObject.h" | 9 #include "core/layout/LayoutEmbeddedObject.h" |
| 10 #include "core/layout/LayoutTheme.h" | 10 #include "core/layout/LayoutTheme.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 void EmbeddedObjectPainter::paintReplaced(const PaintInfo& paintInfo, const Layo
utPoint& paintOffset) | 38 void EmbeddedObjectPainter::paintReplaced(const PaintInfo& paintInfo, const Layo
utPoint& paintOffset) |
| 39 { | 39 { |
| 40 if (!m_layoutEmbeddedObject.showsUnavailablePluginIndicator()) | 40 if (!m_layoutEmbeddedObject.showsUnavailablePluginIndicator()) |
| 41 return; | 41 return; |
| 42 | 42 |
| 43 if (paintInfo.phase == PaintPhaseSelection) | 43 if (paintInfo.phase == PaintPhaseSelection) |
| 44 return; | 44 return; |
| 45 | 45 |
| 46 GraphicsContext* context = paintInfo.context; | 46 GraphicsContext* context = paintInfo.context; |
| 47 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*context, m_layo
utEmbeddedObject, paintInfo.phase)) | 47 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*context, m_layo
utEmbeddedObject, paintInfo.phase, paintOffset)) |
| 48 return; | 48 return; |
| 49 | 49 |
| 50 FloatRect contentRect(m_layoutEmbeddedObject.contentBoxRect()); | 50 FloatRect contentRect(m_layoutEmbeddedObject.contentBoxRect()); |
| 51 contentRect.moveBy(roundedIntPoint(paintOffset)); | 51 contentRect.moveBy(roundedIntPoint(paintOffset)); |
| 52 LayoutObjectDrawingRecorder drawingRecorder(*context, m_layoutEmbeddedObject
, paintInfo.phase, contentRect); | 52 LayoutObjectDrawingRecorder drawingRecorder(*context, m_layoutEmbeddedObject
, paintInfo.phase, contentRect, paintOffset); |
| 53 GraphicsContextStateSaver stateSaver(*context); | 53 GraphicsContextStateSaver stateSaver(*context); |
| 54 // TODO(chrishtr): this should be pixel-snapped. | 54 // TODO(chrishtr): this should be pixel-snapped. |
| 55 context->clip(contentRect); | 55 context->clip(contentRect); |
| 56 | 56 |
| 57 Font font = replacementTextFont(); | 57 Font font = replacementTextFont(); |
| 58 // TODO(trchen): Speculative fix for crbug.com/481880 | 58 // TODO(trchen): Speculative fix for crbug.com/481880 |
| 59 // With last resort font, how could this ever be null? | 59 // With last resort font, how could this ever be null? |
| 60 ASSERT(font.primaryFont()); | 60 ASSERT(font.primaryFont()); |
| 61 if (!font.primaryFont()) | 61 if (!font.primaryFont()) |
| 62 return; | 62 return; |
| 63 TextRun textRun(m_layoutEmbeddedObject.unavailablePluginReplacementText()); | 63 TextRun textRun(m_layoutEmbeddedObject.unavailablePluginReplacementText()); |
| 64 FloatSize textGeometry(font.width(textRun), font.fontMetrics().height()); | 64 FloatSize textGeometry(font.width(textRun), font.fontMetrics().height()); |
| 65 | 65 |
| 66 FloatRect backgroundRect(0, 0, textGeometry.width() + 2 * replacementTextRou
ndedRectLeftRightTextMargin, replacementTextRoundedRectHeight); | 66 FloatRect backgroundRect(0, 0, textGeometry.width() + 2 * replacementTextRou
ndedRectLeftRightTextMargin, replacementTextRoundedRectHeight); |
| 67 backgroundRect.move(contentRect.center() - backgroundRect.center()); | 67 backgroundRect.move(contentRect.center() - backgroundRect.center()); |
| 68 Path roundedBackgroundRect; | 68 Path roundedBackgroundRect; |
| 69 roundedBackgroundRect.addRoundedRect(backgroundRect, FloatSize(replacementTe
xtRoundedRectRadius, replacementTextRoundedRectRadius)); | 69 roundedBackgroundRect.addRoundedRect(backgroundRect, FloatSize(replacementTe
xtRoundedRectRadius, replacementTextRoundedRectRadius)); |
| 70 context->setFillColor(scaleAlpha(Color::white, replacementTextRoundedRectOpa
city)); | 70 context->setFillColor(scaleAlpha(Color::white, replacementTextRoundedRectOpa
city)); |
| 71 context->fillPath(roundedBackgroundRect); | 71 context->fillPath(roundedBackgroundRect); |
| 72 | 72 |
| 73 FloatRect textRect(FloatPoint(), textGeometry); | 73 FloatRect textRect(FloatPoint(), textGeometry); |
| 74 textRect.move(contentRect.center() - textRect.center()); | 74 textRect.move(contentRect.center() - textRect.center()); |
| 75 TextRunPaintInfo runInfo(textRun); | 75 TextRunPaintInfo runInfo(textRun); |
| 76 runInfo.bounds = backgroundRect; | 76 runInfo.bounds = backgroundRect; |
| 77 context->setFillColor(scaleAlpha(Color::black, replacementTextTextOpacity)); | 77 context->setFillColor(scaleAlpha(Color::black, replacementTextTextOpacity)); |
| 78 context->drawBidiText(font, runInfo, textRect.location() + FloatSize(0, font
.fontMetrics().ascent())); | 78 context->drawBidiText(font, runInfo, textRect.location() + FloatSize(0, font
.fontMetrics().ascent())); |
| 79 } | 79 } |
| 80 | 80 |
| 81 } // namespace blink | 81 } // namespace blink |
| OLD | NEW |