2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* code for HTML client-side image maps */
|
|
|
|
|
2011-05-30 04:35:45 -07:00
|
|
|
#ifndef nsImageMap_h
|
|
|
|
#define nsImageMap_h
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-08-22 11:32:52 -07:00
|
|
|
#include "nsCOMPtr.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsCoord.h"
|
2009-02-03 06:42:18 -08:00
|
|
|
#include "nsTArray.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsStubMutationObserver.h"
|
2011-06-28 10:59:14 -07:00
|
|
|
#include "nsIDOMEventListener.h"
|
2013-08-22 11:32:52 -07:00
|
|
|
#include "nsRect.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-02-03 06:42:18 -08:00
|
|
|
class Area;
|
2011-05-30 04:35:45 -07:00
|
|
|
class nsRenderingContext;
|
2011-10-29 03:44:50 -07:00
|
|
|
class nsImageFrame;
|
2013-08-22 11:32:52 -07:00
|
|
|
class nsIFrame;
|
|
|
|
class nsIContent;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-06-28 10:59:14 -07:00
|
|
|
class nsImageMap : public nsStubMutationObserver,
|
|
|
|
public nsIDOMEventListener
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsImageMap();
|
|
|
|
|
2011-10-29 03:44:50 -07:00
|
|
|
nsresult Init(nsImageFrame* aImageFrame, nsIContent* aMap);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
2011-10-30 12:51:19 -07:00
|
|
|
* Return the first area element (in content order) for the given aX,aY pixel
|
2012-07-30 07:20:58 -07:00
|
|
|
* coordinate or nullptr if the coordinate is outside all areas.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2011-10-30 12:51:19 -07:00
|
|
|
nsIContent* GetArea(nscoord aX, nscoord aY) const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-15 13:16:02 -07:00
|
|
|
/**
|
|
|
|
* Return area elements count associated with the image map.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t AreaCount() const { return mAreas.Length(); }
|
2012-03-15 13:16:02 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return area element at the given index.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
nsIContent* GetAreaAt(uint32_t aIndex) const;
|
2012-03-15 13:16:02 -07:00
|
|
|
|
2011-04-07 18:04:40 -07:00
|
|
|
void Draw(nsIFrame* aFrame, nsRenderingContext& aRC);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called just before the nsImageFrame releases us.
|
|
|
|
* Used to break the cycle caused by the DOM listener.
|
|
|
|
*/
|
2011-05-30 04:35:45 -07:00
|
|
|
void Destroy();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
// nsIMutationObserver
|
2007-07-12 13:05:45 -07:00
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
|
2011-10-29 03:44:50 -07:00
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_PARENTCHAINCHANGED
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-06-28 10:59:14 -07:00
|
|
|
//nsIDOMEventListener
|
|
|
|
NS_DECL_NSIDOMEVENTLISTENER
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-04-26 22:51:13 -07:00
|
|
|
nsresult GetBoundsForAreaContent(nsIContent *aContent,
|
|
|
|
nsRect& aBounds);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~nsImageMap();
|
|
|
|
|
|
|
|
void FreeAreas();
|
|
|
|
|
|
|
|
nsresult UpdateAreas();
|
2011-09-28 23:19:26 -07:00
|
|
|
nsresult SearchForAreas(nsIContent* aParent, bool& aFoundArea,
|
|
|
|
bool& aFoundAnchor);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsresult AddArea(nsIContent* aArea);
|
|
|
|
|
|
|
|
void MaybeUpdateAreas(nsIContent *aContent);
|
|
|
|
|
2011-10-29 03:44:50 -07:00
|
|
|
nsImageFrame* mImageFrame; // the frame that owns us
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIContent> mMap;
|
2009-02-03 06:42:18 -08:00
|
|
|
nsAutoTArray<Area*, 8> mAreas; // almost always has some entries
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mContainsBlockContents;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2011-05-30 04:35:45 -07:00
|
|
|
#endif /* nsImageMap_h */
|