[1] Cutting down the size of content. Made nsIJSScriptObject inherit from nsIScriptObjectOwner [2] Cutting down the size of content. Made nsITextContent inherit from nsIContent. [3] Cutting down the size of content. Moved implementation of nsIDOMReceiver to nsListenerManager. This is not true aggregation since it isn't transitive, but it's OK for now. It will be necessary for nsListenerManager to have a reference to its content in the future anyway, so the transitivity could be done. dom/public/nsDOMPropEnums.h,v - bug 12559 dom/public/nsIJSScriptObject.h,v - [1] dom/public/html/MANIFEST,v - bug 12559 dom/public/html/Makefile.in,v - bug 12559 dom/public/html/makefile.win,v - bug 12559 dom/public/html/nsIDOMHTMLInputElement.h,v - bug 17544 dom/public/idl/html/HTMLAnchorElement.idl,v - bug 12559 dom/public/idl/html/HTMLAreaElement.idl,v - bug 12559 dom/public/idl/html/HTMLInputElement.idl,v - bug 17544 dom/src/base/nsGlobalWindow.cpp,v - bug 30700 dom/src/base/nsGlobalWindow.h,v - [1] dom/src/base/nsLocation.cpp,v - [1] dom/src/html/nsJSHTMLAnchorElement.cpp,v - bug 12559 dom/src/html/nsJSHTMLAreaElement.cpp,v - bug 12559 dom/src/html/nsJSHTMLInputElement.cpp,v - bug 17544 layout/base/public/nsIDocument.h,v - bug 27953 layout/base/public/nsITextContent.h,v - [2] layout/base/src/nsCommentNode.cpp,v - [2] layout/base/src/nsDocument.cpp,v - bug 27953 layout/base/src/nsDocument.h,v - bug 27953 layout/base/src/nsDocumentViewer.cpp,v - bug 27953 layout/base/src/nsGenericDOMDataNode.cpp,v - [3] layout/base/src/nsGenericDOMDataNode.h,v - [3] layout/base/src/nsGenericElement.cpp,v - [3] layout/base/src/nsGenericElement.h,v - [3] layout/base/src/nsNameSpaceManager.cpp,v - bug 7834 layout/base/src/nsStyleContext.cpp,v - outline property shouldn't reflow layout/base/src/nsTextNode.cpp,v - [2] layout/events/src/nsEventListenerManager.cpp,v - [3] layout/events/src/nsEventListenerManager.h,v - [3] layout/html/base/src/nsGfxScrollFrame.cpp,v - nsString->nsAutoString layout/html/content/src/nsAttributeContent.cpp,v - [2] layout/html/content/src/nsHTMLAnchorElement.cpp,v - [1][3] layout/html/content/src/nsHTMLAppletElement.cpp,v - [1][3] layout/html/content/src/nsHTMLAreaElement.cpp,v - [1][3] layout/html/content/src/nsHTMLBRElement.cpp,v - [1][3] layout/html/content/src/nsHTMLBaseElement.cpp,v - [1][3] layout/html/content/src/nsHTMLBaseFontElement.cpp,v - [1][3] layout/html/content/src/nsHTMLBodyElement.cpp,v - [1][3] layout/html/content/src/nsHTMLButtonElement.cpp,v - [1][3] layout/html/content/src/nsHTMLDListElement.cpp,v - [1][3] layout/html/content/src/nsHTMLDelElement.cpp,v - [1][3] layout/html/content/src/nsHTMLDirectoryElement.cpp,v - [1][3] layout/html/content/src/nsHTMLDivElement.cpp,v - [1][3] layout/html/content/src/nsHTMLEmbedElement.cpp,v - [1][3] layout/html/content/src/nsHTMLFieldSetElement.cpp,v - [1][3] layout/html/content/src/nsHTMLFontElement.cpp,v - [1][3] layout/html/content/src/nsHTMLFormElement.cpp,v - [1][3] layout/html/content/src/nsHTMLFrameElement.cpp,v - [1][3] layout/html/content/src/nsHTMLFrameSetElement.cpp,v - [1][3] layout/html/content/src/nsHTMLHRElement.cpp,v - [1][3] layout/html/content/src/nsHTMLHeadElement.cpp,v - [1][3] layout/html/content/src/nsHTMLHeadingElement.cpp,v - [1][3] layout/html/content/src/nsHTMLHtmlElement.cpp,v - [1][3] layout/html/content/src/nsHTMLIFrameElement.cpp,v - [1][3] layout/html/content/src/nsHTMLImageElement.cpp,v - [1][3] layout/html/content/src/nsHTMLInputElement.cpp,v - [1][3] layout/html/content/src/nsHTMLInsElement.cpp,v - [1][3] layout/html/content/src/nsHTMLIsIndexElement.cpp,v - [1][3] layout/html/content/src/nsHTMLLIElement.cpp,v - [1][3] layout/html/content/src/nsHTMLLabelElement.cpp,v - [1][3] layout/html/content/src/nsHTMLLayerElement.cpp,v - [1][3] layout/html/content/src/nsHTMLLegendElement.cpp,v - [1][3] layout/html/content/src/nsHTMLLinkElement.cpp,v - [1][3] layout/html/content/src/nsHTMLMapElement.cpp,v - [1][3] layout/html/content/src/nsHTMLMenuElement.cpp,v - [1][3] layout/html/content/src/nsHTMLMetaElement.cpp,v - [1][3] layout/html/content/src/nsHTMLModElement.cpp,v - [1][3] layout/html/content/src/nsHTMLOListElement.cpp,v - [1][3] layout/html/content/src/nsHTMLObjectElement.cpp,v - [1][3] layout/html/content/src/nsHTMLOptGroupElement.cpp,v - [1][3] layout/html/content/src/nsHTMLOptionElement.cpp,v - [1][3] layout/html/content/src/nsHTMLParagraphElement.cpp,v - [1][3] layout/html/content/src/nsHTMLParamElement.cpp,v - [1][3] layout/html/content/src/nsHTMLPreElement.cpp,v - [1][3] layout/html/content/src/nsHTMLQuoteElement.cpp,v - [1][3] layout/html/content/src/nsHTMLScriptElement.cpp,v - [1][3] layout/html/content/src/nsHTMLSelectElement.cpp,v - [1][3] layout/html/content/src/nsHTMLSpacerElement.cpp,v - [1][3] layout/html/content/src/nsHTMLSpanElement.cpp,v - [1][3] layout/html/content/src/nsHTMLStyleElement.cpp,v - [1][3] layout/html/content/src/nsHTMLTableCaptionElement.cpp,v - [1][3] layout/html/content/src/nsHTMLTableCellElement.cpp,v - [1][3] layout/html/content/src/nsHTMLTableColElement.cpp,v - [1][3] layout/html/content/src/nsHTMLTableColGroupElement.cpp,v - [1][3] layout/html/content/src/nsHTMLTableElement.cpp,v - [1][3] layout/html/content/src/nsHTMLTableRowElement.cpp,v - [1][3] layout/html/content/src/nsHTMLTableSectionElement.cpp,v - [1][3] layout/html/content/src/nsHTMLTextAreaElement.cpp,v - [1][3] layout/html/content/src/nsHTMLTitleElement.cpp,v - [1][3] layout/html/content/src/nsHTMLUListElement.cpp,v - [1][3] layout/html/content/src/nsHTMLWBRElement.cpp,v - [1][3] layout/html/document/src/nsHTMLDocument.cpp,v - bug 27953 layout/html/document/src/nsHTMLDocument.h,v - bug 27953 layout/xml/content/src/nsXMLCDATASection.cpp,v - [1][2] layout/xml/content/src/nsXMLDocumentType.cpp,v - [1][2] layout/xml/content/src/nsXMLElement.h,v - [1][2] layout/xml/content/src/nsXMLEntity.cpp,v - [1][2] layout/xml/content/src/nsXMLNotation.cpp,v - [1][2] layout/xml/content/src/nsXMLProcessingInstruction.cpp,v - [1][2] layout/xul/base/src/nsBoxFrame.cpp,v - nsString->nsAutoString layout/xul/base/src/nsSliderFrame.cpp,v - nsString->nsAutoString netwerk/protocol/http/src/nsHTTPRequest.cpp,v - nsString->nsAutoString rdf/content/src/nsXULDocument.cpp,v - bug 27953 rdf/content/src/nsXULDocument.h,v - bug 27953 rdf/content/src/nsXULElement.h,v - [1] xpcom/base/IIDS.h,v - bug 12559 git-svn-id: svn://10.0.0.236/trunk@63290 18797224-902f-48f8-a5cc-f745e15eee43
398 lines
13 KiB
C++
398 lines
13 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
*
|
|
* The contents of this file are subject to the Netscape 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/NPL/
|
|
*
|
|
* 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 Communicator client code.
|
|
*
|
|
* The Initial Developer of the Original Code is Netscape Communications
|
|
* Corporation. Portions created by Netscape are
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
* Rights Reserved.
|
|
*
|
|
* Contributor(s):
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
|
*/
|
|
#include "nsIDOMHTMLAppletElement.h"
|
|
#include "nsIScriptObjectOwner.h"
|
|
#include "nsIDOMEventReceiver.h"
|
|
#include "nsIHTMLContent.h"
|
|
#include "nsGenericHTMLElement.h"
|
|
#include "nsHTMLAtoms.h"
|
|
#include "nsHTMLIIDs.h"
|
|
#include "nsIStyleContext.h"
|
|
#include "nsIMutableStyleContext.h"
|
|
#include "nsStyleConsts.h"
|
|
#include "nsIPresContext.h"
|
|
#include "nsIDocument.h"
|
|
#include "nsIPresShell.h"
|
|
#include "nsIFrame.h"
|
|
|
|
#include "nsIServiceManager.h"
|
|
#include "nsIJVMManager.h"
|
|
#include "nsILiveConnectManager.h"
|
|
#include "nsIPluginInstance.h"
|
|
#include "nsIJVMPluginInstance.h"
|
|
#include "nsLayoutAtoms.h"
|
|
|
|
// XXX this is to get around conflicts with windows.h defines
|
|
// introduced through jni.h
|
|
#ifdef XP_PC
|
|
#undef GetClassName
|
|
#undef GetObject
|
|
#endif
|
|
|
|
static NS_DEFINE_IID(kIDOMHTMLAppletElementIID, NS_IDOMHTMLAPPLETELEMENT_IID);
|
|
|
|
class nsHTMLAppletElement : public nsIDOMHTMLAppletElement,
|
|
public nsIJSScriptObject,
|
|
public nsIHTMLContent
|
|
{
|
|
public:
|
|
nsHTMLAppletElement(nsIAtom* aTag);
|
|
virtual ~nsHTMLAppletElement();
|
|
|
|
// nsISupports
|
|
NS_DECL_ISUPPORTS
|
|
|
|
// nsIDOMNode
|
|
NS_IMPL_IDOMNODE_USING_GENERIC(mInner)
|
|
|
|
// nsIDOMElement
|
|
NS_IMPL_IDOMELEMENT_USING_GENERIC(mInner)
|
|
|
|
// nsIDOMHTMLElement
|
|
NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner)
|
|
|
|
// nsIDOMHTMLAppletElement
|
|
NS_IMETHOD GetAlign(nsString& aAlign);
|
|
NS_IMETHOD SetAlign(const nsString& aAlign);
|
|
NS_IMETHOD GetAlt(nsString& aAlt);
|
|
NS_IMETHOD SetAlt(const nsString& aAlt);
|
|
NS_IMETHOD GetArchive(nsString& aArchive);
|
|
NS_IMETHOD SetArchive(const nsString& aArchive);
|
|
NS_IMETHOD GetCode(nsString& aCode);
|
|
NS_IMETHOD SetCode(const nsString& aCode);
|
|
NS_IMETHOD GetCodeBase(nsString& aCodeBase);
|
|
NS_IMETHOD SetCodeBase(const nsString& aCodeBase);
|
|
NS_IMETHOD GetHeight(nsString& aHeight);
|
|
NS_IMETHOD SetHeight(const nsString& aHeight);
|
|
NS_IMETHOD GetHspace(nsString& aHspace);
|
|
NS_IMETHOD SetHspace(const nsString& aHspace);
|
|
NS_IMETHOD GetName(nsString& aName);
|
|
NS_IMETHOD SetName(const nsString& aName);
|
|
NS_IMETHOD GetObject(nsString& aObject);
|
|
NS_IMETHOD SetObject(const nsString& aObject);
|
|
NS_IMETHOD GetVspace(nsString& aVspace);
|
|
NS_IMETHOD SetVspace(const nsString& aVspace);
|
|
NS_IMETHOD GetWidth(nsString& aWidth);
|
|
NS_IMETHOD SetWidth(const nsString& aWidth);
|
|
|
|
// nsIJSScriptObject
|
|
virtual PRBool AddProperty(JSContext *aContext, JSObject *aObj,
|
|
jsval aID, jsval *aVp) {
|
|
return mInner.AddProperty(aContext, aObj, aID, aVp);
|
|
}
|
|
virtual PRBool DeleteProperty(JSContext *aContext, JSObject *aObj,
|
|
jsval aID, jsval *aVp) {
|
|
return mInner.DeleteProperty(aContext, aObj, aID, aVp);
|
|
}
|
|
virtual PRBool GetProperty(JSContext *aContext, JSObject *aObj,
|
|
jsval aID, jsval *aVp) {
|
|
return mInner.GetProperty(aContext, aObj, aID, aVp);
|
|
}
|
|
virtual PRBool SetProperty(JSContext *aContext, JSObject *aObj,
|
|
jsval aID, jsval *aVp) {
|
|
return mInner.SetProperty(aContext, aObj, aID, aVp);
|
|
}
|
|
virtual PRBool EnumerateProperty(JSContext *aContext, JSObject *aObj) {
|
|
return mInner.EnumerateProperty(aContext, aObj);
|
|
}
|
|
virtual PRBool Resolve(JSContext *aContext, JSObject *aObj, jsval aID) {
|
|
return mInner.EnumerateProperty(aContext, aObj);
|
|
}
|
|
virtual PRBool Convert(JSContext *aContext, JSObject *aObj, jsval aID) {
|
|
return mInner.EnumerateProperty(aContext, aObj);
|
|
}
|
|
virtual void Finalize(JSContext *aContext, JSObject *aObj) {
|
|
mInner.Finalize(aContext, aObj);
|
|
}
|
|
|
|
NS_IMETHOD GetScriptObject(nsIScriptContext* aContext,
|
|
void** aScriptObject);
|
|
NS_IMETHOD SetScriptObject(void *aScriptObject);
|
|
|
|
// nsIContent
|
|
NS_IMPL_ICONTENT_USING_GENERIC(mInner)
|
|
|
|
// nsIHTMLContent
|
|
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
|
|
|
|
protected:
|
|
nsGenericHTMLContainerElement mInner;
|
|
PRBool mReflectedApplet;
|
|
};
|
|
|
|
nsresult
|
|
NS_NewHTMLAppletElement(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag)
|
|
{
|
|
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
|
if (nsnull == aInstancePtrResult) {
|
|
return NS_ERROR_NULL_POINTER;
|
|
}
|
|
nsIHTMLContent* it = new nsHTMLAppletElement(aTag);
|
|
if (nsnull == it) {
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
}
|
|
return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult);
|
|
}
|
|
|
|
|
|
nsHTMLAppletElement::nsHTMLAppletElement(nsIAtom* aTag)
|
|
{
|
|
NS_INIT_REFCNT();
|
|
mInner.Init(this, aTag);
|
|
mReflectedApplet = PR_FALSE;
|
|
}
|
|
|
|
nsHTMLAppletElement::~nsHTMLAppletElement()
|
|
{
|
|
}
|
|
|
|
NS_IMPL_ADDREF(nsHTMLAppletElement)
|
|
|
|
NS_IMPL_RELEASE(nsHTMLAppletElement)
|
|
|
|
nsresult
|
|
nsHTMLAppletElement::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|
{
|
|
NS_IMPL_HTML_CONTENT_QUERY_INTERFACE(aIID, aInstancePtr, this)
|
|
if (aIID.Equals(kIDOMHTMLAppletElementIID)) {
|
|
nsIDOMHTMLAppletElement* tmp = this;
|
|
*aInstancePtr = (void*) tmp;
|
|
NS_ADDREF_THIS();
|
|
return NS_OK;
|
|
}
|
|
return NS_NOINTERFACE;
|
|
}
|
|
|
|
nsresult
|
|
nsHTMLAppletElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
|
{
|
|
nsHTMLAppletElement* it = new nsHTMLAppletElement(mInner.mTag);
|
|
if (nsnull == it) {
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
}
|
|
mInner.CopyInnerTo(this, &it->mInner, aDeep);
|
|
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
|
|
}
|
|
|
|
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Align, align)
|
|
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Alt, alt)
|
|
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Archive, archive)
|
|
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Code, code)
|
|
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, CodeBase, codebase)
|
|
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Height, height)
|
|
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Hspace, hspace)
|
|
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Name, name)
|
|
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Object, object)
|
|
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Vspace, vspace)
|
|
NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Width, width)
|
|
|
|
NS_IMETHODIMP
|
|
nsHTMLAppletElement::StringToAttribute(nsIAtom* aAttribute,
|
|
const nsString& aValue,
|
|
nsHTMLValue& aResult)
|
|
{
|
|
if (aAttribute == nsHTMLAtoms::align) {
|
|
if (nsGenericHTMLElement::ParseAlignValue(aValue, aResult)) {
|
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
|
}
|
|
}
|
|
else if (nsGenericHTMLElement::ParseImageAttribute(aAttribute,
|
|
aValue, aResult)) {
|
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
|
}
|
|
return NS_CONTENT_ATTR_NOT_THERE;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsHTMLAppletElement::AttributeToString(nsIAtom* aAttribute,
|
|
const nsHTMLValue& aValue,
|
|
nsString& aResult) const
|
|
{
|
|
if (aAttribute == nsHTMLAtoms::align) {
|
|
if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
|
|
nsGenericHTMLElement::AlignValueToString(aValue, aResult);
|
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
|
}
|
|
}
|
|
else if (nsGenericHTMLElement::ImageAttributeToString(aAttribute,
|
|
aValue, aResult)) {
|
|
return NS_CONTENT_ATTR_HAS_VALUE;
|
|
}
|
|
return mInner.AttributeToString(aAttribute, aValue, aResult);
|
|
}
|
|
|
|
static void
|
|
MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes,
|
|
nsIMutableStyleContext* aContext,
|
|
nsIPresContext* aPresContext)
|
|
{
|
|
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aContext, aPresContext);
|
|
nsGenericHTMLElement::MapImageAttributesInto(aAttributes, aContext, aPresContext);
|
|
nsGenericHTMLElement::MapImageAlignAttributeInto(aAttributes, aContext, aPresContext);
|
|
nsGenericHTMLElement::MapImageBorderAttributeInto(aAttributes, aContext, aPresContext, nsnull);
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsHTMLAppletElement::GetMappedAttributeImpact(const nsIAtom* aAttribute,
|
|
PRInt32& aHint) const
|
|
{
|
|
if (! nsGenericHTMLElement::GetCommonMappedAttributesImpact(aAttribute, aHint)) {
|
|
if (! nsGenericHTMLElement::GetImageMappedAttributesImpact(aAttribute, aHint)) {
|
|
if (! nsGenericHTMLElement::GetImageAlignAttributeImpact(aAttribute, aHint)) {
|
|
if (! nsGenericHTMLElement::GetImageBorderAttributeImpact(aAttribute, aHint)) {
|
|
aHint = NS_STYLE_HINT_CONTENT;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsHTMLAppletElement::GetAttributeMappingFunctions(nsMapAttributesFunc& aFontMapFunc,
|
|
nsMapAttributesFunc& aMapFunc) const
|
|
{
|
|
aFontMapFunc = nsnull;
|
|
aMapFunc = &MapAttributesInto;
|
|
return NS_OK;
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
nsHTMLAppletElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|
nsEvent* aEvent,
|
|
nsIDOMEvent** aDOMEvent,
|
|
PRUint32 aFlags,
|
|
nsEventStatus* aEventStatus)
|
|
{
|
|
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
|
aFlags, aEventStatus);
|
|
}
|
|
|
|
extern nsresult NS_GetObjectFramePluginInstance(nsIFrame* aFrame, nsIPluginInstance*& aPluginInstance);
|
|
|
|
/**
|
|
* For backwards compatibility an applet element's JavaScript object should expose both the public
|
|
* fields of the applet, and the attributes of the applet tag. The call to nsGenericElement::GetScriptObject
|
|
* takes case of the tag attributes. Here we generate a JavaScript reference to the applet object itself,
|
|
* and set its __proto__ property to the tag object. That way, if the Java applet has public fields that
|
|
* shadow the tag attributes, the applet's fields take precedence.
|
|
*/
|
|
NS_IMETHODIMP
|
|
nsHTMLAppletElement::GetScriptObject(nsIScriptContext* aContext,
|
|
void** aScriptObject)
|
|
{
|
|
nsresult rv = NS_OK;
|
|
NS_WITH_SERVICE(nsIJVMManager, jvm, nsIJVMManager::GetCID(), &rv);
|
|
if (NS_SUCCEEDED(rv)) {
|
|
// nsresult rv = NS_OK;
|
|
if (!mReflectedApplet) {
|
|
// 0. Make sure the presentation is up-to-date
|
|
if (mInner.mDocument) {
|
|
mInner.mDocument->FlushPendingNotifications();
|
|
}
|
|
|
|
// 1. get the script object corresponding to the <APPLET> element itself.
|
|
JSObject* elementObject = nsnull;
|
|
rv = mInner.GetScriptObject(aContext, (void**)&elementObject);
|
|
if (NS_OK != rv)
|
|
return rv;
|
|
|
|
// 2. get the plugin instance corresponding to this element.
|
|
nsIPresShell* shell = mInner.mDocument->GetShellAt(0);
|
|
if (nsnull == shell)
|
|
return NS_ERROR_FAILURE;
|
|
nsIFrame* frame = nsnull;
|
|
shell->GetPrimaryFrameFor(mInner.mContent, &frame);
|
|
NS_RELEASE(shell);
|
|
|
|
if(frame != nsnull)
|
|
{
|
|
nsIAtom* frameType = nsnull;
|
|
frame->GetFrameType(&frameType);
|
|
if(nsLayoutAtoms::objectFrame != frameType)
|
|
{
|
|
*aScriptObject = elementObject;
|
|
return rv;
|
|
}
|
|
}
|
|
|
|
// 3. get the Java object corresponding to this applet, and reflect it into
|
|
// JavaScript using the LiveConnect manager.
|
|
JSContext* context = (JSContext*)aContext->GetNativeContext();
|
|
JSObject* wrappedAppletObject = nsnull;
|
|
nsIPluginInstance* pluginInstance = nsnull;
|
|
rv = NS_GetObjectFramePluginInstance(frame, pluginInstance);
|
|
if ((rv == NS_OK) && (nsnull != pluginInstance)) {
|
|
nsIJVMPluginInstance* javaPluginInstance = nsnull;
|
|
if (pluginInstance->QueryInterface(NS_GET_IID(nsIJVMPluginInstance), (void**)&javaPluginInstance) == NS_OK) {
|
|
jobject appletObject = nsnull;
|
|
rv = javaPluginInstance->GetJavaObject(&appletObject);
|
|
if (NS_OK == rv) {
|
|
nsILiveConnectManager* manager = NULL;
|
|
rv = nsServiceManager::GetService(nsIJVMManager::GetCID(),
|
|
NS_GET_IID(nsILiveConnectManager),
|
|
(nsISupports **)&manager);
|
|
if (rv == NS_OK) {
|
|
rv = manager->WrapJavaObject(context, appletObject, &wrappedAppletObject);
|
|
nsServiceManager::ReleaseService(nsIJVMManager::GetCID(), manager);
|
|
}
|
|
}
|
|
NS_RELEASE(javaPluginInstance);
|
|
}
|
|
NS_RELEASE(pluginInstance);
|
|
}
|
|
|
|
// 4. set the __proto__ field of the applet object to be the element script object.
|
|
if (nsnull != wrappedAppletObject) {
|
|
JS_SetPrototype(context, wrappedAppletObject, elementObject);
|
|
mInner.SetScriptObject(wrappedAppletObject);
|
|
mReflectedApplet = PR_TRUE;
|
|
}
|
|
*aScriptObject = wrappedAppletObject;
|
|
} else {
|
|
rv = mInner.GetScriptObject(aContext, aScriptObject);
|
|
}
|
|
return rv;
|
|
}
|
|
else
|
|
return mInner.GetScriptObject(aContext, aScriptObject);
|
|
}
|
|
|
|
|
|
|
|
// TODO: if this method ever gets called, it will destroy the prototype type chain.
|
|
|
|
NS_IMETHODIMP
|
|
nsHTMLAppletElement::SetScriptObject(void *aScriptObject)
|
|
{
|
|
return mInner.SetScriptObject(aScriptObject);
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsHTMLAppletElement::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const
|
|
{
|
|
return mInner.SizeOf(aSizer, aResult, sizeof(*this));
|
|
}
|