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

Side by Side Diff: ui/gfx/render_text_linux.cc

Issue 18848002: Shows Japanese and English mixed queries correctly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disables the test on Android. Created 7 years, 5 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
« no previous file with comments | « ui/gfx/render_text.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "ui/gfx/render_text_linux.h" 5 #include "ui/gfx/render_text_linux.h"
6 6
7 #include <pango/pangocairo.h> 7 #include <pango/pangocairo.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 } 76 }
77 77
78 RenderTextLinux::~RenderTextLinux() { 78 RenderTextLinux::~RenderTextLinux() {
79 ResetLayout(); 79 ResetLayout();
80 } 80 }
81 81
82 Size RenderTextLinux::GetStringSize() { 82 Size RenderTextLinux::GetStringSize() {
83 EnsureLayout(); 83 EnsureLayout();
84 int width = 0, height = 0; 84 int width = 0, height = 0;
85 pango_layout_get_pixel_size(layout_, &width, &height); 85 pango_layout_get_pixel_size(layout_, &width, &height);
86 return Size(width, height); 86 // Keep a consistent height between this particular string's PangoLayout and
87 // potentially larger text supported by the FontList.
88 return Size(width, std::max(height, font_list().GetHeight()));
87 } 89 }
88 90
89 int RenderTextLinux::GetBaseline() { 91 int RenderTextLinux::GetBaseline() {
90 EnsureLayout(); 92 EnsureLayout();
91 return PANGO_PIXELS(pango_layout_get_baseline(layout_)); 93 // Keep a consistent baseline between this particular string's PangoLayout and
94 // potentially larger text supported by the FontList.
95 return std::max(PANGO_PIXELS(pango_layout_get_baseline(layout_)),
96 font_list().GetBaseline());
92 } 97 }
93 98
94 SelectionModel RenderTextLinux::FindCursorPosition(const Point& point) { 99 SelectionModel RenderTextLinux::FindCursorPosition(const Point& point) {
95 EnsureLayout(); 100 EnsureLayout();
96 101
97 if (text().empty()) 102 if (text().empty())
98 return SelectionModel(0, CURSOR_FORWARD); 103 return SelectionModel(0, CURSOR_FORWARD);
99 104
100 Point p(ToTextPoint(point)); 105 Point p(ToTextPoint(point));
101 106
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 DCHECK(italic == styles()[ITALIC].breaks().end()); 362 DCHECK(italic == styles()[ITALIC].breaks().end());
358 363
359 pango_layout_set_attributes(layout, attrs); 364 pango_layout_set_attributes(layout, attrs);
360 pango_attr_list_unref(attrs); 365 pango_attr_list_unref(attrs);
361 } 366 }
362 367
363 void RenderTextLinux::DrawVisualText(Canvas* canvas) { 368 void RenderTextLinux::DrawVisualText(Canvas* canvas) {
364 DCHECK(layout_); 369 DCHECK(layout_);
365 370
366 // Skia will draw glyphs with respect to the baseline. 371 // Skia will draw glyphs with respect to the baseline.
367 Vector2d offset(GetTextOffset() + 372 Vector2d offset(GetTextOffset() + Vector2d(0, GetBaseline()));
368 Vector2d(0, PANGO_PIXELS(pango_layout_get_baseline(layout_))));
369 373
370 SkScalar x = SkIntToScalar(offset.x()); 374 SkScalar x = SkIntToScalar(offset.x());
371 SkScalar y = SkIntToScalar(offset.y()); 375 SkScalar y = SkIntToScalar(offset.y());
372 376
373 std::vector<SkPoint> pos; 377 std::vector<SkPoint> pos;
374 std::vector<uint16> glyphs; 378 std::vector<uint16> glyphs;
375 379
376 internal::SkiaTextRenderer renderer(canvas); 380 internal::SkiaTextRenderer renderer(canvas);
377 ApplyFadeEffects(&renderer); 381 ApplyFadeEffects(&renderer);
378 ApplyTextShadows(&renderer); 382 ApplyTextShadows(&renderer);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 int glyph_index) const { 496 int glyph_index) const {
493 return LayoutIndexToTextIndex(run->item->offset + 497 return LayoutIndexToTextIndex(run->item->offset +
494 run->glyphs->log_clusters[glyph_index]); 498 run->glyphs->log_clusters[glyph_index]);
495 } 499 }
496 500
497 RenderText* RenderText::CreateInstance() { 501 RenderText* RenderText::CreateInstance() {
498 return new RenderTextLinux; 502 return new RenderTextLinux;
499 } 503 }
500 504
501 } // namespace gfx 505 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/render_text.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698