From fe6b3046a330f10f339099fbbd23587d5da928f6 Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Fri, 13 Jan 2006 11:46:24 +0000 Subject: Don't require a HTML document to activate typeaheadfind. Bug #326813. 2006-01-13 Christian Persch * embed/mozilla/EventContext.cpp: Don't require a HTML document to activate typeaheadfind. Bug #326813. --- embed/mozilla/EventContext.cpp | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) (limited to 'embed') diff --git a/embed/mozilla/EventContext.cpp b/embed/mozilla/EventContext.cpp index cb202d7b8..dd71234f5 100644 --- a/embed/mozilla/EventContext.cpp +++ b/embed/mozilla/EventContext.cpp @@ -1042,10 +1042,7 @@ EventContext::CheckKeyPress (nsIDOMKeyEvent *aEvent) rv = aEvent->GetTarget (getter_AddRefs (target)); NS_ENSURE_SUCCESS (rv, retval); - nsCOMPtr element (do_QueryInterface (target, &rv)); - NS_ENSURE_SUCCESS (rv, retval); - - nsCOMPtr inputElement (do_QueryInterface (element)); + nsCOMPtr inputElement (do_QueryInterface (target)); if (inputElement) { nsEmbedString type; @@ -1063,27 +1060,34 @@ EventContext::CheckKeyPress (nsIDOMKeyEvent *aEvent) nsCOMPtr selectElement; nsCOMPtr indexElement; - if ((textArea = do_QueryInterface (element)) || - (selectElement = do_QueryInterface (element)) || - (indexElement = do_QueryInterface (element))) return retval; + if ((textArea = do_QueryInterface (target)) || + (selectElement = do_QueryInterface (target)) || + (indexElement = do_QueryInterface (target))) return retval; /* check for design mode */ + nsCOMPtr node (do_QueryInterface (target, &rv)); + NS_ENSURE_SUCCESS (rv, PR_FALSE); + nsCOMPtr doc; - rv = element->GetOwnerDocument (getter_AddRefs (doc)); + rv = node->GetOwnerDocument (getter_AddRefs (doc)); NS_ENSURE_SUCCESS (rv, retval); - nsCOMPtr htmlDoc (do_QueryInterface (doc, &rv)); - /* FIXME: return PR_TRUE here ? */ - if (NS_FAILED (rv)) return retval; /* it's okay not to be a HTML document */ - - nsEmbedString uDesign; - rv = htmlDoc->GetDesignMode (uDesign); - NS_ENSURE_SUCCESS (rv, retval); + nsCOMPtr htmlDoc (do_QueryInterface (doc)); + if (htmlDoc) + { + nsEmbedString uDesign; + rv = htmlDoc->GetDesignMode (uDesign); + NS_ENSURE_SUCCESS (rv, retval); - nsEmbedCString design; - NS_UTF16ToCString (uDesign, NS_CSTRING_ENCODING_UTF8, design); + nsEmbedCString design; + NS_UTF16ToCString (uDesign, NS_CSTRING_ENCODING_UTF8, design); - retval = g_ascii_strcasecmp (design.get(), "on") != 0; + retval = g_ascii_strcasecmp (design.get(), "on") != 0; + } + else + { + retval = PR_TRUE; + } return retval; } -- cgit