зеркало из https://github.com/mozilla/pjs.git
Add nsIFrame::GetPresContext, which gets the pres context from the rule node which it gets from the style context. DeCOMtaminate nsStyleContext::GetRuleNode, nsRuleNode::GetRule, and nsRuleNode::GetPresContext. Remove unused nsRuleNode::PathContainsRule. b=208190 r+sr=roc
This commit is contained in:
Родитель
ad4b7cb78e
Коммит
9b1d1eed2b
|
@ -102,7 +102,7 @@ public:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct ChildrenHashEntry : public PLDHashEntryHdr {
|
struct ChildrenHashEntry : public PLDHashEntryHdr {
|
||||||
// key (the rule) is |mRuleNode->Rule()|
|
// key (the rule) is |mRuleNode->GetRule()|
|
||||||
nsRuleNode *mRuleNode;
|
nsRuleNode *mRuleNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ PR_STATIC_CALLBACK(const void *)
|
||||||
ChildrenHashGetKey(PLDHashTable *table, PLDHashEntryHdr *hdr)
|
ChildrenHashGetKey(PLDHashTable *table, PLDHashEntryHdr *hdr)
|
||||||
{
|
{
|
||||||
ChildrenHashEntry *entry = NS_STATIC_CAST(ChildrenHashEntry*, hdr);
|
ChildrenHashEntry *entry = NS_STATIC_CAST(ChildrenHashEntry*, hdr);
|
||||||
return entry->mRuleNode->Rule();
|
return entry->mRuleNode->GetRule();
|
||||||
}
|
}
|
||||||
|
|
||||||
PR_STATIC_CALLBACK(PRBool)
|
PR_STATIC_CALLBACK(PRBool)
|
||||||
|
@ -119,7 +119,7 @@ ChildrenHashMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr,
|
||||||
{
|
{
|
||||||
const ChildrenHashEntry *entry =
|
const ChildrenHashEntry *entry =
|
||||||
NS_STATIC_CAST(const ChildrenHashEntry*, hdr);
|
NS_STATIC_CAST(const ChildrenHashEntry*, hdr);
|
||||||
return entry->mRuleNode->Rule() == key;
|
return entry->mRuleNode->GetRule() == key;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PLDHashTableOps ChildrenHashOps = {
|
static PLDHashTableOps ChildrenHashOps = {
|
||||||
|
@ -537,22 +537,6 @@ nsRuleNode::ConvertChildrenToHash()
|
||||||
SetChildrenHash(hash);
|
SetChildrenHash(hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsRuleNode::PathContainsRule(nsIStyleRule* aRule, PRBool* aMatched)
|
|
||||||
{
|
|
||||||
*aMatched = PR_FALSE;
|
|
||||||
nsRuleNode* ruleDest = this;
|
|
||||||
while (ruleDest) {
|
|
||||||
if (ruleDest->mRule == aRule) {
|
|
||||||
*aMatched = PR_TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ruleDest = ruleDest->mParent;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
PR_STATIC_CALLBACK(PLDHashOperator)
|
PR_STATIC_CALLBACK(PLDHashOperator)
|
||||||
ClearStyleDataHelper(PLDHashTable *table, PLDHashEntryHdr *hdr,
|
ClearStyleDataHelper(PLDHashTable *table, PLDHashEntryHdr *hdr,
|
||||||
PRUint32 number, void *arg)
|
PRUint32 number, void *arg)
|
||||||
|
@ -582,14 +566,6 @@ nsRuleNode::ClearStyleData()
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsRuleNode::GetPresContext(nsIPresContext** aResult)
|
|
||||||
{
|
|
||||||
*aResult = mPresContext;
|
|
||||||
NS_IF_ADDREF(*aResult);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
nsRuleNode::PropagateNoneBit(PRUint32 aBit, nsRuleNode* aHighestNode)
|
nsRuleNode::PropagateNoneBit(PRUint32 aBit, nsRuleNode* aHighestNode)
|
||||||
{
|
{
|
||||||
|
@ -1943,10 +1919,7 @@ SetGenericFont(nsIPresContext* aPresContext, nsStyleContext* aContext,
|
||||||
PRBool dummy;
|
PRBool dummy;
|
||||||
PRUint32 noneBits;
|
PRUint32 noneBits;
|
||||||
PRUint32 fontBit = nsCachedStyleData::GetBitForSID(eStyleStruct_Font);
|
PRUint32 fontBit = nsCachedStyleData::GetBitForSID(eStyleStruct_Font);
|
||||||
nsRuleNode* ruleNode = nsnull;
|
|
||||||
|
|
||||||
nsCOMPtr<nsIStyleRule> rule;
|
|
||||||
|
|
||||||
for (; i >= 0; --i) {
|
for (; i >= 0; --i) {
|
||||||
nsStyleContext* context = (nsStyleContext*)contextPath[i];
|
nsStyleContext* context = (nsStyleContext*)contextPath[i];
|
||||||
nsRuleDataFont fontData; // Declare a struct with null CSS values.
|
nsRuleDataFont fontData; // Declare a struct with null CSS values.
|
||||||
|
@ -1954,17 +1927,15 @@ SetGenericFont(nsIPresContext* aPresContext, nsStyleContext* aContext,
|
||||||
ruleData.mFontData = &fontData;
|
ruleData.mFontData = &fontData;
|
||||||
|
|
||||||
// Trimmed down version of ::WalkRuleTree() to re-apply the style rules
|
// Trimmed down version of ::WalkRuleTree() to re-apply the style rules
|
||||||
context->GetRuleNode(&ruleNode);
|
for (nsRuleNode* ruleNode = context->GetRuleNode(); ruleNode;
|
||||||
while (ruleNode) {
|
ruleNode = ruleNode->GetParent()) {
|
||||||
ruleNode->GetBits(nsRuleNode::eNoneBits, &noneBits);
|
ruleNode->GetBits(nsRuleNode::eNoneBits, &noneBits);
|
||||||
if (noneBits & fontBit) // no more font rules on this branch, get out
|
if (noneBits & fontBit) // no more font rules on this branch, get out
|
||||||
break;
|
break;
|
||||||
|
|
||||||
ruleNode->GetRule(getter_AddRefs(rule));
|
nsIStyleRule *rule = ruleNode->GetRule();
|
||||||
if (rule)
|
if (rule)
|
||||||
rule->MapRuleInfoInto(&ruleData);
|
rule->MapRuleInfoInto(&ruleData);
|
||||||
|
|
||||||
ruleNode = ruleNode->GetParent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute the delta from the information that the rules specified
|
// Compute the delta from the information that the rules specified
|
||||||
|
|
|
@ -92,7 +92,7 @@ nsStyleContext::~nsStyleContext()
|
||||||
{
|
{
|
||||||
NS_ASSERTION((nsnull == mChild) && (nsnull == mEmptyChild), "destructing context with children");
|
NS_ASSERTION((nsnull == mChild) && (nsnull == mEmptyChild), "destructing context with children");
|
||||||
|
|
||||||
nsIPresContext *presContext = mRuleNode->PresContext();
|
nsIPresContext *presContext = mRuleNode->GetPresContext();
|
||||||
|
|
||||||
nsCOMPtr<nsIPresShell> shell;
|
nsCOMPtr<nsIPresShell> shell;
|
||||||
presContext->GetShell(getter_AddRefs(shell));
|
presContext->GetShell(getter_AddRefs(shell));
|
||||||
|
@ -347,14 +347,13 @@ nsStyleContext::SetStyle(nsStyleStructID aSID, nsStyleStruct* aStruct)
|
||||||
char* resetOrInherit = NS_REINTERPRET_CAST(char*,
|
char* resetOrInherit = NS_REINTERPRET_CAST(char*,
|
||||||
*NS_REINTERPRET_CAST(void**, resetOrInheritSlot));
|
*NS_REINTERPRET_CAST(void**, resetOrInheritSlot));
|
||||||
if (!resetOrInherit) {
|
if (!resetOrInherit) {
|
||||||
nsCOMPtr<nsIPresContext> presContext;
|
nsIPresContext *presContext = mRuleNode->GetPresContext();
|
||||||
mRuleNode->GetPresContext(getter_AddRefs(presContext));
|
|
||||||
if (mCachedStyleData.IsReset(aSID)) {
|
if (mCachedStyleData.IsReset(aSID)) {
|
||||||
mCachedStyleData.mResetData = new (presContext.get()) nsResetStyleData;
|
mCachedStyleData.mResetData = new (presContext) nsResetStyleData;
|
||||||
resetOrInherit = NS_REINTERPRET_CAST(char*, mCachedStyleData.mResetData);
|
resetOrInherit = NS_REINTERPRET_CAST(char*, mCachedStyleData.mResetData);
|
||||||
} else {
|
} else {
|
||||||
mCachedStyleData.mInheritedData =
|
mCachedStyleData.mInheritedData =
|
||||||
new (presContext.get()) nsInheritedStyleData;
|
new (presContext) nsInheritedStyleData;
|
||||||
resetOrInherit =
|
resetOrInherit =
|
||||||
NS_REINTERPRET_CAST(char*, mCachedStyleData.mInheritedData);
|
NS_REINTERPRET_CAST(char*, mCachedStyleData.mInheritedData);
|
||||||
}
|
}
|
||||||
|
@ -553,8 +552,7 @@ void nsStyleContext::List(FILE* out, PRInt32 aIndent)
|
||||||
fputs("{\n", out);
|
fputs("{\n", out);
|
||||||
nsRuleNode* ruleNode = mRuleNode;
|
nsRuleNode* ruleNode = mRuleNode;
|
||||||
while (ruleNode) {
|
while (ruleNode) {
|
||||||
nsCOMPtr<nsIStyleRule> styleRule;
|
nsIStyleRule *styleRule = ruleNode->GetRule();
|
||||||
ruleNode->GetRule(getter_AddRefs(styleRule));
|
|
||||||
if (styleRule) {
|
if (styleRule) {
|
||||||
styleRule->List(out, aIndent + 1);
|
styleRule->List(out, aIndent + 1);
|
||||||
}
|
}
|
||||||
|
@ -838,8 +836,7 @@ void
|
||||||
nsStyleContext::Destroy()
|
nsStyleContext::Destroy()
|
||||||
{
|
{
|
||||||
// Get the pres context from our rule node.
|
// Get the pres context from our rule node.
|
||||||
nsCOMPtr<nsIPresContext> presContext;
|
nsCOMPtr<nsIPresContext> presContext = mRuleNode->GetPresContext();
|
||||||
mRuleNode->GetPresContext(getter_AddRefs(presContext));
|
|
||||||
|
|
||||||
// Call our destructor.
|
// Call our destructor.
|
||||||
this->~nsStyleContext();
|
this->~nsStyleContext();
|
||||||
|
|
|
@ -91,7 +91,7 @@ struct nsRuleNodeList
|
||||||
void Destroy() {
|
void Destroy() {
|
||||||
if (mNext)
|
if (mNext)
|
||||||
mNext->Destroy();
|
mNext->Destroy();
|
||||||
mRuleNode->PresContext()->FreeToShell(sizeof(nsRuleNodeList), this);
|
mRuleNode->GetPresContext()->FreeToShell(sizeof(nsRuleNodeList), this);
|
||||||
};
|
};
|
||||||
|
|
||||||
nsRuleNode* mRuleNode;
|
nsRuleNode* mRuleNode;
|
||||||
|
@ -1041,8 +1041,7 @@ StyleSetImpl::AddImportantRules(nsRuleNode* aCurrLevelNode,
|
||||||
|
|
||||||
AddImportantRules(aCurrLevelNode->GetParent(), aLastPrevLevelNode);
|
AddImportantRules(aCurrLevelNode->GetParent(), aLastPrevLevelNode);
|
||||||
|
|
||||||
nsCOMPtr<nsIStyleRule> rule;;
|
nsIStyleRule *rule = aCurrLevelNode->GetRule();
|
||||||
aCurrLevelNode->GetRule(getter_AddRefs(rule));
|
|
||||||
nsCOMPtr<nsICSSStyleRule> cssRule(do_QueryInterface(rule));
|
nsCOMPtr<nsICSSStyleRule> cssRule(do_QueryInterface(rule));
|
||||||
if (cssRule) {
|
if (cssRule) {
|
||||||
nsCOMPtr<nsIStyleRule> impRule = cssRule->GetImportantRule();
|
nsCOMPtr<nsIStyleRule> impRule = cssRule->GetImportantRule();
|
||||||
|
@ -1518,8 +1517,7 @@ StyleSetImpl::ReParentStyleContext(nsIPresContext* aPresContext,
|
||||||
else { // really a new parent
|
else { // really a new parent
|
||||||
nsCOMPtr<nsIAtom> pseudoTag = aStyleContext->GetPseudoType();
|
nsCOMPtr<nsIAtom> pseudoTag = aStyleContext->GetPseudoType();
|
||||||
|
|
||||||
nsRuleNode* ruleNode;
|
nsRuleNode* ruleNode = aStyleContext->GetRuleNode();
|
||||||
aStyleContext->GetRuleNode(&ruleNode);
|
|
||||||
EnsureRuleWalker(aPresContext);
|
EnsureRuleWalker(aPresContext);
|
||||||
NS_ENSURE_TRUE(mRuleWalker, nsnull);
|
NS_ENSURE_TRUE(mRuleWalker, nsnull);
|
||||||
mRuleWalker->SetCurrentNode(ruleNode);
|
mRuleWalker->SetCurrentNode(ruleNode);
|
||||||
|
|
|
@ -808,7 +808,9 @@ HTMLStyleSheetImpl::RulesMatching(ElementRuleProcessorData* aData,
|
||||||
else if (tag == nsHTMLAtoms::table) {
|
else if (tag == nsHTMLAtoms::table) {
|
||||||
if (aData->mCompatMode == eCompatibility_NavQuirks) {
|
if (aData->mCompatMode == eCompatibility_NavQuirks) {
|
||||||
nscolor bodyColor;
|
nscolor bodyColor;
|
||||||
nsresult rv = GetBodyColor(ruleWalker->GetCurrentNode()->PresContext(), &bodyColor);
|
nsresult rv =
|
||||||
|
GetBodyColor(ruleWalker->GetCurrentNode()->GetPresContext(),
|
||||||
|
&bodyColor);
|
||||||
if (NS_SUCCEEDED(rv) &&
|
if (NS_SUCCEEDED(rv) &&
|
||||||
(!mDocumentColorRule || bodyColor != mDocumentColorRule->mColor)) {
|
(!mDocumentColorRule || bodyColor != mDocumentColorRule->mColor)) {
|
||||||
if (mDocumentColorRule) {
|
if (mDocumentColorRule) {
|
||||||
|
|
|
@ -75,7 +75,8 @@ nsInspectorCSSUtils::GetRuleNodeParent(nsRuleNode *aNode, nsRuleNode **aParent)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsInspectorCSSUtils::GetRuleNodeRule(nsRuleNode *aNode, nsIStyleRule **aRule)
|
nsInspectorCSSUtils::GetRuleNodeRule(nsRuleNode *aNode, nsIStyleRule **aRule)
|
||||||
{
|
{
|
||||||
return aNode->GetRule(aRule);
|
*aRule = aNode->GetRule();
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -181,6 +182,6 @@ nsInspectorCSSUtils::GetRuleNodeForContent(nsIContent* aContent,
|
||||||
NS_ENSURE_TRUE(presShell, NS_ERROR_UNEXPECTED);
|
NS_ENSURE_TRUE(presShell, NS_ERROR_UNEXPECTED);
|
||||||
|
|
||||||
nsRefPtr<nsStyleContext> sContext = GetStyleContextForContent(aContent, presShell);
|
nsRefPtr<nsStyleContext> sContext = GetStyleContextForContent(aContent, presShell);
|
||||||
sContext->GetRuleNode(aRuleNode);
|
*aRuleNode = sContext->GetRuleNode();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -539,26 +539,15 @@ public:
|
||||||
|
|
||||||
nsresult GetBits(PRInt32 aType, PRUint32* aResult);
|
nsresult GetBits(PRInt32 aType, PRUint32* aResult);
|
||||||
nsresult Transition(nsIStyleRule* aRule, nsRuleNode** aResult);
|
nsresult Transition(nsIStyleRule* aRule, nsRuleNode** aResult);
|
||||||
nsRuleNode* GetParent() { return mParent; }
|
nsRuleNode* GetParent() const { return mParent; }
|
||||||
PRBool IsRoot() { return mParent == nsnull; }
|
PRBool IsRoot() const { return mParent == nsnull; }
|
||||||
nsresult GetRule(nsIStyleRule** aResult)
|
|
||||||
{
|
// NOTE: Does not |AddRef|.
|
||||||
*aResult = mRule;
|
nsIStyleRule* GetRule() const { return mRule; }
|
||||||
NS_IF_ADDREF(*aResult);
|
// NOTE: Does not |AddRef|.
|
||||||
return NS_OK;
|
nsIPresContext* GetPresContext() const { return mPresContext; }
|
||||||
}
|
|
||||||
nsIStyleRule* Rule() {
|
|
||||||
// NOTE: Does not |AddRef|.
|
|
||||||
return mRule;
|
|
||||||
}
|
|
||||||
nsIPresContext* PresContext() {
|
|
||||||
// NOTE: Does not |AddRef|.
|
|
||||||
return mPresContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult ClearStyleData();
|
nsresult ClearStyleData();
|
||||||
nsresult GetPresContext(nsIPresContext** aResult);
|
|
||||||
nsresult PathContainsRule(nsIStyleRule* aRule, PRBool* aMatched);
|
|
||||||
const nsStyleStruct* GetStyleData(nsStyleStructID aSID,
|
const nsStyleStruct* GetStyleData(nsStyleStructID aSID,
|
||||||
nsStyleContext* aContext,
|
nsStyleContext* aContext,
|
||||||
PRBool aComputeData);
|
PRBool aComputeData);
|
||||||
|
|
|
@ -88,7 +88,7 @@ public:
|
||||||
|
|
||||||
void SetStyle(nsStyleStructID aSID, nsStyleStruct* aStruct);
|
void SetStyle(nsStyleStructID aSID, nsStyleStruct* aStruct);
|
||||||
|
|
||||||
void GetRuleNode(nsRuleNode** aResult) { *aResult = mRuleNode; }
|
nsRuleNode* GetRuleNode() { return mRuleNode; }
|
||||||
void AddStyleBit(const PRUint32& aBit) { mBits |= aBit; }
|
void AddStyleBit(const PRUint32& aBit) { mBits |= aBit; }
|
||||||
void GetStyleBits(PRUint32* aBits) { *aBits = mBits; }
|
void GetStyleBits(PRUint32* aBits) { *aBits = mBits; }
|
||||||
|
|
||||||
|
|
|
@ -1736,10 +1736,7 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext,
|
||||||
NS_ASSERTION(newContext, "failed to get new style context");
|
NS_ASSERTION(newContext, "failed to get new style context");
|
||||||
if (newContext) {
|
if (newContext) {
|
||||||
if (!parentContext) {
|
if (!parentContext) {
|
||||||
nsRuleNode *oldNode, *newNode;
|
if (oldContext->GetRuleNode() == newContext->GetRuleNode()) {
|
||||||
oldContext->GetRuleNode(&oldNode);
|
|
||||||
newContext->GetRuleNode(&newNode);
|
|
||||||
if (oldNode == newNode) {
|
|
||||||
// We're the root of the style context tree and the new style
|
// We're the root of the style context tree and the new style
|
||||||
// context returned has the same rule node. This means that
|
// context returned has the same rule node. This means that
|
||||||
// we can use FindChildWithRules to keep a lot of the old
|
// we can use FindChildWithRules to keep a lot of the old
|
||||||
|
|
|
@ -396,6 +396,11 @@ class nsIFrame : public nsISupports
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFRAME_IID)
|
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFRAME_IID)
|
||||||
|
|
||||||
|
nsIPresContext* GetPresContext() {
|
||||||
|
return GetStyleContext()->GetRuleNode()->GetPresContext();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called to initialize the frame. This is called immediately after creating
|
* Called to initialize the frame. This is called immediately after creating
|
||||||
* the frame.
|
* the frame.
|
||||||
|
|
|
@ -396,6 +396,11 @@ class nsIFrame : public nsISupports
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFRAME_IID)
|
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFRAME_IID)
|
||||||
|
|
||||||
|
nsIPresContext* GetPresContext() {
|
||||||
|
return GetStyleContext()->GetRuleNode()->GetPresContext();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called to initialize the frame. This is called immediately after creating
|
* Called to initialize the frame. This is called immediately after creating
|
||||||
* the frame.
|
* the frame.
|
||||||
|
|
|
@ -1736,10 +1736,7 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext,
|
||||||
NS_ASSERTION(newContext, "failed to get new style context");
|
NS_ASSERTION(newContext, "failed to get new style context");
|
||||||
if (newContext) {
|
if (newContext) {
|
||||||
if (!parentContext) {
|
if (!parentContext) {
|
||||||
nsRuleNode *oldNode, *newNode;
|
if (oldContext->GetRuleNode() == newContext->GetRuleNode()) {
|
||||||
oldContext->GetRuleNode(&oldNode);
|
|
||||||
newContext->GetRuleNode(&newNode);
|
|
||||||
if (oldNode == newNode) {
|
|
||||||
// We're the root of the style context tree and the new style
|
// We're the root of the style context tree and the new style
|
||||||
// context returned has the same rule node. This means that
|
// context returned has the same rule node. This means that
|
||||||
// we can use FindChildWithRules to keep a lot of the old
|
// we can use FindChildWithRules to keep a lot of the old
|
||||||
|
|
|
@ -808,7 +808,9 @@ HTMLStyleSheetImpl::RulesMatching(ElementRuleProcessorData* aData,
|
||||||
else if (tag == nsHTMLAtoms::table) {
|
else if (tag == nsHTMLAtoms::table) {
|
||||||
if (aData->mCompatMode == eCompatibility_NavQuirks) {
|
if (aData->mCompatMode == eCompatibility_NavQuirks) {
|
||||||
nscolor bodyColor;
|
nscolor bodyColor;
|
||||||
nsresult rv = GetBodyColor(ruleWalker->GetCurrentNode()->PresContext(), &bodyColor);
|
nsresult rv =
|
||||||
|
GetBodyColor(ruleWalker->GetCurrentNode()->GetPresContext(),
|
||||||
|
&bodyColor);
|
||||||
if (NS_SUCCEEDED(rv) &&
|
if (NS_SUCCEEDED(rv) &&
|
||||||
(!mDocumentColorRule || bodyColor != mDocumentColorRule->mColor)) {
|
(!mDocumentColorRule || bodyColor != mDocumentColorRule->mColor)) {
|
||||||
if (mDocumentColorRule) {
|
if (mDocumentColorRule) {
|
||||||
|
|
|
@ -75,7 +75,8 @@ nsInspectorCSSUtils::GetRuleNodeParent(nsRuleNode *aNode, nsRuleNode **aParent)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsInspectorCSSUtils::GetRuleNodeRule(nsRuleNode *aNode, nsIStyleRule **aRule)
|
nsInspectorCSSUtils::GetRuleNodeRule(nsRuleNode *aNode, nsIStyleRule **aRule)
|
||||||
{
|
{
|
||||||
return aNode->GetRule(aRule);
|
*aRule = aNode->GetRule();
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -181,6 +182,6 @@ nsInspectorCSSUtils::GetRuleNodeForContent(nsIContent* aContent,
|
||||||
NS_ENSURE_TRUE(presShell, NS_ERROR_UNEXPECTED);
|
NS_ENSURE_TRUE(presShell, NS_ERROR_UNEXPECTED);
|
||||||
|
|
||||||
nsRefPtr<nsStyleContext> sContext = GetStyleContextForContent(aContent, presShell);
|
nsRefPtr<nsStyleContext> sContext = GetStyleContextForContent(aContent, presShell);
|
||||||
sContext->GetRuleNode(aRuleNode);
|
*aRuleNode = sContext->GetRuleNode();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,7 @@ public:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct ChildrenHashEntry : public PLDHashEntryHdr {
|
struct ChildrenHashEntry : public PLDHashEntryHdr {
|
||||||
// key (the rule) is |mRuleNode->Rule()|
|
// key (the rule) is |mRuleNode->GetRule()|
|
||||||
nsRuleNode *mRuleNode;
|
nsRuleNode *mRuleNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ PR_STATIC_CALLBACK(const void *)
|
||||||
ChildrenHashGetKey(PLDHashTable *table, PLDHashEntryHdr *hdr)
|
ChildrenHashGetKey(PLDHashTable *table, PLDHashEntryHdr *hdr)
|
||||||
{
|
{
|
||||||
ChildrenHashEntry *entry = NS_STATIC_CAST(ChildrenHashEntry*, hdr);
|
ChildrenHashEntry *entry = NS_STATIC_CAST(ChildrenHashEntry*, hdr);
|
||||||
return entry->mRuleNode->Rule();
|
return entry->mRuleNode->GetRule();
|
||||||
}
|
}
|
||||||
|
|
||||||
PR_STATIC_CALLBACK(PRBool)
|
PR_STATIC_CALLBACK(PRBool)
|
||||||
|
@ -119,7 +119,7 @@ ChildrenHashMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr,
|
||||||
{
|
{
|
||||||
const ChildrenHashEntry *entry =
|
const ChildrenHashEntry *entry =
|
||||||
NS_STATIC_CAST(const ChildrenHashEntry*, hdr);
|
NS_STATIC_CAST(const ChildrenHashEntry*, hdr);
|
||||||
return entry->mRuleNode->Rule() == key;
|
return entry->mRuleNode->GetRule() == key;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PLDHashTableOps ChildrenHashOps = {
|
static PLDHashTableOps ChildrenHashOps = {
|
||||||
|
@ -537,22 +537,6 @@ nsRuleNode::ConvertChildrenToHash()
|
||||||
SetChildrenHash(hash);
|
SetChildrenHash(hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsRuleNode::PathContainsRule(nsIStyleRule* aRule, PRBool* aMatched)
|
|
||||||
{
|
|
||||||
*aMatched = PR_FALSE;
|
|
||||||
nsRuleNode* ruleDest = this;
|
|
||||||
while (ruleDest) {
|
|
||||||
if (ruleDest->mRule == aRule) {
|
|
||||||
*aMatched = PR_TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ruleDest = ruleDest->mParent;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
PR_STATIC_CALLBACK(PLDHashOperator)
|
PR_STATIC_CALLBACK(PLDHashOperator)
|
||||||
ClearStyleDataHelper(PLDHashTable *table, PLDHashEntryHdr *hdr,
|
ClearStyleDataHelper(PLDHashTable *table, PLDHashEntryHdr *hdr,
|
||||||
PRUint32 number, void *arg)
|
PRUint32 number, void *arg)
|
||||||
|
@ -582,14 +566,6 @@ nsRuleNode::ClearStyleData()
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsRuleNode::GetPresContext(nsIPresContext** aResult)
|
|
||||||
{
|
|
||||||
*aResult = mPresContext;
|
|
||||||
NS_IF_ADDREF(*aResult);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
nsRuleNode::PropagateNoneBit(PRUint32 aBit, nsRuleNode* aHighestNode)
|
nsRuleNode::PropagateNoneBit(PRUint32 aBit, nsRuleNode* aHighestNode)
|
||||||
{
|
{
|
||||||
|
@ -1943,10 +1919,7 @@ SetGenericFont(nsIPresContext* aPresContext, nsStyleContext* aContext,
|
||||||
PRBool dummy;
|
PRBool dummy;
|
||||||
PRUint32 noneBits;
|
PRUint32 noneBits;
|
||||||
PRUint32 fontBit = nsCachedStyleData::GetBitForSID(eStyleStruct_Font);
|
PRUint32 fontBit = nsCachedStyleData::GetBitForSID(eStyleStruct_Font);
|
||||||
nsRuleNode* ruleNode = nsnull;
|
|
||||||
|
|
||||||
nsCOMPtr<nsIStyleRule> rule;
|
|
||||||
|
|
||||||
for (; i >= 0; --i) {
|
for (; i >= 0; --i) {
|
||||||
nsStyleContext* context = (nsStyleContext*)contextPath[i];
|
nsStyleContext* context = (nsStyleContext*)contextPath[i];
|
||||||
nsRuleDataFont fontData; // Declare a struct with null CSS values.
|
nsRuleDataFont fontData; // Declare a struct with null CSS values.
|
||||||
|
@ -1954,17 +1927,15 @@ SetGenericFont(nsIPresContext* aPresContext, nsStyleContext* aContext,
|
||||||
ruleData.mFontData = &fontData;
|
ruleData.mFontData = &fontData;
|
||||||
|
|
||||||
// Trimmed down version of ::WalkRuleTree() to re-apply the style rules
|
// Trimmed down version of ::WalkRuleTree() to re-apply the style rules
|
||||||
context->GetRuleNode(&ruleNode);
|
for (nsRuleNode* ruleNode = context->GetRuleNode(); ruleNode;
|
||||||
while (ruleNode) {
|
ruleNode = ruleNode->GetParent()) {
|
||||||
ruleNode->GetBits(nsRuleNode::eNoneBits, &noneBits);
|
ruleNode->GetBits(nsRuleNode::eNoneBits, &noneBits);
|
||||||
if (noneBits & fontBit) // no more font rules on this branch, get out
|
if (noneBits & fontBit) // no more font rules on this branch, get out
|
||||||
break;
|
break;
|
||||||
|
|
||||||
ruleNode->GetRule(getter_AddRefs(rule));
|
nsIStyleRule *rule = ruleNode->GetRule();
|
||||||
if (rule)
|
if (rule)
|
||||||
rule->MapRuleInfoInto(&ruleData);
|
rule->MapRuleInfoInto(&ruleData);
|
||||||
|
|
||||||
ruleNode = ruleNode->GetParent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute the delta from the information that the rules specified
|
// Compute the delta from the information that the rules specified
|
||||||
|
|
|
@ -539,26 +539,15 @@ public:
|
||||||
|
|
||||||
nsresult GetBits(PRInt32 aType, PRUint32* aResult);
|
nsresult GetBits(PRInt32 aType, PRUint32* aResult);
|
||||||
nsresult Transition(nsIStyleRule* aRule, nsRuleNode** aResult);
|
nsresult Transition(nsIStyleRule* aRule, nsRuleNode** aResult);
|
||||||
nsRuleNode* GetParent() { return mParent; }
|
nsRuleNode* GetParent() const { return mParent; }
|
||||||
PRBool IsRoot() { return mParent == nsnull; }
|
PRBool IsRoot() const { return mParent == nsnull; }
|
||||||
nsresult GetRule(nsIStyleRule** aResult)
|
|
||||||
{
|
// NOTE: Does not |AddRef|.
|
||||||
*aResult = mRule;
|
nsIStyleRule* GetRule() const { return mRule; }
|
||||||
NS_IF_ADDREF(*aResult);
|
// NOTE: Does not |AddRef|.
|
||||||
return NS_OK;
|
nsIPresContext* GetPresContext() const { return mPresContext; }
|
||||||
}
|
|
||||||
nsIStyleRule* Rule() {
|
|
||||||
// NOTE: Does not |AddRef|.
|
|
||||||
return mRule;
|
|
||||||
}
|
|
||||||
nsIPresContext* PresContext() {
|
|
||||||
// NOTE: Does not |AddRef|.
|
|
||||||
return mPresContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult ClearStyleData();
|
nsresult ClearStyleData();
|
||||||
nsresult GetPresContext(nsIPresContext** aResult);
|
|
||||||
nsresult PathContainsRule(nsIStyleRule* aRule, PRBool* aMatched);
|
|
||||||
const nsStyleStruct* GetStyleData(nsStyleStructID aSID,
|
const nsStyleStruct* GetStyleData(nsStyleStructID aSID,
|
||||||
nsStyleContext* aContext,
|
nsStyleContext* aContext,
|
||||||
PRBool aComputeData);
|
PRBool aComputeData);
|
||||||
|
|
|
@ -92,7 +92,7 @@ nsStyleContext::~nsStyleContext()
|
||||||
{
|
{
|
||||||
NS_ASSERTION((nsnull == mChild) && (nsnull == mEmptyChild), "destructing context with children");
|
NS_ASSERTION((nsnull == mChild) && (nsnull == mEmptyChild), "destructing context with children");
|
||||||
|
|
||||||
nsIPresContext *presContext = mRuleNode->PresContext();
|
nsIPresContext *presContext = mRuleNode->GetPresContext();
|
||||||
|
|
||||||
nsCOMPtr<nsIPresShell> shell;
|
nsCOMPtr<nsIPresShell> shell;
|
||||||
presContext->GetShell(getter_AddRefs(shell));
|
presContext->GetShell(getter_AddRefs(shell));
|
||||||
|
@ -347,14 +347,13 @@ nsStyleContext::SetStyle(nsStyleStructID aSID, nsStyleStruct* aStruct)
|
||||||
char* resetOrInherit = NS_REINTERPRET_CAST(char*,
|
char* resetOrInherit = NS_REINTERPRET_CAST(char*,
|
||||||
*NS_REINTERPRET_CAST(void**, resetOrInheritSlot));
|
*NS_REINTERPRET_CAST(void**, resetOrInheritSlot));
|
||||||
if (!resetOrInherit) {
|
if (!resetOrInherit) {
|
||||||
nsCOMPtr<nsIPresContext> presContext;
|
nsIPresContext *presContext = mRuleNode->GetPresContext();
|
||||||
mRuleNode->GetPresContext(getter_AddRefs(presContext));
|
|
||||||
if (mCachedStyleData.IsReset(aSID)) {
|
if (mCachedStyleData.IsReset(aSID)) {
|
||||||
mCachedStyleData.mResetData = new (presContext.get()) nsResetStyleData;
|
mCachedStyleData.mResetData = new (presContext) nsResetStyleData;
|
||||||
resetOrInherit = NS_REINTERPRET_CAST(char*, mCachedStyleData.mResetData);
|
resetOrInherit = NS_REINTERPRET_CAST(char*, mCachedStyleData.mResetData);
|
||||||
} else {
|
} else {
|
||||||
mCachedStyleData.mInheritedData =
|
mCachedStyleData.mInheritedData =
|
||||||
new (presContext.get()) nsInheritedStyleData;
|
new (presContext) nsInheritedStyleData;
|
||||||
resetOrInherit =
|
resetOrInherit =
|
||||||
NS_REINTERPRET_CAST(char*, mCachedStyleData.mInheritedData);
|
NS_REINTERPRET_CAST(char*, mCachedStyleData.mInheritedData);
|
||||||
}
|
}
|
||||||
|
@ -553,8 +552,7 @@ void nsStyleContext::List(FILE* out, PRInt32 aIndent)
|
||||||
fputs("{\n", out);
|
fputs("{\n", out);
|
||||||
nsRuleNode* ruleNode = mRuleNode;
|
nsRuleNode* ruleNode = mRuleNode;
|
||||||
while (ruleNode) {
|
while (ruleNode) {
|
||||||
nsCOMPtr<nsIStyleRule> styleRule;
|
nsIStyleRule *styleRule = ruleNode->GetRule();
|
||||||
ruleNode->GetRule(getter_AddRefs(styleRule));
|
|
||||||
if (styleRule) {
|
if (styleRule) {
|
||||||
styleRule->List(out, aIndent + 1);
|
styleRule->List(out, aIndent + 1);
|
||||||
}
|
}
|
||||||
|
@ -838,8 +836,7 @@ void
|
||||||
nsStyleContext::Destroy()
|
nsStyleContext::Destroy()
|
||||||
{
|
{
|
||||||
// Get the pres context from our rule node.
|
// Get the pres context from our rule node.
|
||||||
nsCOMPtr<nsIPresContext> presContext;
|
nsCOMPtr<nsIPresContext> presContext = mRuleNode->GetPresContext();
|
||||||
mRuleNode->GetPresContext(getter_AddRefs(presContext));
|
|
||||||
|
|
||||||
// Call our destructor.
|
// Call our destructor.
|
||||||
this->~nsStyleContext();
|
this->~nsStyleContext();
|
||||||
|
|
|
@ -88,7 +88,7 @@ public:
|
||||||
|
|
||||||
void SetStyle(nsStyleStructID aSID, nsStyleStruct* aStruct);
|
void SetStyle(nsStyleStructID aSID, nsStyleStruct* aStruct);
|
||||||
|
|
||||||
void GetRuleNode(nsRuleNode** aResult) { *aResult = mRuleNode; }
|
nsRuleNode* GetRuleNode() { return mRuleNode; }
|
||||||
void AddStyleBit(const PRUint32& aBit) { mBits |= aBit; }
|
void AddStyleBit(const PRUint32& aBit) { mBits |= aBit; }
|
||||||
void GetStyleBits(PRUint32* aBits) { *aBits = mBits; }
|
void GetStyleBits(PRUint32* aBits) { *aBits = mBits; }
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ struct nsRuleNodeList
|
||||||
void Destroy() {
|
void Destroy() {
|
||||||
if (mNext)
|
if (mNext)
|
||||||
mNext->Destroy();
|
mNext->Destroy();
|
||||||
mRuleNode->PresContext()->FreeToShell(sizeof(nsRuleNodeList), this);
|
mRuleNode->GetPresContext()->FreeToShell(sizeof(nsRuleNodeList), this);
|
||||||
};
|
};
|
||||||
|
|
||||||
nsRuleNode* mRuleNode;
|
nsRuleNode* mRuleNode;
|
||||||
|
@ -1041,8 +1041,7 @@ StyleSetImpl::AddImportantRules(nsRuleNode* aCurrLevelNode,
|
||||||
|
|
||||||
AddImportantRules(aCurrLevelNode->GetParent(), aLastPrevLevelNode);
|
AddImportantRules(aCurrLevelNode->GetParent(), aLastPrevLevelNode);
|
||||||
|
|
||||||
nsCOMPtr<nsIStyleRule> rule;;
|
nsIStyleRule *rule = aCurrLevelNode->GetRule();
|
||||||
aCurrLevelNode->GetRule(getter_AddRefs(rule));
|
|
||||||
nsCOMPtr<nsICSSStyleRule> cssRule(do_QueryInterface(rule));
|
nsCOMPtr<nsICSSStyleRule> cssRule(do_QueryInterface(rule));
|
||||||
if (cssRule) {
|
if (cssRule) {
|
||||||
nsCOMPtr<nsIStyleRule> impRule = cssRule->GetImportantRule();
|
nsCOMPtr<nsIStyleRule> impRule = cssRule->GetImportantRule();
|
||||||
|
@ -1518,8 +1517,7 @@ StyleSetImpl::ReParentStyleContext(nsIPresContext* aPresContext,
|
||||||
else { // really a new parent
|
else { // really a new parent
|
||||||
nsCOMPtr<nsIAtom> pseudoTag = aStyleContext->GetPseudoType();
|
nsCOMPtr<nsIAtom> pseudoTag = aStyleContext->GetPseudoType();
|
||||||
|
|
||||||
nsRuleNode* ruleNode;
|
nsRuleNode* ruleNode = aStyleContext->GetRuleNode();
|
||||||
aStyleContext->GetRuleNode(&ruleNode);
|
|
||||||
EnsureRuleWalker(aPresContext);
|
EnsureRuleWalker(aPresContext);
|
||||||
NS_ENSURE_TRUE(mRuleWalker, nsnull);
|
NS_ENSURE_TRUE(mRuleWalker, nsnull);
|
||||||
mRuleWalker->SetCurrentNode(ruleNode);
|
mRuleWalker->SetCurrentNode(ruleNode);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче