author | Mark Capella <markcapella@twcny.rr.com> |
Thu, 14 May 2015 22:06:13 -0400 | |
changeset 244028 | 1be077af56e34552a462e30ca7ce1b56ab21f786 |
parent 244027 | a0eeba30549dcdffe897cb9a711863bfc45a5a6b |
child 244029 | 101feffdaed800475440429baace98a1be17a27a |
push id | 59820 |
push user | cbook@mozilla.com |
push date | Fri, 15 May 2015 15:41:47 +0000 |
treeherder | mozilla-inbound@5943d32f3515 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | margaret |
bugs | 988143 |
milestone | 41.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/mobile/android/chrome/content/SelectionHandler.js +++ b/mobile/android/chrome/content/SelectionHandler.js @@ -3,44 +3,54 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; // Define elements that bound phone number containers. 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(). ERROR_NONE: "", // Error codes returned during startSelection(). START_ERROR_INVALID_MODE: "Invalid selection mode requested.", START_ERROR_NONTEXT_INPUT: "Target element by definition contains no text.", START_ERROR_NO_WORD_SELECTED: "No word selected at point.", START_ERROR_SELECT_WORD_FAILED: "Word selection at point failed.", 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", HANDLE_TYPE_FOCUS: "FOCUS", TYPE_NONE: 0, TYPE_CURSOR: 1, TYPE_SELECTION: 2, 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: {} }, _targetIsRTL: false, _anchorIsRTL: false, _focusIsRTL: false, _activeType: 0, // TYPE_NONE @@ -86,16 +96,40 @@ var SelectionHandler = { // Provides UUID service for selection ID's. get _idService() { delete this._idService; return this._idService = Cc["@mozilla.org/uuid-generator;1"]. 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); Services.obs.addObserver(this, "TextSelection:Move", false); Services.obs.addObserver(this, "TextSelection:Position", false); Services.obs.addObserver(this, "TextSelection:End", false); Services.obs.addObserver(this, "TextSelection:Action", false); Services.obs.addObserver(this, "TextSelection:LayerReflow", false); @@ -373,16 +407,21 @@ var SelectionHandler = { * @param aOptions list of options describing how to start selection * Options include: * mode - SELECT_ALL to select everything in the target * element, or SELECT_AT_POINT to select a word. * x - The x-coordinate for SELECT_AT_POINT. * 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(); if (this._isNonTextInputElement(aElement)) { return this.START_ERROR_NONTEXT_INPUT; } const focus = Services.focus.focusedWindow; @@ -832,16 +871,21 @@ var SelectionHandler = { /* * Called by BrowserEventHandler when the user taps in a form input. * Initializes SelectionHandler and positions the caret handle. * * @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(); // Ensure it isn't disabled, isn't handled by Android native dialog, and is editable text element if (aElement.disabled || InputWidgetHelper.hasInputWidget(aElement) || !this.isElementEditableText(aElement)) { return this.ATTACH_ERROR_INCOMPATIBLE; }
--- a/mobile/android/chrome/content/browser.js +++ b/mobile/android/chrome/content/browser.js @@ -149,16 +149,22 @@ let lazilyLoadedObserverScripts = [ ["FindHelper", ["FindInPage:Opened", "FindInPage:Closed", "Tab:Selected"], "chrome://browser/content/FindHelper.js"], ["PermissionsHelper", ["Permissions:Get", "Permissions:Clear"], "chrome://browser/content/PermissionsHelper.js"], ["FeedHandler", ["Feeds:Subscribe"], "chrome://browser/content/FeedHandler.js"], ["Feedback", ["Feedback:Show"], "chrome://browser/content/Feedback.js"], ["SelectionHandler", ["TextSelection:Get"], "chrome://browser/content/SelectionHandler.js"], ["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"]) } lazilyLoadedObserverScripts.forEach(function (aScript) { let [name, notifications, script] = aScript; XPCOMUtils.defineLazyGetter(window, name, function() {
--- a/mobile/android/chrome/jar.mn +++ b/mobile/android/chrome/jar.mn @@ -30,16 +30,17 @@ chrome.jar: content/languages.properties (content/languages.properties) content/browser.xul (content/browser.xul) content/browser.js (content/browser.js) content/bindings/checkbox.xml (content/bindings/checkbox.xml) content/bindings/settings.xml (content/bindings/settings.xml) 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) content/WebrtcUI.js (content/WebrtcUI.js) content/MemoryObserver.js (content/MemoryObserver.js) content/ConsoleAPI.js (content/ConsoleAPI.js) content/PluginHelper.js (content/PluginHelper.js) content/OfflineApps.js (content/OfflineApps.js)
--- a/mobile/android/installer/package-manifest.in +++ b/mobile/android/installer/package-manifest.in @@ -541,16 +541,30 @@ @BINPATH@/res/table-remove-row-active.gif @BINPATH@/res/table-remove-row-hover.gif @BINPATH@/res/table-remove-row.gif @BINPATH@/res/grabber.gif @BINPATH@/res/dtd/* @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/* #endif ; svg @BINPATH@/res/svg.css @BINPATH@/components/dom_svg.xpt