Bug 525608 part 1. Introduce an enum for keeping track of pseudo-elements. r=dbaron

This commit is contained in:
Boris Zbarsky 2009-12-11 02:37:40 -05:00
parent 7316a1c605
commit c1d4ecaf51
5 changed files with 50 additions and 5 deletions

View File

@ -68,7 +68,6 @@
#include "nsIServiceManager.h"
#include "nsIDOMMutationEvent.h"
#include "nsINameSpaceManager.h"
#include "nsCSSPseudoElements.h"
#include "nsCSSAnonBoxes.h"
#include "nsAutoPtr.h"
#include "nsStyleSet.h"
@ -1043,7 +1042,7 @@ nsHTMLFramesetFrame::Reflow(nsPresContext* aPresContext,
nsRefPtr<nsStyleContext> pseudoStyleContext;
pseudoStyleContext = styleSet->ResolvePseudoStyleFor(mContent,
nsCSSPseudoElements::horizontalFramesetBorder,
nsCSSAnonBoxes::horizontalFramesetBorder,
mStyleContext);
borderFrame = new (shell) nsHTMLFramesetBorderFrame(pseudoStyleContext,
@ -1079,7 +1078,7 @@ nsHTMLFramesetFrame::Reflow(nsPresContext* aPresContext,
nsRefPtr<nsStyleContext> pseudoStyleContext;
pseudoStyleContext = styleSet->ResolvePseudoStyleFor(mContent,
nsCSSPseudoElements::verticalFramesetBorder,
nsCSSAnonBoxes::verticalFramesetBorder,
mStyleContext);
borderFrame = new (shell) nsHTMLFramesetBorderFrame(pseudoStyleContext,

View File

@ -59,6 +59,10 @@ CSS_ANON_BOX(mozAnonymousPositionedBlock, ":-moz-anonymous-positioned-block")
CSS_ANON_BOX(mozMathMLAnonymousBlock, ":-moz-mathml-anonymous-block")
CSS_ANON_BOX(mozXULAnonymousBlock, ":-moz-xul-anonymous-block")
// Framesets
CSS_ANON_BOX(horizontalFramesetBorder, ":-moz-hframeset-border")
CSS_ANON_BOX(verticalFramesetBorder, ":-moz-vframeset-border")
CSS_ANON_BOX(mozLineFrame, ":-moz-line-frame")
CSS_ANON_BOX(buttonContent, ":-moz-button-content")

View File

@ -71,11 +71,13 @@ CSS_PSEUDO_ELEMENT(firstLine, ":first-line",
CSS_PSEUDO_ELEMENT(mozSelection, ":-moz-selection",
CSS_PSEUDO_ELEMENT_CONTAINS_ELEMENTS)
// XXXbz should we really allow random content to style these? Maybe
// use our flags to prevent that?
CSS_PSEUDO_ELEMENT(mozFocusInner, ":-moz-focus-inner", 0)
CSS_PSEUDO_ELEMENT(mozFocusOuter, ":-moz-focus-outer", 0)
// XXXbz should we really allow random content to style these? Maybe
// use our flags to prevent that?
CSS_PSEUDO_ELEMENT(mozListBullet, ":-moz-list-bullet", 0)
CSS_PSEUDO_ELEMENT(mozListNumber, ":-moz-list-number", 0)
CSS_PSEUDO_ELEMENT(horizontalFramesetBorder, ":-moz-hframeset-border", 0)
CSS_PSEUDO_ELEMENT(verticalFramesetBorder, ":-moz-vframeset-border", 0)

View File

@ -100,6 +100,28 @@ nsCSSPseudoElements::IsCSS2PseudoElement(nsIAtom *aAtom)
return result;
}
/* static */ nsCSSPseudoElements::Type
nsCSSPseudoElements::GetPseudoType(nsIAtom *aAtom)
{
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(CSSPseudoElements_info); ++i) {
if (*CSSPseudoElements_info[i].mAtom == aAtom) {
return Type(i);
}
}
if (nsCSSAnonBoxes::IsAnonBox(aAtom)) {
#ifdef MOZ_XUL
if (nsCSSAnonBoxes::IsTreePseudoElement(aAtom)) {
return ePseudo_XULTree;
}
#endif
return ePseudo_AnonBox;
}
return ePseudo_NotPseudoElement;
}
/* static */ PRUint32
nsCSSPseudoElements::FlagsForPseudoElement(nsIAtom *aAtom)
{

View File

@ -79,6 +79,24 @@ public:
#include "nsCSSPseudoElementList.h"
#undef CSS_PSEUDO_ELEMENT
enum Type {
// If the actual pseudo-elements stop being first here, change
// GetPseudoType.
#define CSS_PSEUDO_ELEMENT(_name, _value_, _flags) \
ePseudo_##_name,
#include "nsCSSPseudoElementList.h"
#undef CSS_PSEUDO_ELEMENT
ePseudo_PseudoElementCount,
ePseudo_NotPseudoElement = ePseudo_PseudoElementCount,
ePseudo_AnonBox,
#ifdef MOZ_XUL
ePseudo_XULTree,
#endif
ePseudo_MAX
};
static Type GetPseudoType(nsIAtom* aAtom);
private:
static PRUint32 FlagsForPseudoElement(nsIAtom *aAtom);