aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--embed/mozilla/EventContext.cpp87
-rw-r--r--embed/mozilla/EventContext.h1
3 files changed, 59 insertions, 37 deletions
diff --git a/ChangeLog b/ChangeLog
index b0866618a..afe2b6f5d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2004-07-04 Christian Persch <chpe@cvs.gnome.org>
+ * embed/mozilla/EventContext.cpp:
+ * embed/mozilla/EventContext.h:
+
+ Normal context menus for check/radio/submit buttons.
+ Fixes bug #143942.
+
+2004-07-04 Christian Persch <chpe@cvs.gnome.org>
+
* embed/downloader-view.c: (downloader_view_add_download):
Use regular return for valid error conditions, not
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<nsIDOMElement> 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<nsIDOMHTMLInputElement> 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<nsIDOMElement> 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<nsIDOMHTMLInputElement> 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<nsIURI> 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);