added backstop rule count
This commit is contained in:
peterl%netscape.com 1998-08-27 00:47:15 +00:00
Родитель eaf921f1b4
Коммит 4e78d9f83e
6 изменённых файлов: 120 добавлений и 45 удалений

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

@ -566,6 +566,8 @@ public:
virtual nsIStyleContext* GetParent(void) const;
virtual nsISupportsArray* GetStyleRules(void) const;
virtual PRInt32 GetStyleRuleCount(void) const;
virtual PRInt32 GetBackstopStyleRuleCount(void) const;
virtual void SetBackstopStyleRuleCount(PRInt32 aCount);
virtual nsIStyleContext* FindChildWithContent(nsIContent* aContent);
virtual nsIStyleContext* FindChildWithRules(nsISupportsArray* aRules);
@ -599,6 +601,7 @@ protected:
PRUint32 mHashValid: 1;
PRUint32 mHashValue: 31;
nsISupportsArray* mRules;
PRInt32 mBackstopRuleCount;
PRInt32 mDataCode;
// the style data...
@ -631,6 +634,7 @@ StyleContextImpl::StyleContextImpl(nsIStyleContext* aParent,
mChild(nsnull),
mContent(aContent),
mRules(aRules),
mBackstopRuleCount(0),
mDataCode(-1),
mFont(aPresContext->GetDefaultFont(), aPresContext->GetDefaultFixedFont()),
mColor(),
@ -754,6 +758,17 @@ PRInt32 StyleContextImpl::GetStyleRuleCount(void) const
return 0;
}
PRInt32 StyleContextImpl::GetBackstopStyleRuleCount(void) const
{
return mBackstopRuleCount;
}
void StyleContextImpl::SetBackstopStyleRuleCount(PRInt32 aCount)
{
NS_PRECONDITION(aCount <= GetStyleRuleCount(), "bad backstop rule count");
mBackstopRuleCount = aCount;
}
nsIStyleContext* StyleContextImpl::FindChildWithContent(nsIContent* aContent)
{
nsIStyleContext* result = nsnull;
@ -930,7 +945,7 @@ nsStyleStruct* StyleContextImpl::GetMutableStyleData(nsStyleStructID aSID)
}
if (nsnull != result) {
if (0 == mDataCode) {
mDataCode = ++gLastDataCode;
// mDataCode = ++gLastDataCode; // XXX temp disable, this is still used but not needed to force unique
}
}
return result;
@ -978,7 +993,7 @@ void StyleContextImpl::RemapStyle(nsIPresContext* aPresContext)
if ((nsnull != mRules) && (0 < mRules->Count())) {
MapStyleData data(this, aPresContext);
mRules->EnumerateBackwards(MapStyleRule, &data);
mRules->EnumerateForwards(MapStyleRule, &data);
}
if (-1 == mDataCode) {
mDataCode = 0;
@ -998,7 +1013,7 @@ void StyleContextImpl::RemapStyle(nsIPresContext* aPresContext)
if ((nsnull != mRules) && (0 < mRules->Count())) {
MapStyleData data(this, aPresContext);
mRules->EnumerateBackwards(MapStyleRule, &data);
mRules->EnumerateForwards(MapStyleRule, &data);
}
}
}

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

@ -453,9 +453,8 @@ PRInt32 StyleSetImpl::RulesMatching(nsISupportsArray* aSheets,
PRInt32 ruleCount = 0;
if (nsnull != aSheets) {
PRInt32 sheetCount = aSheets->Count();
PRInt32 index;
for (index = 0; index < sheetCount; index++) {
PRInt32 index = aSheets->Count();
while (0 < index--) {
nsIStyleSheet* sheet = (nsIStyleSheet*)aSheets->ElementAt(index);
ruleCount += sheet->RulesMatching(aPresContext, aContent, aParentFrame,
aResults);
@ -549,11 +548,15 @@ nsIStyleContext* StyleSetImpl::ResolveStyleFor(nsIPresContext* aPresContext,
nsISupportsArray* rules = nsnull;
if (NS_OK == NS_NewISupportsArray(&rules)) {
PRInt32 ruleCount = RulesMatching(mOverrideSheets, aPresContext, aContent, aParentFrame, rules);
PRInt32 ruleCount = RulesMatching(mBackstopSheets, aPresContext, aContent, aParentFrame, rules);
PRInt32 backstopRules = ruleCount;
ruleCount += RulesMatching(mDocSheets, aPresContext, aContent, aParentFrame, rules);
ruleCount += RulesMatching(mBackstopSheets, aPresContext, aContent, aParentFrame, rules);
ruleCount += RulesMatching(mOverrideSheets, aPresContext, aContent, aParentFrame, rules);
result = GetContext(aPresContext, aParentFrame, aContent, parentContext, rules, aForceUnique);
if (nsnull != result) {
result->SetBackstopStyleRuleCount(backstopRules);
}
NS_RELEASE(rules);
}
@ -574,9 +577,8 @@ PRInt32 StyleSetImpl::RulesMatching(nsISupportsArray* aSheets,
PRInt32 ruleCount = 0;
if (nsnull != aSheets) {
PRInt32 sheetCount = aSheets->Count();
PRInt32 index;
for (index = 0; index < sheetCount; index++) {
PRInt32 index = aSheets->Count();
while (0 < index--) {
nsIStyleSheet* sheet = (nsIStyleSheet*)aSheets->ElementAt(index);
ruleCount += sheet->RulesMatching(aPresContext, aPseudoTag, aParentFrame,
aResults);
@ -605,11 +607,15 @@ nsIStyleContext* StyleSetImpl::ResolvePseudoStyleFor(nsIPresContext* aPresContex
nsISupportsArray* rules = nsnull;
if (NS_OK == NS_NewISupportsArray(&rules)) {
PRInt32 ruleCount = RulesMatching(mOverrideSheets, aPresContext, aPseudoTag, aParentFrame, rules);
PRInt32 ruleCount = RulesMatching(mBackstopSheets, aPresContext, aPseudoTag, aParentFrame, rules);
PRInt32 backstopRules = ruleCount;
ruleCount += RulesMatching(mDocSheets, aPresContext, aPseudoTag, aParentFrame, rules);
ruleCount += RulesMatching(mBackstopSheets, aPresContext, aPseudoTag, aParentFrame, rules);
ruleCount += RulesMatching(mOverrideSheets, aPresContext, aPseudoTag, aParentFrame, rules);
result = GetContext(aPresContext, aParentFrame, nsnull, parentContext, rules, aForceUnique);
if (nsnull != result) {
result->SetBackstopStyleRuleCount(backstopRules);
}
NS_RELEASE(rules);
}
@ -638,12 +644,16 @@ nsIStyleContext* StyleSetImpl::ProbePseudoStyleFor(nsIPresContext* aPresContext,
nsISupportsArray* rules = nsnull;
if (NS_OK == NS_NewISupportsArray(&rules)) {
PRInt32 ruleCount = RulesMatching(mOverrideSheets, aPresContext, aPseudoTag, aParentFrame, rules);
PRInt32 ruleCount = RulesMatching(mBackstopSheets, aPresContext, aPseudoTag, aParentFrame, rules);
PRInt32 backstopRules = ruleCount;
ruleCount += RulesMatching(mDocSheets, aPresContext, aPseudoTag, aParentFrame, rules);
ruleCount += RulesMatching(mBackstopSheets, aPresContext, aPseudoTag, aParentFrame, rules);
ruleCount += RulesMatching(mOverrideSheets, aPresContext, aPseudoTag, aParentFrame, rules);
if (0 < ruleCount) {
result = GetContext(aPresContext, aParentFrame, nsnull, parentContext, rules, aForceUnique);
if (nsnull != result) {
result->SetBackstopStyleRuleCount(backstopRules);
}
}
NS_RELEASE(rules);

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

@ -566,6 +566,8 @@ public:
virtual nsIStyleContext* GetParent(void) const;
virtual nsISupportsArray* GetStyleRules(void) const;
virtual PRInt32 GetStyleRuleCount(void) const;
virtual PRInt32 GetBackstopStyleRuleCount(void) const;
virtual void SetBackstopStyleRuleCount(PRInt32 aCount);
virtual nsIStyleContext* FindChildWithContent(nsIContent* aContent);
virtual nsIStyleContext* FindChildWithRules(nsISupportsArray* aRules);
@ -599,6 +601,7 @@ protected:
PRUint32 mHashValid: 1;
PRUint32 mHashValue: 31;
nsISupportsArray* mRules;
PRInt32 mBackstopRuleCount;
PRInt32 mDataCode;
// the style data...
@ -631,6 +634,7 @@ StyleContextImpl::StyleContextImpl(nsIStyleContext* aParent,
mChild(nsnull),
mContent(aContent),
mRules(aRules),
mBackstopRuleCount(0),
mDataCode(-1),
mFont(aPresContext->GetDefaultFont(), aPresContext->GetDefaultFixedFont()),
mColor(),
@ -754,6 +758,17 @@ PRInt32 StyleContextImpl::GetStyleRuleCount(void) const
return 0;
}
PRInt32 StyleContextImpl::GetBackstopStyleRuleCount(void) const
{
return mBackstopRuleCount;
}
void StyleContextImpl::SetBackstopStyleRuleCount(PRInt32 aCount)
{
NS_PRECONDITION(aCount <= GetStyleRuleCount(), "bad backstop rule count");
mBackstopRuleCount = aCount;
}
nsIStyleContext* StyleContextImpl::FindChildWithContent(nsIContent* aContent)
{
nsIStyleContext* result = nsnull;
@ -930,7 +945,7 @@ nsStyleStruct* StyleContextImpl::GetMutableStyleData(nsStyleStructID aSID)
}
if (nsnull != result) {
if (0 == mDataCode) {
mDataCode = ++gLastDataCode;
// mDataCode = ++gLastDataCode; // XXX temp disable, this is still used but not needed to force unique
}
}
return result;
@ -978,7 +993,7 @@ void StyleContextImpl::RemapStyle(nsIPresContext* aPresContext)
if ((nsnull != mRules) && (0 < mRules->Count())) {
MapStyleData data(this, aPresContext);
mRules->EnumerateBackwards(MapStyleRule, &data);
mRules->EnumerateForwards(MapStyleRule, &data);
}
if (-1 == mDataCode) {
mDataCode = 0;
@ -998,7 +1013,7 @@ void StyleContextImpl::RemapStyle(nsIPresContext* aPresContext)
if ((nsnull != mRules) && (0 < mRules->Count())) {
MapStyleData data(this, aPresContext);
mRules->EnumerateBackwards(MapStyleRule, &data);
mRules->EnumerateForwards(MapStyleRule, &data);
}
}
}

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

@ -453,9 +453,8 @@ PRInt32 StyleSetImpl::RulesMatching(nsISupportsArray* aSheets,
PRInt32 ruleCount = 0;
if (nsnull != aSheets) {
PRInt32 sheetCount = aSheets->Count();
PRInt32 index;
for (index = 0; index < sheetCount; index++) {
PRInt32 index = aSheets->Count();
while (0 < index--) {
nsIStyleSheet* sheet = (nsIStyleSheet*)aSheets->ElementAt(index);
ruleCount += sheet->RulesMatching(aPresContext, aContent, aParentFrame,
aResults);
@ -549,11 +548,15 @@ nsIStyleContext* StyleSetImpl::ResolveStyleFor(nsIPresContext* aPresContext,
nsISupportsArray* rules = nsnull;
if (NS_OK == NS_NewISupportsArray(&rules)) {
PRInt32 ruleCount = RulesMatching(mOverrideSheets, aPresContext, aContent, aParentFrame, rules);
PRInt32 ruleCount = RulesMatching(mBackstopSheets, aPresContext, aContent, aParentFrame, rules);
PRInt32 backstopRules = ruleCount;
ruleCount += RulesMatching(mDocSheets, aPresContext, aContent, aParentFrame, rules);
ruleCount += RulesMatching(mBackstopSheets, aPresContext, aContent, aParentFrame, rules);
ruleCount += RulesMatching(mOverrideSheets, aPresContext, aContent, aParentFrame, rules);
result = GetContext(aPresContext, aParentFrame, aContent, parentContext, rules, aForceUnique);
if (nsnull != result) {
result->SetBackstopStyleRuleCount(backstopRules);
}
NS_RELEASE(rules);
}
@ -574,9 +577,8 @@ PRInt32 StyleSetImpl::RulesMatching(nsISupportsArray* aSheets,
PRInt32 ruleCount = 0;
if (nsnull != aSheets) {
PRInt32 sheetCount = aSheets->Count();
PRInt32 index;
for (index = 0; index < sheetCount; index++) {
PRInt32 index = aSheets->Count();
while (0 < index--) {
nsIStyleSheet* sheet = (nsIStyleSheet*)aSheets->ElementAt(index);
ruleCount += sheet->RulesMatching(aPresContext, aPseudoTag, aParentFrame,
aResults);
@ -605,11 +607,15 @@ nsIStyleContext* StyleSetImpl::ResolvePseudoStyleFor(nsIPresContext* aPresContex
nsISupportsArray* rules = nsnull;
if (NS_OK == NS_NewISupportsArray(&rules)) {
PRInt32 ruleCount = RulesMatching(mOverrideSheets, aPresContext, aPseudoTag, aParentFrame, rules);
PRInt32 ruleCount = RulesMatching(mBackstopSheets, aPresContext, aPseudoTag, aParentFrame, rules);
PRInt32 backstopRules = ruleCount;
ruleCount += RulesMatching(mDocSheets, aPresContext, aPseudoTag, aParentFrame, rules);
ruleCount += RulesMatching(mBackstopSheets, aPresContext, aPseudoTag, aParentFrame, rules);
ruleCount += RulesMatching(mOverrideSheets, aPresContext, aPseudoTag, aParentFrame, rules);
result = GetContext(aPresContext, aParentFrame, nsnull, parentContext, rules, aForceUnique);
if (nsnull != result) {
result->SetBackstopStyleRuleCount(backstopRules);
}
NS_RELEASE(rules);
}
@ -638,12 +644,16 @@ nsIStyleContext* StyleSetImpl::ProbePseudoStyleFor(nsIPresContext* aPresContext,
nsISupportsArray* rules = nsnull;
if (NS_OK == NS_NewISupportsArray(&rules)) {
PRInt32 ruleCount = RulesMatching(mOverrideSheets, aPresContext, aPseudoTag, aParentFrame, rules);
PRInt32 ruleCount = RulesMatching(mBackstopSheets, aPresContext, aPseudoTag, aParentFrame, rules);
PRInt32 backstopRules = ruleCount;
ruleCount += RulesMatching(mDocSheets, aPresContext, aPseudoTag, aParentFrame, rules);
ruleCount += RulesMatching(mBackstopSheets, aPresContext, aPseudoTag, aParentFrame, rules);
ruleCount += RulesMatching(mOverrideSheets, aPresContext, aPseudoTag, aParentFrame, rules);
if (0 < ruleCount) {
result = GetContext(aPresContext, aParentFrame, nsnull, parentContext, rules, aForceUnique);
if (nsnull != result) {
result->SetBackstopStyleRuleCount(backstopRules);
}
}
NS_RELEASE(rules);

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

@ -566,6 +566,8 @@ public:
virtual nsIStyleContext* GetParent(void) const;
virtual nsISupportsArray* GetStyleRules(void) const;
virtual PRInt32 GetStyleRuleCount(void) const;
virtual PRInt32 GetBackstopStyleRuleCount(void) const;
virtual void SetBackstopStyleRuleCount(PRInt32 aCount);
virtual nsIStyleContext* FindChildWithContent(nsIContent* aContent);
virtual nsIStyleContext* FindChildWithRules(nsISupportsArray* aRules);
@ -599,6 +601,7 @@ protected:
PRUint32 mHashValid: 1;
PRUint32 mHashValue: 31;
nsISupportsArray* mRules;
PRInt32 mBackstopRuleCount;
PRInt32 mDataCode;
// the style data...
@ -631,6 +634,7 @@ StyleContextImpl::StyleContextImpl(nsIStyleContext* aParent,
mChild(nsnull),
mContent(aContent),
mRules(aRules),
mBackstopRuleCount(0),
mDataCode(-1),
mFont(aPresContext->GetDefaultFont(), aPresContext->GetDefaultFixedFont()),
mColor(),
@ -754,6 +758,17 @@ PRInt32 StyleContextImpl::GetStyleRuleCount(void) const
return 0;
}
PRInt32 StyleContextImpl::GetBackstopStyleRuleCount(void) const
{
return mBackstopRuleCount;
}
void StyleContextImpl::SetBackstopStyleRuleCount(PRInt32 aCount)
{
NS_PRECONDITION(aCount <= GetStyleRuleCount(), "bad backstop rule count");
mBackstopRuleCount = aCount;
}
nsIStyleContext* StyleContextImpl::FindChildWithContent(nsIContent* aContent)
{
nsIStyleContext* result = nsnull;
@ -930,7 +945,7 @@ nsStyleStruct* StyleContextImpl::GetMutableStyleData(nsStyleStructID aSID)
}
if (nsnull != result) {
if (0 == mDataCode) {
mDataCode = ++gLastDataCode;
// mDataCode = ++gLastDataCode; // XXX temp disable, this is still used but not needed to force unique
}
}
return result;
@ -978,7 +993,7 @@ void StyleContextImpl::RemapStyle(nsIPresContext* aPresContext)
if ((nsnull != mRules) && (0 < mRules->Count())) {
MapStyleData data(this, aPresContext);
mRules->EnumerateBackwards(MapStyleRule, &data);
mRules->EnumerateForwards(MapStyleRule, &data);
}
if (-1 == mDataCode) {
mDataCode = 0;
@ -998,7 +1013,7 @@ void StyleContextImpl::RemapStyle(nsIPresContext* aPresContext)
if ((nsnull != mRules) && (0 < mRules->Count())) {
MapStyleData data(this, aPresContext);
mRules->EnumerateBackwards(MapStyleRule, &data);
mRules->EnumerateForwards(MapStyleRule, &data);
}
}
}

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

@ -453,9 +453,8 @@ PRInt32 StyleSetImpl::RulesMatching(nsISupportsArray* aSheets,
PRInt32 ruleCount = 0;
if (nsnull != aSheets) {
PRInt32 sheetCount = aSheets->Count();
PRInt32 index;
for (index = 0; index < sheetCount; index++) {
PRInt32 index = aSheets->Count();
while (0 < index--) {
nsIStyleSheet* sheet = (nsIStyleSheet*)aSheets->ElementAt(index);
ruleCount += sheet->RulesMatching(aPresContext, aContent, aParentFrame,
aResults);
@ -549,11 +548,15 @@ nsIStyleContext* StyleSetImpl::ResolveStyleFor(nsIPresContext* aPresContext,
nsISupportsArray* rules = nsnull;
if (NS_OK == NS_NewISupportsArray(&rules)) {
PRInt32 ruleCount = RulesMatching(mOverrideSheets, aPresContext, aContent, aParentFrame, rules);
PRInt32 ruleCount = RulesMatching(mBackstopSheets, aPresContext, aContent, aParentFrame, rules);
PRInt32 backstopRules = ruleCount;
ruleCount += RulesMatching(mDocSheets, aPresContext, aContent, aParentFrame, rules);
ruleCount += RulesMatching(mBackstopSheets, aPresContext, aContent, aParentFrame, rules);
ruleCount += RulesMatching(mOverrideSheets, aPresContext, aContent, aParentFrame, rules);
result = GetContext(aPresContext, aParentFrame, aContent, parentContext, rules, aForceUnique);
if (nsnull != result) {
result->SetBackstopStyleRuleCount(backstopRules);
}
NS_RELEASE(rules);
}
@ -574,9 +577,8 @@ PRInt32 StyleSetImpl::RulesMatching(nsISupportsArray* aSheets,
PRInt32 ruleCount = 0;
if (nsnull != aSheets) {
PRInt32 sheetCount = aSheets->Count();
PRInt32 index;
for (index = 0; index < sheetCount; index++) {
PRInt32 index = aSheets->Count();
while (0 < index--) {
nsIStyleSheet* sheet = (nsIStyleSheet*)aSheets->ElementAt(index);
ruleCount += sheet->RulesMatching(aPresContext, aPseudoTag, aParentFrame,
aResults);
@ -605,11 +607,15 @@ nsIStyleContext* StyleSetImpl::ResolvePseudoStyleFor(nsIPresContext* aPresContex
nsISupportsArray* rules = nsnull;
if (NS_OK == NS_NewISupportsArray(&rules)) {
PRInt32 ruleCount = RulesMatching(mOverrideSheets, aPresContext, aPseudoTag, aParentFrame, rules);
PRInt32 ruleCount = RulesMatching(mBackstopSheets, aPresContext, aPseudoTag, aParentFrame, rules);
PRInt32 backstopRules = ruleCount;
ruleCount += RulesMatching(mDocSheets, aPresContext, aPseudoTag, aParentFrame, rules);
ruleCount += RulesMatching(mBackstopSheets, aPresContext, aPseudoTag, aParentFrame, rules);
ruleCount += RulesMatching(mOverrideSheets, aPresContext, aPseudoTag, aParentFrame, rules);
result = GetContext(aPresContext, aParentFrame, nsnull, parentContext, rules, aForceUnique);
if (nsnull != result) {
result->SetBackstopStyleRuleCount(backstopRules);
}
NS_RELEASE(rules);
}
@ -638,12 +644,16 @@ nsIStyleContext* StyleSetImpl::ProbePseudoStyleFor(nsIPresContext* aPresContext,
nsISupportsArray* rules = nsnull;
if (NS_OK == NS_NewISupportsArray(&rules)) {
PRInt32 ruleCount = RulesMatching(mOverrideSheets, aPresContext, aPseudoTag, aParentFrame, rules);
PRInt32 ruleCount = RulesMatching(mBackstopSheets, aPresContext, aPseudoTag, aParentFrame, rules);
PRInt32 backstopRules = ruleCount;
ruleCount += RulesMatching(mDocSheets, aPresContext, aPseudoTag, aParentFrame, rules);
ruleCount += RulesMatching(mBackstopSheets, aPresContext, aPseudoTag, aParentFrame, rules);
ruleCount += RulesMatching(mOverrideSheets, aPresContext, aPseudoTag, aParentFrame, rules);
if (0 < ruleCount) {
result = GetContext(aPresContext, aParentFrame, nsnull, parentContext, rules, aForceUnique);
if (nsnull != result) {
result->SetBackstopStyleRuleCount(backstopRules);
}
}
NS_RELEASE(rules);