зеркало из https://github.com/mozilla/pjs.git
Bug 232706: Remove unneccesary datatypes from nsHTMLValue and cleanup AttributeToString.
r=caillon sr=jst
This commit is contained in:
Родитель
65d14b7bf0
Коммит
7055ef1c83
|
@ -1352,8 +1352,7 @@ nsTextControlFrame::GetCols()
|
|||
nsHTMLValue attr;
|
||||
nsresult rv = content->GetHTMLAttribute(nsHTMLAtoms::cols, attr);
|
||||
if (rv == NS_CONTENT_ATTR_HAS_VALUE) {
|
||||
PRInt32 cols = ((attr.GetUnit() == eHTMLUnit_Pixel)
|
||||
? attr.GetPixelValue() : attr.GetIntValue());
|
||||
PRInt32 cols = attr.GetIntValue();
|
||||
// XXX why a default of 1 char, why hide it
|
||||
return (cols <= 0) ? 1 : cols;
|
||||
}
|
||||
|
|
|
@ -588,11 +588,11 @@ nsSize nsSubDocumentFrame::GetMargin()
|
|||
if (NS_SUCCEEDED(rv) && content) {
|
||||
nsHTMLValue value;
|
||||
content->GetHTMLAttribute(nsHTMLAtoms::marginwidth, value);
|
||||
if (eHTMLUnit_Pixel == value.GetUnit())
|
||||
result.width = value.GetPixelValue();
|
||||
if (eHTMLUnit_Integer == value.GetUnit())
|
||||
result.width = value.GetIntValue();
|
||||
content->GetHTMLAttribute(nsHTMLAtoms::marginheight, value);
|
||||
if (eHTMLUnit_Pixel == value.GetUnit())
|
||||
result.height = value.GetPixelValue();
|
||||
if (eHTMLUnit_Integer == value.GetUnit())
|
||||
result.height = value.GetIntValue();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -656,9 +656,7 @@ PRInt32 nsHTMLFramesetFrame::GetBorderWidth(nsIPresContext* aPresContext,
|
|||
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetHTMLAttribute(nsHTMLAtoms::border, htmlVal))) {
|
||||
nsHTMLUnit unit = htmlVal.GetUnit();
|
||||
PRInt32 intVal = 0;
|
||||
if (eHTMLUnit_Pixel == unit) {
|
||||
intVal = htmlVal.GetPixelValue();
|
||||
} else if (eHTMLUnit_Integer == unit) {
|
||||
if (eHTMLUnit_Integer == unit) {
|
||||
intVal = htmlVal.GetIntValue();
|
||||
}
|
||||
if (intVal < 0) {
|
||||
|
@ -930,45 +928,36 @@ nsFrameborder nsHTMLFramesetFrame::GetFrameBorder(nsIContent* aContent)
|
|||
|
||||
nscolor nsHTMLFramesetFrame::GetBorderColor()
|
||||
{
|
||||
nscolor result = NO_COLOR;
|
||||
|
||||
nsCOMPtr<nsIHTMLContent> content(do_QueryInterface(mContent));
|
||||
|
||||
if (content) {
|
||||
nsHTMLValue value;
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetHTMLAttribute(nsHTMLAtoms::bordercolor, value))) {
|
||||
if ((eHTMLUnit_Color == value.GetUnit()) ||
|
||||
(eHTMLUnit_ColorName == value.GetUnit())) {
|
||||
result = value.GetColorValue();
|
||||
nscolor color;
|
||||
if (value.GetColorValue(color)) {
|
||||
return color;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (NO_COLOR == result) {
|
||||
|
||||
return mParentBorderColor;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
nscolor nsHTMLFramesetFrame::GetBorderColor(nsIContent* aContent)
|
||||
{
|
||||
nscolor result = NO_COLOR;
|
||||
|
||||
nsCOMPtr<nsIHTMLContent> content(do_QueryInterface(aContent));
|
||||
|
||||
if (content) {
|
||||
nsHTMLValue value;
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetHTMLAttribute(nsHTMLAtoms::bordercolor, value))) {
|
||||
if ((eHTMLUnit_Color == value.GetUnit()) ||
|
||||
(eHTMLUnit_ColorName == value.GetUnit())) {
|
||||
result = value.GetColorValue();
|
||||
nscolor color;
|
||||
if (value.GetColorValue(color)) {
|
||||
return color;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (NO_COLOR == result) {
|
||||
return GetBorderColor();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLFramesetFrame::Reflow(nsIPresContext* aPresContext,
|
||||
|
|
|
@ -588,11 +588,11 @@ nsSize nsSubDocumentFrame::GetMargin()
|
|||
if (NS_SUCCEEDED(rv) && content) {
|
||||
nsHTMLValue value;
|
||||
content->GetHTMLAttribute(nsHTMLAtoms::marginwidth, value);
|
||||
if (eHTMLUnit_Pixel == value.GetUnit())
|
||||
result.width = value.GetPixelValue();
|
||||
if (eHTMLUnit_Integer == value.GetUnit())
|
||||
result.width = value.GetIntValue();
|
||||
content->GetHTMLAttribute(nsHTMLAtoms::marginheight, value);
|
||||
if (eHTMLUnit_Pixel == value.GetUnit())
|
||||
result.height = value.GetPixelValue();
|
||||
if (eHTMLUnit_Integer == value.GetUnit())
|
||||
result.height = value.GetIntValue();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -656,9 +656,7 @@ PRInt32 nsHTMLFramesetFrame::GetBorderWidth(nsIPresContext* aPresContext,
|
|||
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetHTMLAttribute(nsHTMLAtoms::border, htmlVal))) {
|
||||
nsHTMLUnit unit = htmlVal.GetUnit();
|
||||
PRInt32 intVal = 0;
|
||||
if (eHTMLUnit_Pixel == unit) {
|
||||
intVal = htmlVal.GetPixelValue();
|
||||
} else if (eHTMLUnit_Integer == unit) {
|
||||
if (eHTMLUnit_Integer == unit) {
|
||||
intVal = htmlVal.GetIntValue();
|
||||
}
|
||||
if (intVal < 0) {
|
||||
|
@ -930,45 +928,36 @@ nsFrameborder nsHTMLFramesetFrame::GetFrameBorder(nsIContent* aContent)
|
|||
|
||||
nscolor nsHTMLFramesetFrame::GetBorderColor()
|
||||
{
|
||||
nscolor result = NO_COLOR;
|
||||
|
||||
nsCOMPtr<nsIHTMLContent> content(do_QueryInterface(mContent));
|
||||
|
||||
if (content) {
|
||||
nsHTMLValue value;
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetHTMLAttribute(nsHTMLAtoms::bordercolor, value))) {
|
||||
if ((eHTMLUnit_Color == value.GetUnit()) ||
|
||||
(eHTMLUnit_ColorName == value.GetUnit())) {
|
||||
result = value.GetColorValue();
|
||||
nscolor color;
|
||||
if (value.GetColorValue(color)) {
|
||||
return color;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (NO_COLOR == result) {
|
||||
|
||||
return mParentBorderColor;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
nscolor nsHTMLFramesetFrame::GetBorderColor(nsIContent* aContent)
|
||||
{
|
||||
nscolor result = NO_COLOR;
|
||||
|
||||
nsCOMPtr<nsIHTMLContent> content(do_QueryInterface(aContent));
|
||||
|
||||
if (content) {
|
||||
nsHTMLValue value;
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetHTMLAttribute(nsHTMLAtoms::bordercolor, value))) {
|
||||
if ((eHTMLUnit_Color == value.GetUnit()) ||
|
||||
(eHTMLUnit_ColorName == value.GetUnit())) {
|
||||
result = value.GetColorValue();
|
||||
nscolor color;
|
||||
if (value.GetColorValue(color)) {
|
||||
return color;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (NO_COLOR == result) {
|
||||
return GetBorderColor();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLFramesetFrame::Reflow(nsIPresContext* aPresContext,
|
||||
|
|
|
@ -1352,8 +1352,7 @@ nsTextControlFrame::GetCols()
|
|||
nsHTMLValue attr;
|
||||
nsresult rv = content->GetHTMLAttribute(nsHTMLAtoms::cols, attr);
|
||||
if (rv == NS_CONTENT_ATTR_HAS_VALUE) {
|
||||
PRInt32 cols = ((attr.GetUnit() == eHTMLUnit_Pixel)
|
||||
? attr.GetPixelValue() : attr.GetIntValue());
|
||||
PRInt32 cols = attr.GetIntValue();
|
||||
// XXX why a default of 1 char, why hide it
|
||||
return (cols <= 0) ? 1 : cols;
|
||||
}
|
||||
|
|
|
@ -1081,19 +1081,6 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool nsTableCellFrame::ConvertToPixelValue(nsHTMLValue& aValue, PRInt32 aDefault, PRInt32& aResult)
|
||||
{
|
||||
if (aValue.GetUnit() == eHTMLUnit_Pixel)
|
||||
aResult = aValue.GetPixelValue();
|
||||
else if (aValue.GetUnit() == eHTMLUnit_Empty)
|
||||
aResult = aDefault;
|
||||
else {
|
||||
NS_ERROR("Unit must be pixel or empty");
|
||||
return PR_FALSE;
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/* ----- global methods ----- */
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsTableCellFrame, nsHTMLContainerFrame)
|
||||
|
|
|
@ -300,7 +300,6 @@ protected:
|
|||
PRBool aVisibleBackground,
|
||||
PRBool& aPaintChildren);
|
||||
|
||||
PRBool ConvertToPixelValue(nsHTMLValue& aValue, PRInt32 aDefault, PRInt32& aResult);
|
||||
nsresult DecorateForSelection(nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsStyleBackground* aStyleColor);
|
||||
|
|
|
@ -3906,20 +3906,6 @@ void nsTableFrame::SetColumnWidth(PRInt32 aColIndex, nscoord aWidth)
|
|||
}
|
||||
|
||||
|
||||
PRBool nsTableFrame::ConvertToPixelValue(nsHTMLValue& aValue, PRInt32 aDefault, PRInt32& aResult)
|
||||
{
|
||||
if (aValue.GetUnit() == eHTMLUnit_Pixel)
|
||||
aResult = aValue.GetPixelValue();
|
||||
else if (aValue.GetUnit() == eHTMLUnit_Empty)
|
||||
aResult = aDefault;
|
||||
else
|
||||
{
|
||||
NS_ERROR("Unit must be pixel or empty");
|
||||
return PR_FALSE;
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
nscoord
|
||||
CalcPercentPadding(nscoord aBasis,
|
||||
nsStyleCoord aStyleCoord)
|
||||
|
|
|
@ -768,10 +768,6 @@ protected:
|
|||
PRBool DidResizeReflow() const;
|
||||
void SetResizeReflow(PRBool aValue);
|
||||
|
||||
PRBool ConvertToPixelValue(nsHTMLValue& aValue,
|
||||
PRInt32 aDefault,
|
||||
PRInt32& aResult);
|
||||
|
||||
public:
|
||||
PRBool NeedStrategyInit() const;
|
||||
void SetNeedStrategyInit(PRBool aValue);
|
||||
|
|
|
@ -61,19 +61,19 @@ void testAttributes(nsIHTMLContent* content) {
|
|||
nsString sfoo_gif(NS_LITERAL_STRING("foo.gif"));
|
||||
|
||||
content->SetHTMLAttribute(sBORDER, nullValue, PR_FALSE);
|
||||
content->SetHTMLAttribute(sWIDTH, nsHTMLValue(5, eHTMLUnit_Pixel), PR_FALSE);
|
||||
content->SetHTMLAttribute(sWIDTH, nsHTMLValue(5, eHTMLUnit_Integer), PR_FALSE);
|
||||
content->SetAttribute(kNameSpaceID_None, sHEIGHT, sempty, PR_FALSE);
|
||||
content->SetAttribute(kNameSpaceID_None, sSRC, sfoo_gif, PR_FALSE);
|
||||
|
||||
nsHTMLValue ret;
|
||||
nsresult rv;
|
||||
rv = content->GetHTMLAttribute(sBORDER, ret);
|
||||
if ((rv != NS_CONTENT_ATTR_NO_VALUE) || (ret.GetUnit() != eHTMLUnit_Null)) {
|
||||
if (rv == NS_CONTENT_ATTR_NOT_THERE || ret.GetUnit() != eHTMLUnit_String) {
|
||||
printf("test 0 failed\n");
|
||||
}
|
||||
|
||||
rv = content->GetHTMLAttribute(sWIDTH, ret);
|
||||
if ((rv != NS_CONTENT_ATTR_HAS_VALUE) || (! (ret == nsHTMLValue(5, eHTMLUnit_Pixel)))) {
|
||||
if (rv != NS_CONTENT_ATTR_HAS_VALUE || !(ret == nsHTMLValue(5, eHTMLUnit_Integer))) {
|
||||
printf("test 1 failed\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -1081,19 +1081,6 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool nsTableCellFrame::ConvertToPixelValue(nsHTMLValue& aValue, PRInt32 aDefault, PRInt32& aResult)
|
||||
{
|
||||
if (aValue.GetUnit() == eHTMLUnit_Pixel)
|
||||
aResult = aValue.GetPixelValue();
|
||||
else if (aValue.GetUnit() == eHTMLUnit_Empty)
|
||||
aResult = aDefault;
|
||||
else {
|
||||
NS_ERROR("Unit must be pixel or empty");
|
||||
return PR_FALSE;
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/* ----- global methods ----- */
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsTableCellFrame, nsHTMLContainerFrame)
|
||||
|
|
|
@ -300,7 +300,6 @@ protected:
|
|||
PRBool aVisibleBackground,
|
||||
PRBool& aPaintChildren);
|
||||
|
||||
PRBool ConvertToPixelValue(nsHTMLValue& aValue, PRInt32 aDefault, PRInt32& aResult);
|
||||
nsresult DecorateForSelection(nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsStyleBackground* aStyleColor);
|
||||
|
|
|
@ -3906,20 +3906,6 @@ void nsTableFrame::SetColumnWidth(PRInt32 aColIndex, nscoord aWidth)
|
|||
}
|
||||
|
||||
|
||||
PRBool nsTableFrame::ConvertToPixelValue(nsHTMLValue& aValue, PRInt32 aDefault, PRInt32& aResult)
|
||||
{
|
||||
if (aValue.GetUnit() == eHTMLUnit_Pixel)
|
||||
aResult = aValue.GetPixelValue();
|
||||
else if (aValue.GetUnit() == eHTMLUnit_Empty)
|
||||
aResult = aDefault;
|
||||
else
|
||||
{
|
||||
NS_ERROR("Unit must be pixel or empty");
|
||||
return PR_FALSE;
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
nscoord
|
||||
CalcPercentPadding(nscoord aBasis,
|
||||
nsStyleCoord aStyleCoord)
|
||||
|
|
|
@ -768,10 +768,6 @@ protected:
|
|||
PRBool DidResizeReflow() const;
|
||||
void SetResizeReflow(PRBool aValue);
|
||||
|
||||
PRBool ConvertToPixelValue(nsHTMLValue& aValue,
|
||||
PRInt32 aDefault,
|
||||
PRInt32& aResult);
|
||||
|
||||
public:
|
||||
PRBool NeedStrategyInit() const;
|
||||
void SetNeedStrategyInit(PRBool aValue);
|
||||
|
|
Загрузка…
Ссылка в новой задаче