зеркало из https://github.com/mozilla/gecko-dev.git
Bug 336785 r=darin sr+a=bryner Crash when context menu pops up
This commit is contained in:
Родитель
799d6fc8c1
Коммит
f82c20ad33
|
@ -2036,16 +2036,18 @@ nsEventListenerManager::PrepareToUseCaretPosition(nsIWidget* aEventWidget,
|
||||||
nsCOMPtr<nsICaret> caret;
|
nsCOMPtr<nsICaret> caret;
|
||||||
rv = aShell->GetCaret(getter_AddRefs(caret));
|
rv = aShell->GetCaret(getter_AddRefs(caret));
|
||||||
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||||
|
NS_ENSURE_TRUE(caret, PR_FALSE);
|
||||||
|
|
||||||
PRBool caretVisible = PR_FALSE;
|
PRBool caretVisible = PR_FALSE;
|
||||||
rv = caret->GetCaretVisible(&caretVisible);
|
rv = caret->GetCaretVisible(&caretVisible);
|
||||||
if (NS_FAILED(rv) || ! caretVisible)
|
if (NS_FAILED(rv) || ! caretVisible)
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
|
|
||||||
// caret selection
|
// caret selection, watch out: GetCaretDOMSelection can return null but NS_OK
|
||||||
nsCOMPtr<nsISelection> domSelection;
|
nsCOMPtr<nsISelection> domSelection;
|
||||||
rv = caret->GetCaretDOMSelection(getter_AddRefs(domSelection));
|
rv = caret->GetCaretDOMSelection(getter_AddRefs(domSelection));
|
||||||
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||||
|
NS_ENSURE_TRUE(domSelection, PR_FALSE);
|
||||||
|
|
||||||
// since the match could be an anonymous textnode inside a
|
// since the match could be an anonymous textnode inside a
|
||||||
// <textarea> or text <input>, we need to get the outer frame
|
// <textarea> or text <input>, we need to get the outer frame
|
||||||
|
@ -2054,6 +2056,7 @@ nsEventListenerManager::PrepareToUseCaretPosition(nsIWidget* aEventWidget,
|
||||||
nsCOMPtr<nsIDOMNode> node;
|
nsCOMPtr<nsIDOMNode> node;
|
||||||
rv = domSelection->GetFocusNode(getter_AddRefs(node));
|
rv = domSelection->GetFocusNode(getter_AddRefs(node));
|
||||||
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||||
|
NS_ENSURE_TRUE(node, PR_FALSE);
|
||||||
nsCOMPtr<nsIContent> content(do_QueryInterface(node));
|
nsCOMPtr<nsIContent> content(do_QueryInterface(node));
|
||||||
for ( ; content; content = content->GetParent()) {
|
for ( ; content; content = content->GetParent()) {
|
||||||
if (!content->IsNativeAnonymous()) {
|
if (!content->IsNativeAnonymous()) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче