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

Unified Diff: ui/gfx/render_text.cc

Issue 660953002: Type conversion fixes, text rendering edition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
Index: ui/gfx/render_text.cc
diff --git a/ui/gfx/render_text.cc b/ui/gfx/render_text.cc
index 8c516c10b54503745e969bab90a2e7e1b24b058b..704fe8d921c8904e4ff4184b139fbf25cd1cbd14 100644
--- a/ui/gfx/render_text.cc
+++ b/ui/gfx/render_text.cc
@@ -269,8 +269,10 @@ void SkiaTextRenderer::EndDiagonalStrike() {
}
void SkiaTextRenderer::DrawUnderline(int x, int y, int width) {
- SkRect r = SkRect::MakeLTRB(x, y + underline_position_, x + width,
- y + underline_position_ + underline_thickness_);
+ SkScalar x_scalar = SkIntToScalar(x);
+ SkRect r = SkRect::MakeLTRB(
+ x_scalar, y + underline_position_, x_scalar + width,
+ y + underline_position_ + underline_thickness_);
if (underline_thickness_ == kUnderlineMetricsNotSet) {
const SkScalar text_size = paint_.getTextSize();
r.fTop = SkScalarMulAdd(text_size, kUnderlineOffset, y);
@@ -283,7 +285,9 @@ void SkiaTextRenderer::DrawStrike(int x, int y, int width) const {
const SkScalar text_size = paint_.getTextSize();
const SkScalar height = SkScalarMul(text_size, kLineThickness);
const SkScalar offset = SkScalarMulAdd(text_size, kStrikeThroughOffset, y);
- const SkRect r = SkRect::MakeLTRB(x, offset, x + width, offset + height);
+ SkScalar x_scalar = SkIntToScalar(x);
+ const SkRect r =
+ SkRect::MakeLTRB(x_scalar, offset, x_scalar + width, offset + height);
canvas_skia_->drawRect(r, paint_);
}
@@ -314,7 +318,7 @@ void SkiaTextRenderer::DiagonalStrike::Draw() {
const int clip_height = height + 2 * thickness;
paint_.setAntiAlias(true);
- paint_.setStrokeWidth(thickness);
+ paint_.setStrokeWidth(SkIntToScalar(thickness));
const bool clipped = pieces_.size() > 1;
SkCanvas* sk_canvas = canvas_->sk_canvas();
@@ -720,8 +724,7 @@ VisualCursorDirection RenderText::GetVisualDirectionOfLogicalEnd() {
}
SizeF RenderText::GetStringSizeF() {
- const Size size = GetStringSize();
- return SizeF(size.width(), size.height());
+ return GetStringSize();
msw 2014/10/17 22:13:23 Cool, I hadn't seen the gfx::Size operator SizeF()
}
float RenderText::GetContentWidth() {
@@ -857,7 +860,9 @@ const Vector2d& RenderText::GetUpdatedDisplayOffset() {
}
void RenderText::SetDisplayOffset(int horizontal_offset) {
- const int extra_content = GetContentWidth() - display_rect_.width();
+ // !!! Should this round or ceil?
msw 2014/10/17 22:13:23 Dan or Cem may have opinions here; we ultimately w
Daniel Erat 2014/10/17 23:20:05 i have no opinion here.
Peter Kasting 2014/10/21 01:20:45 It seems like ceiling here is a different behavior
+ const int extra_content =
+ static_cast<int>(GetContentWidth()) - display_rect_.width();
const int cursor_width = cursor_enabled_ ? 1 : 0;
int min_offset = 0;
@@ -1210,8 +1215,9 @@ void RenderText::UpdateLayoutText() {
static_cast<int>(GetContentWidth()) > display_rect_.width()) {
// This doesn't trim styles so ellipsis may get rendered as a different
// style than the preceding text. See crbug.com/327850.
- layout_text_.assign(
- Elide(layout_text_, display_rect_.width(), elide_behavior_));
+ layout_text_.assign(Elide(layout_text_,
+ static_cast<float>(display_rect_.width()),
+ elide_behavior_));
}
// Replace the newline character with a newline symbol in single line mode.

Powered by Google App Engine
This is Rietveld 408576698