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

Unified Diff: chrome/browser/autocomplete/autocomplete_edit_view_mac.mm

Issue 2127009: Cleanup a bunch of TODO(shess). (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: Created 10 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
index c4998591adbe6b2024127137ae8f2880d52c1554..720f3ac41a7dfa78b4a3c92b136d87d45f9e2c0d 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
@@ -160,10 +160,6 @@ NSImage* AutocompleteEditViewMac::ImageForResource(int resource_id) {
return rb.GetNSImageNamed(resource_id);
}
-// TODO(shess): AutocompletePopupViewMac doesn't really need an
-// NSTextField. It wants to know where the position the popup, what
-// font to use, and it also needs to be able to attach the popup to
-// the window |field_| is in.
AutocompleteEditViewMac::AutocompleteEditViewMac(
AutocompleteEditController* controller,
ToolbarModel* toolbar_model,
@@ -189,19 +185,14 @@ AutocompleteEditViewMac::AutocompleteEditViewMac(
[field_ setAllowsEditingTextAttributes:YES];
// Get the appropriate line height for the font that we use.
- NSFont* font = ResourceBundle::GetSharedInstance().GetFont(
- ResourceBundle::BaseFont).nativeFont();
scoped_nsobject<NSLayoutManager>
layoutManager([[NSLayoutManager alloc] init]);
[layoutManager setUsesScreenFonts:YES];
- line_height_ = [layoutManager defaultLineHeightForFont:font];
+ line_height_ = [layoutManager defaultLineHeightForFont:GetFieldFont()];
DCHECK(line_height_ > 0);
}
AutocompleteEditViewMac::~AutocompleteEditViewMac() {
- // TODO(shess): Having to be aware of destructor ordering in this
- // way seems brittle. There must be a better way.
-
// Destroy popup view before this object in case it tries to call us
// back in the destructor. Likewise for destroying the model before
// this object.
@@ -487,9 +478,7 @@ void AutocompleteEditViewMac::EmphasizeURLComponents() {
void AutocompleteEditViewMac::ApplyTextAttributes(
const std::wstring& display_text, NSMutableAttributedString* as) {
- NSFont* font = ResourceBundle::GetSharedInstance().GetFont(
- ResourceBundle::BaseFont).nativeFont();
- [as addAttribute:NSFontAttributeName value:font
+ [as addAttribute:NSFontAttributeName value:GetFieldFont()
range:NSMakeRange(0, [as length])];
// Make a paragraph style locking in the standard line height as the maximum,
@@ -686,19 +675,14 @@ bool AutocompleteEditViewMac::OnDoCommandBySelector(SEL cmd) {
return model_->OnEscapeKeyPressed();
}
- if (cmd == @selector(insertTab:)) {
+ if (cmd == @selector(insertTab:) ||
+ cmd == @selector(insertTabIgnoringFieldEditor:)) {
if (model_->is_keyword_hint() && !model_->keyword().empty()) {
model_->AcceptKeyword();
return true;
}
}
- // TODO(shess): Option-tab, would normally insert a literal tab
- // character. Consider combining with -insertTab:
- if (cmd == @selector(insertTabIgnoringFieldEditor:)) {
- return true;
- }
-
// |-noop:| is sent when the user presses Cmd+Return. Override the no-op
// behavior with the proper WindowOpenDisposition.
NSEvent* event = [NSApp currentEvent];
@@ -939,3 +923,9 @@ std::wstring AutocompleteEditViewMac::GetClipboardText(Clipboard* clipboard) {
return std::wstring();
}
+
+// static
+NSFont* AutocompleteEditViewMac::GetFieldFont() {
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ return rb.GetFont(ResourceBundle::BaseFont).nativeFont();
+}

Powered by Google App Engine
This is Rietveld 408576698