diff --git a/mozilla/layout/forms/nsTextControlFrame.cpp b/mozilla/layout/forms/nsTextControlFrame.cpp index ac569eb46ba..f3547a74c92 100644 --- a/mozilla/layout/forms/nsTextControlFrame.cpp +++ b/mozilla/layout/forms/nsTextControlFrame.cpp @@ -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; } diff --git a/mozilla/layout/generic/nsFrameFrame.cpp b/mozilla/layout/generic/nsFrameFrame.cpp index 1fa745a7cdb..ee0e2c8b52f 100644 --- a/mozilla/layout/generic/nsFrameFrame.cpp +++ b/mozilla/layout/generic/nsFrameFrame.cpp @@ -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; } diff --git a/mozilla/layout/generic/nsFrameSetFrame.cpp b/mozilla/layout/generic/nsFrameSetFrame.cpp index d988f123a8c..4e56ae8349f 100644 --- a/mozilla/layout/generic/nsFrameSetFrame.cpp +++ b/mozilla/layout/generic/nsFrameSetFrame.cpp @@ -656,11 +656,9 @@ 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) { intVal = 0; } @@ -930,44 +928,35 @@ nsFrameborder nsHTMLFramesetFrame::GetFrameBorder(nsIContent* aContent) nscolor nsHTMLFramesetFrame::GetBorderColor() { - nscolor result = NO_COLOR; - nsCOMPtr 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; + + return mParentBorderColor; } nscolor nsHTMLFramesetFrame::GetBorderColor(nsIContent* aContent) { - nscolor result = NO_COLOR; - nsCOMPtr 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; + return GetBorderColor(); } NS_IMETHODIMP diff --git a/mozilla/layout/html/document/src/nsFrameFrame.cpp b/mozilla/layout/html/document/src/nsFrameFrame.cpp index 1fa745a7cdb..ee0e2c8b52f 100644 --- a/mozilla/layout/html/document/src/nsFrameFrame.cpp +++ b/mozilla/layout/html/document/src/nsFrameFrame.cpp @@ -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; } diff --git a/mozilla/layout/html/document/src/nsFrameSetFrame.cpp b/mozilla/layout/html/document/src/nsFrameSetFrame.cpp index d988f123a8c..4e56ae8349f 100644 --- a/mozilla/layout/html/document/src/nsFrameSetFrame.cpp +++ b/mozilla/layout/html/document/src/nsFrameSetFrame.cpp @@ -656,11 +656,9 @@ 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) { intVal = 0; } @@ -930,44 +928,35 @@ nsFrameborder nsHTMLFramesetFrame::GetFrameBorder(nsIContent* aContent) nscolor nsHTMLFramesetFrame::GetBorderColor() { - nscolor result = NO_COLOR; - nsCOMPtr 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; + + return mParentBorderColor; } nscolor nsHTMLFramesetFrame::GetBorderColor(nsIContent* aContent) { - nscolor result = NO_COLOR; - nsCOMPtr 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; + return GetBorderColor(); } NS_IMETHODIMP diff --git a/mozilla/layout/html/forms/src/nsTextControlFrame.cpp b/mozilla/layout/html/forms/src/nsTextControlFrame.cpp index ac569eb46ba..f3547a74c92 100644 --- a/mozilla/layout/html/forms/src/nsTextControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsTextControlFrame.cpp @@ -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; } diff --git a/mozilla/layout/html/table/src/nsTableCellFrame.cpp b/mozilla/layout/html/table/src/nsTableCellFrame.cpp index 141c740b33a..2062c27ac80 100644 --- a/mozilla/layout/html/table/src/nsTableCellFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableCellFrame.cpp @@ -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) diff --git a/mozilla/layout/html/table/src/nsTableCellFrame.h b/mozilla/layout/html/table/src/nsTableCellFrame.h index 6d5ffbcdd05..fd2082c2e91 100644 --- a/mozilla/layout/html/table/src/nsTableCellFrame.h +++ b/mozilla/layout/html/table/src/nsTableCellFrame.h @@ -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); diff --git a/mozilla/layout/html/table/src/nsTableFrame.cpp b/mozilla/layout/html/table/src/nsTableFrame.cpp index 297f00d0685..9a9d485c804 100644 --- a/mozilla/layout/html/table/src/nsTableFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableFrame.cpp @@ -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) diff --git a/mozilla/layout/html/table/src/nsTableFrame.h b/mozilla/layout/html/table/src/nsTableFrame.h index 882466cde3e..0ffff8c1072 100644 --- a/mozilla/layout/html/table/src/nsTableFrame.h +++ b/mozilla/layout/html/table/src/nsTableFrame.h @@ -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); diff --git a/mozilla/layout/html/tests/TestAttributes.cpp b/mozilla/layout/html/tests/TestAttributes.cpp index 39c69b934ce..0d09ab8c385 100644 --- a/mozilla/layout/html/tests/TestAttributes.cpp +++ b/mozilla/layout/html/tests/TestAttributes.cpp @@ -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"); } diff --git a/mozilla/layout/tables/nsTableCellFrame.cpp b/mozilla/layout/tables/nsTableCellFrame.cpp index 141c740b33a..2062c27ac80 100644 --- a/mozilla/layout/tables/nsTableCellFrame.cpp +++ b/mozilla/layout/tables/nsTableCellFrame.cpp @@ -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) diff --git a/mozilla/layout/tables/nsTableCellFrame.h b/mozilla/layout/tables/nsTableCellFrame.h index 6d5ffbcdd05..fd2082c2e91 100644 --- a/mozilla/layout/tables/nsTableCellFrame.h +++ b/mozilla/layout/tables/nsTableCellFrame.h @@ -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); diff --git a/mozilla/layout/tables/nsTableFrame.cpp b/mozilla/layout/tables/nsTableFrame.cpp index 297f00d0685..9a9d485c804 100644 --- a/mozilla/layout/tables/nsTableFrame.cpp +++ b/mozilla/layout/tables/nsTableFrame.cpp @@ -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) diff --git a/mozilla/layout/tables/nsTableFrame.h b/mozilla/layout/tables/nsTableFrame.h index 882466cde3e..0ffff8c1072 100644 --- a/mozilla/layout/tables/nsTableFrame.h +++ b/mozilla/layout/tables/nsTableFrame.h @@ -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);