Bug 1195722 - Add a new pref to enable the accessible carets if touch events are supported, and enable the pref on nightly. r=tylin

MozReview-Commit-ID: 2eaVJ4fLqjt
This commit is contained in:
Kartikaya Gupta 2016-08-03 12:00:22 -04:00
parent ea0f7627b9
commit 6d50a6b8e2
4 changed files with 30 additions and 5 deletions

View File

@ -92,6 +92,7 @@
#include "PLDHashTable.h"
#include "mozilla/dom/BeforeAfterKeyboardEventBinding.h"
#include "mozilla/dom/Touch.h"
#include "mozilla/dom/TouchEvent.h"
#include "mozilla/dom/PointerEventBinding.h"
#include "nsIObserverService.h"
#include "nsDocShell.h" // for reflow observation
@ -734,17 +735,29 @@ static bool sSynthMouseMove = true;
static uint32_t sNextPresShellId;
static bool sPointerEventEnabled = true;
static bool sAccessibleCaretEnabled = false;
static bool sAccessibleCaretOnTouch = false;
static bool sBeforeAfterKeyboardEventEnabled = false;
/* static */ bool
PresShell::AccessibleCaretEnabled()
PresShell::AccessibleCaretEnabled(nsIDocShell* aDocShell)
{
static bool initialized = false;
if (!initialized) {
Preferences::AddBoolVarCache(&sAccessibleCaretEnabled, "layout.accessiblecaret.enabled");
Preferences::AddBoolVarCache(&sAccessibleCaretOnTouch, "layout.accessiblecaret.enabled_on_touch");
initialized = true;
}
return sAccessibleCaretEnabled;
// If the pref forces it on, then enable it.
if (sAccessibleCaretEnabled) {
return true;
}
// If the touch pref is on, and touch events are enabled (this depends
// on the specific device running), then enable it.
if (sAccessibleCaretOnTouch && dom::TouchEvent::PrefEnabled(aDocShell)) {
return true;
}
// Otherwise, disabled.
return false;
}
/* static */ bool
@ -898,7 +911,7 @@ PresShell::Init(nsIDocument* aDocument,
// Add the preference style sheet.
UpdatePreferenceStyles();
if (AccessibleCaretEnabled()) {
if (AccessibleCaretEnabled(mDocument->GetDocShell())) {
// Need to happen before nsFrameSelection has been set up.
mAccessibleCaretEventHub = new AccessibleCaretEventHub(this);
}
@ -7603,7 +7616,7 @@ PresShell::HandleEvent(nsIFrame* aFrame,
RecordMouseLocation(aEvent);
if (AccessibleCaretEnabled()) {
if (AccessibleCaretEnabled(mDocument->GetDocShell())) {
// We have to target the focus window because regardless of where the
// touch goes, we want to access the copy paste manager.
nsCOMPtr<nsPIDOMWindowOuter> window = GetFocusedDOMWindowInOurWindow();

View File

@ -40,6 +40,7 @@
#include "MobileViewportManager.h"
#include "ZoomConstraintsClient.h"
class nsIDocShell;
class nsRange;
struct RangePaintInfo;
@ -94,7 +95,7 @@ public:
// nsISupports
NS_DECL_ISUPPORTS
static bool AccessibleCaretEnabled();
static bool AccessibleCaretEnabled(nsIDocShell* aDocShell);
// BeforeAfterKeyboardEvent preference
static bool BeforeAfterKeyboardEventEnabled();

View File

@ -5166,6 +5166,16 @@ pref("snav.enabled", false);
// New implementation to unify touch-caret and selection-carets.
pref("layout.accessiblecaret.enabled", false);
// On Nightly, enable the accessible caret on platforms/devices
// that we detect have touch support. Note that this pref is an
// additional way to enable the accessible carets, rather than
// overriding the layout.accessiblecaret.enabled pref.
#ifdef NIGHTLY_BUILD
pref("layout.accessiblecaret.enabled_on_touch", true);
#else
pref("layout.accessiblecaret.enabled_on_touch", false);
#endif
// CSS attributes of the AccessibleCaret in CSS pixels.
pref("layout.accessiblecaret.width", "34.0");
pref("layout.accessiblecaret.height", "36.0");

View File

@ -48,6 +48,7 @@ user_pref("app.update.url.android", "");
// Make sure GMPInstallManager won't hit the network.
user_pref("media.gmp-manager.url.override", "http://%(server)s/dummy-gmp-manager.xml");
user_pref("dom.w3c_touch_events.enabled", 1);
user_pref("layout.accessiblecaret.enabled_on_touch", false);
user_pref("dom.undo_manager.enabled", true);
user_pref("dom.webcomponents.enabled", true);
user_pref("dom.webcomponents.customelements.enabled", true);