2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04: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 22:29:03 +04:00
|
|
|
|
|
|
|
/* code for HTML client-side image maps */
|
|
|
|
|
2011-05-30 15:35:45 +04:00
|
|
|
#ifndef nsImageMap_h
|
|
|
|
#define nsImageMap_h
|
1999-01-09 03:18:08 +03:00
|
|
|
|
2014-10-16 13:51:14 +04:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2013-08-22 22:32:52 +04:00
|
|
|
#include "nsCOMPtr.h"
|
1999-01-09 03:18:08 +03:00
|
|
|
#include "nsCoord.h"
|
2009-02-03 17:42:18 +03:00
|
|
|
#include "nsTArray.h"
|
2006-07-02 11:23:10 +04:00
|
|
|
#include "nsStubMutationObserver.h"
|
2011-06-28 21:59:14 +04:00
|
|
|
#include "nsIDOMEventListener.h"
|
1999-01-09 03:18:08 +03:00
|
|
|
|
2009-02-03 17:42:18 +03:00
|
|
|
class Area;
|
2011-10-29 14:44:50 +04:00
|
|
|
class nsImageFrame;
|
2013-08-22 22:32:52 +04:00
|
|
|
class nsIFrame;
|
|
|
|
class nsIContent;
|
2013-09-07 06:15:49 +04:00
|
|
|
struct nsRect;
|
1999-01-09 03:18:08 +03:00
|
|
|
|
2017-11-08 18:28:44 +03:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class HTMLAreaElement;
|
|
|
|
}
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsImageMap final : public nsStubMutationObserver,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsIDOMEventListener {
|
2014-10-16 13:51:14 +04:00
|
|
|
typedef mozilla::gfx::DrawTarget DrawTarget;
|
|
|
|
typedef mozilla::gfx::ColorPattern ColorPattern;
|
|
|
|
typedef mozilla::gfx::StrokeOptions StrokeOptions;
|
|
|
|
|
1999-01-09 03:18:08 +03:00
|
|
|
public:
|
|
|
|
nsImageMap();
|
|
|
|
|
2017-07-03 21:35:14 +03:00
|
|
|
void Init(nsImageFrame* aImageFrame, nsIContent* aMap);
|
1999-01-09 03:18:08 +03:00
|
|
|
|
|
|
|
/**
|
2011-10-30 23:51:19 +04:00
|
|
|
* Return the first area element (in content order) for the given aX,aY pixel
|
2012-07-30 18:20:58 +04:00
|
|
|
* coordinate or nullptr if the coordinate is outside all areas.
|
1999-01-09 03:18:08 +03:00
|
|
|
*/
|
2011-10-30 23:51:19 +04:00
|
|
|
nsIContent* GetArea(nscoord aX, nscoord aY) const;
|
1999-01-09 03:18:08 +03:00
|
|
|
|
2012-03-16 00:16:02 +04:00
|
|
|
/**
|
|
|
|
* Return area elements count associated with the image map.
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t AreaCount() const { return mAreas.Length(); }
|
2012-03-16 00:16:02 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return area element at the given index.
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
nsIContent* GetAreaAt(uint32_t aIndex) const;
|
2012-03-16 00:16:02 +04:00
|
|
|
|
2014-10-16 13:51:14 +04:00
|
|
|
void Draw(nsIFrame* aFrame, DrawTarget& aDrawTarget,
|
|
|
|
const ColorPattern& aColor,
|
|
|
|
const StrokeOptions& aStrokeOptions = StrokeOptions());
|
2017-07-06 15:00:35 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called just before the nsImageFrame releases us.
|
2000-08-12 04:38:22 +04:00
|
|
|
* Used to break the cycle caused by the DOM listener.
|
|
|
|
*/
|
2011-05-30 15:35:45 +04:00
|
|
|
void Destroy();
|
2017-07-06 15:00:35 +03:00
|
|
|
|
1999-01-09 03:18:08 +03:00
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2006-07-02 11:23:10 +04:00
|
|
|
// nsIMutationObserver
|
2007-07-13 00:05:45 +04:00
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
|
2017-07-06 15:00:35 +03:00
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_PARENTCHAINCHANGED
|
1999-01-09 03:18:08 +03:00
|
|
|
|
2011-06-28 21:59:14 +04: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-09 01:31:05 +04:00
|
|
|
|
2011-04-27 09:51:13 +04:00
|
|
|
nsresult GetBoundsForAreaContent(nsIContent* aContent, nsRect& aBounds);
|
2002-08-17 05:46:58 +04:00
|
|
|
|
2017-12-15 19:46:04 +03:00
|
|
|
using AreaList = AutoTArray<mozilla::UniquePtr<Area>, 8>;
|
|
|
|
|
1999-01-09 03:18:08 +03:00
|
|
|
protected:
|
1999-02-12 20:45:58 +03:00
|
|
|
virtual ~nsImageMap();
|
1999-01-09 03:18:08 +03:00
|
|
|
|
|
|
|
void FreeAreas();
|
|
|
|
|
2017-07-03 21:35:14 +03:00
|
|
|
void UpdateAreas();
|
1999-01-09 03:18:08 +03:00
|
|
|
|
2017-11-08 18:28:44 +03:00
|
|
|
void SearchForAreas(nsIContent* aParent);
|
|
|
|
|
|
|
|
void AddArea(mozilla::dom::HTMLAreaElement* aArea);
|
2017-12-15 19:46:04 +03:00
|
|
|
void AreaRemoved(mozilla::dom::HTMLAreaElement* aArea);
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2004-01-24 03:46:17 +03:00
|
|
|
void MaybeUpdateAreas(nsIContent* aContent);
|
|
|
|
|
2011-10-29 14:44:50 +04:00
|
|
|
nsImageFrame* mImageFrame; // the frame that owns us
|
2005-01-12 22:45:38 +03:00
|
|
|
nsCOMPtr<nsIContent> mMap;
|
2017-12-15 19:46:04 +03:00
|
|
|
|
|
|
|
// almost always has some entries
|
|
|
|
AreaList mAreas;
|
2017-11-08 18:02:05 +03:00
|
|
|
|
|
|
|
// This is set when we search for all area children and tells us whether we
|
|
|
|
// should consider the whole subtree or just direct children when we get
|
|
|
|
// content notifications about changes inside the map subtree.
|
|
|
|
bool mConsiderWholeSubtree;
|
1999-01-09 03:18:08 +03:00
|
|
|
};
|
|
|
|
|
2011-05-30 15:35:45 +04:00
|
|
|
#endif /* nsImageMap_h */
|