зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1275914 part.6 ContentEventHandler::OnQuerySelectedText() shouldn't refer anchor and focus of selection if there are 2 or more selection ranges r=smaug
Selection's focus and anchor node and offset are stored only for the last range. However, ContentEventHandler needs its first range. Therefore, ContentEventHandler shouldn't refer them if there are two or more selection ranges. MozReview-Commit-ID: ACflFE3ZrOM --HG-- extra : rebase_source : 9a2d1ef0e18a07881f77deff579830a4a0c97fc5
This commit is contained in:
Родитель
4e5c167f73
Коммит
99f2ffe496
|
@ -1233,6 +1233,10 @@ ContentEventHandler::OnQuerySelectedText(WidgetQueryContentEvent* aEvent)
|
|||
nsCOMPtr<nsINode> anchorNode, focusNode;
|
||||
int32_t anchorOffset, focusOffset;
|
||||
if (mSelection->RangeCount()) {
|
||||
// If there is only one selection range, the anchor/focus node and offset
|
||||
// are the information of the range. Therefore, we have the direction
|
||||
// information.
|
||||
if (mSelection->RangeCount() == 1) {
|
||||
anchorNode = mSelection->GetAnchorNode();
|
||||
focusNode = mSelection->GetFocusNode();
|
||||
if (NS_WARN_IF(!anchorNode) || NS_WARN_IF(!focusNode)) {
|
||||
|
@ -1247,23 +1251,15 @@ ContentEventHandler::OnQuerySelectedText(WidgetQueryContentEvent* aEvent)
|
|||
int16_t compare = nsContentUtils::ComparePoints(anchorNode, anchorOffset,
|
||||
focusNode, focusOffset);
|
||||
aEvent->mReply.mReversed = compare > 0;
|
||||
}
|
||||
// However, if there are 2 or more selection ranges, we have no information
|
||||
// of that.
|
||||
else {
|
||||
aEvent->mReply.mReversed = false;
|
||||
}
|
||||
|
||||
if (compare) {
|
||||
RefPtr<nsRange> range;
|
||||
if (mSelection->RangeCount() == 1) {
|
||||
range = mFirstSelectedRange;
|
||||
} else {
|
||||
rv = nsRange::CreateRange(anchorNode, anchorOffset,
|
||||
focusNode, focusOffset,
|
||||
getter_AddRefs(range));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
if (NS_WARN_IF(!range)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
rv = GenerateFlatTextContent(range, aEvent->mReply.mString,
|
||||
if (!mFirstSelectedRange->Collapsed()) {
|
||||
rv = GenerateFlatTextContent(mFirstSelectedRange, aEvent->mReply.mString,
|
||||
lineBreakType);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
|
|
Загрузка…
Ссылка в новой задаче