complete HTML 3.2 attribute support

This commit is contained in:
buster 1998-06-08 17:19:26 +00:00
Родитель 75868dcb41
Коммит 48aad57390
3 изменённых файлов: 82 добавлений и 6 удалений

Просмотреть файл

@ -23,6 +23,9 @@
#include "nsIPresContext.h"
#include "nsHTMLIIDs.h"
#include "nsHTMLAtoms.h"
#include "nsIPtr.h"
NS_DEF_PTR(nsIStyleContext);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
@ -215,21 +218,42 @@ void nsTableCell::MapAttributesInto(nsIStyleContext* aContext,
NS_PRECONDITION(nsnull!=aPresContext, "bad presentation context arg");
if (nsnull != mAttributes) {
nsHTMLValue value;
nsStyleText* textStyle = nsnull;
// align: enum
GetAttribute(nsHTMLAtoms::align, value);
if (value.GetUnit() == eHTMLUnit_Enumerated)
{
nsStyleText* text = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
text->mTextAlign = value.GetIntValue();
textStyle = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
textStyle->mTextAlign = value.GetIntValue();
}
// valign: enum
GetAttribute(nsHTMLAtoms::valign, value);
if (value.GetUnit() == eHTMLUnit_Enumerated)
{
nsStyleText* text = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
text->mTextAlign = value.GetIntValue();
if (nsnull==textStyle)
textStyle = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
textStyle->mVerticalAlign.SetIntValue(value.GetIntValue(), eStyleUnit_Enumerated);
}
// otherwise check the row for valign and inherit it
else {
if (nsnull!=mRow)
{
// TODO: optimize by putting a flag on the row to say whether valign attr is set
nsHTMLValue rowAlignValue;
mRow->GetAttribute(nsHTMLAtoms::valign, rowAlignValue);
if (rowAlignValue.GetUnit() == eHTMLUnit_Enumerated)
{
PRUint8 rowVAlign = rowAlignValue.GetIntValue();
if (NS_STYLE_VERTICAL_ALIGN_MIDDLE!=rowVAlign)
{
if (nsnull==textStyle)
textStyle = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
textStyle->mVerticalAlign.SetIntValue(rowVAlign, eStyleUnit_Enumerated);
}
}
}
}
MapBackgroundAttributesInto(aContext, aPresContext);
@ -238,8 +262,9 @@ void nsTableCell::MapAttributesInto(nsIStyleContext* aContext,
GetAttribute(nsHTMLAtoms::nowrap, value);
if (value.GetUnit() == eHTMLUnit_Empty)
{
nsStyleText* text = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
text->mWhiteSpace = NS_STYLE_WHITESPACE_NOWRAP;
if (nsnull==textStyle)
textStyle = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
textStyle->mWhiteSpace = NS_STYLE_WHITESPACE_NOWRAP;
}
// width: pixel

Просмотреть файл

@ -29,6 +29,7 @@
#include "nsStyleConsts.h"
#include "nsIContentDelegate.h"
#include "nsHTMLIIDs.h"
#include "nsHTMLAtoms.h"
#ifdef NS_DEBUG
static PRBool gsDebug = PR_FALSE;
@ -254,6 +255,51 @@ nsTableRow::RemoveChildAt (int aIndex, PRBool aNotify)
return rv;
}
void nsTableRow::SetAttribute(nsIAtom* aAttribute, const nsString& aValue)
{
NS_PRECONDITION(nsnull!=aAttribute, "bad attribute arg");
nsHTMLValue val;
if ((aAttribute == nsHTMLAtoms::align) &&
ParseDivAlignParam(aValue, val)) {
nsHTMLTagContent::SetAttribute(aAttribute, val);
return;
}
if ((aAttribute == nsHTMLAtoms::valign) &&
ParseAlignParam(aValue, val)) {
nsHTMLTagContent::SetAttribute(aAttribute, val);
return;
}
}
void nsTableRow::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
NS_PRECONDITION(nsnull!=aContext, "bad style context arg");
NS_PRECONDITION(nsnull!=aPresContext, "bad presentation context arg");
if (nsnull != mAttributes) {
nsHTMLValue value;
nsStyleText* textStyle = nsnull;
// align: enum
GetAttribute(nsHTMLAtoms::align, value);
if (value.GetUnit() == eHTMLUnit_Enumerated)
{
textStyle = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
textStyle->mTextAlign = value.GetIntValue();
}
// valign: enum
GetAttribute(nsHTMLAtoms::valign, value);
if (value.GetUnit() == eHTMLUnit_Enumerated)
{
if (nsnull==textStyle)
textStyle = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
textStyle->mVerticalAlign.SetIntValue(value.GetIntValue(), eStyleUnit_Enumerated);
}
}
}
nsresult
nsTableRow::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,

Просмотреть файл

@ -69,6 +69,11 @@ public:
/** returns nsITableContent::kTableRowType */
virtual int GetType();
virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue);
virtual void MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext);
/** @see nsIHTMLContent::CreateFrame */
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,