Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include <AppKit/AppKit.h> | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "ui/base/cocoa/defaults_utils.h" | |
| 9 | |
| 10 namespace ui { | |
| 11 | |
| 12 bool TextInsertionCaretBlinkPeriod(base::TimeDelta* delta) { | |
| 13 const int kMaximumReasonableIntervalMs = 60 * 1000; | |
| 14 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | |
| 15 double on_period_ms = [defaults | |
| 16 floatForKey:@"NSTextInsertionPointBlinkPeriodOn"]; | |
| 17 double off_period_ms = [defaults | |
| 18 floatForKey:@"NSTextInsertionPointBlinkPeriodOff"]; | |
|
Nico
2016/08/25 19:40:37
apparently it's NSTextInsertionPointBlinkPeriod in
Elly Fong-Jones
2016/08/25 19:57:33
Done.
| |
| 19 if (on_period_ms == 0.0 && off_period_ms == 0.0) | |
| 20 return false; | |
| 21 // Neither Blink nor Views support having separate on and off intervals, so | |
| 22 // this function takes the average. | |
| 23 if (on_period_ms > kMaximumReasonableIntervalMs) { | |
|
Nico
2016/08/25 19:40:37
why check this for on_period_ms but not off_period
Elly Fong-Jones
2016/08/25 19:57:33
Added explanation
| |
| 24 *delta = base::TimeDelta(); | |
| 25 } else { | |
| 26 *delta = base::TimeDelta::FromMillisecondsD( | |
| 27 (on_period_ms + off_period_ms) / 2); | |
| 28 } | |
| 29 return true; | |
| 30 } | |
| 31 | |
| 32 } // namespace ui | |
| OLD | NEW |