зеркало из https://github.com/mozilla/pjs.git
Proportional column width based on HTML attributes is now implemented. proportional "multilength" syntax ("1*")
now works on COL and COLGROUP. Bug 1128.
This commit is contained in:
Родитель
f7c134eb44
Коммит
d84790df55
|
@ -1125,6 +1125,30 @@ nsGenericHTMLElement::ValueOrPercentToString(const nsHTMLValue& aValue,
|
|||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsGenericHTMLElement::ValueOrPercentOrProportionalToString(const nsHTMLValue& aValue,
|
||||
nsString& aResult)
|
||||
{
|
||||
aResult.Truncate(0);
|
||||
switch (aValue.GetUnit()) {
|
||||
case eHTMLUnit_Integer:
|
||||
aResult.Append(aValue.GetIntValue(), 10);
|
||||
return PR_TRUE;
|
||||
case eHTMLUnit_Pixel:
|
||||
aResult.Append(aValue.GetPixelValue(), 10);
|
||||
return PR_TRUE;
|
||||
case eHTMLUnit_Percent:
|
||||
aResult.Append(PRInt32(aValue.GetPercentValue() * 100.0f), 10);
|
||||
aResult.Append('%');
|
||||
return PR_TRUE;
|
||||
case eHTMLUnit_Proportional:
|
||||
aResult.Append(aValue.GetIntValue(), 10);
|
||||
aResult.Append('*');
|
||||
return PR_TRUE;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsGenericHTMLElement::ParseValue(const nsString& aString, PRInt32 aMin,
|
||||
nsHTMLValue& aResult, nsHTMLUnit aValueUnit)
|
||||
|
|
|
@ -129,6 +129,9 @@ public:
|
|||
static PRBool ValueOrPercentToString(const nsHTMLValue& aValue,
|
||||
nsString& aResult);
|
||||
|
||||
static PRBool ValueOrPercentOrProportionalToString(const nsHTMLValue& aValue,
|
||||
nsString& aResult);
|
||||
|
||||
static PRBool ParseValue(const nsString& aString, PRInt32 aMin,
|
||||
nsHTMLValue& aResult, nsHTMLUnit aValueUnit);
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ nsHTMLTableColElement::AttributeToString(nsIAtom* aAttribute,
|
|||
ch
|
||||
*/
|
||||
/* ignore attributes that are of standard types
|
||||
choff, span, width
|
||||
choff, span
|
||||
*/
|
||||
if (aAttribute == nsHTMLAtoms::align) {
|
||||
if (nsGenericHTMLElement::TableHAlignValueToString(aValue, aResult)) {
|
||||
|
@ -211,6 +211,11 @@ nsHTMLTableColElement::AttributeToString(nsIAtom* aAttribute,
|
|||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
}
|
||||
else if (aAttribute == nsHTMLAtoms::width) {
|
||||
if (nsGenericHTMLElement::ValueOrPercentOrProportionalToString(aValue, aResult)) {
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
}
|
||||
return mInner.AttributeToString(aAttribute, aValue, aResult);
|
||||
}
|
||||
|
||||
|
@ -241,6 +246,10 @@ MapAttributesInto(nsIHTMLAttributes* aAttributes,
|
|||
aPresContext->GetScaledPixelsToTwips(p2t);
|
||||
position->mWidth.SetCoordValue(NSIntPixelsToTwips(value.GetPixelValue(), p2t));
|
||||
break;
|
||||
|
||||
case eHTMLUnit_Proportional:
|
||||
position->mWidth.SetIntValue(value.GetIntValue(), eStyleUnit_Proportional);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -188,7 +188,7 @@ nsHTMLTableColGroupElement::AttributeToString(nsIAtom* aAttribute,
|
|||
ch
|
||||
*/
|
||||
/* ignore attributes that are of standard types
|
||||
choff, repeat, width
|
||||
choff, repeat
|
||||
*/
|
||||
if (aAttribute == nsHTMLAtoms::align) {
|
||||
if (nsGenericHTMLElement::TableHAlignValueToString(aValue, aResult)) {
|
||||
|
@ -200,6 +200,11 @@ nsHTMLTableColGroupElement::AttributeToString(nsIAtom* aAttribute,
|
|||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
}
|
||||
else if (aAttribute == nsHTMLAtoms::width) {
|
||||
if (nsGenericHTMLElement::ValueOrPercentOrProportionalToString(aValue, aResult)) {
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
}
|
||||
return mInner.AttributeToString(aAttribute, aValue, aResult);
|
||||
}
|
||||
|
||||
|
@ -230,6 +235,10 @@ MapAttributesInto(nsIHTMLAttributes* aAttributes,
|
|||
aPresContext->GetScaledPixelsToTwips(p2t);
|
||||
position->mWidth.SetCoordValue(NSIntPixelsToTwips(value.GetPixelValue(), p2t));
|
||||
break;
|
||||
|
||||
case eHTMLUnit_Proportional:
|
||||
position->mWidth.SetIntValue(value.GetIntValue(), eStyleUnit_Proportional);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1125,6 +1125,30 @@ nsGenericHTMLElement::ValueOrPercentToString(const nsHTMLValue& aValue,
|
|||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsGenericHTMLElement::ValueOrPercentOrProportionalToString(const nsHTMLValue& aValue,
|
||||
nsString& aResult)
|
||||
{
|
||||
aResult.Truncate(0);
|
||||
switch (aValue.GetUnit()) {
|
||||
case eHTMLUnit_Integer:
|
||||
aResult.Append(aValue.GetIntValue(), 10);
|
||||
return PR_TRUE;
|
||||
case eHTMLUnit_Pixel:
|
||||
aResult.Append(aValue.GetPixelValue(), 10);
|
||||
return PR_TRUE;
|
||||
case eHTMLUnit_Percent:
|
||||
aResult.Append(PRInt32(aValue.GetPercentValue() * 100.0f), 10);
|
||||
aResult.Append('%');
|
||||
return PR_TRUE;
|
||||
case eHTMLUnit_Proportional:
|
||||
aResult.Append(aValue.GetIntValue(), 10);
|
||||
aResult.Append('*');
|
||||
return PR_TRUE;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsGenericHTMLElement::ParseValue(const nsString& aString, PRInt32 aMin,
|
||||
nsHTMLValue& aResult, nsHTMLUnit aValueUnit)
|
||||
|
|
|
@ -129,6 +129,9 @@ public:
|
|||
static PRBool ValueOrPercentToString(const nsHTMLValue& aValue,
|
||||
nsString& aResult);
|
||||
|
||||
static PRBool ValueOrPercentOrProportionalToString(const nsHTMLValue& aValue,
|
||||
nsString& aResult);
|
||||
|
||||
static PRBool ParseValue(const nsString& aString, PRInt32 aMin,
|
||||
nsHTMLValue& aResult, nsHTMLUnit aValueUnit);
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ nsHTMLTableColElement::AttributeToString(nsIAtom* aAttribute,
|
|||
ch
|
||||
*/
|
||||
/* ignore attributes that are of standard types
|
||||
choff, span, width
|
||||
choff, span
|
||||
*/
|
||||
if (aAttribute == nsHTMLAtoms::align) {
|
||||
if (nsGenericHTMLElement::TableHAlignValueToString(aValue, aResult)) {
|
||||
|
@ -211,6 +211,11 @@ nsHTMLTableColElement::AttributeToString(nsIAtom* aAttribute,
|
|||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
}
|
||||
else if (aAttribute == nsHTMLAtoms::width) {
|
||||
if (nsGenericHTMLElement::ValueOrPercentOrProportionalToString(aValue, aResult)) {
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
}
|
||||
return mInner.AttributeToString(aAttribute, aValue, aResult);
|
||||
}
|
||||
|
||||
|
@ -241,6 +246,10 @@ MapAttributesInto(nsIHTMLAttributes* aAttributes,
|
|||
aPresContext->GetScaledPixelsToTwips(p2t);
|
||||
position->mWidth.SetCoordValue(NSIntPixelsToTwips(value.GetPixelValue(), p2t));
|
||||
break;
|
||||
|
||||
case eHTMLUnit_Proportional:
|
||||
position->mWidth.SetIntValue(value.GetIntValue(), eStyleUnit_Proportional);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -188,7 +188,7 @@ nsHTMLTableColGroupElement::AttributeToString(nsIAtom* aAttribute,
|
|||
ch
|
||||
*/
|
||||
/* ignore attributes that are of standard types
|
||||
choff, repeat, width
|
||||
choff, repeat
|
||||
*/
|
||||
if (aAttribute == nsHTMLAtoms::align) {
|
||||
if (nsGenericHTMLElement::TableHAlignValueToString(aValue, aResult)) {
|
||||
|
@ -200,6 +200,11 @@ nsHTMLTableColGroupElement::AttributeToString(nsIAtom* aAttribute,
|
|||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
}
|
||||
else if (aAttribute == nsHTMLAtoms::width) {
|
||||
if (nsGenericHTMLElement::ValueOrPercentOrProportionalToString(aValue, aResult)) {
|
||||
return NS_CONTENT_ATTR_HAS_VALUE;
|
||||
}
|
||||
}
|
||||
return mInner.AttributeToString(aAttribute, aValue, aResult);
|
||||
}
|
||||
|
||||
|
@ -230,6 +235,10 @@ MapAttributesInto(nsIHTMLAttributes* aAttributes,
|
|||
aPresContext->GetScaledPixelsToTwips(p2t);
|
||||
position->mWidth.SetCoordValue(NSIntPixelsToTwips(value.GetPixelValue(), p2t));
|
||||
break;
|
||||
|
||||
case eHTMLUnit_Proportional:
|
||||
position->mWidth.SetIntValue(value.GetIntValue(), eStyleUnit_Proportional);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче