Bug 265203. When caret is at end of one link, focus displays to next link. r=ginn.chen, sr=bryner
This commit is contained in:
Родитель
b3a1483551
Коммит
7265e749d5
|
@ -4489,7 +4489,6 @@ nsEventStateManager::GetDocSelectionLocation(nsIContent **aStartContent,
|
||||||
domNode->GetNodeType(&nodeType);
|
domNode->GetNodeType(&nodeType);
|
||||||
|
|
||||||
if (nodeType == nsIDOMNode::TEXT_NODE) {
|
if (nodeType == nsIDOMNode::TEXT_NODE) {
|
||||||
nsCOMPtr<nsIContent> origStartContent(startContent);
|
|
||||||
nsAutoString nodeValue;
|
nsAutoString nodeValue;
|
||||||
domNode->GetNodeValue(nodeValue);
|
domNode->GetNodeValue(nodeValue);
|
||||||
|
|
||||||
|
@ -4509,24 +4508,43 @@ nsEventStateManager::GetDocSelectionLocation(nsIContent **aStartContent,
|
||||||
mPresContext, startFrame);
|
mPresContext, startFrame);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
nsIFrame *newCaretFrame = nsnull;
|
||||||
|
nsCOMPtr<nsIContent> newCaretContent = startContent;
|
||||||
|
PRBool endOfSelectionInStartNode(startContent == endContent);
|
||||||
do {
|
do {
|
||||||
// Get the next logical frame, and set the start of
|
// Continue getting the next frame until the primary content for the frame
|
||||||
// focusable elements. Search for focusable elements from there.
|
|
||||||
// Continue getting next frame until the primary node for the frame
|
|
||||||
// we are on changes - we don't want to be stuck in the same place
|
// we are on changes - we don't want to be stuck in the same place
|
||||||
frameTraversal->Next();
|
frameTraversal->Next();
|
||||||
nsISupports* currentItem;
|
nsISupports* currentItem;
|
||||||
frameTraversal->CurrentItem(¤tItem);
|
frameTraversal->CurrentItem(¤tItem);
|
||||||
startFrame = NS_STATIC_CAST(nsIFrame*, currentItem);
|
if (nsnull == (newCaretFrame = NS_STATIC_CAST(nsIFrame*, currentItem))) {
|
||||||
if (startFrame) {
|
break;
|
||||||
PRBool endEqualsStart(startContent == endContent);
|
}
|
||||||
startContent = startFrame->GetContent();
|
newCaretContent = newCaretFrame->GetContent();
|
||||||
if (endEqualsStart)
|
} while (!newCaretContent || newCaretContent == startContent);
|
||||||
endContent = startContent;
|
|
||||||
|
if (newCaretFrame && newCaretContent) {
|
||||||
|
// If the caret is exactly at the same position of the new frame,
|
||||||
|
// then we can use the newCaretFrame and newCaretContent for our position
|
||||||
|
nsCOMPtr<nsICaret> caret;
|
||||||
|
shell->GetCaret(getter_AddRefs(caret));
|
||||||
|
nsRect caretRect;
|
||||||
|
nsIView *caretView;
|
||||||
|
caret->GetCaretCoordinates(nsICaret::eClosestViewCoordinates,
|
||||||
|
domSelection, &caretRect,
|
||||||
|
&isCollapsed, &caretView);
|
||||||
|
nsPoint framePt;
|
||||||
|
nsIView *frameClosestView = newCaretFrame->GetClosestView(&framePt);
|
||||||
|
if (caretView == frameClosestView && caretRect.y == framePt.y &&
|
||||||
|
caretRect.x == framePt.x) {
|
||||||
|
// The caret is at the start of the new element.
|
||||||
|
startFrame = newCaretFrame;
|
||||||
|
startContent = newCaretContent;
|
||||||
|
if (endOfSelectionInStartNode) {
|
||||||
|
endContent = newCaretContent; // Ensure end of selection is not before start
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else break;
|
|
||||||
}
|
}
|
||||||
while (startContent == origStartContent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче