зеркало из https://github.com/mozilla/pjs.git
Add CSS3 pseudo-class selector :only-child
bug 237568, patch by Sander <mybugzilla@juima.org>, r=bzbarsky, sr=dbaron
This commit is contained in:
Родитель
3fc52ef947
Коммит
2ee57e12be
|
@ -3478,6 +3478,27 @@ static PRBool SelectorMatches(RuleProcessorData &data,
|
||||||
}
|
}
|
||||||
result = localTrue == (data.mContent == lastChild);
|
result = localTrue == (data.mContent == lastChild);
|
||||||
}
|
}
|
||||||
|
else if (nsCSSPseudoClasses::onlyChild == pseudoClass->mAtom) {
|
||||||
|
nsIContent *onlyChild = nsnull;
|
||||||
|
nsIContent *moreChild = nsnull;
|
||||||
|
nsIContent *parent = data.mParentContent;
|
||||||
|
if (parent) {
|
||||||
|
PRInt32 index = -1;
|
||||||
|
do {
|
||||||
|
onlyChild = parent->GetChildAt(++index);
|
||||||
|
// stop at first non-comment, non-whitespace and non-text node
|
||||||
|
} while (onlyChild &&
|
||||||
|
!IsSignificantChild(onlyChild, PR_FALSE));
|
||||||
|
if (data.mContent == onlyChild) {
|
||||||
|
// see if there's any more
|
||||||
|
do {
|
||||||
|
moreChild = parent->GetChildAt(++index);
|
||||||
|
} while (moreChild && !IsSignificantChild(moreChild, PR_FALSE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result = localTrue == (data.mContent == onlyChild &&
|
||||||
|
moreChild == nsnull);
|
||||||
|
}
|
||||||
else if (nsCSSPseudoClasses::empty == pseudoClass->mAtom) {
|
else if (nsCSSPseudoClasses::empty == pseudoClass->mAtom) {
|
||||||
nsIContent *child = nsnull;
|
nsIContent *child = nsnull;
|
||||||
nsIContent *element = data.mContent;
|
nsIContent *element = data.mContent;
|
||||||
|
|
|
@ -73,4 +73,5 @@ CSS_PSEUDO_CLASS(firstChild, ":first-child")
|
||||||
CSS_PSEUDO_CLASS(firstNode, ":-moz-first-node")
|
CSS_PSEUDO_CLASS(firstNode, ":-moz-first-node")
|
||||||
CSS_PSEUDO_CLASS(lastChild, ":last-child")
|
CSS_PSEUDO_CLASS(lastChild, ":last-child")
|
||||||
CSS_PSEUDO_CLASS(lastNode, ":-moz-last-node")
|
CSS_PSEUDO_CLASS(lastNode, ":-moz-last-node")
|
||||||
|
CSS_PSEUDO_CLASS(onlyChild, ":only-child")
|
||||||
|
|
||||||
|
|
|
@ -73,4 +73,5 @@ CSS_PSEUDO_CLASS(firstChild, ":first-child")
|
||||||
CSS_PSEUDO_CLASS(firstNode, ":-moz-first-node")
|
CSS_PSEUDO_CLASS(firstNode, ":-moz-first-node")
|
||||||
CSS_PSEUDO_CLASS(lastChild, ":last-child")
|
CSS_PSEUDO_CLASS(lastChild, ":last-child")
|
||||||
CSS_PSEUDO_CLASS(lastNode, ":-moz-last-node")
|
CSS_PSEUDO_CLASS(lastNode, ":-moz-last-node")
|
||||||
|
CSS_PSEUDO_CLASS(onlyChild, ":only-child")
|
||||||
|
|
||||||
|
|
|
@ -3478,6 +3478,27 @@ static PRBool SelectorMatches(RuleProcessorData &data,
|
||||||
}
|
}
|
||||||
result = localTrue == (data.mContent == lastChild);
|
result = localTrue == (data.mContent == lastChild);
|
||||||
}
|
}
|
||||||
|
else if (nsCSSPseudoClasses::onlyChild == pseudoClass->mAtom) {
|
||||||
|
nsIContent *onlyChild = nsnull;
|
||||||
|
nsIContent *moreChild = nsnull;
|
||||||
|
nsIContent *parent = data.mParentContent;
|
||||||
|
if (parent) {
|
||||||
|
PRInt32 index = -1;
|
||||||
|
do {
|
||||||
|
onlyChild = parent->GetChildAt(++index);
|
||||||
|
// stop at first non-comment, non-whitespace and non-text node
|
||||||
|
} while (onlyChild &&
|
||||||
|
!IsSignificantChild(onlyChild, PR_FALSE));
|
||||||
|
if (data.mContent == onlyChild) {
|
||||||
|
// see if there's any more
|
||||||
|
do {
|
||||||
|
moreChild = parent->GetChildAt(++index);
|
||||||
|
} while (moreChild && !IsSignificantChild(moreChild, PR_FALSE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result = localTrue == (data.mContent == onlyChild &&
|
||||||
|
moreChild == nsnull);
|
||||||
|
}
|
||||||
else if (nsCSSPseudoClasses::empty == pseudoClass->mAtom) {
|
else if (nsCSSPseudoClasses::empty == pseudoClass->mAtom) {
|
||||||
nsIContent *child = nsnull;
|
nsIContent *child = nsnull;
|
||||||
nsIContent *element = data.mContent;
|
nsIContent *element = data.mContent;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче