diff --git a/layout/html/content/src/nsHTMLApplet.cpp b/layout/html/content/src/nsHTMLApplet.cpp
index eb1596c93009..cb29dfcf9b42 100644
--- a/layout/html/content/src/nsHTMLApplet.cpp
+++ b/layout/html/content/src/nsHTMLApplet.cpp
@@ -1,35 +1,29 @@
/* -*- 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
+ * Version 1.0 (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 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.
+ * 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 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.
+ * 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.
*/
#include "nsHTMLParts.h"
#include "nsHTMLContainer.h"
#include "nsFrame.h"
#include "nsHTMLIIDs.h"
-
-// XXX temporary
-nsresult NS_NewAppletFrame(nsIFrame** aFrameResult, nsIContent* aContent,
- nsIFrame* aParentFrame)
-{
- nsFrame::NewFrame(aFrameResult, aContent, aParentFrame);
- if (nsnull == *aFrameResult) {
- return NS_ERROR_OUT_OF_MEMORY;
- }
- return NS_OK;
-}
+#include "nsHTMLAtoms.h"
+#include "nsIStyleContext.h"
+#include "nsIPresContext.h"
+#include "nsStyleConsts.h"
#define nsHTMLAppletSuper nsHTMLContainer
@@ -42,9 +36,17 @@ public:
nsIStyleContext* aStyleContext,
nsIFrame*& aResult);
+ void SetAttribute(nsIAtom* aAttribute, const nsString& aString);
+
+ virtual void MapAttributesInto(nsIStyleContext* aContext,
+ nsIPresContext* aPresContext);
+
protected:
virtual ~nsHTMLApplet();
- nsString mApplet;
+
+ nsContentAttr AttributeToString(nsIAtom* aAttribute,
+ nsHTMLValue& aValue,
+ nsString& aResult) const;
};
nsHTMLApplet::nsHTMLApplet(nsIAtom* aTag)
@@ -63,7 +65,7 @@ nsHTMLApplet::CreateFrame(nsIPresContext* aPresContext,
nsIFrame*& aResult)
{
nsIFrame* frame;
- nsresult rv = NS_NewAppletFrame(&frame, this, aParentFrame);
+ nsresult rv = NS_NewObjectFrame(frame, this, aParentFrame);
if (NS_OK != rv) {
return rv;
}
@@ -72,6 +74,80 @@ nsHTMLApplet::CreateFrame(nsIPresContext* aPresContext,
return NS_OK;
}
+void
+nsHTMLApplet::SetAttribute(nsIAtom* aAttribute, const nsString& aString)
+{
+ nsHTMLValue val;
+ if (aAttribute == nsHTMLAtoms::align) {
+ if (ParseAlignParam(aString, val)) {
+ // Reflect the attribute into the syle system
+ nsHTMLTagContent::SetAttribute(aAttribute, val);
+ }
+ }
+ else if (ParseImageProperty(aAttribute, aString, val)) {
+ nsHTMLTagContent::SetAttribute(aAttribute, val);
+ }
+ else {
+ nsHTMLAppletSuper::SetAttribute(aAttribute, aString);
+ }
+}
+
+nsContentAttr
+nsHTMLApplet::AttributeToString(nsIAtom* aAttribute,
+ nsHTMLValue& aValue,
+ nsString& aResult) const
+{
+ nsContentAttr ca = eContentAttr_NotThere;
+ if (aAttribute == nsHTMLAtoms::align) {
+ if (eHTMLUnit_Enumerated == aValue.GetUnit()) {
+ AlignParamToString(aValue, aResult);
+ ca = eContentAttr_HasValue;
+ }
+ }
+ else if (ImagePropertyToString(aAttribute, aValue, aResult)) {
+ ca = eContentAttr_HasValue;
+ }
+ return ca;
+}
+
+void
+nsHTMLApplet::MapAttributesInto(nsIStyleContext* aContext,
+ nsIPresContext* aPresContext)
+{
+ if (nsnull != mAttributes) {
+ nsHTMLValue value;
+ GetAttribute(nsHTMLAtoms::align, value);
+ if (value.GetUnit() == eHTMLUnit_Enumerated) {
+ PRUint8 align = value.GetIntValue();
+ nsStyleDisplay* display = (nsStyleDisplay*)
+ aContext->GetMutableStyleData(eStyleStruct_Display);
+ nsStyleText* text = (nsStyleText*)
+ aContext->GetMutableStyleData(eStyleStruct_Text);
+ nsStyleSpacing* spacing = (nsStyleSpacing*)
+ aContext->GetMutableStyleData(eStyleStruct_Spacing);
+ float p2t = aPresContext->GetPixelsToTwips();
+ nsStyleCoord three(nscoord(p2t*3));
+ switch (align) {
+ case NS_STYLE_TEXT_ALIGN_LEFT:
+ display->mFloats = NS_STYLE_FLOAT_LEFT;
+ spacing->mMargin.SetLeft(three);
+ spacing->mMargin.SetRight(three);
+ break;
+ case NS_STYLE_TEXT_ALIGN_RIGHT:
+ display->mFloats = NS_STYLE_FLOAT_RIGHT;
+ spacing->mMargin.SetLeft(three);
+ spacing->mMargin.SetRight(three);
+ break;
+ default:
+ text->mVerticalAlign.SetIntValue(align, eStyleUnit_Enumerated);
+ break;
+ }
+ }
+ }
+ MapImagePropertiesInto(aContext, aPresContext);
+ MapImageBorderInto(aContext, aPresContext, nsnull);
+}
+
nsresult
NS_NewHTMLApplet(nsIHTMLContent** aInstancePtrResult,
nsIAtom* aTag)
diff --git a/layout/html/content/src/nsHTMLObject.cpp b/layout/html/content/src/nsHTMLObject.cpp
index e8fbcb5cd1f2..aae1181afda8 100644
--- a/layout/html/content/src/nsHTMLObject.cpp
+++ b/layout/html/content/src/nsHTMLObject.cpp
@@ -1,36 +1,26 @@
/* -*- 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
+ * Version 1.0 (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 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.
+ * 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 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.
+ * 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.
*/
#include "nsHTMLParts.h"
#include "nsHTMLContainer.h"
#include "nsFrame.h"
#include "nsHTMLIIDs.h"
-// XXX temporary
-nsresult NS_NewObjectFrame(nsIFrame** aFrameResult, nsIContent* aContent,
- nsIFrame* aParentFrame)
-{
- nsFrame::NewFrame(aFrameResult, aContent, aParentFrame);
- if (nsnull == *aFrameResult) {
- return NS_ERROR_OUT_OF_MEMORY;
- }
- return NS_OK;
-}
-
#define nsHTMLObjectSuper nsHTMLContainer
class nsHTMLObject : public nsHTMLObjectSuper {
@@ -44,7 +34,6 @@ public:
protected:
virtual ~nsHTMLObject();
- nsString mObject;
};
nsHTMLObject::nsHTMLObject(nsIAtom* aTag)
@@ -63,7 +52,7 @@ nsHTMLObject::CreateFrame(nsIPresContext* aPresContext,
nsIFrame*& aResult)
{
nsIFrame* frame;
- nsresult rv = NS_NewObjectFrame(&frame, this, aParentFrame);
+ nsresult rv = NS_NewObjectFrame(frame, this, aParentFrame);
if (NS_OK != rv) {
return rv;
}