зеркало из https://github.com/mozilla/pjs.git
Make sure that changes to the "span" attribute on a colgroup actually work. Bug 404309, r=bernd, sr=dbaron, a=beltzner
This commit is contained in:
Родитель
30a16a181e
Коммит
4319156262
|
@ -148,6 +148,21 @@ nsHTMLTableColElement::ParseAttribute(PRInt32 aNamespaceID,
|
|||
static
|
||||
void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData)
|
||||
{
|
||||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Table) &&
|
||||
aData->mTableData->mSpan.GetUnit() == eCSSUnit_Null) {
|
||||
// span: int
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::span);
|
||||
if (value && value->Type() == nsAttrValue::eInteger) {
|
||||
PRInt32 val = value->GetIntegerValue();
|
||||
// Note: Do NOT use this code for table cells! The value "0"
|
||||
// means something special for colspan and rowspan, but for <col
|
||||
// span> and <colgroup span> it's just disallowed.
|
||||
if (val > 0) {
|
||||
aData->mTableData->mSpan.SetIntValue(value->GetIntegerValue(),
|
||||
eCSSUnit_Integer);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) &&
|
||||
aData->mPositionData->mWidth.GetUnit() == eCSSUnit_Null) {
|
||||
// width
|
||||
|
@ -187,26 +202,6 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aD
|
|||
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
|
||||
}
|
||||
|
||||
static
|
||||
void ColMapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||
nsRuleData* aData)
|
||||
{
|
||||
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Table) &&
|
||||
aData->mTableData->mSpan.GetUnit() == eCSSUnit_Null) {
|
||||
// span: int
|
||||
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::span);
|
||||
if (value && value->Type() == nsAttrValue::eInteger) {
|
||||
PRInt32 val = value->GetIntegerValue();
|
||||
if (val >= 1) {
|
||||
aData->mTableData->mSpan.SetIntValue(value->GetIntegerValue(),
|
||||
eCSSUnit_Integer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MapAttributesIntoRule(aAttributes, aData);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsHTMLTableColElement::IsAttributeMapped(const nsIAtom* aAttribute) const
|
||||
{
|
||||
|
@ -214,40 +209,21 @@ nsHTMLTableColElement::IsAttributeMapped(const nsIAtom* aAttribute) const
|
|||
{ &nsGkAtoms::width },
|
||||
{ &nsGkAtoms::align },
|
||||
{ &nsGkAtoms::valign },
|
||||
{ nsnull }
|
||||
};
|
||||
|
||||
static const MappedAttributeEntry span_attribute[] = {
|
||||
{ &nsGkAtoms::span },
|
||||
{ nsnull }
|
||||
};
|
||||
|
||||
static const MappedAttributeEntry* const col_map[] = {
|
||||
attributes,
|
||||
span_attribute,
|
||||
sCommonAttributeMap,
|
||||
};
|
||||
|
||||
static const MappedAttributeEntry* const colspan_map[] = {
|
||||
static const MappedAttributeEntry* const map[] = {
|
||||
attributes,
|
||||
sCommonAttributeMap,
|
||||
};
|
||||
|
||||
// we only match "span" if we're a <col>
|
||||
if (mNodeInfo->Equals(nsGkAtoms::col))
|
||||
return FindAttributeDependence(aAttribute, col_map,
|
||||
NS_ARRAY_LENGTH(col_map));
|
||||
return FindAttributeDependence(aAttribute, colspan_map,
|
||||
NS_ARRAY_LENGTH(colspan_map));
|
||||
return FindAttributeDependence(aAttribute, map, NS_ARRAY_LENGTH(map));
|
||||
}
|
||||
|
||||
|
||||
nsMapRuleToAttributesFunc
|
||||
nsHTMLTableColElement::GetAttributeMappingFunction() const
|
||||
{
|
||||
if (mNodeInfo->Equals(nsGkAtoms::col)) {
|
||||
return &ColMapAttributesIntoRule;
|
||||
}
|
||||
|
||||
return &MapAttributesIntoRule;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
table { background: white }
|
||||
colgroup { background: green }
|
||||
td { color: white }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table>
|
||||
<colgroup id="x" span="2">
|
||||
<tr>
|
||||
<td>One</td>
|
||||
<td>Two</td>
|
||||
<td>Three</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
table { background: white }
|
||||
colgroup { background: green }
|
||||
td { color: white }
|
||||
</style>
|
||||
</head>
|
||||
<body onload="runTest()">
|
||||
<table>
|
||||
<colgroup id="x" span="1">
|
||||
<tr>
|
||||
<td>One</td>
|
||||
<td>Two</td>
|
||||
<td>Three</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<script>
|
||||
function runTest() {
|
||||
document.body.offsetWidth;
|
||||
document.getElementById("x").setAttribute("span", 2);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
table { background: white }
|
||||
colgroup { background: green }
|
||||
td { color: white }
|
||||
</style>
|
||||
</head>
|
||||
<body onload="runTest()">
|
||||
<table>
|
||||
<colgroup id="x" span="3">
|
||||
<tr>
|
||||
<td>One</td>
|
||||
<td>Two</td>
|
||||
<td>Three</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<script>
|
||||
function runTest() {
|
||||
document.body.offsetWidth;
|
||||
document.getElementById("x").setAttribute("span", 2);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -652,6 +652,8 @@ random == 403134-1.html 403134-1-ref.html # bug 405377
|
|||
!= 404030-1-notref2.html 404030-1.html
|
||||
== 404180-1.html 404180-1-ref.html
|
||||
== 404301-1.html 404301-1-ref.html
|
||||
== 404309-1a.html 404309-1-ref.html
|
||||
== 404309-1b.html 404309-1-ref.html
|
||||
!= data:application/xml,<foo/> data:text/plain, # bug 404419
|
||||
== 404553-1.html 404553-1-ref.html # assertion test, also tests that marquee binding is applied correctly
|
||||
== 404666-1.html 404666-1-ref.html
|
||||
|
|
|
@ -450,23 +450,7 @@ nsTableColFrame * nsTableColGroupFrame::GetNextColumn(nsIFrame *aChildFrame)
|
|||
|
||||
PRInt32 nsTableColGroupFrame::GetSpan()
|
||||
{
|
||||
PRInt32 span = 1;
|
||||
nsIContent* iContent = GetContent();
|
||||
if (!iContent) return NS_OK;
|
||||
|
||||
// col group element derives from col element
|
||||
nsIDOMHTMLTableColElement* cgContent = nsnull;
|
||||
nsresult rv = iContent->QueryInterface(NS_GET_IID(nsIDOMHTMLTableColElement),
|
||||
(void **)&cgContent);
|
||||
if (cgContent && NS_SUCCEEDED(rv)) {
|
||||
cgContent->GetSpan(&span);
|
||||
// XXX why does this work!!
|
||||
if (span == -1) {
|
||||
span = 1;
|
||||
}
|
||||
NS_RELEASE(cgContent);
|
||||
}
|
||||
return span;
|
||||
return GetStyleTable()->mSpan;
|
||||
}
|
||||
|
||||
void nsTableColGroupFrame::SetContinuousBCBorderWidth(PRUint8 aForSide,
|
||||
|
|
Загрузка…
Ссылка в новой задаче