mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-04-02 12:32:55 +00:00
Implement new method
This commit is contained in:
parent
a0ef7d0fd6
commit
0c1b82b05a
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user