From e04165381965cf4e1c92485482979fe6a1645d02 Mon Sep 17 00:00:00 2001 From: "jwatt%jwatt.org" Date: Wed, 23 Mar 2005 01:42:22 +0000 Subject: [PATCH] Fixing bug 281741. We should implement the GetSVGDocument interface for HTMLEmbedElement. r=tor@acm.org, sr=jst@mozilla.org --- .../html/content/src/nsHTMLSharedElement.cpp | 37 ++++++++++++++ dom/public/idl/svg/Makefile.in | 1 + dom/public/idl/svg/nsIDOMGetSVGDocument.idl | 48 +++++++++++++++++++ dom/src/base/nsDOMClassInfo.cpp | 4 ++ 4 files changed, 90 insertions(+) create mode 100755 dom/public/idl/svg/nsIDOMGetSVGDocument.idl diff --git a/content/html/content/src/nsHTMLSharedElement.cpp b/content/html/content/src/nsHTMLSharedElement.cpp index 81383c994071..3658e3809d45 100644 --- a/content/html/content/src/nsHTMLSharedElement.cpp +++ b/content/html/content/src/nsHTMLSharedElement.cpp @@ -52,12 +52,21 @@ #include "nsMappedAttributes.h" #include "nsStyleContext.h" +#ifdef MOZ_SVG +#include "nsIDOMGetSVGDocument.h" +#include "nsIDOMSVGDocument.h" +#include "nsIDocument.h" +#endif + // XXX nav4 has type= start= (same as OL/UL) extern nsAttrValue::EnumTable kListTypeTable[]; class nsHTMLSharedElement : public nsGenericHTMLElement, public nsImageLoadingContent, public nsIDOMHTMLEmbedElement, +#ifdef MOZ_SVG + public nsIDOMGetSVGDocument, +#endif public nsIDOMHTMLIsIndexElement, public nsIDOMHTMLParamElement, public nsIDOMHTMLBaseElement, @@ -85,6 +94,11 @@ public: // nsIDOMHTMLEmbedElement NS_DECL_NSIDOMHTMLEMBEDELEMENT +#ifdef MOZ_SVG + // nsIDOMGetSVGDocument + NS_DECL_NSIDOMGETSVGDOCUMENT +#endif + // nsIDOMHTMLIsIndexElement NS_DECL_NSIDOMHTMLISINDEXELEMENT @@ -150,6 +164,9 @@ NS_HTML_CONTENT_INTERFACE_MAP_AMBIGOUS_BEGIN(nsHTMLSharedElement, nsGenericHTMLElement, nsIDOMHTMLEmbedElement) NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMHTMLEmbedElement, embed) +#ifdef MOZ_SVG + NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMGetSVGDocument, embed) +#endif NS_INTERFACE_MAP_ENTRY_IF_TAG(imgIDecoderObserver, embed) NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIImageLoadingContent, embed) NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMHTMLParamElement, param) @@ -187,6 +204,26 @@ NS_IMPL_STRING_ATTR(nsHTMLSharedElement, Name, name) //NS_IMPL_STRING_ATTR(nsHTMLSharedElement, Type, type) NS_IMPL_STRING_ATTR(nsHTMLSharedElement, Src, src) +#ifdef MOZ_SVG +// nsIDOMGetSVGDocument +NS_IMETHODIMP +nsHTMLSharedElement::GetSVGDocument(nsIDOMSVGDocument** aResult) +{ + NS_ENSURE_ARG_POINTER(aResult); + + *aResult = nsnull; + + if (!mNodeInfo->Equals(nsHTMLAtoms::embed) || !IsInDoc()) + return NS_OK; + + nsIDocument *sub_doc = GetOwnerDoc()->GetSubDocumentFor(this); + if (sub_doc) + CallQueryInterface(sub_doc, aResult); + + return NS_OK; +} +#endif + // nsIDOMHTMLParamElement NS_IMPL_STRING_ATTR(nsHTMLSharedElement, Value, value) NS_IMPL_STRING_ATTR(nsHTMLSharedElement, ValueType, valuetype) diff --git a/dom/public/idl/svg/Makefile.in b/dom/public/idl/svg/Makefile.in index b75c80399b0e..6b362119d9b6 100644 --- a/dom/public/idl/svg/Makefile.in +++ b/dom/public/idl/svg/Makefile.in @@ -49,6 +49,7 @@ XPIDL_MODULE = dom_svg XPIDLSRCS = \ + nsIDOMGetSVGDocument.idl \ nsIDOMSVGAngle.idl \ nsIDOMSVGAnimatedAngle.idl \ nsIDOMSVGAnimatedEnum.idl \ diff --git a/dom/public/idl/svg/nsIDOMGetSVGDocument.idl b/dom/public/idl/svg/nsIDOMGetSVGDocument.idl new file mode 100755 index 000000000000..fbe5448b1e9a --- /dev/null +++ b/dom/public/idl/svg/nsIDOMGetSVGDocument.idl @@ -0,0 +1,48 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla SVG Project code. + * + * The Initial Developer of the Original Code is + * Jonathan Watt. + * Portions created by the Initial Developer are Copyright (C) 2005 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Jonathan Watt (original author) + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "domstubs.idl" + +interface nsIDOMSVGDocument; + +[scriptable, uuid(0401f299-685b-43a1-82b4-ce1a0011598c)] +interface nsIDOMGetSVGDocument : nsISupports +{ + nsIDOMSVGDocument getSVGDocument ( ); + // raises( DOMException ); +}; diff --git a/dom/src/base/nsDOMClassInfo.cpp b/dom/src/base/nsDOMClassInfo.cpp index f0d8dec83ca3..9e2d90ed26a7 100644 --- a/dom/src/base/nsDOMClassInfo.cpp +++ b/dom/src/base/nsDOMClassInfo.cpp @@ -307,6 +307,7 @@ #include "nsIDOMXPathEvaluator.h" #ifdef MOZ_SVG +#include "nsIDOMGetSVGDocument.h" #include "nsIDOMSVGAngle.h" #include "nsIDOMSVGAnimatedAngle.h" #include "nsIDOMSVGAnimatedEnum.h" @@ -1824,6 +1825,9 @@ nsDOMClassInfo::Init() DOM_CLASSINFO_MAP_BEGIN(HTMLEmbedElement, nsIDOMHTMLEmbedElement) DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLEmbedElement) +#ifdef MOZ_SVG + DOM_CLASSINFO_MAP_ENTRY(nsIDOMGetSVGDocument) +#endif DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES DOM_CLASSINFO_MAP_END