layout/generic/nsImageMap.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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 : public nsStubMutationObserver,
    25                    public nsIDOMEventListener
    26 {
    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.
    35    */
    36   nsIContent* GetArea(nscoord aX, nscoord aY) const;
    38   /**
    39    * Return area elements count associated with the image map.
    40    */
    41   uint32_t AreaCount() const { return mAreas.Length(); }
    43   /**
    44    * Return area element at the given index.
    45    */
    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.
    53    */
    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;
    89 };
    91 #endif /* nsImageMap_h */

mercurial