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

Side by Side Diff: ash/system/user/tray_user.cc

Issue 11535014: Replace StyleRange with BreakList; update RenderText, etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 7 years, 10 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 | « no previous file | chrome/browser/ui/views/extensions/extension_installed_bubble.cc » ('j') | 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 "ash/system/user/tray_user.h" 5 #include "ash/system/user/tray_user.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <climits> 8 #include <climits>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 for (std::vector<string16>::const_iterator it = lines.begin(); 289 for (std::vector<string16>::const_iterator it = lines.begin();
290 it != lines.end(); ++it) { 290 it != lines.end(); ++it) {
291 gfx::RenderText* line = gfx::RenderText::CreateInstance(); 291 gfx::RenderText* line = gfx::RenderText::CreateInstance();
292 line->SetDirectionalityMode(gfx::DIRECTIONALITY_FROM_UI); 292 line->SetDirectionalityMode(gfx::DIRECTIONALITY_FROM_UI);
293 line->SetText(*it); 293 line->SetText(*it);
294 const gfx::Size size(contents_area.width(), line->GetStringSize().height()); 294 const gfx::Size size(contents_area.width(), line->GetStringSize().height());
295 line->SetDisplayRect(gfx::Rect(position, size)); 295 line->SetDisplayRect(gfx::Rect(position, size));
296 position.set_y(position.y() + size.height()); 296 position.set_y(position.y() + size.height());
297 297
298 // Set the default text color for the line. 298 // Set the default text color for the line.
299 gfx::StyleRange default_style(line->default_style()); 299 line->SetColor(kPublicAccountUserCardTextColor);
300 default_style.foreground = kPublicAccountUserCardTextColor;
301 line->set_default_style(default_style);
302 line->ApplyDefaultStyle();
303 300
304 // If a range of the line contains the user's display name, apply a custom 301 // If a range of the line contains the user's display name, apply a custom
305 // text color to it. 302 // text color to it.
306 if (display_name.is_empty()) 303 if (display_name.is_empty())
307 display_name.set_start(it->find(kDisplayNameMark)); 304 display_name.set_start(it->find(kDisplayNameMark));
308 if (!display_name.is_empty()) { 305 if (!display_name.is_empty()) {
309 display_name.set_end( 306 display_name.set_end(
310 it->find(kDisplayNameMark, display_name.start() + 1)); 307 it->find(kDisplayNameMark, display_name.start() + 1));
311 gfx::StyleRange display_name_style(line->default_style());
312 display_name_style.foreground = kPublicAccountUserCardNameColor;
313 ui::Range line_range(0, it->size()); 308 ui::Range line_range(0, it->size());
314 display_name_style.range = display_name.Intersect(line_range); 309 line->ApplyColor(kPublicAccountUserCardNameColor,
315 line->ApplyStyleRange(display_name_style); 310 display_name.Intersect(line_range));
316 // Update the range for the next line. 311 // Update the range for the next line.
317 if (display_name.end() >= line_range.end()) 312 if (display_name.end() >= line_range.end())
318 display_name.set_start(0); 313 display_name.set_start(0);
319 else 314 else
320 display_name = ui::Range::InvalidRange(); 315 display_name = ui::Range::InvalidRange();
321 } 316 }
322 317
323 lines_.push_back(line); 318 lines_.push_back(line);
324 } 319 }
325 320
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 // Check for null to avoid crbug.com/150944. 660 // Check for null to avoid crbug.com/150944.
666 if (avatar_) { 661 if (avatar_) {
667 avatar_->SetImage( 662 avatar_->SetImage(
668 ash::Shell::GetInstance()->system_tray_delegate()->GetUserImage(), 663 ash::Shell::GetInstance()->system_tray_delegate()->GetUserImage(),
669 gfx::Size(kUserIconSize, kUserIconSize)); 664 gfx::Size(kUserIconSize, kUserIconSize));
670 } 665 }
671 } 666 }
672 667
673 } // namespace internal 668 } // namespace internal
674 } // namespace ash 669 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/extensions/extension_installed_bubble.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698