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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/Font.h

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 /* 1 /*
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Antti Koivisto (koivisto@kde.org) 3 * (C) 2000 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2006, 2007, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2006, 2007, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (C) 2008 Holger Hans Peter Freyther 6 * Copyright (C) 2008 Holger Hans Peter Freyther
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 int h, 116 int h,
117 int from = 0, 117 int from = 0,
118 int to = -1, 118 int to = -1,
119 bool accountForGlyphBounds = false) const; 119 bool accountForGlyphBounds = false) const;
120 CharacterRange getCharacterRange(const TextRun&, 120 CharacterRange getCharacterRange(const TextRun&,
121 unsigned from, 121 unsigned from,
122 unsigned to) const; 122 unsigned to) const;
123 Vector<CharacterRange> individualCharacterRanges(const TextRun&) const; 123 Vector<CharacterRange> individualCharacterRanges(const TextRun&) const;
124 124
125 // Metrics that we query the FontFallbackList for. 125 // Metrics that we query the FontFallbackList for.
126 const FontMetrics& getFontMetrics() const {
127 RELEASE_ASSERT(primaryFont());
128 return primaryFont()->getFontMetrics();
129 }
130 float spaceWidth() const { 126 float spaceWidth() const {
131 return primaryFont()->spaceWidth() + getFontDescription().letterSpacing(); 127 return primaryFont()->spaceWidth() + getFontDescription().letterSpacing();
132 } 128 }
133 float tabWidth(const SimpleFontData&, const TabSize&, float position) const; 129 float tabWidth(const SimpleFontData&, const TabSize&, float position) const;
134 float tabWidth(const TabSize& tabSize, float position) const { 130 float tabWidth(const TabSize& tabSize, float position) const {
135 return tabWidth(*primaryFont(), tabSize, position); 131 return tabWidth(*primaryFont(), tabSize, position);
136 } 132 }
137 133
138 int emphasisMarkAscent(const AtomicString&) const; 134 int emphasisMarkAscent(const AtomicString&) const;
139 int emphasisMarkDescent(const AtomicString&) const; 135 int emphasisMarkDescent(const AtomicString&) const;
140 int emphasisMarkHeight(const AtomicString&) const; 136 int emphasisMarkHeight(const AtomicString&) const;
141 137
138 // This may fail and return a nullptr in case the last resort font cannot be
139 // loaded. This *should* not happen but in reality it does ever now and then
140 // when, for whatever reason, the last resort font cannot be loaded.
142 const SimpleFontData* primaryFont() const; 141 const SimpleFontData* primaryFont() const;
143 const FontData* fontDataAt(unsigned) const; 142 const FontData* fontDataAt(unsigned) const;
144 143
145 GlyphData glyphDataForCharacter(UChar32&, 144 GlyphData glyphDataForCharacter(UChar32&,
146 bool mirror, 145 bool mirror,
147 bool normalizeSpace = false, 146 bool normalizeSpace = false,
148 FontDataVariant = AutoVariant) const; 147 FontDataVariant = AutoVariant) const;
149 CodePath codePath(const TextRunPaintInfo&) const; 148 CodePath codePath(const TextRunPaintInfo&) const;
150 149
151 // Whether the font supports shaping word by word instead of shaping the 150 // Whether the font supports shaping word by word instead of shaping the
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 // advance an additional tab stop. 256 // advance an additional tab stop.
258 if (distanceToTabStop < fontData.spaceWidth() / 2) 257 if (distanceToTabStop < fontData.spaceWidth() / 2)
259 distanceToTabStop += baseTabWidth; 258 distanceToTabStop += baseTabWidth;
260 259
261 return distanceToTabStop; 260 return distanceToTabStop;
262 } 261 }
263 262
264 } // namespace blink 263 } // namespace blink
265 264
266 #endif 265 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/exported/WebFont.cpp ('k') | third_party/WebKit/Source/web/ExternalPopupMenu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698