Bug 1304178 - Use a different node to scroll in old and new frontends;r=linclark

MozReview-Commit-ID: CirqjyCei5n
This commit is contained in:
Brian Grinstead 2016-10-06 17:10:00 -07:00
Родитель adc8bcbcca
Коммит b1e8e49e8b
4 изменённых файлов: 23 добавлений и 19 удалений

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

@ -1186,10 +1186,10 @@ JSTerm.prototype = {
this._autocompletePopupNavigated = true;
}
} else {
this.hud.outputWrapper.scrollTop =
this.hud.outputScroller.scrollTop =
Math.max(0,
this.hud.outputWrapper.scrollTop -
this.hud.outputWrapper.clientHeight
this.hud.outputScroller.scrollTop -
this.hud.outputScroller.clientHeight
);
}
event.preventDefault();
@ -1202,10 +1202,10 @@ JSTerm.prototype = {
this._autocompletePopupNavigated = true;
}
} else {
this.hud.outputWrapper.scrollTop =
Math.min(this.hud.outputWrapper.scrollHeight,
this.hud.outputWrapper.scrollTop +
this.hud.outputWrapper.clientHeight
this.hud.outputScroller.scrollTop =
Math.min(this.hud.outputScroller.scrollHeight,
this.hud.outputScroller.scrollTop +
this.hud.outputScroller.clientHeight
);
}
event.preventDefault();
@ -1216,7 +1216,7 @@ JSTerm.prototype = {
this.autocompletePopup.selectedIndex = 0;
event.preventDefault();
} else if (inputValue.length <= 0) {
this.hud.outputWrapper.scrollTop = 0;
this.hud.outputScroller.scrollTop = 0;
event.preventDefault();
}
break;
@ -1227,8 +1227,8 @@ JSTerm.prototype = {
this.autocompletePopup.itemCount - 1;
event.preventDefault();
} else if (inputValue.length <= 0) {
this.hud.outputWrapper.scrollTop =
this.hud.outputWrapper.scrollHeight;
this.hud.outputScroller.scrollTop =
this.hud.outputScroller.scrollHeight;
event.preventDefault();
}
break;

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

@ -31,7 +31,7 @@ const ConsoleOutput = createClass({
componentDidMount() {
scrollToBottom(this.outputNode);
this.props.serviceContainer.attachRefToHud("outputWrapper", this.outputNode);
this.props.serviceContainer.attachRefToHud("outputScroller", this.outputNode);
},
componentWillUpdate(nextProps, nextState) {

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

@ -20,33 +20,33 @@ add_task(function* () {
let hud = yield openNewTabAndConsole(TEST_URI);
info("Web Console opened");
const outputWrapper = hud.ui.outputWrapper;
const outputScroller = hud.ui.outputScroller;
yield waitFor(() => findMessages(hud, "").length == 100);
let currentPosition = outputWrapper.scrollTop;
let currentPosition = outputScroller.scrollTop;
const bottom = currentPosition;
EventUtils.sendMouseEvent({type: "click"}, hud.jsterm.inputNode);
// Page up.
EventUtils.synthesizeKey("VK_PAGE_UP", {});
isnot(outputWrapper.scrollTop, currentPosition,
isnot(outputScroller.scrollTop, currentPosition,
"scroll position changed after page up");
// Page down.
currentPosition = outputWrapper.scrollTop;
currentPosition = outputScroller.scrollTop;
EventUtils.synthesizeKey("VK_PAGE_DOWN", {});
ok(outputWrapper.scrollTop > currentPosition,
ok(outputScroller.scrollTop > currentPosition,
"scroll position now at bottom");
// Home
EventUtils.synthesizeKey("VK_HOME", {});
is(outputWrapper.scrollTop, 0, "scroll position now at top");
is(outputScroller.scrollTop, 0, "scroll position now at top");
// End
EventUtils.synthesizeKey("VK_END", {});
let scrollTop = outputWrapper.scrollTop;
let scrollTop = outputScroller.scrollTop;
ok(scrollTop > 0 && Math.abs(scrollTop - bottom) <= 5,
"scroll position now at bottom");
@ -66,6 +66,6 @@ add_task(function* () {
info("try ctrl-f to focus filter");
synthesizeKeyShortcut(WCUL10n.getStr("webconsole.find.key"));
ok(!hud.jsterm.inputNode.getAttribute("focused"), "jsterm input is not focused");
is(hud.ui.filterBox, outputWrapper.ownerDocument.activeElement,
is(hud.ui.filterBox, outputScroller.ownerDocument.activeElement,
"filter input is focused");
});

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

@ -547,6 +547,10 @@ WebConsoleFrame.prototype = {
this.completeNode = this.document.querySelector(".jsterm-complete-node");
this.inputNode = this.document.querySelector(".jsterm-input-node");
// In the old frontend, the area that scrolls is outputWrapper, but in the new
// frontend this will be reassigned.
this.outputScroller = this.outputWrapper;
// Update the character width and height needed for the popup offset
// calculations.
this._updateCharSize();