diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp
index 3717059a67c..64f0cc50934 100644
--- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp
+++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp
@@ -40,6 +40,8 @@
#include "nsRepository.h"
+extern nsresult NS_NewHTMLIFrame(nsIHTMLContent** aInstancePtrResult,
+ nsIAtom* aTag); // XXX move
// XXX attribute values have entities in them - use the parsers expander!
// XXX Go through a factory for this one
@@ -173,6 +175,8 @@ protected:
nsresult ProcessCloseOPTIONTag(const nsIParserNode& aNode);
nsresult ProcessOPTIONTagContent(const nsIParserNode& aNode);
+ nsresult ProcessIFRAMETag(nsIHTMLContent** aInstancePtrResult,
+ const nsIParserNode& aNode);
//----------------------------------------------------------------------
void GetAttributeValueAt(const nsIParserNode& aNode,
@@ -557,6 +561,10 @@ PRInt32 HTMLContentSink::OpenContainer(const nsIParserNode& aNode)
rv = ProcessOpenOPTIONTag(&container, aNode);
break;
+ case eHTMLTag_iframe:
+ rv = ProcessIFRAMETag(&container, aNode);
+ break;
+
default:
rv = NS_NewHTMLContainer(&container, atom);
break;
@@ -1306,6 +1314,20 @@ HTMLContentSink::ProcessOPTIONTagContent(const nsIParserNode& aNode)
return NS_OK;
}
+nsresult
+HTMLContentSink::ProcessIFRAMETag(nsIHTMLContent** aInstancePtrResult,
+ const nsIParserNode& aNode)
+{
+ nsAutoString tmp(aNode.GetText());
+ tmp.ToUpperCase();
+ nsIAtom* atom = NS_NewAtom(tmp);
+
+ nsresult rv = NS_NewHTMLIFrame(aInstancePtrResult, atom);
+
+ NS_RELEASE(atom);
+ return rv;
+}
+
nsresult HTMLContentSink::ProcessWBRTag(nsIHTMLContent** aInstancePtrResult,
const nsIParserNode& aNode)
{
diff --git a/mozilla/layout/generic/nsHTMLContainerFrame.cpp b/mozilla/layout/generic/nsHTMLContainerFrame.cpp
index 98bfe78ca04..12ea5df79c8 100644
--- a/mozilla/layout/generic/nsHTMLContainerFrame.cpp
+++ b/mozilla/layout/generic/nsHTMLContainerFrame.cpp
@@ -36,7 +36,7 @@
#include "nsIContentDelegate.h"
#include "nsIHTMLContent.h"
#include "nsHTMLParts.h"
-#include "nsHTMLFrame.h"
+#include "nsHTMLBase.h"
#include "nsScrollFrame.h"
#include "nsIView.h"
#include "nsIReflowCommand.h"
@@ -256,7 +256,7 @@ nsHTMLContainerFrame::CreateFrameFor(nsIPresContext* aPresContext,
}
if (NS_OK == rv) {
// Wrap the frame in a view if necessary
- rv = nsHTMLFrame::CreateViewForFrame(aPresContext, frame, aStyleContext,
+ rv = nsHTMLBase::CreateViewForFrame(aPresContext, frame, aStyleContext,
PR_FALSE);
}
aResult = frame;
diff --git a/mozilla/layout/generic/nsLineLayout.cpp b/mozilla/layout/generic/nsLineLayout.cpp
index 9796a35e144..60bc7d2f521 100644
--- a/mozilla/layout/generic/nsLineLayout.cpp
+++ b/mozilla/layout/generic/nsLineLayout.cpp
@@ -30,7 +30,7 @@
#include "nsCRT.h"
#include "nsIReflowCommand.h"
#include "nsIFontMetrics.h"
-#include "nsHTMLFrame.h"
+#include "nsHTMLBase.h"
#include "nsScrollFrame.h"
#undef NOISY_REFLOW
@@ -1487,7 +1487,7 @@ nsLineLayout::CreateFrameFor(nsIContent* aKid)
}
if (NS_OK == rv) {
// Wrap the frame in a view if necessary
- rv = nsHTMLFrame::CreateViewForFrame(mPresContext, kidFrame, kidSC,
+ rv = nsHTMLBase::CreateViewForFrame(mPresContext, kidFrame, kidSC,
PR_FALSE);
if (NS_OK != rv) {
return rv;
diff --git a/mozilla/layout/html/base/src/Makefile b/mozilla/layout/html/base/src/Makefile
index 0974c25af65..38b8b9a0e8a 100644
--- a/mozilla/layout/html/base/src/Makefile
+++ b/mozilla/layout/html/base/src/Makefile
@@ -29,11 +29,11 @@ CPPSRCS = \
nsGlobalVariables.cpp \
nsHRPart.cpp \
nsHTMLAtoms.cpp \
+ nsHTMLBase.cpp \
nsHTMLBullet.cpp \
nsHTMLContainer.cpp \
nsHTMLContainerFrame.cpp \
nsHTMLContent.cpp \
- nsHTMLFrame.cpp \
nsHTMLHead.cpp \
nsHTMLIIDs.cpp \
nsHTMLImage.cpp \
diff --git a/mozilla/layout/html/base/src/makefile.win b/mozilla/layout/html/base/src/makefile.win
index 8882bf96507..00632157b50 100644
--- a/mozilla/layout/html/base/src/makefile.win
+++ b/mozilla/layout/html/base/src/makefile.win
@@ -31,11 +31,11 @@ CPPSRCS= \
nsGlobalVariables.cpp \
nsHRPart.cpp \
nsHTMLAtoms.cpp \
+ nsHTMLBase.cpp \
nsHTMLBullet.cpp \
nsHTMLContainer.cpp \
nsHTMLContainerFrame.cpp \
nsHTMLContent.cpp \
- nsHTMLFrame.cpp \
nsHTMLHead.cpp \
nsHTMLIIDs.cpp \
nsHTMLImage.cpp \
@@ -65,11 +65,11 @@ CPP_OBJS= \
.\$(OBJDIR)\nsGlobalVariables.obj \
.\$(OBJDIR)\nsHRPart.obj \
.\$(OBJDIR)\nsHTMLAtoms.obj \
+ .\$(OBJDIR)\nsHTMLBase.obj \
.\$(OBJDIR)\nsHTMLBullet.obj \
.\$(OBJDIR)\nsHTMLContainer.obj \
.\$(OBJDIR)\nsHTMLContainerFrame.obj \
.\$(OBJDIR)\nsHTMLContent.obj \
- .\$(OBJDIR)\nsHTMLFrame.obj \
.\$(OBJDIR)\nsHTMLHead.obj \
.\$(OBJDIR)\nsHTMLIIDs.obj \
.\$(OBJDIR)\nsHTMLImage.obj \
diff --git a/mozilla/layout/generic/nsHTMLFrame.cpp b/mozilla/layout/html/base/src/nsHTMLBase.cpp
similarity index 92%
rename from mozilla/layout/generic/nsHTMLFrame.cpp
rename to mozilla/layout/html/base/src/nsHTMLBase.cpp
index d28e561d87f..38c23b752db 100644
--- a/mozilla/layout/generic/nsHTMLFrame.cpp
+++ b/mozilla/layout/html/base/src/nsHTMLBase.cpp
@@ -15,7 +15,7 @@
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
-#include "nsHTMLFrame.h"
+#include "nsHTMLBase.h"
#include "nsFrame.h"
#include "nsIStyleContext.h"
#include "nsStyleConsts.h"
@@ -24,7 +24,7 @@
#include "nsIViewManager.h"
nsresult
-nsHTMLFrame::CreateViewForFrame(nsIPresContext* aPresContext,
+nsHTMLBase::CreateViewForFrame(nsIPresContext* aPresContext,
nsIFrame* aFrame,
nsIStyleContext* aStyleContext,
PRBool aForce)
@@ -55,7 +55,7 @@ nsHTMLFrame::CreateViewForFrame(nsIPresContext* aPresContext,
// If the opacities are different then I need a view
if (myColor->mOpacity != parentColor->mOpacity) {
NS_FRAME_LOG(NS_FRAME_TRACE_CALLS,
- ("nsHTMLFrame::CreateViewForFrame: frame=%p opacity=%g parentOpacity=%g",
+ ("nsHTMLBase::CreateViewForFrame: frame=%p opacity=%g parentOpacity=%g",
aFrame, myColor->mOpacity, parentColor->mOpacity));
aForce = PR_TRUE;
}
@@ -69,7 +69,7 @@ nsHTMLFrame::CreateViewForFrame(nsIPresContext* aPresContext,
aStyleContext->GetStyleData(eStyleStruct_Position);
if (NS_STYLE_POSITION_RELATIVE == position->mPosition) {
NS_FRAME_LOG(NS_FRAME_TRACE_CALLS,
- ("nsHTMLFrame::CreateViewForFrame: frame=%p relatively positioned",
+ ("nsHTMLBase::CreateViewForFrame: frame=%p relatively positioned",
aFrame));
aForce = PR_TRUE;
}
@@ -116,7 +116,7 @@ nsHTMLFrame::CreateViewForFrame(nsIPresContext* aPresContext,
NS_RELEASE(parView);
NS_FRAME_LOG(NS_FRAME_TRACE_CALLS,
- ("nsHTMLFrame::CreateViewForFrame: frame=%p view=%p",
+ ("nsHTMLBase::CreateViewForFrame: frame=%p view=%p",
aFrame));
return result;
}
diff --git a/mozilla/layout/html/base/src/nsHTMLFrame.h b/mozilla/layout/html/base/src/nsHTMLBase.h
similarity index 93%
rename from mozilla/layout/html/base/src/nsHTMLFrame.h
rename to mozilla/layout/html/base/src/nsHTMLBase.h
index e56d0ebb87d..68b2f4decc2 100644
--- a/mozilla/layout/html/base/src/nsHTMLFrame.h
+++ b/mozilla/layout/html/base/src/nsHTMLBase.h
@@ -15,14 +15,14 @@
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
-#ifndef nsHTMLFrame_h___
-#define nsHTMLFrame_h___
+#ifndef nsHTMLBase_h___
+#define nsHTMLBase_h___
#include "nsIFrame.h"
// This is a class whose purpose is to provide shared code that is
// common to all html frames, including containers and leaf frames.
-class nsHTMLFrame {
+class nsHTMLBase {
public:
/**
* Create a view for a frame if it needs one. A frame needs a view
@@ -35,4 +35,4 @@ public:
PRBool aForce);
};
-#endif /* nsHTMLFrame_h___ */
+#endif /* nsHTMLBase_h___ */
diff --git a/mozilla/layout/html/base/src/nsHTMLBullet.cpp b/mozilla/layout/html/base/src/nsHTMLBullet.cpp
index 929eb7d9a39..5666a8a6fc5 100644
--- a/mozilla/layout/html/base/src/nsHTMLBullet.cpp
+++ b/mozilla/layout/html/base/src/nsHTMLBullet.cpp
@@ -29,7 +29,7 @@
#include "nsHTMLIIDs.h"
#include "nsHTMLImage.h"
#include "prprf.h"
-#include "nsHTMLFrame.h"
+#include "nsHTMLBase.h"
#include "nsIView.h"
class Bullet : public nsHTMLTagContent {
@@ -526,7 +526,7 @@ BulletFrame::GetDesiredSize(nsIPresContext* aCX,
mImageLoader.SetURL(myList->mListStyleImage);
mImageLoader.GetDesiredSize(aCX, aReflowState, aDesiredSize);
if (!mImageLoader.GetLoadImageFailed()) {
- nsHTMLFrame::CreateViewForFrame(aCX, this, mStyleContext, PR_FALSE);
+ nsHTMLBase::CreateViewForFrame(aCX, this, mStyleContext, PR_FALSE);
aDesiredSize.ascent = aDesiredSize.height;
aDesiredSize.descent = 0;
return;
diff --git a/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp b/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp
index 98bfe78ca04..12ea5df79c8 100644
--- a/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp
+++ b/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp
@@ -36,7 +36,7 @@
#include "nsIContentDelegate.h"
#include "nsIHTMLContent.h"
#include "nsHTMLParts.h"
-#include "nsHTMLFrame.h"
+#include "nsHTMLBase.h"
#include "nsScrollFrame.h"
#include "nsIView.h"
#include "nsIReflowCommand.h"
@@ -256,7 +256,7 @@ nsHTMLContainerFrame::CreateFrameFor(nsIPresContext* aPresContext,
}
if (NS_OK == rv) {
// Wrap the frame in a view if necessary
- rv = nsHTMLFrame::CreateViewForFrame(aPresContext, frame, aStyleContext,
+ rv = nsHTMLBase::CreateViewForFrame(aPresContext, frame, aStyleContext,
PR_FALSE);
}
aResult = frame;
diff --git a/mozilla/layout/html/base/src/nsHTMLFrame.cpp b/mozilla/layout/html/base/src/nsHTMLFrame.cpp
deleted file mode 100644
index d28e561d87f..00000000000
--- a/mozilla/layout/html/base/src/nsHTMLFrame.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-/* -*- 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.0 (the "NPL"); you may not use this file except in
- * compliance with the NPL. You may obtain a copy of the NPL at
- * http://www.mozilla.org/NPL/
- *
- * Software distributed under the NPL is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
- * for the specific language governing rights and limitations under the
- * NPL.
- *
- * The Initial Developer of this code under the NPL is Netscape
- * Communications Corporation. Portions created by Netscape are
- * Copyright (C) 1998 Netscape Communications Corporation. All Rights
- * Reserved.
- */
-#include "nsHTMLFrame.h"
-#include "nsFrame.h"
-#include "nsIStyleContext.h"
-#include "nsStyleConsts.h"
-#include "nsViewsCID.h"
-#include "nsIView.h"
-#include "nsIViewManager.h"
-
-nsresult
-nsHTMLFrame::CreateViewForFrame(nsIPresContext* aPresContext,
- nsIFrame* aFrame,
- nsIStyleContext* aStyleContext,
- PRBool aForce)
-{
- nsIView* view;
- aFrame->GetView(view);
- if (nsnull == view) {
- // We don't yet have a view; see if we need a view
-
- PRBool scrollView = PR_FALSE;
-
- // See if the opacity is not the same as the geometric parent
- // frames opacity.
- if (!aForce) {
- nsIFrame* parent;
- aFrame->GetGeometricParent(parent);
- if (nsnull != parent) {
- // Get my nsStyleColor
- const nsStyleColor* myColor = (const nsStyleColor*)
- aStyleContext->GetStyleData(eStyleStruct_Color);
-
- // Get parent's nsStyleColor
- nsIStyleContext* parentSC;
- parent->GetStyleContext(aPresContext, parentSC);
- const nsStyleColor* parentColor = (const nsStyleColor*)
- parentSC->GetStyleData(eStyleStruct_Color);
-
- // If the opacities are different then I need a view
- if (myColor->mOpacity != parentColor->mOpacity) {
- NS_FRAME_LOG(NS_FRAME_TRACE_CALLS,
- ("nsHTMLFrame::CreateViewForFrame: frame=%p opacity=%g parentOpacity=%g",
- aFrame, myColor->mOpacity, parentColor->mOpacity));
- aForce = PR_TRUE;
- }
- NS_RELEASE(parentSC);
- }
- }
-
- // See if the frame is being relatively positioned
- if (!aForce) {
- const nsStylePosition* position = (const nsStylePosition*)
- aStyleContext->GetStyleData(eStyleStruct_Position);
- if (NS_STYLE_POSITION_RELATIVE == position->mPosition) {
- NS_FRAME_LOG(NS_FRAME_TRACE_CALLS,
- ("nsHTMLFrame::CreateViewForFrame: frame=%p relatively positioned",
- aFrame));
- aForce = PR_TRUE;
- }
- }
-
- if (aForce) {
- // Create a view
- nsIFrame* parent;
- nsIView* view;
-
- aFrame->GetParentWithView(parent);
- NS_ASSERTION(parent, "GetParentWithView failed");
- nsIView* parView;
-
- parent->GetView(parView);
- NS_ASSERTION(parView, "no parent with view");
-
- // Create a view
- static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
- static NS_DEFINE_IID(kIViewIID, NS_IVIEW_IID);
-
- nsresult result = NSRepository::CreateInstance(kViewCID,
- nsnull,
- kIViewIID,
- (void **)&view);
- if (NS_OK == result) {
- nsIView* rootView = parView;
- nsIViewManager* viewManager = rootView->GetViewManager();
-
- // Initialize the view
- NS_ASSERTION(nsnull != viewManager, "null view manager");
-
- nsRect bounds;
- aFrame->GetRect(bounds);
- view->Init(viewManager, bounds, rootView);
- viewManager->InsertChild(rootView, view, 0);
-
- NS_RELEASE(viewManager);
- }
-
- // Remember our view
- aFrame->SetView(view);
- NS_RELEASE(view);
- NS_RELEASE(parView);
-
- NS_FRAME_LOG(NS_FRAME_TRACE_CALLS,
- ("nsHTMLFrame::CreateViewForFrame: frame=%p view=%p",
- aFrame));
- return result;
- }
- }
- return NS_OK;
-}
diff --git a/mozilla/layout/html/base/src/nsHTMLImage.cpp b/mozilla/layout/html/base/src/nsHTMLImage.cpp
index a1d9f66f3ff..c13344229a8 100644
--- a/mozilla/layout/html/base/src/nsHTMLImage.cpp
+++ b/mozilla/layout/html/base/src/nsHTMLImage.cpp
@@ -37,7 +37,7 @@
#include "nsILinkHandler.h"
#include "nsIURL.h"
#include "nsCSSLayout.h"
-#include "nsHTMLFrame.h"
+#include "nsHTMLBase.h"
#include "prprf.h"
#include "nsISizeOfHandler.h"
@@ -372,7 +372,7 @@ ImageFrame::GetDesiredSize(nsIPresContext* aPresContext,
const nsReflowState& aReflowState,
nsReflowMetrics& aDesiredSize)
{
- nsHTMLFrame::CreateViewForFrame(aPresContext, this, mStyleContext, PR_TRUE);
+ nsHTMLBase::CreateViewForFrame(aPresContext, this, mStyleContext, PR_TRUE);
// Setup url before starting the image load
nsAutoString src;
diff --git a/mozilla/layout/html/base/src/nsLineLayout.cpp b/mozilla/layout/html/base/src/nsLineLayout.cpp
index 9796a35e144..60bc7d2f521 100644
--- a/mozilla/layout/html/base/src/nsLineLayout.cpp
+++ b/mozilla/layout/html/base/src/nsLineLayout.cpp
@@ -30,7 +30,7 @@
#include "nsCRT.h"
#include "nsIReflowCommand.h"
#include "nsIFontMetrics.h"
-#include "nsHTMLFrame.h"
+#include "nsHTMLBase.h"
#include "nsScrollFrame.h"
#undef NOISY_REFLOW
@@ -1487,7 +1487,7 @@ nsLineLayout::CreateFrameFor(nsIContent* aKid)
}
if (NS_OK == rv) {
// Wrap the frame in a view if necessary
- rv = nsHTMLFrame::CreateViewForFrame(mPresContext, kidFrame, kidSC,
+ rv = nsHTMLBase::CreateViewForFrame(mPresContext, kidFrame, kidSC,
PR_FALSE);
if (NS_OK != rv) {
return rv;
diff --git a/mozilla/layout/html/base/src/nsScrollFrame.cpp b/mozilla/layout/html/base/src/nsScrollFrame.cpp
index 077b232df9d..fd0f4ec4047 100644
--- a/mozilla/layout/html/base/src/nsScrollFrame.cpp
+++ b/mozilla/layout/html/base/src/nsScrollFrame.cpp
@@ -26,7 +26,7 @@
#include "nsIView.h"
#include "nsIViewManager.h"
#include "nsBodyFrame.h"
-#include "nsHTMLFrame.h"
+#include "nsHTMLBase.h"
#include "nsCSSLayout.h"
#include "nsBodyFrame.h"
@@ -53,7 +53,7 @@ protected:
nsScrollBodyFrame::nsScrollBodyFrame(nsIContent* aContent, nsIFrame* aParent)
: nsContainerFrame(aContent, aParent)
{
- nsHTMLFrame::CreateViewForFrame(nsnull, this, nsnull, PR_TRUE);
+ nsHTMLBase::CreateViewForFrame(nsnull, this, nsnull, PR_TRUE);
}
void
diff --git a/mozilla/layout/html/document/src/Makefile b/mozilla/layout/html/document/src/Makefile
index 506264301b9..bc1a0903d0d 100644
--- a/mozilla/layout/html/document/src/Makefile
+++ b/mozilla/layout/html/document/src/Makefile
@@ -35,6 +35,7 @@ INCLUDES += \
CPPSRCS = \
nsHTMLContentSink.cpp \
nsHTMLDocument.cpp \
+ nsHTMLIFrame.cpp \
$(NULL)
EXPORTS = \
diff --git a/mozilla/layout/html/document/src/makefile.win b/mozilla/layout/html/document/src/makefile.win
index b5378d5d1ae..f0e40c68c5f 100644
--- a/mozilla/layout/html/document/src/makefile.win
+++ b/mozilla/layout/html/document/src/makefile.win
@@ -23,10 +23,10 @@ REQUIRES=xpcom raptor
DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
-CPPSRCS=nsHTMLContentSink.cpp nsHTMLDocument.cpp
+CPPSRCS=nsHTMLContentSink.cpp nsHTMLDocument.cpp nsHTMLIFrame.cpp
CPP_OBJS=.\$(OBJDIR)\nsHTMLContentSink.obj \
- .\$(OBJDIR)\nsHTMLDocument.obj
+ .\$(OBJDIR)\nsHTMLDocument.obj nsHTMLIFrame.obj
EXPORTS = \
nsIHTMLDocument.h \
diff --git a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp
index 3717059a67c..64f0cc50934 100644
--- a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp
+++ b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp
@@ -40,6 +40,8 @@
#include "nsRepository.h"
+extern nsresult NS_NewHTMLIFrame(nsIHTMLContent** aInstancePtrResult,
+ nsIAtom* aTag); // XXX move
// XXX attribute values have entities in them - use the parsers expander!
// XXX Go through a factory for this one
@@ -173,6 +175,8 @@ protected:
nsresult ProcessCloseOPTIONTag(const nsIParserNode& aNode);
nsresult ProcessOPTIONTagContent(const nsIParserNode& aNode);
+ nsresult ProcessIFRAMETag(nsIHTMLContent** aInstancePtrResult,
+ const nsIParserNode& aNode);
//----------------------------------------------------------------------
void GetAttributeValueAt(const nsIParserNode& aNode,
@@ -557,6 +561,10 @@ PRInt32 HTMLContentSink::OpenContainer(const nsIParserNode& aNode)
rv = ProcessOpenOPTIONTag(&container, aNode);
break;
+ case eHTMLTag_iframe:
+ rv = ProcessIFRAMETag(&container, aNode);
+ break;
+
default:
rv = NS_NewHTMLContainer(&container, atom);
break;
@@ -1306,6 +1314,20 @@ HTMLContentSink::ProcessOPTIONTagContent(const nsIParserNode& aNode)
return NS_OK;
}
+nsresult
+HTMLContentSink::ProcessIFRAMETag(nsIHTMLContent** aInstancePtrResult,
+ const nsIParserNode& aNode)
+{
+ nsAutoString tmp(aNode.GetText());
+ tmp.ToUpperCase();
+ nsIAtom* atom = NS_NewAtom(tmp);
+
+ nsresult rv = NS_NewHTMLIFrame(aInstancePtrResult, atom);
+
+ NS_RELEASE(atom);
+ return rv;
+}
+
nsresult HTMLContentSink::ProcessWBRTag(nsIHTMLContent** aInstancePtrResult,
const nsIParserNode& aNode)
{
diff --git a/mozilla/layout/html/document/src/nsHTMLIFrame.cpp b/mozilla/layout/html/document/src/nsHTMLIFrame.cpp
new file mode 100644
index 00000000000..5ee67d2d0dc
--- /dev/null
+++ b/mozilla/layout/html/document/src/nsHTMLIFrame.cpp
@@ -0,0 +1,185 @@
+/* -*- 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.0 (the "NPL"); you may not use this file except in
+ * compliance with the NPL. You may obtain a copy of the NPL at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the NPL is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
+ * for the specific language governing rights and limitations under the
+ * NPL.
+ *
+ * The Initial Developer of this code under the NPL is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All Rights
+ * Reserved.
+ */
+
+#include "nsHTMLContainer.h"
+#include "nsLeafFrame.h"
+#include "nsIWebWidget.h"
+#include "nsIPresContext.h"
+#include "nsHTMLIIDs.h"
+#include "nsRepository.h"
+
+class nsHTMLIFrameFrame : public nsLeafFrame {
+
+public:
+
+ nsHTMLIFrameFrame(nsIContent* aContent, nsIFrame* aParentFrame);
+
+ /**
+ * @see nsIFrame::Paint
+ */
+ NS_IMETHOD Paint(nsIPresContext& aPresContext,
+ nsIRenderingContext& aRenderingContext,
+ const nsRect& aDirtyRect);
+
+ /**
+ * @see nsIFrame::Reflow
+ */
+ NS_IMETHOD Reflow(nsIPresContext* aCX,
+ nsReflowMetrics& aDesiredSize,
+ const nsReflowState& aReflowState,
+ nsReflowStatus& aStatus);
+
+
+protected:
+
+ virtual ~nsHTMLIFrameFrame();
+
+ virtual void GetDesiredSize(nsIPresContext* aPresContext,
+ const nsReflowState& aReflowState,
+ nsReflowMetrics& aDesiredSize);
+
+ nsIWebWidget* mWebWidget;
+};
+
+class nsHTMLIFrame : public nsHTMLContainer {
+public:
+
+ virtual nsresult CreateFrame(nsIPresContext* aPresContext,
+ nsIFrame* aParentFrame,
+ nsIStyleContext* aStyleContext,
+ nsIFrame*& aResult);
+
+#if 0
+ virtual nsContentAttr GetAttribute(nsIAtom* aAttribute,
+ nsHTMLValue& aValue) const;
+
+ virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue);
+#endif
+
+protected:
+ nsHTMLIFrame(nsIAtom* aTag);
+ virtual ~nsHTMLIFrame();
+
+ friend nsresult NS_NewHTMLIFrame(nsIHTMLContent** aInstancePtrResult,
+ nsIAtom* aTag);
+
+};
+
+// nsHTMLIFrameFrame
+
+nsHTMLIFrameFrame::nsHTMLIFrameFrame(nsIContent* aContent, nsIFrame* aParentFrame)
+ : nsLeafFrame(aContent, aParentFrame)
+{
+ mWebWidget = nsnull;
+}
+
+nsHTMLIFrameFrame::~nsHTMLIFrameFrame()
+{
+}
+
+NS_IMETHODIMP
+nsHTMLIFrameFrame::Paint(nsIPresContext& aPresContext,
+ nsIRenderingContext& aRenderingContext,
+ const nsRect& aDirtyRect)
+{
+ //mWebWidget->Show();
+ return NS_OK;
+}
+
+
+static NS_DEFINE_IID(kCWebWidget, NS_WEBWIDGET_CID);
+static NS_DEFINE_IID(kIWebWidget, NS_IWEBWIDGET_IID);
+
+NS_IMETHODIMP
+nsHTMLIFrameFrame::Reflow(nsIPresContext* aPresContext,
+ nsReflowMetrics& aDesiredSize,
+ const nsReflowState& aReflowState,
+ nsReflowStatus& aStatus)
+{
+ GetDesiredSize(aPresContext, aReflowState, aDesiredSize);
+
+ if (nsnull == mWebWidget) {
+ NSRepository::CreateInstance(kCWebWidget, nsnull, kIWebWidget, (void**)&mWebWidget);
+ if (nsnull != mWebWidget) {
+ nsRect rect(0, 0, aDesiredSize.width, aDesiredSize.height);
+ nsIWidget* parentWin;
+ GetWindow(parentWin);
+ mWebWidget->Init(parentWin->GetNativeData(NS_NATIVE_WINDOW), rect);
+ NS_IF_RELEASE(parentWin);
+ //mWebWidget->Show();
+ }
+ else {
+ NS_ASSERTION(0, "could not instantiate web widget for sub document");
+ }
+ }
+ aStatus = NS_FRAME_COMPLETE;
+ return NS_OK;
+}
+
+void
+nsHTMLIFrameFrame::GetDesiredSize(nsIPresContext* aPresContext,
+ const nsReflowState& aReflowState,
+ nsReflowMetrics& aDesiredSize)
+{
+ float p2t = aPresContext->GetPixelsToTwips();
+ aDesiredSize.width = (int) (p2t * 200);
+ aDesiredSize.height = (int) (p2t * 200);
+ aDesiredSize.ascent = aDesiredSize.height;
+ aDesiredSize.descent = 0;
+}
+
+// nsHTMLIFrame
+
+nsHTMLIFrame::nsHTMLIFrame(nsIAtom* aTag) : nsHTMLContainer(aTag)
+{
+}
+
+nsHTMLIFrame::~nsHTMLIFrame()
+{
+}
+
+nsresult
+nsHTMLIFrame::CreateFrame(nsIPresContext* aPresContext,
+ nsIFrame* aParentFrame,
+ nsIStyleContext* aStyleContext,
+ nsIFrame*& aResult)
+{
+ nsIFrame* frame = new nsHTMLIFrameFrame(this, aParentFrame);
+ if (nsnull == frame) {
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
+ aResult = frame;
+ return NS_OK;
+}
+
+nsresult
+NS_NewHTMLIFrame(nsIHTMLContent** aInstancePtrResult,
+ nsIAtom* aTag)
+{
+ NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
+ if (nsnull == aInstancePtrResult) {
+ return NS_ERROR_NULL_POINTER;
+ }
+
+ nsIHTMLContent* it = new nsHTMLIFrame(aTag);
+
+ if (nsnull == it) {
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
+ return it->QueryInterface(kIHTMLContentIID, (void**) aInstancePtrResult);
+}
diff --git a/mozilla/webshell/public/nsIWebWidget.h b/mozilla/webshell/public/nsIWebWidget.h
index 9e173720dbb..ba18401f179 100644
--- a/mozilla/webshell/public/nsIWebWidget.h
+++ b/mozilla/webshell/public/nsIWebWidget.h
@@ -31,6 +31,12 @@ class nsIScriptContext;
{ 0x02606880, 0x94e1, 0x11d1, \
{0x89, 0x5c, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81} }
+// XXX this doesn't belong here, but to put it elsewhere requires a new header
+// CID for the web widget
+#define NS_WEBWIDGET_CID \
+{ 0xc552f181, 0x8d, 0x11d2, \
+ { 0x80, 0x32, 0x0, 0x60, 0x8, 0x15, 0xa7, 0x91 } }
+
// Interface to the web widget. The web widget is a container for web
// content.
class nsIWebWidget : public nsIDocumentWidget {
diff --git a/mozilla/webshell/src/nsWebWidget.cpp b/mozilla/webshell/src/nsWebWidget.cpp
index 9bd3b5e0ba2..3cdb67390f6 100644
--- a/mozilla/webshell/src/nsWebWidget.cpp
+++ b/mozilla/webshell/src/nsWebWidget.cpp
@@ -39,10 +39,13 @@
#include "nsIScriptObjectOwner.h"
#include "nsICSSParser.h"
#include "nsIDOMDocument.h"
-
#include "prprf.h"
#include "prtime.h"
+#include "nscore.h"
+#include "nsIFactory.h"
+#include "nsISupports.h"
+
#define UA_CSS_URL "resource:/res/ua.css"
#define GET_OUTER() \
@@ -749,5 +752,137 @@ nsresult WebWidgetImpl::GetScriptObject(JSContext *aContext, void** aScriptObjec
return res;
}
+/*******************************************
+/* nsWebWidgetFactory
+/*******************************************/
+
+static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
+static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
+static NS_DEFINE_IID(kCWebWidget, NS_WEBWIDGET_CID);
+
+class nsWebWidgetFactory : public nsIFactory
+{
+ public:
+ // nsISupports methods
+ NS_IMETHOD QueryInterface(const nsIID &aIID,
+ void **aResult);
+ NS_IMETHOD_(nsrefcnt) AddRef(void);
+ NS_IMETHOD_(nsrefcnt) Release(void);
+
+ // nsIFactory methods
+ NS_IMETHOD CreateInstance(nsISupports *aOuter,
+ const nsIID &aIID,
+ void **aResult);
+
+ NS_IMETHOD LockFactory(PRBool aLock);
+
+ nsWebWidgetFactory(const nsCID &aClass);
+ ~nsWebWidgetFactory();
+
+ private:
+ nsrefcnt mRefCnt;
+ nsCID mClassID;
+};
+
+nsWebWidgetFactory::nsWebWidgetFactory(const nsCID &aClass)
+{
+ mRefCnt = 0;
+ mClassID = aClass;
+}
+
+nsWebWidgetFactory::~nsWebWidgetFactory()
+{
+ NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
+}
+
+nsresult nsWebWidgetFactory::QueryInterface(const nsIID &aIID,
+ void **aResult)
+{
+ if (aResult == NULL) {
+ return NS_ERROR_NULL_POINTER;
+ }
+
+ // Always NULL result, in case of failure
+ *aResult = NULL;
+
+ if (aIID.Equals(kISupportsIID)) {
+ *aResult = (void *)(nsISupports*)this;
+ } else if (aIID.Equals(kIFactoryIID)) {
+ *aResult = (void *)(nsIFactory*)this;
+ }
+
+ if (*aResult == NULL) {
+ return NS_NOINTERFACE;
+ }
+
+ AddRef(); // Increase reference count for caller
+ return NS_OK;
+}
+
+nsrefcnt nsWebWidgetFactory::AddRef()
+{
+ return ++mRefCnt;
+}
+
+nsrefcnt nsWebWidgetFactory::Release()
+{
+ if (--mRefCnt == 0) {
+ delete this;
+ return 0; // Don't access mRefCnt after deleting!
+ }
+ return mRefCnt;
+}
+
+nsresult nsWebWidgetFactory::CreateInstance(nsISupports *aOuter,
+ const nsIID &aIID,
+ void **aResult)
+{
+ if (aResult == NULL) {
+ return NS_ERROR_NULL_POINTER;
+ }
+
+ *aResult = NULL;
+
+ WebWidgetImpl *inst = nsnull;
+
+ if (mClassID.Equals(kCWebWidget)) {
+ inst = new WebWidgetImpl();
+ }
+
+ if (inst == NULL) {
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
+
+ nsresult res = inst->QueryInterface(aIID, aResult);
+
+ if (res != NS_OK) {
+ // We didn't get the right interface, so clean up
+ delete inst;
+ }
+
+ return res;
+}
+
+nsresult nsWebWidgetFactory::LockFactory(PRBool aLock)
+{
+ // Not implemented in simplest case.
+ return NS_OK;
+}
+
+// return the proper factory to the caller
+extern "C" NS_WEB nsresult NSGetFactory(const nsCID &aClass, nsIFactory **aFactory)
+{
+ if (nsnull == aFactory) {
+ return NS_ERROR_NULL_POINTER;
+ }
+
+ *aFactory = new nsWebWidgetFactory(aClass);
+
+ if (nsnull == aFactory) {
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
+
+ return (*aFactory)->QueryInterface(kIFactoryIID, (void**)aFactory);
+}
diff --git a/mozilla/webshell/tests/viewer/nsViewer.cpp b/mozilla/webshell/tests/viewer/nsViewer.cpp
index cd9a19ba383..ef7d692eac2 100644
--- a/mozilla/webshell/tests/viewer/nsViewer.cpp
+++ b/mozilla/webshell/tests/viewer/nsViewer.cpp
@@ -78,6 +78,7 @@ static NS_DEFINE_IID(kCRegionIID, NS_REGION_CID);
static NS_DEFINE_IID(kCViewManagerCID, NS_VIEW_MANAGER_CID);
static NS_DEFINE_IID(kCViewCID, NS_VIEW_CID);
static NS_DEFINE_IID(kCScrollingViewCID, NS_SCROLLING_VIEW_CID);
+static NS_DEFINE_IID(kCWebWidgetCID, NS_WEBWIDGET_CID);
#define SAMPLES_BASE_URL "resource:/res/samples"
@@ -1062,6 +1063,7 @@ nsDocLoader* nsViewer::SetupViewer(nsIWidget **aMainWindow, int argc, char **arg
NSRepository::RegisterFactory(kCViewManagerCID, VIEW_DLL, PR_FALSE, PR_FALSE);
NSRepository::RegisterFactory(kCViewCID, VIEW_DLL, PR_FALSE, PR_FALSE);
NSRepository::RegisterFactory(kCScrollingViewCID, VIEW_DLL, PR_FALSE, PR_FALSE);
+ NSRepository::RegisterFactory(kCWebWidgetCID, WEB_DLL, PR_FALSE, PR_FALSE);
// Create an application shell
nsresult res;
diff --git a/mozilla/webshell/tests/viewer/nsViewer.h b/mozilla/webshell/tests/viewer/nsViewer.h
index 992dadbae4a..f0f9eff08ef 100644
--- a/mozilla/webshell/tests/viewer/nsViewer.h
+++ b/mozilla/webshell/tests/viewer/nsViewer.h
@@ -30,10 +30,12 @@
#define WIDGET_DLL "raptorwidget.dll"
#define GFXWIN_DLL "raptorgfxwin.dll"
#define VIEW_DLL "raptorview.dll"
+#define WEB_DLL "raptorweb.dll"
#else
#define WIDGET_DLL "libwidgetunix.so"
#define GFXWIN_DLL "libgfxunix.so"
#define VIEW_DLL "libraptorview.so"
+#define WEB_DLL "libraptorweb.so"
#endif
#define MAXPATHLEN 1024