1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 /* code for HTML client-side image maps */
14 #include "nsStubMutationObserver.h"
15 #include "nsIDOMEventListener.h"
18 class nsRenderingContext
;
24 class nsImageMap MOZ_FINAL
: public nsStubMutationObserver
,
25 public nsIDOMEventListener
30 nsresult
Init(nsImageFrame
* aImageFrame
, nsIContent
* aMap
);
33 * Return the first area element (in content order) for the given aX,aY pixel
34 * coordinate or nullptr if the coordinate is outside all areas.
36 nsIContent
* GetArea(nscoord aX
, nscoord aY
) const;
39 * Return area elements count associated with the image map.
41 uint32_t AreaCount() const { return mAreas
.Length(); }
44 * Return area element at the given index.
46 nsIContent
* GetAreaAt(uint32_t aIndex
) const;
48 void Draw(nsIFrame
* aFrame
, nsRenderingContext
& aRC
);
51 * Called just before the nsImageFrame releases us.
52 * Used to break the cycle caused by the DOM listener.
59 // nsIMutationObserver
60 NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
61 NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
62 NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
63 NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
64 NS_DECL_NSIMUTATIONOBSERVER_PARENTCHAINCHANGED
67 NS_DECL_NSIDOMEVENTLISTENER
69 nsresult
GetBoundsForAreaContent(nsIContent
*aContent
,
73 virtual ~nsImageMap();
77 nsresult
UpdateAreas();
78 nsresult
SearchForAreas(nsIContent
* aParent
, bool& aFoundArea
,
81 nsresult
AddArea(nsIContent
* aArea
);
83 void MaybeUpdateAreas(nsIContent
*aContent
);
85 nsImageFrame
* mImageFrame
; // the frame that owns us
86 nsCOMPtr
<nsIContent
> mMap
;
87 nsAutoTArray
<Area
*, 8> mAreas
; // almost always has some entries
88 bool mContainsBlockContents
;
91 #endif /* nsImageMap_h */