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

Side by Side Diff: chrome/browser/ui/cocoa/status_bubble_mac.mm

Issue 6121004: Remove wstring from gfx. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome/browser/ui/cocoa/status_bubble_mac.h" 5 #include "chrome/browser/ui/cocoa/status_bubble_mac.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "app/text_elider.h" 9 #include "app/text_elider.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 141
142 int text_width = static_cast<int>(NSWidth(frame) - 142 int text_width = static_cast<int>(NSWidth(frame) -
143 kBubbleViewTextPositionX - 143 kBubbleViewTextPositionX -
144 kTextPadding); 144 kTextPadding);
145 145
146 // Scale from view to window coordinates before eliding URL string. 146 // Scale from view to window coordinates before eliding URL string.
147 NSSize scaled_width = NSMakeSize(text_width, 0); 147 NSSize scaled_width = NSMakeSize(text_width, 0);
148 scaled_width = [[parent_ contentView] convertSize:scaled_width fromView:nil]; 148 scaled_width = [[parent_ contentView] convertSize:scaled_width fromView:nil];
149 text_width = static_cast<int>(scaled_width.width); 149 text_width = static_cast<int>(scaled_width.width);
150 NSFont* font = [[window_ contentView] font]; 150 NSFont* font = [[window_ contentView] font];
151 gfx::Font font_chr(base::SysNSStringToWide([font fontName]), 151 gfx::Font font_chr(base::SysNSStringToUTF16([font fontName]),
152 [font pointSize]); 152 [font pointSize]);
153 153
154 string16 original_url_text = net::FormatUrl(url, UTF16ToUTF8(languages)); 154 string16 original_url_text = net::FormatUrl(url, UTF16ToUTF8(languages));
155 string16 status = gfx::ElideUrl(url, font_chr, text_width, 155 string16 status = gfx::ElideUrl(url, font_chr, text_width,
156 UTF16ToWideHack(languages)); 156 UTF16ToWideHack(languages));
157 157
158 SetText(status, true); 158 SetText(status, true);
159 159
160 // In testing, don't use animation. When ExpandBubble is tested, it is 160 // In testing, don't use animation. When ExpandBubble is tested, it is
161 // called explicitly. 161 // called explicitly.
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 599
600 void StatusBubbleMac::ExpandBubble() { 600 void StatusBubbleMac::ExpandBubble() {
601 // Calculate the width available for expanded and standard bubbles. 601 // Calculate the width available for expanded and standard bubbles.
602 NSRect window_frame = CalculateWindowFrame(/*expand=*/true); 602 NSRect window_frame = CalculateWindowFrame(/*expand=*/true);
603 CGFloat max_bubble_width = NSWidth(window_frame); 603 CGFloat max_bubble_width = NSWidth(window_frame);
604 CGFloat standard_bubble_width = 604 CGFloat standard_bubble_width =
605 NSWidth(CalculateWindowFrame(/*expand=*/false)); 605 NSWidth(CalculateWindowFrame(/*expand=*/false));
606 606
607 // Generate the URL string that fits in the expanded bubble. 607 // Generate the URL string that fits in the expanded bubble.
608 NSFont* font = [[window_ contentView] font]; 608 NSFont* font = [[window_ contentView] font];
609 gfx::Font font_chr(base::SysNSStringToWide([font fontName]), 609 gfx::Font font_chr(base::SysNSStringToUTF16([font fontName]),
610 [font pointSize]); 610 [font pointSize]);
611 string16 expanded_url = gfx::ElideUrl(url_, font_chr, 611 string16 expanded_url = gfx::ElideUrl(url_, font_chr,
612 max_bubble_width, UTF16ToWideHack(languages_)); 612 max_bubble_width, UTF16ToWideHack(languages_));
613 613
614 // Scale width from gfx::Font in view coordinates to window coordinates. 614 // Scale width from gfx::Font in view coordinates to window coordinates.
615 int required_width_for_string = 615 int required_width_for_string =
616 font_chr.GetStringWidth(expanded_url) + 616 font_chr.GetStringWidth(expanded_url) +
617 kTextPadding * 2 + kBubbleViewTextPositionX; 617 kTextPadding * 2 + kBubbleViewTextPositionX;
618 NSSize scaled_width = NSMakeSize(required_width_for_string, 0); 618 NSSize scaled_width = NSMakeSize(required_width_for_string, 0);
619 scaled_width = [[parent_ contentView] convertSize:scaled_width toView:nil]; 619 scaled_width = [[parent_ contentView] convertSize:scaled_width toView:nil];
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 696
697 if (expanded_width) { 697 if (expanded_width) {
698 size.width = screenRect.size.width; 698 size.width = screenRect.size.width;
699 } else { 699 } else {
700 size.width = kWindowWidthPercent * screenRect.size.width; 700 size.width = kWindowWidthPercent * screenRect.size.width;
701 } 701 }
702 702
703 screenRect.size = size; 703 screenRect.size = size;
704 return screenRect; 704 return screenRect;
705 } 705 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698