Bug 1334330 - Part 6: stylo: Use GenericSpecifiedValue abstraction for table elements; r=emilio

MozReview-Commit-ID: 6wo4iw4zEWP
This commit is contained in:
Manish Goregaokar
2017-01-26 16:51:01 -08:00
parent a2e18900da
commit 33a682c81d
10 changed files with 170 additions and 254 deletions

View File

@@ -440,78 +440,58 @@ HTMLTableCellElement::ParseAttribute(int32_t aNamespaceID,
void
HTMLTableCellElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aGenericData)
GenericSpecifiedValues* aData)
{
nsRuleData* aData = aGenericData->AsRuleData();
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) {
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Position))) {
// width: value
nsCSSValue* width = aData->ValueForWidth();
if (width->GetUnit() == eCSSUnit_Null) {
if (!aData->PropertyIsSet(eCSSProperty_width)) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
if (value && value->Type() == nsAttrValue::eInteger) {
if (value->GetIntegerValue() > 0)
width->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
aData->SetPixelValue(eCSSProperty_width, (float)value->GetIntegerValue());
// else 0 implies auto for compatibility.
}
else if (value && value->Type() == nsAttrValue::ePercent) {
if (value->GetPercentValue() > 0.0f)
width->SetPercentValue(value->GetPercentValue());
aData->SetPercentValue(eCSSProperty_width, value->GetPercentValue());
// else 0 implies auto for compatibility
}
}
// height: value
nsCSSValue* height = aData->ValueForHeight();
if (height->GetUnit() == eCSSUnit_Null) {
if (!aData->PropertyIsSet(eCSSProperty_height)) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::height);
if (value && value->Type() == nsAttrValue::eInteger) {
if (value->GetIntegerValue() > 0)
height->SetFloatValue((float)value->GetIntegerValue(), eCSSUnit_Pixel);
aData->SetPixelValue(eCSSProperty_height, (float)value->GetIntegerValue());
// else 0 implies auto for compatibility.
}
else if (value && value->Type() == nsAttrValue::ePercent) {
if (value->GetPercentValue() > 0.0f)
height->SetPercentValue(value->GetPercentValue());
aData->SetPercentValue(eCSSProperty_height, value->GetPercentValue());
// else 0 implies auto for compatibility
}
}
}
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Text)) {
nsCSSValue* textAlign = aData->ValueForTextAlign();
if (textAlign->GetUnit() == eCSSUnit_Null) {
// align: enum
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
if (value && value->Type() == nsAttrValue::eEnum)
textAlign->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
}
nsCSSValue* whiteSpace = aData->ValueForWhiteSpace();
if (whiteSpace->GetUnit() == eCSSUnit_Null) {
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Text))) {
if (!aData->PropertyIsSet(eCSSProperty_white_space)) {
// nowrap: enum
if (aAttributes->GetAttr(nsGkAtoms::nowrap)) {
// See if our width is not a nonzero integer width.
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
nsCompatibility mode = aData->mPresContext->CompatibilityMode();
nsCompatibility mode = aData->PresContext()->CompatibilityMode();
if (!value || value->Type() != nsAttrValue::eInteger ||
value->GetIntegerValue() == 0 ||
eCompatibility_NavQuirks != mode) {
whiteSpace->SetIntValue(NS_STYLE_WHITESPACE_NOWRAP, eCSSUnit_Enumerated);
aData->SetKeywordValue(eCSSProperty_white_space, NS_STYLE_WHITESPACE_NOWRAP);
}
}
}
}
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Display)) {
nsCSSValue* verticalAlign = aData->ValueForVerticalAlign();
if (verticalAlign->GetUnit() == eCSSUnit_Null) {
// valign: enum
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::valign);
if (value && value->Type() == nsAttrValue::eEnum)
verticalAlign->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
}
}
nsGenericHTMLElement::MapBackgroundAttributesInto(aAttributes, aGenericData);
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aGenericData);
nsGenericHTMLElement::MapDivAlignAttributeInto(aAttributes, aData);
nsGenericHTMLElement::MapVAlignAttributeInto(aAttributes, aData);
nsGenericHTMLElement::MapBackgroundAttributesInto(aAttributes, aData);
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
}
NS_IMETHODIMP_(bool)