Chromium Code Reviews| Index: chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm |
| diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm |
| index 1777998887526adcc8cceccf1b949b828f4d40ce..9b53c5565bf1989d95485928c2d5aa04410e2ea6 100644 |
| --- a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm |
| +++ b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm |
| @@ -401,6 +401,13 @@ void OmniboxViewMac::SetTextAndSelectedRange(const base::string16& display_text, |
| } |
| void OmniboxViewMac::EmphasizeURLComponents() { |
| + // Obtain the text before any editing - GetText will update the field's value |
| + // from textStorage, and if EmphasizeURLComponents is called from within the |
| + // editor's -resignFirstResponder, |field_| will have a text value that is |
| + // stripped of all attributes. (Since the editor is about to die and has |
| + // already synced the field to its value). |
| + base::string16 text = GetText(); |
|
Scott Hess - ex-Googler
2014/03/06 02:42:24
I cannot understand how the comment applies at all
groby-ooo-7-16
2014/03/06 04:07:51
Unfortunately, it still is the firstResponder, exc
Scott Hess - ex-Googler
2014/03/06 06:30:32
Still nack. base::string16 cannot have Cocoa attr
groby-ooo-7-16
2014/03/06 19:07:58
It doesn't. It's a side effect. Sequence of events
Scott Hess - ex-Googler
2014/03/06 19:28:12
This implies that calling [field_ stringValue] aft
Scott Hess - ex-Googler
2014/03/06 20:54:28
OK, I'm reading old CLs trying to wrap my head aro
groby-ooo-7-16
2014/03/07 01:47:08
Based on my reading of old CL's, we cannot call se
|
| + |
| NSTextView* editor = (NSTextView*)[field_ currentEditor]; |
| // If the autocomplete text field is in editing mode, then we can just change |
| // its attributes through its editor. Otherwise, we simply reset its content. |
| @@ -412,11 +419,11 @@ void OmniboxViewMac::EmphasizeURLComponents() { |
| // overlay the appropriate Omnibox attributes. |
| [storage setAttributes:[NSDictionary dictionary] |
| range:NSMakeRange(0, [storage length])]; |
| - ApplyTextAttributes(GetText(), storage); |
| + ApplyTextAttributes(text, storage); |
| [storage endEditing]; |
| } else { |
| - SetText(GetText()); |
| + SetText(text); |
| } |
| } |