зеркало из https://github.com/mozilla/gecko-dev.git
Bug 942749 - [keyboard] Fix forms.js contenteditable scroll position. r=fabrice
This commit is contained in:
Родитель
c064900de4
Коммит
6b31866e22
|
@ -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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче