mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1701796: Move IsTouchDeviceSupportPresent to LookAndFeel remoting to prevent win32k usage in the content process. r=emilio,geckoview-reviewers,owlish
Differential Revision: https://phabricator.services.mozilla.com/D123497
This commit is contained in:
parent
27c0b44edb
commit
8434181376
@ -9,12 +9,12 @@
|
||||
#include "mozilla/dom/Touch.h"
|
||||
#include "mozilla/dom/TouchListBinding.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/LookAndFeel.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
#include "mozilla/TouchEvents.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "mozilla/WidgetUtils.h"
|
||||
|
||||
namespace mozilla::dom {
|
||||
|
||||
@ -194,29 +194,16 @@ bool TouchEvent::PrefEnabled(JSContext* aCx, JSObject* aGlobal) {
|
||||
return PrefEnabled(docShell);
|
||||
}
|
||||
|
||||
// static
|
||||
bool TouchEvent::PlatformSupportsTouch() {
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
// Touch support is always enabled on android.
|
||||
return true;
|
||||
#elif defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
|
||||
static bool sDidCheckTouchDeviceSupport = false;
|
||||
static bool sIsTouchDeviceSupportPresent = false;
|
||||
// On Windows and GTK3 we auto-detect based on device support.
|
||||
if (!sDidCheckTouchDeviceSupport) {
|
||||
sDidCheckTouchDeviceSupport = true;
|
||||
sIsTouchDeviceSupportPresent =
|
||||
widget::WidgetUtils::IsTouchDeviceSupportPresent();
|
||||
// But touch events are only actually supported if APZ is enabled. If
|
||||
// APZ is disabled globally, we can check that once and incorporate that
|
||||
// into the cached state. If APZ is enabled, we need to further check
|
||||
// based on the widget, which we do below (and don't cache that result).
|
||||
sIsTouchDeviceSupportPresent &= gfxPlatform::AsyncPanZoomEnabled();
|
||||
}
|
||||
static bool PlatformSupportsTouch() {
|
||||
// Touch events are only actually supported if APZ is enabled. If APZ is
|
||||
// disabled globally, we can check that once and incorporate that into the
|
||||
// cached state. If APZ is enabled, we need to further check based on the
|
||||
// widget, which we do in PrefEnabled (and don't cache that result).
|
||||
static bool sIsTouchDeviceSupportPresent =
|
||||
!!LookAndFeel::GetInt(LookAndFeel::IntID::TouchDeviceSupportPresent) &&
|
||||
gfxPlatform::AsyncPanZoomEnabled();
|
||||
|
||||
return sIsTouchDeviceSupportPresent;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -94,7 +94,6 @@ class TouchEvent : public UIEvent {
|
||||
bool aMetaKey, TouchList* aTouches,
|
||||
TouchList* aTargetTouches, TouchList* aChangedTouches);
|
||||
|
||||
static bool PlatformSupportsTouch();
|
||||
static bool PrefEnabled(JSContext* aCx, JSObject* aGlobal);
|
||||
static bool PrefEnabled(nsIDocShell* aDocShell);
|
||||
static bool LegacyAPIEnabled(JSContext* aCx, JSObject* aGlobal);
|
||||
|
@ -342,6 +342,9 @@ class LookAndFeel {
|
||||
/** The horizontal scrollbar height, in CSS pixels. */
|
||||
SystemHorizontalScrollbarHeight,
|
||||
|
||||
/** A boolean value to determine whether a touch device is present */
|
||||
TouchDeviceSupportPresent,
|
||||
|
||||
/*
|
||||
* Not an ID; used to define the range of valid IDs. Must be last.
|
||||
*/
|
||||
|
@ -14,12 +14,6 @@
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsTArray.h"
|
||||
#include "prenv.h"
|
||||
#ifdef XP_WIN
|
||||
# include "WinUtils.h"
|
||||
#endif
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
# include "mozilla/WidgetUtilsGtk.h"
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -97,16 +91,6 @@ nsIntRect RotateRect(nsIntRect aRect, const nsIntRect& aBounds,
|
||||
|
||||
namespace widget {
|
||||
|
||||
uint32_t WidgetUtils::IsTouchDeviceSupportPresent() {
|
||||
#ifdef XP_WIN
|
||||
return WinUtils::IsTouchDeviceSupportPresent();
|
||||
#elif defined(MOZ_WIDGET_GTK)
|
||||
return WidgetUtilsGTK::IsTouchDeviceSupportPresent();
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
// static
|
||||
void WidgetUtils::SendBidiKeyboardInfoToContent() {
|
||||
nsCOMPtr<nsIBidiKeyboard> bidiKeyboard = nsContentUtils::GetBidiKeyboard();
|
||||
|
@ -79,11 +79,6 @@ class WidgetUtils {
|
||||
uint32_t* aUnshiftedCharCode,
|
||||
uint32_t* aShiftedCharCode);
|
||||
|
||||
/**
|
||||
* Does device have touch support
|
||||
*/
|
||||
static uint32_t IsTouchDeviceSupportPresent();
|
||||
|
||||
/**
|
||||
* Send bidi keyboard information to content process
|
||||
*/
|
||||
|
@ -376,6 +376,11 @@ nsresult nsLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) {
|
||||
aResult = 25;
|
||||
break;
|
||||
|
||||
case IntID::TouchDeviceSupportPresent:
|
||||
// Touch support is always enabled on android.
|
||||
aResult = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
aResult = 0;
|
||||
rv = NS_ERROR_FAILURE;
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "mozilla/AutoRestore.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/ScopeExit.h"
|
||||
#include "mozilla/WidgetUtilsGtk.h"
|
||||
#include "ScreenHelperGTK.h"
|
||||
#include "nsNativeBasicThemeGTK.h"
|
||||
|
||||
@ -872,6 +873,9 @@ nsresult nsLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) {
|
||||
aResult = 1;
|
||||
break;
|
||||
}
|
||||
case IntID::TouchDeviceSupportPresent:
|
||||
aResult = WidgetUtilsGTK::IsTouchDeviceSupportPresent() ? 1 : 0;
|
||||
break;
|
||||
default:
|
||||
aResult = 0;
|
||||
res = NS_ERROR_FAILURE;
|
||||
|
@ -108,7 +108,7 @@ static EnumeratedCache<FontID, widget::LookAndFeelFont, FontID::End> sFontCache;
|
||||
//
|
||||
// This needs to be of the same length and in the same order as
|
||||
// LookAndFeel::IntID values.
|
||||
static const char sIntPrefs[][42] = {
|
||||
static const char sIntPrefs[][43] = {
|
||||
"ui.caretBlinkTime",
|
||||
"ui.caretBlinkCount",
|
||||
"ui.caretWidth",
|
||||
@ -175,6 +175,7 @@ static const char sIntPrefs[][42] = {
|
||||
"ui.allPointerCapabilities",
|
||||
"ui.systemVerticalScrollbarWidth",
|
||||
"ui.systemHorizontalScrollbarHeight",
|
||||
"ui.touchDeviceSupportPresent",
|
||||
};
|
||||
|
||||
static_assert(ArrayLength(sIntPrefs) == size_t(LookAndFeel::IntID::End),
|
||||
|
@ -591,6 +591,9 @@ nsresult nsLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) {
|
||||
static_cast<int32_t>(widget::WinUtils::GetAllPointerCapabilities());
|
||||
break;
|
||||
}
|
||||
case IntID::TouchDeviceSupportPresent:
|
||||
aResult = WinUtils::IsTouchDeviceSupportPresent() ? 1 : 0;
|
||||
break;
|
||||
default:
|
||||
aResult = 0;
|
||||
res = NS_ERROR_FAILURE;
|
||||
|
Loading…
Reference in New Issue
Block a user