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

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

Issue 18848002: Shows Japanese and English mixed queries correctly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adds a unit test. 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
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.h" 5 #include "ui/gfx/render_text.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/i18n/break_iterator.h" 9 #include "base/i18n/break_iterator.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 void RenderText::SetVerticalAlignment(VerticalAlignment alignment) { 341 void RenderText::SetVerticalAlignment(VerticalAlignment alignment) {
342 if (vertical_alignment_ != alignment) { 342 if (vertical_alignment_ != alignment) {
343 vertical_alignment_ = alignment; 343 vertical_alignment_ = alignment;
344 display_offset_ = Vector2d(); 344 display_offset_ = Vector2d();
345 cached_bounds_and_offset_valid_ = false; 345 cached_bounds_and_offset_valid_ = false;
346 } 346 }
347 } 347 }
348 348
349 void RenderText::SetFontList(const FontList& font_list) { 349 void RenderText::SetFontList(const FontList& font_list) {
350 font_list_ = font_list; 350 font_list_ = font_list;
351 // Cache the height and baseline of the font list.
352 font_list_height_ = font_list_.GetHeight();
msw 2013/07/11 22:47:29 Init these values to 0 in the ctor.
Yuki 2013/07/12 08:25:53 Done.
353 font_list_baseline_ = font_list_.GetBaseline();
351 cached_bounds_and_offset_valid_ = false; 354 cached_bounds_and_offset_valid_ = false;
352 ResetLayout(); 355 ResetLayout();
353 } 356 }
354 357
355 void RenderText::SetFont(const Font& font) { 358 void RenderText::SetFont(const Font& font) {
356 SetFontList(FontList(font)); 359 SetFontList(FontList(font));
357 } 360 }
358 361
359 void RenderText::SetFontSize(int size) { 362 void RenderText::SetFontSize(int size) {
360 font_list_ = font_list_.DeriveFontListWithSize(size); 363 SetFontList(font_list_.DeriveFontListWithSize(size));
361 cached_bounds_and_offset_valid_ = false;
362 ResetLayout();
363 } 364 }
364 365
365 void RenderText::SetCursorEnabled(bool cursor_enabled) { 366 void RenderText::SetCursorEnabled(bool cursor_enabled) {
366 cursor_enabled_ = cursor_enabled; 367 cursor_enabled_ = cursor_enabled;
367 cached_bounds_and_offset_valid_ = false; 368 cached_bounds_and_offset_valid_ = false;
368 } 369 }
369 370
370 const Font& RenderText::GetFont() const { 371 const Font& RenderText::GetFont() const {
371 return font_list_.GetFonts()[0]; 372 return font_list_.GetFonts()[0];
372 } 373 }
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 cursor_bounds_ += delta_offset; 1017 cursor_bounds_ += delta_offset;
1017 } 1018 }
1018 1019
1019 void RenderText::DrawSelection(Canvas* canvas) { 1020 void RenderText::DrawSelection(Canvas* canvas) {
1020 const std::vector<Rect> sel = GetSubstringBounds(selection()); 1021 const std::vector<Rect> sel = GetSubstringBounds(selection());
1021 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) 1022 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i)
1022 canvas->FillRect(*i, selection_background_focused_color_); 1023 canvas->FillRect(*i, selection_background_focused_color_);
1023 } 1024 }
1024 1025
1025 } // namespace gfx 1026 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698