2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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/. */
|
2006-03-29 18:29:03 +00:00
|
|
|
|
|
|
|
/* code for HTML client-side image maps */
|
|
|
|
|
2011-05-30 11:35:45 +00:00
|
|
|
#ifndef nsImageMap_h
|
|
|
|
#define nsImageMap_h
|
1999-01-09 00:18:08 +00:00
|
|
|
|
2014-10-16 09:51:14 +00:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2013-08-22 18:32:52 +00:00
|
|
|
#include "nsCOMPtr.h"
|
1999-01-09 00:18:08 +00:00
|
|
|
#include "nsCoord.h"
|
2009-02-03 14:42:18 +00:00
|
|
|
#include "nsTArray.h"
|
2006-07-02 07:23:10 +00:00
|
|
|
#include "nsStubMutationObserver.h"
|
2011-06-28 17:59:14 +00:00
|
|
|
#include "nsIDOMEventListener.h"
|
1999-01-09 00:18:08 +00:00
|
|
|
|
2009-02-03 14:42:18 +00:00
|
|
|
class Area;
|
2011-10-29 10:44:50 +00:00
|
|
|
class nsImageFrame;
|
2013-08-22 18:32:52 +00:00
|
|
|
class nsIFrame;
|
|
|
|
class nsIContent;
|
2013-09-07 02:15:49 +00:00
|
|
|
struct nsRect;
|
1999-01-09 00:18:08 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class nsImageMap final : public nsStubMutationObserver,
|
2015-03-27 18:52:19 +00:00
|
|
|
public nsIDOMEventListener
|
1999-01-09 00:18:08 +00:00
|
|
|
{
|
2014-10-16 09:51:14 +00:00
|
|
|
typedef mozilla::gfx::DrawTarget DrawTarget;
|
|
|
|
typedef mozilla::gfx::ColorPattern ColorPattern;
|
|
|
|
typedef mozilla::gfx::StrokeOptions StrokeOptions;
|
|
|
|
|
1999-01-09 00:18:08 +00:00
|
|
|
public:
|
|
|
|
nsImageMap();
|
|
|
|
|
2011-10-29 10:44:50 +00:00
|
|
|
nsresult Init(nsImageFrame* aImageFrame, nsIContent* aMap);
|
1999-01-09 00:18:08 +00:00
|
|
|
|
|
|
|
/**
|
2011-10-30 19:51:19 +00:00
|
|
|
* Return the first area element (in content order) for the given aX,aY pixel
|
2012-07-30 14:20:58 +00:00
|
|
|
* coordinate or nullptr if the coordinate is outside all areas.
|
1999-01-09 00:18:08 +00:00
|
|
|
*/
|
2011-10-30 19:51:19 +00:00
|
|
|
nsIContent* GetArea(nscoord aX, nscoord aY) const;
|
1999-01-09 00:18:08 +00:00
|
|
|
|
2012-03-15 20:16:02 +00:00
|
|
|
/**
|
|
|
|
* Return area elements count associated with the image map.
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t AreaCount() const { return mAreas.Length(); }
|
2012-03-15 20:16:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return area element at the given index.
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
nsIContent* GetAreaAt(uint32_t aIndex) const;
|
2012-03-15 20:16:02 +00:00
|
|
|
|
2014-10-16 09:51:14 +00:00
|
|
|
void Draw(nsIFrame* aFrame, DrawTarget& aDrawTarget,
|
|
|
|
const ColorPattern& aColor,
|
|
|
|
const StrokeOptions& aStrokeOptions = StrokeOptions());
|
2000-08-12 00:38:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called just before the nsImageFrame releases us.
|
|
|
|
* Used to break the cycle caused by the DOM listener.
|
|
|
|
*/
|
2011-05-30 11:35:45 +00:00
|
|
|
void Destroy();
|
2000-08-12 00:38:22 +00:00
|
|
|
|
1999-01-09 00:18:08 +00:00
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2006-07-02 07:23:10 +00:00
|
|
|
// nsIMutationObserver
|
2007-07-12 20:05:45 +00:00
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
|
2011-10-29 10:44:50 +00:00
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_PARENTCHAINCHANGED
|
1999-01-09 00:18:08 +00:00
|
|
|
|
2011-06-28 17:59:14 +00:00
|
|
|
//nsIDOMEventListener
|
|
|
|
NS_DECL_NSIDOMEVENTLISTENER
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-08 21:31:05 +00:00
|
|
|
|
2011-04-27 05:51:13 +00:00
|
|
|
nsresult GetBoundsForAreaContent(nsIContent *aContent,
|
|
|
|
nsRect& aBounds);
|
2002-08-17 01:46:58 +00:00
|
|
|
|
1999-01-09 00:18:08 +00:00
|
|
|
protected:
|
1999-02-12 17:45:58 +00:00
|
|
|
virtual ~nsImageMap();
|
1999-01-09 00:18:08 +00:00
|
|
|
|
|
|
|
void FreeAreas();
|
|
|
|
|
|
|
|
nsresult UpdateAreas();
|
2011-09-29 06:19:26 +00:00
|
|
|
nsresult SearchForAreas(nsIContent* aParent, bool& aFoundArea,
|
|
|
|
bool& aFoundAnchor);
|
1999-01-09 00:18:08 +00:00
|
|
|
|
1999-03-01 16:57:35 +00:00
|
|
|
nsresult AddArea(nsIContent* aArea);
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-08 21:31:05 +00:00
|
|
|
|
2004-01-24 00:46:17 +00:00
|
|
|
void MaybeUpdateAreas(nsIContent *aContent);
|
|
|
|
|
2011-10-29 10:44:50 +00:00
|
|
|
nsImageFrame* mImageFrame; // the frame that owns us
|
2005-01-12 19:45:38 +00:00
|
|
|
nsCOMPtr<nsIContent> mMap;
|
2009-02-03 14:42:18 +00:00
|
|
|
nsAutoTArray<Area*, 8> mAreas; // almost always has some entries
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mContainsBlockContents;
|
1999-01-09 00:18:08 +00:00
|
|
|
};
|
|
|
|
|
2011-05-30 11:35:45 +00:00
|
|
|
#endif /* nsImageMap_h */
|