1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 /* code for HTML client-side image maps */
40 #ifndef nsImageMap_h___
41 #define nsImageMap_h___
43 #include "nsISupports.h"
46 #include "nsStubMutationObserver.h"
47 #include "nsIDOMFocusListener.h"
49 #include "nsIImageMap.h"
51 class nsIDOMHTMLAreaElement
;
52 class nsIDOMHTMLMapElement
;
53 class nsIRenderingContext
;
59 class nsImageMap
: public nsStubMutationObserver
, public nsIDOMFocusListener
,
65 nsresult
Init(nsIPresShell
* aPresShell
, nsIFrame
* aImageFrame
, nsIDOMHTMLMapElement
* aMap
);
68 * See if the given aX,aY <b>pixel</b> coordinates are in the image
69 * map. If they are then PR_TRUE is returned and aContent points to the
70 * found area. If the coordinates are not in the map then PR_FALSE
73 PRBool
IsInside(nscoord aX
, nscoord aY
,
74 nsIContent
** aContent
) const;
76 void Draw(nsIFrame
* aFrame
, nsIRenderingContext
& aRC
);
79 * Called just before the nsImageFrame releases us.
80 * Used to break the cycle caused by the DOM listener.
87 // nsIMutationObserver
88 NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
89 NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
90 NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
91 NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
94 NS_IMETHOD
Focus(nsIDOMEvent
* aEvent
);
95 NS_IMETHOD
Blur(nsIDOMEvent
* aEvent
);
96 NS_IMETHOD
HandleEvent(nsIDOMEvent
* aEvent
);
99 NS_IMETHOD
GetBoundsForAreaContent(nsIContent
*aContent
,
103 virtual ~nsImageMap();
107 nsresult
UpdateAreas();
108 nsresult
SearchForAreas(nsIContent
* aParent
, PRBool
& aFoundArea
,
109 PRBool
& aFoundAnchor
);
111 nsresult
AddArea(nsIContent
* aArea
);
113 nsresult
ChangeFocus(nsIDOMEvent
* aEvent
, PRBool aFocus
);
115 void MaybeUpdateAreas(nsIContent
*aContent
);
117 nsIPresShell
* mPresShell
; // WEAK - owns the frame that owns us
118 nsIFrame
* mImageFrame
; // the frame that owns us
119 nsCOMPtr
<nsIContent
> mMap
;
120 nsAutoTArray
<Area
*, 8> mAreas
; // almost always has some entries
121 PRBool mContainsBlockContents
;
124 #endif /* nsImageMap_h___ */