commit b1e0a3252e5d556652d71d16dd501317196a5a66 Author: Arthur Edelstein arthuredelstein@gmail.com Date: Wed Sep 23 10:20:44 2015 -0700
Bug 17009: Pref to suppress some modifier key events --- layout/base/nsIPresShell.h | 3 +++ layout/base/nsPresShell.cpp | 13 +++++++++++++ 2 files changed, 16 insertions(+)
diff --git a/layout/base/nsIPresShell.h b/layout/base/nsIPresShell.h index 2e74cae..3369d1f 100644 --- a/layout/base/nsIPresShell.h +++ b/layout/base/nsIPresShell.h @@ -1811,6 +1811,9 @@ protected: // to true, so we can avoid any paint calls for widget related to this // presshell. bool mIsNeverPainting; + + // If true, don't report Alt, Shift, and AltGr KeyboardEvents to content. + static bool sSuppressModifierKeyEvents; };
NS_DEFINE_STATIC_IID_ACCESSOR(nsIPresShell, NS_IPRESSHELL_IID) diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 938df78..e64584f 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -205,6 +205,7 @@ nsRefPtrHashtable<nsUint32HashKey, dom::Touch>* nsIPresShell::gCaptureTouchList; nsClassHashtable<nsUint32HashKey, nsIPresShell::PointerCaptureInfo>* nsIPresShell::gPointerCaptureList; nsClassHashtable<nsUint32HashKey, nsIPresShell::PointerInfo>* nsIPresShell::gActivePointersIds; bool nsIPresShell::gPreventMouseEvents = false; +bool nsIPresShell::sSuppressModifierKeyEvents = false;
// convert a color value to a string, in the CSS format #RRGGBB // * - initially created for bugs 31816, 20760, 22963 @@ -7187,6 +7188,16 @@ PresShell::HandleKeyboardEvent(nsINode* aTarget, nsEventStatus* aStatus, EventDispatchingCallback* aEventCB) { + if (nsContentUtils::ResistFingerprinting() && sSuppressModifierKeyEvents) { + nsString keyName; + aEvent.GetDOMKeyName(keyName); + if (keyName.Equals(NS_LITERAL_STRING("Shift")) || + keyName.Equals(NS_LITERAL_STRING("Alt")) || + keyName.Equals(NS_LITERAL_STRING("AltGraph"))) { + aEvent.mFlags.mOnlyChromeDispatch = true; + } + } + if (aEvent.message == NS_KEY_PRESS || !BeforeAfterKeyboardEventEnabled()) { EventDispatcher::Dispatch(aTarget, mPresContext, @@ -10866,6 +10877,8 @@ void nsIPresShell::InitializeStatics() gCaptureTouchList = new nsRefPtrHashtable<nsUint32HashKey, dom::Touch>; gPointerCaptureList = new nsClassHashtable<nsUint32HashKey, PointerCaptureInfo>; gActivePointersIds = new nsClassHashtable<nsUint32HashKey, PointerInfo>; + Preferences::AddBoolVarCache(&sSuppressModifierKeyEvents, + "privacy.suppressModifierKeyEvents", false); }
void nsIPresShell::ReleaseStatics()