refactor: move GetCursorBlinkInterval() to a helper function (#20060)
This commit is contained in:
parent
c46a386970
commit
b136819371
1 changed files with 22 additions and 18 deletions
|
@ -313,6 +313,25 @@ void OnCapturePageDone(util::Promise<gfx::Image> promise,
|
||||||
promise.Resolve(gfx::Image::CreateFrom1xBitmap(bitmap));
|
promise.Resolve(gfx::Image::CreateFrom1xBitmap(bitmap));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
base::Optional<base::TimeDelta> GetCursorBlinkInterval() {
|
||||||
|
#if defined(OS_MACOSX)
|
||||||
|
base::TimeDelta interval;
|
||||||
|
if (ui::TextInsertionCaretBlinkPeriod(&interval))
|
||||||
|
return interval;
|
||||||
|
#elif defined(OS_LINUX)
|
||||||
|
if (auto* linux_ui = views::LinuxUI::instance())
|
||||||
|
return linux_ui->GetCursorBlinkInterval();
|
||||||
|
#elif defined(OS_WIN)
|
||||||
|
const auto system_msec = ::GetCaretBlinkTime();
|
||||||
|
if (system_msec != 0) {
|
||||||
|
return (system_msec == INFINITE)
|
||||||
|
? base::TimeDelta()
|
||||||
|
: base::TimeDelta::FromMilliseconds(system_msec);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return base::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
WebContents::WebContents(v8::Isolate* isolate,
|
WebContents::WebContents(v8::Isolate* isolate,
|
||||||
|
@ -467,24 +486,9 @@ 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
|
// Honor the system's cursor blink rate settings
|
||||||
#if defined(OS_MACOSX)
|
if (auto interval = GetCursorBlinkInterval())
|
||||||
base::TimeDelta interval;
|
prefs->caret_blink_interval = *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