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

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

Issue 213029: [Mac] Paste in Omnibox needs to initiate field editing correctly. (Closed)
Patch Set: Created 11 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 ff81db30fca5b1b3cd97a5d7a76aec62ae803850..a95be0d450c036b6fe499c97631021a142244d67 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
@@ -586,24 +586,32 @@ void AutocompleteEditViewMac::OnPaste() {
if (text.empty()) {
return;
}
+ NSString* s = base::SysWideToNSString(text);
- // If this paste will be replacing all the text, record that, so we
- // can do different behaviors in such a case.
- const NSRange allRange = NSMakeRange(0, [[field_ stringValue] length]);
+ // -shouldChangeTextInRange:* and -didChangeText are documented in
+ // NSTextView as things you need to do if you write additional
+ // user-initiated editing functions. They cause the appropriate
+ // delegate methods to be called.
+ // TODO(shess): It would be nice to separate the Cocoa-specific code
+ // from the Chrome-specific code.
+ NSTextView* editor = static_cast<NSTextView*>([field_ currentEditor]);
const NSRange selectedRange = GetSelectedRange();
- if (NSEqualRanges(allRange, selectedRange)) {
- model_->on_paste_replacing_all();
- }
-
- // Force a Paste operation to trigger the text_changed code in
- // OnAfterPossibleChange(), even if identical contents are pasted into the
- // text box.
- text_before_change_.clear();
+ if ([editor shouldChangeTextInRange:selectedRange replacementString:s]) {
+ // If this paste will be replacing all the text, record that, so
+ // we can do different behaviors in such a case.
+ const NSRange allRange = NSMakeRange(0, [[field_ stringValue] length]);
+ if (NSEqualRanges(allRange, selectedRange)) {
+ model_->on_paste_replacing_all();
+ }
- NSString* s = base::SysWideToNSString(text);
- [[field_ currentEditor] replaceCharactersInRange:selectedRange withString:s];
+ // Force a Paste operation to trigger the text_changed code in
+ // OnAfterPossibleChange(), even if identical contents are pasted
+ // into the text box.
+ text_before_change_.clear();
- OnAfterPossibleChange();
+ [editor replaceCharactersInRange:selectedRange withString:s];
+ [editor didChangeText];
rohitrao (ping after 24h) 2009/09/18 20:38:25 So this is what fires off controlTextDidChange?
Scott Hess - ex-Googler 2009/09/18 21:20:51 -didChangeText leads to -controlTextDidChange:, -s
+ }
}
bool AutocompleteEditViewMac::OnTabPressed() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698