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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/location_bar/autocomplete_text_field_editor.h" 5 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h"
6 6
7 #include "base/mac/sdk_forward_declarations.h" 7 #include "base/mac/sdk_forward_declarations.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #include "chrome/app/chrome_command_ids.h" // IDC_* 10 #include "chrome/app/chrome_command_ids.h" // IDC_*
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 if (observer) 482 if (observer)
483 observer->OnBeforeChange(); 483 observer->OnBeforeChange();
484 484
485 [super interpretKeyEvents:eventArray]; 485 [super interpretKeyEvents:eventArray];
486 486
487 if (textChangedByKeyEvents_ && observer) 487 if (textChangedByKeyEvents_ && observer)
488 observer->OnDidChange(); 488 observer->OnDidChange();
489 489
490 DCHECK(interpretingKeyEvents_); 490 DCHECK(interpretingKeyEvents_);
491 interpretingKeyEvents_ = NO; 491 interpretingKeyEvents_ = NO;
492
493 // -[NSTextView interpretKeyEvents:] invalidates the existing layout.
494 //
495 // observer->OnDidChange() calls OmniboxViewMac::ApplyTextStyle, which
496 // invalidates the existing layout again, but in a slightly different way.
497 // Details unclear.
498 //
499 // On older versions of macOS, this results in a single call to -[NSTextView
500 // drawRect:] on the next frame, which paints the correct contents.
501 //
502 // On macOS 10.12 dp4, for unknown reasons, this causes two calls to
503 // -[NSTextView drawRect:] across two(!) frames. The first call to
504 // -[NSTextView drawRect:] draws no text, which causes a flicker in the
505 // omnibox. Forcing a layout ensures that drawRect: is only called once, and
506 // is drawn with the correct contents.
507 // https://crbug.com/634318.
508 [self.layoutManager
509 ensureLayoutForCharacterRange:NSMakeRange(0, self.textStorage.length)];
492 } 510 }
493 511
494 - (BOOL)shouldChangeTextInRange:(NSRange)affectedCharRange 512 - (BOOL)shouldChangeTextInRange:(NSRange)affectedCharRange
495 replacementString:(NSString *)replacementString { 513 replacementString:(NSString *)replacementString {
496 BOOL ret = [super shouldChangeTextInRange:affectedCharRange 514 BOOL ret = [super shouldChangeTextInRange:affectedCharRange
497 replacementString:replacementString]; 515 replacementString:replacementString];
498 516
499 if (ret && !interpretingKeyEvents_) { 517 if (ret && !interpretingKeyEvents_) {
500 AutocompleteTextFieldObserver* observer = [self observer]; 518 AutocompleteTextFieldObserver* observer = [self observer];
501 if (observer) 519 if (observer)
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 if (!ui::MaterialDesignController::IsModeMaterial()) { 626 if (!ui::MaterialDesignController::IsModeMaterial()) {
609 return; 627 return;
610 } 628 }
611 [self updateColorsToMatchTheme]; 629 [self updateColorsToMatchTheme];
612 } 630 }
613 631
614 - (void)windowDidChangeActive { 632 - (void)windowDidChangeActive {
615 } 633 }
616 634
617 @end 635 @end
OLDNEW
« 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