Bug 1101364 - Part 1: Apply AutoApplyUserSelectStyle to nsHTMLEditor::SelectAll(). r=mats

This commit is contained in:
Morris Tseng 2014-12-12 01:15:00 -05:00
parent 50d890e0f7
commit 8ef3486369

View File

@ -3540,24 +3540,26 @@ nsHTMLEditor::SelectAll()
nsCOMPtr<nsIContent> anchorContent = do_QueryInterface(anchorNode, &rv);
NS_ENSURE_SUCCESS(rv, rv);
// If the anchor content has independent selection, we never need to explicitly
// select its children.
nsIContent *rootContent;
if (anchorContent->HasIndependentSelection()) {
rv = selection->SetAncestorLimiter(nullptr);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDOMNode> rootElement = do_QueryInterface(mRootElement, &rv);
NS_ENSURE_SUCCESS(rv, rv);
return selection->SelectAllChildren(rootElement);
rootContent = mRootElement;
} else {
nsCOMPtr<nsIPresShell> ps = GetPresShell();
rootContent = anchorContent->GetSelectionRootContent(ps);
}
nsCOMPtr<nsIPresShell> ps = GetPresShell();
nsIContent *rootContent = anchorContent->GetSelectionRootContent(ps);
NS_ENSURE_TRUE(rootContent, NS_ERROR_UNEXPECTED);
nsCOMPtr<nsIDOMNode> rootElement = do_QueryInterface(rootContent, &rv);
NS_ENSURE_SUCCESS(rv, rv);
Maybe<mozilla::dom::Selection::AutoApplyUserSelectStyle> userSelection;
if (!rootContent->IsEditable()) {
userSelection.emplace(selection);
}
return selection->SelectAllChildren(rootElement);
}