correct case of selectors
skip empty selectors better pseudo-class support
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
#include "nsCRT.h"
|
#include "nsCRT.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
#include "nsStyleConsts.h"
|
#include "nsStyleConsts.h"
|
||||||
|
#include "nsHTMLAtoms.h"
|
||||||
#include "nsUnitConversion.h"
|
#include "nsUnitConversion.h"
|
||||||
|
|
||||||
//#define DEBUG_REFS
|
//#define DEBUG_REFS
|
||||||
@@ -115,12 +116,14 @@ PRBool nsCSSSelector::Equals(const nsCSSSelector* aOther) const
|
|||||||
void nsCSSSelector::Set(const nsString& aTag, const nsString& aID,
|
void nsCSSSelector::Set(const nsString& aTag, const nsString& aID,
|
||||||
const nsString& aClass, const nsString& aPseudoClass)
|
const nsString& aClass, const nsString& aPseudoClass)
|
||||||
{
|
{
|
||||||
|
nsAutoString buffer;
|
||||||
NS_IF_RELEASE(mTag);
|
NS_IF_RELEASE(mTag);
|
||||||
NS_IF_RELEASE(mID);
|
NS_IF_RELEASE(mID);
|
||||||
NS_IF_RELEASE(mClass);
|
NS_IF_RELEASE(mClass);
|
||||||
NS_IF_RELEASE(mPseudoClass);
|
NS_IF_RELEASE(mPseudoClass);
|
||||||
if (0 < aTag.Length()) {
|
if (0 < aTag.Length()) {
|
||||||
mTag = NS_NewAtom(aTag);
|
aTag.ToUpperCase(buffer); // XXX is this correct? what about class?
|
||||||
|
mTag = NS_NewAtom(buffer);
|
||||||
}
|
}
|
||||||
if (0 < aID.Length()) {
|
if (0 < aID.Length()) {
|
||||||
mID = NS_NewAtom(aID);
|
mID = NS_NewAtom(aID);
|
||||||
@@ -129,7 +132,12 @@ void nsCSSSelector::Set(const nsString& aTag, const nsString& aID,
|
|||||||
mClass = NS_NewAtom(aClass);
|
mClass = NS_NewAtom(aClass);
|
||||||
}
|
}
|
||||||
if (0 < aPseudoClass.Length()) {
|
if (0 < aPseudoClass.Length()) {
|
||||||
mPseudoClass = NS_NewAtom(aPseudoClass);
|
aPseudoClass.ToLowerCase(buffer);
|
||||||
|
mPseudoClass = NS_NewAtom(buffer);
|
||||||
|
if (nsnull == mTag) {
|
||||||
|
mTag = nsHTMLAtoms::a;
|
||||||
|
NS_ADDREF(mTag);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,6 +364,8 @@ nsCSSSelector* CSSStyleRuleImpl::FirstSelector(void)
|
|||||||
|
|
||||||
void CSSStyleRuleImpl::AddSelector(const nsCSSSelector& aSelector)
|
void CSSStyleRuleImpl::AddSelector(const nsCSSSelector& aSelector)
|
||||||
{
|
{
|
||||||
|
if ((nsnull != aSelector.mTag) || (nsnull != aSelector.mID) ||
|
||||||
|
(nsnull != aSelector.mClass) || (nsnull != aSelector.mPseudoClass)) { // skip empty selectors
|
||||||
nsCSSSelector* selector = new nsCSSSelector(aSelector);
|
nsCSSSelector* selector = new nsCSSSelector(aSelector);
|
||||||
nsCSSSelector* last = &mSelector;
|
nsCSSSelector* last = &mSelector;
|
||||||
|
|
||||||
@@ -364,6 +374,7 @@ void CSSStyleRuleImpl::AddSelector(const nsCSSSelector& aSelector)
|
|||||||
}
|
}
|
||||||
last->mNext = selector;
|
last->mNext = selector;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void CSSStyleRuleImpl::DeleteSelector(nsCSSSelector* aSelector)
|
void CSSStyleRuleImpl::DeleteSelector(nsCSSSelector* aSelector)
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include "nsCRT.h"
|
#include "nsCRT.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
#include "nsStyleConsts.h"
|
#include "nsStyleConsts.h"
|
||||||
|
#include "nsHTMLAtoms.h"
|
||||||
#include "nsUnitConversion.h"
|
#include "nsUnitConversion.h"
|
||||||
|
|
||||||
//#define DEBUG_REFS
|
//#define DEBUG_REFS
|
||||||
@@ -115,12 +116,14 @@ PRBool nsCSSSelector::Equals(const nsCSSSelector* aOther) const
|
|||||||
void nsCSSSelector::Set(const nsString& aTag, const nsString& aID,
|
void nsCSSSelector::Set(const nsString& aTag, const nsString& aID,
|
||||||
const nsString& aClass, const nsString& aPseudoClass)
|
const nsString& aClass, const nsString& aPseudoClass)
|
||||||
{
|
{
|
||||||
|
nsAutoString buffer;
|
||||||
NS_IF_RELEASE(mTag);
|
NS_IF_RELEASE(mTag);
|
||||||
NS_IF_RELEASE(mID);
|
NS_IF_RELEASE(mID);
|
||||||
NS_IF_RELEASE(mClass);
|
NS_IF_RELEASE(mClass);
|
||||||
NS_IF_RELEASE(mPseudoClass);
|
NS_IF_RELEASE(mPseudoClass);
|
||||||
if (0 < aTag.Length()) {
|
if (0 < aTag.Length()) {
|
||||||
mTag = NS_NewAtom(aTag);
|
aTag.ToUpperCase(buffer); // XXX is this correct? what about class?
|
||||||
|
mTag = NS_NewAtom(buffer);
|
||||||
}
|
}
|
||||||
if (0 < aID.Length()) {
|
if (0 < aID.Length()) {
|
||||||
mID = NS_NewAtom(aID);
|
mID = NS_NewAtom(aID);
|
||||||
@@ -129,7 +132,12 @@ void nsCSSSelector::Set(const nsString& aTag, const nsString& aID,
|
|||||||
mClass = NS_NewAtom(aClass);
|
mClass = NS_NewAtom(aClass);
|
||||||
}
|
}
|
||||||
if (0 < aPseudoClass.Length()) {
|
if (0 < aPseudoClass.Length()) {
|
||||||
mPseudoClass = NS_NewAtom(aPseudoClass);
|
aPseudoClass.ToLowerCase(buffer);
|
||||||
|
mPseudoClass = NS_NewAtom(buffer);
|
||||||
|
if (nsnull == mTag) {
|
||||||
|
mTag = nsHTMLAtoms::a;
|
||||||
|
NS_ADDREF(mTag);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,6 +364,8 @@ nsCSSSelector* CSSStyleRuleImpl::FirstSelector(void)
|
|||||||
|
|
||||||
void CSSStyleRuleImpl::AddSelector(const nsCSSSelector& aSelector)
|
void CSSStyleRuleImpl::AddSelector(const nsCSSSelector& aSelector)
|
||||||
{
|
{
|
||||||
|
if ((nsnull != aSelector.mTag) || (nsnull != aSelector.mID) ||
|
||||||
|
(nsnull != aSelector.mClass) || (nsnull != aSelector.mPseudoClass)) { // skip empty selectors
|
||||||
nsCSSSelector* selector = new nsCSSSelector(aSelector);
|
nsCSSSelector* selector = new nsCSSSelector(aSelector);
|
||||||
nsCSSSelector* last = &mSelector;
|
nsCSSSelector* last = &mSelector;
|
||||||
|
|
||||||
@@ -364,6 +374,7 @@ void CSSStyleRuleImpl::AddSelector(const nsCSSSelector& aSelector)
|
|||||||
}
|
}
|
||||||
last->mNext = selector;
|
last->mNext = selector;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void CSSStyleRuleImpl::DeleteSelector(nsCSSSelector* aSelector)
|
void CSSStyleRuleImpl::DeleteSelector(nsCSSSelector* aSelector)
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include "nsCRT.h"
|
#include "nsCRT.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
#include "nsStyleConsts.h"
|
#include "nsStyleConsts.h"
|
||||||
|
#include "nsHTMLAtoms.h"
|
||||||
#include "nsUnitConversion.h"
|
#include "nsUnitConversion.h"
|
||||||
|
|
||||||
//#define DEBUG_REFS
|
//#define DEBUG_REFS
|
||||||
@@ -115,12 +116,14 @@ PRBool nsCSSSelector::Equals(const nsCSSSelector* aOther) const
|
|||||||
void nsCSSSelector::Set(const nsString& aTag, const nsString& aID,
|
void nsCSSSelector::Set(const nsString& aTag, const nsString& aID,
|
||||||
const nsString& aClass, const nsString& aPseudoClass)
|
const nsString& aClass, const nsString& aPseudoClass)
|
||||||
{
|
{
|
||||||
|
nsAutoString buffer;
|
||||||
NS_IF_RELEASE(mTag);
|
NS_IF_RELEASE(mTag);
|
||||||
NS_IF_RELEASE(mID);
|
NS_IF_RELEASE(mID);
|
||||||
NS_IF_RELEASE(mClass);
|
NS_IF_RELEASE(mClass);
|
||||||
NS_IF_RELEASE(mPseudoClass);
|
NS_IF_RELEASE(mPseudoClass);
|
||||||
if (0 < aTag.Length()) {
|
if (0 < aTag.Length()) {
|
||||||
mTag = NS_NewAtom(aTag);
|
aTag.ToUpperCase(buffer); // XXX is this correct? what about class?
|
||||||
|
mTag = NS_NewAtom(buffer);
|
||||||
}
|
}
|
||||||
if (0 < aID.Length()) {
|
if (0 < aID.Length()) {
|
||||||
mID = NS_NewAtom(aID);
|
mID = NS_NewAtom(aID);
|
||||||
@@ -129,7 +132,12 @@ void nsCSSSelector::Set(const nsString& aTag, const nsString& aID,
|
|||||||
mClass = NS_NewAtom(aClass);
|
mClass = NS_NewAtom(aClass);
|
||||||
}
|
}
|
||||||
if (0 < aPseudoClass.Length()) {
|
if (0 < aPseudoClass.Length()) {
|
||||||
mPseudoClass = NS_NewAtom(aPseudoClass);
|
aPseudoClass.ToLowerCase(buffer);
|
||||||
|
mPseudoClass = NS_NewAtom(buffer);
|
||||||
|
if (nsnull == mTag) {
|
||||||
|
mTag = nsHTMLAtoms::a;
|
||||||
|
NS_ADDREF(mTag);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,6 +364,8 @@ nsCSSSelector* CSSStyleRuleImpl::FirstSelector(void)
|
|||||||
|
|
||||||
void CSSStyleRuleImpl::AddSelector(const nsCSSSelector& aSelector)
|
void CSSStyleRuleImpl::AddSelector(const nsCSSSelector& aSelector)
|
||||||
{
|
{
|
||||||
|
if ((nsnull != aSelector.mTag) || (nsnull != aSelector.mID) ||
|
||||||
|
(nsnull != aSelector.mClass) || (nsnull != aSelector.mPseudoClass)) { // skip empty selectors
|
||||||
nsCSSSelector* selector = new nsCSSSelector(aSelector);
|
nsCSSSelector* selector = new nsCSSSelector(aSelector);
|
||||||
nsCSSSelector* last = &mSelector;
|
nsCSSSelector* last = &mSelector;
|
||||||
|
|
||||||
@@ -364,6 +374,7 @@ void CSSStyleRuleImpl::AddSelector(const nsCSSSelector& aSelector)
|
|||||||
}
|
}
|
||||||
last->mNext = selector;
|
last->mNext = selector;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void CSSStyleRuleImpl::DeleteSelector(nsCSSSelector* aSelector)
|
void CSSStyleRuleImpl::DeleteSelector(nsCSSSelector* aSelector)
|
||||||
|
|||||||
Reference in New Issue
Block a user