aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2005-08-18 01:19:29 +0800
committerChristian Persch <chpe@src.gnome.org>2005-08-18 01:19:29 +0800
commit1f6738608dcf343978412ed273ad58e974b4811a (patch)
tree9a7399205cde01f8a18e0f8f831c87a728c4409b
parent0e355828070842dc959d876aaac84fc3e327a28d (diff)
downloadgsoc2013-epiphany-1f6738608dcf343978412ed273ad58e974b4811a.tar
gsoc2013-epiphany-1f6738608dcf343978412ed273ad58e974b4811a.tar.gz
gsoc2013-epiphany-1f6738608dcf343978412ed273ad58e974b4811a.tar.bz2
gsoc2013-epiphany-1f6738608dcf343978412ed273ad58e974b4811a.tar.lz
gsoc2013-epiphany-1f6738608dcf343978412ed273ad58e974b4811a.tar.xz
gsoc2013-epiphany-1f6738608dcf343978412ed273ad58e974b4811a.tar.zst
gsoc2013-epiphany-1f6738608dcf343978412ed273ad58e974b4811a.zip
QI the element to check whether it's of some type, don't check the tag.
2005-08-17 Christian Persch <chpe@cvs.gnome.org> * embed/mozilla/EventContext.cpp: QI the element to check whether it's of some type, don't check the tag.
-rw-r--r--ChangeLog7
-rw-r--r--embed/mozilla/EventContext.cpp41
2 files changed, 35 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 87a135709..77fe3c584 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2005-08-17 Christian Persch <chpe@cvs.gnome.org>
+ * embed/mozilla/EventContext.cpp:
+
+ QI the element to check whether it's of some type,
+ don't check the tag.
+
+2005-08-17 Christian Persch <chpe@cvs.gnome.org>
+
* src/ephy-tab.c: (ephy_tab_title_cb):
Use ephy_tab_set_title after ephy_tab_set_loading_title
diff --git a/embed/mozilla/EventContext.cpp b/embed/mozilla/EventContext.cpp
index 04e1c1022..855cd06a5 100644
--- a/embed/mozilla/EventContext.cpp
+++ b/embed/mozilla/EventContext.cpp
@@ -58,6 +58,8 @@
#include <nsIDOMAbstractView.h>
#include <nsIDOMNSHTMLDocument.h>
#include <nsIDOMNSUIEvent.h>
+#include <nsIDOMHTMLSelectElement.h>
+#include <nsIDOMHTMLIsIndexElement.h>
#ifdef ALLOW_PRIVATE_API
#include <nsITextToSubURI.h>
@@ -1014,6 +1016,13 @@ EventContext::CheckKeyPress (nsIDOMKeyEvent *aEvent)
{
PRBool retval = PR_FALSE;
+ /* make sure the event is trusted */
+ nsCOMPtr<nsIDOMNSEvent> nsEvent (do_QueryInterface (aEvent));
+ NS_ENSURE_TRUE (nsEvent, retval);
+ PRBool isTrusted = PR_FALSE;
+ nsEvent->GetIsTrusted (&isTrusted);
+ if (!isTrusted) return retval;
+
/* check for alt/ctrl */
PRBool isCtrl = PR_FALSE, isAlt = PR_FALSE;
aEvent->GetCtrlKey (&isCtrl);
@@ -1037,22 +1046,27 @@ EventContext::CheckKeyPress (nsIDOMKeyEvent *aEvent)
nsCOMPtr<nsIDOMHTMLElement> element (do_QueryInterface (target, &rv));
NS_ENSURE_SUCCESS (rv, retval);
- PRUint16 type = 0;
- element->GetNodeType(&type);
- if (nsIDOMNode::ELEMENT_NODE != type) return retval;
+ nsCOMPtr<nsIDOMHTMLInputElement> inputElement (do_QueryInterface (element));
+ if (inputElement)
+ {
+ nsEmbedString type;
+ inputElement->GetType (type);
- nsEmbedString uTag;
- rv = element->GetLocalName(uTag);
- NS_ENSURE_SUCCESS (rv, retval);
+ nsEmbedCString (cType);
+ NS_UTF16ToCString (type, NS_CSTRING_ENCODING_UTF8, cType);
+
+ if (g_ascii_strcasecmp (cType.get(), "text") == 0 ||
+ g_ascii_strcasecmp (cType.get(), "password") == 0 ||
+ g_ascii_strcasecmp (cType.get(), "file") == 0) return retval;
+ }
- nsEmbedCString tag;
- NS_UTF16ToCString (uTag, NS_CSTRING_ENCODING_UTF8, tag);
+ nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea;
+ nsCOMPtr<nsIDOMHTMLSelectElement> selectElement;
+ nsCOMPtr<nsIDOMHTMLIsIndexElement> indexElement;
- if (g_ascii_strcasecmp (tag.get(), "input") == 0 ||
- g_ascii_strcasecmp (tag.get(), "textarea") == 0 ||
- g_ascii_strcasecmp (tag.get(), "select") == 0 ||
- g_ascii_strcasecmp (tag.get(), "button") == 0 ||
- g_ascii_strcasecmp (tag.get(), "isindex") == 0) return retval;
+ if ((textArea = do_QueryInterface (element)) ||
+ (selectElement = do_QueryInterface (element)) ||
+ (indexElement = do_QueryInterface (element))) return retval;
/* check for design mode */
nsCOMPtr<nsIDOMDocument> doc;
@@ -1060,6 +1074,7 @@ EventContext::CheckKeyPress (nsIDOMKeyEvent *aEvent)
NS_ENSURE_SUCCESS (rv, retval);
nsCOMPtr<nsIDOMNSHTMLDocument> 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;