Bug 792928 - Don't select entire text when event offsets are out of bounds; r=masayuki

This commit is contained in:
Jim Chen 2012-10-19 14:45:54 -04:00
parent 8d914286b7
commit 726441b618
2 changed files with 6 additions and 3 deletions

View File

@ -375,7 +375,7 @@ nsContentEventHandler::SetRangeFromFlatTextOffset(
uint32_t nativeOffset = 0;
uint32_t nativeEndOffset = aNativeOffset + aNativeLength;
nsCOMPtr<nsIContent> content;
bool startSet = false;
for (; !iter->IsDone(); iter->Next()) {
nsINode* node = iter->GetCurrentNode();
if (!node)
@ -405,6 +405,7 @@ nsContentEventHandler::SetRangeFromFlatTextOffset(
rv = aRange->SetStart(domNode, int32_t(xpOffset));
NS_ENSURE_SUCCESS(rv, rv);
startSet = true;
if (aNativeLength == 0) {
// Ensure that the end offset and the start offset are same.
rv = aRange->SetEnd(domNode, int32_t(xpOffset));
@ -446,8 +447,9 @@ nsContentEventHandler::SetRangeFromFlatTextOffset(
nsCOMPtr<nsIDOMNode> domNode(do_QueryInterface(mRootContent));
NS_ASSERTION(domNode, "lastContent doesn't have nsIDOMNode!");
if (!content) {
rv = aRange->SetStart(domNode, 0);
if (!startSet) {
MOZ_ASSERT(!mRootContent->IsNodeOfType(nsINode::eTEXT));
rv = aRange->SetStart(domNode, int32_t(mRootContent->GetChildCount()));
NS_ENSURE_SUCCESS(rv, rv);
}
rv = aRange->SetEnd(domNode, int32_t(mRootContent->GetChildCount()));

View File

@ -1956,6 +1956,7 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
ae->Offset() + ae->Count());
selEvent.mLength = uint32_t(NS_ABS(ae->Count()));
selEvent.mReversed = ae->Count() >= 0 ? false : true;
selEvent.mExpandToClusterBoundary = false;
DispatchEvent(&selEvent);
}