зеркало из https://github.com/mozilla/pjs.git
bug 384612: Remove script from scrollbar XBL binding. r/sr=dbaron
This commit is contained in:
Родитель
53ec1e918e
Коммит
c09eb2fac7
|
@ -80,6 +80,7 @@
|
|||
#include "nsTextFrameTextRunCache.h"
|
||||
#include "nsCCUncollectableMarker.h"
|
||||
#include "nsTextFragment.h"
|
||||
#include "nsCSSRuleProcessor.h"
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
#include "nsXULPopupManager.h"
|
||||
|
@ -245,6 +246,7 @@ nsLayoutStatics::Shutdown()
|
|||
nsContentList::Shutdown();
|
||||
nsComputedDOMStyle::Shutdown();
|
||||
CSSLoaderImpl::Shutdown();
|
||||
nsCSSRuleProcessor::Shutdown();
|
||||
nsTextFrameTextRunCache::Shutdown();
|
||||
nsCSSRendering::Shutdown();
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -2592,7 +2592,8 @@ CSSParserImpl::ParsePseudoSelector(PRInt32& aDataMask,
|
|||
#endif
|
||||
nsCSSPseudoClasses::notPseudo == pseudo ||
|
||||
nsCSSPseudoClasses::lang == pseudo ||
|
||||
nsCSSPseudoClasses::mozEmptyExceptChildrenWithLocalname == pseudo)) {
|
||||
nsCSSPseudoClasses::mozEmptyExceptChildrenWithLocalname == pseudo ||
|
||||
nsCSSPseudoClasses::mozSystemMetric == pseudo)) {
|
||||
// There are no other function pseudos
|
||||
REPORT_UNEXPECTED_TOKEN(PEPseudoSelNonFunc);
|
||||
UngetToken();
|
||||
|
@ -2624,7 +2625,8 @@ CSSParserImpl::ParsePseudoSelector(PRInt32& aDataMask,
|
|||
else if (!parsingPseudoElement && isPseudoClass) {
|
||||
aDataMask |= SEL_MASK_PCLASS;
|
||||
if (nsCSSPseudoClasses::lang == pseudo ||
|
||||
nsCSSPseudoClasses::mozEmptyExceptChildrenWithLocalname == pseudo) {
|
||||
nsCSSPseudoClasses::mozEmptyExceptChildrenWithLocalname == pseudo ||
|
||||
nsCSSPseudoClasses::mozSystemMetric == pseudo) {
|
||||
nsSelectorParsingStatus parsingStatus =
|
||||
ParsePseudoClassWithIdentArg(aSelector, pseudo, aErrorCode);
|
||||
if (eSelectorParsingStatus_Continue != parsingStatus) {
|
||||
|
|
|
@ -91,6 +91,9 @@ CSS_PSEUDO_CLASS(mozHasHandlerRef, ":-moz-has-handlerref")
|
|||
// Match nodes that are HTML but not XHTML
|
||||
CSS_PSEUDO_CLASS(mozIsHTML, ":-moz-is-html")
|
||||
|
||||
// Matches anything when the specified look-and-feel metric is set
|
||||
CSS_PSEUDO_CLASS(mozSystemMetric, ":-moz-system-metric")
|
||||
|
||||
// CSS 3 UI
|
||||
// http://www.w3.org/TR/2004/CR-css3-ui-20040511/#pseudo-classes
|
||||
CSS_PSEUDO_CLASS(required, ":required")
|
||||
|
|
|
@ -74,6 +74,13 @@
|
|||
#include "nsQuickSort.h"
|
||||
#include "nsAttrValue.h"
|
||||
#include "nsAttrName.h"
|
||||
#include "nsILookAndFeel.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
||||
static nsTArray< nsCOMPtr<nsIAtom> >* sSystemMetrics = 0;
|
||||
|
||||
struct RuleValue {
|
||||
/**
|
||||
|
@ -738,6 +745,48 @@ nsCSSRuleProcessor::~nsCSSRuleProcessor()
|
|||
|
||||
NS_IMPL_ISUPPORTS1(nsCSSRuleProcessor, nsIStyleRuleProcessor)
|
||||
|
||||
static PRBool
|
||||
InitSystemMetrics()
|
||||
{
|
||||
NS_ASSERTION(!sSystemMetrics, "already initialized");
|
||||
|
||||
sSystemMetrics = new nsTArray< nsCOMPtr<nsIAtom> >;
|
||||
NS_ENSURE_TRUE(sSystemMetrics, PR_FALSE);
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsILookAndFeel> lookAndFeel(do_GetService(kLookAndFeelCID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||
|
||||
PRInt32 metricResult;
|
||||
lookAndFeel->GetMetric(nsILookAndFeel::eMetric_ScrollArrowStyle, metricResult);
|
||||
if (metricResult & nsILookAndFeel::eMetric_ScrollArrowStartBackward) {
|
||||
sSystemMetrics->AppendElement(do_GetAtom("scrollbar-start-backward"));
|
||||
}
|
||||
if (metricResult & nsILookAndFeel::eMetric_ScrollArrowStartForward) {
|
||||
sSystemMetrics->AppendElement(do_GetAtom("scrollbar-start-forward"));
|
||||
}
|
||||
if (metricResult & nsILookAndFeel::eMetric_ScrollArrowEndBackward) {
|
||||
sSystemMetrics->AppendElement(do_GetAtom("scrollbar-end-backward"));
|
||||
}
|
||||
if (metricResult & nsILookAndFeel::eMetric_ScrollArrowEndForward) {
|
||||
sSystemMetrics->AppendElement(do_GetAtom("scrollbar-end-forward"));
|
||||
}
|
||||
|
||||
lookAndFeel->GetMetric(nsILookAndFeel::eMetric_ScrollSliderStyle, metricResult);
|
||||
if (metricResult != nsILookAndFeel::eMetric_ScrollThumbStyleNormal) {
|
||||
sSystemMetrics->AppendElement(do_GetAtom("scrollbar-thumb-proportional"));
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
nsCSSRuleProcessor::Shutdown()
|
||||
{
|
||||
delete sSystemMetrics;
|
||||
sSystemMetrics = nsnull;
|
||||
}
|
||||
|
||||
RuleProcessorData::RuleProcessorData(nsPresContext* aPresContext,
|
||||
nsIContent* aContent,
|
||||
nsRuleWalker* aRuleWalker,
|
||||
|
@ -1105,6 +1154,15 @@ static PRBool SelectorMatches(RuleProcessorData &data,
|
|||
child->Tag()->Equals(nsDependentString(pseudoClass->mString)))));
|
||||
result = (child == nsnull);
|
||||
}
|
||||
else if (nsCSSPseudoClasses::mozSystemMetric == pseudoClass->mAtom) {
|
||||
if (!sSystemMetrics && !InitSystemMetrics()) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
NS_ASSERTION(pseudoClass->mString, "Must have string!");
|
||||
nsCOMPtr<nsIAtom> metric = do_GetAtom(pseudoClass->mString);
|
||||
result = sSystemMetrics->IndexOf(metric) !=
|
||||
sSystemMetrics->NoIndex;
|
||||
}
|
||||
else if (nsCSSPseudoClasses::mozHasHandlerRef == pseudoClass->mAtom) {
|
||||
nsIContent *child = nsnull;
|
||||
nsIContent *element = data.mContent;
|
||||
|
|
|
@ -71,6 +71,8 @@ public:
|
|||
public:
|
||||
nsresult ClearRuleCascades();
|
||||
|
||||
static void Shutdown();
|
||||
|
||||
// nsIStyleRuleProcessor
|
||||
NS_IMETHOD RulesMatching(ElementRuleProcessorData* aData);
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
|
||||
interface nsIDOMElement;
|
||||
|
||||
[scriptable, uuid(21f723fd-7fb9-4e19-bfa8-0a53a26dc242)]
|
||||
[scriptable, uuid(ce572460-b0f2-4650-a9e7-c53a99d3b6ad)]
|
||||
interface nsIBoxObject : nsISupports
|
||||
{
|
||||
readonly attribute nsIDOMElement element;
|
||||
|
@ -64,8 +64,6 @@ interface nsIBoxObject : nsISupports
|
|||
readonly attribute nsIDOMElement lastChild;
|
||||
readonly attribute nsIDOMElement nextSibling;
|
||||
readonly attribute nsIDOMElement previousSibling;
|
||||
|
||||
wstring getLookAndFeelMetric(in wstring propertyName);
|
||||
};
|
||||
|
||||
%{C++
|
||||
|
|
|
@ -46,9 +46,6 @@
|
|||
#include "nsIFrame.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsILookAndFeel.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
#include "nsIView.h"
|
||||
#include "nsIWidget.h"
|
||||
|
@ -59,9 +56,6 @@
|
|||
#include "prtypes.h"
|
||||
#include "nsSupportsPrimitives.h"
|
||||
|
||||
// Static IIDs/CIDs. Try to minimize these.
|
||||
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
||||
|
||||
// Implementation /////////////////////////////////////////////////////////////////
|
||||
|
||||
// Static member variable initialization
|
||||
|
@ -297,45 +291,6 @@ nsBoxObject::GetScreenY(PRInt32 *_retval)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBoxObject::GetLookAndFeelMetric(const PRUnichar* aPropertyName,
|
||||
PRUnichar** aResult)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
nsCOMPtr<nsILookAndFeel> lookAndFeel(do_GetService(kLookAndFeelCID));
|
||||
if (!lookAndFeel)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsAutoString property(aPropertyName);
|
||||
if (property.LowerCaseEqualsLiteral("scrollbararrows")) {
|
||||
PRInt32 metricResult;
|
||||
lookAndFeel->GetMetric(nsILookAndFeel::eMetric_ScrollArrowStyle, metricResult);
|
||||
nsAutoString result;
|
||||
if (metricResult & nsILookAndFeel::eMetric_ScrollArrowStartBackward) {
|
||||
result.AppendLiteral("start-backward ");
|
||||
}
|
||||
if (metricResult & nsILookAndFeel::eMetric_ScrollArrowStartForward) {
|
||||
result.AppendLiteral("start-forward ");
|
||||
}
|
||||
if (metricResult & nsILookAndFeel::eMetric_ScrollArrowEndBackward) {
|
||||
result.AppendLiteral("end-backward ");
|
||||
}
|
||||
if (metricResult & nsILookAndFeel::eMetric_ScrollArrowEndForward) {
|
||||
result.AppendLiteral("end-forward");
|
||||
}
|
||||
*aResult = ToNewUnicode(result);
|
||||
}
|
||||
else if (property.LowerCaseEqualsLiteral("thumbstyle")) {
|
||||
PRInt32 metricResult;
|
||||
lookAndFeel->GetMetric(nsILookAndFeel::eMetric_ScrollSliderStyle, metricResult);
|
||||
if ( metricResult == nsILookAndFeel::eMetric_ScrollThumbStyleNormal )
|
||||
*aResult = ToNewUnicode(NS_LITERAL_STRING("fixed"));
|
||||
else
|
||||
*aResult = ToNewUnicode(NS_LITERAL_STRING("proportional"));
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBoxObject::GetPropertyAsSupports(const PRUnichar* aPropertyName, nsISupports** aResult)
|
||||
{
|
||||
|
|
|
@ -23,55 +23,14 @@
|
|||
<binding id="scrollbar" extends="chrome://global/content/bindings/scrollbar.xml#scrollbar-base">
|
||||
<content>
|
||||
<xul:scrollbarbutton sbattr="scrollbar-up-top" type="decrement" xbl:inherits="disabled,sborient=orient"/>
|
||||
<xul:scrollbarbutton sbattr="scrollbar-down-top" type="increment" hidden="true" xbl:inherits="disabled,sborient=orient"/>
|
||||
<xul:scrollbarbutton sbattr="scrollbar-down-top" type="increment" xbl:inherits="disabled,sborient=orient"/>
|
||||
<xul:slider flex="1" xbl:inherits="disabled,curpos,maxpos,pageincrement,increment,orient,sborient=orient">
|
||||
<xul:thumb sbattr="scrollbar-thumb" xbl:inherits="orient,sborient=orient,collapsed=disabled"
|
||||
align="center" pack="center" flex="1"/>
|
||||
align="center" pack="center"/>
|
||||
</xul:slider>
|
||||
<xul:scrollbarbutton sbattr="scrollbar-up-bottom" type="decrement" hidden="true" xbl:inherits="disabled,sborient=orient"/>
|
||||
<xul:scrollbarbutton sbattr="scrollbar-up-bottom" type="decrement" xbl:inherits="disabled,sborient=orient"/>
|
||||
<xul:scrollbarbutton sbattr="scrollbar-down-bottom" type="increment" xbl:inherits="disabled,sborient=orient"/>
|
||||
</content>
|
||||
|
||||
<implementation>
|
||||
<constructor>
|
||||
this.initScrollbar();
|
||||
</constructor>
|
||||
|
||||
<method name="initScrollbar">
|
||||
<body>
|
||||
<![CDATA[
|
||||
try {
|
||||
var arrows = this.boxObject.getLookAndFeelMetric("scrollbarArrows");
|
||||
var thumbStyle = this.boxObject.getLookAndFeelMetric("thumbStyle");
|
||||
if (!arrows.match(/start-backward/)) {
|
||||
var upTop = document.getAnonymousElementByAttribute(this, "sbattr", "scrollbar-up-top");
|
||||
upTop.setAttribute("hidden","true");
|
||||
}
|
||||
if (arrows.match(/start-forward/)) {
|
||||
var downTop = document.getAnonymousElementByAttribute(this, "sbattr", "scrollbar-down-top");
|
||||
downTop.removeAttribute("hidden");
|
||||
}
|
||||
if (!arrows.match(/end-forward/)) {
|
||||
var downBottom = document.getAnonymousElementByAttribute(this, "sbattr", "scrollbar-down-bottom");
|
||||
downBottom.setAttribute("hidden","true");
|
||||
}
|
||||
if (arrows.match(/end-backward/)) {
|
||||
var upBottom = document.getAnonymousElementByAttribute(this, "sbattr", "scrollbar-up-bottom");
|
||||
upBottom.removeAttribute("hidden");
|
||||
}
|
||||
if ( thumbStyle == "fixed" ) {
|
||||
var thumb = document.getAnonymousElementByAttribute(this, "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>
|
||||
</implementation>
|
||||
</binding>
|
||||
</bindings>
|
||||
|
||||
|
|
|
@ -875,6 +875,17 @@ scale {
|
|||
-moz-user-focus: normal;
|
||||
}
|
||||
|
||||
scrollbarbutton[sbattr="scrollbar-up-top"]:not(:-moz-system-metric(scrollbar-start-backward)),
|
||||
scrollbarbutton[sbattr="scrollbar-down-top"]:not(:-moz-system-metric(scrollbar-start-forward)),
|
||||
scrollbarbutton[sbattr="scrollbar-up-bottom"]:not(:-moz-system-metric(scrollbar-end-backward)),
|
||||
scrollbarbutton[sbattr="scrollbar-down-bottom"]:not(:-moz-system-metric(scrollbar-end-forward)) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
thumb[sbattr="scrollbar-thumb"]:-moz-system-metric(scrollbar-thumb-proportional) {
|
||||
-moz-box-flex: 1;
|
||||
}
|
||||
|
||||
/******** scrollbox ********/
|
||||
|
||||
scrollbox {
|
||||
|
|
Загрузка…
Ссылка в новой задаче