mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 1689884 - Cache pointer information needed by media queries r=jld
Currently, every single usage of the @media (pointer) CSS query causes a substantial amount of processing to figure out whether the device has a pointer installed, and whether or not it's fine or coarse. This value should probably just be cached after the first time it's called. Furthermore, it probably shouldn't be called in content at all because it's a win32k call. This changes the variable to be both read in the parent process and cached in the child. Differential Revision: https://phabricator.services.mozilla.com/D105838
This commit is contained in:
parent
cfef04f1a8
commit
7aa22c0cc7
@ -122,6 +122,8 @@ void nsLookAndFeel::RefreshImpl() {
|
||||
}
|
||||
mCaretBlinkTime = -1;
|
||||
|
||||
mCacheValidBits.reset();
|
||||
|
||||
mInitialized = false;
|
||||
}
|
||||
|
||||
@ -604,14 +606,25 @@ nsresult nsLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) {
|
||||
break;
|
||||
}
|
||||
case IntID::PrimaryPointerCapabilities: {
|
||||
PointerCapabilities caps =
|
||||
widget::WinUtils::GetPrimaryPointerCapabilities();
|
||||
aResult = static_cast<int32_t>(caps);
|
||||
if (!mCacheValidBits[PrimaryPointerCapabilitiesKind] &&
|
||||
!XRE_IsContentProcess()) {
|
||||
mPrimaryPointerCapabilities = static_cast<int32_t>(
|
||||
widget::WinUtils::GetPrimaryPointerCapabilities());
|
||||
mCacheValidBits[PrimaryPointerCapabilitiesKind] = true;
|
||||
}
|
||||
|
||||
aResult = mPrimaryPointerCapabilities;
|
||||
break;
|
||||
}
|
||||
case IntID::AllPointerCapabilities: {
|
||||
PointerCapabilities caps = widget::WinUtils::GetAllPointerCapabilities();
|
||||
aResult = static_cast<int32_t>(caps);
|
||||
if (!mCacheValidBits[AllPointerCapabilitiesKind] &&
|
||||
!XRE_IsContentProcess()) {
|
||||
mAllPointerCapabilities =
|
||||
static_cast<int32_t>(widget::WinUtils::GetAllPointerCapabilities());
|
||||
mCacheValidBits[AllPointerCapabilitiesKind] = true;
|
||||
}
|
||||
|
||||
aResult = mAllPointerCapabilities;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -835,6 +848,14 @@ LookAndFeelCache nsLookAndFeel::GetCacheImpl() {
|
||||
lafInt.value() = GetInt(IntID::WindowsThemeIdentifier);
|
||||
cache.mInts().AppendElement(lafInt);
|
||||
|
||||
lafInt.id() = IntID::PrimaryPointerCapabilities;
|
||||
lafInt.value() = GetInt(IntID::PrimaryPointerCapabilities);
|
||||
cache.mInts().AppendElement(lafInt);
|
||||
|
||||
lafInt.id() = IntID::AllPointerCapabilities;
|
||||
lafInt.value() = GetInt(IntID::AllPointerCapabilities);
|
||||
cache.mInts().AppendElement(lafInt);
|
||||
|
||||
for (size_t i = size_t(LookAndFeel::FontID::MINIMUM);
|
||||
i <= size_t(LookAndFeel::FontID::MAXIMUM); ++i) {
|
||||
cache.mFonts().AppendElement(GetLookAndFeelFont(LookAndFeel::FontID(i)));
|
||||
@ -862,6 +883,12 @@ void nsLookAndFeel::DoSetCache(const LookAndFeelCache& aCache) {
|
||||
case IntID::WindowsThemeIdentifier:
|
||||
mNativeThemeId = entry.value();
|
||||
break;
|
||||
case IntID::PrimaryPointerCapabilities:
|
||||
mPrimaryPointerCapabilities = entry.value();
|
||||
break;
|
||||
case IntID::AllPointerCapabilities:
|
||||
mAllPointerCapabilities = entry.value();
|
||||
break;
|
||||
default:
|
||||
MOZ_ASSERT_UNREACHABLE("Bogus Int ID in cache");
|
||||
break;
|
||||
|
@ -6,6 +6,7 @@
|
||||
#ifndef __nsLookAndFeel
|
||||
#define __nsLookAndFeel
|
||||
|
||||
#include <bitset>
|
||||
#include <windows.h>
|
||||
|
||||
#include "nsXPLookAndFeel.h"
|
||||
@ -62,6 +63,12 @@ class nsLookAndFeel final : public nsXPLookAndFeel {
|
||||
void SetCacheImpl(const LookAndFeelCache& aCache) override;
|
||||
|
||||
private:
|
||||
enum CachedValueKind {
|
||||
PrimaryPointerCapabilitiesKind,
|
||||
AllPointerCapabilitiesKind,
|
||||
CachedValueKindMax = AllPointerCapabilitiesKind,
|
||||
};
|
||||
|
||||
void DoSetCache(const LookAndFeelCache& aCache);
|
||||
|
||||
/**
|
||||
@ -95,6 +102,15 @@ class nsLookAndFeel final : public nsXPLookAndFeel {
|
||||
int32_t mUseAccessibilityTheme;
|
||||
int32_t mUseDefaultTheme; // is the current theme a known default?
|
||||
int32_t mNativeThemeId; // see LookAndFeel enum 'WindowsTheme'
|
||||
|
||||
// Information about whether pointers exist, and whether they are fine
|
||||
// (like a mouse) or coarse (like a VR peripheral), and whether they
|
||||
// support the concept of "hovering" over something
|
||||
//
|
||||
// See the CSS "@media pointer" query for more info
|
||||
int32_t mPrimaryPointerCapabilities;
|
||||
int32_t mAllPointerCapabilities;
|
||||
|
||||
int32_t mCaretBlinkTime;
|
||||
|
||||
// Cached colors and flags indicating success in their retrieval.
|
||||
@ -133,6 +149,11 @@ class nsLookAndFeel final : public nsXPLookAndFeel {
|
||||
mFontCache;
|
||||
|
||||
nsCOMPtr<nsIWindowsRegKey> mDwmKey;
|
||||
|
||||
// A bitmap of which cached values are currently valid (ignored in content
|
||||
// process, since all cached values in content may only be updated from
|
||||
// one valid value to another, otherwise layout will not function properly)
|
||||
std::bitset<CachedValueKindMax + 1> mCacheValidBits;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user