Bug 942749 - [keyboard] Fix forms.js contenteditable scroll position. r=fabrice

This commit is contained in:
Kevin Grandon 2013-12-13 16:10:56 -05:00
Родитель c064900de4
Коммит 6b31866e22
1 изменённых файлов: 18 добавлений и 1 удалений

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

@ -415,7 +415,7 @@ let FormAssistant = {
this.scrollIntoViewTimeout = content.setTimeout(function () {
this.scrollIntoViewTimeout = null;
if (this.focusedElement && !FormVisibility.isVisible(this.focusedElement)) {
this.focusedElement.scrollIntoView(false);
scrollSelectionOrElementIntoView(this.focusedElement);
}
}.bind(this), RESIZE_SCROLL_DELAY);
}
@ -1017,6 +1017,23 @@ function setSelectionRange(element, start, end) {
}
}
/**
* Scroll the given element into view.
*
* Calls scrollSelectionIntoView for contentEditable elements.
*/
function scrollSelectionOrElementIntoView(element) {
let editor = getPlaintextEditor(element);
if (editor) {
editor.selectionController.scrollSelectionIntoView(
Ci.nsISelectionController.SELECTION_NORMAL,
Ci.nsISelectionController.SELECTION_FOCUS_REGION,
Ci.nsISelectionController.SCROLL_SYNCHRONOUS);
} else {
element.scrollIntoView(false);
}
}
// Get nsIPlaintextEditor object from an input field
function getPlaintextEditor(element) {
let editor = null;