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

Side by Side Diff: third_party/WebKit/Source/core/paint/EllipsisBoxPainter.cpp

Issue 2416033003: Remove unsafe getFontMetrics methods (Closed)
Patch Set: Address wkroman suggestions Created 4 years, 2 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
OLDNEW
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 "core/paint/EllipsisBoxPainter.h" 5 #include "core/paint/EllipsisBoxPainter.h"
6 6
7 #include "core/layout/TextRunConstructor.h" 7 #include "core/layout/TextRunConstructor.h"
8 #include "core/layout/api/LineLayoutItem.h" 8 #include "core/layout/api/LineLayoutItem.h"
9 #include "core/layout/api/SelectionState.h" 9 #include "core/layout/api/SelectionState.h"
10 #include "core/layout/line/EllipsisBox.h" 10 #include "core/layout/line/EllipsisBox.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 boxOrigin.moveBy(paintOffset); 51 boxOrigin.moveBy(paintOffset);
52 LayoutRect boxRect(boxOrigin, 52 LayoutRect boxRect(boxOrigin,
53 LayoutSize(m_ellipsisBox.logicalWidth(), 53 LayoutSize(m_ellipsisBox.logicalWidth(),
54 m_ellipsisBox.virtualLogicalHeight())); 54 m_ellipsisBox.virtualLogicalHeight()));
55 55
56 GraphicsContextStateSaver stateSaver(context); 56 GraphicsContextStateSaver stateSaver(context);
57 if (!m_ellipsisBox.isHorizontal()) 57 if (!m_ellipsisBox.isHorizontal())
58 context.concatCTM(TextPainter::rotation(boxRect, TextPainter::Clockwise)); 58 context.concatCTM(TextPainter::rotation(boxRect, TextPainter::Clockwise));
59 59
60 const Font& font = style.font(); 60 const Font& font = style.font();
61 const SimpleFontData* fontData = font.primaryFont();
62 DCHECK(fontData);
63 if (!fontData)
64 return;
61 65
62 TextPainter::Style textStyle = TextPainter::textPaintingStyle( 66 TextPainter::Style textStyle = TextPainter::textPaintingStyle(
63 m_ellipsisBox.getLineLayoutItem(), style, paintInfo); 67 m_ellipsisBox.getLineLayoutItem(), style, paintInfo);
64 TextRun textRun = constructTextRun(font, m_ellipsisBox.ellipsisStr(), style, 68 TextRun textRun = constructTextRun(font, m_ellipsisBox.ellipsisStr(), style,
65 TextRun::AllowTrailingExpansion); 69 TextRun::AllowTrailingExpansion);
66 LayoutPoint textOrigin(boxOrigin.x(), 70 LayoutPoint textOrigin(boxOrigin.x(),
67 boxOrigin.y() + font.getFontMetrics().ascent()); 71 boxOrigin.y() + fontData->getFontMetrics().ascent());
68 TextPainter textPainter(context, font, textRun, textOrigin, boxRect, 72 TextPainter textPainter(context, font, textRun, textOrigin, boxRect,
69 m_ellipsisBox.isHorizontal()); 73 m_ellipsisBox.isHorizontal());
70 textPainter.paint(0, m_ellipsisBox.ellipsisStr().length(), 74 textPainter.paint(0, m_ellipsisBox.ellipsisStr().length(),
71 m_ellipsisBox.ellipsisStr().length(), textStyle); 75 m_ellipsisBox.ellipsisStr().length(), textStyle);
72 } 76 }
73 77
74 } // namespace blink 78 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698