зеркало из https://github.com/mozilla/gecko-dev.git
Fix for bug 190382 (selectionEnd off by one when user selects text via CMD/CTRL-A)
- Prevent DOMPointToOffset() from counting a br as a newline, if it is the last child of the anonymous div. - Fixed 3 compiler warnings in DOMPointToOffset(). r=jkeiser@netscape.com sr=sfraser@netscape.com a=asa@mozilla.org
This commit is contained in:
Родитель
3686edfca5
Коммит
539c56b91f
|
@ -2430,8 +2430,9 @@ nsTextControlFrame::DOMPointToOffset(nsIDOMNode* aNode,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
PRInt32 i, textOffset = 0;
|
PRInt32 i, textOffset = 0;
|
||||||
|
PRInt32 lastIndex = (PRInt32)length - 1;
|
||||||
|
|
||||||
for (i = 0; i < length; i++) {
|
for (i = 0; i < (PRInt32)length; i++) {
|
||||||
if (rootNode == aNode && i == aNodeOffset) {
|
if (rootNode == aNode && i == aNodeOffset) {
|
||||||
*aResult = textOffset;
|
*aResult = textOffset;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -2451,7 +2452,7 @@ nsTextControlFrame::DOMPointToOffset(nsIDOMNode* aNode,
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
if (item == aNode) {
|
if (item == aNode) {
|
||||||
NS_ASSERTION((aNodeOffset >= 0 && aNodeOffset <= textLength),
|
NS_ASSERTION((aNodeOffset >= 0 && aNodeOffset <= (PRInt32)textLength),
|
||||||
"Invalid aNodeOffset!");
|
"Invalid aNodeOffset!");
|
||||||
*aResult = textOffset + aNodeOffset;
|
*aResult = textOffset + aNodeOffset;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -2460,13 +2461,15 @@ nsTextControlFrame::DOMPointToOffset(nsIDOMNode* aNode,
|
||||||
textOffset += textLength;
|
textOffset += textLength;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Must be a BR node, count it as a newline.
|
// Must be a BR node. If it's not the last BR node
|
||||||
|
// under the root, count it as a newline.
|
||||||
|
|
||||||
++textOffset;
|
if (i != lastIndex)
|
||||||
|
++textOffset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_ASSERTION((aNode == rootNode && aNodeOffset == length),
|
NS_ASSERTION((aNode == rootNode && aNodeOffset == (PRInt32)length),
|
||||||
"Invalide node offset!");
|
"Invalide node offset!");
|
||||||
|
|
||||||
*aResult = textOffset;
|
*aResult = textOffset;
|
||||||
|
|
|
@ -2430,8 +2430,9 @@ nsTextControlFrame::DOMPointToOffset(nsIDOMNode* aNode,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
PRInt32 i, textOffset = 0;
|
PRInt32 i, textOffset = 0;
|
||||||
|
PRInt32 lastIndex = (PRInt32)length - 1;
|
||||||
|
|
||||||
for (i = 0; i < length; i++) {
|
for (i = 0; i < (PRInt32)length; i++) {
|
||||||
if (rootNode == aNode && i == aNodeOffset) {
|
if (rootNode == aNode && i == aNodeOffset) {
|
||||||
*aResult = textOffset;
|
*aResult = textOffset;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -2451,7 +2452,7 @@ nsTextControlFrame::DOMPointToOffset(nsIDOMNode* aNode,
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
if (item == aNode) {
|
if (item == aNode) {
|
||||||
NS_ASSERTION((aNodeOffset >= 0 && aNodeOffset <= textLength),
|
NS_ASSERTION((aNodeOffset >= 0 && aNodeOffset <= (PRInt32)textLength),
|
||||||
"Invalid aNodeOffset!");
|
"Invalid aNodeOffset!");
|
||||||
*aResult = textOffset + aNodeOffset;
|
*aResult = textOffset + aNodeOffset;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -2460,13 +2461,15 @@ nsTextControlFrame::DOMPointToOffset(nsIDOMNode* aNode,
|
||||||
textOffset += textLength;
|
textOffset += textLength;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Must be a BR node, count it as a newline.
|
// Must be a BR node. If it's not the last BR node
|
||||||
|
// under the root, count it as a newline.
|
||||||
|
|
||||||
++textOffset;
|
if (i != lastIndex)
|
||||||
|
++textOffset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_ASSERTION((aNode == rootNode && aNodeOffset == length),
|
NS_ASSERTION((aNode == rootNode && aNodeOffset == (PRInt32)length),
|
||||||
"Invalide node offset!");
|
"Invalide node offset!");
|
||||||
|
|
||||||
*aResult = textOffset;
|
*aResult = textOffset;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче