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

Side by Side Diff: ui/gfx/canvas.h

Issue 24883002: Uses and returns the fractional width in text eliding (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix round-down problems Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef UI_GFX_CANVAS_H_ 5 #ifndef UI_GFX_CANVAS_H_
6 #define UI_GFX_CANVAS_H_ 6 #define UI_GFX_CANVAS_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // this method can be private. 118 // this method can be private.
119 void RecreateBackingCanvas(const Size& size, 119 void RecreateBackingCanvas(const Size& size,
120 float image_scale, 120 float image_scale,
121 bool is_opaque); 121 bool is_opaque);
122 122
123 // Compute the size required to draw some text with the provided fonts. 123 // Compute the size required to draw some text with the provided fonts.
124 // Attempts to fit the text with the provided width and height. Increases 124 // Attempts to fit the text with the provided width and height. Increases
125 // height and then width as needed to make the text fit. This method 125 // height and then width as needed to make the text fit. This method
126 // supports multiple lines. On Skia only a line_height can be specified and 126 // supports multiple lines. On Skia only a line_height can be specified and
127 // specifying a 0 value for it will cause the default height to be used. 127 // specifying a 0 value for it will cause the default height to be used.
128 static void SizeStringInt(const base::string16& text, 128 static void SizeStringToFit(const base::string16& text,
129 const FontList& font_list, 129 const FontList& font_list,
130 int* width, 130 float* width,
131 int* height, 131 float* height,
132 int line_height, 132 int line_height,
133 int flags); 133 int flags);
134 // Obsolete version. Use the above version which takes FontList. 134 // Obsolete version. Use the above version which takes FontList.
135 static void SizeStringInt(const base::string16& text, 135 static void SizeStringToFit(const base::string16& text,
136 const Font& font, 136 const Font& font,
137 int* width, 137 float* width,
138 int* height, 138 float* height,
139 int line_height, 139 int line_height,
140 int flags); 140 int flags);
141 141
142 // Returns the number of horizontal pixels needed to display the specified 142 // Returns the number of horizontal pixels needed to display the specified
sky 2013/10/03 14:19:23 Update description, since presumably a fractional
jianli 2013/10/03 18:42:17 Done.
143 // |text| with |font_list|. 143 // |text| with |font_list|.
144 static int GetStringWidth(const base::string16& text, 144 static float GetStringWidth(const base::string16& text,
145 const FontList& font_list); 145 const FontList& font_list);
146 // Obsolete version. Use the above version which takes FontList. 146 // Obsolete version. Use the above version which takes FontList.
147 static int GetStringWidth(const base::string16& text, const Font& font); 147 static float GetStringWidth(const base::string16& text, const Font& font);
148 148
149 // Returns the default text alignment to be used when drawing text on a 149 // Returns the default text alignment to be used when drawing text on a
150 // Canvas based on the directionality of the system locale language. 150 // Canvas based on the directionality of the system locale language.
151 // This function is used by Canvas::DrawStringInt when the text alignment 151 // This function is used by Canvas::DrawStringInt when the text alignment
152 // is not specified. 152 // is not specified.
153 // 153 //
154 // This function returns either Canvas::TEXT_ALIGN_LEFT or 154 // This function returns either Canvas::TEXT_ALIGN_LEFT or
155 // Canvas::TEXT_ALIGN_RIGHT. 155 // Canvas::TEXT_ALIGN_RIGHT.
156 static int DefaultCanvasTextAlignment(); 156 static int DefaultCanvasTextAlignment();
157 157
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 478
479 skia::RefPtr<skia::PlatformCanvas> owned_canvas_; 479 skia::RefPtr<skia::PlatformCanvas> owned_canvas_;
480 SkCanvas* canvas_; 480 SkCanvas* canvas_;
481 481
482 DISALLOW_COPY_AND_ASSIGN(Canvas); 482 DISALLOW_COPY_AND_ASSIGN(Canvas);
483 }; 483 };
484 484
485 } // namespace gfx 485 } // namespace gfx
486 486
487 #endif // UI_GFX_CANVAS_H_ 487 #endif // UI_GFX_CANVAS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698