Bug 531933. Give HasStateDependentStyle a better signature. r=dbaron

This commit is contained in:
Boris Zbarsky 2009-12-11 22:36:34 -08:00
Родитель 1333943c85
Коммит 62f12d76fb
9 изменённых файлов: 30 добавлений и 44 удалений

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

@ -2244,9 +2244,8 @@ IsSiblingOperator(PRUnichar oper)
return oper == PRUnichar('+') || oper == PRUnichar('~');
}
NS_IMETHODIMP
nsCSSRuleProcessor::HasStateDependentStyle(StateRuleProcessorData* aData,
nsReStyleHint* aResult)
nsReStyleHint
nsCSSRuleProcessor::HasStateDependentStyle(StateRuleProcessorData* aData)
{
NS_PRECONDITION(aData->mContent->IsNodeOfType(nsINode::eELEMENT),
"content must be element");
@ -2261,8 +2260,8 @@ nsCSSRuleProcessor::HasStateDependentStyle(StateRuleProcessorData* aData,
// "body > p:hover" will be in |cascade->mStateSelectors|). Note that
// |IsStateSelector| below determines which selectors are in
// |cascade->mStateSelectors|.
nsReStyleHint hint = nsReStyleHint(0);
if (cascade) {
*aResult = nsReStyleHint(0);
nsCSSSelector **iter = cascade->mStateSelectors.Elements(),
**end = iter + cascade->mStateSelectors.Length();
for(; iter != end; ++iter) {
@ -2271,17 +2270,17 @@ nsCSSRuleProcessor::HasStateDependentStyle(StateRuleProcessorData* aData,
nsReStyleHint possibleChange = IsSiblingOperator(selector->mOperator) ?
eReStyle_LaterSiblings : eReStyle_Self;
// If *aResult already includes all the bits of possibleChange,
// If hint already includes all the bits of possibleChange,
// don't bother calling SelectorMatches, since even if it returns false
// *aResult won't change.
if ((possibleChange & ~(*aResult)) &&
// hint won't change.
if ((possibleChange & ~hint) &&
SelectorMatches(*aData, selector, aData->mStateMask, PR_FALSE) &&
SelectorMatchesTree(*aData, selector->mNext, PR_FALSE)) {
*aResult = nsReStyleHint(*aResult | possibleChange);
hint = nsReStyleHint(hint | possibleChange);
}
}
}
return NS_OK;
return hint;
}
struct AttributeEnumData {

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

@ -101,8 +101,7 @@ public:
NS_IMETHOD RulesMatching(XULTreeRuleProcessorData* aData);
#endif
NS_IMETHOD HasStateDependentStyle(StateRuleProcessorData* aData,
nsReStyleHint* aResult);
virtual nsReStyleHint HasStateDependentStyle(StateRuleProcessorData* aData);
virtual nsReStyleHint
HasAttributeDependentStyle(AttributeRuleProcessorData* aData);

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

@ -97,8 +97,7 @@ public:
NS_IMETHOD RulesMatching(XULTreeRuleProcessorData* aData);
#endif
NS_IMETHOD HasStateDependentStyle(StateRuleProcessorData* aData,
nsReStyleHint* aResult);
virtual nsReStyleHint HasStateDependentStyle(StateRuleProcessorData* aData);
virtual nsReStyleHint
HasAttributeDependentStyle(AttributeRuleProcessorData* aData);
@ -201,12 +200,10 @@ HTMLCSSStyleSheetImpl::Init(nsIURI* aURL, nsIDocument* aDocument)
}
// Test if style is dependent on content state
NS_IMETHODIMP
HTMLCSSStyleSheetImpl::HasStateDependentStyle(StateRuleProcessorData* aData,
nsReStyleHint* aResult)
nsReStyleHint
HTMLCSSStyleSheetImpl::HasStateDependentStyle(StateRuleProcessorData* aData)
{
*aResult = nsReStyleHint(0);
return NS_OK;
return nsReStyleHint(0);
}
// Test if style is dependent on attribute

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

@ -501,23 +501,19 @@ nsHTMLStyleSheet::RulesMatching(ElementRuleProcessorData* aData)
}
// Test if style is dependent on content state
NS_IMETHODIMP
nsHTMLStyleSheet::HasStateDependentStyle(StateRuleProcessorData* aData,
nsReStyleHint* aResult)
nsReStyleHint
nsHTMLStyleSheet::HasStateDependentStyle(StateRuleProcessorData* aData)
{
if (aData->mContent &&
aData->mIsHTMLContent &&
if (aData->mIsHTMLContent &&
aData->mContentTag == nsGkAtoms::a &&
aData->IsLink() &&
((mActiveRule && (aData->mStateMask & NS_EVENT_STATE_ACTIVE)) ||
(mLinkRule && (aData->mStateMask & NS_EVENT_STATE_VISITED)) ||
(mVisitedRule && (aData->mStateMask & NS_EVENT_STATE_VISITED)))) {
*aResult = eReStyle_Self;
return eReStyle_Self;
}
else
*aResult = nsReStyleHint(0);
return NS_OK;
return nsReStyleHint(0);
}
nsReStyleHint

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

@ -84,8 +84,7 @@ public:
#ifdef MOZ_XUL
NS_IMETHOD RulesMatching(XULTreeRuleProcessorData* aData);
#endif
NS_IMETHOD HasStateDependentStyle(StateRuleProcessorData* aData,
nsReStyleHint* aResult);
virtual nsReStyleHint HasStateDependentStyle(StateRuleProcessorData* aData);
virtual nsReStyleHint
HasAttributeDependentStyle(AttributeRuleProcessorData* aData);
NS_IMETHOD MediumFeaturesChanged(nsPresContext* aPresContext,

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

@ -61,10 +61,10 @@ struct AttributeRuleProcessorData;
class nsPresContext;
// IID for the nsIStyleRuleProcessor interface
// {ec92bc0c-9518-48ea-9289-74e654659be9}
// {566a7bea-fdc5-40a5-bf8a-87b5a231d79e}
#define NS_ISTYLE_RULE_PROCESSOR_IID \
{ 0xec92bc0c, 0x9518, 0x48ea, \
{ 0x92, 0x89, 0x74, 0xe6, 0x54, 0x65, 0x9b, 0xe9 } }
{ 0x566a7bea, 0xfdc5, 0x40a5, \
{ 0xbf, 0x8a, 0x87, 0xb5, 0xa2, 0x31, 0xd7, 0x9e } }
/* The style rule processor interface is a mechanism to separate the matching
* of style rules from style sheet instances.
@ -117,8 +117,8 @@ public:
*
* Event states are defined in nsIEventStateManager.h.
*/
NS_IMETHOD HasStateDependentStyle(StateRuleProcessorData* aData,
nsReStyleHint* aResult) = 0;
virtual nsReStyleHint
HasStateDependentStyle(StateRuleProcessorData* aData) = 0;
/**
* This method will be called twice for every attribute change.

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

@ -1076,8 +1076,7 @@ static PRBool SheetHasStatefulStyle(nsIStyleRuleProcessor* aProcessor,
void *aData)
{
StatefulData* data = (StatefulData*)aData;
nsReStyleHint hint;
aProcessor->HasStateDependentStyle(data, &hint);
nsReStyleHint hint = aProcessor->HasStateDependentStyle(data);
data->mHint = nsReStyleHint(data->mHint | hint);
return PR_TRUE; // continue
}

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

@ -828,12 +828,10 @@ nsTransitionManager::RulesMatching(XULTreeRuleProcessorData* aData)
}
#endif
NS_IMETHODIMP
nsTransitionManager::HasStateDependentStyle(StateRuleProcessorData* aData,
nsReStyleHint* aResult)
nsReStyleHint
nsTransitionManager::HasStateDependentStyle(StateRuleProcessorData* aData)
{
*aResult = nsReStyleHint(0);
return NS_OK;
return nsReStyleHint(0);
}
nsReStyleHint

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

@ -91,8 +91,7 @@ public:
#ifdef MOZ_XUL
NS_IMETHOD RulesMatching(XULTreeRuleProcessorData* aData);
#endif
NS_IMETHOD HasStateDependentStyle(StateRuleProcessorData* aData,
nsReStyleHint* aResult);
virtual nsReStyleHint HasStateDependentStyle(StateRuleProcessorData* aData);
virtual nsReStyleHint
HasAttributeDependentStyle(AttributeRuleProcessorData* aData);
NS_IMETHOD MediumFeaturesChanged(nsPresContext* aPresContext,