зеркало из https://github.com/mozilla/gecko-dev.git
Rebased to use nsObjectContent to share common code
This commit is contained in:
Родитель
44dba2b2a1
Коммит
5ef073ab09
|
@ -17,36 +17,17 @@
|
|||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
#include "nsHTMLParts.h"
|
||||
#include "nsHTMLContainer.h"
|
||||
#include "nsFrame.h"
|
||||
#include "nsObjectContent.h"
|
||||
#include "nsHTMLIIDs.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsStyleConsts.h"
|
||||
|
||||
#define nsHTMLAppletSuper nsHTMLContainer
|
||||
#define nsHTMLAppletSuper nsObjectContent
|
||||
|
||||
class nsHTMLApplet : public nsHTMLAppletSuper {
|
||||
public:
|
||||
nsHTMLApplet(nsIAtom* aTag);
|
||||
|
||||
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
|
||||
nsIFrame* aParentFrame,
|
||||
nsIStyleContext* aStyleContext,
|
||||
nsIFrame*& aResult);
|
||||
|
||||
void SetAttribute(nsIAtom* aAttribute, const nsString& aString);
|
||||
|
||||
virtual void MapAttributesInto(nsIStyleContext* aContext,
|
||||
nsIPresContext* aPresContext);
|
||||
|
||||
protected:
|
||||
virtual ~nsHTMLApplet();
|
||||
|
||||
nsContentAttr AttributeToString(nsIAtom* aAttribute,
|
||||
nsHTMLValue& aValue,
|
||||
nsString& aResult) const;
|
||||
};
|
||||
|
||||
nsHTMLApplet::nsHTMLApplet(nsIAtom* aTag)
|
||||
|
@ -58,96 +39,6 @@ nsHTMLApplet::~nsHTMLApplet()
|
|||
{
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLApplet::CreateFrame(nsIPresContext* aPresContext,
|
||||
nsIFrame* aParentFrame,
|
||||
nsIStyleContext* aStyleContext,
|
||||
nsIFrame*& aResult)
|
||||
{
|
||||
nsIFrame* frame;
|
||||
nsresult rv = NS_NewObjectFrame(frame, this, aParentFrame);
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
frame->SetStyleContext(aPresContext, aStyleContext);
|
||||
aResult = frame;
|
||||
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)
|
||||
|
|
|
@ -17,21 +17,15 @@
|
|||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
#include "nsHTMLParts.h"
|
||||
#include "nsHTMLContainer.h"
|
||||
#include "nsFrame.h"
|
||||
#include "nsObjectContent.h"
|
||||
#include "nsHTMLIIDs.h"
|
||||
|
||||
#define nsHTMLEmbedSuper nsHTMLContainer
|
||||
#define nsHTMLEmbedSuper nsObjectContent
|
||||
|
||||
class nsHTMLEmbed : public nsHTMLEmbedSuper {
|
||||
public:
|
||||
nsHTMLEmbed(nsIAtom* aTag);
|
||||
|
||||
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
|
||||
nsIFrame* aParentFrame,
|
||||
nsIStyleContext* aStyleContext,
|
||||
nsIFrame*& aResult);
|
||||
|
||||
protected:
|
||||
virtual ~nsHTMLEmbed();
|
||||
};
|
||||
|
@ -45,22 +39,6 @@ nsHTMLEmbed::~nsHTMLEmbed()
|
|||
{
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLEmbed::CreateFrame(nsIPresContext* aPresContext,
|
||||
nsIFrame* aParentFrame,
|
||||
nsIStyleContext* aStyleContext,
|
||||
nsIFrame*& aResult)
|
||||
{
|
||||
nsIFrame* frame;
|
||||
nsresult rv = NS_NewObjectFrame(frame, this, aParentFrame);
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
frame->SetStyleContext(aPresContext, aStyleContext);
|
||||
aResult = frame;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewHTMLEmbed(nsIHTMLContent** aInstancePtrResult,
|
||||
nsIAtom* aTag)
|
||||
|
|
|
@ -17,21 +17,15 @@
|
|||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
#include "nsHTMLParts.h"
|
||||
#include "nsHTMLContainer.h"
|
||||
#include "nsFrame.h"
|
||||
#include "nsObjectContent.h"
|
||||
#include "nsHTMLIIDs.h"
|
||||
|
||||
#define nsHTMLObjectSuper nsHTMLContainer
|
||||
#define nsHTMLObjectSuper nsObjectContent
|
||||
|
||||
class nsHTMLObject : public nsHTMLObjectSuper {
|
||||
public:
|
||||
nsHTMLObject(nsIAtom* aTag);
|
||||
|
||||
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
|
||||
nsIFrame* aParentFrame,
|
||||
nsIStyleContext* aStyleContext,
|
||||
nsIFrame*& aResult);
|
||||
|
||||
protected:
|
||||
virtual ~nsHTMLObject();
|
||||
};
|
||||
|
@ -45,22 +39,6 @@ nsHTMLObject::~nsHTMLObject()
|
|||
{
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLObject::CreateFrame(nsIPresContext* aPresContext,
|
||||
nsIFrame* aParentFrame,
|
||||
nsIStyleContext* aStyleContext,
|
||||
nsIFrame*& aResult)
|
||||
{
|
||||
nsIFrame* frame;
|
||||
nsresult rv = NS_NewObjectFrame(frame, this, aParentFrame);
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
frame->SetStyleContext(aPresContext, aStyleContext);
|
||||
aResult = frame;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewHTMLObject(nsIHTMLContent** aInstancePtrResult,
|
||||
nsIAtom* aTag)
|
||||
|
|
Загрузка…
Ссылка в новой задаче