mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 1182214 - Update highlight rect as you scroll. r=yzen
This commit is contained in:
parent
95147a7039
commit
bfdf59d692
@ -108,8 +108,9 @@ Presenter.prototype = {
|
||||
* The viewport has changed, either a scroll, pan, zoom, or
|
||||
* landscape/portrait toggle.
|
||||
* @param {Window} aWindow window of viewport that changed.
|
||||
* @param {PivotContext} aCurrentContext context of last pivot change.
|
||||
*/
|
||||
viewportChanged: function viewportChanged(aWindow) {}, // jshint ignore:line
|
||||
viewportChanged: function viewportChanged(aWindow, aCurrentContext) {}, // jshint ignore:line
|
||||
|
||||
/**
|
||||
* We have entered or left text editing mode.
|
||||
@ -142,9 +143,7 @@ Presenter.prototype = {
|
||||
/**
|
||||
* Visual presenter. Draws a box around the virtual cursor's position.
|
||||
*/
|
||||
function VisualPresenter() {
|
||||
this._displayedAccessibles = new WeakMap();
|
||||
}
|
||||
function VisualPresenter() {}
|
||||
|
||||
VisualPresenter.prototype = Object.create(Presenter.prototype);
|
||||
|
||||
@ -156,15 +155,14 @@ VisualPresenter.prototype.type = 'Visual';
|
||||
VisualPresenter.prototype.BORDER_PADDING = 2;
|
||||
|
||||
VisualPresenter.prototype.viewportChanged =
|
||||
function VisualPresenter_viewportChanged(aWindow) {
|
||||
let currentDisplay = this._displayedAccessibles.get(aWindow);
|
||||
if (!currentDisplay) {
|
||||
function VisualPresenter_viewportChanged(aWindow, aCurrentContext) {
|
||||
if (!aCurrentContext) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let currentAcc = currentDisplay.accessible;
|
||||
let start = currentDisplay.startOffset;
|
||||
let end = currentDisplay.endOffset;
|
||||
let currentAcc = aCurrentContext.accessibleForBounds;
|
||||
let start = aCurrentContext.startOffset;
|
||||
let end = aCurrentContext.endOffset;
|
||||
if (Utils.isAliveAndVisible(currentAcc)) {
|
||||
let bounds = (start === -1 && end === -1) ? Utils.getBounds(currentAcc) :
|
||||
Utils.getTextBounds(currentAcc, start, end);
|
||||
@ -189,11 +187,6 @@ VisualPresenter.prototype.pivotChanged =
|
||||
return null;
|
||||
}
|
||||
|
||||
this._displayedAccessibles.set(aContext.accessible.document.window,
|
||||
{ accessible: aContext.accessibleForBounds,
|
||||
startOffset: aContext.startOffset,
|
||||
endOffset: aContext.endOffset });
|
||||
|
||||
try {
|
||||
aContext.accessibleForBounds.scrollTo(
|
||||
Ci.nsIAccessibleScrollType.SCROLL_TYPE_ANYWHERE);
|
||||
@ -413,21 +406,33 @@ AndroidPresenter.prototype.textSelectionChanged =
|
||||
};
|
||||
|
||||
AndroidPresenter.prototype.viewportChanged =
|
||||
function AndroidPresenter_viewportChanged(aWindow) {
|
||||
function AndroidPresenter_viewportChanged(aWindow, aCurrentContext) {
|
||||
if (Utils.AndroidSdkVersion < 14) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let events = [{
|
||||
eventType: this.ANDROID_VIEW_SCROLLED,
|
||||
text: [],
|
||||
scrollX: aWindow.scrollX,
|
||||
scrollY: aWindow.scrollY,
|
||||
maxScrollX: aWindow.scrollMaxX,
|
||||
maxScrollY: aWindow.scrollMaxY
|
||||
}];
|
||||
|
||||
if (Utils.AndroidSdkVersion >= 16 && aCurrentContext) {
|
||||
let currentAcc = aCurrentContext.accessibleForBounds;
|
||||
if (Utils.isAliveAndVisible(currentAcc)) {
|
||||
events.push({
|
||||
eventType: this.ANDROID_VIEW_ACCESSIBILITY_FOCUSED,
|
||||
bounds: Utils.getBounds(currentAcc)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
type: this.type,
|
||||
details: [{
|
||||
eventType: this.ANDROID_VIEW_SCROLLED,
|
||||
text: [],
|
||||
scrollX: aWindow.scrollX,
|
||||
scrollY: aWindow.scrollY,
|
||||
maxScrollX: aWindow.scrollMaxX,
|
||||
maxScrollY: aWindow.scrollMaxY
|
||||
}]
|
||||
details: events
|
||||
};
|
||||
};
|
||||
|
||||
@ -683,10 +688,17 @@ this.Presentation = { // jshint ignore:line
|
||||
return this.presenters;
|
||||
},
|
||||
|
||||
get displayedAccessibles() {
|
||||
delete this.displayedAccessibles;
|
||||
this.displayedAccessibles = new WeakMap();
|
||||
},
|
||||
|
||||
pivotChanged: function Presentation_pivotChanged(
|
||||
aPosition, aOldPosition, aReason, aStartOffset, aEndOffset, aIsUserInput) {
|
||||
let context = new PivotContext(
|
||||
aPosition, aOldPosition, aStartOffset, aEndOffset);
|
||||
this.displayedAccessibles.set(context.accessible.document.window, context);
|
||||
|
||||
return [p.pivotChanged(context, aReason, aIsUserInput)
|
||||
for each (p in this.presenters)]; // jshint ignore:line
|
||||
},
|
||||
@ -724,7 +736,9 @@ this.Presentation = { // jshint ignore:line
|
||||
},
|
||||
|
||||
viewportChanged: function Presentation_viewportChanged(aWindow) {
|
||||
return [p.viewportChanged(aWindow) for each (p in this.presenters)]; // jshint ignore:line
|
||||
let context = this.displayedAccessibles.get(aWindow);
|
||||
return [p.viewportChanged(aWindow, context) // jshint ignore:line
|
||||
for each (p in this.presenters)]; // jshint ignore:line
|
||||
},
|
||||
|
||||
editingModeChanged: function Presentation_editingModeChanged(aIsEditing) {
|
||||
|
Loading…
Reference in New Issue
Block a user