зеркало из https://github.com/mozilla/gecko-dev.git
Bug 581644 - Make nsHTMLDocument::GetImageMap return dom::Element; r=peterv
This commit is contained in:
Родитель
3c41948d77
Коммит
415741f594
|
@ -100,6 +100,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "mozilla/FunctionTimer.h"
|
#include "mozilla/FunctionTimer.h"
|
||||||
|
#include "mozilla/dom/Element.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// nsAccessibilityService
|
// nsAccessibilityService
|
||||||
|
@ -275,7 +276,7 @@ nsAccessibilityService::CreateHTMLImageAccessible(nsIContent* aContent,
|
||||||
if (!mapElmName.IsEmpty()) {
|
if (!mapElmName.IsEmpty()) {
|
||||||
if (mapElmName.CharAt(0) == '#')
|
if (mapElmName.CharAt(0) == '#')
|
||||||
mapElmName.Cut(0,1);
|
mapElmName.Cut(0,1);
|
||||||
mapElm = htmlDoc->GetImageMap(mapElmName);
|
mapElm = do_QueryInterface(htmlDoc->GetImageMap(mapElmName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,11 +39,13 @@
|
||||||
#include "nsReadableUtils.h"
|
#include "nsReadableUtils.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsIDocument.h"
|
#include "nsIDocument.h"
|
||||||
#include "nsIContent.h"
|
#include "mozilla/dom/Element.h"
|
||||||
#include "nsIHTMLDocument.h"
|
#include "nsIHTMLDocument.h"
|
||||||
#include "nsIDOMHTMLMapElement.h"
|
#include "nsIDOMHTMLMapElement.h"
|
||||||
#include "nsImageMapUtils.h"
|
#include "nsImageMapUtils.h"
|
||||||
|
|
||||||
|
using namespace mozilla::dom;
|
||||||
|
|
||||||
/*static*/
|
/*static*/
|
||||||
already_AddRefed<nsIDOMHTMLMapElement>
|
already_AddRefed<nsIDOMHTMLMapElement>
|
||||||
nsImageMapUtils::FindImageMap(nsIDocument *aDocument,
|
nsImageMapUtils::FindImageMap(nsIDocument *aDocument,
|
||||||
|
@ -79,9 +81,9 @@ nsImageMapUtils::FindImageMap(nsIDocument *aDocument,
|
||||||
|
|
||||||
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(aDocument));
|
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(aDocument));
|
||||||
if (htmlDoc) {
|
if (htmlDoc) {
|
||||||
nsIDOMHTMLMapElement* map = htmlDoc->GetImageMap(usemap);
|
nsCOMPtr<nsIDOMHTMLMapElement> map =
|
||||||
NS_IF_ADDREF(map);
|
do_QueryInterface(htmlDoc->GetImageMap(usemap));
|
||||||
return map;
|
return map.forget();
|
||||||
} else {
|
} else {
|
||||||
// For XHTML elements embedded in non-XHTML documents we get the
|
// For XHTML elements embedded in non-XHTML documents we get the
|
||||||
// map by id since XHTML requires that where a "name" attribute
|
// 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
|
// XHTML. The attribute "name" is officially deprecated. This
|
||||||
// simplifies our life becase we can simply get the map with
|
// simplifies our life becase we can simply get the map with
|
||||||
// getElementById().
|
// getElementById().
|
||||||
nsIContent *element = aDocument->GetElementById(usemap);
|
Element* element = aDocument->GetElementById(usemap);
|
||||||
|
|
||||||
if (element) {
|
if (element) {
|
||||||
nsIDOMHTMLMapElement* map;
|
nsIDOMHTMLMapElement* map;
|
||||||
|
|
|
@ -1158,7 +1158,7 @@ nsHTMLDocument::SetTitle(const nsAString& aTitle)
|
||||||
return nsDocument::SetTitle(aTitle);
|
return nsDocument::SetTitle(aTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIDOMHTMLMapElement *
|
Element*
|
||||||
nsHTMLDocument::GetImageMap(const nsAString& aMapName)
|
nsHTMLDocument::GetImageMap(const nsAString& aMapName)
|
||||||
{
|
{
|
||||||
if (!mImageMaps) {
|
if (!mImageMaps) {
|
||||||
|
@ -1168,25 +1168,12 @@ nsHTMLDocument::GetImageMap(const nsAString& aMapName)
|
||||||
nsAutoString name;
|
nsAutoString name;
|
||||||
PRUint32 i, n = mImageMaps->Length(PR_TRUE);
|
PRUint32 i, n = mImageMaps->Length(PR_TRUE);
|
||||||
for (i = 0; i < n; ++i) {
|
for (i = 0; i < n; ++i) {
|
||||||
nsCOMPtr<nsIDOMHTMLMapElement> map(
|
nsIContent* map = mImageMaps->GetNodeAt(i);
|
||||||
do_QueryInterface(mImageMaps->GetNodeAt(i)));
|
if (map->AttrValueIs(kNameSpaceID_None, nsGkAtoms::id, aMapName,
|
||||||
|
eCaseMatters) ||
|
||||||
PRBool match;
|
map->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name, aMapName,
|
||||||
nsresult rv;
|
eIgnoreCase)) {
|
||||||
|
return map->AsElement();
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,6 @@
|
||||||
#include "nsIDOMHTMLDocument.h"
|
#include "nsIDOMHTMLDocument.h"
|
||||||
#include "nsIDOMNSHTMLDocument.h"
|
#include "nsIDOMNSHTMLDocument.h"
|
||||||
#include "nsIDOMHTMLBodyElement.h"
|
#include "nsIDOMHTMLBodyElement.h"
|
||||||
#include "nsIDOMHTMLMapElement.h"
|
|
||||||
#include "nsIDOMHTMLCollection.h"
|
#include "nsIDOMHTMLCollection.h"
|
||||||
#include "nsIScriptElement.h"
|
#include "nsIScriptElement.h"
|
||||||
#include "jsapi.h"
|
#include "jsapi.h"
|
||||||
|
@ -106,7 +105,7 @@ public:
|
||||||
|
|
||||||
virtual void EndLoad();
|
virtual void EndLoad();
|
||||||
|
|
||||||
virtual nsIDOMHTMLMapElement *GetImageMap(const nsAString& aMapName);
|
virtual mozilla::dom::Element* GetImageMap(const nsAString& aMapName);
|
||||||
|
|
||||||
virtual void SetCompatibilityMode(nsCompatibility aMode);
|
virtual void SetCompatibilityMode(nsCompatibility aMode);
|
||||||
|
|
||||||
|
|
|
@ -34,28 +34,29 @@
|
||||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
#ifndef nsIHTMLDocument_h___
|
|
||||||
#define nsIHTMLDocument_h___
|
#ifndef nsIHTMLDocument_h
|
||||||
|
#define nsIHTMLDocument_h
|
||||||
|
|
||||||
#include "nsISupports.h"
|
#include "nsISupports.h"
|
||||||
#include "nsCompatibility.h"
|
#include "nsCompatibility.h"
|
||||||
#include "nsContentList.h"
|
|
||||||
|
|
||||||
class nsIImageMap;
|
class nsIDOMHTMLFormElement;
|
||||||
class nsString;
|
|
||||||
class nsIDOMNodeList;
|
|
||||||
class nsIDOMHTMLCollection;
|
|
||||||
class nsIDOMHTMLMapElement;
|
|
||||||
class nsHTMLStyleSheet;
|
|
||||||
class nsIStyleSheet;
|
|
||||||
class nsIContent;
|
class nsIContent;
|
||||||
class nsIDOMHTMLBodyElement;
|
|
||||||
class nsIScriptElement;
|
class nsIScriptElement;
|
||||||
class nsIEditor;
|
class nsIEditor;
|
||||||
|
class nsContentList;
|
||||||
|
class nsWrapperCache;
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
namespace dom {
|
||||||
|
class Element;
|
||||||
|
} // namespace dom
|
||||||
|
} // namespace mozilla
|
||||||
|
|
||||||
#define NS_IHTMLDOCUMENT_IID \
|
#define NS_IHTMLDOCUMENT_IID \
|
||||||
{ 0x840cacc9, 0x1956, 0x4987, \
|
{ 0xe43a4bfd, 0xff5a, 0x40b0, \
|
||||||
{ 0x80, 0x6e, 0xc6, 0xab, 0x19, 0x1b, 0x92, 0xd2 } }
|
{ 0x8c, 0x31, 0x24, 0xac, 0xe8, 0x15, 0xda, 0xf2 } }
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -66,7 +67,7 @@ class nsIHTMLDocument : public nsISupports
|
||||||
public:
|
public:
|
||||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IHTMLDOCUMENT_IID)
|
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
|
* Set compatibility mode for this document
|
||||||
|
@ -189,4 +190,4 @@ public:
|
||||||
|
|
||||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIHTMLDocument, NS_IHTMLDOCUMENT_IID)
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsIHTMLDocument, NS_IHTMLDOCUMENT_IID)
|
||||||
|
|
||||||
#endif /* nsIHTMLDocument_h___ */
|
#endif /* nsIHTMLDocument_h */
|
||||||
|
|
Загрузка…
Ссылка в новой задаче