aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
authorJean-François Rameau <jframeau@cvs.gnome.org>2005-06-03 04:50:28 +0800
committerJean-François Rameau <jframeau@src.gnome.org>2005-06-03 04:50:28 +0800
commit822d2a28ff4c437e23043dc03adbb00ddde36e4d (patch)
treeb9b3df4e0350c30ee40f1883995d7e504905322a /embed
parentc05ed5c9156eb0bede7b1ed088fdad8c28b2372a (diff)
downloadgsoc2013-epiphany-822d2a28ff4c437e23043dc03adbb00ddde36e4d.tar
gsoc2013-epiphany-822d2a28ff4c437e23043dc03adbb00ddde36e4d.tar.gz
gsoc2013-epiphany-822d2a28ff4c437e23043dc03adbb00ddde36e4d.tar.bz2
gsoc2013-epiphany-822d2a28ff4c437e23043dc03adbb00ddde36e4d.tar.lz
gsoc2013-epiphany-822d2a28ff4c437e23043dc03adbb00ddde36e4d.tar.xz
gsoc2013-epiphany-822d2a28ff4c437e23043dc03adbb00ddde36e4d.tar.zst
gsoc2013-epiphany-822d2a28ff4c437e23043dc03adbb00ddde36e4d.zip
Add code to handle area tags. Fix bug #152482
2005-06-02 Jean-François Rameau <jframeau@cvs.gnome.org> * embed/mozilla/EventContext.cpp: (EventContext::GetEventContext): Add code to handle area tags. Fix bug #152482
Diffstat (limited to 'embed')
-rw-r--r--embed/mozilla/EventContext.cpp63
1 files changed, 63 insertions, 0 deletions
diff --git a/embed/mozilla/EventContext.cpp b/embed/mozilla/EventContext.cpp
index 1ac345b5b..6211b36a8 100644
--- a/embed/mozilla/EventContext.cpp
+++ b/embed/mozilla/EventContext.cpp
@@ -43,9 +43,11 @@
#include <nsIDOMElement.h>
#include <nsIURI.h>
#include <nsIDOMCharacterData.h>
+#include <nsIDOMHTMLAreaElement.h>
#include <nsIDOMHTMLButtonElement.h>
#include <nsIDOMHTMLLabelElement.h>
#include <nsIDOMHTMLLegendElement.h>
+#include <nsIDOMHTMLMapElement.h>
#include <nsIDOMHTMLTextAreaElement.h>
#include <nsIDOMElementCSSInlineStyle.h>
#include <nsIDOMCSSStyleDeclaration.h>
@@ -198,6 +200,7 @@ nsresult EventContext::GetEventContext (nsIDOMEventTarget *EventTarget,
nsresult rv;
const PRUnichar hrefLiteral[] = {'h', 'r', 'e', 'f', '\0'};
+ const PRUnichar imgLiteral[] = {'i', 'm', 'g', '\0'};
const PRUnichar typeLiteral[] = {'t', 'y', 'p', 'e', '\0'};
const PRUnichar xlinknsLiteral[] = {'h', 't', 't', 'p', ':', '/', '/','w',
'w', 'w', '.', 'w', '3', '.', 'o', 'r',
@@ -284,6 +287,66 @@ nsresult EventContext::GetEventContext (nsIDOMEventTarget *EventTarget,
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
SetStringProperty ("image", img);
}
+ else if (g_ascii_strcasecmp (tag.get(), "area") == 0)
+ {
+ nsCOMPtr <nsIDOMHTMLAreaElement> area =
+ do_QueryInterface(node, &rv);
+ if (NS_FAILED(rv) || !area) return NS_ERROR_FAILURE;
+
+ // Parent node is the map itself
+ nsCOMPtr<nsIDOMNode> parentNode;
+ node->GetParentNode (getter_AddRefs(parentNode));
+
+ nsCOMPtr <nsIDOMHTMLMapElement> map =
+ do_QueryInterface(parentNode, &rv);
+ if (NS_FAILED(rv) || !area) return NS_ERROR_FAILURE;
+
+ nsEmbedString mapName;
+ rv = map->GetName (mapName);
+ if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
+
+ // Now we are searching for all the images with a usemap attribute
+ nsCOMPtr<nsIDOMNodeList> imgs;
+ rv = mDOMDocument->GetElementsByTagName (nsEmbedString(imgLiteral),
+ getter_AddRefs (imgs));
+ if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
+
+ PRUint32 imgs_count;
+ rv = imgs->GetLength (&imgs_count);
+ if (NS_FAILED (rv)) return NS_ERROR_FAILURE;
+
+ for (PRUint32 i = 0; i < imgs_count; i++)
+ {
+ nsCOMPtr<nsIDOMNode> aNode;
+ rv = imgs->Item (i, getter_AddRefs (aNode));
+ if (NS_FAILED (rv)) continue;
+
+ nsCOMPtr<nsIDOMHTMLImageElement> img =
+ do_QueryInterface(aNode, &rv);
+ if (NS_FAILED(rv) || !img) continue;
+
+ nsEmbedString imgMapName;
+ rv = img->GetUseMap (imgMapName);
+ if (NS_FAILED (rv)) continue;
+
+ // usemap always starts with #
+ imgMapName.Cut (0,1);
+
+ // Check if the current image is attached to the map we are looking for
+ if (EphyUtils::StringEquals(imgMapName, mapName))
+ {
+ nsEmbedString imgSrc;
+ rv = img->GetSrc (imgSrc);
+ if (NS_FAILED(rv)) continue;
+
+ info->context |= EPHY_EMBED_CONTEXT_IMAGE;
+
+ SetStringProperty ("image", imgSrc);
+
+ break;
+ }
+ }
+ }
else if (g_ascii_strcasecmp (tag.get(), "input") == 0)
{
CheckInput (node);