Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Side by Side Diff: Source/core/paint/EmbeddedObjectPainter.cpp

Issue 1316163002: Make the LayoutRect->FloatRect constructor explicit. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/paint/EllipsisBoxPainter.cpp ('k') | Source/core/paint/FieldsetPainter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 29 matching lines...) Expand all
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))
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);
53 GraphicsContextStateSaver stateSaver(*context); 53 GraphicsContextStateSaver stateSaver(*context);
54 // TODO(chrishtr): this should be pixel-snapped.
54 context->clip(contentRect); 55 context->clip(contentRect);
55 56
56 Font font = replacementTextFont(); 57 Font font = replacementTextFont();
57 // TODO(trchen): Speculative fix for crbug.com/481880 58 // TODO(trchen): Speculative fix for crbug.com/481880
58 // With last resort font, how could this ever be null? 59 // With last resort font, how could this ever be null?
59 ASSERT(font.primaryFont()); 60 ASSERT(font.primaryFont());
60 if (!font.primaryFont()) 61 if (!font.primaryFont())
61 return; 62 return;
62 TextRun textRun(m_layoutEmbeddedObject.unavailablePluginReplacementText()); 63 TextRun textRun(m_layoutEmbeddedObject.unavailablePluginReplacementText());
63 FloatSize textGeometry(font.width(textRun), font.fontMetrics().height()); 64 FloatSize textGeometry(font.width(textRun), font.fontMetrics().height());
64 65
65 FloatRect backgroundRect(0, 0, textGeometry.width() + 2 * replacementTextRou ndedRectLeftRightTextMargin, replacementTextRoundedRectHeight); 66 FloatRect backgroundRect(0, 0, textGeometry.width() + 2 * replacementTextRou ndedRectLeftRightTextMargin, replacementTextRoundedRectHeight);
66 backgroundRect.move(contentRect.center() - backgroundRect.center()); 67 backgroundRect.move(contentRect.center() - backgroundRect.center());
67 Path roundedBackgroundRect; 68 Path roundedBackgroundRect;
68 roundedBackgroundRect.addRoundedRect(backgroundRect, FloatSize(replacementTe xtRoundedRectRadius, replacementTextRoundedRectRadius)); 69 roundedBackgroundRect.addRoundedRect(backgroundRect, FloatSize(replacementTe xtRoundedRectRadius, replacementTextRoundedRectRadius));
69 context->setFillColor(scaleAlpha(Color::white, replacementTextRoundedRectOpa city)); 70 context->setFillColor(scaleAlpha(Color::white, replacementTextRoundedRectOpa city));
70 context->fillPath(roundedBackgroundRect); 71 context->fillPath(roundedBackgroundRect);
71 72
72 FloatRect textRect(FloatPoint(), textGeometry); 73 FloatRect textRect(FloatPoint(), textGeometry);
73 textRect.move(contentRect.center() - textRect.center()); 74 textRect.move(contentRect.center() - textRect.center());
74 TextRunPaintInfo runInfo(textRun); 75 TextRunPaintInfo runInfo(textRun);
75 runInfo.bounds = backgroundRect; 76 runInfo.bounds = backgroundRect;
76 context->setFillColor(scaleAlpha(Color::black, replacementTextTextOpacity)); 77 context->setFillColor(scaleAlpha(Color::black, replacementTextTextOpacity));
77 context->drawBidiText(font, runInfo, textRect.location() + FloatSize(0, font .fontMetrics().ascent())); 78 context->drawBidiText(font, runInfo, textRect.location() + FloatSize(0, font .fontMetrics().ascent()));
78 } 79 }
79 80
80 } // namespace blink 81 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/EllipsisBoxPainter.cpp ('k') | Source/core/paint/FieldsetPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698