From e05d740183059e04eb1a12f8b40815a572949261 Mon Sep 17 00:00:00 2001 From: "av%netscape.com" Date: Wed, 5 Jan 2000 01:18:38 +0000 Subject: [PATCH] Bug 22598. r=vidur git-svn-id: svn://10.0.0.236/trunk@56781 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/generic/nsObjectFrame.cpp | 25 +++++++++++++++++++ .../layout/html/base/src/nsObjectFrame.cpp | 25 +++++++++++++++++++ .../plugin/base/public/nsIPluginTagInfo.h | 14 +++++++++++ .../plugin/base/src/nsPluginInstancePeer.cpp | 22 ++++++++++++++++ .../plugin/base/src/nsPluginInstancePeer.h | 3 +++ .../plugin/nglsrc/nsPluginInstancePeer.cpp | 22 ++++++++++++++++ .../plugin/nglsrc/nsPluginInstancePeer.h | 3 +++ .../modules/plugin/public/nsIPluginTagInfo.h | 14 +++++++++++ 8 files changed, 128 insertions(+) diff --git a/mozilla/layout/generic/nsObjectFrame.cpp b/mozilla/layout/generic/nsObjectFrame.cpp index d9ac0f7117d..2cfa35c3bda 100644 --- a/mozilla/layout/generic/nsObjectFrame.cpp +++ b/mozilla/layout/generic/nsObjectFrame.cpp @@ -51,6 +51,7 @@ #include "nsITimerCallback.h" #include "nsLayoutAtoms.h" #include "nsIDocShellTreeItem.h" +#include "nsIDOMElement.h" // XXX For temporary paint code #include "nsIStyleContext.h" @@ -97,6 +98,8 @@ public: NS_IMETHOD GetAttribute(const char* name, const char* *result); + NS_IMETHOD GetDOMElement(nsIDOMElement* *result); + //nsIPluginTagInfo2 interface NS_IMETHOD GetTagType(nsPluginTagType *result); @@ -1662,6 +1665,28 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetAttribute(const char* name, const char* return NS_ERROR_FAILURE; } +NS_IMETHODIMP nsPluginInstanceOwner::GetDOMElement(nsIDOMElement* *result) +{ + nsresult rv = NS_ERROR_FAILURE; + + *result = nsnull; + + if (nsnull != mOwner) + { + nsIContent *cont; + + mOwner->GetContent(&cont); + + if (nsnull != cont) + { + rv = cont->QueryInterface(nsIDOMElement::GetIID(), (void **)result); + NS_RELEASE(cont); + } + } + + return rv; +} + NS_IMETHODIMP nsPluginInstanceOwner::GetInstance(nsIPluginInstance *&aInstance) { if (nsnull != mInstance) diff --git a/mozilla/layout/html/base/src/nsObjectFrame.cpp b/mozilla/layout/html/base/src/nsObjectFrame.cpp index d9ac0f7117d..2cfa35c3bda 100644 --- a/mozilla/layout/html/base/src/nsObjectFrame.cpp +++ b/mozilla/layout/html/base/src/nsObjectFrame.cpp @@ -51,6 +51,7 @@ #include "nsITimerCallback.h" #include "nsLayoutAtoms.h" #include "nsIDocShellTreeItem.h" +#include "nsIDOMElement.h" // XXX For temporary paint code #include "nsIStyleContext.h" @@ -97,6 +98,8 @@ public: NS_IMETHOD GetAttribute(const char* name, const char* *result); + NS_IMETHOD GetDOMElement(nsIDOMElement* *result); + //nsIPluginTagInfo2 interface NS_IMETHOD GetTagType(nsPluginTagType *result); @@ -1662,6 +1665,28 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetAttribute(const char* name, const char* return NS_ERROR_FAILURE; } +NS_IMETHODIMP nsPluginInstanceOwner::GetDOMElement(nsIDOMElement* *result) +{ + nsresult rv = NS_ERROR_FAILURE; + + *result = nsnull; + + if (nsnull != mOwner) + { + nsIContent *cont; + + mOwner->GetContent(&cont); + + if (nsnull != cont) + { + rv = cont->QueryInterface(nsIDOMElement::GetIID(), (void **)result); + NS_RELEASE(cont); + } + } + + return rv; +} + NS_IMETHODIMP nsPluginInstanceOwner::GetInstance(nsIPluginInstance *&aInstance) { if (nsnull != mInstance) diff --git a/mozilla/modules/plugin/base/public/nsIPluginTagInfo.h b/mozilla/modules/plugin/base/public/nsIPluginTagInfo.h index 9fb1e94c991..b9ad32fcc0f 100644 --- a/mozilla/modules/plugin/base/public/nsIPluginTagInfo.h +++ b/mozilla/modules/plugin/base/public/nsIPluginTagInfo.h @@ -41,6 +41,8 @@ #include "nsplugindefs.h" #include "nsISupports.h" +class nsIDOMElement; + #define NS_IPLUGINTAGINFO_IID \ { /* 5f1ec1d0-019b-11d2-815b-006008119d7a */ \ 0x5f1ec1d0, \ @@ -80,6 +82,18 @@ public: NS_IMETHOD GetAttribute(const char* name, const char* *result) = 0; + /** + * Returns the DOM element corresponding to the tag which references + * this plugin in the document. + * + * REMIND: do we need to expose as an nsISupports * to avoid + * introducing runtime dependencies on XPCOM? + * + * @param result - resulting DOM element + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + GetDOMElement(nsIDOMElement* *result) = 0; }; //////////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/modules/plugin/base/src/nsPluginInstancePeer.cpp b/mozilla/modules/plugin/base/src/nsPluginInstancePeer.cpp index a2412934461..bc2a6defac1 100644 --- a/mozilla/modules/plugin/base/src/nsPluginInstancePeer.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginInstancePeer.cpp @@ -358,6 +358,28 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetAttribute(const char* name, const cha } } +NS_IMETHODIMP nsPluginInstancePeerImpl::GetDOMElement(nsIDOMElement* *result) +{ + if (mOwner == nsnull) + { + *result = nsnull; + return NS_ERROR_FAILURE; + } + + nsIPluginTagInfo *tinfo; + nsresult rv; + + rv = mOwner->QueryInterface(kIPluginTagInfoIID, (void **)&tinfo); + + if (NS_OK == rv) + { + rv = tinfo->GetDOMElement(result); + NS_RELEASE(tinfo); + } + + return rv; +} + NS_IMETHODIMP nsPluginInstancePeerImpl::GetTagType(nsPluginTagType *result) { if (nsnull != mOwner) diff --git a/mozilla/modules/plugin/base/src/nsPluginInstancePeer.h b/mozilla/modules/plugin/base/src/nsPluginInstancePeer.h index 77d1d5d5de5..0b5d8e96bce 100644 --- a/mozilla/modules/plugin/base/src/nsPluginInstancePeer.h +++ b/mozilla/modules/plugin/base/src/nsPluginInstancePeer.h @@ -98,6 +98,9 @@ public: NS_IMETHOD GetAttribute(const char* name, const char* *result); + NS_IMETHOD + GetDOMElement(nsIDOMElement* *result); + //nsIPluginTagInfo2 interface NS_IMETHOD diff --git a/mozilla/modules/plugin/nglsrc/nsPluginInstancePeer.cpp b/mozilla/modules/plugin/nglsrc/nsPluginInstancePeer.cpp index a2412934461..bc2a6defac1 100644 --- a/mozilla/modules/plugin/nglsrc/nsPluginInstancePeer.cpp +++ b/mozilla/modules/plugin/nglsrc/nsPluginInstancePeer.cpp @@ -358,6 +358,28 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetAttribute(const char* name, const cha } } +NS_IMETHODIMP nsPluginInstancePeerImpl::GetDOMElement(nsIDOMElement* *result) +{ + if (mOwner == nsnull) + { + *result = nsnull; + return NS_ERROR_FAILURE; + } + + nsIPluginTagInfo *tinfo; + nsresult rv; + + rv = mOwner->QueryInterface(kIPluginTagInfoIID, (void **)&tinfo); + + if (NS_OK == rv) + { + rv = tinfo->GetDOMElement(result); + NS_RELEASE(tinfo); + } + + return rv; +} + NS_IMETHODIMP nsPluginInstancePeerImpl::GetTagType(nsPluginTagType *result) { if (nsnull != mOwner) diff --git a/mozilla/modules/plugin/nglsrc/nsPluginInstancePeer.h b/mozilla/modules/plugin/nglsrc/nsPluginInstancePeer.h index 77d1d5d5de5..0b5d8e96bce 100644 --- a/mozilla/modules/plugin/nglsrc/nsPluginInstancePeer.h +++ b/mozilla/modules/plugin/nglsrc/nsPluginInstancePeer.h @@ -98,6 +98,9 @@ public: NS_IMETHOD GetAttribute(const char* name, const char* *result); + NS_IMETHOD + GetDOMElement(nsIDOMElement* *result); + //nsIPluginTagInfo2 interface NS_IMETHOD diff --git a/mozilla/modules/plugin/public/nsIPluginTagInfo.h b/mozilla/modules/plugin/public/nsIPluginTagInfo.h index 9fb1e94c991..b9ad32fcc0f 100644 --- a/mozilla/modules/plugin/public/nsIPluginTagInfo.h +++ b/mozilla/modules/plugin/public/nsIPluginTagInfo.h @@ -41,6 +41,8 @@ #include "nsplugindefs.h" #include "nsISupports.h" +class nsIDOMElement; + #define NS_IPLUGINTAGINFO_IID \ { /* 5f1ec1d0-019b-11d2-815b-006008119d7a */ \ 0x5f1ec1d0, \ @@ -80,6 +82,18 @@ public: NS_IMETHOD GetAttribute(const char* name, const char* *result) = 0; + /** + * Returns the DOM element corresponding to the tag which references + * this plugin in the document. + * + * REMIND: do we need to expose as an nsISupports * to avoid + * introducing runtime dependencies on XPCOM? + * + * @param result - resulting DOM element + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + GetDOMElement(nsIDOMElement* *result) = 0; }; ////////////////////////////////////////////////////////////////////////////////