зеркало из https://github.com/mozilla/gecko-dev.git
use mac smart-scrolling prefs in XUL scrollbars. This is my first use of my mac other hosting scc's porn. r=pinkerton,a=ben.
This commit is contained in:
Родитель
83a8928dcd
Коммит
083af4b37a
|
@ -42,6 +42,8 @@ interface nsIBoxObject : nsISupports
|
|||
wstring getProperty(in wstring propertyName);
|
||||
void setProperty(in wstring propertyName, in wstring propertyValue);
|
||||
void removeProperty(in wstring propertyName);
|
||||
|
||||
wstring getLookAndFeelMetric(in wstring propertyName);
|
||||
};
|
||||
|
||||
%{C++
|
||||
|
|
|
@ -33,9 +33,13 @@
|
|||
#include "nsIStyleContext.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsILookAndFeel.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
|
||||
// Static IIDs/CIDs. Try to minimize these.
|
||||
// None so far.
|
||||
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
||||
|
||||
// Implementation /////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -265,6 +269,44 @@ nsBoxObject::GetHeight(PRInt32* aResult)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBoxObject::GetLookAndFeelMetric(const PRUnichar* aPropertyName,
|
||||
PRUnichar** aResult)
|
||||
{
|
||||
nsCOMPtr<nsILookAndFeel> lookAndFeel(do_GetService(kLookAndFeelCID));
|
||||
if (!lookAndFeel)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsAutoString property(aPropertyName);
|
||||
if (property.EqualsIgnoreCase("scrollbarStyle")) {
|
||||
PRInt32 metricResult;
|
||||
lookAndFeel->GetMetric(nsILookAndFeel::eMetric_ScrollArrowStyle, metricResult);
|
||||
switch (metricResult) {
|
||||
case nsILookAndFeel::eMetric_ScrollArrowStyleBothAtBottom:
|
||||
*aResult = nsXPIDLString::Copy(NS_LITERAL_STRING("doublebottom"));
|
||||
break;
|
||||
case nsILookAndFeel::eMetric_ScrollArrowStyleBothAtEachEnd:
|
||||
*aResult = nsXPIDLString::Copy(NS_LITERAL_STRING("double"));
|
||||
break;
|
||||
case nsILookAndFeel::eMetric_ScrollArrowStyleBothAtTop:
|
||||
*aResult = nsXPIDLString::Copy(NS_LITERAL_STRING("doubletop"));
|
||||
break;
|
||||
default:
|
||||
*aResult = nsXPIDLString::Copy(NS_LITERAL_STRING("single"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (property.EqualsIgnoreCase("thumbStyle")) {
|
||||
PRInt32 metricResult;
|
||||
lookAndFeel->GetMetric(nsILookAndFeel::eMetric_ScrollSliderStyle, metricResult);
|
||||
if ( metricResult == nsILookAndFeel::eMetric_ScrollThumbStyleNormal )
|
||||
*aResult = nsXPIDLString::Copy(NS_LITERAL_STRING("fixed"));
|
||||
else
|
||||
*aResult = nsXPIDLString::Copy(NS_LITERAL_STRING("proportional"));
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBoxObject::GetPropertyAsSupports(const PRUnichar* aPropertyName, nsISupports** aResult)
|
||||
{
|
||||
|
|
|
@ -78,17 +78,23 @@
|
|||
</content>
|
||||
</binding>
|
||||
|
||||
<binding id="scrollbar">
|
||||
<binding id="scrollbar" extends="chrome://global/content/scrollbarBindings.xml#scrollbar">
|
||||
<content>
|
||||
<xul:scrollbarbutton type="decrement" inherits="sborient=align">
|
||||
<xul:image inherits="src"/>
|
||||
</xul:scrollbarbutton>
|
||||
<xul:scrollbarbutton sbattr="scrollbar-up-top" type="decrement" inherits="sborient=align">
|
||||
<xul:image inherits="src"/>
|
||||
</xul:scrollbarbutton>
|
||||
<xul:scrollbarbutton sbattr="scrollbar-down-top" type="increment" collapsed="true" inherits="sborient=align">
|
||||
<xul:image inherits="src"/>
|
||||
</xul:scrollbarbutton>
|
||||
<xul:slider flex="1" inherits="curpos,maxpos,pageincrement,increment,align">
|
||||
<xul:thumb inherits="align,src" flex="1"/>
|
||||
<xul:thumb sbattr="scrollbar-thumb" inherits="align,src" flex="1"/>
|
||||
</xul:slider>
|
||||
<xul:scrollbarbutton type="increment" inherits="sborient=align">
|
||||
<xul:image inherits="src"/>
|
||||
</xul:scrollbarbutton>
|
||||
<xul:scrollbarbutton sbattr="scrollbar-up-bottom" type="decrement" collapsed="true" inherits="sborient=align">
|
||||
<xul:image inherits="src"/>
|
||||
</xul:scrollbarbutton>
|
||||
<xul:scrollbarbutton sbattr="scrollbar-down-bottom" type="increment" inherits="sborient=align">
|
||||
<xul:image inherits="src"/>
|
||||
</xul:scrollbarbutton>
|
||||
</content>
|
||||
</binding>
|
||||
|
||||
|
|
|
@ -173,17 +173,23 @@
|
|||
</content>
|
||||
</binding>
|
||||
|
||||
<binding id="scrollbar">
|
||||
<binding id="scrollbar" extends="chrome://global/content/scrollbarBindings.xml#scrollbar">
|
||||
<content>
|
||||
<xul:scrollbarbutton type="decrement" inherits="sborient=align">
|
||||
<xul:image inherits="src"/>
|
||||
</xul:scrollbarbutton>
|
||||
<xul:scrollbarbutton sbattr="scrollbar-up-top" type="decrement" inherits="sborient=align">
|
||||
<xul:image inherits="src"/>
|
||||
</xul:scrollbarbutton>
|
||||
<xul:scrollbarbutton sbattr="scrollbar-down-top" type="increment" collapsed="true" inherits="sborient=align">
|
||||
<xul:image inherits="src"/>
|
||||
</xul:scrollbarbutton>
|
||||
<xul:slider flex="1" inherits="curpos,maxpos,pageincrement,increment,align">
|
||||
<xul:thumb inherits="align,src" flex="1"/>
|
||||
<xul:thumb sbattr="scrollbar-thumb" inherits="align,src" flex="1"/>
|
||||
</xul:slider>
|
||||
<xul:scrollbarbutton type="increment" inherits="sborient=align">
|
||||
<xul:image inherits="src"/>
|
||||
</xul:scrollbarbutton>
|
||||
<xul:scrollbarbutton sbattr="scrollbar-up-bottom" type="decrement" collapsed="true" inherits="sborient=align">
|
||||
<xul:image inherits="src"/>
|
||||
</xul:scrollbarbutton>
|
||||
<xul:scrollbarbutton sbattr="scrollbar-down-bottom" type="increment" inherits="sborient=align">
|
||||
<xul:image inherits="src"/>
|
||||
</xul:scrollbarbutton>
|
||||
</content>
|
||||
</binding>
|
||||
|
||||
|
|
|
@ -5,26 +5,67 @@
|
|||
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<binding id="thumb" extends="xul:box">
|
||||
<content>
|
||||
<xul:spring flex="1"/>
|
||||
<xul:image inherits="src"/>
|
||||
<xul:spring flex="1"/>
|
||||
</content>
|
||||
</binding>
|
||||
|
||||
<binding id="scrollbar">
|
||||
<content>
|
||||
<xul:scrollbarbutton type="decrement">
|
||||
<xul:image inherits="src"/>
|
||||
</xul:scrollbarbutton>
|
||||
<xul:slider flex="1" inherits="curpos,maxpos,pageincrement,increment">
|
||||
<xul:thumb inherits="align,src" flex="1"/>
|
||||
</xul:slider>
|
||||
<xul:scrollbarbutton type="increment">
|
||||
<xul:image inherits="src"/>
|
||||
</xul:scrollbarbutton>
|
||||
</content>
|
||||
<implementation>
|
||||
<method name="initScrollbar">
|
||||
<body>
|
||||
<![CDATA[
|
||||
try {
|
||||
var scrollbarStyle = this.boxObject.getLookAndFeelMetric("scrollbarStyle");
|
||||
var thumbStyle = this.boxObject.getLookAndFeelMetric("thumbStyle");
|
||||
if ( scrollbarStyle == "double" ) {
|
||||
var downTop = this.findNodeByAttribute("sbattr", "scrollbar-down-top");
|
||||
var upBottom = this.findNodeByAttribute("sbattr", "scrollbar-up-bottom");
|
||||
downTop.removeAttribute("collapsed");
|
||||
upBottom.removeAttribute("collapsed");
|
||||
}
|
||||
else if ( scrollbarStyle == "doubletop" ) {
|
||||
var downTop = this.findNodeByAttribute("sbattr", "scrollbar-down-top");
|
||||
var downBottom = this.findNodeByAttribute("sbattr", "scrollbar-down-bottom");
|
||||
downTop.removeAttribute("collapsed");
|
||||
downBottom.setAttribute("collapsed","true");
|
||||
}
|
||||
else if ( scrollbarStyle == "doublebottom" ) {
|
||||
var upTop = this.findNodeByAttribute("sbattr", "scrollbar-up-top");
|
||||
var upBottom = this.findNodeByAttribute("sbattr", "scrollbar-up-bottom");
|
||||
upTop.setAttribute("collapsed","true");
|
||||
upBottom.removeAttribute("collapsed");
|
||||
}
|
||||
if ( thumbStyle == "fixed" ) {
|
||||
var thumb = this.findNodeByAttribute("sbattr","scrollbar-thumb");
|
||||
if ( thumb )
|
||||
thumb.removeAttribute("flex");
|
||||
}
|
||||
}
|
||||
catch ( x ) {
|
||||
throw "Scrollbars in this skin are not properly supporting mac smart-scrolling prefs!";
|
||||
}
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
<method name="findNodeByAttribute">
|
||||
<parameter name="aAttribute"/>
|
||||
<parameter name="aValue"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
var nodes = document.getAnonymousNodes(this);
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
if (nodes[i].getAttribute(aAttribute) == aValue)
|
||||
return nodes[i];
|
||||
else {
|
||||
var subnodes = nodes[i].getElementsByAttribute(aAttribute, aValue);
|
||||
if (!subnodes.length) continue;
|
||||
return subnodes[0];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
</implementation>
|
||||
<handlers>
|
||||
<handler event="bindingattached" action="this.initScrollbar();"/>
|
||||
</handlers>
|
||||
</binding>
|
||||
|
||||
<binding id="slider">
|
||||
|
|
Загрузка…
Ссылка в новой задаче