From 9b327283f0707c0cbed4489efa66e149f5c0dc54 Mon Sep 17 00:00:00 2001 From: peterl Date: Wed, 13 May 1998 22:40:54 +0000 Subject: [PATCH] fixed bug in parse declaration block, we now discard empty declarations tweaked position --- content/html/style/src/nsCSSParser.cpp | 18 +++++++++++------- layout/html/style/src/nsCSSParser.cpp | 18 +++++++++++------- layout/style/nsCSSParser.cpp | 18 +++++++++++------- 3 files changed, 33 insertions(+), 21 deletions(-) diff --git a/content/html/style/src/nsCSSParser.cpp b/content/html/style/src/nsCSSParser.cpp index 449b6af625d..83fe8a37b2f 100644 --- a/content/html/style/src/nsCSSParser.cpp +++ b/content/html/style/src/nsCSSParser.cpp @@ -639,8 +639,6 @@ PRBool CSSParserImpl::ParseRuleSet(PRInt32* aErrorCode) // Translate the selector list and declaration block into style data - // XXX PSL working here - SelectorList* list = slist; nsCSSSelector selector; nsICSSStyleRule* rule; @@ -670,8 +668,6 @@ PRBool CSSParserImpl::ParseRuleSet(PRInt32* aErrorCode) list = list->mNext; } - // XXX PSL working here - // Release temporary storage slist->Destroy(); NS_RELEASE(declaration); @@ -833,8 +829,12 @@ nsICSSDeclaration* CSSParserImpl::ParseDeclarationBlock(PRInt32* aErrorCode) } nsICSSDeclaration* declaration = nsnull; if (NS_OK == NS_NewCSSDeclaration(&declaration)) { + PRInt32 count = 0; for (;;) { - if (!ParseDeclaration(aErrorCode, declaration)) { + if (ParseDeclaration(aErrorCode, declaration)) { + count++; // count declarations + } + else { SkipDeclaration(aErrorCode); if (ExpectSymbol(aErrorCode, '}', PR_TRUE)) { break; @@ -843,6 +843,9 @@ nsICSSDeclaration* CSSParserImpl::ParseDeclarationBlock(PRInt32* aErrorCode) // the next declaration. } } + if (0 == count) { // didn't get any XXX is this ok with the DOM? + NS_RELEASE(declaration); + } } return declaration; } @@ -999,6 +1002,7 @@ PRBool CSSParserImpl::ParseDeclaration(PRInt32* aErrorCode, nsICSSDeclaration* a #define VARIANT_HL (VARIANT_INHERIT | VARIANT_LENGTH) #define VARIANT_HLP (VARIANT_HL | VARIANT_PERCENT) #define VARIANT_HLPN (VARIANT_HLP | VARIANT_NUMBER) +#define VARIANT_HMK (VARIANT_INHERIT | VARIANT_NORMAL | VARIANT_KEYWORD) #define VARIANT_AL (VARIANT_AUTO | VARIANT_LENGTH) #define VARIANT_LP (VARIANT_LENGTH | VARIANT_PERCENT) #define VARIANT_CK (VARIANT_COLOR | VARIANT_KEYWORD) @@ -1146,9 +1150,9 @@ static PRInt32 kOverflowKTable[] = { }; static PRInt32 kPositionKTable[] = { - KEYWORD_STATIC, NS_STYLE_POSITION_STATIC, KEYWORD_RELATIVE, NS_STYLE_POSITION_RELATIVE, KEYWORD_ABSOLUTE, NS_STYLE_POSITION_ABSOLUTE, + KEYWORD_FIXED, NS_STYLE_POSITION_FIXED, -1 }; @@ -1594,7 +1598,7 @@ PRBool CSSParserImpl::ParseProperty(PRInt32* aErrorCode, case PROP_OVERFLOW: return ParseEnum(aErrorCode, aDeclaration, aName, kOverflowKTable); case PROP_POSITION: - return ParseEnum(aErrorCode, aDeclaration, aName, kPositionKTable); + return ParseVariant(aErrorCode, aDeclaration, aName, VARIANT_HMK, kPositionKTable); case PROP_TEXT_ALIGN: return ParseEnum(aErrorCode, aDeclaration, aName, kTextAlignKTable); case PROP_TEXT_DECORATION: diff --git a/layout/html/style/src/nsCSSParser.cpp b/layout/html/style/src/nsCSSParser.cpp index 449b6af625d..83fe8a37b2f 100644 --- a/layout/html/style/src/nsCSSParser.cpp +++ b/layout/html/style/src/nsCSSParser.cpp @@ -639,8 +639,6 @@ PRBool CSSParserImpl::ParseRuleSet(PRInt32* aErrorCode) // Translate the selector list and declaration block into style data - // XXX PSL working here - SelectorList* list = slist; nsCSSSelector selector; nsICSSStyleRule* rule; @@ -670,8 +668,6 @@ PRBool CSSParserImpl::ParseRuleSet(PRInt32* aErrorCode) list = list->mNext; } - // XXX PSL working here - // Release temporary storage slist->Destroy(); NS_RELEASE(declaration); @@ -833,8 +829,12 @@ nsICSSDeclaration* CSSParserImpl::ParseDeclarationBlock(PRInt32* aErrorCode) } nsICSSDeclaration* declaration = nsnull; if (NS_OK == NS_NewCSSDeclaration(&declaration)) { + PRInt32 count = 0; for (;;) { - if (!ParseDeclaration(aErrorCode, declaration)) { + if (ParseDeclaration(aErrorCode, declaration)) { + count++; // count declarations + } + else { SkipDeclaration(aErrorCode); if (ExpectSymbol(aErrorCode, '}', PR_TRUE)) { break; @@ -843,6 +843,9 @@ nsICSSDeclaration* CSSParserImpl::ParseDeclarationBlock(PRInt32* aErrorCode) // the next declaration. } } + if (0 == count) { // didn't get any XXX is this ok with the DOM? + NS_RELEASE(declaration); + } } return declaration; } @@ -999,6 +1002,7 @@ PRBool CSSParserImpl::ParseDeclaration(PRInt32* aErrorCode, nsICSSDeclaration* a #define VARIANT_HL (VARIANT_INHERIT | VARIANT_LENGTH) #define VARIANT_HLP (VARIANT_HL | VARIANT_PERCENT) #define VARIANT_HLPN (VARIANT_HLP | VARIANT_NUMBER) +#define VARIANT_HMK (VARIANT_INHERIT | VARIANT_NORMAL | VARIANT_KEYWORD) #define VARIANT_AL (VARIANT_AUTO | VARIANT_LENGTH) #define VARIANT_LP (VARIANT_LENGTH | VARIANT_PERCENT) #define VARIANT_CK (VARIANT_COLOR | VARIANT_KEYWORD) @@ -1146,9 +1150,9 @@ static PRInt32 kOverflowKTable[] = { }; static PRInt32 kPositionKTable[] = { - KEYWORD_STATIC, NS_STYLE_POSITION_STATIC, KEYWORD_RELATIVE, NS_STYLE_POSITION_RELATIVE, KEYWORD_ABSOLUTE, NS_STYLE_POSITION_ABSOLUTE, + KEYWORD_FIXED, NS_STYLE_POSITION_FIXED, -1 }; @@ -1594,7 +1598,7 @@ PRBool CSSParserImpl::ParseProperty(PRInt32* aErrorCode, case PROP_OVERFLOW: return ParseEnum(aErrorCode, aDeclaration, aName, kOverflowKTable); case PROP_POSITION: - return ParseEnum(aErrorCode, aDeclaration, aName, kPositionKTable); + return ParseVariant(aErrorCode, aDeclaration, aName, VARIANT_HMK, kPositionKTable); case PROP_TEXT_ALIGN: return ParseEnum(aErrorCode, aDeclaration, aName, kTextAlignKTable); case PROP_TEXT_DECORATION: diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index 449b6af625d..83fe8a37b2f 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -639,8 +639,6 @@ PRBool CSSParserImpl::ParseRuleSet(PRInt32* aErrorCode) // Translate the selector list and declaration block into style data - // XXX PSL working here - SelectorList* list = slist; nsCSSSelector selector; nsICSSStyleRule* rule; @@ -670,8 +668,6 @@ PRBool CSSParserImpl::ParseRuleSet(PRInt32* aErrorCode) list = list->mNext; } - // XXX PSL working here - // Release temporary storage slist->Destroy(); NS_RELEASE(declaration); @@ -833,8 +829,12 @@ nsICSSDeclaration* CSSParserImpl::ParseDeclarationBlock(PRInt32* aErrorCode) } nsICSSDeclaration* declaration = nsnull; if (NS_OK == NS_NewCSSDeclaration(&declaration)) { + PRInt32 count = 0; for (;;) { - if (!ParseDeclaration(aErrorCode, declaration)) { + if (ParseDeclaration(aErrorCode, declaration)) { + count++; // count declarations + } + else { SkipDeclaration(aErrorCode); if (ExpectSymbol(aErrorCode, '}', PR_TRUE)) { break; @@ -843,6 +843,9 @@ nsICSSDeclaration* CSSParserImpl::ParseDeclarationBlock(PRInt32* aErrorCode) // the next declaration. } } + if (0 == count) { // didn't get any XXX is this ok with the DOM? + NS_RELEASE(declaration); + } } return declaration; } @@ -999,6 +1002,7 @@ PRBool CSSParserImpl::ParseDeclaration(PRInt32* aErrorCode, nsICSSDeclaration* a #define VARIANT_HL (VARIANT_INHERIT | VARIANT_LENGTH) #define VARIANT_HLP (VARIANT_HL | VARIANT_PERCENT) #define VARIANT_HLPN (VARIANT_HLP | VARIANT_NUMBER) +#define VARIANT_HMK (VARIANT_INHERIT | VARIANT_NORMAL | VARIANT_KEYWORD) #define VARIANT_AL (VARIANT_AUTO | VARIANT_LENGTH) #define VARIANT_LP (VARIANT_LENGTH | VARIANT_PERCENT) #define VARIANT_CK (VARIANT_COLOR | VARIANT_KEYWORD) @@ -1146,9 +1150,9 @@ static PRInt32 kOverflowKTable[] = { }; static PRInt32 kPositionKTable[] = { - KEYWORD_STATIC, NS_STYLE_POSITION_STATIC, KEYWORD_RELATIVE, NS_STYLE_POSITION_RELATIVE, KEYWORD_ABSOLUTE, NS_STYLE_POSITION_ABSOLUTE, + KEYWORD_FIXED, NS_STYLE_POSITION_FIXED, -1 }; @@ -1594,7 +1598,7 @@ PRBool CSSParserImpl::ParseProperty(PRInt32* aErrorCode, case PROP_OVERFLOW: return ParseEnum(aErrorCode, aDeclaration, aName, kOverflowKTable); case PROP_POSITION: - return ParseEnum(aErrorCode, aDeclaration, aName, kPositionKTable); + return ParseVariant(aErrorCode, aDeclaration, aName, VARIANT_HMK, kPositionKTable); case PROP_TEXT_ALIGN: return ParseEnum(aErrorCode, aDeclaration, aName, kTextAlignKTable); case PROP_TEXT_DECORATION: