fix: honor cursor blink rate (#20020)
* fix: honor cursor blink rate on macOS * fix: honor cursor blink rate on Linux * fix: honor cursor blink rate on Windows * refactor: clean up os_win cursor blink logic * remove unneeded include
This commit is contained in:
parent
805a55099b
commit
5cbbd489d5
1 changed files with 25 additions and 0 deletions
|
@ -100,6 +100,12 @@
|
||||||
|
|
||||||
#if !defined(OS_MACOSX)
|
#if !defined(OS_MACOSX)
|
||||||
#include "ui/aura/window.h"
|
#include "ui/aura/window.h"
|
||||||
|
#else
|
||||||
|
#include "ui/base/cocoa/defaults_utils.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(OS_LINUX)
|
||||||
|
#include "ui/views/linux_ui/linux_ui.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(OS_LINUX) || defined(OS_WIN)
|
#if defined(OS_LINUX) || defined(OS_WIN)
|
||||||
|
@ -458,6 +464,25 @@ void WebContents::InitWithSessionAndOptions(
|
||||||
prefs->subpixel_rendering = params->subpixel_rendering;
|
prefs->subpixel_rendering = params->subpixel_rendering;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Honor the system's cursor blink rate settings
|
||||||
|
#if defined(OS_MACOSX)
|
||||||
|
base::TimeDelta interval;
|
||||||
|
if (ui::TextInsertionCaretBlinkPeriod(&interval))
|
||||||
|
prefs->caret_blink_interval = interval;
|
||||||
|
#elif defined(OS_LINUX)
|
||||||
|
views::LinuxUI* linux_ui = views::LinuxUI::instance();
|
||||||
|
if (linux_ui)
|
||||||
|
prefs->caret_blink_interval = linux_ui->GetCursorBlinkInterval();
|
||||||
|
#elif defined(OS_WIN)
|
||||||
|
const auto system_msec = ::GetCaretBlinkTime();
|
||||||
|
if (system_msec != 0) {
|
||||||
|
prefs->caret_blink_interval =
|
||||||
|
(system_msec == INFINITE)
|
||||||
|
? base::TimeDelta()
|
||||||
|
: base::TimeDelta::FromMilliseconds(system_msec);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Save the preferences in C++.
|
// Save the preferences in C++.
|
||||||
new WebContentsPreferences(web_contents(), options);
|
new WebContentsPreferences(web_contents(), options);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue