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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_edit_view_mac.mm

Issue 2762014: Mac: clang build (Closed)
Patch Set: more Created 10 years, 6 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/autocomplete/autocomplete_edit_view_mac.h" 5 #include "chrome/browser/autocomplete/autocomplete_edit_view_mac.h"
6 6
7 #include <Carbon/Carbon.h> // kVK_Return 7 #include <Carbon/Carbon.h> // kVK_Return
8 8
9 #include "app/clipboard/clipboard.h" 9 #include "app/clipboard/clipboard.h"
10 #include "app/clipboard/scoped_clipboard_writer.h" 10 #include "app/clipboard/scoped_clipboard_writer.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // scope, when the window resigns key the autocomplete popup is 48 // scope, when the window resigns key the autocomplete popup is
49 // closed. |model_| still believes it has focus, and the popup will 49 // closed. |model_| still believes it has focus, and the popup will
50 // be regenerated on the user's next edit. That seems to match how 50 // be regenerated on the user's next edit. That seems to match how
51 // things work on other platforms. 51 // things work on other platforms.
52 52
53 namespace { 53 namespace {
54 54
55 // TODO(shess): This is ugly, find a better way. Using it right now 55 // TODO(shess): This is ugly, find a better way. Using it right now
56 // so that I can crib from gtk and still be able to see that I'm using 56 // so that I can crib from gtk and still be able to see that I'm using
57 // the same values easily. 57 // the same values easily.
58 const NSColor* ColorWithRGBBytes(int rr, int gg, int bb) { 58 NSColor* ColorWithRGBBytes(int rr, int gg, int bb) {
59 DCHECK_LE(rr, 255); 59 DCHECK_LE(rr, 255);
60 DCHECK_LE(bb, 255); 60 DCHECK_LE(bb, 255);
61 DCHECK_LE(gg, 255); 61 DCHECK_LE(gg, 255);
62 return [NSColor colorWithCalibratedRed:static_cast<float>(rr)/255.0 62 return [NSColor colorWithCalibratedRed:static_cast<float>(rr)/255.0
63 green:static_cast<float>(gg)/255.0 63 green:static_cast<float>(gg)/255.0
64 blue:static_cast<float>(bb)/255.0 64 blue:static_cast<float>(bb)/255.0
65 alpha:1.0]; 65 alpha:1.0];
66 } 66 }
67 67
68 const NSColor* HostTextColor() { 68 NSColor* HostTextColor() {
69 return [NSColor blackColor]; 69 return [NSColor blackColor];
70 } 70 }
71 const NSColor* BaseTextColor() { 71 NSColor* BaseTextColor() {
72 return [NSColor darkGrayColor]; 72 return [NSColor darkGrayColor];
73 } 73 }
74 const NSColor* EVSecureSchemeColor() { 74 NSColor* EVSecureSchemeColor() {
75 return ColorWithRGBBytes(0x07, 0x95, 0x00); 75 return ColorWithRGBBytes(0x07, 0x95, 0x00);
76 } 76 }
77 const NSColor* SecureSchemeColor() { 77 NSColor* SecureSchemeColor() {
78 return ColorWithRGBBytes(0x00, 0x0e, 0x95); 78 return ColorWithRGBBytes(0x00, 0x0e, 0x95);
79 } 79 }
80 const NSColor* SecurityErrorSchemeColor() { 80 NSColor* SecurityErrorSchemeColor() {
81 return ColorWithRGBBytes(0xa2, 0x00, 0x00); 81 return ColorWithRGBBytes(0xa2, 0x00, 0x00);
82 } 82 }
83 83
84 // Store's the model and view state across tab switches. 84 // Store's the model and view state across tab switches.
85 struct AutocompleteEditViewMacState { 85 struct AutocompleteEditViewMacState {
86 AutocompleteEditViewMacState(const AutocompleteEditModel::State model_state, 86 AutocompleteEditViewMacState(const AutocompleteEditModel::State model_state,
87 const bool has_focus, const NSRange& selection) 87 const bool has_focus, const NSRange& selection)
88 : model_state(model_state), 88 : model_state(model_state),
89 has_focus(has_focus), 89 has_focus(has_focus),
90 selection(selection) { 90 selection(selection) {
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 model_->OnControlKeyChanged(pressed); 871 model_->OnControlKeyChanged(pressed);
872 } 872 }
873 873
874 void AutocompleteEditViewMac::FocusLocation(bool select_all) { 874 void AutocompleteEditViewMac::FocusLocation(bool select_all) {
875 if ([field_ isEditable]) { 875 if ([field_ isEditable]) {
876 // If the text field has a field editor, it's the first responder, meaning 876 // If the text field has a field editor, it's the first responder, meaning
877 // that it's already focused. makeFirstResponder: will select all, so only 877 // that it's already focused. makeFirstResponder: will select all, so only
878 // call it if this behavior is desired. 878 // call it if this behavior is desired.
879 if (select_all || ![field_ currentEditor]) 879 if (select_all || ![field_ currentEditor])
880 [[field_ window] makeFirstResponder:field_]; 880 [[field_ window] makeFirstResponder:field_];
881 DCHECK_EQ([field_ currentEditor], [[field_ window] firstResponder]); 881 // FIXME
882 DCHECK_EQ((id)[field_ currentEditor], (id)[[field_ window] firstResponder]);
882 } 883 }
883 } 884 }
884 885
885 // TODO(shess): Copied from autocomplete_edit_view_win.cc. Could this 886 // TODO(shess): Copied from autocomplete_edit_view_win.cc. Could this
886 // be pushed into the model? 887 // be pushed into the model?
887 std::wstring AutocompleteEditViewMac::GetClipboardText(Clipboard* clipboard) { 888 std::wstring AutocompleteEditViewMac::GetClipboardText(Clipboard* clipboard) {
888 // autocomplete_edit_view_win.cc assumes this can never happen, we 889 // autocomplete_edit_view_win.cc assumes this can never happen, we
889 // will too. 890 // will too.
890 DCHECK(clipboard); 891 DCHECK(clipboard);
891 892
(...skipping 30 matching lines...) Expand all
922 } 923 }
923 924
924 return std::wstring(); 925 return std::wstring();
925 } 926 }
926 927
927 // static 928 // static
928 NSFont* AutocompleteEditViewMac::GetFieldFont() { 929 NSFont* AutocompleteEditViewMac::GetFieldFont() {
929 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 930 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
930 return rb.GetFont(ResourceBundle::BaseFont).nativeFont(); 931 return rb.GetFont(ResourceBundle::BaseFont).nativeFont();
931 } 932 }
OLDNEW
« no previous file with comments | « chrome/browser/app_controller_mac.mm ('k') | chrome/browser/autocomplete/autocomplete_popup_view_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698