зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1110917 - v3 Part 2: Fix focus not changing while selecting word. r=roc
This commit is contained in:
Родитель
31bef005d4
Коммит
a276a30c08
|
@ -584,18 +584,30 @@ SelectionCarets::SelectWord()
|
|||
nsPoint ptInFrame = mDownPoint;
|
||||
nsLayoutUtils::TransformPoint(rootFrame, ptFrame, ptInFrame);
|
||||
|
||||
// If target frame is editable, we should move focus to targe frame. If
|
||||
// target frame isn't editable and our focus content is editable, we should
|
||||
nsIFrame* currFrame = ptFrame;
|
||||
nsIContent* newFocusContent = nullptr;
|
||||
while (currFrame) {
|
||||
int32_t tabIndexUnused = 0;
|
||||
if (currFrame->IsFocusable(&tabIndexUnused, true)) {
|
||||
newFocusContent = currFrame->GetContent();
|
||||
nsCOMPtr<nsIDOMElement> domElement(do_QueryInterface(newFocusContent));
|
||||
if (domElement)
|
||||
break;
|
||||
}
|
||||
currFrame = currFrame->GetParent();
|
||||
}
|
||||
|
||||
|
||||
// If target frame is focusable, we should move focus to it. If target frame
|
||||
// isn't focusable, and our previous focused content is editable, we should
|
||||
// clear focus.
|
||||
nsFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
nsIContent* editingHost = ptFrame->GetContent()->GetEditingHost();
|
||||
if (editingHost) {
|
||||
nsCOMPtr<nsIDOMElement> elt = do_QueryInterface(editingHost->GetParent());
|
||||
if (elt) {
|
||||
fm->SetFocus(elt, 0);
|
||||
}
|
||||
if (newFocusContent && currFrame) {
|
||||
nsCOMPtr<nsIDOMElement> domElement(do_QueryInterface(newFocusContent));
|
||||
fm->SetFocus(domElement,0);
|
||||
|
||||
if (!nsContentUtils::HasNonEmptyTextContent(
|
||||
if (editingHost && !nsContentUtils::HasNonEmptyTextContent(
|
||||
editingHost, nsContentUtils::eRecurseIntoChildren)) {
|
||||
SELECTIONCARETS_LOG("Select a editable content %p with empty text",
|
||||
editingHost);
|
||||
|
|
Загрузка…
Ссылка в новой задаче