Bumping manifests a=b2g-bump
[gecko.git] / layout / generic / nsImageMap.h
blob239ffbbbd0e383b1e04a380798d063e7a6d56676
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 */
8 #ifndef nsImageMap_h
9 #define nsImageMap_h
11 #include "nsCOMPtr.h"
12 #include "nsCoord.h"
13 #include "nsTArray.h"
14 #include "nsStubMutationObserver.h"
15 #include "nsIDOMEventListener.h"
17 class Area;
18 class nsRenderingContext;
19 class nsImageFrame;
20 class nsIFrame;
21 class nsIContent;
22 struct nsRect;
24 class nsImageMap MOZ_FINAL : public nsStubMutationObserver,
25 public nsIDOMEventListener
27 public:
28 nsImageMap();
30 nsresult Init(nsImageFrame* aImageFrame, nsIContent* aMap);
32 /**
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;
38 /**
39 * Return area elements count associated with the image map.
41 uint32_t AreaCount() const { return mAreas.Length(); }
43 /**
44 * Return area element at the given index.
46 nsIContent* GetAreaAt(uint32_t aIndex) const;
48 void Draw(nsIFrame* aFrame, nsRenderingContext& aRC);
50 /**
51 * Called just before the nsImageFrame releases us.
52 * Used to break the cycle caused by the DOM listener.
54 void Destroy();
56 // nsISupports
57 NS_DECL_ISUPPORTS
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
66 //nsIDOMEventListener
67 NS_DECL_NSIDOMEVENTLISTENER
69 nsresult GetBoundsForAreaContent(nsIContent *aContent,
70 nsRect& aBounds);
72 protected:
73 virtual ~nsImageMap();
75 void FreeAreas();
77 nsresult UpdateAreas();
78 nsresult SearchForAreas(nsIContent* aParent, bool& aFoundArea,
79 bool& aFoundAnchor);
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 */