Bug 659743 - Part c: Reduce QIing in nsImageMap; r=smaug

This commit is contained in:
Ms2ger 2011-05-30 13:35:45 +02:00
parent e18ad59abc
commit 1bad80a509
3 changed files with 14 additions and 25 deletions

View File

@ -1457,8 +1457,7 @@ nsImageFrame::GetImageMap(nsPresContext* aPresContext)
nsAutoString usemap;
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::usemap, usemap);
nsCOMPtr<nsIDOMHTMLMapElement> map =
do_QueryInterface(doc->FindImageMap(usemap));
nsCOMPtr<nsIContent> map = doc->FindImageMap(usemap);
if (map) {
mImageMap = new nsImageMap();
NS_ADDREF(mImageMap);

View File

@ -39,21 +39,16 @@
/* code for HTML client-side image maps */
#include "nsImageMap.h"
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsRenderingContext.h"
#include "nsPresContext.h"
#include "nsIURL.h"
#include "nsIURL.h"
#include "nsIServiceManager.h"
#include "nsNetUtil.h"
#include "nsTextFragment.h"
#include "mozilla/dom/Element.h"
#include "nsIDOMHTMLElement.h"
#include "nsIDOMHTMLMapElement.h"
#include "nsIDOMHTMLAreaElement.h"
#include "nsIDOMHTMLAnchorElement.h"
#include "nsIDOMHTMLCollection.h"
#include "nsIDocument.h"
#include "nsINameSpaceManager.h"
#include "nsGkAtoms.h"
@ -749,17 +744,16 @@ nsImageMap::FreeAreas()
}
nsresult
nsImageMap::Init(nsIPresShell* aPresShell, nsIFrame* aImageFrame, nsIDOMHTMLMapElement* aMap)
nsImageMap::Init(nsIPresShell* aPresShell, nsIFrame* aImageFrame, nsIContent* aMap)
{
NS_PRECONDITION(nsnull != aMap, "null ptr");
if (nsnull == aMap) {
NS_PRECONDITION(aMap, "null ptr");
if (!aMap) {
return NS_ERROR_NULL_POINTER;
}
mPresShell = aPresShell;
mImageFrame = aImageFrame;
mMap = do_QueryInterface(aMap);
NS_ASSERTION(mMap, "aMap is not an nsIContent!");
mMap = aMap;
mMap->AddMutationObserver(this);
// "Compile" the areas in the map into faster access versions

View File

@ -37,8 +37,8 @@
/* code for HTML client-side image maps */
#ifndef nsImageMap_h___
#define nsImageMap_h___
#ifndef nsImageMap_h
#define nsImageMap_h
#include "nsISupports.h"
#include "nsCoord.h"
@ -47,20 +47,16 @@
#include "nsIDOMFocusListener.h"
#include "nsIFrame.h"
class nsIDOMHTMLAreaElement;
class nsIDOMHTMLMapElement;
class nsRenderingContext;
class nsIURI;
class nsString;
class nsIDOMEvent;
class Area;
class nsIDOMEvent;
class nsRenderingContext;
class nsImageMap : public nsStubMutationObserver, public nsIDOMFocusListener
{
public:
nsImageMap();
nsresult Init(nsIPresShell* aPresShell, nsIFrame* aImageFrame, nsIDOMHTMLMapElement* aMap);
nsresult Init(nsIPresShell* aPresShell, nsIFrame* aImageFrame, nsIContent* aMap);
/**
* See if the given aX,aY <b>pixel</b> coordinates are in the image
@ -77,7 +73,7 @@ public:
* Called just before the nsImageFrame releases us.
* Used to break the cycle caused by the DOM listener.
*/
void Destroy(void);
void Destroy();
// nsISupports
NS_DECL_ISUPPORTS
@ -103,7 +99,7 @@ protected:
nsresult UpdateAreas();
nsresult SearchForAreas(nsIContent* aParent, PRBool& aFoundArea,
PRBool& aFoundAnchor);
PRBool& aFoundAnchor);
nsresult AddArea(nsIContent* aArea);
@ -118,4 +114,4 @@ protected:
PRBool mContainsBlockContents;
};
#endif /* nsImageMap_h___ */
#endif /* nsImageMap_h */