Fix for 104336, deCOMtaminate rulenode, rulewalker, frames, r=dbaron, sr=waterson

git-svn-id: svn://10.0.0.236/trunk@106100 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
hyatt%netscape.com 2001-10-24 00:01:09 +00:00
parent d06349b965
commit ab0e4e56d4
110 changed files with 1813 additions and 1326 deletions

View File

@ -51,7 +51,7 @@ class nsIContent;
class nsISupportsArray;
class nsIAtom;
class nsICSSPseudoComparator;
class nsIRuleWalker;
class nsRuleWalker;
// IID for the nsIStyleRuleProcessor interface {015575fe-7b6c-11d3-ba05-001083023c2b}
#define NS_ISTYLE_RULE_PROCESSOR_IID \
@ -73,7 +73,7 @@ public:
nsIAtom* aMedium,
nsIContent* aContent,
nsIStyleContext* aParentContext,
nsIRuleWalker* aRuleWalker) = 0;
nsRuleWalker* aRuleWalker) = 0;
NS_IMETHOD RulesMatching(nsIPresContext* aPresContext,
nsIAtom* aMedium,
@ -81,7 +81,7 @@ public:
nsIAtom* aPseudoTag,
nsIStyleContext* aParentContext,
nsICSSPseudoComparator* aComparator,
nsIRuleWalker* aRuleWalker) = 0;
nsRuleWalker* aRuleWalker) = 0;
// Test if style is dependent on content state
NS_IMETHOD HasStateDependentStyle(nsIPresContext* aPresContext,

View File

@ -44,7 +44,7 @@ class nsString;
class nsIStyleRule;
class nsIStyleContext;
class nsISupportsArray;
class nsIRuleWalker;
class nsRuleWalker;
// IID for the nsIStyledContent class
#define NS_ISTYLEDCONTENT_IID \
@ -60,8 +60,8 @@ public:
NS_IMETHOD GetClasses(nsVoidArray& aArray) const = 0;
NS_IMETHOD HasClass(nsIAtom* aClass, PRBool aCaseSensitive) const = 0;
NS_IMETHOD WalkContentStyleRules(nsIRuleWalker* aRuleWalker) = 0;
NS_IMETHOD WalkInlineStyleRules(nsIRuleWalker* aRuleWalker) = 0;
NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker) = 0;
NS_IMETHOD WalkInlineStyleRules(nsRuleWalker* aRuleWalker) = 0;
/** NRA ***
* Get a hint that tells the style system what to do when

View File

@ -55,7 +55,6 @@
#include "nsIStyleSet.h"
#include "nsIStyleSheet.h"
#include "nsICSSStyleSheet.h"
#include "nsIStyleContext.h"
#include "nsIFrame.h"
#include "nsIScriptGlobalObjectOwner.h"

View File

@ -1954,13 +1954,13 @@ nsGenericElement::HasClass(nsIAtom* aClass, PRBool aCaseSensitive) const
}
NS_IMETHODIMP
nsGenericElement::WalkContentStyleRules(nsIRuleWalker* aRuleWalker)
nsGenericElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker)
{
return NS_OK;
}
NS_IMETHODIMP
nsGenericElement::WalkInlineStyleRules(nsIRuleWalker* aRuleWalker)
nsGenericElement::WalkInlineStyleRules(nsRuleWalker* aRuleWalker)
{
return NS_ERROR_NOT_IMPLEMENTED;
}

View File

@ -294,8 +294,8 @@ public:
NS_IMETHOD GetID(nsIAtom*& aResult) const;
NS_IMETHOD GetClasses(nsVoidArray& aArray) const;
NS_IMETHOD HasClass(nsIAtom* aClass, PRBool aCaseSensitive) const;
NS_IMETHOD WalkContentStyleRules(nsIRuleWalker* aRuleWalker);
NS_IMETHOD WalkInlineStyleRules(nsIRuleWalker* aRuleWalker);
NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker);
NS_IMETHOD WalkInlineStyleRules(nsRuleWalker* aRuleWalker);
NS_IMETHOD GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType,
PRInt32& aHint) const;

View File

@ -38,7 +38,6 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsString.h"
#include "nsUnitConversion.h"
@ -70,7 +69,7 @@ class nsStyleContext : public nsIStyleContext
{
public:
nsStyleContext(nsIStyleContext* aParent, nsIAtom* aPseudoTag,
nsIRuleNode* aRuleNode,
nsRuleNode* aRuleNode,
nsIPresContext* aPresContext);
virtual ~nsStyleContext();
@ -84,7 +83,7 @@ public:
NS_IMETHOD GetPseudoType(nsIAtom*& aPseudoTag) const;
NS_IMETHOD FindChildWithRules(const nsIAtom* aPseudoTag, nsIRuleNode* aRules,
NS_IMETHOD FindChildWithRules(const nsIAtom* aPseudoTag, nsRuleNode* aRules,
nsIStyleContext*& aResult);
virtual PRBool Equals(const nsIStyleContext* aOther) const;
@ -95,13 +94,15 @@ public:
NS_IMETHOD GetStyle(nsStyleStructID aSID, const nsStyleStruct** aStruct);
NS_IMETHOD SetStyle(nsStyleStructID aSID, const nsStyleStruct& aStruct);
NS_IMETHOD GetRuleNode(nsIRuleNode** aResult) { *aResult = mRuleNode; NS_IF_ADDREF(*aResult); return NS_OK; };
NS_IMETHOD GetRuleNode(nsRuleNode** aResult) { *aResult = mRuleNode; return NS_OK; };
NS_IMETHOD AddStyleBit(const PRUint32& aBit) { mBits |= aBit; return NS_OK; };
NS_IMETHOD GetStyleBits(PRUint32* aBits) { *aBits = mBits; return NS_OK; };
virtual const nsStyleStruct* GetStyleData(nsStyleStructID aSID);
virtual nsStyleStruct* GetUniqueStyleData(nsIPresContext* aPresContext, const nsStyleStructID& aSID);
virtual nsresult ClearCachedDataForRule(nsIStyleRule* aRule);
virtual nsresult ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule);
virtual void ForceUnique(void);
@ -130,7 +131,7 @@ protected:
nsIAtom* mPseudoTag;
PRUint32 mBits; // Which structs are inherited from the parent context.
nsIRuleNode* mRuleNode; // Weak. Rules can't go away without us going away.
nsRuleNode* mRuleNode;
nsCachedStyleData mCachedStyleData; // Our cached style data.
};
@ -138,7 +139,7 @@ static PRInt32 gLastDataCode;
nsStyleContext::nsStyleContext(nsIStyleContext* aParent,
nsIAtom* aPseudoTag,
nsIRuleNode* aRuleNode,
nsRuleNode* aRuleNode,
nsIPresContext* aPresContext)
: mParent((nsStyleContext*)aParent),
mChild(nsnull),
@ -219,12 +220,10 @@ nsStyleContext::GetFirstChild(nsIStyleContext** aContext)
void nsStyleContext::AppendChild(nsStyleContext* aChild)
{
PRBool isRoot = PR_FALSE;
nsCOMPtr<nsIRuleNode> ruleNode;
aChild->GetRuleNode(getter_AddRefs(ruleNode));
ruleNode->IsRoot(&isRoot);
if (isRoot) {
nsRuleNode* ruleNode;
aChild->GetRuleNode(&ruleNode);
if (ruleNode->IsRoot()) {
// We matched no rules.
if (nsnull == mEmptyChild) {
mEmptyChild = aChild;
@ -257,12 +256,10 @@ void nsStyleContext::RemoveChild(nsStyleContext* aChild)
return;
}
PRBool isRoot = PR_FALSE;
nsCOMPtr<nsIRuleNode> ruleNode;
aChild->GetRuleNode(getter_AddRefs(ruleNode));
ruleNode->IsRoot(&isRoot);
if (isRoot) { // is empty
nsRuleNode* ruleNode;
aChild->GetRuleNode(&ruleNode);
if (ruleNode->IsRoot()) { // is empty
if (aChild->mPrevSibling != aChild) { // has siblings
if (mEmptyChild == aChild) {
mEmptyChild = mEmptyChild->mNextSibling;
@ -302,7 +299,7 @@ nsStyleContext::GetPseudoType(nsIAtom*& aPseudoTag) const
NS_IMETHODIMP
nsStyleContext::FindChildWithRules(const nsIAtom* aPseudoTag,
nsIRuleNode* aRuleNode,
nsRuleNode* aRuleNode,
nsIStyleContext*& aResult)
{
PRUint32 threshold = 10; // The # of siblings we're willing to examine
@ -312,9 +309,7 @@ nsStyleContext::FindChildWithRules(const nsIAtom* aPseudoTag,
if ((nsnull != mChild) || (nsnull != mEmptyChild)) {
nsStyleContext* child;
PRBool isRoot = PR_TRUE;
aRuleNode->IsRoot(&isRoot);
if (isRoot) {
if (aRuleNode->IsRoot()) {
if (nsnull != mEmptyChild) {
child = mEmptyChild;
do {
@ -568,6 +563,17 @@ nsStyleContext::ApplyStyleFixups(nsIPresContext* aPresContext)
}
}
nsresult
nsStyleContext::ClearCachedDataForRule(nsIStyleRule* aInlineStyleRule)
{
mRuleNode->ClearCachedData(aInlineStyleRule); // XXXdwh. If we're willing to *really* special case
// inline style, we could only invalidate the struct data
// that actually changed. For example, if someone changes
// style.left, we really only need to blow away cached
// data in the position struct.
return NS_OK;
}
nsresult
nsStyleContext::ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule)
{
@ -846,19 +852,16 @@ void nsStyleContext::List(FILE* out, PRInt32 aIndent)
fputs(" ", out);
}
nsCOMPtr<nsIRuleNode> ruleNode;
GetRuleNode(getter_AddRefs(ruleNode));
if (ruleNode) {
if (mRuleNode) {
fputs("{\n", out);
nsRuleNode* ruleNode = mRuleNode;
while (ruleNode) {
nsCOMPtr<nsIStyleRule> styleRule;
ruleNode->GetRule(getter_AddRefs(styleRule));
if (styleRule) {
styleRule->List(out, aIndent + 1);
}
nsIRuleNode* parent;
ruleNode->GetParent(&parent);
ruleNode = dont_AddRef(parent);
ruleNode = ruleNode->GetParent();
}
for (ix = aIndent; --ix >= 0; ) fputs(" ", out);
fputs("}\n", out);
@ -1206,7 +1209,7 @@ NS_EXPORT nsresult
NS_NewStyleContext(nsIStyleContext** aInstancePtrResult,
nsIStyleContext* aParentContext,
nsIAtom* aPseudoTag,
nsIRuleNode* aRuleNode,
nsRuleNode* aRuleNode,
nsIPresContext* aPresContext)
{
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
@ -1215,7 +1218,7 @@ NS_NewStyleContext(nsIStyleContext** aInstancePtrResult,
}
nsStyleContext* context = new (aPresContext) nsStyleContext(aParentContext, aPseudoTag,
aRuleNode, aPresContext);
aRuleNode, aPresContext);
if (nsnull == context) {
return NS_ERROR_OUT_OF_MEMORY;
}

View File

@ -42,7 +42,6 @@
#include "nsIStyleRuleProcessor.h"
#include "nsIStyleRule.h"
#include "nsICSSStyleRule.h"
#include "nsIStyleContext.h"
#include "nsISupportsArray.h"
#include "nsIFrame.h"
#include "nsIPresContext.h"
@ -56,7 +55,7 @@
#include "nsNetUtil.h"
#include "nsIStyleRuleSupplier.h"
#include "nsRuleNode.h"
#include "nsIRuleWalker.h"
#include "nsRuleWalker.h"
#include "nsIBodySuper.h"
#include "nsIHTMLDocument.h"
#include "nsIDOMHTMLBodyElement.h"
@ -134,7 +133,9 @@ public:
NS_IMETHOD Shutdown();
virtual nsresult GetRuleTree(nsIRuleNode** aResult);
virtual nsresult GetRuleTree(nsRuleNode** aResult);
virtual nsresult ClearCachedDataInRuleTree(nsIStyleRule* aRule);
virtual nsresult ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule, nsIStyleContext* aContext);
virtual nsresult RemoveBodyFixupRule(nsIDocument *aDocument);
@ -232,7 +233,7 @@ public:
#endif
virtual void ResetUniqueStyleItems(void);
void AddImportantRules(nsIRuleNode* aRuleNode);
void AddImportantRules(nsRuleNode* aRuleNode);
#ifdef MOZ_PERF_METRICS
NS_DECL_NSITIMERECORDER
@ -290,10 +291,10 @@ protected:
nsCOMPtr<nsIStyleRuleSupplier> mStyleRuleSupplier;
nsCOMPtr<nsIRuleNode> mRuleTree; // This is the root of our rule tree. It is a lexicographic tree of
// matched rules that style contexts use to look up properties.
nsCOMPtr<nsIRuleWalker> mRuleWalker; // This is an instance of a rule walker that can be used
// to navigate through our tree.
nsRuleNode* mRuleTree; // This is the root of our rule tree. It is a lexicographic tree of
// matched rules that style contexts use to look up properties.
nsRuleWalker* mRuleWalker; // This is an instance of a rule walker that can be used
// to navigate through our tree.
MOZ_TIMER_DECLARE(mStyleResolutionWatch)
@ -316,7 +317,9 @@ StyleSetImpl::StyleSetImpl()
mRecycler(nsnull),
mFrameConstructor(nsnull),
mQuirkStyleSheet(nsnull),
mStyleRuleSupplier(nsnull)
mStyleRuleSupplier(nsnull),
mRuleTree(nsnull),
mRuleWalker(nsnull)
#ifdef MOZ_PERF_METRICS
,mTimerEnabled(PR_FALSE)
#endif
@ -746,7 +749,7 @@ struct RulesMatchingData {
nsIAtom* aMedium,
nsIContent* aContent,
nsIStyleContext* aParentContext,
nsIRuleWalker* aRuleWalker)
nsRuleWalker* aRuleWalker)
: mPresContext(aPresContext),
mMedium(aMedium),
mContent(aContent),
@ -758,7 +761,7 @@ struct RulesMatchingData {
nsIAtom* mMedium;
nsIContent* mContent;
nsIStyleContext* mParentContext;
nsCOMPtr<nsIRuleWalker> mRuleWalker;
nsRuleWalker* mRuleWalker;
};
static PRBool
@ -779,8 +782,7 @@ nsIStyleContext* StyleSetImpl::GetContext(nsIPresContext* aPresContext,
{
nsIStyleContext* result = nsnull;
nsCOMPtr<nsIRuleNode> ruleNode;
mRuleWalker->GetCurrentNode(getter_AddRefs(ruleNode));
nsRuleNode* ruleNode = mRuleWalker->GetCurrentNode();
if ((PR_FALSE == aForceUnique) && (nsnull != aParentContext)) {
aParentContext->FindChildWithRules(aPseudoTag, ruleNode, result);
@ -805,12 +807,11 @@ nsIStyleContext* StyleSetImpl::GetContext(nsIPresContext* aPresContext,
}
void
StyleSetImpl::AddImportantRules(nsIRuleNode* aCurrNode)
StyleSetImpl::AddImportantRules(nsRuleNode* aCurrNode)
{
// XXX Note: this is still incorrect from a cascade standpoint, but
// it preserves the existing incorrect cascade behavior.
nsCOMPtr<nsIRuleNode> parent;
aCurrNode->GetParent(getter_AddRefs(parent));
nsRuleNode* parent = aCurrNode->GetParent();
if (parent)
AddImportantRules(parent);
@ -839,8 +840,8 @@ void StyleSetImpl::EnsureRuleWalker(nsIPresContext* aPresContext)
if (mRuleWalker)
return;
nsRuleNode::CreateRootNode(aPresContext, getter_AddRefs(mRuleTree));
NS_NewRuleWalker(mRuleTree, getter_AddRefs(mRuleWalker));
nsRuleNode::CreateRootNode(aPresContext, &mRuleTree);
mRuleWalker = new nsRuleWalker(mRuleTree);
}
nsIStyleContext* StyleSetImpl::ResolveStyleFor(nsIPresContext* aPresContext,
@ -866,8 +867,7 @@ nsIStyleContext* StyleSetImpl::ResolveStyleFor(nsIPresContext* aPresContext,
WalkRuleProcessors(EnumRulesMatching, &data, aContent);
// Walk all of the rules and add in the !important counterparts.
nsCOMPtr<nsIRuleNode> ruleNode;
mRuleWalker->GetCurrentNode(getter_AddRefs(ruleNode));
nsRuleNode* ruleNode = mRuleWalker->GetCurrentNode();
AddImportantRules(ruleNode);
result = GetContext(aPresContext, aParentContext, nsnull, aForceUnique);
@ -888,7 +888,7 @@ struct PseudoRulesMatchingData {
nsIAtom* aPseudoTag,
nsIStyleContext* aParentContext,
nsICSSPseudoComparator* aComparator,
nsIRuleWalker* aWalker)
nsRuleWalker* aWalker)
: mPresContext(aPresContext),
mMedium(aMedium),
mParentContent(aParentContent),
@ -904,7 +904,7 @@ struct PseudoRulesMatchingData {
nsIAtom* mPseudoTag;
nsIStyleContext* mParentContext;
nsICSSPseudoComparator* mComparator;
nsCOMPtr<nsIRuleWalker> mRuleWalker;
nsRuleWalker* mRuleWalker;
};
static PRBool
@ -945,8 +945,7 @@ nsIStyleContext* StyleSetImpl::ResolvePseudoStyleFor(nsIPresContext* aPresContex
WalkRuleProcessors(EnumPseudoRulesMatching, &data, aParentContent);
// Walk all of the rules and add in the !important counterparts.
nsCOMPtr<nsIRuleNode> ruleNode;
mRuleWalker->GetCurrentNode(getter_AddRefs(ruleNode));
nsRuleNode* ruleNode = mRuleWalker->GetCurrentNode();
AddImportantRules(ruleNode);
result = GetContext(aPresContext, aParentContext, aPseudoTag, aForceUnique);
@ -985,12 +984,9 @@ nsIStyleContext* StyleSetImpl::ProbePseudoStyleFor(nsIPresContext* aPresContext,
WalkRuleProcessors(EnumPseudoRulesMatching, &data, aParentContent);
// Walk all of the rules and add in the !important counterparts.
nsCOMPtr<nsIRuleNode> ruleNode;
mRuleWalker->GetCurrentNode(getter_AddRefs(ruleNode));
nsRuleNode* ruleNode = mRuleWalker->GetCurrentNode();
AddImportantRules(ruleNode);
PRBool isAtRoot = PR_FALSE;
mRuleWalker->AtRoot(&isAtRoot);
if (!isAtRoot)
if (!mRuleWalker->AtRoot())
result = GetContext(aPresContext, aParentContext, aPseudoTag, aForceUnique);
// Now reset the walker back to the root of the tree.
@ -1006,16 +1002,24 @@ nsIStyleContext* StyleSetImpl::ProbePseudoStyleFor(nsIPresContext* aPresContext,
NS_IMETHODIMP
StyleSetImpl::Shutdown()
{
mRuleWalker = nsnull; // Drop our ref. This destroys all rule nodes.
delete mRuleWalker;
mRuleTree->Destroy();
mRuleTree = nsnull;
return NS_OK;
}
nsresult
StyleSetImpl::GetRuleTree(nsIRuleNode** aResult)
StyleSetImpl::GetRuleTree(nsRuleNode** aResult)
{
*aResult = mRuleTree;
NS_IF_ADDREF(*aResult);
return NS_OK;
}
nsresult
StyleSetImpl::ClearCachedDataInRuleTree(nsIStyleRule* aInlineStyleRule)
{
if (mRuleTree)
mRuleTree->ClearCachedDataInSubtree(aInlineStyleRule);
return NS_OK;
}
@ -1028,8 +1032,8 @@ StyleSetImpl::ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule,
// style.left, we really only need to blow away cached
// data in the position struct.
if (aContext) {
nsCOMPtr<nsIRuleNode> ruleNode;
aContext->GetRuleNode(getter_AddRefs(ruleNode));
nsRuleNode* ruleNode;
aContext->GetRuleNode(&ruleNode);
ruleNode->ClearCachedData(aRule);
// We don't need to mess with the style tree in this case, since the act of
@ -1109,8 +1113,8 @@ StyleSetImpl::ReParentStyleContext(nsIPresContext* aPresContext,
nsIAtom* pseudoTag = nsnull;
aStyleContext->GetPseudoType(pseudoTag);
nsCOMPtr<nsIRuleNode> ruleNode;
aStyleContext->GetRuleNode(getter_AddRefs(ruleNode));
nsRuleNode* ruleNode;
aStyleContext->GetRuleNode(&ruleNode);
if (aNewParentContext) {
result = aNewParentContext->FindChildWithRules(pseudoTag, ruleNode, newChild);
}

View File

@ -63,7 +63,6 @@
#include "nsILinkHandler.h"
#include "nsPIDOMWindow.h"
#include "nsISizeOfHandler.h"
#include "nsIStyleContext.h"
#include "nsIStyleRule.h"
#include "nsISupportsArray.h"
#include "nsIURL.h"
@ -112,7 +111,7 @@
#include "nsIBindingManager.h"
#include "nsIXBLBinding.h"
#include "nsIRuleWalker.h"
#include "nsRuleWalker.h"
#include "nsIObjectFrame.h"
#include "nsLayoutAtoms.h"
@ -2400,7 +2399,7 @@ nsGenericHTMLElement::HasClass(nsIAtom* aClass, PRBool aCaseSensitive) const
}
nsresult
nsGenericHTMLElement::WalkContentStyleRules(nsIRuleWalker* aRuleWalker)
nsGenericHTMLElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker)
{
nsresult result = NS_OK;
@ -2416,7 +2415,7 @@ nsGenericHTMLElement::WalkContentStyleRules(nsIRuleWalker* aRuleWalker)
}
nsresult
nsGenericHTMLElement::WalkInlineStyleRules(nsIRuleWalker* aRuleWalker)
nsGenericHTMLElement::WalkInlineStyleRules(nsRuleWalker* aRuleWalker)
{
nsresult result = NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIStyleRule> rule;

View File

@ -182,8 +182,8 @@ public:
NS_IMETHOD GetID(nsIAtom*& aResult) const;
NS_IMETHOD GetClasses(nsVoidArray& aArray) const;
NS_IMETHOD HasClass(nsIAtom* aClass, PRBool aCaseSensitive) const;
NS_IMETHOD WalkContentStyleRules(nsIRuleWalker* aRuleWalker);
NS_IMETHOD WalkInlineStyleRules(nsIRuleWalker* aRuleWalker);
NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker);
NS_IMETHOD WalkInlineStyleRules(nsRuleWalker* aRuleWalker);
NS_IMETHOD GetBaseURL(nsIURI*& aBaseURL) const;
NS_IMETHOD GetBaseTarget(nsAWritableString& aBaseTarget) const;

View File

@ -48,7 +48,6 @@
#include "nsILink.h"
#include "nsHTMLAtoms.h"
#include "nsHTMLIIDs.h"
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
#include "nsIEventStateManager.h"

View File

@ -45,7 +45,7 @@
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
#include "nsIHTMLAttributes.h"
#include "nsIRuleNode.h"
#include "nsRuleNode.h"
class nsHTMLBRElement : public nsGenericHTMLLeafElement,
public nsIDOMHTMLBRElement

View File

@ -68,7 +68,7 @@
#include "nsISizeOfHandler.h"
#include "nsIView.h"
#include "nsLayoutAtoms.h"
#include "nsIRuleWalker.h"
#include "nsRuleWalker.h"
#include "nsIBodySuper.h"
//----------------------------------------------------------------------
@ -233,8 +233,8 @@ public:
const nsAReadableString& aValue,
nsHTMLValue& aResult);
NS_IMETHOD GetAttributeMappingFunction(nsMapRuleToAttributesFunc& aMapRuleFunc) const;
NS_IMETHOD WalkContentStyleRules(nsIRuleWalker* aRuleWalker);
NS_IMETHOD WalkInlineStyleRules(nsIRuleWalker* aRuleWalker);
NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker);
NS_IMETHOD WalkInlineStyleRules(nsRuleWalker* aRuleWalker);
NS_IMETHOD GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType,
PRInt32& aHint) const;
#ifdef DEBUG
@ -995,7 +995,7 @@ static nsIHTMLStyleSheet* GetAttrStyleSheet(nsIDocument* aDocument)
}
NS_IMETHODIMP
nsHTMLBodyElement::WalkContentStyleRules(nsIRuleWalker* aRuleWalker)
nsHTMLBodyElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker)
{
nsBodySuper::WalkContentStyleRules(aRuleWalker);
@ -1032,7 +1032,7 @@ static nsIHTMLCSSStyleSheet* GetInlineStyleSheet(nsIDocument* aDocument)
}
NS_IMETHODIMP
nsHTMLBodyElement::WalkInlineStyleRules(nsIRuleWalker* aRuleWalker)
nsHTMLBodyElement::WalkInlineStyleRules(nsRuleWalker* aRuleWalker)
{
PRBool useBodyFixupRule = PR_FALSE;

View File

@ -50,6 +50,7 @@
#include "nsIForm.h"
#include "nsIURL.h"
#include "nsIFrame.h"
#include "nsIFormControlFrame.h"
#include "nsIEventStateManager.h"
#include "nsIDOMEvent.h"

View File

@ -45,7 +45,7 @@
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
#include "nsIHTMLAttributes.h"
#include "nsIRuleNode.h"
#include "nsRuleNode.h"
// XXX nav4 has type= start= (same as OL/UL)

View File

@ -45,7 +45,7 @@
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
#include "nsIHTMLAttributes.h"
#include "nsIRuleNode.h"
#include "nsRuleNode.h"
// XXX support missing nav attributes? gutter, cols, width

View File

@ -49,7 +49,7 @@
#include "nsIPresContext.h"
#include "nsIHTMLAttributes.h"
#include "nsICSSDeclaration.h"
#include "nsIRuleNode.h"
#include "nsRuleNode.h"
class nsHTMLFontElement : public nsGenericHTMLContainerElement,
public nsIDOMHTMLFontElement

View File

@ -45,7 +45,7 @@
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
#include "nsIHTMLAttributes.h"
#include "nsIRuleNode.h"
#include "nsRuleNode.h"
class nsHTMLHRElement : public nsGenericHTMLLeafElement,
public nsIDOMHTMLHRElement

View File

@ -45,7 +45,7 @@
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
#include "nsIHTMLAttributes.h"
#include "nsIRuleNode.h"
#include "nsRuleNode.h"
class nsHTMLHeadingElement : public nsGenericHTMLContainerElement,
public nsIDOMHTMLHeadingElement

View File

@ -53,7 +53,7 @@
#include "nsIHTMLAttributes.h"
#include "nsIChromeEventHandler.h"
#include "nsDOMError.h"
#include "nsIRuleNode.h"
#include "nsRuleNode.h"
class nsHTMLIFrameElement : public nsGenericHTMLContainerElement,
public nsIDOMHTMLIFrameElement,

View File

@ -76,7 +76,7 @@
#include "nsILoadGroup.h"
#include "nsIRuleNode.h"
#include "nsRuleNode.h"
#include "nsIJSContextStack.h"

View File

@ -84,7 +84,7 @@
#include "nsIDOMEventReceiver.h"
#include "nsMutationEvent.h"
#include "nsIRuleNode.h"
#include "nsRuleNode.h"
// XXX align=left, hspace, vspace, border? other nav4 attrs

View File

@ -45,7 +45,7 @@
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
#include "nsIHTMLAttributes.h"
#include "nsIRuleNode.h"
#include "nsRuleNode.h"
class nsHTMLLIElement : public nsGenericHTMLContainerElement,
public nsIDOMHTMLLIElement

View File

@ -45,7 +45,7 @@
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
#include "nsIHTMLAttributes.h"
#include "nsIRuleNode.h"
#include "nsRuleNode.h"
// XXX nav4 has type= start= (same as OL/UL)

View File

@ -45,7 +45,7 @@
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
#include "nsIHTMLAttributes.h"
#include "nsIRuleNode.h"
#include "nsRuleNode.h"
class nsHTMLOListElement : public nsGenericHTMLContainerElement,
public nsIDOMHTMLOListElement

View File

@ -45,7 +45,7 @@
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
#include "nsIHTMLAttributes.h"
#include "nsIRuleNode.h"
#include "nsRuleNode.h"
// XXX missing nav attributes

View File

@ -45,7 +45,7 @@
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
#include "nsIHTMLAttributes.h"
#include "nsIRuleNode.h"
#include "nsRuleNode.h"
#include "nsICSSDeclaration.h"
// XXX wrap, variable, cols, tabstop

View File

@ -72,7 +72,7 @@
#include "nsIFormControlFrame.h"
#include "nsIFrame.h"
#include "nsIRuleNode.h"
#include "nsRuleNode.h"
class nsHTMLSelectElement;

View File

@ -58,7 +58,7 @@
#include "nsIWebShell.h"
#include "nsIFrame.h"
#include "nsLayoutAtoms.h"
#include "nsIRuleNode.h"
#include "nsRuleNode.h"
// XXX nav attrs: suppress

View File

@ -45,7 +45,7 @@
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
#include "nsIHTMLAttributes.h"
#include "nsIRuleNode.h"
#include "nsRuleNode.h"
class nsHTMLTableCaptionElement : public nsGenericHTMLContainerElement,
public nsIDOMHTMLTableCaptionElement

View File

@ -48,7 +48,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
#include "nsIRuleNode.h"
#include "nsRuleNode.h"
class nsHTMLTableCellElement : public nsGenericHTMLContainerElement,
public nsIHTMLTableCellElement,
@ -84,7 +84,7 @@ public:
const nsHTMLValue& aValue,
nsAWritableString& aResult) const;
NS_IMETHOD GetAttributeMappingFunction(nsMapRuleToAttributesFunc& aMapRuleFunc) const;
NS_IMETHOD WalkContentStyleRules(nsIRuleWalker* aRuleWalker);
NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker);
NS_IMETHOD GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType,
PRInt32& aHint) const;
#ifdef DEBUG
@ -248,7 +248,7 @@ nsHTMLTableCellElement::GetCellIndex(PRInt32* aCellIndex)
NS_IMETHODIMP
nsHTMLTableCellElement::WalkContentStyleRules(nsIRuleWalker* aRuleWalker)
nsHTMLTableCellElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker)
{
// get table, add its rules too
// XXX can we safely presume structure or do we need to QI on the way up?

View File

@ -46,7 +46,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
#include "nsIRuleNode.h"
#include "nsRuleNode.h"
class nsHTMLTableColElement : public nsGenericHTMLContainerElement,
public nsIDOMHTMLTableColElement,

View File

@ -45,7 +45,7 @@
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
#include "nsIRuleNode.h"
#include "nsRuleNode.h"
class nsHTMLTableColGroupElement : public nsGenericHTMLContainerElement,
public nsIDOMHTMLTableColElement

View File

@ -51,7 +51,7 @@
#include "nsIPresContext.h"
#include "nsHTMLParts.h"
#include "nsStyleUtil.h"
#include "nsIRuleNode.h"
#include "nsRuleNode.h"
/* for collections */
#include "nsIDOMElement.h"

View File

@ -50,7 +50,7 @@
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
#include "nsHTMLParts.h"
#include "nsIRuleNode.h"
#include "nsRuleNode.h"
// temporary
#include "nsIDocument.h"

View File

@ -47,7 +47,7 @@
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
#include "GenericElementCollection.h"
#include "nsIRuleNode.h"
#include "nsRuleNode.h"
// you will see the phrases "rowgroup" and "section" used interchangably

View File

@ -65,7 +65,7 @@
#include "nsIFormControlFrame.h"
#include "nsIPrivateDOMEvent.h"
#include "nsGUIEvent.h"
#include "nsIRuleNode.h"
#include "nsRuleNode.h"
static NS_DEFINE_CID(kXULControllersCID, NS_XULCONTROLLERS_CID);

View File

@ -45,7 +45,7 @@
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
#include "nsIHTMLAttributes.h"
#include "nsIRuleNode.h"
#include "nsRuleNode.h"
extern nsGenericHTMLElement::EnumTable kListTypeTable[];
extern nsGenericHTMLElement::EnumTable kOldListTypeTable[];

View File

@ -7,6 +7,4 @@ nsICSSLoaderObserver.h
nsICSSParser.h
nsICSSPseudoComparator.h
nsICSSStyleSheet.h
nsIRuleWalker.h
nsIRuleNode.h
nsIMediaList.h

View File

@ -35,9 +35,7 @@ EXPORTS = \
nsICSSStyleSheet.h \
nsICSSLoaderObserver.h \
nsIComputedDOMStyle.h \
nsIRuleNode.h \
nsIRuleWalker.h \
nsIMediaList.h \
nsIMediaList.h \
$(NULL)
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))

View File

@ -21,7 +21,7 @@
DEPTH=..\..\..\..
EXPORTS=nsICSSLoader.h nsICSSParser.h nsICSSPseudoComparator.h nsICSSStyleSheet.h nsICSSLoaderObserver.h nsIComputedDOMStyle.h nsIRuleNode.h nsIRuleWalker.h nsIMediaList.h
EXPORTS=nsICSSLoader.h nsICSSParser.h nsICSSPseudoComparator.h nsICSSStyleSheet.h nsICSSLoaderObserver.h nsIComputedDOMStyle.h nsIMediaList.h
MODULE=content
include <$(DEPTH)\config\rules.mak>

View File

@ -1,333 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Original Author: David W. Hyatt (hyatt@netscape.com)
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsIRuleNode_h___
#define nsIRuleNode_h___
#include "nsCOMPtr.h"
#include "nsHashtable.h"
#include "nsIStyleRule.h"
#include "nsIStyleContext.h"
#include "nsICSSDeclaration.h"
class nsIHTMLMappedAttributes;
typedef void (*nsPostResolveFunc)(nsStyleStruct* aStyleStruct, nsRuleData* aData);
struct nsInheritedStyleData
{
nsStyleVisibility* mVisibilityData;
nsStyleFont* mFontData;
nsStyleList* mListData;
nsStyleTableBorder* mTableData;
nsStyleColor* mColorData;
nsStyleQuotes* mQuotesData;
nsStyleText* mTextData;
nsStyleUserInterface* mUIData;
void* operator new(size_t sz, nsIPresContext* aContext) {
void* result = nsnull;
aContext->AllocateFromShell(sz, &result);
return result;
};
void ClearInheritedData(PRUint32 aBits) {
if (mVisibilityData && (aBits & NS_STYLE_INHERIT_VISIBILITY))
mVisibilityData = nsnull;
if (mFontData && (aBits & NS_STYLE_INHERIT_FONT))
mFontData = nsnull;
if (mListData && (aBits & NS_STYLE_INHERIT_LIST))
mListData = nsnull;
if (mTableData && (aBits & NS_STYLE_INHERIT_TABLE_BORDER))
mTableData = nsnull;
if (mColorData && (aBits & NS_STYLE_INHERIT_COLOR))
mColorData = nsnull;
if (mQuotesData && (aBits & NS_STYLE_INHERIT_QUOTES))
mQuotesData = nsnull;
if (mTextData && (aBits & NS_STYLE_INHERIT_TEXT))
mTextData = nsnull;
if (mUIData && (aBits & NS_STYLE_INHERIT_UI))
mUIData = nsnull;
};
void Destroy(PRUint32 aBits, nsIPresContext* aContext) {
if (mVisibilityData && !(aBits & NS_STYLE_INHERIT_VISIBILITY))
mVisibilityData->Destroy(aContext);
if (mFontData && !(aBits & NS_STYLE_INHERIT_FONT))
mFontData->Destroy(aContext);
if (mListData && !(aBits & NS_STYLE_INHERIT_LIST))
mListData->Destroy(aContext);
if (mTableData && !(aBits & NS_STYLE_INHERIT_TABLE_BORDER))
mTableData->Destroy(aContext);
if (mColorData && !(aBits & NS_STYLE_INHERIT_COLOR))
mColorData->Destroy(aContext);
if (mQuotesData && !(aBits & NS_STYLE_INHERIT_QUOTES))
mQuotesData->Destroy(aContext);
if (mTextData && !(aBits & NS_STYLE_INHERIT_TEXT))
mTextData->Destroy(aContext);
if (mUIData && !(aBits & NS_STYLE_INHERIT_UI))
mUIData->Destroy(aContext);
aContext->FreeToShell(sizeof(nsInheritedStyleData), this);
};
nsInheritedStyleData()
:mVisibilityData(nsnull), mFontData(nsnull), mListData(nsnull),
mTableData(nsnull), mColorData(nsnull), mQuotesData(nsnull), mTextData(nsnull), mUIData(nsnull)
{};
};
struct nsResetStyleData
{
nsResetStyleData()
:mDisplayData(nsnull), mMarginData(nsnull), mBorderData(nsnull), mPaddingData(nsnull),
mOutlineData(nsnull), mPositionData(nsnull), mTableData(nsnull), mBackgroundData(nsnull),
mContentData(nsnull), mTextData(nsnull), mUIData(nsnull)
{
#ifdef INCLUDE_XUL
mXULData = nsnull;
#endif
};
void* operator new(size_t sz, nsIPresContext* aContext) {
void* result = nsnull;
aContext->AllocateFromShell(sz, &result);
return result;
}
void ClearInheritedData(PRUint32 aBits) {
if (mDisplayData && (aBits & NS_STYLE_INHERIT_DISPLAY))
mDisplayData = nsnull;
if (mMarginData && (aBits & NS_STYLE_INHERIT_MARGIN))
mMarginData = nsnull;
if (mBorderData && (aBits & NS_STYLE_INHERIT_BORDER))
mBorderData = nsnull;
if (mPaddingData && (aBits & NS_STYLE_INHERIT_PADDING))
mPaddingData = nsnull;
if (mOutlineData && (aBits & NS_STYLE_INHERIT_OUTLINE))
mOutlineData = nsnull;
if (mPositionData && (aBits & NS_STYLE_INHERIT_POSITION))
mPositionData = nsnull;
if (mTableData && (aBits & NS_STYLE_INHERIT_TABLE))
mTableData = nsnull;
if (mBackgroundData && (aBits & NS_STYLE_INHERIT_BACKGROUND))
mBackgroundData = nsnull;
if (mContentData && (aBits & NS_STYLE_INHERIT_CONTENT))
mContentData = nsnull;
if (mTextData && (aBits & NS_STYLE_INHERIT_TEXT_RESET))
mTextData = nsnull;
if (mUIData && (aBits & NS_STYLE_INHERIT_UI_RESET))
mUIData = nsnull;
#ifdef INCLUDE_XUL
if (mXULData && (aBits & NS_STYLE_INHERIT_XUL))
mXULData = nsnull;
#endif
};
void Destroy(PRUint32 aBits, nsIPresContext* aContext) {
if (mDisplayData && !(aBits & NS_STYLE_INHERIT_DISPLAY))
mDisplayData->Destroy(aContext);
if (mMarginData && !(aBits & NS_STYLE_INHERIT_MARGIN))
mMarginData->Destroy(aContext);
if (mBorderData && !(aBits & NS_STYLE_INHERIT_BORDER))
mBorderData->Destroy(aContext);
if (mPaddingData && !(aBits & NS_STYLE_INHERIT_PADDING))
mPaddingData->Destroy(aContext);
if (mOutlineData && !(aBits & NS_STYLE_INHERIT_OUTLINE))
mOutlineData->Destroy(aContext);
if (mPositionData && !(aBits & NS_STYLE_INHERIT_POSITION))
mPositionData->Destroy(aContext);
if (mTableData && !(aBits & NS_STYLE_INHERIT_TABLE))
mTableData->Destroy(aContext);
if (mBackgroundData && !(aBits & NS_STYLE_INHERIT_BACKGROUND))
mBackgroundData->Destroy(aContext);
if (mContentData && !(aBits & NS_STYLE_INHERIT_CONTENT))
mContentData->Destroy(aContext);
if (mTextData && !(aBits & NS_STYLE_INHERIT_TEXT_RESET))
mTextData->Destroy(aContext);
if (mUIData && !(aBits & NS_STYLE_INHERIT_UI_RESET))
mUIData->Destroy(aContext);
#ifdef INCLUDE_XUL
if (mXULData && !(aBits & NS_STYLE_INHERIT_XUL))
mXULData->Destroy(aContext);
#endif
aContext->FreeToShell(sizeof(nsResetStyleData), this);
};
nsStyleDisplay* mDisplayData;
nsStyleMargin* mMarginData;
nsStyleBorder* mBorderData;
nsStylePadding* mPaddingData;
nsStyleOutline* mOutlineData;
nsStylePosition* mPositionData;
nsStyleTable* mTableData;
nsStyleBackground* mBackgroundData;
nsStyleContent* mContentData;
nsStyleTextReset* mTextData;
nsStyleUIReset* mUIData;
#ifdef INCLUDE_XUL
nsStyleXUL* mXULData;
#endif
};
struct nsCachedStyleData
{
struct StyleStructInfo {
ptrdiff_t mCachedStyleDataOffset;
ptrdiff_t mInheritResetOffset;
PRBool mIsReset;
};
static StyleStructInfo gInfo[];
nsInheritedStyleData* mInheritedData;
nsResetStyleData* mResetData;
static PRBool IsReset(const nsStyleStructID& aSID) {
return gInfo[aSID].mIsReset;
};
static PRUint32 GetBitForSID(const nsStyleStructID& aSID) {
return 1 << (aSID - 1);
};
nsStyleStruct* GetStyleData(const nsStyleStructID& aSID) {
const StyleStructInfo& info = gInfo[aSID];
char* resetOrInheritSlot = NS_REINTERPRET_CAST(char*, this) + info.mCachedStyleDataOffset;
char* resetOrInherit = NS_REINTERPRET_CAST(char*, *NS_REINTERPRET_CAST(void**, resetOrInheritSlot));
nsStyleStruct* data = nsnull;
if (resetOrInherit) {
char* dataSlot = resetOrInherit + info.mInheritResetOffset;
data = *NS_REINTERPRET_CAST(nsStyleStruct**, dataSlot);
}
return data;
};
void ClearInheritedData(PRUint32 aBits) {
if (mResetData)
mResetData->ClearInheritedData(aBits);
if (mInheritedData)
mInheritedData->ClearInheritedData(aBits);
}
void Destroy(PRUint32 aBits, nsIPresContext* aContext) {
if (mResetData)
mResetData->Destroy(aBits, aContext);
if (mInheritedData)
mInheritedData->Destroy(aBits, aContext);
mResetData = nsnull;
mInheritedData = nsnull;
}
nsCachedStyleData() :mInheritedData(nsnull), mResetData(nsnull) {};
~nsCachedStyleData() {};
};
struct nsRuleData
{
nsStyleStructID mSID;
nsIPresContext* mPresContext;
nsIStyleContext* mStyleContext;
nsPostResolveFunc mPostResolveCallback;
PRBool mCanStoreInRuleTree;
nsIHTMLMappedAttributes* mAttributes; // Can be cached in the rule data by a content node for a post-resolve callback.
nsCSSFont* mFontData; // Should always be stack-allocated! We don't own these structures!
nsCSSDisplay* mDisplayData;
nsCSSMargin* mMarginData;
nsCSSList* mListData;
nsCSSPosition* mPositionData;
nsCSSTable* mTableData;
nsCSSColor* mColorData;
nsCSSContent* mContentData;
nsCSSText* mTextData;
nsCSSUserInterface* mUIData;
#ifdef INCLUDE_XUL
nsCSSXUL* mXULData;
#endif
nsRuleData(const nsStyleStructID& aSID, nsIPresContext* aContext, nsIStyleContext* aStyleContext)
:mSID(aSID), mPresContext(aContext), mStyleContext(aStyleContext), mPostResolveCallback(nsnull),
mAttributes(nsnull), mFontData(nsnull), mDisplayData(nsnull), mMarginData(nsnull), mListData(nsnull),
mPositionData(nsnull), mTableData(nsnull), mColorData(nsnull), mContentData(nsnull), mTextData(nsnull),
mUIData(nsnull)
{
mCanStoreInRuleTree = PR_TRUE;
#ifdef INCLUDE_XUL
mXULData = nsnull;
#endif
};
~nsRuleData() {};
};
// {ED86146A-00A0-4a9d-B075-91C164D8FF20}
#define NS_IRULENODE_IID \
{ 0xed86146a, 0xa0, 0x4a9d, { 0xb0, 0x75, 0x91, 0xc1, 0x64, 0xd8, 0xff, 0x20 } }
class nsIRuleNode : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IRULENODE_IID)
enum { // Types of RuleBits
eNoneBits,
eInheritBits
};
NS_IMETHOD GetBits(PRInt32 aType, PRUint32* aResult)=0;
NS_IMETHOD Transition(nsIStyleRule* aRule, nsIRuleNode** aResult)=0;
NS_IMETHOD GetParent(nsIRuleNode** aResult)=0;
NS_IMETHOD IsRoot(PRBool* aResult)=0;
NS_IMETHOD GetRule(nsIStyleRule** aResult)=0;
NS_IMETHOD GetPresContext(nsIPresContext** aResult)=0;
NS_IMETHOD PathContainsRule(nsIStyleRule* aRule, PRBool* aMatched) = 0;
NS_IMETHOD ClearCachedData(nsIStyleRule* aRule)=0;
NS_IMETHOD ClearCachedDataInSubtree(nsIStyleRule* aRule)=0;
virtual const nsStyleStruct* GetStyleData(nsStyleStructID aSID,
nsIStyleContext* aContext)=0;
};
#endif

View File

@ -65,9 +65,7 @@ CPPSRCS = \
nsHTMLCSSStyleSheet.cpp \
nsComputedDOMStyle.cpp \
nsROCSSPrimitiveValue.cpp \
nsRuleNode.cpp \
nsRuleWalker.cpp \
$(NULL)
$(NULL)
EXPORTS = \
nsDOMCSSDeclaration.h \

View File

@ -77,9 +77,7 @@ CPPSRCS= \
nsDOMCSSDeclaration.cpp \
nsComputedDOMStyle.cpp \
nsROCSSPrimitiveValue.cpp \
nsRuleNode.cpp \
nsRuleWalker.cpp \
$(NULL)
$(NULL)
CPP_OBJS = \
.\$(OBJDIR)\nsHTMLStyleSheet.obj \
@ -97,9 +95,7 @@ CPP_OBJS = \
.\$(OBJDIR)\nsDOMCSSDeclaration.obj \
.\$(OBJDIR)\nsComputedDOMStyle.obj \
.\$(OBJDIR)\nsROCSSPrimitiveValue.obj \
.\$(OBJDIR)\nsRuleNode.obj \
.\$(OBJDIR)\nsRuleWalker.obj \
$(NULL)
$(NULL)
LINCS= -I..\..\..\base\src \
-I..\..\..\xul\content\src \

View File

@ -1227,6 +1227,8 @@ CSSLoaderImpl::LoadSheet(URLKey& aKey, SheetLoadData* aData)
nsCOMPtr<nsILoadGroup> loadGroup;
mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
NS_ASSERTION(loadGroup, "A stylesheet was unable to locate a load group. This means the onload is going to fire too early!");
#ifdef MOZ_TIMELINE
NS_TIMELINE_MARK_URI("Loading style sheet: %s", urlClone);
NS_TIMELINE_INDENT();

View File

@ -69,7 +69,7 @@
#include "nsINameSpace.h"
#include "nsILookAndFeel.h"
#include "xp_core.h"
#include "nsIRuleNode.h"
#include "nsRuleNode.h"
#include "nsIStyleSet.h"
#include "nsISizeOfHandler.h"

View File

@ -80,7 +80,7 @@
#include "nsIPresShell.h"
#include "nsICSSParser.h"
#include "nsICSSLoader.h"
#include "nsIRuleWalker.h"
#include "nsRuleWalker.h"
#include "nsCSSAtoms.h"
#include "nsINameSpaceManager.h"
#include "nsINameSpace.h"
@ -717,7 +717,7 @@ public:
nsIAtom* aMedium,
nsIContent* aContent,
nsIStyleContext* aParentContext,
nsIRuleWalker* aRuleWalker);
nsRuleWalker* aRuleWalker);
NS_IMETHOD RulesMatching(nsIPresContext* aPresContext,
nsIAtom* aMedium,
@ -725,7 +725,7 @@ public:
nsIAtom* aPseudoTag,
nsIStyleContext* aParentContext,
nsICSSPseudoComparator* aComparator,
nsIRuleWalker* aRuleWalker);
nsRuleWalker* aRuleWalker);
NS_IMETHOD HasStateDependentStyle(nsIPresContext* aPresContext,
nsIAtom* aMedium,
@ -3226,7 +3226,7 @@ MOZ_DECL_CTOR_COUNTER(SelectorMatchesData)
struct SelectorMatchesData {
SelectorMatchesData(nsIPresContext* aPresContext, nsIContent* aContent,
nsIRuleWalker* aRuleWalker, nsCompatibility* aCompat = nsnull);
nsRuleWalker* aRuleWalker, nsCompatibility* aCompat = nsnull);
virtual ~SelectorMatchesData()
{
@ -3256,7 +3256,7 @@ struct SelectorMatchesData {
nsIPresContext* mPresContext;
nsIContent* mContent;
nsIContent* mParentContent; // if content, content->GetParent()
nsCOMPtr<nsIRuleWalker> mRuleWalker; // Used to add rules to our results.
nsRuleWalker* mRuleWalker; // Used to add rules to our results.
nsCOMPtr<nsIStyleRuleSupplier> mStyleRuleSupplier; // used to query for the current scope
nsIAtom* mContentTag; // if content, then content->GetTag()
@ -3275,7 +3275,7 @@ struct SelectorMatchesData {
};
SelectorMatchesData::SelectorMatchesData(nsIPresContext* aPresContext, nsIContent* aContent,
nsIRuleWalker* aRuleWalker,
nsRuleWalker* aRuleWalker,
nsCompatibility* aCompat /*= nsnull*/)
{
MOZ_COUNT_CTOR(SelectorMatchesData);
@ -3797,7 +3797,7 @@ static PRBool SelectorMatches(SelectorMatchesData &data,
struct ContentEnumData : public SelectorMatchesData {
ContentEnumData(nsIPresContext* aPresContext, nsIContent* aContent,
nsIRuleWalker* aRuleWalker)
nsRuleWalker* aRuleWalker)
: SelectorMatchesData(aPresContext,aContent,aRuleWalker)
{}
};
@ -3947,7 +3947,7 @@ CSSRuleProcessor::RulesMatching(nsIPresContext* aPresContext,
nsIAtom* aMedium,
nsIContent* aContent,
nsIStyleContext* aParentContext,
nsIRuleWalker* aRuleWalker)
nsRuleWalker* aRuleWalker)
{
NS_PRECONDITION(nsnull != aPresContext, "null arg");
NS_PRECONDITION(nsnull != aContent, "null arg");
@ -3994,7 +3994,7 @@ CSSRuleProcessor::RulesMatching(nsIPresContext* aPresContext,
struct PseudoEnumData : public SelectorMatchesData {
PseudoEnumData(nsIPresContext* aPresContext, nsIContent* aParentContent,
nsIAtom* aPseudoTag, nsICSSPseudoComparator* aComparator,
nsIRuleWalker* aRuleWalker)
nsRuleWalker* aRuleWalker)
: SelectorMatchesData(aPresContext, aParentContent, aRuleWalker)
{
mPseudoTag = aPseudoTag;
@ -4061,7 +4061,7 @@ CSSRuleProcessor::RulesMatching(nsIPresContext* aPresContext,
nsIAtom* aPseudoTag,
nsIStyleContext* aParentContext,
nsICSSPseudoComparator* aComparator,
nsIRuleWalker* aRuleWalker)
nsRuleWalker* aRuleWalker)
{
NS_PRECONDITION(nsnull != aPresContext, "null arg");
NS_PRECONDITION(nsnull != aPseudoTag, "null arg");

View File

@ -56,7 +56,7 @@
#include "nsCOMPtr.h"
#include "nsIStyleSet.h"
#include "nsIRuleWalker.h"
#include "nsRuleWalker.h"
MOZ_DECL_CTOR_COUNTER(HTMLAttribute)
@ -856,7 +856,7 @@ public:
NS_IMETHOD SetStyleSheet(nsIHTMLStyleSheet* aSheet);
NS_IMETHOD WalkMappedAttributeStyleRules(nsIRuleWalker* aRuleWalker) const;
NS_IMETHOD WalkMappedAttributeStyleRules(nsRuleWalker* aRuleWalker) const;
#ifdef UNIQUE_ATTR_SUPPORT
NS_IMETHOD AddContentRef(void);
@ -1474,7 +1474,7 @@ HTMLAttributesImpl::SetStyleSheet(nsIHTMLStyleSheet* aSheet)
}
NS_IMETHODIMP
HTMLAttributesImpl::WalkMappedAttributeStyleRules(nsIRuleWalker* aRuleWalker) const
HTMLAttributesImpl::WalkMappedAttributeStyleRules(nsRuleWalker* aRuleWalker) const
{
if (aRuleWalker && mMapped)
aRuleWalker->Forward((nsIStyleRule*)mMapped);

View File

@ -56,7 +56,7 @@
#include "nsCOMPtr.h"
#include "nsIStyleSet.h"
#include "nsIRuleWalker.h"
#include "nsRuleWalker.h"
#include "nsISizeOfHandler.h"
@ -248,7 +248,7 @@ public:
nsIAtom* aMedium,
nsIContent* aContent,
nsIStyleContext* aParentContext,
nsIRuleWalker* aRuleWalker);
nsRuleWalker* aRuleWalker);
NS_IMETHOD RulesMatching(nsIPresContext* aPresContext,
nsIAtom* aMedium,
@ -256,7 +256,7 @@ public:
nsIAtom* aPseudoTag,
nsIStyleContext* aParentContext,
nsICSSPseudoComparator* aComparator,
nsIRuleWalker* aRuleWalker);
nsRuleWalker* aRuleWalker);
NS_IMETHOD HasStateDependentStyle(nsIPresContext* aPresContext,
nsIAtom* aMedium,
@ -400,7 +400,7 @@ HTMLCSSStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
nsIAtom* aMedium,
nsIContent* aContent,
nsIStyleContext* aParentContext,
nsIRuleWalker* aRuleWalker)
nsRuleWalker* aRuleWalker)
{
NS_PRECONDITION(nsnull != aPresContext, "null arg");
NS_PRECONDITION(nsnull != aContent, "null arg");
@ -422,12 +422,10 @@ HTMLCSSStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
nsIAtom* aPseudoTag,
nsIStyleContext* aParentContext,
nsICSSPseudoComparator* aComparator,
nsIRuleWalker* aRuleWalker)
nsRuleWalker* aRuleWalker)
{
if (aPseudoTag == nsHTMLAtoms::firstLinePseudo) {
PRBool atRoot = PR_FALSE;
aRuleWalker->AtRoot(&atRoot);
if (!atRoot) {
if (!aRuleWalker->AtRoot()) {
if (nsnull == mFirstLineRule) {
mFirstLineRule = new CSSFirstLineRule(this);
if (mFirstLineRule) {
@ -441,9 +439,7 @@ HTMLCSSStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
}
}
if (aPseudoTag == nsHTMLAtoms::firstLetterPseudo) {
PRBool atRoot = PR_FALSE;
aRuleWalker->AtRoot(&atRoot);
if (!atRoot) {
if (!aRuleWalker->AtRoot()) {
if (nsnull == mFirstLetterRule) {
mFirstLetterRule = new CSSFirstLetterRule(this);
if (mFirstLetterRule) {

View File

@ -59,7 +59,7 @@
#include "nsContentCID.h"
#include "nsLayoutCID.h"
#include "nsIRuleWalker.h"
#include "nsRuleWalker.h"
#include "nsIStyleSet.h"
#include "nsISizeOfHandler.h"
@ -567,7 +567,7 @@ public:
nsIAtom* aMedium,
nsIContent* aContent,
nsIStyleContext* aParentContext,
nsIRuleWalker* aRuleWalker);
nsRuleWalker* aRuleWalker);
NS_IMETHOD RulesMatching(nsIPresContext* aPresContext,
nsIAtom* aMedium,
@ -575,7 +575,7 @@ public:
nsIAtom* aPseudoTag,
nsIStyleContext* aParentContext,
nsICSSPseudoComparator* aComparator,
nsIRuleWalker* aRuleWalker);
nsRuleWalker* aRuleWalker);
NS_IMETHOD HasStateDependentStyle(nsIPresContext* aPresContext,
nsIAtom* aMedium,
@ -808,7 +808,7 @@ HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
nsIAtom* aMedium,
nsIContent* aContent,
nsIStyleContext* aParentContext,
nsIRuleWalker* aRuleWalker)
nsRuleWalker* aRuleWalker)
{
NS_PRECONDITION(nsnull != aPresContext, "null arg");
NS_PRECONDITION(nsnull != aContent, "null arg");
@ -922,7 +922,7 @@ HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
nsIAtom* aPseudoTag,
nsIStyleContext* aParentContext,
nsICSSPseudoComparator* aComparator,
nsIRuleWalker* aRuleWalker)
nsRuleWalker* aRuleWalker)
{
// no pseudo frame style
return NS_OK;

View File

@ -44,7 +44,7 @@
class nsIAtom;
class nsISupportsArray;
class nsIHTMLStyleSheet;
class nsIRuleWalker;
class nsRuleWalker;
// IID for the nsIHTMLAttributes interface {a18f85f0-c058-11d1-8031-006008159b5a}
#define NS_IHTML_ATTRIBUTES_IID \
@ -94,7 +94,7 @@ public:
NS_IMETHOD SetStyleSheet(nsIHTMLStyleSheet* aSheet) = 0;
NS_IMETHOD WalkMappedAttributeStyleRules(nsIRuleWalker* aRuleWalker) const = 0;
NS_IMETHOD WalkMappedAttributeStyleRules(nsRuleWalker* aRuleWalker) const = 0;
#ifdef UNIQUE_ATTR_SUPPORT
NS_IMETHOD Equals(const nsIHTMLAttributes* aAttributes, PRBool& aResult) const = 0;

View File

@ -1,139 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Original Author: David W. Hyatt (hyatt@netscape.com)
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsCOMPtr.h"
#include "nsHashtable.h"
#include "nsIStyleRule.h"
#include "nsFixedSizeAllocator.h"
#include "nsIRuleNode.h"
#include "nsIRuleWalker.h"
class nsRuleWalker: public nsIRuleWalker {
public:
NS_DECL_ISUPPORTS
NS_IMETHOD GetCurrentNode(nsIRuleNode** aResult);
NS_IMETHOD SetCurrentNode(nsIRuleNode* aNode);
NS_IMETHOD Forward(nsIStyleRule* aRule);
NS_IMETHOD Back();
NS_IMETHOD Reset();
NS_IMETHOD AtRoot(PRBool* aResult);
private:
nsCOMPtr<nsIRuleNode> mCurrent; // Our current position.
nsCOMPtr<nsIRuleNode> mRoot; // The root of the tree we're walking.
protected:
public:
nsRuleWalker(nsIRuleNode* aRoot) :mRoot(aRoot), mCurrent(aRoot) { NS_INIT_REFCNT(); };
virtual ~nsRuleWalker() {};
};
NS_IMPL_ISUPPORTS1(nsRuleWalker, nsIRuleWalker)
NS_IMETHODIMP
nsRuleWalker::GetCurrentNode(nsIRuleNode** aResult)
{
*aResult = mCurrent;
NS_IF_ADDREF(*aResult);
return NS_OK;
}
NS_IMETHODIMP
nsRuleWalker::SetCurrentNode(nsIRuleNode* aNode)
{
mCurrent = aNode;
return NS_OK;
}
NS_IMETHODIMP
nsRuleWalker::Forward(nsIStyleRule* aRule)
{
if (!mCurrent)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIRuleNode> next;
mCurrent->Transition(aRule, getter_AddRefs(next));
mCurrent = next;
return NS_OK;
}
NS_IMETHODIMP
nsRuleWalker::Back()
{
if (mCurrent == mRoot)
return NS_OK;
nsCOMPtr<nsIRuleNode> prev;
mCurrent->GetParent(getter_AddRefs(prev));
mCurrent = prev;
return NS_OK;
}
NS_IMETHODIMP
nsRuleWalker::Reset()
{
mCurrent = mRoot;
return NS_OK;
}
NS_IMETHODIMP
nsRuleWalker::AtRoot(PRBool* aResult)
{
*aResult = (mCurrent == mRoot);
return NS_OK;
}
// Creation Routine ///////////////////////////////////////////////////////////////////////
nsresult
NS_NewRuleWalker(nsIRuleNode* aRoot, nsIRuleWalker** aResult)
{
*aResult = new nsRuleWalker(aRoot);
if (!*aResult)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aResult);
return NS_OK;
}

View File

@ -39,7 +39,6 @@
#include <math.h>
#include "nsStyleUtil.h"
#include "nsCRT.h"
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsUnitConversion.h"
@ -59,7 +58,7 @@
// XXX This is here because nsCachedStyleData is accessed outside of
// the content module; e.g., by nsCSSFrameConstructor.
#include "nsIRuleNode.h"
#include "nsRuleNode.h"
nsCachedStyleData::StyleStructInfo
nsCachedStyleData::gInfo[] = {

View File

@ -14,6 +14,8 @@ nsHTMLValue.h
nsImageMapUtils.h
nsLayoutAtomList.h
nsLayoutAtoms.h
nsRuleNode.h
nsRuleWalker.h
nsStyleCoord.h
nsStyleUtil.h
nsStyleStruct.h

View File

@ -42,6 +42,8 @@ nsHTMLUtils.h \
nsImageMapUtils.h \
nsLayoutAtomList.h \
nsLayoutAtoms.h \
nsRuleNode.h \
nsRuleWalker.h \
nsStyleCoord.h \
nsStyleUtil.h \
nsStyleStruct.h \

View File

@ -35,6 +35,8 @@ EXPORTS = \
nsImageMapUtils.h \
nsLayoutAtomList.h \
nsLayoutAtoms.h \
nsRuleNode.h \
nsRuleWalker.h \
nsStyleCoord.h \
nsStyleUtil.h \
nsStyleStruct.h \

View File

@ -43,16 +43,267 @@
#include "nsCOMPtr.h"
#include "nsHashtable.h"
#include "nsIStyleRule.h"
#include "nsIFrame.h"
#include "nsFixedSizeAllocator.h"
#include "nsIRuleNode.h"
#include "nsIStyleContext.h"
#include "nsIPresContext.h"
#include "nsICSSDeclaration.h"
class nsRuleNode: public nsIRuleNode {
public:
NS_DECL_ISUPPORTS
class nsIHTMLMappedAttributes;
class nsIStyleContext;
struct nsRuleList;
typedef void (*nsPostResolveFunc)(nsStyleStruct* aStyleStruct, nsRuleData* aData);
struct nsInheritedStyleData
{
nsStyleVisibility* mVisibilityData;
nsStyleFont* mFontData;
nsStyleList* mListData;
nsStyleTableBorder* mTableData;
nsStyleColor* mColorData;
nsStyleQuotes* mQuotesData;
nsStyleText* mTextData;
nsStyleUserInterface* mUIData;
void* operator new(size_t sz, nsIPresContext* aContext) {
void* result = nsnull;
aContext->AllocateFromShell(sz, &result);
return result;
};
void ClearInheritedData(PRUint32 aBits) {
if (mVisibilityData && (aBits & NS_STYLE_INHERIT_VISIBILITY))
mVisibilityData = nsnull;
if (mFontData && (aBits & NS_STYLE_INHERIT_FONT))
mFontData = nsnull;
if (mListData && (aBits & NS_STYLE_INHERIT_LIST))
mListData = nsnull;
if (mTableData && (aBits & NS_STYLE_INHERIT_TABLE_BORDER))
mTableData = nsnull;
if (mColorData && (aBits & NS_STYLE_INHERIT_COLOR))
mColorData = nsnull;
if (mQuotesData && (aBits & NS_STYLE_INHERIT_QUOTES))
mQuotesData = nsnull;
if (mTextData && (aBits & NS_STYLE_INHERIT_TEXT))
mTextData = nsnull;
if (mUIData && (aBits & NS_STYLE_INHERIT_UI))
mUIData = nsnull;
};
void Destroy(PRUint32 aBits, nsIPresContext* aContext) {
if (mVisibilityData && !(aBits & NS_STYLE_INHERIT_VISIBILITY))
mVisibilityData->Destroy(aContext);
if (mFontData && !(aBits & NS_STYLE_INHERIT_FONT))
mFontData->Destroy(aContext);
if (mListData && !(aBits & NS_STYLE_INHERIT_LIST))
mListData->Destroy(aContext);
if (mTableData && !(aBits & NS_STYLE_INHERIT_TABLE_BORDER))
mTableData->Destroy(aContext);
if (mColorData && !(aBits & NS_STYLE_INHERIT_COLOR))
mColorData->Destroy(aContext);
if (mQuotesData && !(aBits & NS_STYLE_INHERIT_QUOTES))
mQuotesData->Destroy(aContext);
if (mTextData && !(aBits & NS_STYLE_INHERIT_TEXT))
mTextData->Destroy(aContext);
if (mUIData && !(aBits & NS_STYLE_INHERIT_UI))
mUIData->Destroy(aContext);
aContext->FreeToShell(sizeof(nsInheritedStyleData), this);
};
nsInheritedStyleData()
:mVisibilityData(nsnull), mFontData(nsnull), mListData(nsnull),
mTableData(nsnull), mColorData(nsnull), mQuotesData(nsnull), mTextData(nsnull), mUIData(nsnull)
{};
};
struct nsResetStyleData
{
nsResetStyleData()
:mDisplayData(nsnull), mMarginData(nsnull), mBorderData(nsnull), mPaddingData(nsnull),
mOutlineData(nsnull), mPositionData(nsnull), mTableData(nsnull), mBackgroundData(nsnull),
mContentData(nsnull), mTextData(nsnull), mUIData(nsnull)
{
#ifdef INCLUDE_XUL
mXULData = nsnull;
#endif
};
void* operator new(size_t sz, nsIPresContext* aContext) {
void* result = nsnull;
aContext->AllocateFromShell(sz, &result);
return result;
}
void ClearInheritedData(PRUint32 aBits) {
if (mDisplayData && (aBits & NS_STYLE_INHERIT_DISPLAY))
mDisplayData = nsnull;
if (mMarginData && (aBits & NS_STYLE_INHERIT_MARGIN))
mMarginData = nsnull;
if (mBorderData && (aBits & NS_STYLE_INHERIT_BORDER))
mBorderData = nsnull;
if (mPaddingData && (aBits & NS_STYLE_INHERIT_PADDING))
mPaddingData = nsnull;
if (mOutlineData && (aBits & NS_STYLE_INHERIT_OUTLINE))
mOutlineData = nsnull;
if (mPositionData && (aBits & NS_STYLE_INHERIT_POSITION))
mPositionData = nsnull;
if (mTableData && (aBits & NS_STYLE_INHERIT_TABLE))
mTableData = nsnull;
if (mBackgroundData && (aBits & NS_STYLE_INHERIT_BACKGROUND))
mBackgroundData = nsnull;
if (mContentData && (aBits & NS_STYLE_INHERIT_CONTENT))
mContentData = nsnull;
if (mTextData && (aBits & NS_STYLE_INHERIT_TEXT_RESET))
mTextData = nsnull;
if (mUIData && (aBits & NS_STYLE_INHERIT_UI_RESET))
mUIData = nsnull;
#ifdef INCLUDE_XUL
if (mXULData && (aBits & NS_STYLE_INHERIT_XUL))
mXULData = nsnull;
#endif
};
void Destroy(PRUint32 aBits, nsIPresContext* aContext) {
if (mDisplayData && !(aBits & NS_STYLE_INHERIT_DISPLAY))
mDisplayData->Destroy(aContext);
if (mMarginData && !(aBits & NS_STYLE_INHERIT_MARGIN))
mMarginData->Destroy(aContext);
if (mBorderData && !(aBits & NS_STYLE_INHERIT_BORDER))
mBorderData->Destroy(aContext);
if (mPaddingData && !(aBits & NS_STYLE_INHERIT_PADDING))
mPaddingData->Destroy(aContext);
if (mOutlineData && !(aBits & NS_STYLE_INHERIT_OUTLINE))
mOutlineData->Destroy(aContext);
if (mPositionData && !(aBits & NS_STYLE_INHERIT_POSITION))
mPositionData->Destroy(aContext);
if (mTableData && !(aBits & NS_STYLE_INHERIT_TABLE))
mTableData->Destroy(aContext);
if (mBackgroundData && !(aBits & NS_STYLE_INHERIT_BACKGROUND))
mBackgroundData->Destroy(aContext);
if (mContentData && !(aBits & NS_STYLE_INHERIT_CONTENT))
mContentData->Destroy(aContext);
if (mTextData && !(aBits & NS_STYLE_INHERIT_TEXT_RESET))
mTextData->Destroy(aContext);
if (mUIData && !(aBits & NS_STYLE_INHERIT_UI_RESET))
mUIData->Destroy(aContext);
#ifdef INCLUDE_XUL
if (mXULData && !(aBits & NS_STYLE_INHERIT_XUL))
mXULData->Destroy(aContext);
#endif
aContext->FreeToShell(sizeof(nsResetStyleData), this);
};
nsStyleDisplay* mDisplayData;
nsStyleMargin* mMarginData;
nsStyleBorder* mBorderData;
nsStylePadding* mPaddingData;
nsStyleOutline* mOutlineData;
nsStylePosition* mPositionData;
nsStyleTable* mTableData;
nsStyleBackground* mBackgroundData;
nsStyleContent* mContentData;
nsStyleTextReset* mTextData;
nsStyleUIReset* mUIData;
#ifdef INCLUDE_XUL
nsStyleXUL* mXULData;
#endif
};
struct nsCachedStyleData
{
struct StyleStructInfo {
ptrdiff_t mCachedStyleDataOffset;
ptrdiff_t mInheritResetOffset;
PRBool mIsReset;
};
static StyleStructInfo gInfo[];
nsInheritedStyleData* mInheritedData;
nsResetStyleData* mResetData;
static PRBool IsReset(const nsStyleStructID& aSID) {
return gInfo[aSID].mIsReset;
};
static PRUint32 GetBitForSID(const nsStyleStructID& aSID) {
return 1 << (aSID - 1);
};
nsStyleStruct* GetStyleData(const nsStyleStructID& aSID) {
const StyleStructInfo& info = gInfo[aSID];
char* resetOrInheritSlot = NS_REINTERPRET_CAST(char*, this) + info.mCachedStyleDataOffset;
char* resetOrInherit = NS_REINTERPRET_CAST(char*, *NS_REINTERPRET_CAST(void**, resetOrInheritSlot));
nsStyleStruct* data = nsnull;
if (resetOrInherit) {
char* dataSlot = resetOrInherit + info.mInheritResetOffset;
data = *NS_REINTERPRET_CAST(nsStyleStruct**, dataSlot);
}
return data;
};
void ClearInheritedData(PRUint32 aBits) {
if (mResetData)
mResetData->ClearInheritedData(aBits);
if (mInheritedData)
mInheritedData->ClearInheritedData(aBits);
}
void Destroy(PRUint32 aBits, nsIPresContext* aContext) {
if (mResetData)
mResetData->Destroy(aBits, aContext);
if (mInheritedData)
mInheritedData->Destroy(aBits, aContext);
mResetData = nsnull;
mInheritedData = nsnull;
}
nsCachedStyleData() :mInheritedData(nsnull), mResetData(nsnull) {};
~nsCachedStyleData() {};
};
struct nsRuleData
{
nsStyleStructID mSID;
nsIPresContext* mPresContext;
nsIStyleContext* mStyleContext;
nsPostResolveFunc mPostResolveCallback;
PRBool mCanStoreInRuleTree;
nsIHTMLMappedAttributes* mAttributes; // Can be cached in the rule data by a content node for a post-resolve callback.
nsCSSFont* mFontData; // Should always be stack-allocated! We don't own these structures!
nsCSSDisplay* mDisplayData;
nsCSSMargin* mMarginData;
nsCSSList* mListData;
nsCSSPosition* mPositionData;
nsCSSTable* mTableData;
nsCSSColor* mColorData;
nsCSSContent* mContentData;
nsCSSText* mTextData;
nsCSSUserInterface* mUIData;
#ifdef INCLUDE_XUL
nsCSSXUL* mXULData;
#endif
nsRuleData(const nsStyleStructID& aSID, nsIPresContext* aContext, nsIStyleContext* aStyleContext)
:mSID(aSID), mPresContext(aContext), mStyleContext(aStyleContext), mPostResolveCallback(nsnull),
mAttributes(nsnull), mFontData(nsnull), mDisplayData(nsnull), mMarginData(nsnull), mListData(nsnull),
mPositionData(nsnull), mTableData(nsnull), mColorData(nsnull), mContentData(nsnull), mTextData(nsnull),
mUIData(nsnull)
{
mCanStoreInRuleTree = PR_TRUE;
#ifdef INCLUDE_XUL
mXULData = nsnull;
#endif
};
~nsRuleData() {};
};
class nsRuleNode {
public:
// for purposes of the RuleDetail (and related code),
// * a non-inherited value is one that is specified as a
// non-"inherit" value or as an "inherit" value that is reflected
@ -77,6 +328,11 @@ public:
// callback to trigger the normal checking codepath)
};
enum { // Types of RuleBits
eNoneBits,
eInheritBits
};
private:
nsIPresContext* mPresContext; // Our pres context.
@ -86,10 +342,13 @@ private:
// of style properties.
nsCOMPtr<nsIStyleRule> mRule; // A pointer to our specific rule.
nsSupportsHashtable* mChildren; // A hashtable that maps from rules to our RuleNode children.
// When matching rules, we use this table to transition from
// node to node (constructing new nodes as needed to flesh out
// the tree).
union {
nsHashtable* mRootChildren; // A hashtable that maps from rules to our RuleNode children.
// When matching rules, we use this table to transition from
// node to node (constructing new nodes as needed to flesh out
// the tree).
nsRuleList* mChildren;
};
nsCachedStyleData mStyleData; // Any data we cached on the rule node.
@ -104,15 +363,19 @@ private:
static PRUint32 gRefCnt;
friend struct nsRuleList;
protected:
// The callback function for deleting rule nodes from our rule tree.
static PRBool PR_CALLBACK DeleteChildren(nsHashKey *aKey, void *aData, void *closure);
// Overloaded new operator. Initializes the memory to 0 and relies on an arena
public:
// Overloaded new operator. Initializes the memory to 0 and relies on an arena
// (which comes from the presShell) to perform the allocation.
void* operator new(size_t sz, nsIPresContext* aContext);
void Destroy();
protected:
void PropagateInheritBit(PRUint32 aBit, nsRuleNode* aHighestNode);
void PropagateNoneBit(PRUint32 aBit, nsRuleNode* aHighestNode);
@ -238,18 +501,17 @@ public:
nsRuleNode(nsIPresContext* aPresContext, nsIStyleRule* aRule=nsnull, nsRuleNode* aParent=nsnull);
virtual ~nsRuleNode();
static void CreateRootNode(nsIPresContext* aPresContext, nsIRuleNode** aResult);
static void CreateRootNode(nsIPresContext* aPresContext, nsRuleNode** aResult);
// The nsIRuleNode Interface
NS_IMETHOD GetBits(PRInt32 aType, PRUint32* aResult);
NS_IMETHOD Transition(nsIStyleRule* aRule, nsIRuleNode** aResult);
NS_IMETHOD GetParent(nsIRuleNode** aResult);
NS_IMETHOD IsRoot(PRBool* aResult);
NS_IMETHOD GetRule(nsIStyleRule** aResult);
NS_IMETHOD ClearCachedData(nsIStyleRule* aRule);
NS_IMETHOD ClearCachedDataInSubtree(nsIStyleRule* aRule);
NS_IMETHOD GetPresContext(nsIPresContext** aResult);
NS_IMETHOD PathContainsRule(nsIStyleRule* aRule, PRBool* aMatched);
nsresult GetBits(PRInt32 aType, PRUint32* aResult);
nsresult Transition(nsIStyleRule* aRule, nsRuleNode** aResult);
nsRuleNode* GetParent() { return mParent; }
PRBool IsRoot() { return mParent == nsnull; }
nsresult GetRule(nsIStyleRule** aResult);
nsresult ClearCachedData(nsIStyleRule* aRule);
nsresult ClearCachedDataInSubtree(nsIStyleRule* aRule);
nsresult GetPresContext(nsIPresContext** aResult);
nsresult PathContainsRule(nsIStyleRule* aRule, PRBool* aMatched);
const nsStyleStruct* GetStyleData(nsStyleStructID aSID,
nsIStyleContext* aContext);
};

View File

@ -36,34 +36,34 @@
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsIRuleWalker_h___
#define nsIRuleWalker_h___
#include "nsCOMPtr.h"
#include "nsIRuleNode.h"
#include "nsRuleNode.h"
class nsIRuleNode;
// {6ED294B0-2E91-40a6-949D-7A0173691487}
#define NS_IRULEWALKER_IID \
{ 0x6ed294b0, 0x2e91, 0x40a6, { 0x94, 0x9d, 0x7a, 0x1, 0x73, 0x69, 0x14, 0x87 } }
class nsIRuleWalker : public nsISupports {
class nsRuleWalker {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IRULEWALKER_IID)
nsRuleNode* GetCurrentNode() { return mCurrent; }
void SetCurrentNode(nsRuleNode* aNode) { mCurrent = aNode; }
NS_IMETHOD GetCurrentNode(nsIRuleNode** aResult)=0;
NS_IMETHOD SetCurrentNode(nsIRuleNode* aNode)=0;
void Forward(nsIStyleRule* aRule) {
nsRuleNode* next;
mCurrent->Transition(aRule, &next);
mCurrent = next;
}
NS_IMETHOD Forward(nsIStyleRule* aRule)=0;
NS_IMETHOD Back()=0;
void Back() {
if (mCurrent != mRoot)
mCurrent = mCurrent->GetParent();
}
NS_IMETHOD Reset()=0;
void Reset() { mCurrent = mRoot; }
NS_IMETHOD AtRoot(PRBool* aResult)=0;
PRBool AtRoot() { return mCurrent == mRoot; }
private:
nsRuleNode* mCurrent; // Our current position.
nsRuleNode* mRoot; // The root of the tree we're walking.
public:
nsRuleWalker(nsRuleNode* aRoot) :mCurrent(aRoot), mRoot(aRoot) { MOZ_COUNT_CTOR(nsRuleWalker); };
~nsRuleWalker() { MOZ_COUNT_DTOR(nsRuleWalker); };
};
extern nsresult
NS_NewRuleWalker(nsIRuleNode* aRoot, nsIRuleWalker** aResult);
#endif

View File

@ -52,6 +52,7 @@ CPPSRCS = \
nsHTMLValue.cpp \
nsImageMapUtils.cpp \
nsLayoutAtoms.cpp \
nsRuleNode.cpp \
nsStyleUtil.cpp \
nsTextFragment.cpp \
nsXULAtoms.cpp \

View File

@ -28,6 +28,7 @@ REQUIRES = xpcom \
locale \
dom \
webshell \
docshell \
pref \
necko \
htmlparser \
@ -52,6 +53,7 @@ CPPSRCS = \
nsHTMLValue.cpp \
nsImageMapUtils.cpp \
nsLayoutAtoms.cpp \
nsRuleNode.cpp \
nsStyleUtil.cpp \
nsStyleStruct.cpp \
nsTextFragment.cpp \
@ -69,6 +71,7 @@ CPP_OBJS= \
.\$(OBJDIR)\nsHTMLValue.obj \
.\$(OBJDIR)\nsImageMapUtils.obj \
.\$(OBJDIR)\nsLayoutAtoms.obj \
.\$(OBJDIR)\nsRuleNode.obj \
.\$(OBJDIR)\nsStyleUtil.obj \
.\$(OBJDIR)\nsStyleStruct.obj \
.\$(OBJDIR)\nsTextFragment.obj \

View File

@ -53,6 +53,38 @@
#include "nsIPref.h"
#include "nsIServiceManager.h"
struct nsRuleList {
nsRuleNode* mRuleNode;
nsRuleList* mNext;
public:
nsRuleList(nsRuleNode* aNode, nsRuleList* aNext= nsnull) {
MOZ_COUNT_CTOR(nsRuleList);
mRuleNode = aNode;
mNext = aNext;
}
~nsRuleList() {
MOZ_COUNT_DTOR(nsRuleList);
mRuleNode->Destroy();
if (mNext)
mNext->Destroy(mRuleNode->mPresContext);
}
void* operator new(size_t sz, nsIPresContext* aContext) {
void* result = nsnull;
aContext->AllocateFromShell(sz, &result);
return result;
};
void operator delete(void* aPtr) {} // Does nothing. The arena will free us up when the rule tree
// dies.
void Destroy(nsIPresContext* aContext) {
this->~nsRuleList();
aContext->FreeToShell(sizeof(nsRuleList), this);
}
};
class nsShellISupportsKey : public nsHashKey {
public:
nsISupports* mKey;
@ -335,13 +367,6 @@ static PRBool SetColor(const nsCSSValue& aValue, const nscolor aParentColor,
return result;
}
// nsRuleNode globals
PRUint32 nsRuleNode::gRefCnt = 0;
NS_IMPL_ADDREF(nsRuleNode)
NS_IMPL_RELEASE_WITH_DESTROY(nsRuleNode, Destroy())
NS_IMPL_QUERY_INTERFACE1(nsRuleNode, nsIRuleNode)
// Overloaded new operator. Initializes the memory to 0 and relies on an arena
// (which comes from the presShell) to perform the allocation.
void*
@ -366,29 +391,34 @@ nsRuleNode::Destroy()
mPresContext->FreeToShell(sizeof(nsRuleNode), this);
}
void nsRuleNode::CreateRootNode(nsIPresContext* aPresContext, nsIRuleNode** aResult)
void nsRuleNode::CreateRootNode(nsIPresContext* aPresContext, nsRuleNode** aResult)
{
*aResult = new (aPresContext) nsRuleNode(aPresContext);
NS_IF_ADDREF(*aResult);
}
nsRuleNode::nsRuleNode(nsIPresContext* aContext, nsIStyleRule* aRule, nsRuleNode* aParent)
:mPresContext(aContext), mParent(aParent), mChildren(nsnull), mInheritBits(0), mNoneBits(0)
:mPresContext(aContext), mParent(aParent), mInheritBits(0), mNoneBits(0)
{
NS_INIT_REFCNT();
gRefCnt++;
MOZ_COUNT_CTOR(nsRuleNode);
mRule = aRule;
if (mParent)
mChildren = nsnull;
else
mRootChildren = nsnull;
}
nsRuleNode::~nsRuleNode()
{
MOZ_COUNT_DTOR(nsRuleNode);
if (mStyleData.mResetData || mStyleData.mInheritedData)
mStyleData.Destroy(0, mPresContext);
delete mChildren;
gRefCnt--;
if (mParent && mChildren)
mChildren->Destroy(mPresContext);
else if (!mParent)
delete mRootChildren;
}
NS_IMETHODIMP
nsresult
nsRuleNode::GetBits(PRInt32 aType, PRUint32* aResult)
{
switch (aType) {
@ -401,48 +431,51 @@ nsRuleNode::GetBits(PRInt32 aType, PRUint32* aResult)
return NS_OK;
}
NS_IMETHODIMP
nsRuleNode::Transition(nsIStyleRule* aRule, nsIRuleNode** aResult)
nsresult
nsRuleNode::Transition(nsIStyleRule* aRule, nsRuleNode** aResult)
{
nsCOMPtr<nsIRuleNode> next;
nsShellISupportsKey key(aRule);
if (mChildren)
next = getter_AddRefs(NS_STATIC_CAST(nsIRuleNode*, mChildren->Get(&key)));
if (!next) {
// Create the new entry in our table.
nsRuleNode* newNode = new (mPresContext) nsRuleNode(mPresContext, aRule, this);
next = newNode;
nsRuleNode* next = nsnull;
if (!mChildren)
mChildren = new nsSupportsHashtable(4);
if (!mParent) {
nsShellISupportsKey key(aRule);
if (mRootChildren)
next = NS_STATIC_CAST(nsRuleNode*, mRootChildren->Get(&key));
if (!next) {
// Create the new entry in our table.
nsRuleNode* newNode = new (mPresContext) nsRuleNode(mPresContext, aRule, this);
next = newNode;
// Clone the key ourselves by allocating it from the shell's arena.
nsShellISupportsKey* clonedKey = new (mPresContext) nsShellISupportsKey(aRule);
mChildren->Put(clonedKey, next);
if (!mRootChildren)
mRootChildren = new nsHashtable(4);
// Clone the key ourselves by allocating it from the shell's arena.
nsShellISupportsKey* clonedKey = new (mPresContext) nsShellISupportsKey(aRule);
mRootChildren->Put(clonedKey, next);
}
}
else {
if (mChildren) {
for (nsRuleList* curr = mChildren; curr && curr->mRuleNode->mRule != aRule; curr = curr->mNext);
if (curr)
next = curr->mRuleNode;
}
if (!next) {
// Create the new entry in our table.
nsRuleNode* newNode = new (mPresContext) nsRuleNode(mPresContext, aRule, this);
next = newNode;
if (!mChildren)
mChildren = new (mPresContext) nsRuleList(newNode);
else
mChildren = new (mPresContext) nsRuleList(newNode, mChildren);
}
}
*aResult = next;
NS_IF_ADDREF(*aResult);
return NS_OK;
}
NS_IMETHODIMP
nsRuleNode::GetParent(nsIRuleNode** aResult)
{
*aResult = mParent;
NS_IF_ADDREF(*aResult);
return NS_OK;
}
NS_IMETHODIMP
nsRuleNode::IsRoot(PRBool* aResult)
{
*aResult = (mParent == nsnull);
return NS_OK;
}
NS_IMETHODIMP
nsresult
nsRuleNode::GetRule(nsIStyleRule** aResult)
{
*aResult = mRule;
@ -450,7 +483,7 @@ nsRuleNode::GetRule(nsIStyleRule** aResult)
return NS_OK;
}
NS_IMETHODIMP
nsresult
nsRuleNode::PathContainsRule(nsIStyleRule* aRule, PRBool* aMatched)
{
*aMatched = PR_FALSE;
@ -466,7 +499,7 @@ nsRuleNode::PathContainsRule(nsIStyleRule* aRule, PRBool* aMatched)
return NS_OK;
}
NS_IMETHODIMP
nsresult
nsRuleNode::ClearCachedData(nsIStyleRule* aRule)
{
nsRuleNode* ruleDest = this;
@ -501,13 +534,13 @@ nsRuleNode::ClearCachedData(nsIStyleRule* aRule)
PRBool PR_CALLBACK ClearCachedDataInSubtreeHelper(nsHashKey* aKey, void* aData, void* aClosure)
{
nsIRuleNode* ruleNode = (nsIRuleNode*)aData;
nsRuleNode* ruleNode = (nsRuleNode*)aData;
nsIStyleRule* rule = (nsIStyleRule*)aClosure;
ruleNode->ClearCachedDataInSubtree(rule);
return PR_TRUE;
}
NS_IMETHODIMP
nsresult
nsRuleNode::ClearCachedDataInSubtree(nsIStyleRule* aRule)
{
if (aRule == nsnull || mRule == aRule) {
@ -519,13 +552,18 @@ nsRuleNode::ClearCachedDataInSubtree(nsIStyleRule* aRule)
aRule = nsnull;
}
if (mChildren)
mChildren->Enumerate(ClearCachedDataInSubtreeHelper, (void*)aRule);
if (!mParent) {
if (mRootChildren)
mRootChildren->Enumerate(ClearCachedDataInSubtreeHelper, (void*)aRule);
}
else
for (nsRuleList* curr = mChildren; curr; curr = curr->mNext)
curr->mRuleNode->ClearCachedDataInSubtree(curr->mRuleNode->mRule);
return NS_OK;
}
NS_IMETHODIMP
nsresult
nsRuleNode::GetPresContext(nsIPresContext** aResult)
{
*aResult = mPresContext;
@ -1926,7 +1964,8 @@ SetGenericFont(nsIPresContext* aPresContext, nsIStyleContext* aContext,
PRBool dummy;
PRUint32 noneBits;
PRUint32 fontBit = nsCachedStyleData::GetBitForSID(eStyleStruct_Font);
nsCOMPtr<nsIRuleNode> ruleNode, tmpNode;
nsRuleNode* ruleNode = nsnull;
nsCOMPtr<nsIStyleRule> rule;
for (; i >= 0; --i) {
@ -1936,9 +1975,9 @@ SetGenericFont(nsIPresContext* aPresContext, nsIStyleContext* aContext,
ruleData.mFontData = &fontData;
// Trimmed down version of ::WalkRuleTree() to re-apply the style rules
context->GetRuleNode(getter_AddRefs(ruleNode));
context->GetRuleNode(&ruleNode);
while (ruleNode) {
ruleNode->GetBits(nsIRuleNode::eNoneBits, &noneBits);
ruleNode->GetBits(nsRuleNode::eNoneBits, &noneBits);
if (noneBits & fontBit) // no more font rules on this branch, get out
break;
@ -1946,8 +1985,7 @@ SetGenericFont(nsIPresContext* aPresContext, nsIStyleContext* aContext,
if (rule)
rule->MapRuleInfoInto(&ruleData);
tmpNode = ruleNode;
tmpNode->GetParent(getter_AddRefs(ruleNode));
ruleNode = ruleNode->GetParent();
}
// Compute the delta from the information that the rules specified
@ -4232,7 +4270,7 @@ nsRuleNode::gGetStyleDataFn[] = {
nsnull
};
inline const nsStyleStruct*
const nsStyleStruct*
nsRuleNode::GetStyleData(nsStyleStructID aSID,
nsIStyleContext* aContext)
{

View File

@ -37,7 +37,6 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsString.h"
#include "nsUnitConversion.h"
@ -49,6 +48,7 @@
#include "nsCOMPtr.h"
#include "nsIStyleSet.h"
#include "nsIPresShell.h"
#include "nsIFrame.h"
#include "nsLayoutAtoms.h"
#include "prenv.h"

View File

@ -39,7 +39,6 @@
#include <math.h>
#include "nsStyleUtil.h"
#include "nsCRT.h"
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsUnitConversion.h"
@ -59,7 +58,7 @@
// XXX This is here because nsCachedStyleData is accessed outside of
// the content module; e.g., by nsCSSFrameConstructor.
#include "nsIRuleNode.h"
#include "nsRuleNode.h"
nsCachedStyleData::StyleStructInfo
nsCachedStyleData::gInfo[] = {

View File

@ -554,6 +554,14 @@ nsXBLPrototypeBinding::LoadResources(PRBool* aResult)
resource->GetAttr(kNameSpaceID_None, nsHTMLAtoms::media, media);
PRInt32 numSheets = 0;
doc->GetNumberOfStyleSheets(&numSheets);
#ifdef DEBUG
nsCOMPtr<nsILoadGroup> loadGroup;
doc->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
NS_ASSERTION(loadGroup, "An XBL scoped stylesheet is unable to locate a load group. This means the onload is going to fire too early!");
#endif
rv = cssLoader->LoadStyleLink(nsnull, url, empty, media, kNameSpaceID_Unknown,
numSheets,
nsnull,

View File

@ -121,7 +121,7 @@
#include "nsIBoxObject.h"
#include "nsPIBoxObject.h"
#include "nsXULDocument.h"
#include "nsIRuleWalker.h"
#include "nsRuleWalker.h"
#include "nsIDOMViewCSS.h"
#include "nsIDOMCSSStyleDeclaration.h"
#include "nsXULAtoms.h"
@ -3851,13 +3851,13 @@ nsXULElement::HasClass(nsIAtom* aClass, PRBool /*aCaseSensitive*/) const
}
NS_IMETHODIMP
nsXULElement::WalkContentStyleRules(nsIRuleWalker* aRuleWalker)
nsXULElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker)
{
return NS_OK;
}
NS_IMETHODIMP
nsXULElement::WalkInlineStyleRules(nsIRuleWalker* aRuleWalker)
nsXULElement::WalkInlineStyleRules(nsRuleWalker* aRuleWalker)
{
// Fetch the cached style rule from the attributes.
nsresult result = NS_ERROR_NULL_POINTER;

View File

@ -435,8 +435,8 @@ public:
NS_IMETHOD GetClasses(nsVoidArray& aArray) const;
NS_IMETHOD HasClass(nsIAtom* aClass, PRBool aCaseSensitive) const;
NS_IMETHOD WalkContentStyleRules(nsIRuleWalker* aRuleWalker);
NS_IMETHOD WalkInlineStyleRules(nsIRuleWalker* aRuleWalker);
NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker);
NS_IMETHOD WalkInlineStyleRules(nsRuleWalker* aRuleWalker);
NS_IMETHOD GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType,
PRInt32& aHint) const;

View File

@ -49,7 +49,6 @@
#include "nsIHTMLAttributes.h"
#include "nsIStyleRule.h"
#include "nsIFrame.h"
#include "nsIStyleContext.h"
#include "nsHTMLAtoms.h"
#include "nsIPresContext.h"
#include "nsILinkHandler.h"
@ -102,7 +101,7 @@
#include "nsIDocShell.h"
#include "nsFormControlHelper.h"
#include "nsObjectFrame.h"
#include "nsIRuleNode.h"
#include "nsRuleNode.h"
#include "nsIXULDocument.h"
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
@ -11312,24 +11311,12 @@ nsCSSFrameConstructor::RecreateFramesForContent(nsIPresContext* aPresContext,
// data, we need to blow away our style information if this reframe happened as
// a result of an inline style attribute changing.
if (aInlineStyle) {
if (aStyleContext) {
nsCOMPtr<nsIRuleNode> ruleNode;
aStyleContext->GetRuleNode(getter_AddRefs(ruleNode));
ruleNode->ClearCachedData(aInlineStyleRule); // XXXdwh. If we're willing to *really* special case
// inline style, we could only invalidate the struct data
// that actually changed. For example, if someone changes
// style.left, we really only need to blow away cached
// data in the position struct.
}
if (aStyleContext)
aStyleContext->ClearCachedDataForRule(aInlineStyleRule);
else {
// Ok, our only option left is to just crawl the entire rule
// tree and blow away the data that way.
nsCOMPtr<nsIStyleSet> set;
shell->GetStyleSet(getter_AddRefs(set));
nsCOMPtr<nsIRuleNode> rootNode;
set->GetRuleTree(getter_AddRefs(rootNode));
if (rootNode)
rootNode->ClearCachedDataInSubtree(aInlineStyleRule);
set->ClearCachedDataInRuleTree(aInlineStyleRule);
}
}

View File

@ -41,7 +41,6 @@
#include "nsIStyleFrameConstruction.h"
#include "nsIPresContext.h"
#include "nsCOMPtr.h"
#include "nsIStyleContext.h"
#include "nsILayoutHistoryState.h"
#include "nsIXBLService.h"
#include "nsIServiceManager.h"

View File

@ -34,7 +34,6 @@
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsCSSRendering.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
#include "nsIImage.h"
@ -56,6 +55,7 @@
#include "nsIScrollableFrame.h"
#include "imgIRequest.h"
#include "imgIContainer.h"
#include "nsCSSRendering.h"
#define BORDER_FULL 0 //entire side
#define BORDER_INSIDE 1 //inside half

View File

@ -38,8 +38,9 @@
#define nsCSSRendering_h___
#include "nsIRenderingContext.h"
#include "nsIStyleContext.h"
struct nsPoint;
class nsIStyleContext;
class nsIPresContext;
class nsCSSRendering {
public:

View File

@ -55,7 +55,6 @@
#include "nsIStyleSet.h"
#include "nsIStyleSheet.h"
#include "nsICSSStyleSheet.h"
#include "nsIStyleContext.h"
#include "nsIFrame.h"
#include "nsIScriptGlobalObjectOwner.h"

View File

@ -1101,7 +1101,7 @@ DumpContext(nsIFrame* aFrame, nsIStyleContext* aContext)
NS_RELEASE(pseudoTag);
}
/* XXXdwh fix debugging here. Need to add a List method to nsIRuleNode
/* XXXdwh fix debugging here. Need to add a List method to nsRuleNode
and have the context call list on its rule node.
PRInt32 count = aContext->GetStyleRuleCount();
if (0 < count) {

View File

@ -48,7 +48,6 @@
#include "nsICSSStyleSheet.h" // XXX for UA sheet loading hack, can this go away please?
#include "nsIDOMCSSStyleSheet.h" // for Pref-related rule management (bugs 22963,20760,31816)
#include "nsINameSpaceManager.h" // for Pref-related rule management (bugs 22963,20760,31816)
#include "nsIStyleContext.h"
#include "nsIServiceManager.h"
#include "nsFrame.h"
#include "nsIReflowCommand.h"

View File

@ -34,13 +34,21 @@
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsIFrame_h___
#define nsIFrame_h___
/* nsIFrame is in the process of being deCOMtaminated, i.e., this file is eventually
going to be eliminated, and all callers will use nsFrame instead. At the moment
we're midway through this process, so you will see inlined functions and member
variables in this file. -dwh */
#include <stdio.h>
#include "nsISupports.h"
#include "nsEvent.h"
#include "nsStyleStruct.h"
#include "nsIStyleContext.h"
#include "nsIContent.h"
/**
* New rules of reflow:
@ -64,12 +72,10 @@ class nsIReflowCommand;
struct nsHTMLReflowMetrics;
class nsIAtom;
class nsIContent;
class nsIPresContext;
class nsIPresShell;
class nsIRenderingContext;
class nsISizeOfHandler;
class nsIStyleContext;
class nsIView;
class nsIWidget;
class nsIDOMRange;
@ -514,7 +520,7 @@ public:
*
* @see nsISupports#Release()
*/
NS_IMETHOD GetContent(nsIContent** aContent) const = 0;
nsresult GetContent(nsIContent** aContent) const { *aContent = mContent; NS_IF_ADDREF(*aContent); return NS_OK; }
/**
* Get the offsets of the frame. most will be 0,0
@ -528,17 +534,41 @@ public:
*
* @see nsISupports#Release()
*/
NS_IMETHOD GetStyleContext(nsIStyleContext** aStyleContext) const = 0;
NS_IMETHOD SetStyleContext(nsIPresContext* aPresContext,
nsIStyleContext* aContext) = 0;
nsresult GetStyleContext(nsIStyleContext** aStyleContext) const {
NS_IF_ADDREF(mStyleContext); *aStyleContext = mStyleContext; return NS_OK;
}
nsresult SetStyleContext(nsIPresContext* aPresContext, nsIStyleContext* aContext) {
if (aContext != mStyleContext) {
NS_IF_RELEASE(mStyleContext);
if (nsnull != aContext) {
mStyleContext = aContext;
NS_ADDREF(aContext);
DidSetStyleContext(aPresContext);
}
}
return NS_OK;
}
// Style post processing hook
NS_IMETHOD DidSetStyleContext(nsIPresContext* aPresContext) = 0;
/**
* Get the style data associated with this frame.
*/
NS_IMETHOD GetStyleData(nsStyleStructID aSID,
const nsStyleStruct*& aStyleStruct) const = 0;
nsresult GetStyleData(nsStyleStructID aSID,
const nsStyleStruct*& aStyleStruct) const {
NS_ASSERTION(mStyleContext, "No style context found!");
aStyleStruct = mStyleContext->GetStyleData(aSID);
return NS_OK;
}
// Fill a style struct with data
NS_IMETHOD GetStyle(nsStyleStructID aSID, const nsStyleStruct** aStruct) const = 0;
nsresult GetStyle(nsStyleStructID aSID, const nsStyleStruct** aStruct) const {
NS_ASSERTION(mStyleContext, "No style context found!");
mStyleContext->GetStyle(aSID, aStruct);
return NS_OK;
}
// Utility function: more convenient than 2 calls to GetStyleData to get border and padding
NS_IMETHOD CalcBorderPadding(nsMargin& aBorderPadding) const = 0;
@ -560,8 +590,8 @@ public:
/**
* Accessor functions for geometric parent
*/
NS_IMETHOD GetParent(nsIFrame** aParent) const = 0;
NS_IMETHOD SetParent(const nsIFrame* aParent) = 0;
nsresult GetParent(nsIFrame** aParent) const { *aParent = mParent; return NS_OK; }
nsresult SetParent(const nsIFrame* aParent) { mParent = (nsIFrame*)aParent; return NS_OK; }
/**
* Bounding rect of the frame. The values are in twips, and the origin is
@ -571,17 +601,45 @@ public:
* Note: moving or sizing the frame does not affect the view's size or
* position.
*/
NS_IMETHOD GetRect(nsRect& aRect) const = 0;
NS_IMETHOD GetOrigin(nsPoint& aPoint) const = 0;
NS_IMETHOD GetSize(nsSize& aSize) const = 0;
NS_IMETHOD SetRect(nsIPresContext* aPresContext,
const nsRect& aRect) = 0;
NS_IMETHOD MoveTo(nsIPresContext* aPresContext,
nscoord aX,
nscoord aY) = 0;
NS_IMETHOD SizeTo(nsIPresContext* aPresContext,
nscoord aWidth,
nscoord aHeight) = 0;
nsresult GetRect(nsRect& aRect) const {
aRect = mRect;
return NS_OK;
}
nsresult GetOrigin(nsPoint& aPoint) const {
aPoint.x = mRect.x;
aPoint.y = mRect.y;
return NS_OK;
}
nsresult GetSize(nsSize& aSize) const {
aSize.width = mRect.width;
aSize.height = mRect.height;
return NS_OK;
}
nsresult SetRect(nsIPresContext* aPresContext,
const nsRect& aRect) {
MoveTo(aPresContext, aRect.x, aRect.y);
SizeTo(aPresContext, aRect.width, aRect.height);
return NS_OK;
}
nsresult MoveTo(nsIPresContext* aPresContext,
nscoord aX,
nscoord aY) {
mRect.x = aX;
mRect.y = aY;
return NS_OK;
}
nsresult SizeTo(nsIPresContext* aPresContext,
nscoord aWidth,
nscoord aHeight) {
mRect.width = aWidth;
mRect.height = aHeight;
return NS_OK;
}
/**
* Used to iterate the list of additional child list names. Returns the atom
@ -611,8 +669,15 @@ public:
/**
* Child frames are linked together in a singly-linked
*/
NS_IMETHOD GetNextSibling(nsIFrame** aNextSibling) const = 0;
NS_IMETHOD SetNextSibling(nsIFrame* aNextSibling) = 0;
nsresult GetNextSibling(nsIFrame** aNextSibling) const {
*aNextSibling = mNextSibling;
return NS_OK;
}
nsresult SetNextSibling(nsIFrame* aNextSibling) {
mNextSibling = aNextSibling;
return NS_OK;
}
/**
* Paint is responsible for painting the a frame. The aWhichLayer
@ -701,16 +766,20 @@ public:
/**
* Get the current frame-state value for this frame. aResult is
* filled in with the state bits. The return value has no
* meaning.
* filled in with the state bits.
*/
NS_IMETHOD GetFrameState(nsFrameState* aResult) = 0;
nsresult GetFrameState(nsFrameState* aResult) {
*aResult = mState;
return NS_OK;
}
/**
* Set the current frame-state value for this frame. The return
* value has no meaning.
* Set the current frame-state value for this frame.
*/
NS_IMETHOD SetFrameState(nsFrameState aNewState) = 0;
nsresult SetFrameState(nsFrameState aNewState) {
mState = aNewState;
return NS_OK;
}
/**
* This call is invoked when content is changed in the content tree.
@ -1061,6 +1130,15 @@ public:
void* aPropertyValue) = 0;
#endif // IBMBIDI
protected:
// Members
nsRect mRect;
nsIContent* mContent;
nsIStyleContext* mStyleContext;
nsIFrame* mParent;
nsIFrame* mNextSibling; // singly linked list of frames
nsFrameState mState;
private:
NS_IMETHOD_(nsrefcnt) AddRef(void) = 0;
NS_IMETHOD_(nsrefcnt) Release(void) = 0;

View File

@ -47,18 +47,17 @@
#include "nsStyleCoord.h"
#include "nsStyleStruct.h"
#include "nsStyleConsts.h"
#include "nsIStyleSet.h"
#include "nsIPresContext.h"
#include "nsCOMPtr.h"
#include "nsILanguageAtom.h"
#include "nsIFrame.h"
class nsISizeOfHandler;
class nsIFrame;
class nsIStyleSet;
class nsIPresContext;
class nsISupportsArray;
class nsIStyleContext;
class nsIRuleNode;
class nsRuleNode;
//----------------------------------------------------------------------
@ -78,7 +77,7 @@ public:
NS_IMETHOD GetPseudoType(nsIAtom*& aPseudoTag) const = 0;
NS_IMETHOD FindChildWithRules(const nsIAtom* aPseudoTag,
nsIRuleNode* aRules,
nsRuleNode* aRules,
nsIStyleContext*& aResult) = 0;
virtual PRBool HasTextDecorations()=0;
@ -89,7 +88,7 @@ public:
// compute the effective difference between two contexts
NS_IMETHOD CalcStyleDifference(nsIStyleContext* aOther, PRInt32& aHint, PRBool aStopAtFirst = PR_FALSE) = 0;
NS_IMETHOD GetRuleNode(nsIRuleNode** aResult)=0;
NS_IMETHOD GetRuleNode(nsRuleNode** aResult)=0;
NS_IMETHOD AddStyleBit(const PRUint32& aBit)=0;
NS_IMETHOD GetStyleBits(PRUint32* aBits)=0;
@ -115,6 +114,9 @@ public:
// display. Don't add support for new structs or use this method without careful consideration! -dwh
virtual nsStyleStruct* GetUniqueStyleData(nsIPresContext* aPresContext, const nsStyleStructID& aSID) = 0;
// Used only for inline style.
virtual nsresult ClearCachedDataForRule(nsIStyleRule* aRule) = 0;
// Used to clear away the style data for a given style context if it matches the specified |aRule|.
// If |aRule| is null, then the style data is always blown away.
virtual nsresult ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule) = 0;
@ -129,7 +131,7 @@ extern NS_EXPORT nsresult
NS_NewStyleContext(nsIStyleContext** aInstancePtrResult,
nsIStyleContext* aParentContext,
nsIAtom* aPseudoType,
nsIRuleNode* aRuleNode,
nsRuleNode* aRuleNode,
nsIPresContext* aPresContext);

View File

@ -53,7 +53,7 @@ class nsIFrame;
class nsIDocument;
class nsIFrameManager;
class nsISupportsArray;
class nsIRuleNode;
class nsRuleNode;
struct nsFindFrameHint;
#include "nsVoidArray.h"
@ -96,7 +96,8 @@ public:
virtual nsIStyleSheet* GetBackstopStyleSheetAt(PRInt32 aIndex) = 0;
virtual void ReplaceBackstopStyleSheets(nsISupportsArray* aNewSheets) = 0;
virtual nsresult GetRuleTree(nsIRuleNode** aResult) = 0;
virtual nsresult GetRuleTree(nsRuleNode** aResult) = 0;
virtual nsresult ClearCachedDataInRuleTree(nsIStyleRule* aRule) = 0;
virtual nsresult RemoveBodyFixupRule(nsIDocument *aDocument) = 0;

View File

@ -44,7 +44,6 @@
#define nsButtonFrameRenderer_h___
#include "nsCoord.h"
#include "nsIStyleContext.h"
#include "nsCOMPtr.h"
#include "nsFrame.h"

View File

@ -475,15 +475,6 @@ nsFrame::Destroy(nsIPresContext* aPresContext)
return NS_OK;
}
NS_IMETHODIMP
nsFrame::GetContent(nsIContent** aContent) const
{
NS_PRECONDITION(nsnull != aContent, "null OUT parameter pointer");
*aContent = mContent;
NS_IF_ADDREF(*aContent);
return NS_OK;
}
NS_IMETHODIMP
nsFrame::GetOffsets(PRInt32 &aStart, PRInt32 &aEnd) const
{
@ -492,58 +483,12 @@ nsFrame::GetOffsets(PRInt32 &aStart, PRInt32 &aEnd) const
return NS_OK;
}
NS_IMETHODIMP
nsFrame::GetStyleContext(nsIStyleContext** aStyleContext) const
{
NS_PRECONDITION(nsnull != aStyleContext, "null OUT parameter pointer");
NS_ASSERTION(nsnull != mStyleContext, "frame should always have style context");
NS_IF_ADDREF(mStyleContext);
*aStyleContext = mStyleContext;
return NS_OK;
}
NS_IMETHODIMP nsFrame::SetStyleContext(nsIPresContext* aPresContext,nsIStyleContext* aContext)
{
// NS_PRECONDITION(0 == (mState & NS_FRAME_IN_REFLOW), "Shouldn't set style context during reflow");
NS_PRECONDITION(nsnull != aContext, "null ptr");
if (aContext != mStyleContext) {
NS_IF_RELEASE(mStyleContext);
if (nsnull != aContext) {
mStyleContext = aContext;
NS_ADDREF(aContext);
DidSetStyleContext(aPresContext);
}
}
return NS_OK;
}
// Subclass hook for style post processing
NS_IMETHODIMP nsFrame::DidSetStyleContext(nsIPresContext* aPresContext)
{
return NS_OK;
}
NS_IMETHODIMP nsFrame::GetStyleData(nsStyleStructID aSID, const nsStyleStruct*& aStyleStruct) const
{
NS_ASSERTION(mStyleContext!=nsnull,"null style context");
if (mStyleContext) {
aStyleStruct = mStyleContext->GetStyleData(aSID);
} else {
aStyleStruct = nsnull;
}
return NS_OK;
}
NS_IMETHODIMP nsFrame::GetStyle(nsStyleStructID aSID, const nsStyleStruct** aStruct) const {
NS_ASSERTION(mStyleContext!=nsnull,"null style context");
if (mStyleContext) {
return mStyleContext->GetStyle(aSID, aStruct);
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsFrame::CalcBorderPadding(nsMargin& aBorderPadding) const {
NS_ASSERTION(mStyleContext!=nsnull,"null style context");
if (mStyleContext) {
@ -576,65 +521,6 @@ nsFrame::SetAdditionalStyleContext(PRInt32 aIndex,
return ((aIndex < 0) ? NS_ERROR_INVALID_ARG : NS_OK);
}
// Geometric parent member functions
NS_IMETHODIMP nsFrame::GetParent(nsIFrame** aParent) const
{
NS_PRECONDITION(nsnull != aParent, "null OUT parameter pointer");
*aParent = mParent;
return NS_OK;
}
NS_IMETHODIMP nsFrame::SetParent(const nsIFrame* aParent)
{
mParent = (nsIFrame*)aParent;
return NS_OK;
}
// Bounding rect member functions
NS_IMETHODIMP nsFrame::GetRect(nsRect& aRect) const
{
aRect = mRect;
return NS_OK;
}
NS_IMETHODIMP nsFrame::GetOrigin(nsPoint& aPoint) const
{
aPoint.x = mRect.x;
aPoint.y = mRect.y;
return NS_OK;
}
NS_IMETHODIMP nsFrame::GetSize(nsSize& aSize) const
{
aSize.width = mRect.width;
aSize.height = mRect.height;
return NS_OK;
}
NS_IMETHODIMP nsFrame::SetRect(nsIPresContext* aPresContext,
const nsRect& aRect)
{
MoveTo(aPresContext, aRect.x, aRect.y);
SizeTo(aPresContext, aRect.width, aRect.height);
return NS_OK;
}
NS_IMETHODIMP nsFrame::MoveTo(nsIPresContext* aPresContext, nscoord aX, nscoord aY)
{
mRect.x = aX;
mRect.y = aY;
return NS_OK;
}
NS_IMETHODIMP nsFrame::SizeTo(nsIPresContext* aPresContext, nscoord aWidth, nscoord aHeight)
{
mRect.width = aWidth;
mRect.height = aHeight;
return NS_OK;
}
// Child frame enumeration
NS_IMETHODIMP
@ -1870,20 +1756,6 @@ nsFrame::GetFrameForPoint(nsIPresContext* aPresContext,
}
// Resize and incremental reflow
NS_IMETHODIMP
nsFrame::GetFrameState(nsFrameState* aResult)
{
NS_PRECONDITION(nsnull != aResult, "null OUT parameter pointer");
*aResult = mState;
return NS_OK;
}
NS_IMETHODIMP
nsFrame::SetFrameState(nsFrameState aNewState)
{
mState = aNewState;
return NS_OK;
}
// nsIHTMLReflow member functions
@ -2308,22 +2180,6 @@ NS_IMETHODIMP nsFrame::IsPercentageBase(PRBool& aBase) const
return NS_OK;
}
// Sibling pointer used to link together frames
NS_IMETHODIMP nsFrame::GetNextSibling(nsIFrame** aNextSibling) const
{
NS_PRECONDITION(nsnull != aNextSibling, "null OUT parameter pointer");
*aNextSibling = mNextSibling;
return NS_OK;
}
NS_IMETHODIMP nsFrame::SetNextSibling(nsIFrame* aNextSibling)
{
NS_ASSERTION(aNextSibling != this, "attempt to create circular frame list");
mNextSibling = aNextSibling;
return NS_OK;
}
NS_IMETHODIMP nsFrame::Scrolled(nsIView *aView)
{
return NS_OK;
@ -4115,9 +3971,9 @@ nsFrame::CaptureMouse(nsIPresContext* aPresContext, PRBool aGrabMouseEvents)
if (!view)
{
nsresult rv = GetParentWithView(aPresContext, &parent);
if (NS_FAILED(rv))
if (NS_FAILED(rv))
return rv;
if (!parent)
if (!parent)
return NS_ERROR_FAILURE;
parent->GetView(aPresContext,&view);
}
@ -4149,9 +4005,9 @@ nsFrame::IsMouseCaptured(nsIPresContext* aPresContext)
{
nsIFrame *parent;//might be THIS frame thats ok
nsresult rv = GetParentWithView(aPresContext, &parent);
if (NS_FAILED(rv))
if (NS_FAILED(rv))
return rv;
if (!parent)
if (!parent)
return NS_ERROR_FAILURE;
parent->GetView(aPresContext,&view);

View File

@ -184,26 +184,11 @@ public:
nsIFrame* aOldFrame,
nsIFrame* aNewFrame);
NS_IMETHOD Destroy(nsIPresContext* aPresContext);
NS_IMETHOD GetContent(nsIContent** aContent) const;
NS_IMETHOD GetStyleContext(nsIStyleContext** aStyleContext) const;
NS_IMETHOD SetStyleContext(nsIPresContext* aPresContext,
nsIStyleContext* aContext);
NS_IMETHOD GetStyleData(nsStyleStructID aSID,
const nsStyleStruct*& aStyleStruct) const;
NS_IMETHOD GetStyle(nsStyleStructID aSID, const nsStyleStruct** aStruct) const;
NS_IMETHOD CalcBorderPadding(nsMargin& aBorderPadding) const;
NS_IMETHOD GetAdditionalStyleContext(PRInt32 aIndex,
nsIStyleContext** aStyleContext) const;
NS_IMETHOD SetAdditionalStyleContext(PRInt32 aIndex,
nsIStyleContext* aStyleContext);
NS_IMETHOD GetParent(nsIFrame** aParent) const;
NS_IMETHOD SetParent(const nsIFrame* aParent);
NS_IMETHOD GetRect(nsRect& aRect) const;
NS_IMETHOD GetOrigin(nsPoint& aPoint) const;
NS_IMETHOD GetSize(nsSize& aSize) const;
NS_IMETHOD SetRect(nsIPresContext* aPresContext, const nsRect& aRect);
NS_IMETHOD MoveTo(nsIPresContext* aPresContext, nscoord aX, nscoord aY);
NS_IMETHOD SizeTo(nsIPresContext* aPresContext, nscoord aWidth, nscoord aHeight);
NS_IMETHOD GetAdditionalChildListName(PRInt32 aIndex, nsIAtom** aListName) const;
NS_IMETHOD FirstChild(nsIPresContext* aPresContext,
nsIAtom* aListName,
@ -243,10 +228,6 @@ public:
PRInt32 aLineStart,
PRInt8 aOutSideLimit
);
NS_IMETHOD GetFrameState(nsFrameState* aResult);
NS_IMETHOD SetFrameState(nsFrameState aNewState);
NS_IMETHOD ContentChanged(nsIPresContext* aPresContext,
nsIContent* aChild,
nsISupports* aSubContent);
@ -271,8 +252,6 @@ public:
NS_IMETHOD GetWindow(nsIPresContext* aPresContext, nsIWidget**) const;
NS_IMETHOD GetFrameType(nsIAtom** aType) const;
NS_IMETHOD IsPercentageBase(PRBool& aBase) const;
NS_IMETHOD GetNextSibling(nsIFrame** aNextSibling) const;
NS_IMETHOD SetNextSibling(nsIFrame* aNextSibling);
NS_IMETHOD Scrolled(nsIView *aView);
#ifdef NS_DEBUG
NS_IMETHOD List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) const;
@ -499,13 +478,6 @@ protected:
// applies to its situation.
void SetOverflowClipRect(nsIRenderingContext& aRenderingContext);
nsRect mRect;
nsIContent* mContent;
nsIStyleContext* mStyleContext;
nsIFrame* mParent;
nsIFrame* mNextSibling; // singly linked list of frames
nsFrameState mState;
protected:
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);

View File

@ -37,7 +37,6 @@
#include "nsCOMPtr.h"
#include "nsHTMLParts.h"
#include "nsIPresContext.h"
#include "nsIStyleContext.h"
#include "nsIReflowCommand.h"
#include "nsIDeviceContext.h"
#include "nsPageFrame.h"

View File

@ -35,7 +35,6 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsCOMPtr.h"
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsFrame.h"
#include "nsIContent.h"

View File

@ -34,13 +34,21 @@
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsIFrame_h___
#define nsIFrame_h___
/* nsIFrame is in the process of being deCOMtaminated, i.e., this file is eventually
going to be eliminated, and all callers will use nsFrame instead. At the moment
we're midway through this process, so you will see inlined functions and member
variables in this file. -dwh */
#include <stdio.h>
#include "nsISupports.h"
#include "nsEvent.h"
#include "nsStyleStruct.h"
#include "nsIStyleContext.h"
#include "nsIContent.h"
/**
* New rules of reflow:
@ -64,12 +72,10 @@ class nsIReflowCommand;
struct nsHTMLReflowMetrics;
class nsIAtom;
class nsIContent;
class nsIPresContext;
class nsIPresShell;
class nsIRenderingContext;
class nsISizeOfHandler;
class nsIStyleContext;
class nsIView;
class nsIWidget;
class nsIDOMRange;
@ -514,7 +520,7 @@ public:
*
* @see nsISupports#Release()
*/
NS_IMETHOD GetContent(nsIContent** aContent) const = 0;
nsresult GetContent(nsIContent** aContent) const { *aContent = mContent; NS_IF_ADDREF(*aContent); return NS_OK; }
/**
* Get the offsets of the frame. most will be 0,0
@ -528,17 +534,41 @@ public:
*
* @see nsISupports#Release()
*/
NS_IMETHOD GetStyleContext(nsIStyleContext** aStyleContext) const = 0;
NS_IMETHOD SetStyleContext(nsIPresContext* aPresContext,
nsIStyleContext* aContext) = 0;
nsresult GetStyleContext(nsIStyleContext** aStyleContext) const {
NS_IF_ADDREF(mStyleContext); *aStyleContext = mStyleContext; return NS_OK;
}
nsresult SetStyleContext(nsIPresContext* aPresContext, nsIStyleContext* aContext) {
if (aContext != mStyleContext) {
NS_IF_RELEASE(mStyleContext);
if (nsnull != aContext) {
mStyleContext = aContext;
NS_ADDREF(aContext);
DidSetStyleContext(aPresContext);
}
}
return NS_OK;
}
// Style post processing hook
NS_IMETHOD DidSetStyleContext(nsIPresContext* aPresContext) = 0;
/**
* Get the style data associated with this frame.
*/
NS_IMETHOD GetStyleData(nsStyleStructID aSID,
const nsStyleStruct*& aStyleStruct) const = 0;
nsresult GetStyleData(nsStyleStructID aSID,
const nsStyleStruct*& aStyleStruct) const {
NS_ASSERTION(mStyleContext, "No style context found!");
aStyleStruct = mStyleContext->GetStyleData(aSID);
return NS_OK;
}
// Fill a style struct with data
NS_IMETHOD GetStyle(nsStyleStructID aSID, const nsStyleStruct** aStruct) const = 0;
nsresult GetStyle(nsStyleStructID aSID, const nsStyleStruct** aStruct) const {
NS_ASSERTION(mStyleContext, "No style context found!");
mStyleContext->GetStyle(aSID, aStruct);
return NS_OK;
}
// Utility function: more convenient than 2 calls to GetStyleData to get border and padding
NS_IMETHOD CalcBorderPadding(nsMargin& aBorderPadding) const = 0;
@ -560,8 +590,8 @@ public:
/**
* Accessor functions for geometric parent
*/
NS_IMETHOD GetParent(nsIFrame** aParent) const = 0;
NS_IMETHOD SetParent(const nsIFrame* aParent) = 0;
nsresult GetParent(nsIFrame** aParent) const { *aParent = mParent; return NS_OK; }
nsresult SetParent(const nsIFrame* aParent) { mParent = (nsIFrame*)aParent; return NS_OK; }
/**
* Bounding rect of the frame. The values are in twips, and the origin is
@ -571,17 +601,45 @@ public:
* Note: moving or sizing the frame does not affect the view's size or
* position.
*/
NS_IMETHOD GetRect(nsRect& aRect) const = 0;
NS_IMETHOD GetOrigin(nsPoint& aPoint) const = 0;
NS_IMETHOD GetSize(nsSize& aSize) const = 0;
NS_IMETHOD SetRect(nsIPresContext* aPresContext,
const nsRect& aRect) = 0;
NS_IMETHOD MoveTo(nsIPresContext* aPresContext,
nscoord aX,
nscoord aY) = 0;
NS_IMETHOD SizeTo(nsIPresContext* aPresContext,
nscoord aWidth,
nscoord aHeight) = 0;
nsresult GetRect(nsRect& aRect) const {
aRect = mRect;
return NS_OK;
}
nsresult GetOrigin(nsPoint& aPoint) const {
aPoint.x = mRect.x;
aPoint.y = mRect.y;
return NS_OK;
}
nsresult GetSize(nsSize& aSize) const {
aSize.width = mRect.width;
aSize.height = mRect.height;
return NS_OK;
}
nsresult SetRect(nsIPresContext* aPresContext,
const nsRect& aRect) {
MoveTo(aPresContext, aRect.x, aRect.y);
SizeTo(aPresContext, aRect.width, aRect.height);
return NS_OK;
}
nsresult MoveTo(nsIPresContext* aPresContext,
nscoord aX,
nscoord aY) {
mRect.x = aX;
mRect.y = aY;
return NS_OK;
}
nsresult SizeTo(nsIPresContext* aPresContext,
nscoord aWidth,
nscoord aHeight) {
mRect.width = aWidth;
mRect.height = aHeight;
return NS_OK;
}
/**
* Used to iterate the list of additional child list names. Returns the atom
@ -611,8 +669,15 @@ public:
/**
* Child frames are linked together in a singly-linked
*/
NS_IMETHOD GetNextSibling(nsIFrame** aNextSibling) const = 0;
NS_IMETHOD SetNextSibling(nsIFrame* aNextSibling) = 0;
nsresult GetNextSibling(nsIFrame** aNextSibling) const {
*aNextSibling = mNextSibling;
return NS_OK;
}
nsresult SetNextSibling(nsIFrame* aNextSibling) {
mNextSibling = aNextSibling;
return NS_OK;
}
/**
* Paint is responsible for painting the a frame. The aWhichLayer
@ -701,16 +766,20 @@ public:
/**
* Get the current frame-state value for this frame. aResult is
* filled in with the state bits. The return value has no
* meaning.
* filled in with the state bits.
*/
NS_IMETHOD GetFrameState(nsFrameState* aResult) = 0;
nsresult GetFrameState(nsFrameState* aResult) {
*aResult = mState;
return NS_OK;
}
/**
* Set the current frame-state value for this frame. The return
* value has no meaning.
* Set the current frame-state value for this frame.
*/
NS_IMETHOD SetFrameState(nsFrameState aNewState) = 0;
nsresult SetFrameState(nsFrameState aNewState) {
mState = aNewState;
return NS_OK;
}
/**
* This call is invoked when content is changed in the content tree.
@ -1061,6 +1130,15 @@ public:
void* aPropertyValue) = 0;
#endif // IBMBIDI
protected:
// Members
nsRect mRect;
nsIContent* mContent;
nsIStyleContext* mStyleContext;
nsIFrame* mParent;
nsIFrame* mNextSibling; // singly linked list of frames
nsFrameState mState;
private:
NS_IMETHOD_(nsrefcnt) AddRef(void) = 0;
NS_IMETHOD_(nsrefcnt) Release(void) = 0;

View File

@ -475,15 +475,6 @@ nsFrame::Destroy(nsIPresContext* aPresContext)
return NS_OK;
}
NS_IMETHODIMP
nsFrame::GetContent(nsIContent** aContent) const
{
NS_PRECONDITION(nsnull != aContent, "null OUT parameter pointer");
*aContent = mContent;
NS_IF_ADDREF(*aContent);
return NS_OK;
}
NS_IMETHODIMP
nsFrame::GetOffsets(PRInt32 &aStart, PRInt32 &aEnd) const
{
@ -492,58 +483,12 @@ nsFrame::GetOffsets(PRInt32 &aStart, PRInt32 &aEnd) const
return NS_OK;
}
NS_IMETHODIMP
nsFrame::GetStyleContext(nsIStyleContext** aStyleContext) const
{
NS_PRECONDITION(nsnull != aStyleContext, "null OUT parameter pointer");
NS_ASSERTION(nsnull != mStyleContext, "frame should always have style context");
NS_IF_ADDREF(mStyleContext);
*aStyleContext = mStyleContext;
return NS_OK;
}
NS_IMETHODIMP nsFrame::SetStyleContext(nsIPresContext* aPresContext,nsIStyleContext* aContext)
{
// NS_PRECONDITION(0 == (mState & NS_FRAME_IN_REFLOW), "Shouldn't set style context during reflow");
NS_PRECONDITION(nsnull != aContext, "null ptr");
if (aContext != mStyleContext) {
NS_IF_RELEASE(mStyleContext);
if (nsnull != aContext) {
mStyleContext = aContext;
NS_ADDREF(aContext);
DidSetStyleContext(aPresContext);
}
}
return NS_OK;
}
// Subclass hook for style post processing
NS_IMETHODIMP nsFrame::DidSetStyleContext(nsIPresContext* aPresContext)
{
return NS_OK;
}
NS_IMETHODIMP nsFrame::GetStyleData(nsStyleStructID aSID, const nsStyleStruct*& aStyleStruct) const
{
NS_ASSERTION(mStyleContext!=nsnull,"null style context");
if (mStyleContext) {
aStyleStruct = mStyleContext->GetStyleData(aSID);
} else {
aStyleStruct = nsnull;
}
return NS_OK;
}
NS_IMETHODIMP nsFrame::GetStyle(nsStyleStructID aSID, const nsStyleStruct** aStruct) const {
NS_ASSERTION(mStyleContext!=nsnull,"null style context");
if (mStyleContext) {
return mStyleContext->GetStyle(aSID, aStruct);
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsFrame::CalcBorderPadding(nsMargin& aBorderPadding) const {
NS_ASSERTION(mStyleContext!=nsnull,"null style context");
if (mStyleContext) {
@ -576,65 +521,6 @@ nsFrame::SetAdditionalStyleContext(PRInt32 aIndex,
return ((aIndex < 0) ? NS_ERROR_INVALID_ARG : NS_OK);
}
// Geometric parent member functions
NS_IMETHODIMP nsFrame::GetParent(nsIFrame** aParent) const
{
NS_PRECONDITION(nsnull != aParent, "null OUT parameter pointer");
*aParent = mParent;
return NS_OK;
}
NS_IMETHODIMP nsFrame::SetParent(const nsIFrame* aParent)
{
mParent = (nsIFrame*)aParent;
return NS_OK;
}
// Bounding rect member functions
NS_IMETHODIMP nsFrame::GetRect(nsRect& aRect) const
{
aRect = mRect;
return NS_OK;
}
NS_IMETHODIMP nsFrame::GetOrigin(nsPoint& aPoint) const
{
aPoint.x = mRect.x;
aPoint.y = mRect.y;
return NS_OK;
}
NS_IMETHODIMP nsFrame::GetSize(nsSize& aSize) const
{
aSize.width = mRect.width;
aSize.height = mRect.height;
return NS_OK;
}
NS_IMETHODIMP nsFrame::SetRect(nsIPresContext* aPresContext,
const nsRect& aRect)
{
MoveTo(aPresContext, aRect.x, aRect.y);
SizeTo(aPresContext, aRect.width, aRect.height);
return NS_OK;
}
NS_IMETHODIMP nsFrame::MoveTo(nsIPresContext* aPresContext, nscoord aX, nscoord aY)
{
mRect.x = aX;
mRect.y = aY;
return NS_OK;
}
NS_IMETHODIMP nsFrame::SizeTo(nsIPresContext* aPresContext, nscoord aWidth, nscoord aHeight)
{
mRect.width = aWidth;
mRect.height = aHeight;
return NS_OK;
}
// Child frame enumeration
NS_IMETHODIMP
@ -1870,20 +1756,6 @@ nsFrame::GetFrameForPoint(nsIPresContext* aPresContext,
}
// Resize and incremental reflow
NS_IMETHODIMP
nsFrame::GetFrameState(nsFrameState* aResult)
{
NS_PRECONDITION(nsnull != aResult, "null OUT parameter pointer");
*aResult = mState;
return NS_OK;
}
NS_IMETHODIMP
nsFrame::SetFrameState(nsFrameState aNewState)
{
mState = aNewState;
return NS_OK;
}
// nsIHTMLReflow member functions
@ -2308,22 +2180,6 @@ NS_IMETHODIMP nsFrame::IsPercentageBase(PRBool& aBase) const
return NS_OK;
}
// Sibling pointer used to link together frames
NS_IMETHODIMP nsFrame::GetNextSibling(nsIFrame** aNextSibling) const
{
NS_PRECONDITION(nsnull != aNextSibling, "null OUT parameter pointer");
*aNextSibling = mNextSibling;
return NS_OK;
}
NS_IMETHODIMP nsFrame::SetNextSibling(nsIFrame* aNextSibling)
{
NS_ASSERTION(aNextSibling != this, "attempt to create circular frame list");
mNextSibling = aNextSibling;
return NS_OK;
}
NS_IMETHODIMP nsFrame::Scrolled(nsIView *aView)
{
return NS_OK;
@ -4115,9 +3971,9 @@ nsFrame::CaptureMouse(nsIPresContext* aPresContext, PRBool aGrabMouseEvents)
if (!view)
{
nsresult rv = GetParentWithView(aPresContext, &parent);
if (NS_FAILED(rv))
if (NS_FAILED(rv))
return rv;
if (!parent)
if (!parent)
return NS_ERROR_FAILURE;
parent->GetView(aPresContext,&view);
}
@ -4149,9 +4005,9 @@ nsFrame::IsMouseCaptured(nsIPresContext* aPresContext)
{
nsIFrame *parent;//might be THIS frame thats ok
nsresult rv = GetParentWithView(aPresContext, &parent);
if (NS_FAILED(rv))
if (NS_FAILED(rv))
return rv;
if (!parent)
if (!parent)
return NS_ERROR_FAILURE;
parent->GetView(aPresContext,&view);

View File

@ -184,26 +184,11 @@ public:
nsIFrame* aOldFrame,
nsIFrame* aNewFrame);
NS_IMETHOD Destroy(nsIPresContext* aPresContext);
NS_IMETHOD GetContent(nsIContent** aContent) const;
NS_IMETHOD GetStyleContext(nsIStyleContext** aStyleContext) const;
NS_IMETHOD SetStyleContext(nsIPresContext* aPresContext,
nsIStyleContext* aContext);
NS_IMETHOD GetStyleData(nsStyleStructID aSID,
const nsStyleStruct*& aStyleStruct) const;
NS_IMETHOD GetStyle(nsStyleStructID aSID, const nsStyleStruct** aStruct) const;
NS_IMETHOD CalcBorderPadding(nsMargin& aBorderPadding) const;
NS_IMETHOD GetAdditionalStyleContext(PRInt32 aIndex,
nsIStyleContext** aStyleContext) const;
NS_IMETHOD SetAdditionalStyleContext(PRInt32 aIndex,
nsIStyleContext* aStyleContext);
NS_IMETHOD GetParent(nsIFrame** aParent) const;
NS_IMETHOD SetParent(const nsIFrame* aParent);
NS_IMETHOD GetRect(nsRect& aRect) const;
NS_IMETHOD GetOrigin(nsPoint& aPoint) const;
NS_IMETHOD GetSize(nsSize& aSize) const;
NS_IMETHOD SetRect(nsIPresContext* aPresContext, const nsRect& aRect);
NS_IMETHOD MoveTo(nsIPresContext* aPresContext, nscoord aX, nscoord aY);
NS_IMETHOD SizeTo(nsIPresContext* aPresContext, nscoord aWidth, nscoord aHeight);
NS_IMETHOD GetAdditionalChildListName(PRInt32 aIndex, nsIAtom** aListName) const;
NS_IMETHOD FirstChild(nsIPresContext* aPresContext,
nsIAtom* aListName,
@ -243,10 +228,6 @@ public:
PRInt32 aLineStart,
PRInt8 aOutSideLimit
);
NS_IMETHOD GetFrameState(nsFrameState* aResult);
NS_IMETHOD SetFrameState(nsFrameState aNewState);
NS_IMETHOD ContentChanged(nsIPresContext* aPresContext,
nsIContent* aChild,
nsISupports* aSubContent);
@ -271,8 +252,6 @@ public:
NS_IMETHOD GetWindow(nsIPresContext* aPresContext, nsIWidget**) const;
NS_IMETHOD GetFrameType(nsIAtom** aType) const;
NS_IMETHOD IsPercentageBase(PRBool& aBase) const;
NS_IMETHOD GetNextSibling(nsIFrame** aNextSibling) const;
NS_IMETHOD SetNextSibling(nsIFrame* aNextSibling);
NS_IMETHOD Scrolled(nsIView *aView);
#ifdef NS_DEBUG
NS_IMETHOD List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) const;
@ -499,13 +478,6 @@ protected:
// applies to its situation.
void SetOverflowClipRect(nsIRenderingContext& aRenderingContext);
nsRect mRect;
nsIContent* mContent;
nsIStyleContext* mStyleContext;
nsIFrame* mParent;
nsIFrame* mNextSibling; // singly linked list of frames
nsFrameState mState;
protected:
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);

View File

@ -1101,7 +1101,7 @@ DumpContext(nsIFrame* aFrame, nsIStyleContext* aContext)
NS_RELEASE(pseudoTag);
}
/* XXXdwh fix debugging here. Need to add a List method to nsIRuleNode
/* XXXdwh fix debugging here. Need to add a List method to nsRuleNode
and have the context call list on its rule node.
PRInt32 count = aContext->GetStyleRuleCount();
if (0 < count) {

View File

@ -37,7 +37,6 @@
#include "nsCOMPtr.h"
#include "nsHTMLParts.h"
#include "nsIPresContext.h"
#include "nsIStyleContext.h"
#include "nsIReflowCommand.h"
#include "nsIDeviceContext.h"
#include "nsPageFrame.h"

View File

@ -35,7 +35,6 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsCOMPtr.h"
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
#include "nsFrame.h"
#include "nsIContent.h"

View File

@ -48,7 +48,6 @@
#include "nsICSSStyleSheet.h" // XXX for UA sheet loading hack, can this go away please?
#include "nsIDOMCSSStyleSheet.h" // for Pref-related rule management (bugs 22963,20760,31816)
#include "nsINameSpaceManager.h" // for Pref-related rule management (bugs 22963,20760,31816)
#include "nsIStyleContext.h"
#include "nsIServiceManager.h"
#include "nsFrame.h"
#include "nsIReflowCommand.h"

View File

@ -38,7 +38,6 @@
#include "nsCOMPtr.h"
#include "nsHTMLParts.h"
#include "nsIPresContext.h"
#include "nsIStyleContext.h"
#include "nsIReflowCommand.h"
#include "nsIDeviceContext.h"
#include "nsPageFrame.h"

View File

@ -44,7 +44,6 @@
#define nsButtonFrameRenderer_h___
#include "nsCoord.h"
#include "nsIStyleContext.h"
#include "nsCOMPtr.h"
#include "nsFrame.h"

View File

@ -49,7 +49,6 @@
#include "nsIHTMLAttributes.h"
#include "nsIStyleRule.h"
#include "nsIFrame.h"
#include "nsIStyleContext.h"
#include "nsHTMLAtoms.h"
#include "nsIPresContext.h"
#include "nsILinkHandler.h"
@ -102,7 +101,7 @@
#include "nsIDocShell.h"
#include "nsFormControlHelper.h"
#include "nsObjectFrame.h"
#include "nsIRuleNode.h"
#include "nsRuleNode.h"
#include "nsIXULDocument.h"
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
@ -11312,24 +11311,12 @@ nsCSSFrameConstructor::RecreateFramesForContent(nsIPresContext* aPresContext,
// data, we need to blow away our style information if this reframe happened as
// a result of an inline style attribute changing.
if (aInlineStyle) {
if (aStyleContext) {
nsCOMPtr<nsIRuleNode> ruleNode;
aStyleContext->GetRuleNode(getter_AddRefs(ruleNode));
ruleNode->ClearCachedData(aInlineStyleRule); // XXXdwh. If we're willing to *really* special case
// inline style, we could only invalidate the struct data
// that actually changed. For example, if someone changes
// style.left, we really only need to blow away cached
// data in the position struct.
}
if (aStyleContext)
aStyleContext->ClearCachedDataForRule(aInlineStyleRule);
else {
// Ok, our only option left is to just crawl the entire rule
// tree and blow away the data that way.
nsCOMPtr<nsIStyleSet> set;
shell->GetStyleSet(getter_AddRefs(set));
nsCOMPtr<nsIRuleNode> rootNode;
set->GetRuleTree(getter_AddRefs(rootNode));
if (rootNode)
rootNode->ClearCachedDataInSubtree(aInlineStyleRule);
set->ClearCachedDataInRuleTree(aInlineStyleRule);
}
}

View File

@ -41,7 +41,6 @@
#include "nsIStyleFrameConstruction.h"
#include "nsIPresContext.h"
#include "nsCOMPtr.h"
#include "nsIStyleContext.h"
#include "nsILayoutHistoryState.h"
#include "nsIXBLService.h"
#include "nsIServiceManager.h"

View File

@ -34,7 +34,6 @@
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsCSSRendering.h"
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
#include "nsIImage.h"
@ -56,6 +55,7 @@
#include "nsIScrollableFrame.h"
#include "imgIRequest.h"
#include "imgIContainer.h"
#include "nsCSSRendering.h"
#define BORDER_FULL 0 //entire side
#define BORDER_INSIDE 1 //inside half

View File

@ -38,8 +38,9 @@
#define nsCSSRendering_h___
#include "nsIRenderingContext.h"
#include "nsIStyleContext.h"
struct nsPoint;
class nsIStyleContext;
class nsIPresContext;
class nsCSSRendering {
public:

View File

@ -1227,6 +1227,8 @@ CSSLoaderImpl::LoadSheet(URLKey& aKey, SheetLoadData* aData)
nsCOMPtr<nsILoadGroup> loadGroup;
mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
NS_ASSERTION(loadGroup, "A stylesheet was unable to locate a load group. This means the onload is going to fire too early!");
#ifdef MOZ_TIMELINE
NS_TIMELINE_MARK_URI("Loading style sheet: %s", urlClone);
NS_TIMELINE_INDENT();

View File

@ -69,7 +69,7 @@
#include "nsINameSpace.h"
#include "nsILookAndFeel.h"
#include "xp_core.h"
#include "nsIRuleNode.h"
#include "nsRuleNode.h"
#include "nsIStyleSet.h"
#include "nsISizeOfHandler.h"

View File

@ -80,7 +80,7 @@
#include "nsIPresShell.h"
#include "nsICSSParser.h"
#include "nsICSSLoader.h"
#include "nsIRuleWalker.h"
#include "nsRuleWalker.h"
#include "nsCSSAtoms.h"
#include "nsINameSpaceManager.h"
#include "nsINameSpace.h"
@ -717,7 +717,7 @@ public:
nsIAtom* aMedium,
nsIContent* aContent,
nsIStyleContext* aParentContext,
nsIRuleWalker* aRuleWalker);
nsRuleWalker* aRuleWalker);
NS_IMETHOD RulesMatching(nsIPresContext* aPresContext,
nsIAtom* aMedium,
@ -725,7 +725,7 @@ public:
nsIAtom* aPseudoTag,
nsIStyleContext* aParentContext,
nsICSSPseudoComparator* aComparator,
nsIRuleWalker* aRuleWalker);
nsRuleWalker* aRuleWalker);
NS_IMETHOD HasStateDependentStyle(nsIPresContext* aPresContext,
nsIAtom* aMedium,
@ -3226,7 +3226,7 @@ MOZ_DECL_CTOR_COUNTER(SelectorMatchesData)
struct SelectorMatchesData {
SelectorMatchesData(nsIPresContext* aPresContext, nsIContent* aContent,
nsIRuleWalker* aRuleWalker, nsCompatibility* aCompat = nsnull);
nsRuleWalker* aRuleWalker, nsCompatibility* aCompat = nsnull);
virtual ~SelectorMatchesData()
{
@ -3256,7 +3256,7 @@ struct SelectorMatchesData {
nsIPresContext* mPresContext;
nsIContent* mContent;
nsIContent* mParentContent; // if content, content->GetParent()
nsCOMPtr<nsIRuleWalker> mRuleWalker; // Used to add rules to our results.
nsRuleWalker* mRuleWalker; // Used to add rules to our results.
nsCOMPtr<nsIStyleRuleSupplier> mStyleRuleSupplier; // used to query for the current scope
nsIAtom* mContentTag; // if content, then content->GetTag()
@ -3275,7 +3275,7 @@ struct SelectorMatchesData {
};
SelectorMatchesData::SelectorMatchesData(nsIPresContext* aPresContext, nsIContent* aContent,
nsIRuleWalker* aRuleWalker,
nsRuleWalker* aRuleWalker,
nsCompatibility* aCompat /*= nsnull*/)
{
MOZ_COUNT_CTOR(SelectorMatchesData);
@ -3797,7 +3797,7 @@ static PRBool SelectorMatches(SelectorMatchesData &data,
struct ContentEnumData : public SelectorMatchesData {
ContentEnumData(nsIPresContext* aPresContext, nsIContent* aContent,
nsIRuleWalker* aRuleWalker)
nsRuleWalker* aRuleWalker)
: SelectorMatchesData(aPresContext,aContent,aRuleWalker)
{}
};
@ -3947,7 +3947,7 @@ CSSRuleProcessor::RulesMatching(nsIPresContext* aPresContext,
nsIAtom* aMedium,
nsIContent* aContent,
nsIStyleContext* aParentContext,
nsIRuleWalker* aRuleWalker)
nsRuleWalker* aRuleWalker)
{
NS_PRECONDITION(nsnull != aPresContext, "null arg");
NS_PRECONDITION(nsnull != aContent, "null arg");
@ -3994,7 +3994,7 @@ CSSRuleProcessor::RulesMatching(nsIPresContext* aPresContext,
struct PseudoEnumData : public SelectorMatchesData {
PseudoEnumData(nsIPresContext* aPresContext, nsIContent* aParentContent,
nsIAtom* aPseudoTag, nsICSSPseudoComparator* aComparator,
nsIRuleWalker* aRuleWalker)
nsRuleWalker* aRuleWalker)
: SelectorMatchesData(aPresContext, aParentContent, aRuleWalker)
{
mPseudoTag = aPseudoTag;
@ -4061,7 +4061,7 @@ CSSRuleProcessor::RulesMatching(nsIPresContext* aPresContext,
nsIAtom* aPseudoTag,
nsIStyleContext* aParentContext,
nsICSSPseudoComparator* aComparator,
nsIRuleWalker* aRuleWalker)
nsRuleWalker* aRuleWalker)
{
NS_PRECONDITION(nsnull != aPresContext, "null arg");
NS_PRECONDITION(nsnull != aPseudoTag, "null arg");

View File

@ -56,7 +56,7 @@
#include "nsCOMPtr.h"
#include "nsIStyleSet.h"
#include "nsIRuleWalker.h"
#include "nsRuleWalker.h"
#include "nsISizeOfHandler.h"
@ -248,7 +248,7 @@ public:
nsIAtom* aMedium,
nsIContent* aContent,
nsIStyleContext* aParentContext,
nsIRuleWalker* aRuleWalker);
nsRuleWalker* aRuleWalker);
NS_IMETHOD RulesMatching(nsIPresContext* aPresContext,
nsIAtom* aMedium,
@ -256,7 +256,7 @@ public:
nsIAtom* aPseudoTag,
nsIStyleContext* aParentContext,
nsICSSPseudoComparator* aComparator,
nsIRuleWalker* aRuleWalker);
nsRuleWalker* aRuleWalker);
NS_IMETHOD HasStateDependentStyle(nsIPresContext* aPresContext,
nsIAtom* aMedium,
@ -400,7 +400,7 @@ HTMLCSSStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
nsIAtom* aMedium,
nsIContent* aContent,
nsIStyleContext* aParentContext,
nsIRuleWalker* aRuleWalker)
nsRuleWalker* aRuleWalker)
{
NS_PRECONDITION(nsnull != aPresContext, "null arg");
NS_PRECONDITION(nsnull != aContent, "null arg");
@ -422,12 +422,10 @@ HTMLCSSStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
nsIAtom* aPseudoTag,
nsIStyleContext* aParentContext,
nsICSSPseudoComparator* aComparator,
nsIRuleWalker* aRuleWalker)
nsRuleWalker* aRuleWalker)
{
if (aPseudoTag == nsHTMLAtoms::firstLinePseudo) {
PRBool atRoot = PR_FALSE;
aRuleWalker->AtRoot(&atRoot);
if (!atRoot) {
if (!aRuleWalker->AtRoot()) {
if (nsnull == mFirstLineRule) {
mFirstLineRule = new CSSFirstLineRule(this);
if (mFirstLineRule) {
@ -441,9 +439,7 @@ HTMLCSSStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
}
}
if (aPseudoTag == nsHTMLAtoms::firstLetterPseudo) {
PRBool atRoot = PR_FALSE;
aRuleWalker->AtRoot(&atRoot);
if (!atRoot) {
if (!aRuleWalker->AtRoot()) {
if (nsnull == mFirstLetterRule) {
mFirstLetterRule = new CSSFirstLetterRule(this);
if (mFirstLetterRule) {

View File

@ -59,7 +59,7 @@
#include "nsContentCID.h"
#include "nsLayoutCID.h"
#include "nsIRuleWalker.h"
#include "nsRuleWalker.h"
#include "nsIStyleSet.h"
#include "nsISizeOfHandler.h"
@ -567,7 +567,7 @@ public:
nsIAtom* aMedium,
nsIContent* aContent,
nsIStyleContext* aParentContext,
nsIRuleWalker* aRuleWalker);
nsRuleWalker* aRuleWalker);
NS_IMETHOD RulesMatching(nsIPresContext* aPresContext,
nsIAtom* aMedium,
@ -575,7 +575,7 @@ public:
nsIAtom* aPseudoTag,
nsIStyleContext* aParentContext,
nsICSSPseudoComparator* aComparator,
nsIRuleWalker* aRuleWalker);
nsRuleWalker* aRuleWalker);
NS_IMETHOD HasStateDependentStyle(nsIPresContext* aPresContext,
nsIAtom* aMedium,
@ -808,7 +808,7 @@ HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
nsIAtom* aMedium,
nsIContent* aContent,
nsIStyleContext* aParentContext,
nsIRuleWalker* aRuleWalker)
nsRuleWalker* aRuleWalker)
{
NS_PRECONDITION(nsnull != aPresContext, "null arg");
NS_PRECONDITION(nsnull != aContent, "null arg");
@ -922,7 +922,7 @@ HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
nsIAtom* aPseudoTag,
nsIStyleContext* aParentContext,
nsICSSPseudoComparator* aComparator,
nsIRuleWalker* aRuleWalker)
nsRuleWalker* aRuleWalker)
{
// no pseudo frame style
return NS_OK;

View File

@ -51,7 +51,7 @@ class nsIContent;
class nsISupportsArray;
class nsIAtom;
class nsICSSPseudoComparator;
class nsIRuleWalker;
class nsRuleWalker;
// IID for the nsIStyleRuleProcessor interface {015575fe-7b6c-11d3-ba05-001083023c2b}
#define NS_ISTYLE_RULE_PROCESSOR_IID \
@ -73,7 +73,7 @@ public:
nsIAtom* aMedium,
nsIContent* aContent,
nsIStyleContext* aParentContext,
nsIRuleWalker* aRuleWalker) = 0;
nsRuleWalker* aRuleWalker) = 0;
NS_IMETHOD RulesMatching(nsIPresContext* aPresContext,
nsIAtom* aMedium,
@ -81,7 +81,7 @@ public:
nsIAtom* aPseudoTag,
nsIStyleContext* aParentContext,
nsICSSPseudoComparator* aComparator,
nsIRuleWalker* aRuleWalker) = 0;
nsRuleWalker* aRuleWalker) = 0;
// Test if style is dependent on content state
NS_IMETHOD HasStateDependentStyle(nsIPresContext* aPresContext,

View File

@ -0,0 +1,519 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Original Author: David W. Hyatt (hyatt@netscape.com)
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsRuleNode_h___
#define nsRuleNode_h___
#include "nsCOMPtr.h"
#include "nsHashtable.h"
#include "nsIStyleRule.h"
#include "nsIFrame.h"
#include "nsFixedSizeAllocator.h"
#include "nsIPresContext.h"
#include "nsICSSDeclaration.h"
class nsIHTMLMappedAttributes;
class nsIStyleContext;
struct nsRuleList;
typedef void (*nsPostResolveFunc)(nsStyleStruct* aStyleStruct, nsRuleData* aData);
struct nsInheritedStyleData
{
nsStyleVisibility* mVisibilityData;
nsStyleFont* mFontData;
nsStyleList* mListData;
nsStyleTableBorder* mTableData;
nsStyleColor* mColorData;
nsStyleQuotes* mQuotesData;
nsStyleText* mTextData;
nsStyleUserInterface* mUIData;
void* operator new(size_t sz, nsIPresContext* aContext) {
void* result = nsnull;
aContext->AllocateFromShell(sz, &result);
return result;
};
void ClearInheritedData(PRUint32 aBits) {
if (mVisibilityData && (aBits & NS_STYLE_INHERIT_VISIBILITY))
mVisibilityData = nsnull;
if (mFontData && (aBits & NS_STYLE_INHERIT_FONT))
mFontData = nsnull;
if (mListData && (aBits & NS_STYLE_INHERIT_LIST))
mListData = nsnull;
if (mTableData && (aBits & NS_STYLE_INHERIT_TABLE_BORDER))
mTableData = nsnull;
if (mColorData && (aBits & NS_STYLE_INHERIT_COLOR))
mColorData = nsnull;
if (mQuotesData && (aBits & NS_STYLE_INHERIT_QUOTES))
mQuotesData = nsnull;
if (mTextData && (aBits & NS_STYLE_INHERIT_TEXT))
mTextData = nsnull;
if (mUIData && (aBits & NS_STYLE_INHERIT_UI))
mUIData = nsnull;
};
void Destroy(PRUint32 aBits, nsIPresContext* aContext) {
if (mVisibilityData && !(aBits & NS_STYLE_INHERIT_VISIBILITY))
mVisibilityData->Destroy(aContext);
if (mFontData && !(aBits & NS_STYLE_INHERIT_FONT))
mFontData->Destroy(aContext);
if (mListData && !(aBits & NS_STYLE_INHERIT_LIST))
mListData->Destroy(aContext);
if (mTableData && !(aBits & NS_STYLE_INHERIT_TABLE_BORDER))
mTableData->Destroy(aContext);
if (mColorData && !(aBits & NS_STYLE_INHERIT_COLOR))
mColorData->Destroy(aContext);
if (mQuotesData && !(aBits & NS_STYLE_INHERIT_QUOTES))
mQuotesData->Destroy(aContext);
if (mTextData && !(aBits & NS_STYLE_INHERIT_TEXT))
mTextData->Destroy(aContext);
if (mUIData && !(aBits & NS_STYLE_INHERIT_UI))
mUIData->Destroy(aContext);
aContext->FreeToShell(sizeof(nsInheritedStyleData), this);
};
nsInheritedStyleData()
:mVisibilityData(nsnull), mFontData(nsnull), mListData(nsnull),
mTableData(nsnull), mColorData(nsnull), mQuotesData(nsnull), mTextData(nsnull), mUIData(nsnull)
{};
};
struct nsResetStyleData
{
nsResetStyleData()
:mDisplayData(nsnull), mMarginData(nsnull), mBorderData(nsnull), mPaddingData(nsnull),
mOutlineData(nsnull), mPositionData(nsnull), mTableData(nsnull), mBackgroundData(nsnull),
mContentData(nsnull), mTextData(nsnull), mUIData(nsnull)
{
#ifdef INCLUDE_XUL
mXULData = nsnull;
#endif
};
void* operator new(size_t sz, nsIPresContext* aContext) {
void* result = nsnull;
aContext->AllocateFromShell(sz, &result);
return result;
}
void ClearInheritedData(PRUint32 aBits) {
if (mDisplayData && (aBits & NS_STYLE_INHERIT_DISPLAY))
mDisplayData = nsnull;
if (mMarginData && (aBits & NS_STYLE_INHERIT_MARGIN))
mMarginData = nsnull;
if (mBorderData && (aBits & NS_STYLE_INHERIT_BORDER))
mBorderData = nsnull;
if (mPaddingData && (aBits & NS_STYLE_INHERIT_PADDING))
mPaddingData = nsnull;
if (mOutlineData && (aBits & NS_STYLE_INHERIT_OUTLINE))
mOutlineData = nsnull;
if (mPositionData && (aBits & NS_STYLE_INHERIT_POSITION))
mPositionData = nsnull;
if (mTableData && (aBits & NS_STYLE_INHERIT_TABLE))
mTableData = nsnull;
if (mBackgroundData && (aBits & NS_STYLE_INHERIT_BACKGROUND))
mBackgroundData = nsnull;
if (mContentData && (aBits & NS_STYLE_INHERIT_CONTENT))
mContentData = nsnull;
if (mTextData && (aBits & NS_STYLE_INHERIT_TEXT_RESET))
mTextData = nsnull;
if (mUIData && (aBits & NS_STYLE_INHERIT_UI_RESET))
mUIData = nsnull;
#ifdef INCLUDE_XUL
if (mXULData && (aBits & NS_STYLE_INHERIT_XUL))
mXULData = nsnull;
#endif
};
void Destroy(PRUint32 aBits, nsIPresContext* aContext) {
if (mDisplayData && !(aBits & NS_STYLE_INHERIT_DISPLAY))
mDisplayData->Destroy(aContext);
if (mMarginData && !(aBits & NS_STYLE_INHERIT_MARGIN))
mMarginData->Destroy(aContext);
if (mBorderData && !(aBits & NS_STYLE_INHERIT_BORDER))
mBorderData->Destroy(aContext);
if (mPaddingData && !(aBits & NS_STYLE_INHERIT_PADDING))
mPaddingData->Destroy(aContext);
if (mOutlineData && !(aBits & NS_STYLE_INHERIT_OUTLINE))
mOutlineData->Destroy(aContext);
if (mPositionData && !(aBits & NS_STYLE_INHERIT_POSITION))
mPositionData->Destroy(aContext);
if (mTableData && !(aBits & NS_STYLE_INHERIT_TABLE))
mTableData->Destroy(aContext);
if (mBackgroundData && !(aBits & NS_STYLE_INHERIT_BACKGROUND))
mBackgroundData->Destroy(aContext);
if (mContentData && !(aBits & NS_STYLE_INHERIT_CONTENT))
mContentData->Destroy(aContext);
if (mTextData && !(aBits & NS_STYLE_INHERIT_TEXT_RESET))
mTextData->Destroy(aContext);
if (mUIData && !(aBits & NS_STYLE_INHERIT_UI_RESET))
mUIData->Destroy(aContext);
#ifdef INCLUDE_XUL
if (mXULData && !(aBits & NS_STYLE_INHERIT_XUL))
mXULData->Destroy(aContext);
#endif
aContext->FreeToShell(sizeof(nsResetStyleData), this);
};
nsStyleDisplay* mDisplayData;
nsStyleMargin* mMarginData;
nsStyleBorder* mBorderData;
nsStylePadding* mPaddingData;
nsStyleOutline* mOutlineData;
nsStylePosition* mPositionData;
nsStyleTable* mTableData;
nsStyleBackground* mBackgroundData;
nsStyleContent* mContentData;
nsStyleTextReset* mTextData;
nsStyleUIReset* mUIData;
#ifdef INCLUDE_XUL
nsStyleXUL* mXULData;
#endif
};
struct nsCachedStyleData
{
struct StyleStructInfo {
ptrdiff_t mCachedStyleDataOffset;
ptrdiff_t mInheritResetOffset;
PRBool mIsReset;
};
static StyleStructInfo gInfo[];
nsInheritedStyleData* mInheritedData;
nsResetStyleData* mResetData;
static PRBool IsReset(const nsStyleStructID& aSID) {
return gInfo[aSID].mIsReset;
};
static PRUint32 GetBitForSID(const nsStyleStructID& aSID) {
return 1 << (aSID - 1);
};
nsStyleStruct* GetStyleData(const nsStyleStructID& aSID) {
const StyleStructInfo& info = gInfo[aSID];
char* resetOrInheritSlot = NS_REINTERPRET_CAST(char*, this) + info.mCachedStyleDataOffset;
char* resetOrInherit = NS_REINTERPRET_CAST(char*, *NS_REINTERPRET_CAST(void**, resetOrInheritSlot));
nsStyleStruct* data = nsnull;
if (resetOrInherit) {
char* dataSlot = resetOrInherit + info.mInheritResetOffset;
data = *NS_REINTERPRET_CAST(nsStyleStruct**, dataSlot);
}
return data;
};
void ClearInheritedData(PRUint32 aBits) {
if (mResetData)
mResetData->ClearInheritedData(aBits);
if (mInheritedData)
mInheritedData->ClearInheritedData(aBits);
}
void Destroy(PRUint32 aBits, nsIPresContext* aContext) {
if (mResetData)
mResetData->Destroy(aBits, aContext);
if (mInheritedData)
mInheritedData->Destroy(aBits, aContext);
mResetData = nsnull;
mInheritedData = nsnull;
}
nsCachedStyleData() :mInheritedData(nsnull), mResetData(nsnull) {};
~nsCachedStyleData() {};
};
struct nsRuleData
{
nsStyleStructID mSID;
nsIPresContext* mPresContext;
nsIStyleContext* mStyleContext;
nsPostResolveFunc mPostResolveCallback;
PRBool mCanStoreInRuleTree;
nsIHTMLMappedAttributes* mAttributes; // Can be cached in the rule data by a content node for a post-resolve callback.
nsCSSFont* mFontData; // Should always be stack-allocated! We don't own these structures!
nsCSSDisplay* mDisplayData;
nsCSSMargin* mMarginData;
nsCSSList* mListData;
nsCSSPosition* mPositionData;
nsCSSTable* mTableData;
nsCSSColor* mColorData;
nsCSSContent* mContentData;
nsCSSText* mTextData;
nsCSSUserInterface* mUIData;
#ifdef INCLUDE_XUL
nsCSSXUL* mXULData;
#endif
nsRuleData(const nsStyleStructID& aSID, nsIPresContext* aContext, nsIStyleContext* aStyleContext)
:mSID(aSID), mPresContext(aContext), mStyleContext(aStyleContext), mPostResolveCallback(nsnull),
mAttributes(nsnull), mFontData(nsnull), mDisplayData(nsnull), mMarginData(nsnull), mListData(nsnull),
mPositionData(nsnull), mTableData(nsnull), mColorData(nsnull), mContentData(nsnull), mTextData(nsnull),
mUIData(nsnull)
{
mCanStoreInRuleTree = PR_TRUE;
#ifdef INCLUDE_XUL
mXULData = nsnull;
#endif
};
~nsRuleData() {};
};
class nsRuleNode {
public:
// for purposes of the RuleDetail (and related code),
// * a non-inherited value is one that is specified as a
// non-"inherit" value or as an "inherit" value that is reflected
// in the struct and to the user of the style system with an
// eCSSUnit_Inherit value
// * an inherited value is one that is specified as "inherit" and
// where the inheritance is computed by the style system
enum RuleDetail {
eRuleNone, // No props have been specified at all.
eRulePartialMixed, // At least one prop with a non-inherited value
// has been specified. Some props may also have
// been specified with an inherited value. At
// least one prop remains unspecified.
eRulePartialInherited, // Only props with inherited values have
// have been specified. At least one prop
// remains unspecified.
eRuleFullMixed, // All props have been specified. At least one has
// a non-inherited value.
eRuleFullInherited, // All props have been specified with inherited
// values.
eRuleUnknown // Information unknown (used as a result from a check
// callback to trigger the normal checking codepath)
};
enum { // Types of RuleBits
eNoneBits,
eInheritBits
};
private:
nsIPresContext* mPresContext; // Our pres context.
nsRuleNode* mParent; // A pointer to the parent node in the tree. This enables us to
// walk backwards from the most specific rule matched to the least
// specific rule (which is the optimal order to use for lookups
// of style properties.
nsCOMPtr<nsIStyleRule> mRule; // A pointer to our specific rule.
union {
nsHashtable* mRootChildren; // A hashtable that maps from rules to our RuleNode children.
// When matching rules, we use this table to transition from
// node to node (constructing new nodes as needed to flesh out
// the tree).
nsRuleList* mChildren;
};
nsCachedStyleData mStyleData; // Any data we cached on the rule node.
PRUint32 mInheritBits; // Used to cache the fact that we can look up cached data under a parent
// rule. This is not the same thing as CSS inheritance.
PRUint32 mNoneBits; // Used to cache the fact that this entire branch specifies no data
// for a given struct type. For example, if an entire rule branch
// specifies no color information, then a bit will be set along every
// rule node on that branch, so that you can break out of the rule tree
// early.
static PRUint32 gRefCnt;
friend struct nsRuleList;
protected:
// The callback function for deleting rule nodes from our rule tree.
static PRBool PR_CALLBACK DeleteChildren(nsHashKey *aKey, void *aData, void *closure);
public:
// Overloaded new operator. Initializes the memory to 0 and relies on an arena
// (which comes from the presShell) to perform the allocation.
void* operator new(size_t sz, nsIPresContext* aContext);
void Destroy();
protected:
void PropagateInheritBit(PRUint32 aBit, nsRuleNode* aHighestNode);
void PropagateNoneBit(PRUint32 aBit, nsRuleNode* aHighestNode);
PRBool InheritsFromParentRule(const nsStyleStructID aSID);
const nsStyleStruct* SetDefaultOnRoot(const nsStyleStructID aSID, nsIStyleContext* aContext);
const nsStyleStruct* WalkRuleTree(const nsStyleStructID aSID, nsIStyleContext* aContext,
nsRuleData* aRuleData,
nsCSSStruct* aSpecificData);
const nsStyleStruct* ComputeDisplayData(nsStyleStruct* aStartDisplay, const nsCSSStruct& aDisplayData,
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeVisibilityData(nsStyleStruct* aStartVisibility, const nsCSSStruct& aDisplayData,
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeFontData(nsStyleStruct* aStartFont, const nsCSSStruct& aFontData,
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeColorData(nsStyleStruct* aStartColor, const nsCSSStruct& aColorData,
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeBackgroundData(nsStyleStruct* aStartBackground, const nsCSSStruct& aColorData,
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeMarginData(nsStyleStruct* aStartMargin, const nsCSSStruct& aMarginData,
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeBorderData(nsStyleStruct* aStartBorder, const nsCSSStruct& aMarginData,
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputePaddingData(nsStyleStruct* aStartPadding, const nsCSSStruct& aMarginData,
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeOutlineData(nsStyleStruct* aStartOutline, const nsCSSStruct& aMarginData,
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeListData(nsStyleStruct* aStartList, const nsCSSStruct& aListData,
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputePositionData(nsStyleStruct* aStartPosition, const nsCSSStruct& aPositionData,
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeTableData(nsStyleStruct* aStartTable, const nsCSSStruct& aTableData,
nsIStyleContext* aContext, nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeTableBorderData(nsStyleStruct* aStartTable, const nsCSSStruct& aTableData,
nsIStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeContentData(nsStyleStruct* aStartContent, const nsCSSStruct& aData,
nsIStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeQuotesData(nsStyleStruct* aStartQuotes, const nsCSSStruct& aData,
nsIStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeTextData(nsStyleStruct* aStartData, const nsCSSStruct& aData,
nsIStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeTextResetData(nsStyleStruct* aStartData, const nsCSSStruct& aData,
nsIStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeUIData(nsStyleStruct* aStartData, const nsCSSStruct& aData,
nsIStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
const nsStyleStruct* ComputeUIResetData(nsStyleStruct* aStartData, const nsCSSStruct& aData,
nsIStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
#ifdef INCLUDE_XUL
const nsStyleStruct* ComputeXULData(nsStyleStruct* aStartXUL, const nsCSSStruct& aXULData,
nsIStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail, PRBool aInherited);
#endif
typedef const nsStyleStruct*
(nsRuleNode::*ComputeStyleDataFn)(nsStyleStruct* aStartStruct,
const nsCSSStruct& aStartData,
nsIStyleContext* aContext,
nsRuleNode* aHighestNode,
const RuleDetail& aRuleDetail,
PRBool aInherited);
static ComputeStyleDataFn gComputeStyleDataFn[];
inline RuleDetail CheckSpecifiedProperties(const nsStyleStructID aSID, const nsCSSStruct& aCSSStruct);
const nsStyleStruct* GetParentData(const nsStyleStructID aSID);
const nsStyleStruct* GetDisplayData(nsIStyleContext* aContext);
const nsStyleStruct* GetVisibilityData(nsIStyleContext* aContext);
const nsStyleStruct* GetFontData(nsIStyleContext* aContext);
const nsStyleStruct* GetColorData(nsIStyleContext* aContext);
const nsStyleStruct* GetBackgroundData(nsIStyleContext* aContext);
const nsStyleStruct* GetMarginData(nsIStyleContext* aContext);
const nsStyleStruct* GetBorderData(nsIStyleContext* aContext);
const nsStyleStruct* GetPaddingData(nsIStyleContext* aContext);
const nsStyleStruct* GetOutlineData(nsIStyleContext* aContext);
const nsStyleStruct* GetListData(nsIStyleContext* aContext);
const nsStyleStruct* GetPositionData(nsIStyleContext* aContext);
const nsStyleStruct* GetTableData(nsIStyleContext* aContext);
const nsStyleStruct* GetTableBorderData(nsIStyleContext* aContext);
const nsStyleStruct* GetContentData(nsIStyleContext* aContext);
const nsStyleStruct* GetQuotesData(nsIStyleContext* aContext);
const nsStyleStruct* GetTextData(nsIStyleContext* aContext);
const nsStyleStruct* GetTextResetData(nsIStyleContext* aContext);
const nsStyleStruct* GetUIData(nsIStyleContext* aContext);
const nsStyleStruct* GetUIResetData(nsIStyleContext* aContext);
#ifdef INCLUDE_XUL
const nsStyleStruct* GetXULData(nsIStyleContext* aContext);
#endif
typedef const nsStyleStruct* (nsRuleNode::*GetStyleDataFn)(nsIStyleContext*);
static GetStyleDataFn gGetStyleDataFn[];
public:
nsRuleNode(nsIPresContext* aPresContext, nsIStyleRule* aRule=nsnull, nsRuleNode* aParent=nsnull);
virtual ~nsRuleNode();
static void CreateRootNode(nsIPresContext* aPresContext, nsRuleNode** aResult);
nsresult GetBits(PRInt32 aType, PRUint32* aResult);
nsresult Transition(nsIStyleRule* aRule, nsRuleNode** aResult);
nsRuleNode* GetParent() { return mParent; }
PRBool IsRoot() { return mParent == nsnull; }
nsresult GetRule(nsIStyleRule** aResult);
nsresult ClearCachedData(nsIStyleRule* aRule);
nsresult ClearCachedDataInSubtree(nsIStyleRule* aRule);
nsresult GetPresContext(nsIPresContext** aResult);
nsresult PathContainsRule(nsIStyleRule* aRule, PRBool* aMatched);
const nsStyleStruct* GetStyleData(nsStyleStructID aSID,
nsIStyleContext* aContext);
};
#endif

Some files were not shown because too many files have changed in this diff Show More