Document pseudo-element code a little better and add some assertions. b=307939 r+sr=bzbarsky

This commit is contained in:
dbaron%dbaron.org 2005-09-11 23:17:28 +00:00
parent dbc3c993a1
commit 667d1f2104
2 changed files with 19 additions and 12 deletions

View File

@ -639,6 +639,12 @@ nsStyleSet::ResolvePseudoStyleFor(nsIContent* aParentContent,
NS_ASSERTION(!aParentContent ||
aParentContent->IsContentOfType(nsIContent::eELEMENT),
"content (if non-null) must be element");
NS_ASSERTION(aParentContent ||
nsCSSAnonBoxes::IsAnonBox(aPseudoTag),
"null content must correspond to anonymous box");
NS_ASSERTION(nsCSSAnonBoxes::IsAnonBox(aPseudoTag) ||
nsCSSPseudoElements::IsPseudoElement(aPseudoTag),
"aPseudoTag must be pseudo-element or anonymous box");
if (aPseudoTag && presContext) {
if (mRuleProcessors[eAgentSheet] ||
@ -673,9 +679,11 @@ nsStyleSet::ProbePseudoStyleFor(nsIContent* aParentContent,
nsPresContext *presContext = PresContext();
NS_ASSERTION(aPseudoTag, "must have pseudo tag");
NS_ASSERTION(!aParentContent ||
NS_ASSERTION(aParentContent &&
aParentContent->IsContentOfType(nsIContent::eELEMENT),
"content (if non-null) must be element");
"aParentContent must be element");
NS_ASSERTION(nsCSSPseudoElements::IsPseudoElement(aPseudoTag),
"aPseudoTag must be a pseudo-element");
if (aPseudoTag && presContext) {
if (mRuleProcessors[eAgentSheet] ||

View File

@ -76,21 +76,20 @@ class nsStyleSet
already_AddRefed<nsStyleContext>
ResolveStyleFor(nsIContent* aContent, nsStyleContext* aParentContext);
// Get a style context for a non-element (which no rules will match).
// Eventually, this should go away and we shouldn't even create style
// Get a style context for a non-element (which no rules will match),
// such as text nodes, placeholder frames, and the nsFirstLetterFrame
// for everything after the first letter.
//
// Perhaps this should go away and we shouldn't even create style
// contexts for such content nodes. However, not doing any rule
// matching for them is a first step.
//
// XXX This is temporary. It should go away when we stop creating
// style contexts for text nodes and placeholder frames. (We also use
// it once to create a style context for the nsFirstLetterFrame that
// represents everything except the first letter.)
//
already_AddRefed<nsStyleContext>
ResolveStyleForNonElement(nsStyleContext* aParentContext);
// get a style context for a pseudo-element (i.e.,
// |aPseudoTag == nsCOMPtr<nsIAtom>(do_GetAtom(":first-line"))|;
// |aPseudoTag == nsCOMPtr<nsIAtom>(do_GetAtom(":first-line"))|, in
// which case aParentContent must be non-null, or an anonymous box, in
// which case it may be null or non-null.
already_AddRefed<nsStyleContext>
ResolvePseudoStyleFor(nsIContent* aParentContent,
nsIAtom* aPseudoTag,
@ -99,7 +98,7 @@ class nsStyleSet
// This funtions just like ResolvePseudoStyleFor except that it will
// return nsnull if there are no explicit style rules for that
// pseudo element.
// pseudo element. It should be used only for pseudo-elements.
already_AddRefed<nsStyleContext>
ProbePseudoStyleFor(nsIContent* aParentContent,
nsIAtom* aPseudoTag,