зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1182208 - Add support for android scrolling and range accessibility actions. r=mfinkle r=yzen
This commit is contained in:
Родитель
6006fe1ee6
Коммит
3aee5343dc
|
@ -134,6 +134,8 @@ this.AccessFu = { // jshint ignore:line
|
|||
Services.obs.addObserver(this, 'Accessibility:Focus', false);
|
||||
Services.obs.addObserver(this, 'Accessibility:ActivateObject', false);
|
||||
Services.obs.addObserver(this, 'Accessibility:LongPress', false);
|
||||
Services.obs.addObserver(this, 'Accessibility:ScrollForward', false);
|
||||
Services.obs.addObserver(this, 'Accessibility:ScrollBackward', false);
|
||||
Services.obs.addObserver(this, 'Accessibility:MoveByGranularity', false);
|
||||
Utils.win.addEventListener('TabOpen', this);
|
||||
Utils.win.addEventListener('TabClose', this);
|
||||
|
@ -187,6 +189,8 @@ this.AccessFu = { // jshint ignore:line
|
|||
Services.obs.removeObserver(this, 'Accessibility:Focus');
|
||||
Services.obs.removeObserver(this, 'Accessibility:ActivateObject');
|
||||
Services.obs.removeObserver(this, 'Accessibility:LongPress');
|
||||
Services.obs.removeObserver(this, 'Accessibility:ScrollForward');
|
||||
Services.obs.removeObserver(this, 'Accessibility:ScrollBackward');
|
||||
Services.obs.removeObserver(this, 'Accessibility:MoveByGranularity');
|
||||
|
||||
delete this._quicknavModesPref;
|
||||
|
@ -315,6 +319,12 @@ this.AccessFu = { // jshint ignore:line
|
|||
case 'Accessibility:LongPress':
|
||||
this.Input.sendContextMenuMessage();
|
||||
break;
|
||||
case 'Accessibility:ScrollForward':
|
||||
this.Input.androidScroll('forward');
|
||||
break;
|
||||
case 'Accessibility:ScrollBackward':
|
||||
this.Input.androidScroll('backward');
|
||||
break;
|
||||
case 'Accessibility:Focus':
|
||||
this._focused = JSON.parse(aData);
|
||||
if (this._focused) {
|
||||
|
@ -837,6 +847,12 @@ var Input = {
|
|||
adjustRange: aAdjustRange });
|
||||
},
|
||||
|
||||
androidScroll: function androidScroll(aDirection) {
|
||||
let mm = Utils.getMessageManager(Utils.CurrentBrowser);
|
||||
mm.sendAsyncMessage('AccessFu:AndroidScroll',
|
||||
{ direction: aDirection, origin: 'top' });
|
||||
},
|
||||
|
||||
moveByGranularity: function moveByGranularity(aDetails) {
|
||||
const MOVEMENT_GRANULARITY_PARAGRAPH = 8;
|
||||
|
||||
|
|
|
@ -38,7 +38,8 @@ this.ContentControl.prototype = {
|
|||
'AccessFu:AutoMove',
|
||||
'AccessFu:Activate',
|
||||
'AccessFu:MoveCaret',
|
||||
'AccessFu:MoveByGranularity'],
|
||||
'AccessFu:MoveByGranularity',
|
||||
'AccessFu:AndroidScroll'],
|
||||
|
||||
start: function cc_start() {
|
||||
let cs = this._contentScope.get();
|
||||
|
@ -91,6 +92,27 @@ this.ContentControl.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
handleAndroidScroll: function cc_handleAndroidScroll(aMessage) {
|
||||
let vc = this.vc;
|
||||
let position = vc.position;
|
||||
|
||||
if (aMessage.json.origin != 'child' && this.sendToChild(vc, aMessage)) {
|
||||
// Forwarded succesfully to child cursor.
|
||||
return;
|
||||
}
|
||||
|
||||
// Counter-intuitive, but scrolling backward (ie. up), actually should
|
||||
// increase range values.
|
||||
if (this.adjustRange(position, aMessage.json.direction === 'backward')) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._contentScope.get().sendAsyncMessage('AccessFu:DoScroll',
|
||||
{ bounds: Utils.getBounds(position, true),
|
||||
page: aMessage.json.direction === 'forward' ? 1 : -1,
|
||||
horizontal: false });
|
||||
},
|
||||
|
||||
handleMoveCursor: function cc_handleMoveCursor(aMessage) {
|
||||
let origin = aMessage.json.origin;
|
||||
let action = aMessage.json.action;
|
||||
|
|
|
@ -391,6 +391,20 @@ var ContentMessages = {
|
|||
}
|
||||
},
|
||||
|
||||
androidScrollForward: function adjustUp() {
|
||||
return {
|
||||
name: 'AccessFu:AndroidScroll',
|
||||
json: { origin: 'top', direction: 'forward' }
|
||||
};
|
||||
},
|
||||
|
||||
androidScrollBackward: function adjustDown() {
|
||||
return {
|
||||
name: 'AccessFu:AndroidScroll',
|
||||
json: { origin: 'top', direction: 'backward' }
|
||||
};
|
||||
},
|
||||
|
||||
focusSelector: function focusSelector(aSelector, aBlur) {
|
||||
return {
|
||||
name: 'AccessFuTest:Focus',
|
||||
|
|
|
@ -81,6 +81,8 @@
|
|||
[ContentMessages.simpleMovePrevious,
|
||||
new ExpectedCursorChange(['much range', '6', {'string': 'slider'}, 'such app'])],
|
||||
[ContentMessages.moveOrAdjustDown(), new ExpectedValueChange('5')],
|
||||
[ContentMessages.androidScrollForward(), new ExpectedValueChange('6')],
|
||||
[ContentMessages.androidScrollBackward(), new ExpectedValueChange('5')],
|
||||
[ContentMessages.simpleMovePrevious,
|
||||
new ExpectedCursorChange(['much range', {'string': 'label'}])],
|
||||
[ContentMessages.simpleMovePrevious,
|
||||
|
|
|
@ -348,6 +348,8 @@ public class GeckoAccessibility {
|
|||
info.addAction(AccessibilityNodeInfo.ACTION_LONG_CLICK);
|
||||
info.addAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY);
|
||||
info.addAction(AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY);
|
||||
info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
|
||||
info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
|
||||
info.setMovementGranularities(AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER |
|
||||
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_WORD |
|
||||
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH);
|
||||
|
@ -388,6 +390,14 @@ public class GeckoAccessibility {
|
|||
GeckoAppShell.
|
||||
sendEventToGecko(GeckoEvent.createBroadcastEvent("Accessibility:LongPress", null));
|
||||
return true;
|
||||
} else if (action == AccessibilityNodeInfo.ACTION_SCROLL_FORWARD && virtualViewId == VIRTUAL_CURSOR_POSITION) {
|
||||
GeckoAppShell.
|
||||
sendEventToGecko(GeckoEvent.createBroadcastEvent("Accessibility:ScrollForward", null));
|
||||
return true;
|
||||
} else if (action == AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD && virtualViewId == VIRTUAL_CURSOR_POSITION) {
|
||||
GeckoAppShell.
|
||||
sendEventToGecko(GeckoEvent.createBroadcastEvent("Accessibility:ScrollBackward", null));
|
||||
return true;
|
||||
} else if (action == AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY &&
|
||||
virtualViewId == VIRTUAL_CURSOR_POSITION) {
|
||||
// XXX: Self brailling gives this action with a bogus argument instead of an actual click action;
|
||||
|
|
Загрузка…
Ссылка в новой задаче