Bug 1383659 - LookAndFeel::GetInt(LookAndFeel::eIntID_CaretBlinkTime) should cache caret blink rate. r=jimm

WebKit's Speedometer benchmark updates textbox to emulate text input. So it also updates caret position with focus.  And, nsCaret always gets current blink time when reseting caret via LookAndFeel.

When profiling speedometer benchmark, GetCaretBlinkTime somestimes show profiling stack.  This API gets data from kernel mode, so this isn't faster.

So, we should cache caret blink rate.

And when changing this rate via control panel, WM_SETTINGCHANGE is posted. So we should update this cache via this message.

MozReview-Commit-ID: IEIi25RvR1g

--HG--
extra : rebase_source : 4bc506acd67f2737cf44dc2a667c938efc7b4024
This commit is contained in:
Makoto Kato 2017-07-27 18:53:34 +09:00
Родитель 9297f5b2a3
Коммит dc2ee6bae4
3 изменённых файлов: 14 добавлений и 1 удалений

Просмотреть файл

@ -65,6 +65,7 @@ nsLookAndFeel::nsLookAndFeel()
, mUseAccessibilityTheme(0)
, mUseDefaultTheme(0)
, mNativeThemeId(eWindowsTheme_Generic)
, mCaretBlinkTime(-1)
{
mozilla::Telemetry::Accumulate(mozilla::Telemetry::TOUCH_ENABLED_DEVICE,
WinUtils::IsTouchDeviceSupportPresent());
@ -333,7 +334,12 @@ nsLookAndFeel::GetIntImpl(IntID aID, int32_t &aResult)
switch (aID) {
case eIntID_CaretBlinkTime:
aResult = (int32_t)::GetCaretBlinkTime();
// eIntID_CaretBlinkTime is often called by updating editable text
// that has focus. So it should be cached to improve performance.
if (mCaretBlinkTime < 0) {
mCaretBlinkTime = static_cast<int32_t>(::GetCaretBlinkTime());
}
aResult = mCaretBlinkTime;
break;
case eIntID_CaretWidth:
aResult = 1;
@ -739,6 +745,7 @@ nsLookAndFeel::RefreshImpl()
e != end; ++e) {
e->mCacheValid = false;
}
mCaretBlinkTime = -1;
}
/* virtual */

Просмотреть файл

@ -76,6 +76,7 @@ private:
int32_t mUseAccessibilityTheme;
int32_t mUseDefaultTheme; // is the current theme a known default?
int32_t mNativeThemeId; // see LookAndFeel enum 'WindowsTheme'
int32_t mCaretBlinkTime;
struct CachedSystemFont {
CachedSystemFont()

Просмотреть файл

@ -5210,6 +5210,11 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
case WM_SETTINGCHANGE:
{
if (wParam == SPI_SETKEYBOARDDELAY) {
// CaretBlinkTime is cached in nsLookAndFeel
NotifyThemeChanged();
break;
}
if (lParam) {
auto lParamString = reinterpret_cast<const wchar_t*>(lParam);
if (!wcscmp(lParamString, L"ImmersiveColorSet")) {