!import
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1 //@line 42 "/home/visbrero/mnt/roisin/rev_control/hg/mozilla/mail/base/content/contentAreaClick.js"
2
3 /**
4 * Extract the href from the link click event.
5 * We look for HTMLAnchorElement, HTMLAreaElement, HTMLLinkElement,
6 * HTMLInputElement.form.action, and nested anchor tags.
7 *
8 * @return href for the url being clicked
9 */
hRefForClickEvent
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
10 function hRefForClickEvent(aEvent)
11 {
12 var target = aEvent.target;
13 var href;
14 var isKeyPress = (aEvent.type == "keypress");
15
16 if (target instanceof HTMLAnchorElement ||
17 target instanceof HTMLAreaElement ||
18 target instanceof HTMLLinkElement)
19 {
20 if (target.hasAttribute("href"))
21 href = target.href;
22 }
23 else if (target instanceof HTMLInputElement)
24 {
25 if (target.form && target.form.action)
26 href = target.form.action;
27 }
28 else
29 {
30 // we may be nested inside of a link node
31 var linkNode = aEvent.originalTarget;
32 while (linkNode && !(linkNode instanceof HTMLAnchorElement))
33 linkNode = linkNode.parentNode;
34
35 if (linkNode)
36 href = linkNode.href;
37 }
38
39 return href;
40 }
41
messagePaneOnResize
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
42 function messagePaneOnResize(aEvent)
43 {
44 // scale any overflowing images
45 var messagepane = document.getElementById("messagepane");
46 var doc = messagepane.contentDocument;
47 var imgs = doc.images;
48 for each (var img in imgs)
49 {
50 if (img.className == "moz-attached-image")
51 {
52 if (img.naturalWidth <= doc.width)
53 {
54 img.removeAttribute("isshrunk");
55 img.removeAttribute("overflowing");
56 }
57 else if (img.hasAttribute("shrinktofit"))
58 {
59 img.setAttribute("isshrunk", "true");
60 img.removeAttribute("overflowing");
61 }
62 else
63 {
64 img.setAttribute("overflowing", "true");
65 img.removeAttribute("isshrunk");
66 }
67 }
68 }
69 }
70
71 // Called whenever the user clicks in the content area,
72 // should always return true for click to go through
contentAreaClick
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
73 function contentAreaClick(aEvent)
74 {
75 var href = hRefForClickEvent(aEvent);
76 if (href && !aEvent.button) // left click on link only
77 {
78 // let the phishing detector check the link
79 return gPhishingDetector.warnOnSuspiciousLinkClick(href);
80 }
81 if (!aEvent.button)
82 {
83 var target = aEvent.target;
84 // is this an image that we might want to scale?
85 const Ci = Components.interfaces;
86 if (target instanceof Ci.nsIImageLoadingContent)
87 {
88 // make sure it loaded successfully
89 var req = target.getRequest(Ci.nsIImageLoadingContent.CURRENT_REQUEST);
90 if (!req || req.imageStatus & Ci.imgIRequest.STATUS_ERROR)
91 return true;
92 // is it an inline attachment?
93 if (/^moz-attached-image/.test(target.className))
94 {
95 if (target.hasAttribute("isshrunk"))
96 {
97 // currently shrunk to fit, so unshrink it
98 target.removeAttribute("isshrunk");
99 target.removeAttribute("shrinktofit");
100 target.setAttribute("overflowing", "true");
101 }
102 else if (target.hasAttribute("overflowing"))
103 {
104 // user wants to shrink now
105 target.setAttribute("isshrunk", "true");
106 target.setAttribute("shrinktofit", "true");
107 target.removeAttribute("overflowing");
108 }
109 }
110 }
111 }
112
113 return true;
114 }