зеркало из https://github.com/mozilla/pjs.git
added tags for plugins.
This commit is contained in:
Родитель
c5ec39f9ae
Коммит
5469028d38
|
@ -27,6 +27,7 @@ nsIAtom* nsHTMLAtoms::active;
|
|||
nsIAtom* nsHTMLAtoms::align;
|
||||
nsIAtom* nsHTMLAtoms::alink;
|
||||
nsIAtom* nsHTMLAtoms::alt;
|
||||
nsIAtom* nsHTMLAtoms::applet;
|
||||
nsIAtom* nsHTMLAtoms::archive;
|
||||
nsIAtom* nsHTMLAtoms::background;
|
||||
nsIAtom* nsHTMLAtoms::below;
|
||||
|
@ -56,6 +57,7 @@ nsIAtom* nsHTMLAtoms::dir;
|
|||
nsIAtom* nsHTMLAtoms::disabled;
|
||||
nsIAtom* nsHTMLAtoms::div;
|
||||
nsIAtom* nsHTMLAtoms::dl;
|
||||
nsIAtom* nsHTMLAtoms::embed;
|
||||
nsIAtom* nsHTMLAtoms::encoding;
|
||||
nsIAtom* nsHTMLAtoms::enctype;
|
||||
nsIAtom* nsHTMLAtoms::face;
|
||||
|
@ -99,6 +101,7 @@ nsIAtom* nsHTMLAtoms::name;
|
|||
nsIAtom* nsHTMLAtoms::noresize;
|
||||
nsIAtom* nsHTMLAtoms::noshade;
|
||||
nsIAtom* nsHTMLAtoms::nowrap;
|
||||
nsIAtom* nsHTMLAtoms::object;
|
||||
nsIAtom* nsHTMLAtoms::ol;
|
||||
nsIAtom* nsHTMLAtoms::onabort;
|
||||
nsIAtom* nsHTMLAtoms::onblur;
|
||||
|
@ -179,6 +182,7 @@ void nsHTMLAtoms::AddrefAtoms()
|
|||
align = NS_NewAtom("ALIGN");
|
||||
alink = NS_NewAtom("ALINK");
|
||||
alt = NS_NewAtom("ALT");
|
||||
applet = NS_NewAtom("APPLET");
|
||||
archive = NS_NewAtom("ARCHIVE");
|
||||
background = NS_NewAtom("BACKGROUND");
|
||||
below = NS_NewAtom("BELOW");
|
||||
|
@ -208,6 +212,7 @@ void nsHTMLAtoms::AddrefAtoms()
|
|||
disabled = NS_NewAtom("DISABLED");
|
||||
dl = NS_NewAtom("DL");
|
||||
data = NS_NewAtom("DATA");
|
||||
embed = NS_NewAtom("EMBED");
|
||||
encoding = NS_NewAtom("ENCODING");
|
||||
enctype = NS_NewAtom("ENCTYPE");
|
||||
face = NS_NewAtom("FACE");
|
||||
|
@ -250,6 +255,7 @@ void nsHTMLAtoms::AddrefAtoms()
|
|||
noresize = NS_NewAtom("NORESIZE");
|
||||
noshade = NS_NewAtom("NOSHADE");
|
||||
nowrap = NS_NewAtom("NOWRAP");
|
||||
object = NS_NewAtom("OBJECT");
|
||||
ol = NS_NewAtom("OL");
|
||||
onabort = NS_NewAtom("ONABORT");
|
||||
onblur = NS_NewAtom("ONBLUR");
|
||||
|
@ -330,6 +336,7 @@ void nsHTMLAtoms::ReleaseAtoms()
|
|||
NS_RELEASE(align);
|
||||
NS_RELEASE(alink);
|
||||
NS_RELEASE(alt);
|
||||
NS_RELEASE(applet);
|
||||
NS_RELEASE(archive);
|
||||
NS_RELEASE(background);
|
||||
NS_RELEASE(below);
|
||||
|
@ -359,6 +366,7 @@ void nsHTMLAtoms::ReleaseAtoms()
|
|||
NS_RELEASE(div);
|
||||
NS_RELEASE(dl);
|
||||
NS_RELEASE(data);
|
||||
NS_RELEASE(embed);
|
||||
NS_RELEASE(encoding);
|
||||
NS_RELEASE(face);
|
||||
NS_RELEASE(font);
|
||||
|
@ -397,6 +405,7 @@ void nsHTMLAtoms::ReleaseAtoms()
|
|||
NS_RELEASE(noresize);
|
||||
NS_RELEASE(noshade);
|
||||
NS_RELEASE(nowrap);
|
||||
NS_RELEASE(object);
|
||||
NS_RELEASE(ol);
|
||||
NS_RELEASE(onabort);
|
||||
NS_RELEASE(onblur);
|
||||
|
|
|
@ -48,6 +48,7 @@ public:
|
|||
static nsIAtom* align;
|
||||
static nsIAtom* alink;
|
||||
static nsIAtom* alt;
|
||||
static nsIAtom* applet;
|
||||
static nsIAtom* archive;
|
||||
|
||||
static nsIAtom* background;
|
||||
|
@ -81,6 +82,7 @@ public:
|
|||
static nsIAtom* div;
|
||||
static nsIAtom* dl;
|
||||
|
||||
static nsIAtom* embed;
|
||||
static nsIAtom* encoding;
|
||||
static nsIAtom* enctype;
|
||||
|
||||
|
@ -132,6 +134,7 @@ public:
|
|||
static nsIAtom* noshade;
|
||||
static nsIAtom* nowrap;
|
||||
|
||||
static nsIAtom* object;
|
||||
static nsIAtom* ol;
|
||||
static nsIAtom* onabort;
|
||||
static nsIAtom* onblur;
|
||||
|
|
|
@ -48,6 +48,7 @@ public:
|
|||
static nsIAtom* align;
|
||||
static nsIAtom* alink;
|
||||
static nsIAtom* alt;
|
||||
static nsIAtom* applet;
|
||||
static nsIAtom* archive;
|
||||
|
||||
static nsIAtom* background;
|
||||
|
@ -81,6 +82,7 @@ public:
|
|||
static nsIAtom* div;
|
||||
static nsIAtom* dl;
|
||||
|
||||
static nsIAtom* embed;
|
||||
static nsIAtom* encoding;
|
||||
static nsIAtom* enctype;
|
||||
|
||||
|
@ -132,6 +134,7 @@ public:
|
|||
static nsIAtom* noshade;
|
||||
static nsIAtom* nowrap;
|
||||
|
||||
static nsIAtom* object;
|
||||
static nsIAtom* ol;
|
||||
static nsIAtom* onabort;
|
||||
static nsIAtom* onblur;
|
||||
|
|
|
@ -27,6 +27,7 @@ nsIAtom* nsHTMLAtoms::active;
|
|||
nsIAtom* nsHTMLAtoms::align;
|
||||
nsIAtom* nsHTMLAtoms::alink;
|
||||
nsIAtom* nsHTMLAtoms::alt;
|
||||
nsIAtom* nsHTMLAtoms::applet;
|
||||
nsIAtom* nsHTMLAtoms::archive;
|
||||
nsIAtom* nsHTMLAtoms::background;
|
||||
nsIAtom* nsHTMLAtoms::below;
|
||||
|
@ -56,6 +57,7 @@ nsIAtom* nsHTMLAtoms::dir;
|
|||
nsIAtom* nsHTMLAtoms::disabled;
|
||||
nsIAtom* nsHTMLAtoms::div;
|
||||
nsIAtom* nsHTMLAtoms::dl;
|
||||
nsIAtom* nsHTMLAtoms::embed;
|
||||
nsIAtom* nsHTMLAtoms::encoding;
|
||||
nsIAtom* nsHTMLAtoms::enctype;
|
||||
nsIAtom* nsHTMLAtoms::face;
|
||||
|
@ -99,6 +101,7 @@ nsIAtom* nsHTMLAtoms::name;
|
|||
nsIAtom* nsHTMLAtoms::noresize;
|
||||
nsIAtom* nsHTMLAtoms::noshade;
|
||||
nsIAtom* nsHTMLAtoms::nowrap;
|
||||
nsIAtom* nsHTMLAtoms::object;
|
||||
nsIAtom* nsHTMLAtoms::ol;
|
||||
nsIAtom* nsHTMLAtoms::onabort;
|
||||
nsIAtom* nsHTMLAtoms::onblur;
|
||||
|
@ -179,6 +182,7 @@ void nsHTMLAtoms::AddrefAtoms()
|
|||
align = NS_NewAtom("ALIGN");
|
||||
alink = NS_NewAtom("ALINK");
|
||||
alt = NS_NewAtom("ALT");
|
||||
applet = NS_NewAtom("APPLET");
|
||||
archive = NS_NewAtom("ARCHIVE");
|
||||
background = NS_NewAtom("BACKGROUND");
|
||||
below = NS_NewAtom("BELOW");
|
||||
|
@ -208,6 +212,7 @@ void nsHTMLAtoms::AddrefAtoms()
|
|||
disabled = NS_NewAtom("DISABLED");
|
||||
dl = NS_NewAtom("DL");
|
||||
data = NS_NewAtom("DATA");
|
||||
embed = NS_NewAtom("EMBED");
|
||||
encoding = NS_NewAtom("ENCODING");
|
||||
enctype = NS_NewAtom("ENCTYPE");
|
||||
face = NS_NewAtom("FACE");
|
||||
|
@ -250,6 +255,7 @@ void nsHTMLAtoms::AddrefAtoms()
|
|||
noresize = NS_NewAtom("NORESIZE");
|
||||
noshade = NS_NewAtom("NOSHADE");
|
||||
nowrap = NS_NewAtom("NOWRAP");
|
||||
object = NS_NewAtom("OBJECT");
|
||||
ol = NS_NewAtom("OL");
|
||||
onabort = NS_NewAtom("ONABORT");
|
||||
onblur = NS_NewAtom("ONBLUR");
|
||||
|
@ -330,6 +336,7 @@ void nsHTMLAtoms::ReleaseAtoms()
|
|||
NS_RELEASE(align);
|
||||
NS_RELEASE(alink);
|
||||
NS_RELEASE(alt);
|
||||
NS_RELEASE(applet);
|
||||
NS_RELEASE(archive);
|
||||
NS_RELEASE(background);
|
||||
NS_RELEASE(below);
|
||||
|
@ -359,6 +366,7 @@ void nsHTMLAtoms::ReleaseAtoms()
|
|||
NS_RELEASE(div);
|
||||
NS_RELEASE(dl);
|
||||
NS_RELEASE(data);
|
||||
NS_RELEASE(embed);
|
||||
NS_RELEASE(encoding);
|
||||
NS_RELEASE(face);
|
||||
NS_RELEASE(font);
|
||||
|
@ -397,6 +405,7 @@ void nsHTMLAtoms::ReleaseAtoms()
|
|||
NS_RELEASE(noresize);
|
||||
NS_RELEASE(noshade);
|
||||
NS_RELEASE(nowrap);
|
||||
NS_RELEASE(object);
|
||||
NS_RELEASE(ol);
|
||||
NS_RELEASE(onabort);
|
||||
NS_RELEASE(onblur);
|
||||
|
|
|
@ -30,6 +30,9 @@
|
|||
#include "nsString.h"
|
||||
#include "nsIContentViewerContainer.h"
|
||||
#include "prmem.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIURL.h"
|
||||
|
||||
// XXX For temporary paint code
|
||||
#include "nsIStyleContext.h"
|
||||
|
@ -59,9 +62,15 @@ protected:
|
|||
|
||||
nsresult CreateWidget(nsIPresContext* aPresContext,
|
||||
nscoord aWidth, nscoord aHeight);
|
||||
|
||||
nsresult SetURL(const nsString& aURLSpec);
|
||||
nsresult SetBaseHREF(const nsString& aBaseHREF);
|
||||
|
||||
private:
|
||||
nsPluginWindow mPluginWindow;
|
||||
nsIPluginInstance *mInstance;
|
||||
nsString *mURLSpec;
|
||||
nsString *mBaseHREF;
|
||||
};
|
||||
|
||||
nsObjectFrame::nsObjectFrame(nsIContent* aContent, nsIFrame* aParentFrame)
|
||||
|
@ -72,6 +81,18 @@ nsObjectFrame::nsObjectFrame(nsIContent* aContent, nsIFrame* aParentFrame)
|
|||
nsObjectFrame::~nsObjectFrame()
|
||||
{
|
||||
NS_IF_RELEASE(mInstance);
|
||||
|
||||
if (nsnull != mURLSpec)
|
||||
{
|
||||
delete mURLSpec;
|
||||
mURLSpec = nsnull;
|
||||
}
|
||||
|
||||
if (nsnull != mBaseHREF)
|
||||
{
|
||||
delete mBaseHREF;
|
||||
mBaseHREF = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
|
||||
|
@ -202,51 +223,48 @@ nsObjectFrame::Reflow(nsIPresContext& aPresContext,
|
|||
|
||||
// XXX deal with border and padding the usual way...wrap it up!
|
||||
|
||||
#if XXX
|
||||
// Create view if necessary
|
||||
nsIView* view;
|
||||
GetView(view);
|
||||
if (nsnull == view) {
|
||||
nsresult rv = CreateWidget(&aPresContext, aMetrics.width,
|
||||
aMetrics.height);
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
nsIAtom* atom = mContent->GetTag();
|
||||
if (nsnull != atom) {
|
||||
//don't make a view for an applet since we know we can't support them yet...
|
||||
if (atom != nsHTMLAtoms::applet) {
|
||||
static NS_DEFINE_IID(kIPluginHostIID, NS_IPLUGINHOST_IID);
|
||||
static NS_DEFINE_IID(kIContentViewerContainerIID, NS_ICONTENT_VIEWER_CONTAINER_IID);
|
||||
|
||||
static NS_DEFINE_IID(kIPluginHostIID, NS_IPLUGINHOST_IID);
|
||||
static NS_DEFINE_IID(kIContentViewerContainerIID, NS_ICONTENT_VIEWER_CONTAINER_IID);
|
||||
nsISupports *container;
|
||||
nsIPluginHost *pm;
|
||||
nsIContentViewerContainer *cv;
|
||||
nsresult rv;
|
||||
|
||||
nsISupports *container;
|
||||
nsIPluginHost *pm;
|
||||
nsIContentViewerContainer *cv;
|
||||
|
||||
rv = aPresContext.GetContainer(&container);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
rv = container->QueryInterface(kIContentViewerContainerIID, (void **)&cv);
|
||||
rv = aPresContext.GetContainer(&container);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
rv = cv->QueryCapability(kIPluginHostIID, (void **)&pm);
|
||||
rv = container->QueryInterface(kIContentViewerContainerIID, (void **)&cv);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
nsAutoString type;
|
||||
char *buf;
|
||||
PRInt32 buflen;
|
||||
|
||||
mContent->GetAttribute(nsString("type"), type);
|
||||
|
||||
buflen = type.Length();
|
||||
|
||||
if (buflen > 0) {
|
||||
buf = (char *)PR_Malloc(buflen + 1);
|
||||
|
||||
if (nsnull != buf) {
|
||||
type.ToCString(buf, buflen + 1);
|
||||
|
||||
rv = pm->InstantiatePlugin(buf, &mInstance);
|
||||
rv = cv->QueryCapability(kIPluginHostIID, (void **)&pm);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
// Create view if necessary
|
||||
nsIView* view;
|
||||
GetView(view);
|
||||
if (nsnull == view) {
|
||||
rv = CreateWidget(&aPresContext, aMetrics.width,
|
||||
aMetrics.height);
|
||||
if (NS_OK == rv) {
|
||||
mInstance->Start();
|
||||
nsAutoString type;
|
||||
char *buf = nsnull;
|
||||
PRInt32 buflen;
|
||||
|
||||
mContent->GetAttribute(nsString("type"), type);
|
||||
|
||||
buflen = type.Length();
|
||||
|
||||
if (buflen > 0) {
|
||||
buf = (char *)PR_Malloc(buflen + 1);
|
||||
|
||||
if (nsnull != buf)
|
||||
type.ToCString(buf, buflen + 1);
|
||||
}
|
||||
|
||||
nsIView *view;
|
||||
nsIWidget *widget;
|
||||
|
@ -257,6 +275,28 @@ nsObjectFrame::Reflow(nsIPresContext& aPresContext,
|
|||
widget = view->GetWidget();
|
||||
widget->GetBounds(wrect);
|
||||
|
||||
nsAutoString src, base, fullurl;
|
||||
|
||||
//stream in the object source if there is one...
|
||||
|
||||
if (eContentAttr_HasValue == mContent->GetAttribute("SRC", src)) {
|
||||
SetURL(src);
|
||||
|
||||
if (eContentAttr_HasValue == mContent->GetAttribute(NS_HTML_BASE_HREF, base))
|
||||
SetBaseHREF(base);
|
||||
|
||||
nsIPresShell *shell = aPresContext.GetShell();
|
||||
nsIDocument *doc = shell->GetDocument();
|
||||
nsIURL *docURL = doc->GetDocumentURL();
|
||||
|
||||
// Create an absolute URL
|
||||
nsresult rv = NS_MakeAbsoluteURL(docURL, base, *mURLSpec, fullurl);
|
||||
|
||||
NS_RELEASE(shell);
|
||||
NS_RELEASE(docURL);
|
||||
NS_RELEASE(doc);
|
||||
}
|
||||
|
||||
mPluginWindow.window = (nsPluginPort *)widget->GetNativeData(NS_NATIVE_WINDOW);
|
||||
mPluginWindow.x = wrect.x;
|
||||
mPluginWindow.y = wrect.y;
|
||||
|
@ -269,10 +309,12 @@ nsObjectFrame::Reflow(nsIPresContext& aPresContext,
|
|||
#ifdef XP_UNIX
|
||||
mPluginWindow.ws_info = nsnull; //XXX need to figure out what this is. MMP
|
||||
#endif
|
||||
//this will change with support for windowless plugins?... MMP
|
||||
//this will change with support for windowless plugins... MMP
|
||||
mPluginWindow.type = nsPluginWindowType_Window;
|
||||
|
||||
mInstance->SetWindow(&mPluginWindow);
|
||||
rv = pm->InstantiatePlugin(buf, &mInstance, &mPluginWindow, fullurl);
|
||||
|
||||
PR_Free((void *)buf);
|
||||
|
||||
//since the plugin is holding on to private data in the widget,
|
||||
//we probably need to keep around the ref on the view and/or widget.
|
||||
|
@ -282,21 +324,18 @@ nsObjectFrame::Reflow(nsIPresContext& aPresContext,
|
|||
NS_RELEASE(widget);
|
||||
}
|
||||
}
|
||||
else {
|
||||
NS_RELEASE(view);
|
||||
}
|
||||
NS_RELEASE(pm);
|
||||
}
|
||||
|
||||
NS_RELEASE(pm);
|
||||
NS_RELEASE(cv);
|
||||
}
|
||||
|
||||
NS_RELEASE(cv);
|
||||
NS_RELEASE(container);
|
||||
}
|
||||
|
||||
NS_RELEASE(container);
|
||||
}
|
||||
NS_RELEASE(atom);
|
||||
}
|
||||
else {
|
||||
NS_RELEASE(view);
|
||||
}
|
||||
#endif
|
||||
|
||||
aStatus = NS_FRAME_COMPLETE;
|
||||
return NS_OK;
|
||||
|
@ -356,3 +395,29 @@ NS_NewObjectFrame(nsIFrame*& aFrameResult, nsIContent* aContent,
|
|||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsObjectFrame::SetURL(const nsString& aURLSpec)
|
||||
{
|
||||
if (nsnull != mURLSpec) {
|
||||
delete mURLSpec;
|
||||
}
|
||||
mURLSpec = new nsString(aURLSpec);
|
||||
if (nsnull == mURLSpec) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsObjectFrame::SetBaseHREF(const nsString& aBaseHREF)
|
||||
{
|
||||
if (nsnull != mBaseHREF) {
|
||||
delete mBaseHREF;
|
||||
}
|
||||
mBaseHREF = new nsString(aBaseHREF);
|
||||
if (nsnull == mBaseHREF) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ nsIAtom* nsHTMLAtoms::active;
|
|||
nsIAtom* nsHTMLAtoms::align;
|
||||
nsIAtom* nsHTMLAtoms::alink;
|
||||
nsIAtom* nsHTMLAtoms::alt;
|
||||
nsIAtom* nsHTMLAtoms::applet;
|
||||
nsIAtom* nsHTMLAtoms::archive;
|
||||
nsIAtom* nsHTMLAtoms::background;
|
||||
nsIAtom* nsHTMLAtoms::below;
|
||||
|
@ -56,6 +57,7 @@ nsIAtom* nsHTMLAtoms::dir;
|
|||
nsIAtom* nsHTMLAtoms::disabled;
|
||||
nsIAtom* nsHTMLAtoms::div;
|
||||
nsIAtom* nsHTMLAtoms::dl;
|
||||
nsIAtom* nsHTMLAtoms::embed;
|
||||
nsIAtom* nsHTMLAtoms::encoding;
|
||||
nsIAtom* nsHTMLAtoms::enctype;
|
||||
nsIAtom* nsHTMLAtoms::face;
|
||||
|
@ -99,6 +101,7 @@ nsIAtom* nsHTMLAtoms::name;
|
|||
nsIAtom* nsHTMLAtoms::noresize;
|
||||
nsIAtom* nsHTMLAtoms::noshade;
|
||||
nsIAtom* nsHTMLAtoms::nowrap;
|
||||
nsIAtom* nsHTMLAtoms::object;
|
||||
nsIAtom* nsHTMLAtoms::ol;
|
||||
nsIAtom* nsHTMLAtoms::onabort;
|
||||
nsIAtom* nsHTMLAtoms::onblur;
|
||||
|
@ -179,6 +182,7 @@ void nsHTMLAtoms::AddrefAtoms()
|
|||
align = NS_NewAtom("ALIGN");
|
||||
alink = NS_NewAtom("ALINK");
|
||||
alt = NS_NewAtom("ALT");
|
||||
applet = NS_NewAtom("APPLET");
|
||||
archive = NS_NewAtom("ARCHIVE");
|
||||
background = NS_NewAtom("BACKGROUND");
|
||||
below = NS_NewAtom("BELOW");
|
||||
|
@ -208,6 +212,7 @@ void nsHTMLAtoms::AddrefAtoms()
|
|||
disabled = NS_NewAtom("DISABLED");
|
||||
dl = NS_NewAtom("DL");
|
||||
data = NS_NewAtom("DATA");
|
||||
embed = NS_NewAtom("EMBED");
|
||||
encoding = NS_NewAtom("ENCODING");
|
||||
enctype = NS_NewAtom("ENCTYPE");
|
||||
face = NS_NewAtom("FACE");
|
||||
|
@ -250,6 +255,7 @@ void nsHTMLAtoms::AddrefAtoms()
|
|||
noresize = NS_NewAtom("NORESIZE");
|
||||
noshade = NS_NewAtom("NOSHADE");
|
||||
nowrap = NS_NewAtom("NOWRAP");
|
||||
object = NS_NewAtom("OBJECT");
|
||||
ol = NS_NewAtom("OL");
|
||||
onabort = NS_NewAtom("ONABORT");
|
||||
onblur = NS_NewAtom("ONBLUR");
|
||||
|
@ -330,6 +336,7 @@ void nsHTMLAtoms::ReleaseAtoms()
|
|||
NS_RELEASE(align);
|
||||
NS_RELEASE(alink);
|
||||
NS_RELEASE(alt);
|
||||
NS_RELEASE(applet);
|
||||
NS_RELEASE(archive);
|
||||
NS_RELEASE(background);
|
||||
NS_RELEASE(below);
|
||||
|
@ -359,6 +366,7 @@ void nsHTMLAtoms::ReleaseAtoms()
|
|||
NS_RELEASE(div);
|
||||
NS_RELEASE(dl);
|
||||
NS_RELEASE(data);
|
||||
NS_RELEASE(embed);
|
||||
NS_RELEASE(encoding);
|
||||
NS_RELEASE(face);
|
||||
NS_RELEASE(font);
|
||||
|
@ -397,6 +405,7 @@ void nsHTMLAtoms::ReleaseAtoms()
|
|||
NS_RELEASE(noresize);
|
||||
NS_RELEASE(noshade);
|
||||
NS_RELEASE(nowrap);
|
||||
NS_RELEASE(object);
|
||||
NS_RELEASE(ol);
|
||||
NS_RELEASE(onabort);
|
||||
NS_RELEASE(onblur);
|
||||
|
|
|
@ -48,6 +48,7 @@ public:
|
|||
static nsIAtom* align;
|
||||
static nsIAtom* alink;
|
||||
static nsIAtom* alt;
|
||||
static nsIAtom* applet;
|
||||
static nsIAtom* archive;
|
||||
|
||||
static nsIAtom* background;
|
||||
|
@ -81,6 +82,7 @@ public:
|
|||
static nsIAtom* div;
|
||||
static nsIAtom* dl;
|
||||
|
||||
static nsIAtom* embed;
|
||||
static nsIAtom* encoding;
|
||||
static nsIAtom* enctype;
|
||||
|
||||
|
@ -132,6 +134,7 @@ public:
|
|||
static nsIAtom* noshade;
|
||||
static nsIAtom* nowrap;
|
||||
|
||||
static nsIAtom* object;
|
||||
static nsIAtom* ol;
|
||||
static nsIAtom* onabort;
|
||||
static nsIAtom* onblur;
|
||||
|
|
|
@ -30,6 +30,9 @@
|
|||
#include "nsString.h"
|
||||
#include "nsIContentViewerContainer.h"
|
||||
#include "prmem.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIURL.h"
|
||||
|
||||
// XXX For temporary paint code
|
||||
#include "nsIStyleContext.h"
|
||||
|
@ -59,9 +62,15 @@ protected:
|
|||
|
||||
nsresult CreateWidget(nsIPresContext* aPresContext,
|
||||
nscoord aWidth, nscoord aHeight);
|
||||
|
||||
nsresult SetURL(const nsString& aURLSpec);
|
||||
nsresult SetBaseHREF(const nsString& aBaseHREF);
|
||||
|
||||
private:
|
||||
nsPluginWindow mPluginWindow;
|
||||
nsIPluginInstance *mInstance;
|
||||
nsString *mURLSpec;
|
||||
nsString *mBaseHREF;
|
||||
};
|
||||
|
||||
nsObjectFrame::nsObjectFrame(nsIContent* aContent, nsIFrame* aParentFrame)
|
||||
|
@ -72,6 +81,18 @@ nsObjectFrame::nsObjectFrame(nsIContent* aContent, nsIFrame* aParentFrame)
|
|||
nsObjectFrame::~nsObjectFrame()
|
||||
{
|
||||
NS_IF_RELEASE(mInstance);
|
||||
|
||||
if (nsnull != mURLSpec)
|
||||
{
|
||||
delete mURLSpec;
|
||||
mURLSpec = nsnull;
|
||||
}
|
||||
|
||||
if (nsnull != mBaseHREF)
|
||||
{
|
||||
delete mBaseHREF;
|
||||
mBaseHREF = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
|
||||
|
@ -202,51 +223,48 @@ nsObjectFrame::Reflow(nsIPresContext& aPresContext,
|
|||
|
||||
// XXX deal with border and padding the usual way...wrap it up!
|
||||
|
||||
#if XXX
|
||||
// Create view if necessary
|
||||
nsIView* view;
|
||||
GetView(view);
|
||||
if (nsnull == view) {
|
||||
nsresult rv = CreateWidget(&aPresContext, aMetrics.width,
|
||||
aMetrics.height);
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
nsIAtom* atom = mContent->GetTag();
|
||||
if (nsnull != atom) {
|
||||
//don't make a view for an applet since we know we can't support them yet...
|
||||
if (atom != nsHTMLAtoms::applet) {
|
||||
static NS_DEFINE_IID(kIPluginHostIID, NS_IPLUGINHOST_IID);
|
||||
static NS_DEFINE_IID(kIContentViewerContainerIID, NS_ICONTENT_VIEWER_CONTAINER_IID);
|
||||
|
||||
static NS_DEFINE_IID(kIPluginHostIID, NS_IPLUGINHOST_IID);
|
||||
static NS_DEFINE_IID(kIContentViewerContainerIID, NS_ICONTENT_VIEWER_CONTAINER_IID);
|
||||
nsISupports *container;
|
||||
nsIPluginHost *pm;
|
||||
nsIContentViewerContainer *cv;
|
||||
nsresult rv;
|
||||
|
||||
nsISupports *container;
|
||||
nsIPluginHost *pm;
|
||||
nsIContentViewerContainer *cv;
|
||||
|
||||
rv = aPresContext.GetContainer(&container);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
rv = container->QueryInterface(kIContentViewerContainerIID, (void **)&cv);
|
||||
rv = aPresContext.GetContainer(&container);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
rv = cv->QueryCapability(kIPluginHostIID, (void **)&pm);
|
||||
rv = container->QueryInterface(kIContentViewerContainerIID, (void **)&cv);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
nsAutoString type;
|
||||
char *buf;
|
||||
PRInt32 buflen;
|
||||
|
||||
mContent->GetAttribute(nsString("type"), type);
|
||||
|
||||
buflen = type.Length();
|
||||
|
||||
if (buflen > 0) {
|
||||
buf = (char *)PR_Malloc(buflen + 1);
|
||||
|
||||
if (nsnull != buf) {
|
||||
type.ToCString(buf, buflen + 1);
|
||||
|
||||
rv = pm->InstantiatePlugin(buf, &mInstance);
|
||||
rv = cv->QueryCapability(kIPluginHostIID, (void **)&pm);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
// Create view if necessary
|
||||
nsIView* view;
|
||||
GetView(view);
|
||||
if (nsnull == view) {
|
||||
rv = CreateWidget(&aPresContext, aMetrics.width,
|
||||
aMetrics.height);
|
||||
if (NS_OK == rv) {
|
||||
mInstance->Start();
|
||||
nsAutoString type;
|
||||
char *buf = nsnull;
|
||||
PRInt32 buflen;
|
||||
|
||||
mContent->GetAttribute(nsString("type"), type);
|
||||
|
||||
buflen = type.Length();
|
||||
|
||||
if (buflen > 0) {
|
||||
buf = (char *)PR_Malloc(buflen + 1);
|
||||
|
||||
if (nsnull != buf)
|
||||
type.ToCString(buf, buflen + 1);
|
||||
}
|
||||
|
||||
nsIView *view;
|
||||
nsIWidget *widget;
|
||||
|
@ -257,6 +275,28 @@ nsObjectFrame::Reflow(nsIPresContext& aPresContext,
|
|||
widget = view->GetWidget();
|
||||
widget->GetBounds(wrect);
|
||||
|
||||
nsAutoString src, base, fullurl;
|
||||
|
||||
//stream in the object source if there is one...
|
||||
|
||||
if (eContentAttr_HasValue == mContent->GetAttribute("SRC", src)) {
|
||||
SetURL(src);
|
||||
|
||||
if (eContentAttr_HasValue == mContent->GetAttribute(NS_HTML_BASE_HREF, base))
|
||||
SetBaseHREF(base);
|
||||
|
||||
nsIPresShell *shell = aPresContext.GetShell();
|
||||
nsIDocument *doc = shell->GetDocument();
|
||||
nsIURL *docURL = doc->GetDocumentURL();
|
||||
|
||||
// Create an absolute URL
|
||||
nsresult rv = NS_MakeAbsoluteURL(docURL, base, *mURLSpec, fullurl);
|
||||
|
||||
NS_RELEASE(shell);
|
||||
NS_RELEASE(docURL);
|
||||
NS_RELEASE(doc);
|
||||
}
|
||||
|
||||
mPluginWindow.window = (nsPluginPort *)widget->GetNativeData(NS_NATIVE_WINDOW);
|
||||
mPluginWindow.x = wrect.x;
|
||||
mPluginWindow.y = wrect.y;
|
||||
|
@ -269,10 +309,12 @@ nsObjectFrame::Reflow(nsIPresContext& aPresContext,
|
|||
#ifdef XP_UNIX
|
||||
mPluginWindow.ws_info = nsnull; //XXX need to figure out what this is. MMP
|
||||
#endif
|
||||
//this will change with support for windowless plugins?... MMP
|
||||
//this will change with support for windowless plugins... MMP
|
||||
mPluginWindow.type = nsPluginWindowType_Window;
|
||||
|
||||
mInstance->SetWindow(&mPluginWindow);
|
||||
rv = pm->InstantiatePlugin(buf, &mInstance, &mPluginWindow, fullurl);
|
||||
|
||||
PR_Free((void *)buf);
|
||||
|
||||
//since the plugin is holding on to private data in the widget,
|
||||
//we probably need to keep around the ref on the view and/or widget.
|
||||
|
@ -282,21 +324,18 @@ nsObjectFrame::Reflow(nsIPresContext& aPresContext,
|
|||
NS_RELEASE(widget);
|
||||
}
|
||||
}
|
||||
else {
|
||||
NS_RELEASE(view);
|
||||
}
|
||||
NS_RELEASE(pm);
|
||||
}
|
||||
|
||||
NS_RELEASE(pm);
|
||||
NS_RELEASE(cv);
|
||||
}
|
||||
|
||||
NS_RELEASE(cv);
|
||||
NS_RELEASE(container);
|
||||
}
|
||||
|
||||
NS_RELEASE(container);
|
||||
}
|
||||
NS_RELEASE(atom);
|
||||
}
|
||||
else {
|
||||
NS_RELEASE(view);
|
||||
}
|
||||
#endif
|
||||
|
||||
aStatus = NS_FRAME_COMPLETE;
|
||||
return NS_OK;
|
||||
|
@ -356,3 +395,29 @@ NS_NewObjectFrame(nsIFrame*& aFrameResult, nsIContent* aContent,
|
|||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsObjectFrame::SetURL(const nsString& aURLSpec)
|
||||
{
|
||||
if (nsnull != mURLSpec) {
|
||||
delete mURLSpec;
|
||||
}
|
||||
mURLSpec = new nsString(aURLSpec);
|
||||
if (nsnull == mURLSpec) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsObjectFrame::SetBaseHREF(const nsString& aBaseHREF)
|
||||
{
|
||||
if (nsnull != mBaseHREF) {
|
||||
delete mBaseHREF;
|
||||
}
|
||||
mBaseHREF = new nsString(aBaseHREF);
|
||||
if (nsnull == mBaseHREF) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче