mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 725221. Don't fire notifications in nsGenericDOMDataNode::SetTextInternal if the text hasn't changed. r=jst
This commit is contained in:
parent
e9992c0076
commit
f141285d2c
@ -313,6 +313,9 @@ nsGenericDOMDataNode::SetTextInternal(PRUint32 aOffset, PRUint32 aCount,
|
||||
return NS_ERROR_DOM_DOMSTRING_SIZE_ERR;
|
||||
}
|
||||
|
||||
if (aCount == aLength && mText.SubstringEquals(aOffset, aBuffer, aLength))
|
||||
return NS_OK;
|
||||
|
||||
nsIDocument *document = GetCurrentDoc();
|
||||
mozAutoDocUpdate updateBatch(document, UPDATE_CONTENT_MODEL, aNotify);
|
||||
|
||||
|
@ -453,3 +453,18 @@ nsTextFragment::UpdateBidiFlag(const PRUnichar* aBuffer, PRUint32 aLength)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
nsTextFragment::SubstringEquals(PRInt32 aOffset, const PRUnichar* aString, PRInt32 aLength)
|
||||
{
|
||||
NS_ASSERTION(aOffset + aLength <= GetLength(), "Bad substring");
|
||||
if (mState.mIs2b) {
|
||||
return memcmp(aString, m2b + aOffset, sizeof(PRUnichar)*aLength) == 0;
|
||||
}
|
||||
const char* text = m1b + aOffset;
|
||||
for (PRInt32 i = 0; i < aLength; ++i) {
|
||||
if (PRUint8(text[i]) != aString[i])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -211,6 +211,8 @@ public:
|
||||
return mState.mIs2b ? m2b[aIndex] : static_cast<unsigned char>(m1b[aIndex]);
|
||||
}
|
||||
|
||||
bool SubstringEquals(PRInt32 aOffset, const PRUnichar* aString, PRInt32 aLength);
|
||||
|
||||
struct FragmentBits {
|
||||
// PRUint32 to ensure that the values are unsigned, because we
|
||||
// want 0/1, not 0/-1!
|
||||
|
Loading…
Reference in New Issue
Block a user