Implement new method

git-svn-id: svn://10.0.0.236/trunk@25289 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
kipp%netscape.com
1999-03-27 01:20:15 +00:00
parent cde51e3c4f
commit ec12bbacef
2 changed files with 68 additions and 0 deletions

View File

@@ -73,6 +73,8 @@ public:
PRInt32 aLength,
PRBool aNotify);
NS_IMETHOD IsOnlyWhitespace(PRBool* aResult);
protected:
nsGenericDOMDataNode mInner;
};
@@ -298,3 +300,35 @@ nsTextNode::SetText(const char* aBuffer, PRInt32 aLength,
}
return NS_OK;
}
NS_IMETHODIMP
nsTextNode::IsOnlyWhitespace(PRBool* aResult)
{
nsTextFragment& frag = mInner.mText;
if (frag.Is2b()) {
const PRUnichar* cp = frag.Get2b();
const PRUnichar* end = cp + frag.GetLength();
while (cp < end) {
PRUnichar ch = *cp++;
if (!XP_IS_SPACE(ch)) {
*aResult = PR_FALSE;
return NS_OK;
}
}
}
else {
const char* cp = frag.Get1b();
const char* end = cp + frag.GetLength();
while (cp < end) {
PRUnichar ch = PRUnichar(*(unsigned char*)cp);
cp++;
if (!XP_IS_SPACE(ch)) {
*aResult = PR_FALSE;
return NS_OK;
}
}
}
*aResult = PR_TRUE;
return NS_OK;
}