Bug 988143 - Enable Gecko Touch in Fennec, Enable all in Mobile, r=margaret

This commit is contained in:
Mark Capella 2015-05-14 22:06:13 -04:00
Родитель b15dcbbc97
Коммит 33bcf62e76
4 изменённых файлов: 65 добавлений и 0 удалений

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

@ -8,6 +8,10 @@
const PHONE_NUMBER_CONTAINERS = "td,div";
const DEFER_CLOSE_TRIGGER_MS = 125; // Grace period delay before deferred _closeSelection()
// Gecko TouchCaret/SelectionCaret pref names.
const PREF_GECKO_TOUCHCARET_ENABLED = "touchcaret.enabled";
const PREF_GECKO_SELECTIONCARETS_ENABLED = "selectioncaret.enabled";
var SelectionHandler = {
// Successful startSelection() or attachCaret().
@ -21,9 +25,11 @@ var SelectionHandler = {
START_ERROR_SELECT_ALL_PARAGRAPH_FAILED: "Select-All Paragraph failed.",
START_ERROR_NO_SELECTION: "Selection performed, but nothing resulted.",
START_ERROR_PROXIMITY: "Selection target and result seem unrelated.",
START_ERROR_SELECTIONCARETS_ENABLED: "Native selectionCarets requested while Gecko enabled.",
// Error codes returned during attachCaret().
ATTACH_ERROR_INCOMPATIBLE: "Element disabled, handled natively, or not editable.",
ATTACH_ERROR_TOUCHCARET_ENABLED: "Native touchCaret requested while Gecko enabled.",
HANDLE_TYPE_ANCHOR: "ANCHOR",
HANDLE_TYPE_CARET: "CARET",
@ -36,6 +42,10 @@ var SelectionHandler = {
SELECT_ALL: 0,
SELECT_AT_POINT: 1,
// Gecko TouchCaret/SelectionCaret pref values.
_touchCaretEnabledValue: null,
_selectionCaretEnabledValue: null,
// Keeps track of data about the dimensions of the selection. Coordinates
// stored here are relative to the _contentWindow window.
_cache: { anchorPt: {}, focusPt: {} },
@ -91,6 +101,30 @@ var SelectionHandler = {
getService(Ci.nsIUUIDGenerator);
},
// Are we supporting Gecko or Native touchCarets?
get _touchCaretEnabled() {
if (this._touchCaretEnabledValue == null) {
this._touchCaretEnabledValue = Services.prefs.getBoolPref(PREF_GECKO_TOUCHCARET_ENABLED);
Services.prefs.addObserver(PREF_GECKO_TOUCHCARET_ENABLED, function() {
SelectionHandler._touchCaretEnabledValue =
Services.prefs.getBoolPref(PREF_GECKO_TOUCHCARET_ENABLED);
}, false);
}
return this._touchCaretEnabledValue;
},
// Are we supporting Gecko or Native selectionCarets?
get _selectionCaretEnabled() {
if (this._selectionCaretEnabledValue == null) {
this._selectionCaretEnabledValue = Services.prefs.getBoolPref(PREF_GECKO_SELECTIONCARETS_ENABLED);
Services.prefs.addObserver(PREF_GECKO_SELECTIONCARETS_ENABLED, function() {
SelectionHandler._selectionCaretEnabledValue =
Services.prefs.getBoolPref(PREF_GECKO_SELECTIONCARETS_ENABLED);
}, false);
}
return this._selectionCaretEnabledValue;
},
_addObservers: function sh_addObservers() {
Services.obs.addObserver(this, "Gesture:SingleTap", false);
Services.obs.addObserver(this, "Tab:Selected", false);
@ -378,6 +412,11 @@ var SelectionHandler = {
* y - The y-coordinate for SELECT_AT_POINT.
*/
startSelection: function sh_startSelection(aElement, aOptions = { mode: SelectionHandler.SELECT_ALL }) {
// Disable Native touchCarets if Gecko enabled.
if (this._selectionCaretEnabled) {
return this.START_ERROR_SELECTIONCARETS_ENABLED;
}
// Clear out any existing active selection
this._closeSelection();
@ -837,6 +876,11 @@ var SelectionHandler = {
* @param aX, aY tap location in client coordinates.
*/
attachCaret: function sh_attachCaret(aElement) {
// Disable Native attachCaret() if Gecko touchCarets are enabled.
if (this._touchCaretEnabled) {
return this.ATTACH_ERROR_TOUCHCARET_ENABLED;
}
// Clear out any existing active selection
this._closeSelection();

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

@ -154,6 +154,12 @@ let lazilyLoadedObserverScripts = [
["EmbedRT", ["GeckoView:ImportScript"], "chrome://browser/content/EmbedRT.js"],
["Reader", ["Reader:FetchContent", "Reader:Added", "Reader:Removed"], "chrome://browser/content/Reader.js"],
];
if (AppConstants.NIGHTLY_BUILD) {
lazilyLoadedObserverScripts.push(
["ActionBarHandler", ["ActionBar:OpenNew", "ActionBar:Close", "TextSelection:Get"],
"chrome://browser/content/ActionBarHandler.js"]
);
}
if (AppConstants.MOZ_WEBRTC) {
lazilyLoadedObserverScripts.push(
["WebrtcUI", ["getUserMedia:request", "recording-device-events"], "chrome://browser/content/WebrtcUI.js"])

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

@ -35,6 +35,7 @@ chrome.jar:
content/netError.xhtml (content/netError.xhtml)
content/SelectHelper.js (content/SelectHelper.js)
content/SelectionHandler.js (content/SelectionHandler.js)
content/ActionBarHandler.js (content/ActionBarHandler.js)
content/WebappRT.js (content/WebappRT.js)
content/EmbedRT.js (content/EmbedRT.js)
content/InputWidgetHelper.js (content/InputWidgetHelper.js)

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

@ -546,6 +546,20 @@
@BINPATH@/res/html/*
@BINPATH@/res/language.properties
@BINPATH@/res/entityTables/*
#ifdef NIGHTLY_BUILD
@BINPATH@/res/text_caret.png
@BINPATH@/res/text_caret@1.5x.png
@BINPATH@/res/text_caret@2.25x.png
@BINPATH@/res/text_caret@2x.png
@BINPATH@/res/text_caret_tilt_left.png
@BINPATH@/res/text_caret_tilt_left@1.5x.png
@BINPATH@/res/text_caret_tilt_left@2.25x.png
@BINPATH@/res/text_caret_tilt_left@2x.png
@BINPATH@/res/text_caret_tilt_right.png
@BINPATH@/res/text_caret_tilt_right@1.5x.png
@BINPATH@/res/text_caret_tilt_right@2.25x.png
@BINPATH@/res/text_caret_tilt_right@2x.png
#endif
#ifndef MOZ_ANDROID_EXCLUDE_FONTS
@BINPATH@/res/fonts/*