| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #import "chrome/browser/ui/cocoa/autofill/autofill_section_container.h" | 5 #import "chrome/browser/ui/cocoa/autofill/autofill_section_container.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| 11 #include "base/mac/foundation_util.h" | 11 #include "base/mac/foundation_util.h" |
| 12 #include "base/mac/sdk_forward_declarations.h" |
| 12 #include "base/strings/sys_string_conversions.h" | 13 #include "base/strings/sys_string_conversions.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 14 #include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h" | 15 #include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h" |
| 15 #include "chrome/browser/ui/chrome_style.h" | 16 #include "chrome/browser/ui/chrome_style.h" |
| 16 #import "chrome/browser/ui/cocoa/autofill/autofill_pop_up_button.h" | 17 #import "chrome/browser/ui/cocoa/autofill/autofill_pop_up_button.h" |
| 17 #import "chrome/browser/ui/cocoa/autofill/autofill_section_view.h" | 18 #import "chrome/browser/ui/cocoa/autofill/autofill_section_view.h" |
| 18 #import "chrome/browser/ui/cocoa/autofill/autofill_suggestion_container.h" | 19 #import "chrome/browser/ui/cocoa/autofill/autofill_suggestion_container.h" |
| 19 #import "chrome/browser/ui/cocoa/autofill/autofill_textfield.h" | 20 #import "chrome/browser/ui/cocoa/autofill/autofill_textfield.h" |
| 20 #import "chrome/browser/ui/cocoa/autofill/autofill_tooltip_controller.h" | 21 #import "chrome/browser/ui/cocoa/autofill/autofill_tooltip_controller.h" |
| 21 #import "chrome/browser/ui/cocoa/autofill/layout_view.h" | 22 #import "chrome/browser/ui/cocoa/autofill/layout_view.h" |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 | 399 |
| 399 #pragma mark Internal API for AutofillSectionContainer. | 400 #pragma mark Internal API for AutofillSectionContainer. |
| 400 | 401 |
| 401 - (void)fieldEditedOrActivated:(NSControl<AutofillInputField>*)field | 402 - (void)fieldEditedOrActivated:(NSControl<AutofillInputField>*)field |
| 402 edited:(BOOL)edited { | 403 edited:(BOOL)edited { |
| 403 autofill::ServerFieldType type = [self fieldTypeForControl:field]; | 404 autofill::ServerFieldType type = [self fieldTypeForControl:field]; |
| 404 base::string16 fieldValue = base::SysNSStringToUTF16([field fieldValue]); | 405 base::string16 fieldValue = base::SysNSStringToUTF16([field fieldValue]); |
| 405 | 406 |
| 406 // Get the frame rectangle for the designated field, in screen coordinates. | 407 // Get the frame rectangle for the designated field, in screen coordinates. |
| 407 NSRect textFrameInScreen = [field convertRect:[field bounds] toView:nil]; | 408 NSRect textFrameInScreen = [field convertRect:[field bounds] toView:nil]; |
| 408 textFrameInScreen.origin = | 409 textFrameInScreen = [[field window] convertRectToScreen:textFrameInScreen]; |
| 409 [[field window] convertBaseToScreen:textFrameInScreen.origin]; | |
| 410 | 410 |
| 411 // And adjust for gfx::Rect being flipped compared to OSX coordinates. | 411 // And adjust for gfx::Rect being flipped compared to OSX coordinates. |
| 412 NSScreen* screen = [[NSScreen screens] firstObject]; | 412 NSScreen* screen = [[NSScreen screens] firstObject]; |
| 413 textFrameInScreen.origin.y = | 413 textFrameInScreen.origin.y = |
| 414 NSMaxY([screen frame]) - NSMaxY(textFrameInScreen); | 414 NSMaxY([screen frame]) - NSMaxY(textFrameInScreen); |
| 415 gfx::Rect textFrameRect(NSRectToCGRect(textFrameInScreen)); | 415 gfx::Rect textFrameRect(NSRectToCGRect(textFrameInScreen)); |
| 416 | 416 |
| 417 delegate_->UserEditedOrActivatedInput(section_, | 417 delegate_->UserEditedOrActivatedInput(section_, |
| 418 type, | 418 type, |
| 419 [self view], | 419 [self view], |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 | 750 |
| 751 - (void)activateFieldForType:(autofill::ServerFieldType)type { | 751 - (void)activateFieldForType:(autofill::ServerFieldType)type { |
| 752 NSControl<AutofillInputField>* field = [inputs_ viewWithTag:type]; | 752 NSControl<AutofillInputField>* field = [inputs_ viewWithTag:type]; |
| 753 if (field) { | 753 if (field) { |
| 754 [[field window] makeFirstResponder:field]; | 754 [[field window] makeFirstResponder:field]; |
| 755 [self fieldEditedOrActivated:field edited:NO]; | 755 [self fieldEditedOrActivated:field edited:NO]; |
| 756 } | 756 } |
| 757 } | 757 } |
| 758 | 758 |
| 759 @end | 759 @end |
| OLD | NEW |