Bug 581644 - Make nsHTMLDocument::GetImageMap return dom::Element; r=peterv

This commit is contained in:
Ms2ger 2011-03-28 12:51:59 -04:00
Родитель 3c41948d77
Коммит 415741f594
5 изменённых файлов: 33 добавлений и 43 удалений

Просмотреть файл

@ -100,6 +100,7 @@
#endif
#include "mozilla/FunctionTimer.h"
#include "mozilla/dom/Element.h"
////////////////////////////////////////////////////////////////////////////////
// nsAccessibilityService
@ -275,7 +276,7 @@ nsAccessibilityService::CreateHTMLImageAccessible(nsIContent* aContent,
if (!mapElmName.IsEmpty()) {
if (mapElmName.CharAt(0) == '#')
mapElmName.Cut(0,1);
mapElm = htmlDoc->GetImageMap(mapElmName);
mapElm = do_QueryInterface(htmlDoc->GetImageMap(mapElmName));
}
}

Просмотреть файл

@ -39,11 +39,13 @@
#include "nsReadableUtils.h"
#include "nsCOMPtr.h"
#include "nsIDocument.h"
#include "nsIContent.h"
#include "mozilla/dom/Element.h"
#include "nsIHTMLDocument.h"
#include "nsIDOMHTMLMapElement.h"
#include "nsImageMapUtils.h"
using namespace mozilla::dom;
/*static*/
already_AddRefed<nsIDOMHTMLMapElement>
nsImageMapUtils::FindImageMap(nsIDocument *aDocument,
@ -79,9 +81,9 @@ nsImageMapUtils::FindImageMap(nsIDocument *aDocument,
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(aDocument));
if (htmlDoc) {
nsIDOMHTMLMapElement* map = htmlDoc->GetImageMap(usemap);
NS_IF_ADDREF(map);
return map;
nsCOMPtr<nsIDOMHTMLMapElement> map =
do_QueryInterface(htmlDoc->GetImageMap(usemap));
return map.forget();
} else {
// For XHTML elements embedded in non-XHTML documents we get the
// map by id since XHTML requires that where a "name" attribute
@ -89,7 +91,7 @@ nsImageMapUtils::FindImageMap(nsIDocument *aDocument,
// XHTML. The attribute "name" is officially deprecated. This
// simplifies our life becase we can simply get the map with
// getElementById().
nsIContent *element = aDocument->GetElementById(usemap);
Element* element = aDocument->GetElementById(usemap);
if (element) {
nsIDOMHTMLMapElement* map;

Просмотреть файл

@ -1158,7 +1158,7 @@ nsHTMLDocument::SetTitle(const nsAString& aTitle)
return nsDocument::SetTitle(aTitle);
}
nsIDOMHTMLMapElement *
Element*
nsHTMLDocument::GetImageMap(const nsAString& aMapName)
{
if (!mImageMaps) {
@ -1168,25 +1168,12 @@ nsHTMLDocument::GetImageMap(const nsAString& aMapName)
nsAutoString name;
PRUint32 i, n = mImageMaps->Length(PR_TRUE);
for (i = 0; i < n; ++i) {
nsCOMPtr<nsIDOMHTMLMapElement> map(
do_QueryInterface(mImageMaps->GetNodeAt(i)));
PRBool match;
nsresult rv;
rv = map->GetId(name);
NS_ENSURE_SUCCESS(rv, nsnull);
match = name.Equals(aMapName);
if (!match) {
rv = map->GetName(name);
NS_ENSURE_SUCCESS(rv, nsnull);
match = name.Equals(aMapName, nsCaseInsensitiveStringComparator());
}
if (match) {
return map;
nsIContent* map = mImageMaps->GetNodeAt(i);
if (map->AttrValueIs(kNameSpaceID_None, nsGkAtoms::id, aMapName,
eCaseMatters) ||
map->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name, aMapName,
eIgnoreCase)) {
return map->AsElement();
}
}

Просмотреть файл

@ -43,7 +43,6 @@
#include "nsIDOMHTMLDocument.h"
#include "nsIDOMNSHTMLDocument.h"
#include "nsIDOMHTMLBodyElement.h"
#include "nsIDOMHTMLMapElement.h"
#include "nsIDOMHTMLCollection.h"
#include "nsIScriptElement.h"
#include "jsapi.h"
@ -106,7 +105,7 @@ public:
virtual void EndLoad();
virtual nsIDOMHTMLMapElement *GetImageMap(const nsAString& aMapName);
virtual mozilla::dom::Element* GetImageMap(const nsAString& aMapName);
virtual void SetCompatibilityMode(nsCompatibility aMode);

Просмотреть файл

@ -34,28 +34,29 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsIHTMLDocument_h___
#define nsIHTMLDocument_h___
#ifndef nsIHTMLDocument_h
#define nsIHTMLDocument_h
#include "nsISupports.h"
#include "nsCompatibility.h"
#include "nsContentList.h"
class nsIImageMap;
class nsString;
class nsIDOMNodeList;
class nsIDOMHTMLCollection;
class nsIDOMHTMLMapElement;
class nsHTMLStyleSheet;
class nsIStyleSheet;
class nsIDOMHTMLFormElement;
class nsIContent;
class nsIDOMHTMLBodyElement;
class nsIScriptElement;
class nsIEditor;
class nsContentList;
class nsWrapperCache;
namespace mozilla {
namespace dom {
class Element;
} // namespace dom
} // namespace mozilla
#define NS_IHTMLDOCUMENT_IID \
{ 0x840cacc9, 0x1956, 0x4987, \
{ 0x80, 0x6e, 0xc6, 0xab, 0x19, 0x1b, 0x92, 0xd2 } }
{ 0xe43a4bfd, 0xff5a, 0x40b0, \
{ 0x8c, 0x31, 0x24, 0xac, 0xe8, 0x15, 0xda, 0xf2 } }
/**
@ -66,7 +67,7 @@ class nsIHTMLDocument : public nsISupports
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IHTMLDOCUMENT_IID)
virtual nsIDOMHTMLMapElement *GetImageMap(const nsAString& aMapName) = 0;
virtual mozilla::dom::Element* GetImageMap(const nsAString& aMapName) = 0;
/**
* Set compatibility mode for this document
@ -189,4 +190,4 @@ public:
NS_DEFINE_STATIC_IID_ACCESSOR(nsIHTMLDocument, NS_IHTMLDOCUMENT_IID)
#endif /* nsIHTMLDocument_h___ */
#endif /* nsIHTMLDocument_h */