From 3d5210a4ca588096cd847bff8a5e89b2d9f8c28b Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Sun, 4 Jul 2004 10:56:23 +0000 Subject: Normal context menus for check/radio/submit buttons. Fixes bug #143942. 2004-07-04 Christian Persch * embed/mozilla/EventContext.cpp: * embed/mozilla/EventContext.h: Normal context menus for check/radio/submit buttons. Fixes bug #143942. --- ChangeLog | 8 ++++ embed/mozilla/EventContext.cpp | 87 ++++++++++++++++++++++++------------------ embed/mozilla/EventContext.h | 1 + 3 files changed, 59 insertions(+), 37 deletions(-) diff --git a/ChangeLog b/ChangeLog index b0866618a..afe2b6f5d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-07-04 Christian Persch + + * embed/mozilla/EventContext.cpp: + * embed/mozilla/EventContext.h: + + Normal context menus for check/radio/submit buttons. + Fixes bug #143942. + 2004-07-04 Christian Persch * embed/downloader-view.c: (downloader_view_add_download): diff --git a/embed/mozilla/EventContext.cpp b/embed/mozilla/EventContext.cpp index 656def8c8..f3fac4740 100644 --- a/embed/mozilla/EventContext.cpp +++ b/embed/mozilla/EventContext.cpp @@ -245,41 +245,7 @@ nsresult EventContext::GetEventContext (nsIDOMEventTarget *EventTarget, } else if (g_ascii_strcasecmp (tag.get(), "input") == 0) { - nsCOMPtr element; - element = do_QueryInterface (node); - if (!element) return NS_ERROR_FAILURE; - - nsEmbedString uValue; - element->GetAttribute (nsEmbedString(typeLiteral), uValue); - - nsEmbedCString value; - NS_UTF16ToCString (uValue, NS_CSTRING_ENCODING_UTF8, value); - - if (g_ascii_strcasecmp (value.get(), "image") == 0) - { - info->context |= EMBED_CONTEXT_IMAGE; - nsCOMPtr input; - input = do_QueryInterface (node); - if (!input) return NS_ERROR_FAILURE; - - nsEmbedString img; - rv = input->GetSrc (img); - if (NS_FAILED(rv)) return NS_ERROR_FAILURE; - - nsEmbedCString cImg; - rv = ResolveBaseURL (img, cImg); - if (NS_FAILED(rv)) return NS_ERROR_FAILURE; - SetStringProperty ("image", cImg.get()); - } - else if (g_ascii_strcasecmp (value.get(), "radio") != 0 && - g_ascii_strcasecmp (value.get(), "submit") != 0 && - g_ascii_strcasecmp (value.get(), "reset") != 0 && - g_ascii_strcasecmp (value.get(), "hidden") != 0 && - g_ascii_strcasecmp (value.get(), "button") != 0 && - g_ascii_strcasecmp (value.get(), "checkbox") != 0) - { - info->context |= EMBED_CONTEXT_INPUT; - } + CheckInput (node); } else if (g_ascii_strcasecmp (tag.get(), "textarea") == 0) { @@ -494,8 +460,11 @@ nsresult EventContext::GetEventContext (nsIDOMEventTarget *EventTarget, CheckLinkScheme (href); } } - else if (g_ascii_strcasecmp (tag.get(), "textarea") == 0 || - g_ascii_strcasecmp (tag.get(), "input") == 0) + else if (g_ascii_strcasecmp (tag.get(), "input") == 0) + { + CheckInput (node); + } + else if (g_ascii_strcasecmp (tag.get(), "textarea") == 0) { info->context |= EMBED_CONTEXT_INPUT; } @@ -741,6 +710,50 @@ nsresult EventContext::GetTargetDocument (nsIDOMDocument **domDoc) return NS_OK; } +nsresult EventContext::CheckInput (nsIDOMNode *aNode) +{ + const PRUnichar typeLiteral[] = { 't', 'y', 'p', 'e', '\0' }; + + nsCOMPtr element; + element = do_QueryInterface (aNode); + if (!element) return NS_ERROR_FAILURE; + + nsEmbedString uValue; + element->GetAttribute (nsEmbedString(typeLiteral), uValue); + + nsEmbedCString value; + NS_UTF16ToCString (uValue, NS_CSTRING_ENCODING_UTF8, value); + + if (g_ascii_strcasecmp (value.get(), "image") == 0) + { + mEmbedEvent->context |= EMBED_CONTEXT_IMAGE; + nsCOMPtr input; + input = do_QueryInterface (aNode); + if (!input) return NS_ERROR_FAILURE; + + nsresult rv; + nsEmbedString img; + rv = input->GetSrc (img); + if (NS_FAILED(rv)) return NS_ERROR_FAILURE; + + nsEmbedCString cImg; + rv = ResolveBaseURL (img, cImg); + if (NS_FAILED(rv)) return NS_ERROR_FAILURE; + SetStringProperty ("image", cImg.get()); + } + else if (g_ascii_strcasecmp (value.get(), "radio") != 0 && + g_ascii_strcasecmp (value.get(), "submit") != 0 && + g_ascii_strcasecmp (value.get(), "reset") != 0 && + g_ascii_strcasecmp (value.get(), "hidden") != 0 && + g_ascii_strcasecmp (value.get(), "button") != 0 && + g_ascii_strcasecmp (value.get(), "checkbox") != 0) + { + mEmbedEvent->context |= EMBED_CONTEXT_INPUT; + } + + return NS_OK; +} + nsresult EventContext::CheckLinkScheme (const nsAString &link) { nsCOMPtr uri; diff --git a/embed/mozilla/EventContext.h b/embed/mozilla/EventContext.h index efc05322b..56ac96c58 100644 --- a/embed/mozilla/EventContext.h +++ b/embed/mozilla/EventContext.h @@ -57,6 +57,7 @@ private: MozillaEmbedEvent *info); nsresult GetCSSBackground (nsIDOMNode *node, nsAString& url); nsresult IsPageFramed (nsIDOMNode *node, PRBool *Framed); + nsresult CheckInput (nsIDOMNode *node); nsresult CheckLinkScheme (const nsAString &link); nsresult SetIntProperty (const char *name, int value); nsresult SetStringProperty (const char *name, const char *value); -- cgit v1.2.3