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

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

Issue 567543002: Avoid re-parsing of string in fillText and measureText in Canvas (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updating code and adding Layout test case Created 6 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
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 float spaceWidth() const { return primaryFont()->spaceWidth() + fontDescript ion().letterSpacing(); } 116 float spaceWidth() const { return primaryFont()->spaceWidth() + fontDescript ion().letterSpacing(); }
117 float tabWidth(const SimpleFontData&, unsigned tabSize, float position) cons t; 117 float tabWidth(const SimpleFontData&, unsigned tabSize, float position) cons t;
118 float tabWidth(unsigned tabSize, float position) const { return tabWidth(*pr imaryFont(), tabSize, position); } 118 float tabWidth(unsigned tabSize, float position) const { return tabWidth(*pr imaryFont(), tabSize, position); }
119 119
120 int emphasisMarkAscent(const AtomicString&) const; 120 int emphasisMarkAscent(const AtomicString&) const;
121 int emphasisMarkDescent(const AtomicString&) const; 121 int emphasisMarkDescent(const AtomicString&) const;
122 int emphasisMarkHeight(const AtomicString&) const; 122 int emphasisMarkHeight(const AtomicString&) const;
123 123
124 const SimpleFontData* primaryFont() const; 124 const SimpleFontData* primaryFont() const;
125 const FontData* fontDataAt(unsigned) const; 125 const FontData* fontDataAt(unsigned) const;
126 inline GlyphData glyphDataForCharacter(UChar32 c, bool mirror, FontDataVaria nt variant = AutoVariant) const 126 inline GlyphData glyphDataForCharacter(UChar32& c, bool mirror, bool spaceNo rmalize = false, FontDataVariant variant = AutoVariant) const
127 { 127 {
128 return glyphDataAndPageForCharacter(c, mirror, variant).first; 128 return glyphDataAndPageForCharacter(c, mirror, spaceNormalize, variant). first;
129 } 129 }
130 #if OS(MACOSX) 130 #if OS(MACOSX)
131 const SimpleFontData* fontDataForCombiningCharacterSequence(const UChar*, si ze_t length, FontDataVariant) const; 131 const SimpleFontData* fontDataForCombiningCharacterSequence(const UChar*, si ze_t length, FontDataVariant) const;
132 #endif 132 #endif
133 std::pair<GlyphData, GlyphPage*> glyphDataAndPageForCharacter(UChar32, bool mirror, FontDataVariant = AutoVariant) const; 133 std::pair<GlyphData, GlyphPage*> glyphDataAndPageForCharacter(UChar32&, bool mirror, bool spaceNormalize = false, FontDataVariant = AutoVariant) const;
134 bool primaryFontHasGlyphForCharacter(UChar32) const; 134 bool primaryFontHasGlyphForCharacter(UChar32) const;
135 135
136 CodePath codePath(const TextRun&) const; 136 CodePath codePath(const TextRun&) const;
137 137
138 private: 138 private:
139 enum ForTextEmphasisOrNot { NotForTextEmphasis, ForTextEmphasis }; 139 enum ForTextEmphasisOrNot { NotForTextEmphasis, ForTextEmphasis };
140 140
141 // Returns the initial in-stream advance. 141 // Returns the initial in-stream advance.
142 float getGlyphsAndAdvancesForSimpleText(const TextRunPaintInfo&, GlyphBuffer &, ForTextEmphasisOrNot = NotForTextEmphasis) const; 142 float getGlyphsAndAdvancesForSimpleText(const TextRunPaintInfo&, GlyphBuffer &, ForTextEmphasisOrNot = NotForTextEmphasis) const;
143 float drawSimpleText(GraphicsContext*, const TextRunPaintInfo&, const FloatP oint&) const; 143 float drawSimpleText(GraphicsContext*, const TextRunPaintInfo&, const FloatP oint&) const;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 { 224 {
225 if (!tabSize) 225 if (!tabSize)
226 return fontDescription().letterSpacing(); 226 return fontDescription().letterSpacing();
227 float tabWidth = tabSize * fontData.spaceWidth() + fontDescription().letterS pacing(); 227 float tabWidth = tabSize * fontData.spaceWidth() + fontDescription().letterS pacing();
228 return tabWidth - fmodf(position, tabWidth); 228 return tabWidth - fmodf(position, tabWidth);
229 } 229 }
230 230
231 } // namespace blink 231 } // namespace blink
232 232
233 #endif 233 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698