Bug 1521309 - Refresh richlistbox.xml from last pre-CE version of 2019-01-04. r=Paenglab

This commit is contained in:
Jorg K 2019-01-19 20:50:41 +01:00
Родитель 4df7e3bce0
Коммит 531aa80287
1 изменённых файлов: 29 добавлений и 55 удалений

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

@ -14,18 +14,9 @@
<binding id="xbl-richlistbox"
extends="chrome://global/content/bindings/general.xml#basecontrol">
<content>
<children includes="listheader"/>
<xul:scrollbox allowevents="true" orient="vertical" anonid="main-box"
flex="1" style="overflow: auto;" xbl:inherits="dir,pack">
<children/>
</xul:scrollbox>
</content>
<content allowevents="true" orient="vertical"/>
<implementation implements="nsIDOMXULMultiSelectControlElement">
<field name="_scrollbox">
document.getAnonymousElementByAttribute(this, "anonid", "main-box");
</field>
<constructor>
<![CDATA[
this._refreshSelection();
@ -65,18 +56,13 @@
</body>
</method>
<!-- We override base-listbox here because those methods don't take dir
into account on listbox (which doesn't support dir yet) -->
<method name="getNextItem">
<parameter name="aStartItem"/>
<parameter name="aDelta"/>
<body>
<![CDATA[
var prop = this.dir == "reverse" && this._mayReverse ?
"previousSibling" :
"nextSibling";
while (aStartItem) {
aStartItem = aStartItem[prop];
aStartItem = aStartItem.nextSibling;
if (aStartItem && aStartItem.localName == "richlistitem" &&
(!this._userSelecting || this._canUserSelect(aStartItem))) {
--aDelta;
@ -94,11 +80,8 @@
<parameter name="aDelta"/>
<body>
<![CDATA[
var prop = this.dir == "reverse" && this._mayReverse ?
"nextSibling" :
"previousSibling";
while (aStartItem) {
aStartItem = aStartItem[prop];
aStartItem = aStartItem.previousSibling;
if (aStartItem && aStartItem.localName == "richlistitem" &&
(!this._userSelecting || this._canUserSelect(aStartItem))) {
--aDelta;
@ -480,21 +463,26 @@
<method name="ensureElementIsVisible">
<parameter name="aElement"/>
<parameter name="aAlignToTop"/>
<body>
<![CDATA[
if (!aElement)
if (!aElement) {
return;
}
// These calculations assume that there is no padding on the
// "richlistbox" element, although there might be a margin.
var targetRect = aElement.getBoundingClientRect();
var scrollRect = this._scrollbox.getBoundingClientRect();
var scrollRect = this.getBoundingClientRect();
var offset = targetRect.top - scrollRect.top;
if (offset >= 0) {
if (!aAlignToTop && offset >= 0) {
// scrollRect.bottom wouldn't take a horizontal scroll bar into account
let scrollRectBottom = scrollRect.top + this._scrollbox.clientHeight;
let scrollRectBottom = scrollRect.top + this.clientHeight;
offset = targetRect.bottom - scrollRectBottom;
if (offset <= 0)
return;
}
this._scrollbox.scrollTop += offset;
this.scrollTop += offset;
]]>
</body>
</method>
@ -504,8 +492,9 @@
<body>
<![CDATA[
var item = this.getItemAtIndex(aIndex);
if (item)
this._scrollbox.scrollToElement(item);
if (item) {
this.ensureElementIsVisible(item, true);
}
]]>
</body>
</method>
@ -550,15 +539,15 @@
// the new current item is at approximately the same position as
// the existing current item.
if (this._isItemVisible(this.currentItem))
this._scrollbox.scrollBy(0, this._scrollbox.boxObject.height * aDirection);
this.scrollBy(0, this.clientHeight * aDirection);
// Figure out, how many items fully fit into the view port
// (including the currently selected one), and determine
// the index of the first one lying (partially) outside
var height = this._scrollbox.boxObject.height;
var height = this.clientHeight;
var startBorder = this.currentItem.boxObject.y;
if (aDirection == -1)
startBorder += this.currentItem.boxObject.height;
startBorder += this.currentItem.clientHeight;
var index = this.currentIndex;
for (var ix = index; 0 <= ix && ix < children.length; ix += aDirection) {
@ -581,9 +570,6 @@
<![CDATA[
let children = Array.from(this.children)
.filter(node => node.localName == "richlistitem");
if (this.dir == "reverse" && this._mayReverse) {
children.reverse();
}
return children;
]]>
</getter>
@ -619,14 +605,12 @@
if (this.selType != "multiple" && this.selectedCount == 0)
this.selectedItem = currentItem;
if (this._scrollbox.boxObject.height) {
if (this.clientHeight) {
this.ensureElementIsVisible(currentItem);
} else {
// XXX hack around a bug in ensureElementIsVisible as it will
// scroll beyond the last element, bug 493645.
var previousElement = this.dir == "reverse" ? currentItem.nextElementSibling :
currentItem.previousElementSibling;
this.ensureElementIsVisible(previousElement);
this.ensureElementIsVisible(currentItem.previousElementSibling);
}
}
this._suppressOnSelect = suppressSelect;
@ -684,11 +668,11 @@
if (!aItem)
return false;
var y = this._scrollbox.scrollTop + this._scrollbox.boxObject.y;
var y = this.scrollTop + this.boxObject.y;
// Partially visible items are also considered visible
return (aItem.boxObject.y + aItem.boxObject.height > y) &&
(aItem.boxObject.y < y + this._scrollbox.boxObject.height);
return (aItem.boxObject.y + aItem.clientHeight > y) &&
(aItem.boxObject.y < y + this.clientHeight);
]]>
</body>
</method>
@ -745,10 +729,8 @@
<![CDATA[
if (!aEvent.defaultPrevented) {
this._userSelecting = true;
this._mayReverse = true;
this.moveByOffset(aOffset, !aEvent.ctrlKey, aEvent.shiftKey);
this._userSelecting = false;
this._mayReverse = false;
aEvent.preventDefault();
}
]]>
@ -760,7 +742,8 @@
<body>
<![CDATA[
var style = document.defaultView.getComputedStyle(aItem);
return style.display != "none" && style.visibility == "visible";
return style.display != "none" && style.visibility == "visible" &&
style.MozUserInput != "none";
]]>
</body>
</method>
@ -801,7 +784,6 @@
<field name="_incrementalString">""</field>
<field name="_suppressOnSelect">false</field>
<field name="_userSelecting">false</field>
<field name="_mayReverse">false</field>
<field name="_selectTimeout">null</field>
<field name="_currentItem">null</field>
<field name="_selectionStart">null</field>
@ -829,36 +811,28 @@
<handler event="keypress" keycode="VK_HOME" modifiers="control shift any"
group="system">
<![CDATA[
this._mayReverse = true;
this._moveByOffsetFromUserEvent(-this.currentIndex, event);
this._mayReverse = false;
]]>
</handler>
<handler event="keypress" keycode="VK_END" modifiers="control shift any"
group="system">
<![CDATA[
this._mayReverse = true;
this._moveByOffsetFromUserEvent(this.getRowCount() - this.currentIndex - 1, event);
this._mayReverse = false;
]]>
</handler>
<handler event="keypress" keycode="VK_PAGE_UP" modifiers="control shift any"
group="system">
<![CDATA[
this._mayReverse = true;
this._moveByOffsetFromUserEvent(this.scrollOnePage(-1), event);
this._mayReverse = false;
]]>
</handler>
<handler event="keypress" keycode="VK_PAGE_DOWN" modifiers="control shift any"
group="system">
<![CDATA[
this._mayReverse = true;
this._moveByOffsetFromUserEvent(this.scrollOnePage(1), event);
this._mayReverse = false;
]]>
</handler>
@ -933,7 +907,7 @@
<handler event="click">
<![CDATA[
// clicking into nothing should unselect
if (event.originalTarget == this._scrollbox) {
if (event.originalTarget == this) {
this.clearSelection();
this.currentItem = null;
}
@ -945,10 +919,10 @@
// Only handle swipe gestures up and down
switch (event.direction) {
case event.DIRECTION_DOWN:
this._scrollbox.scrollTop = this._scrollbox.scrollHeight;
this.scrollTop = this.scrollHeight;
break;
case event.DIRECTION_UP:
this._scrollbox.scrollTop = 0;
this.scrollTop = 0;
break;
}
]]>