Bug 1343078 part 3. Introduce the concept of non-inheriting anon boxes without adding any yet. r=dbaron

MozReview-Commit-ID: 1NZ2xI4XCWH

--HG--
extra : rebase_source : 5a24fa9954be80cbac06d9a1873ce5ec8c91ea95
This commit is contained in:
Boris Zbarsky 2017-03-08 00:18:39 -05:00
Родитель dca977e5a4
Коммит be2dd33efe
3 изменённых файлов: 73 добавлений и 8 удалений

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

@ -8,16 +8,29 @@
/*
* This file contains the list of nsIAtoms and their values for CSS
* pseudo-element-ish things used internally for anonymous boxes. It is
* designed to be used as inline input to nsCSSAnonBoxes.cpp *only*
* through the magic of C preprocessing. All entries must be enclosed
* in the macro CSS_ANON_BOX which will have cruel and unusual things
* done to it. The entries should be kept in some sort of logical
* order. The first argument to CSS_ANON_BOX is the C++ identifier of
* the atom. The second argument is the string value of the atom.
* designed to be used as inline input to nsCSSAnonBoxes.cpp *only* through the
* magic of C preprocessing. All entries must be enclosed in the macros
* CSS_ANON_BOX and CSS_NON_INHERITING_ANON_BOX which will have cruel and
* unusual things done to it. The entries should be kept in some sort of
* logical order. The first argument to
* CSS_ANON_BOX/CSS_NON_INHERITING_ANON_BOX is the C++ identifier of the atom.
* The second argument is the string value of the atom.
*
* CSS_NON_INHERITING_ANON_BOX is used for anon boxes that never inherit style
* from anything. This means all their property values are the initial values
* of those properties.
*/
// OUTPUT_CLASS=nsCSSAnonBoxes
// MACRO_NAME=CSS_ANON_BOX
// MACRO_NAME=CSS_ANON_BOX/CSS_NON_INHERITING_ANON_BOX
#ifndef CSS_NON_INHERITING_ANON_BOX
# ifdef DEFINED_CSS_NON_INHERITING_ANON_BOX
# error "Recursive includes of nsCSSAnonBoxList.h?"
# endif /* DEFINED_CSS_NON_INHERITING_ANON_BOX */
# define CSS_NON_INHERITING_ANON_BOX CSS_ANON_BOX
# define DEFINED_CSS_NON_INHERITING_ANON_BOX
#endif /* CSS_NON_INHERITING_ANON_BOX */
// ::-moz-text, ::-moz-oof-placeholder, and ::-moz-first-letter-continuation are
// non-elements which no rule will match.
@ -102,3 +115,8 @@ CSS_ANON_BOX(mozSVGMarkerAnonChild, ":-moz-svg-marker-anon-child")
CSS_ANON_BOX(mozSVGOuterSVGAnonChild, ":-moz-svg-outer-svg-anon-child")
CSS_ANON_BOX(mozSVGForeignContent, ":-moz-svg-foreign-content")
CSS_ANON_BOX(mozSVGText, ":-moz-svg-text")
#ifdef DEFINED_CSS_NON_INHERITING_ANON_BOX
# undef DEFINED_CSS_NON_INHERITING_ANON_BOX
# undef CSS_NON_INHERITING_ANON_BOX
#endif /* DEFINED_CSS_NON_INHERITING_ANON_BOX */

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

@ -25,9 +25,19 @@ using namespace mozilla;
#undef CSS_ANON_BOX
static const nsStaticAtom CSSAnonBoxes_info[] = {
#define CSS_ANON_BOX(name_, value_) \
// Put the non-inheriting anon boxes first, so we can index into them easily.
#define CSS_ANON_BOX(name_, value_) /* nothing */
#define CSS_NON_INHERITING_ANON_BOX(name_, value_) \
NS_STATIC_ATOM(name_##_buffer, (nsIAtom**)&nsCSSAnonBoxes::name_),
#include "nsCSSAnonBoxList.h"
#undef CSS_NON_INHERITING_ANON_BOX
#undef CSS_ANON_BOX
#define CSS_ANON_BOX(name_, value_) \
NS_STATIC_ATOM(name_##_buffer, (nsIAtom**)&nsCSSAnonBoxes::name_),
#define CSS_NON_INHERITING_ANON_BOX(name_, value_) /* nothing */
#include "nsCSSAnonBoxList.h"
#undef CSS_NON_INHERITING_ANON_BOX
#undef CSS_ANON_BOX
};
@ -50,3 +60,10 @@ nsCSSAnonBoxes::IsTreePseudoElement(nsIAtom* aPseudo)
NS_LITERAL_STRING(":-moz-tree-"));
}
#endif
/* static */ nsIAtom*
nsCSSAnonBoxes::GetNonInheritingPseudoAtom(NonInheriting aBoxType)
{
MOZ_ASSERT(aBoxType < NonInheriting::_Count);
return *CSSAnonBoxes_info[static_cast<NonInheritingBase>(aBoxType)].mAtom;
}

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

@ -32,6 +32,36 @@ public:
#define CSS_ANON_BOX(_name, _value) static nsICSSAnonBoxPseudo* _name;
#include "nsCSSAnonBoxList.h"
#undef CSS_ANON_BOX
typedef uint8_t NonInheritingBase;
enum class NonInheriting : NonInheritingBase {
#define CSS_ANON_BOX(_name, _value) /* nothing */
#define CSS_NON_INHERITING_ANON_BOX(_name, _value) _name,
#include "nsCSSAnonBoxList.h"
#undef CSS_NON_INHERITING_ANON_BOX
#undef CSS_ANON_BOX
_Count
};
// Be careful using this: if we have a lot of non-inheriting anon box types it
// might not be very fast. We may want to think of ways to handle that
// (e.g. by moving to an enum instead of an atom, like we did for
// pseudo-elements, or by adding a new value of the pseudo-element enum for
// non-inheriting anon boxes or something).
static bool IsNonInheritingAnonBox(nsIAtom* aPseudo)
{
return
#define CSS_ANON_BOX(_name, _value) /* nothing */
#define CSS_NON_INHERITING_ANON_BOX(_name, _value) _name == aPseudo ||
#include "nsCSSAnonBoxList.h"
#undef CSS_NON_INHERITING_ANON_BOX
#undef CSS_ANON_BOX
0;
}
// Get the atom for a given non-inheriting anon box type. aBoxType must be <
// NonInheriting::_Count.
static nsIAtom* GetNonInheritingPseudoAtom(NonInheriting aBoxType);
};
#endif /* nsCSSAnonBoxes_h___ */