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

Unified Diff: chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.mm

Issue 2237003004: Fix omnibox flickering on macOS Sierra. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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/ui/cocoa/location_bar/autocomplete_text_field_editor.mm
diff --git a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.mm b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.mm
index f76f2a3cb87f523be1f48f6904b3c29cf7cdfd52..d837c4efa65d6f0992ef09537260d590337784d1 100644
--- a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.mm
+++ b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.mm
@@ -489,6 +489,24 @@ BOOL ThePasteboardIsTooDamnBig() {
DCHECK(interpretingKeyEvents_);
interpretingKeyEvents_ = NO;
+
+ // -[NSTextView interpretKeyEvents:] invalidates the existing layout.
+ //
+ // observer->OnDidChange() calls OmniboxViewMac::ApplyTextStyle, which
+ // invalidates the existing layout again, but in a slightly different way.
+ // Details unclear.
+ //
+ // On older versions of macOS, this results in a single call to -[NSTextView
+ // drawRect:] on the next frame, which paints the correct contents.
+ //
+ // On macOS 10.12 dp4, for unknown reasons, this causes two calls to
+ // -[NSTextView drawRect:] across two(!) frames. The first call to
+ // -[NSTextView drawRect:] draws no text, which causes a flicker in the
+ // omnibox. Forcing a layout ensures that drawRect: is only called once, and
+ // is drawn with the correct contents.
+ // https://crbug.com/634318.
+ [self.layoutManager
+ ensureLayoutForCharacterRange:NSMakeRange(0, self.textStorage.length)];
}
- (BOOL)shouldChangeTextInRange:(NSRange)affectedCharRange
« 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