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