From c0cd260b345d1bfaa769aed79ddfe19316754aa0 Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Wed, 17 Jun 2009 00:36:23 +0000 Subject: [PATCH] Bug 495798. Drop native theming for controls styled with transparent backgrounds, even if the user said to not use the page colors. r+sr=dbaron, a=ss git-svn-id: svn://10.0.0.236/trunk@257515 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/base/nsPresContext.cpp | 4 ++-- mozilla/layout/style/nsCSSDataBlock.cpp | 5 +---- mozilla/layout/style/nsCSSValue.cpp | 7 +++++++ mozilla/layout/style/nsCSSValue.h | 2 ++ mozilla/layout/style/nsRuleNode.cpp | 21 +++++++++++++++++---- mozilla/layout/style/nsRuleNode.h | 4 +++- 6 files changed, 32 insertions(+), 11 deletions(-) diff --git a/mozilla/layout/base/nsPresContext.cpp b/mozilla/layout/base/nsPresContext.cpp index 6ddccb10534..9a891433890 100644 --- a/mozilla/layout/base/nsPresContext.cpp +++ b/mozilla/layout/base/nsPresContext.cpp @@ -1502,7 +1502,7 @@ nsPresContext::IsChrome() const nsPresContext::HasAuthorSpecifiedRules(nsIFrame *aFrame, PRUint32 ruleTypeMask) const { return - UseDocumentColors() && nsRuleNode::HasAuthorSpecifiedRules(aFrame->GetStyleContext(), - ruleTypeMask); + ruleTypeMask, + UseDocumentColors()); } diff --git a/mozilla/layout/style/nsCSSDataBlock.cpp b/mozilla/layout/style/nsCSSDataBlock.cpp index ddf8b3bd8e9..cabe8051122 100644 --- a/mozilla/layout/style/nsCSSDataBlock.cpp +++ b/mozilla/layout/style/nsCSSDataBlock.cpp @@ -232,10 +232,7 @@ nsCSSCompressedDataBlock::MapRuleInfoInto(nsRuleData *aRuleData) const if (iProp == eCSSProperty_background_color) { // Force non-'transparent' background // colors to the user's default. - nsCSSUnit u = target->GetUnit(); - if (u != eCSSUnit_Enumerated && - u != eCSSUnit_Inherit && - u != eCSSUnit_Initial) { + if (target->IsNonTransparentColor()) { target->SetColorValue(aRuleData-> mPresContext-> DefaultBackgroundColor()); diff --git a/mozilla/layout/style/nsCSSValue.cpp b/mozilla/layout/style/nsCSSValue.cpp index 35e41dc7b4a..3628fbb3e79 100644 --- a/mozilla/layout/style/nsCSSValue.cpp +++ b/mozilla/layout/style/nsCSSValue.cpp @@ -394,6 +394,13 @@ void nsCSSValue::StartImageLoad(nsIDocument* aDocument) const } } +PRBool nsCSSValue::IsNonTransparentColor() const +{ + nsCSSUnit u = GetUnit(); + return u != eCSSUnit_Enumerated && u != eCSSUnit_Initial && + u != eCSSUnit_Initial; +} + // static nsStringBuffer* nsCSSValue::BufferFromString(const nsString& aValue) diff --git a/mozilla/layout/style/nsCSSValue.h b/mozilla/layout/style/nsCSSValue.h index cc53a25b49c..56d4ddf2e64 100644 --- a/mozilla/layout/style/nsCSSValue.h +++ b/mozilla/layout/style/nsCSSValue.h @@ -216,6 +216,8 @@ public: return mValue.mColor; } + PRBool IsNonTransparentColor() const; + Array* GetArrayValue() const { NS_ASSERTION(eCSSUnit_Array <= mUnit && mUnit <= eCSSUnit_Counters, diff --git a/mozilla/layout/style/nsRuleNode.cpp b/mozilla/layout/style/nsRuleNode.cpp index ac7712eef37..c42df4ecde5 100644 --- a/mozilla/layout/style/nsRuleNode.cpp +++ b/mozilla/layout/style/nsRuleNode.cpp @@ -5171,7 +5171,8 @@ nsRuleNode::Sweep() /* static */ PRBool nsRuleNode::HasAuthorSpecifiedRules(nsStyleContext* aStyleContext, - PRUint32 ruleTypeMask) + PRUint32 ruleTypeMask, + PRBool aAuthorColorsAllowed) { nsRuleDataColor colorData; nsRuleDataMargin marginData; @@ -5262,10 +5263,22 @@ nsRuleNode::HasAuthorSpecifiedRules(nsStyleContext* aStyleContext, } else { // If any of the values we care about was set by the above rule, // we have author style. - for (PRUint32 i = 0; i < nValues; ++i) + for (PRUint32 i = 0; i < nValues; ++i) { if (values[i]->GetUnit() != eCSSUnit_Null && - values[i]->GetUnit() != eCSSUnit_Dummy) // see above - return PR_TRUE; + values[i]->GetUnit() != eCSSUnit_Dummy) { // see above + // If author colors are not allowed, only claim to have + // author-specified rules if we're looking at the background + // color and it's set to transparent. Anything else should get + // set to a dummy value instead. + if (aAuthorColorsAllowed || + (values[i] == &colorData.mBackColor && + !values[i]->IsNonTransparentColor())) { + return PR_TRUE; + } + + values[i]->SetDummyValue(); + } + } } } } diff --git a/mozilla/layout/style/nsRuleNode.h b/mozilla/layout/style/nsRuleNode.h index 72b34503eaa..ae39fae3b20 100644 --- a/mozilla/layout/style/nsRuleNode.h +++ b/mozilla/layout/style/nsRuleNode.h @@ -722,7 +722,9 @@ public: NS_HIDDEN_(PRBool) Sweep(); static PRBool - HasAuthorSpecifiedRules(nsStyleContext* aStyleContext, PRUint32 ruleTypeMask); + HasAuthorSpecifiedRules(nsStyleContext* aStyleContext, + PRUint32 ruleTypeMask, + PRBool aAuthorColorsAllowed); }; #endif