зеркало из https://github.com/mozilla/gecko-dev.git
Use NS_NewObjectFrame
This commit is contained in:
Родитель
d9b9fa893c
Коммит
4e2e0f5153
|
@ -1,35 +1,29 @@
|
||||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
/* -*- 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
|
* 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
|
* Version 1.0 (the "License"); you may not use this file except in
|
||||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
* compliance with the License. You may obtain a copy of the License at
|
||||||
* http://www.mozilla.org/NPL/
|
* http://www.mozilla.org/NPL/
|
||||||
*
|
*
|
||||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
* Software distributed under the License is distributed on an "AS IS"
|
||||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||||
* for the specific language governing rights and limitations under the
|
* the License for the specific language governing rights and limitations
|
||||||
* NPL.
|
* under the License.
|
||||||
*
|
*
|
||||||
* The Initial Developer of this code under the NPL is Netscape
|
* The Original Code is Mozilla Communicator client code.
|
||||||
* Communications Corporation. Portions created by Netscape are
|
*
|
||||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
* The Initial Developer of the Original Code is Netscape Communications
|
||||||
* Reserved.
|
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||||
|
* Netscape Communications Corporation. All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
#include "nsHTMLParts.h"
|
#include "nsHTMLParts.h"
|
||||||
#include "nsHTMLContainer.h"
|
#include "nsHTMLContainer.h"
|
||||||
#include "nsFrame.h"
|
#include "nsFrame.h"
|
||||||
#include "nsHTMLIIDs.h"
|
#include "nsHTMLIIDs.h"
|
||||||
|
#include "nsHTMLAtoms.h"
|
||||||
// XXX temporary
|
#include "nsIStyleContext.h"
|
||||||
nsresult NS_NewAppletFrame(nsIFrame** aFrameResult, nsIContent* aContent,
|
#include "nsIPresContext.h"
|
||||||
nsIFrame* aParentFrame)
|
#include "nsStyleConsts.h"
|
||||||
{
|
|
||||||
nsFrame::NewFrame(aFrameResult, aContent, aParentFrame);
|
|
||||||
if (nsnull == *aFrameResult) {
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define nsHTMLAppletSuper nsHTMLContainer
|
#define nsHTMLAppletSuper nsHTMLContainer
|
||||||
|
|
||||||
|
@ -42,9 +36,17 @@ public:
|
||||||
nsIStyleContext* aStyleContext,
|
nsIStyleContext* aStyleContext,
|
||||||
nsIFrame*& aResult);
|
nsIFrame*& aResult);
|
||||||
|
|
||||||
|
void SetAttribute(nsIAtom* aAttribute, const nsString& aString);
|
||||||
|
|
||||||
|
virtual void MapAttributesInto(nsIStyleContext* aContext,
|
||||||
|
nsIPresContext* aPresContext);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~nsHTMLApplet();
|
virtual ~nsHTMLApplet();
|
||||||
nsString mApplet;
|
|
||||||
|
nsContentAttr AttributeToString(nsIAtom* aAttribute,
|
||||||
|
nsHTMLValue& aValue,
|
||||||
|
nsString& aResult) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
nsHTMLApplet::nsHTMLApplet(nsIAtom* aTag)
|
nsHTMLApplet::nsHTMLApplet(nsIAtom* aTag)
|
||||||
|
@ -63,7 +65,7 @@ nsHTMLApplet::CreateFrame(nsIPresContext* aPresContext,
|
||||||
nsIFrame*& aResult)
|
nsIFrame*& aResult)
|
||||||
{
|
{
|
||||||
nsIFrame* frame;
|
nsIFrame* frame;
|
||||||
nsresult rv = NS_NewAppletFrame(&frame, this, aParentFrame);
|
nsresult rv = NS_NewObjectFrame(frame, this, aParentFrame);
|
||||||
if (NS_OK != rv) {
|
if (NS_OK != rv) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -72,6 +74,80 @@ nsHTMLApplet::CreateFrame(nsIPresContext* aPresContext,
|
||||||
return NS_OK;
|
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
|
nsresult
|
||||||
NS_NewHTMLApplet(nsIHTMLContent** aInstancePtrResult,
|
NS_NewHTMLApplet(nsIHTMLContent** aInstancePtrResult,
|
||||||
nsIAtom* aTag)
|
nsIAtom* aTag)
|
||||||
|
|
|
@ -1,36 +1,26 @@
|
||||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
/* -*- 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
|
* 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
|
* Version 1.0 (the "License"); you may not use this file except in
|
||||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
* compliance with the License. You may obtain a copy of the License at
|
||||||
* http://www.mozilla.org/NPL/
|
* http://www.mozilla.org/NPL/
|
||||||
*
|
*
|
||||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
* Software distributed under the License is distributed on an "AS IS"
|
||||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||||
* for the specific language governing rights and limitations under the
|
* the License for the specific language governing rights and limitations
|
||||||
* NPL.
|
* under the License.
|
||||||
*
|
*
|
||||||
* The Initial Developer of this code under the NPL is Netscape
|
* The Original Code is Mozilla Communicator client code.
|
||||||
* Communications Corporation. Portions created by Netscape are
|
*
|
||||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
* The Initial Developer of the Original Code is Netscape Communications
|
||||||
* Reserved.
|
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||||
|
* Netscape Communications Corporation. All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
#include "nsHTMLParts.h"
|
#include "nsHTMLParts.h"
|
||||||
#include "nsHTMLContainer.h"
|
#include "nsHTMLContainer.h"
|
||||||
#include "nsFrame.h"
|
#include "nsFrame.h"
|
||||||
#include "nsHTMLIIDs.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
|
#define nsHTMLObjectSuper nsHTMLContainer
|
||||||
|
|
||||||
class nsHTMLObject : public nsHTMLObjectSuper {
|
class nsHTMLObject : public nsHTMLObjectSuper {
|
||||||
|
@ -44,7 +34,6 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~nsHTMLObject();
|
virtual ~nsHTMLObject();
|
||||||
nsString mObject;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
nsHTMLObject::nsHTMLObject(nsIAtom* aTag)
|
nsHTMLObject::nsHTMLObject(nsIAtom* aTag)
|
||||||
|
@ -63,7 +52,7 @@ nsHTMLObject::CreateFrame(nsIPresContext* aPresContext,
|
||||||
nsIFrame*& aResult)
|
nsIFrame*& aResult)
|
||||||
{
|
{
|
||||||
nsIFrame* frame;
|
nsIFrame* frame;
|
||||||
nsresult rv = NS_NewObjectFrame(&frame, this, aParentFrame);
|
nsresult rv = NS_NewObjectFrame(frame, this, aParentFrame);
|
||||||
if (NS_OK != rv) {
|
if (NS_OK != rv) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче