mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-12 10:40:12 +00:00
update to new property and keyword enums and apis
This commit is contained in:
parent
a47e2611ce
commit
49e887a855
@ -25,6 +25,7 @@
|
||||
#include "nsString.h"
|
||||
#include "nsCoord.h"
|
||||
#include "nsCSSValue.h"
|
||||
#include "nsCSSProps.h"
|
||||
|
||||
|
||||
struct nsCSSStruct {
|
||||
@ -127,7 +128,6 @@ struct nsCSSColor : public nsCSSStruct {
|
||||
nsCSSValue mBackAttachment;
|
||||
nsCSSValue mBackPositionX;
|
||||
nsCSSValue mBackPositionY;
|
||||
nsCSSValue mBackFilter;
|
||||
nsCSSValueList* mCursor;
|
||||
nsCSSValue mOpacity;
|
||||
};
|
||||
@ -168,8 +168,8 @@ struct nsCSSText : public nsCSSStruct {
|
||||
struct nsCSSRect {
|
||||
nsCSSRect(void);
|
||||
nsCSSRect(const nsCSSRect& aCopy);
|
||||
void List(FILE* out = 0, PRInt32 aPropID = -1, PRInt32 aIndent = 0) const;
|
||||
void List(FILE* out, PRInt32 aIndent, PRIntn aTRBL[]) const;
|
||||
void List(FILE* out = 0, nsCSSProperty aPropID = eCSSProperty_UNKNOWN, PRInt32 aIndent = 0) const;
|
||||
void List(FILE* out, PRInt32 aIndent, const nsCSSProperty aTRBL[]) const;
|
||||
|
||||
nsCSSValue mTop;
|
||||
nsCSSValue mRight;
|
||||
@ -192,7 +192,6 @@ struct nsCSSDisplay : public nsCSSStruct {
|
||||
nsCSSRect* mClip;
|
||||
nsCSSValue mOverflow;
|
||||
nsCSSValue mVisibility;
|
||||
nsCSSValue mFilter;
|
||||
};
|
||||
|
||||
struct nsCSSMargin : public nsCSSStruct {
|
||||
@ -360,19 +359,19 @@ public:
|
||||
NS_IMETHOD GetData(const nsID& aIID, nsCSSStruct** aData) = 0;
|
||||
NS_IMETHOD EnsureData(const nsID& aSID, nsCSSStruct** aData) = 0;
|
||||
|
||||
NS_IMETHOD AppendValue(PRInt32 aProperty, const nsCSSValue& aValue) = 0;
|
||||
NS_IMETHOD AppendStructValue(PRInt32 aProperty, void* aStruct) = 0;
|
||||
NS_IMETHOD SetValueImportant(PRInt32 aProperty) = 0;
|
||||
NS_IMETHOD AppendValue(nsCSSProperty aProperty, const nsCSSValue& aValue) = 0;
|
||||
NS_IMETHOD AppendStructValue(nsCSSProperty aProperty, void* aStruct) = 0;
|
||||
NS_IMETHOD SetValueImportant(nsCSSProperty aProperty) = 0;
|
||||
NS_IMETHOD AppendComment(const nsString& aComment) = 0;
|
||||
|
||||
// XXX make nscolor a struct to avoid type conflicts
|
||||
NS_IMETHOD GetValue(PRInt32 aProperty, nsCSSValue& aValue) = 0;
|
||||
NS_IMETHOD GetValue(nsCSSProperty aProperty, nsCSSValue& aValue) = 0;
|
||||
|
||||
NS_IMETHOD GetValue(PRInt32 aProperty, nsString& aValue) = 0;
|
||||
NS_IMETHOD GetValue(nsCSSProperty aProperty, nsString& aValue) = 0;
|
||||
NS_IMETHOD GetValue(const nsString& aProperty, nsString& aValue) = 0;
|
||||
|
||||
NS_IMETHOD GetImportantValues(nsICSSDeclaration*& aResult) = 0;
|
||||
NS_IMETHOD GetValueIsImportant(PRInt32 aProperty, PRBool& aIsImportant) = 0;
|
||||
NS_IMETHOD GetValueIsImportant(nsCSSProperty aProperty, PRBool& aIsImportant) = 0;
|
||||
NS_IMETHOD GetValueIsImportant(const nsString& aProperty, PRBool& aIsImportant) = 0;
|
||||
|
||||
NS_IMETHOD Count(PRUint32* aCount) = 0;
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "nsString.h"
|
||||
#include "nsCoord.h"
|
||||
#include "nsCSSValue.h"
|
||||
#include "nsCSSProps.h"
|
||||
|
||||
|
||||
struct nsCSSStruct {
|
||||
@ -127,7 +128,6 @@ struct nsCSSColor : public nsCSSStruct {
|
||||
nsCSSValue mBackAttachment;
|
||||
nsCSSValue mBackPositionX;
|
||||
nsCSSValue mBackPositionY;
|
||||
nsCSSValue mBackFilter;
|
||||
nsCSSValueList* mCursor;
|
||||
nsCSSValue mOpacity;
|
||||
};
|
||||
@ -168,8 +168,8 @@ struct nsCSSText : public nsCSSStruct {
|
||||
struct nsCSSRect {
|
||||
nsCSSRect(void);
|
||||
nsCSSRect(const nsCSSRect& aCopy);
|
||||
void List(FILE* out = 0, PRInt32 aPropID = -1, PRInt32 aIndent = 0) const;
|
||||
void List(FILE* out, PRInt32 aIndent, PRIntn aTRBL[]) const;
|
||||
void List(FILE* out = 0, nsCSSProperty aPropID = eCSSProperty_UNKNOWN, PRInt32 aIndent = 0) const;
|
||||
void List(FILE* out, PRInt32 aIndent, const nsCSSProperty aTRBL[]) const;
|
||||
|
||||
nsCSSValue mTop;
|
||||
nsCSSValue mRight;
|
||||
@ -192,7 +192,6 @@ struct nsCSSDisplay : public nsCSSStruct {
|
||||
nsCSSRect* mClip;
|
||||
nsCSSValue mOverflow;
|
||||
nsCSSValue mVisibility;
|
||||
nsCSSValue mFilter;
|
||||
};
|
||||
|
||||
struct nsCSSMargin : public nsCSSStruct {
|
||||
@ -360,19 +359,19 @@ public:
|
||||
NS_IMETHOD GetData(const nsID& aIID, nsCSSStruct** aData) = 0;
|
||||
NS_IMETHOD EnsureData(const nsID& aSID, nsCSSStruct** aData) = 0;
|
||||
|
||||
NS_IMETHOD AppendValue(PRInt32 aProperty, const nsCSSValue& aValue) = 0;
|
||||
NS_IMETHOD AppendStructValue(PRInt32 aProperty, void* aStruct) = 0;
|
||||
NS_IMETHOD SetValueImportant(PRInt32 aProperty) = 0;
|
||||
NS_IMETHOD AppendValue(nsCSSProperty aProperty, const nsCSSValue& aValue) = 0;
|
||||
NS_IMETHOD AppendStructValue(nsCSSProperty aProperty, void* aStruct) = 0;
|
||||
NS_IMETHOD SetValueImportant(nsCSSProperty aProperty) = 0;
|
||||
NS_IMETHOD AppendComment(const nsString& aComment) = 0;
|
||||
|
||||
// XXX make nscolor a struct to avoid type conflicts
|
||||
NS_IMETHOD GetValue(PRInt32 aProperty, nsCSSValue& aValue) = 0;
|
||||
NS_IMETHOD GetValue(nsCSSProperty aProperty, nsCSSValue& aValue) = 0;
|
||||
|
||||
NS_IMETHOD GetValue(PRInt32 aProperty, nsString& aValue) = 0;
|
||||
NS_IMETHOD GetValue(nsCSSProperty aProperty, nsString& aValue) = 0;
|
||||
NS_IMETHOD GetValue(const nsString& aProperty, nsString& aValue) = 0;
|
||||
|
||||
NS_IMETHOD GetImportantValues(nsICSSDeclaration*& aResult) = 0;
|
||||
NS_IMETHOD GetValueIsImportant(PRInt32 aProperty, PRBool& aIsImportant) = 0;
|
||||
NS_IMETHOD GetValueIsImportant(nsCSSProperty aProperty, PRBool& aIsImportant) = 0;
|
||||
NS_IMETHOD GetValueIsImportant(const nsString& aProperty, PRBool& aIsImportant) = 0;
|
||||
|
||||
NS_IMETHOD Count(PRUint32* aCount) = 0;
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "plstr.h"
|
||||
#include "nsCSSProps.h"
|
||||
#include "nsCSSKeywords.h"
|
||||
#include "nsString.h"
|
||||
|
||||
static const char* kJunkNames[] = {
|
||||
nsnull,
|
||||
@ -31,35 +32,42 @@ static const char* kJunkNames[] = {
|
||||
|
||||
int TestProps() {
|
||||
int rv = 0;
|
||||
PRInt32 id;
|
||||
nsCSSProperty id;
|
||||
nsCSSProperty index;
|
||||
|
||||
// First make sure we can find all of the tags that are supposed to
|
||||
// be in the table. Futz with the case to make sure any case will
|
||||
// work
|
||||
const nsCSSProps::NameTableEntry* et = &nsCSSProps::kNameTable[0];
|
||||
const nsCSSProps::NameTableEntry* end = &nsCSSProps::kNameTable[PROP_MAX];
|
||||
extern const char* kCSSRawProperties[];
|
||||
const char** et = &kCSSRawProperties[0];
|
||||
const char** end = &kCSSRawProperties[eCSSProperty_COUNT];
|
||||
index = eCSSProperty_UNKNOWN;
|
||||
while (et < end) {
|
||||
char tagName[100];
|
||||
id = nsCSSProps::LookupName(et->name);
|
||||
if (id < 0) {
|
||||
printf("bug: can't find '%s'\n", et->name);
|
||||
PL_strcpy(tagName, *et);
|
||||
index = nsCSSProperty(PRInt32(index) + 1);
|
||||
|
||||
id = nsCSSProps::LookupProperty(nsSubsumeCStr(tagName, PR_FALSE));
|
||||
if (id == eCSSProperty_UNKNOWN) {
|
||||
printf("bug: can't find '%s'\n", tagName);
|
||||
rv = -1;
|
||||
}
|
||||
if (et->id != id) {
|
||||
printf("bug: name='%s' et->id=%d id=%d\n", et->name, et->id, id);
|
||||
if (id != index) {
|
||||
printf("bug: name='%s' id=%d index=%d\n", tagName, id, index);
|
||||
rv = -1;
|
||||
}
|
||||
|
||||
// fiddle with the case to make sure we can still find it
|
||||
PL_strcpy(tagName, et->name);
|
||||
tagName[0] = tagName[0] - 32;
|
||||
id = nsCSSProps::LookupName(tagName);
|
||||
if (('a' <= tagName[0]) && (tagName[0] <= 'z')) {
|
||||
tagName[0] = tagName[0] - 32;
|
||||
}
|
||||
id = nsCSSProps::LookupProperty(nsAutoString(tagName));
|
||||
if (id < 0) {
|
||||
printf("bug: can't find '%s'\n", tagName);
|
||||
rv = -1;
|
||||
}
|
||||
if (et->id != id) {
|
||||
printf("bug: name='%s' et->id=%d id=%d\n", et->name, et->id, id);
|
||||
if (index != id) {
|
||||
printf("bug: name='%s' id=%d index=%d\n", tagName, id, index);
|
||||
rv = -1;
|
||||
}
|
||||
et++;
|
||||
@ -68,7 +76,7 @@ int TestProps() {
|
||||
// Now make sure we don't find some garbage
|
||||
for (int i = 0; i < (int) (sizeof(kJunkNames) / sizeof(const char*)); i++) {
|
||||
const char* tag = kJunkNames[i];
|
||||
id = nsCSSProps::LookupName(tag);
|
||||
id = nsCSSProps::LookupProperty(nsCAutoString(tag));
|
||||
if (id >= 0) {
|
||||
printf("bug: found '%s'\n", tag ? tag : "(null)");
|
||||
rv = -1;
|
||||
@ -79,36 +87,54 @@ int TestProps() {
|
||||
}
|
||||
|
||||
int TestKeywords() {
|
||||
nsCSSKeywords::AddRefTable();
|
||||
|
||||
int rv = 0;
|
||||
PRInt32 id;
|
||||
nsCSSKeyword id;
|
||||
nsCSSKeyword index;
|
||||
|
||||
extern const char* kCSSRawKeywords[];
|
||||
|
||||
// First make sure we can find all of the tags that are supposed to
|
||||
// be in the table. Futz with the case to make sure any case will
|
||||
// work
|
||||
const nsCSSKeywords::NameTableEntry* et = &nsCSSKeywords::kNameTable[0];
|
||||
const nsCSSKeywords::NameTableEntry* end = &nsCSSKeywords::kNameTable[KEYWORD_MAX];
|
||||
const char** et = &kCSSRawKeywords[0];
|
||||
const char** end = &kCSSRawKeywords[eCSSKeyword_COUNT - 1];
|
||||
index = eCSSKeyword_UNKNOWN;
|
||||
while (et < end) {
|
||||
char tagName[100];
|
||||
id = nsCSSKeywords::LookupName(et->name);
|
||||
if (id < 0) {
|
||||
printf("bug: can't find '%s'\n", et->name);
|
||||
char tagName[512];
|
||||
char* underscore = &(tagName[0]);
|
||||
|
||||
PL_strcpy(tagName, *et);
|
||||
while (*underscore) {
|
||||
if (*underscore == '_') {
|
||||
*underscore = '-';
|
||||
}
|
||||
underscore++;
|
||||
}
|
||||
index = nsCSSKeyword(PRInt32(index) + 1);
|
||||
|
||||
id = nsCSSKeywords::LookupKeyword(nsSubsumeCStr(tagName, PR_FALSE));
|
||||
if (id <= eCSSKeyword_UNKNOWN) {
|
||||
printf("bug: can't find '%s'\n", tagName);
|
||||
rv = -1;
|
||||
}
|
||||
if (et->id != id) {
|
||||
printf("bug: name='%s' et->id=%d id=%d\n", et->name, et->id, id);
|
||||
if (id != index) {
|
||||
printf("bug: name='%s' id=%d index=%d\n", tagName, id, index);
|
||||
rv = -1;
|
||||
}
|
||||
|
||||
// fiddle with the case to make sure we can still find it
|
||||
PL_strcpy(tagName, et->name);
|
||||
tagName[0] = tagName[0] - 32;
|
||||
id = nsCSSKeywords::LookupName(tagName);
|
||||
if (id < 0) {
|
||||
if (('a' <= tagName[0]) && (tagName[0] <= 'z')) {
|
||||
tagName[0] = tagName[0] - 32;
|
||||
}
|
||||
id = nsCSSKeywords::LookupKeyword(nsSubsumeCStr(tagName, PR_FALSE));
|
||||
if (id <= eCSSKeyword_UNKNOWN) {
|
||||
printf("bug: can't find '%s'\n", tagName);
|
||||
rv = -1;
|
||||
}
|
||||
if (et->id != id) {
|
||||
printf("bug: name='%s' et->id=%d id=%d\n", et->name, et->id, id);
|
||||
if (id != index) {
|
||||
printf("bug: name='%s' id=%d index=%d\n", tagName, id, index);
|
||||
rv = -1;
|
||||
}
|
||||
et++;
|
||||
@ -117,13 +143,14 @@ int TestKeywords() {
|
||||
// Now make sure we don't find some garbage
|
||||
for (int i = 0; i < (int) (sizeof(kJunkNames) / sizeof(const char*)); i++) {
|
||||
const char* tag = kJunkNames[i];
|
||||
id = nsCSSKeywords::LookupName(tag);
|
||||
if (id >= 0) {
|
||||
id = nsCSSKeywords::LookupKeyword(nsCAutoString(tag));
|
||||
if (eCSSKeyword_UNKNOWN < id) {
|
||||
printf("bug: found '%s'\n", tag ? tag : "(null)");
|
||||
rv = -1;
|
||||
}
|
||||
}
|
||||
|
||||
nsCSSKeywords::ReleaseTable();
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user