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 "core/paint/EmbeddedObjectPainter.h" | 5 #include "core/paint/EmbeddedObjectPainter.h" |
6 | 6 |
7 #include "core/frame/Settings.h" | 7 #include "core/frame/Settings.h" |
8 #include "core/layout/LayoutEmbeddedObject.h" | 8 #include "core/layout/LayoutEmbeddedObject.h" |
9 #include "core/layout/LayoutTheme.h" | 9 #include "core/layout/LayoutTheme.h" |
10 #include "core/paint/LayoutObjectDrawingRecorder.h" | 10 #include "core/paint/LayoutObjectDrawingRecorder.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 GraphicsContextStateSaver stateSaver(context); | 52 GraphicsContextStateSaver stateSaver(context); |
53 context.clip(pixelSnappedIntRect(contentRect)); | 53 context.clip(pixelSnappedIntRect(contentRect)); |
54 | 54 |
55 Font font = replacementTextFont(); | 55 Font font = replacementTextFont(); |
56 // TODO(trchen): Speculative fix for crbug.com/481880 | 56 // TODO(trchen): Speculative fix for crbug.com/481880 |
57 // With last resort font, how could this ever be null? | 57 // With last resort font, how could this ever be null? |
58 ASSERT(font.primaryFont()); | 58 ASSERT(font.primaryFont()); |
59 if (!font.primaryFont()) | 59 if (!font.primaryFont()) |
60 return; | 60 return; |
61 TextRun textRun(m_layoutEmbeddedObject.unavailablePluginReplacementText()); | 61 TextRun textRun(m_layoutEmbeddedObject.unavailablePluginReplacementText()); |
62 FloatSize textGeometry(font.width(textRun), font.fontMetrics().height()); | 62 FloatSize textGeometry(font.width(textRun), font.getFontMetrics().height()); |
63 | 63 |
64 LayoutRect backgroundRect(0, 0, textGeometry.width() + 2 * replacementTextRo
undedRectLeftRightTextMargin, replacementTextRoundedRectHeight); | 64 LayoutRect backgroundRect(0, 0, textGeometry.width() + 2 * replacementTextRo
undedRectLeftRightTextMargin, replacementTextRoundedRectHeight); |
65 backgroundRect.move(contentRect.center() - backgroundRect.center()); | 65 backgroundRect.move(contentRect.center() - backgroundRect.center()); |
66 backgroundRect = LayoutRect(pixelSnappedIntRect(backgroundRect)); | 66 backgroundRect = LayoutRect(pixelSnappedIntRect(backgroundRect)); |
67 Path roundedBackgroundRect; | 67 Path roundedBackgroundRect; |
68 FloatRect floatBackgroundRect(backgroundRect); | 68 FloatRect floatBackgroundRect(backgroundRect); |
69 roundedBackgroundRect.addRoundedRect(floatBackgroundRect, FloatSize(replacem
entTextRoundedRectRadius, replacementTextRoundedRectRadius)); | 69 roundedBackgroundRect.addRoundedRect(floatBackgroundRect, FloatSize(replacem
entTextRoundedRectRadius, replacementTextRoundedRectRadius)); |
70 context.setFillColor(scaleAlpha(Color::white, replacementTextRoundedRectOpac
ity)); | 70 context.setFillColor(scaleAlpha(Color::white, replacementTextRoundedRectOpac
ity)); |
71 context.fillPath(roundedBackgroundRect); | 71 context.fillPath(roundedBackgroundRect); |
72 | 72 |
73 FloatRect textRect(FloatPoint(), textGeometry); | 73 FloatRect textRect(FloatPoint(), textGeometry); |
74 textRect.move(FloatPoint(contentRect.center()) - textRect.center()); | 74 textRect.move(FloatPoint(contentRect.center()) - textRect.center()); |
75 TextRunPaintInfo runInfo(textRun); | 75 TextRunPaintInfo runInfo(textRun); |
76 runInfo.bounds = floatBackgroundRect; | 76 runInfo.bounds = floatBackgroundRect; |
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.
getFontMetrics().ascent())); |
79 } | 79 } |
80 | 80 |
81 } // namespace blink | 81 } // namespace blink |
OLD | NEW |