Allow multiple post-resolve callbacks. (Maybe not the long term approach for CSS transitions, but easiest right now.) (Bug 435441) r=bzbarsky

This commit is contained in:
L. David Baron 2009-09-11 06:46:36 -04:00
Родитель e990c4947f
Коммит 311cbeddec
3 изменённых файлов: 25 добавлений и 15 удалений

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

@ -205,7 +205,7 @@ nsHTMLStyleSheet::TableTbodyRule::MapRuleInfoInto(nsRuleData* aRuleData)
{
if (aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(Border)) {
aRuleData->mCanStoreInRuleTree = PR_FALSE;
aRuleData->mPostResolveCallback = &TbodyPostResolveCallback;
aRuleData->mPostResolveCallbacks.AppendElement(&TbodyPostResolveCallback);
}
return NS_OK;
}
@ -224,7 +224,7 @@ nsHTMLStyleSheet::TableRowRule::MapRuleInfoInto(nsRuleData* aRuleData)
{
if (aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(Border)) {
aRuleData->mCanStoreInRuleTree = PR_FALSE;
aRuleData->mPostResolveCallback = &RowPostResolveCallback;
aRuleData->mPostResolveCallbacks.AppendElement(&RowPostResolveCallback);
}
return NS_OK;
}
@ -242,7 +242,7 @@ nsHTMLStyleSheet::TableColgroupRule::MapRuleInfoInto(nsRuleData* aRuleData)
{
if (aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(Border)) {
aRuleData->mCanStoreInRuleTree = PR_FALSE;
aRuleData->mPostResolveCallback = &ColgroupPostResolveCallback;
aRuleData->mPostResolveCallbacks.AppendElement(&ColgroupPostResolveCallback);
}
return NS_OK;
}
@ -271,7 +271,7 @@ nsHTMLStyleSheet::TableColRule::MapRuleInfoInto(nsRuleData* aRuleData)
{
if (aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(Border)) {
aRuleData->mCanStoreInRuleTree = PR_FALSE;
aRuleData->mPostResolveCallback = &ColPostResolveCallback;
aRuleData->mPostResolveCallbacks.AppendElement(&ColPostResolveCallback);
}
return NS_OK;
}
@ -281,7 +281,7 @@ nsHTMLStyleSheet::TableUngroupedColRule::MapRuleInfoInto(nsRuleData* aRuleData)
{
if (aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(Border)) {
aRuleData->mCanStoreInRuleTree = PR_FALSE;
aRuleData->mPostResolveCallback = &UngroupedColPostResolveCallback;
aRuleData->mPostResolveCallbacks.AppendElement(&UngroupedColPostResolveCallback);
}
return NS_OK;
}

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

@ -46,6 +46,7 @@
#include "nsCSSStruct.h"
#include "nsStyleStructFwd.h"
#include "nsTArray.h"
class nsPresContext;
class nsStyleContext;
@ -60,7 +61,9 @@ struct nsRuleData
PRUint8 mLevel; // an nsStyleSet::sheetType
nsPresContext* mPresContext;
nsStyleContext* mStyleContext;
nsPostResolveFunc mPostResolveCallback;
// MapRuleInfoInto should append to this array, so it is ordered from
// most specific to least.
nsTArray<nsPostResolveFunc> mPostResolveCallbacks;
nsRuleDataFont* mFontData; // Should always be stack-allocated! We don't own these structures!
nsRuleDataDisplay* mDisplayData;
nsRuleDataMargin* mMarginData;
@ -80,7 +83,7 @@ struct nsRuleData
nsRuleDataColumn* mColumnData;
nsRuleData(PRUint32 aSIDs, nsPresContext* aContext, nsStyleContext* aStyleContext)
:mSIDs(aSIDs), mPresContext(aContext), mStyleContext(aStyleContext), mPostResolveCallback(nsnull),
:mSIDs(aSIDs), mPresContext(aContext), mStyleContext(aStyleContext),
mFontData(nsnull), mDisplayData(nsnull), mMarginData(nsnull), mListData(nsnull),
mPositionData(nsnull), mTableData(nsnull), mColorData(nsnull), mContentData(nsnull), mTextData(nsnull),
mUserInterfaceData(nsnull), mColumnData(nsnull)

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

@ -1944,7 +1944,8 @@ nsRuleNode::WalkRuleTree(const nsStyleStructID aSID,
detail = eRulePartialMixed; // Treat as though some data is specified to avoid
// the optimizations and force data computation.
if (detail == eRuleNone && startStruct && !aRuleData->mPostResolveCallback) {
if (detail == eRuleNone && startStruct &&
aRuleData->mPostResolveCallbacks.IsEmpty()) {
// We specified absolutely no rule information, but a parent rule in the tree
// specified all the rule information. We set a bit along the branch from our
// node in the tree to the node that specified the data that tells nodes on that
@ -1953,7 +1954,7 @@ nsRuleNode::WalkRuleTree(const nsStyleStructID aSID,
PropagateDependentBit(bit, ruleNode);
return startStruct;
}
// FIXME Do we need to check for mPostResolveCallback?
// FIXME Do we need to check for mPostResolveCallbacks?
if ((!startStruct && !isReset &&
(detail == eRuleNone || detail == eRulePartialInherited)) ||
detail == eRuleFullInherited) {
@ -2008,9 +2009,13 @@ nsRuleNode::WalkRuleTree(const nsStyleStructID aSID,
#undef STYLE_STRUCT
#undef STYLE_STRUCT_TEST
// If we have a post-resolve callback, handle that now.
if (aRuleData->mPostResolveCallback && (NS_LIKELY(res != nsnull)))
(*aRuleData->mPostResolveCallback)(const_cast<void*>(res), aRuleData);
// If we have post-resolve callbacks, handle that now.
if (NS_LIKELY(res != nsnull)) {
// Enumerate from least to most specific rule.
for (PRUint32 i = aRuleData->mPostResolveCallbacks.Length(); i-- != 0; ) {
(*aRuleData->mPostResolveCallbacks[i])(const_cast<void*>(res), aRuleData);
}
}
// Now return the result.
return res;
@ -3003,9 +3008,11 @@ nsRuleNode::SetGenericFont(nsPresContext* aPresContext,
PR_FALSE, dummy);
// XXX Not sure if we need to do this here
// If we have a post-resolve callback, handle that now.
if (ruleData.mPostResolveCallback)
(ruleData.mPostResolveCallback)(aFont, &ruleData);
// If we have post-resolve callbacks, handle that now.
// Enumerate from least to most specific rule.
for (PRUint32 j = ruleData.mPostResolveCallbacks.Length(); j-- != 0; ) {
(*ruleData.mPostResolveCallbacks[j])(aFont, &ruleData);
}
parentFont = *aFont;
}