/* -*- 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 "nsTableCell.h" #include "nsTableColGroup.h" #include "nsTableRow.h" #include "nsTablePart.h" #include "nsTableCellFrame.h" #include "nsHTMLParts.h" #include "nsHTMLContainer.h" #include "nsReflowCommand.h" #include "nsIStyleContext.h" #include "nsStyleConsts.h" #include "nsIPresContext.h" #include "nsIRenderingContext.h" #include "nsHTMLIIDs.h" #include "nsHTMLAtoms.h" static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kStyleTextSID, NS_STYLETEXT_SID); static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLETEXT_SID); static NS_DEFINE_IID(kStyleBorderSID, NS_STYLETEXT_SID); #ifdef NS_DEBUG static PRBool gsDebug = PR_TRUE; static PRBool gsNoisyRefs = PR_FALSE; #else static const PRBool gsDebug = PR_FALSE; static const PRBool gsNoisyRefs = PR_FALSE; #endif // nsTableContent checks aTag nsTableCell::nsTableCell(nsIAtom* aTag) : nsTableContent(aTag), mRow(0), mRowSpan(1), mColSpan(1), mColIndex(0) { mImplicit = PR_FALSE; } nsTableCell::nsTableCell(PRBool aImplicit) : nsTableContent(NS_NewAtom(nsTablePart::kDataCellTagString)), mRow(0), mRowSpan(1), mColSpan(1), mColIndex(0) { mImplicit = aImplicit; } // nsTableContent checks aTag nsTableCell::nsTableCell (nsIAtom* aTag, int aRowSpan, int aColSpan) : nsTableContent(aTag), mRow(0), mRowSpan(aRowSpan), mColSpan(aColSpan), mColIndex(0) { NS_ASSERTION(0SetStyleContext(aPresContext, aStyleContext); aResult = frame; return rv; } void nsTableCell::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::background) { nsAutoString href(aValue); href.StripWhitespace(); nsHTMLTagContent::SetAttribute(aAttribute, href); return; } if (aAttribute == nsHTMLAtoms::bgcolor) { ParseColor(aValue, val); nsHTMLTagContent::SetAttribute(aAttribute, val); return; } if (aAttribute == nsHTMLAtoms::rowspan) { ParseValue(aValue, 1, 10000, val, eHTMLUnit_Integer); SetRowSpan(val.GetIntValue()); return; } if (aAttribute == nsHTMLAtoms::colspan) { ParseValue(aValue, 1, 1000, val, eHTMLUnit_Integer); SetColSpan(val.GetIntValue()); return; } // Use default attribute catching code nsTableContent::SetAttribute(aAttribute, aValue); } void nsTableCell::MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) { NS_PRECONDITION(nsnull!=aContext, "bad style context arg"); NS_PRECONDITION(nsnull!=aPresContext, "bad presentation context arg"); nsHTMLValue value; // align: enum GetAttribute(nsHTMLAtoms::align, value); if (value.GetUnit() == eHTMLUnit_Enumerated) { nsStyleText* text = (nsStyleText*)aContext->GetData(kStyleTextSID); text->mTextAlign = value.GetIntValue(); } MapBackgroundAttributesInto(aContext, aPresContext); } void nsTableCell::SetRowSpan(int aRowSpan) { NS_ASSERTION(0ResetCellMap (); } nsresult NS_NewTableCellPart(nsIHTMLContent** aInstancePtrResult, nsIAtom* aTag) { NS_PRECONDITION(nsnull != aInstancePtrResult, "nsnull ptr"); if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } nsIHTMLContent* body = new nsTableCell(aTag); if (nsnull == body) { return NS_ERROR_OUT_OF_MEMORY; } return body->QueryInterface(kIHTMLContentIID, (void **) aInstancePtrResult); }