Files
Mozilla/mozilla/toolkit/content/widgets/scrollbox.xml
sspitzer%mozilla.org 3f433347bf fix for bug #318168: tab browsing improvements such as:
1) when we have "too many" tabs in a window, allow the user to scroll through
the tabs.

2) add events for when adding and removing tabs

initial patch by mconnor. final patch r=mconnor

and includes the supplimental fixes for:

fix for bug #342364: set the clicktoscroll attribute on the pinstripe
specific binding for tabbrowser. Otherwise, the tabs will scroll on mouseover.

fix for bug #343054: js errors when changing certain browser.tabs.* prefs

r=mconnor,ben a=mconnor,schrep


git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@201207 18797224-902f-48f8-a5cc-f745e15eee43
2006-06-29 05:49:32 +00:00

150 lines
5.1 KiB
XML

<?xml version="1.0"?>
<!DOCTYPE bindings [
<!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd">
%globalDTD;
]>
<bindings id="arrowscrollboxBindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="scrollbox-base">
<resources>
<stylesheet src="chrome://global/skin/scrollbox.css"/>
</resources>
</binding>
<binding id="scrollbox" extends="chrome://global/content/bindings/scrollbox.xml#scrollbox-base">
<content>
<xul:box class="box-inherit scrollbox-innerbox" xbl:inherits="orient,align,pack,dir" flex="1">
<children/>
</xul:box>
</content>
</binding>
<binding id="arrowscrollbox" extends="chrome://global/content/bindings/scrollbox.xml#scrollbox-base">
<content>
<xul:autorepeatbutton class="autorepeatbutton-up" collapsed="true" xbl:inherits="orient,clicktoscroll"
onclick="handleOnClick(event, -1);"
oncommand="handleOnCommand(event, -1);"/>
<xul:scrollbox xbl:inherits="orient,align,pack,dir" flex="1">
<children/>
</xul:scrollbox>
<xul:autorepeatbutton class="autorepeatbutton-down" collapsed="true" xbl:inherits="orient,clicktoscroll"
onclick="handleOnClick(event, 1);"
oncommand="handleOnCommand(event, 1);"/>
</content>
<implementation>
<field name="_scrollIncrement">0</field>
<property name="scrollIncrement" readonly="true">
<getter><![CDATA[
if (!this._scrollIncrement) {
var pb2 =
Components.classes['@mozilla.org/preferences-service;1'].
getService(Components.interfaces.nsIPrefBranch2);
try {
this._scrollIncrement = pb2.getIntPref("toolkit.scrollbox.scrollIncrement");
}
catch (ex) {
this._scrollIncrement = 20;
}
}
return this._scrollIncrement;
]]></getter>
</property>
<field name="_scrollBoxObject">null</field>
<property name="scrollBoxObject" readonly="true">
<getter><![CDATA[
if (!this._scrollBoxObject) {
var kids = document.getAnonymousNodes(this);
this._scrollBoxObject = kids[1].boxObject.QueryInterface(Components.interfaces.nsIScrollBoxObject);
}
return this._scrollBoxObject;
]]></getter>
</property>
<method name="ensureElementIsVisible">
<parameter name="aElement"/>
<body><![CDATA[
this.scrollBoxObject.ensureElementIsVisible(aElement);
]]></body>
</method>
<method name="handleOnCommand">
<parameter name="aEvent"/>
<parameter name="aMultiple"/>
<body><![CDATA[
// don't scroll on mouseover if clicktoscroll="true"
if (this.getAttribute("clicktoscroll") != "true") {
var px = this.scrollIncrement * aMultiple;
this.scrollByPixels(px);
aEvent.stopPropagation();
}
]]></body>
</method>
<method name="handleOnClick">
<parameter name="aEvent"/>
<parameter name="aMultiple"/>
<body><![CDATA[
// only scroll by index on click if clicktoscroll="true"
if (this.getAttribute("clicktoscroll") == "true") {
this.scrollByIndex(aMultiple);
aEvent.stopPropagation();
}
]]></body>
</method>
<method name="scrollByIndex">
<parameter name="lines"/>
<body><![CDATA[
this.scrollBoxObject.scrollByIndex(lines);
]]></body>
</method>
<method name="scrollByPixels">
<parameter name="px"/>
<body><![CDATA[
if (this.getAttribute("orient") == "horizontal") {
// if not ltr, we want to scroll the other direction
var actualPx = window.getComputedStyle(this.parentNode, "")
.direction == "ltr" ? px : (-1 * px);
this.scrollBoxObject.scrollBy(actualPx, 0);
}
else
this.scrollBoxObject.scrollBy(0, px);
]]></body>
</method>
</implementation>
<handlers>
<handler event="DOMMouseScroll" action="this.scrollByIndex(event.detail); event.stopPropagation();"/>
<handler event="underflow"><![CDATA[
var kids = document.getAnonymousNodes(this);
kids[0].collapsed = true;
kids[2].collapsed = true;
event.stopPropagation();
]]></handler>
<handler event="overflow"><![CDATA[
var kids = document.getAnonymousNodes(this);
kids[0].collapsed = false;
kids[2].collapsed = false;
event.stopPropagation();
]]></handler>
</handlers>
</binding>
<binding id="autorepeatbutton" extends="chrome://global/content/bindings/scrollbox.xml#scrollbox-base">
<content chromedir="&locale.dir;">
<xul:image class="autorepeatbutton-icon"/>
</content>
</binding>
</bindings>