Bug 1449798 - Remove GenericSpecifiedValues::ShouldComputeStyleStruct and mSIDs. r=emilio

This was useful because nsRuleData in the old style system may not hold
all the data, but the only subclass ServoSpecifiedValues is always able
to hold any data, and thus passes NS_STYLE_INHERIT_MASK to mSIDS. Given
this, this method and mSIDs seems to be useless and can be removed.

MozReview-Commit-ID: 4vWcV4DRS2i

--HG--
extra : rebase_source : 4f364d431821e29838082e391c6dde08af7f5343
This commit is contained in:
Xidorn Quan 2018-03-29 12:39:07 +11:00
parent 9c4356e89b
commit 3e1eaab1ee
19 changed files with 701 additions and 817 deletions

View File

@ -55,14 +55,11 @@ void
HTMLBRElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aData)
{
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Display))) {
if (!aData->PropertyIsSet(eCSSProperty_clear)) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::clear);
if (value && value->Type() == nsAttrValue::eEnum)
aData->SetKeywordValue(eCSSProperty_clear, value->GetEnumValue());
}
if (!aData->PropertyIsSet(eCSSProperty_clear)) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::clear);
if (value && value->Type() == nsAttrValue::eEnum)
aData->SetKeywordValue(eCSSProperty_clear, value->GetEnumValue());
}
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
}

View File

@ -76,153 +76,145 @@ void
HTMLBodyElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aData)
{
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Margin)) {
// This is the one place where we try to set the same property
// multiple times in presentation attributes. Servo does not support
// querying if a property is set (because that is O(n) behavior
// in ServoSpecifiedValues). Instead, we use the below values to keep
// track of whether we have already set a property, and if so, what value
// we set it to (which is used when handling margin
// attributes from the containing frame element)
// This is the one place where we try to set the same property
// multiple times in presentation attributes. Servo does not support
// querying if a property is set (because that is O(n) behavior
// in ServoSpecifiedValues). Instead, we use the below values to keep
// track of whether we have already set a property, and if so, what value
// we set it to (which is used when handling margin
// attributes from the containing frame element)
int32_t bodyMarginWidth = -1;
int32_t bodyMarginHeight = -1;
int32_t bodyTopMargin = -1;
int32_t bodyBottomMargin = -1;
int32_t bodyLeftMargin = -1;
int32_t bodyRightMargin = -1;
int32_t bodyMarginWidth = -1;
int32_t bodyMarginHeight = -1;
int32_t bodyTopMargin = -1;
int32_t bodyBottomMargin = -1;
int32_t bodyLeftMargin = -1;
int32_t bodyRightMargin = -1;
const nsAttrValue* value;
// if marginwidth/marginheight are set, reflect them as 'margin'
value = aAttributes->GetAttr(nsGkAtoms::marginwidth);
if (value && value->Type() == nsAttrValue::eInteger) {
bodyMarginWidth = value->GetIntegerValue();
if (bodyMarginWidth < 0) {
bodyMarginWidth = 0;
}
aData->SetPixelValueIfUnset(eCSSProperty_margin_left, (float)bodyMarginWidth);
aData->SetPixelValueIfUnset(eCSSProperty_margin_right, (float)bodyMarginWidth);
}
const nsAttrValue* value;
// if marginwidth/marginheight are set, reflect them as 'margin'
value = aAttributes->GetAttr(nsGkAtoms::marginwidth);
value = aAttributes->GetAttr(nsGkAtoms::marginheight);
if (value && value->Type() == nsAttrValue::eInteger) {
bodyMarginHeight = value->GetIntegerValue();
if (bodyMarginHeight < 0) {
bodyMarginHeight = 0;
}
aData->SetPixelValueIfUnset(eCSSProperty_margin_top, (float)bodyMarginHeight);
aData->SetPixelValueIfUnset(eCSSProperty_margin_bottom, (float)bodyMarginHeight);
}
// topmargin (IE-attribute)
if (bodyMarginHeight == -1) {
value = aAttributes->GetAttr(nsGkAtoms::topmargin);
if (value && value->Type() == nsAttrValue::eInteger) {
bodyMarginWidth = value->GetIntegerValue();
if (bodyMarginWidth < 0) {
bodyMarginWidth = 0;
bodyTopMargin = value->GetIntegerValue();
if (bodyTopMargin < 0) {
bodyTopMargin = 0;
}
aData->SetPixelValueIfUnset(eCSSProperty_margin_left, (float)bodyMarginWidth);
aData->SetPixelValueIfUnset(eCSSProperty_margin_right, (float)bodyMarginWidth);
aData->SetPixelValueIfUnset(eCSSProperty_margin_top, (float)bodyTopMargin);
}
}
// bottommargin (IE-attribute)
value = aAttributes->GetAttr(nsGkAtoms::marginheight);
if (bodyMarginHeight == -1) {
value = aAttributes->GetAttr(nsGkAtoms::bottommargin);
if (value && value->Type() == nsAttrValue::eInteger) {
bodyMarginHeight = value->GetIntegerValue();
if (bodyMarginHeight < 0) {
bodyMarginHeight = 0;
bodyBottomMargin = value->GetIntegerValue();
if (bodyBottomMargin < 0) {
bodyBottomMargin = 0;
}
aData->SetPixelValueIfUnset(eCSSProperty_margin_top, (float)bodyMarginHeight);
aData->SetPixelValueIfUnset(eCSSProperty_margin_bottom, (float)bodyMarginHeight);
aData->SetPixelValueIfUnset(eCSSProperty_margin_bottom, (float)bodyBottomMargin);
}
}
// topmargin (IE-attribute)
if (bodyMarginHeight == -1) {
value = aAttributes->GetAttr(nsGkAtoms::topmargin);
if (value && value->Type() == nsAttrValue::eInteger) {
bodyTopMargin = value->GetIntegerValue();
if (bodyTopMargin < 0) {
bodyTopMargin = 0;
}
aData->SetPixelValueIfUnset(eCSSProperty_margin_top, (float)bodyTopMargin);
// leftmargin (IE-attribute)
if (bodyMarginWidth == -1) {
value = aAttributes->GetAttr(nsGkAtoms::leftmargin);
if (value && value->Type() == nsAttrValue::eInteger) {
bodyLeftMargin = value->GetIntegerValue();
if (bodyLeftMargin < 0) {
bodyLeftMargin = 0;
}
aData->SetPixelValueIfUnset(eCSSProperty_margin_left, (float)bodyLeftMargin);
}
// bottommargin (IE-attribute)
if (bodyMarginHeight == -1) {
value = aAttributes->GetAttr(nsGkAtoms::bottommargin);
if (value && value->Type() == nsAttrValue::eInteger) {
bodyBottomMargin = value->GetIntegerValue();
if (bodyBottomMargin < 0) {
bodyBottomMargin = 0;
}
aData->SetPixelValueIfUnset(eCSSProperty_margin_bottom, (float)bodyBottomMargin);
}
// rightmargin (IE-attribute)
if (bodyMarginWidth == -1) {
value = aAttributes->GetAttr(nsGkAtoms::rightmargin);
if (value && value->Type() == nsAttrValue::eInteger) {
bodyRightMargin = value->GetIntegerValue();
if (bodyRightMargin < 0) {
bodyRightMargin = 0;
}
aData->SetPixelValueIfUnset(eCSSProperty_margin_right, (float)bodyRightMargin);
}
}
// leftmargin (IE-attribute)
if (bodyMarginWidth == -1) {
value = aAttributes->GetAttr(nsGkAtoms::leftmargin);
if (value && value->Type() == nsAttrValue::eInteger) {
bodyLeftMargin = value->GetIntegerValue();
if (bodyLeftMargin < 0) {
bodyLeftMargin = 0;
// if marginwidth or marginheight is set in the <frame> and not set in the <body>
// reflect them as margin in the <body>
if (bodyMarginWidth == -1 || bodyMarginHeight == -1) {
nsCOMPtr<nsIDocShell> docShell(aData->Document()->GetDocShell());
if (docShell) {
nscoord frameMarginWidth=-1; // default value
nscoord frameMarginHeight=-1; // default value
docShell->GetMarginWidth(&frameMarginWidth); // -1 indicates not set
docShell->GetMarginHeight(&frameMarginHeight);
if (bodyMarginWidth == -1 && frameMarginWidth >= 0) {
if (bodyLeftMargin == -1) {
aData->SetPixelValueIfUnset(eCSSProperty_margin_left, (float)frameMarginWidth);
}
if (bodyRightMargin == -1) {
aData->SetPixelValueIfUnset(eCSSProperty_margin_right, (float)frameMarginWidth);
}
aData->SetPixelValueIfUnset(eCSSProperty_margin_left, (float)bodyLeftMargin);
}
}
// rightmargin (IE-attribute)
if (bodyMarginWidth == -1) {
value = aAttributes->GetAttr(nsGkAtoms::rightmargin);
if (value && value->Type() == nsAttrValue::eInteger) {
bodyRightMargin = value->GetIntegerValue();
if (bodyRightMargin < 0) {
bodyRightMargin = 0;
if (bodyMarginHeight == -1 && frameMarginHeight >= 0) {
if (bodyTopMargin == -1) {
aData->SetPixelValueIfUnset(eCSSProperty_margin_top, (float)frameMarginHeight);
}
aData->SetPixelValueIfUnset(eCSSProperty_margin_right, (float)bodyRightMargin);
}
}
// if marginwidth or marginheight is set in the <frame> and not set in the <body>
// reflect them as margin in the <body>
if (bodyMarginWidth == -1 || bodyMarginHeight == -1) {
nsCOMPtr<nsIDocShell> docShell(aData->Document()->GetDocShell());
if (docShell) {
nscoord frameMarginWidth=-1; // default value
nscoord frameMarginHeight=-1; // default value
docShell->GetMarginWidth(&frameMarginWidth); // -1 indicates not set
docShell->GetMarginHeight(&frameMarginHeight);
if (bodyMarginWidth == -1 && frameMarginWidth >= 0) {
if (bodyLeftMargin == -1) {
aData->SetPixelValueIfUnset(eCSSProperty_margin_left, (float)frameMarginWidth);
}
if (bodyRightMargin == -1) {
aData->SetPixelValueIfUnset(eCSSProperty_margin_right, (float)frameMarginWidth);
}
}
if (bodyMarginHeight == -1 && frameMarginHeight >= 0) {
if (bodyTopMargin == -1) {
aData->SetPixelValueIfUnset(eCSSProperty_margin_top, (float)frameMarginHeight);
}
if (bodyBottomMargin == -1) {
aData->SetPixelValueIfUnset(eCSSProperty_margin_bottom, (float)frameMarginHeight);
}
if (bodyBottomMargin == -1) {
aData->SetPixelValueIfUnset(eCSSProperty_margin_bottom, (float)frameMarginHeight);
}
}
}
}
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Display))) {
// When display if first asked for, go ahead and get our colors set up.
if (nsHTMLStyleSheet* styleSheet = aData->Document()->GetAttributeStyleSheet()) {
const nsAttrValue* value;
nscolor color;
value = aAttributes->GetAttr(nsGkAtoms::link);
if (value && value->GetColorValue(color)) {
styleSheet->SetLinkColor(color);
}
// When display if first asked for, go ahead and get our colors set up.
if (nsHTMLStyleSheet* styleSheet = aData->Document()->GetAttributeStyleSheet()) {
nscolor color;
value = aAttributes->GetAttr(nsGkAtoms::link);
if (value && value->GetColorValue(color)) {
styleSheet->SetLinkColor(color);
}
value = aAttributes->GetAttr(nsGkAtoms::alink);
if (value && value->GetColorValue(color)) {
styleSheet->SetActiveLinkColor(color);
}
value = aAttributes->GetAttr(nsGkAtoms::alink);
if (value && value->GetColorValue(color)) {
styleSheet->SetActiveLinkColor(color);
}
value = aAttributes->GetAttr(nsGkAtoms::vlink);
if (value && value->GetColorValue(color)) {
styleSheet->SetVisitedLinkColor(color);
}
value = aAttributes->GetAttr(nsGkAtoms::vlink);
if (value && value->GetColorValue(color)) {
styleSheet->SetVisitedLinkColor(color);
}
}
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Color))) {
if (!aData->PropertyIsSet(eCSSProperty_color)) {
// color: color
nscolor color;
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::text);
if (value && value->GetColorValue(color)) {
aData->SetColorValue(eCSSProperty_color, color);
}
if (!aData->PropertyIsSet(eCSSProperty_color)) {
// color: color
nscolor color;
value = aAttributes->GetAttr(nsGkAtoms::text);
if (value && value->GetColorValue(color)) {
aData->SetColorValue(eCSSProperty_color, color);
}
}

View File

@ -58,34 +58,29 @@ void
HTMLFontElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aData)
{
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Font))) {
// face: string list
if (!aData->PropertyIsSet(eCSSProperty_font_family)) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::face);
if (value && value->Type() == nsAttrValue::eString &&
!value->IsEmptyString()) {
aData->SetFontFamily(value->GetStringValue());
}
}
// size: int
if (!aData->PropertyIsSet(eCSSProperty_font_size)) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::size);
if (value && value->Type() == nsAttrValue::eInteger)
aData->SetKeywordValue(eCSSProperty_font_size, value->GetIntegerValue());
// face: string list
if (!aData->PropertyIsSet(eCSSProperty_font_family)) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::face);
if (value && value->Type() == nsAttrValue::eString &&
!value->IsEmptyString()) {
aData->SetFontFamily(value->GetStringValue());
}
}
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Color))) {
if (!aData->PropertyIsSet(eCSSProperty_color)) {
// color: color
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::color);
nscolor color;
if (value && value->GetColorValue(color)) {
aData->SetColorValue(eCSSProperty_color, color);
}
// size: int
if (!aData->PropertyIsSet(eCSSProperty_font_size)) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::size);
if (value && value->Type() == nsAttrValue::eInteger)
aData->SetKeywordValue(eCSSProperty_font_size, value->GetIntegerValue());
}
if (!aData->PropertyIsSet(eCSSProperty_color)) {
// color: color
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::color);
nscolor color;
if (value && value->GetColorValue(color)) {
aData->SetColorValue(eCSSProperty_color, color);
}
}
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(TextReset)) &&
aData->Document()->GetCompatibilityMode() == eCompatibility_NavQuirks) {
if (aData->Document()->GetCompatibilityMode() == eCompatibility_NavQuirks) {
// Make <a><font color="red">text</font></a> give the text a red underline
// in quirks mode. The NS_STYLE_TEXT_DECORATION_LINE_OVERRIDE_ALL flag only
// affects quirks mode rendering.

View File

@ -67,62 +67,55 @@ HTMLHRElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
nscolor color;
bool colorIsSet = colorValue && colorValue->GetColorValue(color);
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Position) |
NS_STYLE_INHERIT_BIT(Border))) {
if (colorIsSet) {
noshade = true;
} else {
noshade = !!aAttributes->GetAttr(nsGkAtoms::noshade);
}
if (colorIsSet) {
noshade = true;
} else {
noshade = !!aAttributes->GetAttr(nsGkAtoms::noshade);
}
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Margin))) {
// align: enum
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
if (value && value->Type() == nsAttrValue::eEnum) {
// Map align attribute into auto side margins
switch (value->GetEnumValue()) {
case NS_STYLE_TEXT_ALIGN_LEFT:
aData->SetPixelValueIfUnset(eCSSProperty_margin_left, 0.0f);
aData->SetAutoValueIfUnset(eCSSProperty_margin_right);
break;
case NS_STYLE_TEXT_ALIGN_RIGHT:
aData->SetAutoValueIfUnset(eCSSProperty_margin_left);
aData->SetPixelValueIfUnset(eCSSProperty_margin_right, 0.0f);
break;
case NS_STYLE_TEXT_ALIGN_CENTER:
aData->SetAutoValueIfUnset(eCSSProperty_margin_left);
aData->SetAutoValueIfUnset(eCSSProperty_margin_right);
break;
}
// align: enum
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
if (value && value->Type() == nsAttrValue::eEnum) {
// Map align attribute into auto side margins
switch (value->GetEnumValue()) {
case NS_STYLE_TEXT_ALIGN_LEFT:
aData->SetPixelValueIfUnset(eCSSProperty_margin_left, 0.0f);
aData->SetAutoValueIfUnset(eCSSProperty_margin_right);
break;
case NS_STYLE_TEXT_ALIGN_RIGHT:
aData->SetAutoValueIfUnset(eCSSProperty_margin_left);
aData->SetPixelValueIfUnset(eCSSProperty_margin_right, 0.0f);
break;
case NS_STYLE_TEXT_ALIGN_CENTER:
aData->SetAutoValueIfUnset(eCSSProperty_margin_left);
aData->SetAutoValueIfUnset(eCSSProperty_margin_right);
break;
}
}
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Position))) {
if (!aData->PropertyIsSet(eCSSProperty_height)) {
// size: integer
if (noshade) {
// noshade case: size is set using the border
aData->SetAutoValue(eCSSProperty_height);
} else {
// normal case
// the height includes the top and bottom borders that are initially 1px.
// for size=1, html.css has a special case rule that makes this work by
// removing all but the top border.
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::size);
if (value && value->Type() == nsAttrValue::eInteger) {
aData->SetPixelValue(eCSSProperty_height, (float)value->GetIntegerValue());
} // else use default value from html.css
}
if (!aData->PropertyIsSet(eCSSProperty_height)) {
// size: integer
if (noshade) {
// noshade case: size is set using the border
aData->SetAutoValue(eCSSProperty_height);
} else {
// normal case
// the height includes the top and bottom borders that are initially 1px.
// for size=1, html.css has a special case rule that makes this work by
// removing all but the top border.
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::size);
if (value && value->Type() == nsAttrValue::eInteger) {
aData->SetPixelValue(eCSSProperty_height, (float)value->GetIntegerValue());
} // else use default value from html.css
}
}
// if not noshade, border styles are dealt with by html.css
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Border)) && noshade) {
if (noshade) {
// size: integer
// if a size is set, use half of it per side, otherwise, use 1px per side
float sizePerSide;
bool allSides = true;
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::size);
value = aAttributes->GetAttr(nsGkAtoms::size);
if (value && value->Type() == nsAttrValue::eInteger) {
sizePerSide = (float)value->GetIntegerValue() / 2.0f;
if (sizePerSide < 1.0f) {
@ -164,12 +157,10 @@ HTMLHRElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
}
}
}
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Color))) {
// color: a color
// (we got the color attribute earlier)
if (colorIsSet) {
aData->SetColorValueIfUnset(eCSSProperty_color, color);
}
// color: a color
// (we got the color attribute earlier)
if (colorIsSet) {
aData->SetColorValueIfUnset(eCSSProperty_color, color);
}
nsGenericHTMLElement::MapWidthAttributeInto(aAttributes, aData);

View File

@ -84,21 +84,19 @@ void
HTMLIFrameElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aData)
{
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Border))) {
// frameborder: 0 | 1 (| NO | YES in quirks mode)
// If frameborder is 0 or No, set border to 0
// else leave it as the value set in html.css
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::frameborder);
if (value && value->Type() == nsAttrValue::eEnum) {
int32_t frameborder = value->GetEnumValue();
if (NS_STYLE_FRAME_0 == frameborder ||
NS_STYLE_FRAME_NO == frameborder ||
NS_STYLE_FRAME_OFF == frameborder) {
aData->SetPixelValueIfUnset(eCSSProperty_border_top_width, 0.0f);
aData->SetPixelValueIfUnset(eCSSProperty_border_right_width, 0.0f);
aData->SetPixelValueIfUnset(eCSSProperty_border_bottom_width, 0.0f);
aData->SetPixelValueIfUnset(eCSSProperty_border_left_width, 0.0f);
}
// frameborder: 0 | 1 (| NO | YES in quirks mode)
// If frameborder is 0 or No, set border to 0
// else leave it as the value set in html.css
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::frameborder);
if (value && value->Type() == nsAttrValue::eEnum) {
int32_t frameborder = value->GetEnumValue();
if (NS_STYLE_FRAME_0 == frameborder ||
NS_STYLE_FRAME_NO == frameborder ||
NS_STYLE_FRAME_OFF == frameborder) {
aData->SetPixelValueIfUnset(eCSSProperty_border_top_width, 0.0f);
aData->SetPixelValueIfUnset(eCSSProperty_border_right_width, 0.0f);
aData->SetPixelValueIfUnset(eCSSProperty_border_bottom_width, 0.0f);
aData->SetPixelValueIfUnset(eCSSProperty_border_left_width, 0.0f);
}
}

View File

@ -69,13 +69,11 @@ void
HTMLLIElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aData)
{
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(List))) {
if (!aData->PropertyIsSet(eCSSProperty_list_style_type)) {
// type: enum
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::type);
if (value && value->Type() == nsAttrValue::eEnum)
aData->SetKeywordValue(eCSSProperty_list_style_type, value->GetEnumValue());
}
if (!aData->PropertyIsSet(eCSSProperty_list_style_type)) {
// type: enum
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::type);
if (value && value->Type() == nsAttrValue::eEnum)
aData->SetKeywordValue(eCSSProperty_list_style_type, value->GetEnumValue());
}
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);

View File

@ -45,12 +45,10 @@ void
HTMLPreElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aData)
{
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Text))) {
if (!aData->PropertyIsSet(eCSSProperty_white_space)) {
// wrap: empty
if (aAttributes->GetAttr(nsGkAtoms::wrap))
aData->SetKeywordValue(eCSSProperty_white_space, StyleWhiteSpace::PreWrap);
}
if (!aData->PropertyIsSet(eCSSProperty_white_space)) {
// wrap: empty
if (aAttributes->GetAttr(nsGkAtoms::wrap))
aData->SetKeywordValue(eCSSProperty_white_space, StyleWhiteSpace::PreWrap);
}
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);

View File

@ -81,16 +81,14 @@ static void
DirectoryMapAttributesIntoRule(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aData)
{
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(List))) {
if (!aData->PropertyIsSet(eCSSProperty_list_style_type)) {
// type: enum
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::type);
if (value) {
if (value->Type() == nsAttrValue::eEnum) {
aData->SetKeywordValue(eCSSProperty_list_style_type, value->GetEnumValue());
} else {
aData->SetKeywordValue(eCSSProperty_list_style_type, NS_STYLE_LIST_STYLE_DISC);
}
if (!aData->PropertyIsSet(eCSSProperty_list_style_type)) {
// type: enum
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::type);
if (value) {
if (value->Type() == nsAttrValue::eEnum) {
aData->SetKeywordValue(eCSSProperty_list_style_type, value->GetEnumValue());
} else {
aData->SetKeywordValue(eCSSProperty_list_style_type, NS_STYLE_LIST_STYLE_DISC);
}
}
}

View File

@ -83,13 +83,11 @@ void
HTMLSharedListElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aData)
{
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(List))) {
if (!aData->PropertyIsSet(eCSSProperty_list_style_type)) {
// type: enum
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::type);
if (value && value->Type() == nsAttrValue::eEnum) {
aData->SetKeywordValue(eCSSProperty_list_style_type, value->GetEnumValue());
}
if (!aData->PropertyIsSet(eCSSProperty_list_style_type)) {
// type: enum
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::type);
if (value && value->Type() == nsAttrValue::eEnum) {
aData->SetKeywordValue(eCSSProperty_list_style_type, value->GetEnumValue());
}
}

View File

@ -55,12 +55,10 @@ void
HTMLTableCaptionElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aData)
{
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(TableBorder))) {
if (!aData->PropertyIsSet(eCSSProperty_caption_side)) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
if (value && value->Type() == nsAttrValue::eEnum)
aData->SetKeywordValue(eCSSProperty_caption_side, value->GetEnumValue());
}
if (!aData->PropertyIsSet(eCSSProperty_caption_side)) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
if (value && value->Type() == nsAttrValue::eEnum)
aData->SetKeywordValue(eCSSProperty_caption_side, value->GetEnumValue());
}
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);

View File

@ -185,48 +185,44 @@ void
HTMLTableCellElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aData)
{
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Position))) {
// width: value
if (!aData->PropertyIsSet(eCSSProperty_width)) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
if (value && value->Type() == nsAttrValue::eInteger) {
if (value->GetIntegerValue() > 0)
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)
aData->SetPercentValue(eCSSProperty_width, value->GetPercentValue());
// else 0 implies auto for compatibility
}
// width: value
if (!aData->PropertyIsSet(eCSSProperty_width)) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
if (value && value->Type() == nsAttrValue::eInteger) {
if (value->GetIntegerValue() > 0)
aData->SetPixelValue(eCSSProperty_width, (float)value->GetIntegerValue());
// else 0 implies auto for compatibility.
}
// height: value
if (!aData->PropertyIsSet(eCSSProperty_height)) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::height);
if (value && value->Type() == nsAttrValue::eInteger) {
if (value->GetIntegerValue() > 0)
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)
aData->SetPercentValue(eCSSProperty_height, value->GetPercentValue());
// else 0 implies auto for compatibility
}
else if (value && value->Type() == nsAttrValue::ePercent) {
if (value->GetPercentValue() > 0.0f)
aData->SetPercentValue(eCSSProperty_width, value->GetPercentValue());
// else 0 implies auto for compatibility
}
}
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->Document()->GetCompatibilityMode();
if (!value || value->Type() != nsAttrValue::eInteger ||
value->GetIntegerValue() == 0 ||
eCompatibility_NavQuirks != mode) {
aData->SetKeywordValue(eCSSProperty_white_space, StyleWhiteSpace::Nowrap);
}
// height: value
if (!aData->PropertyIsSet(eCSSProperty_height)) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::height);
if (value && value->Type() == nsAttrValue::eInteger) {
if (value->GetIntegerValue() > 0)
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)
aData->SetPercentValue(eCSSProperty_height, value->GetPercentValue());
// else 0 implies auto for compatibility
}
}
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->Document()->GetCompatibilityMode();
if (!value || value->Type() != nsAttrValue::eInteger ||
value->GetIntegerValue() == 0 ||
eCompatibility_NavQuirks != mode) {
aData->SetKeywordValue(eCSSProperty_white_space, StyleWhiteSpace::Nowrap);
}
}
}

View File

@ -67,18 +67,16 @@ void
HTMLTableColElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aData)
{
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Table))) {
if (!aData->PropertyIsSet(eCSSProperty__x_span)) {
// span: int
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::span);
if (value && value->Type() == nsAttrValue::eInteger) {
int32_t 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->SetIntValue(eCSSProperty__x_span, value->GetIntegerValue());
}
if (!aData->PropertyIsSet(eCSSProperty__x_span)) {
// span: int
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::span);
if (value && value->Type() == nsAttrValue::eInteger) {
int32_t 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->SetIntValue(eCSSProperty__x_span, value->GetIntegerValue());
}
}
}

View File

@ -946,73 +946,67 @@ HTMLTableElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
nsCompatibility mode = aData->Document()->GetCompatibilityMode();
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(TableBorder))) {
// cellspacing
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::cellspacing);
if (value && value->Type() == nsAttrValue::eInteger &&
!aData->PropertyIsSet(eCSSProperty_border_spacing)) {
aData->SetPixelValue(eCSSProperty_border_spacing, float(value->GetIntegerValue()));
// cellspacing
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::cellspacing);
if (value && value->Type() == nsAttrValue::eInteger &&
!aData->PropertyIsSet(eCSSProperty_border_spacing)) {
aData->SetPixelValue(eCSSProperty_border_spacing, float(value->GetIntegerValue()));
}
// align; Check for enumerated type (it may be another type if
// illegal)
value = aAttributes->GetAttr(nsGkAtoms::align);
if (value && value->Type() == nsAttrValue::eEnum) {
if (value->GetEnumValue() == NS_STYLE_TEXT_ALIGN_CENTER ||
value->GetEnumValue() == NS_STYLE_TEXT_ALIGN_MOZ_CENTER) {
aData->SetAutoValueIfUnset(eCSSProperty_margin_left);
aData->SetAutoValueIfUnset(eCSSProperty_margin_right);
}
}
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Margin))) {
// align; Check for enumerated type (it may be another type if
// illegal)
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
if (value && value->Type() == nsAttrValue::eEnum) {
if (value->GetEnumValue() == NS_STYLE_TEXT_ALIGN_CENTER ||
value->GetEnumValue() == NS_STYLE_TEXT_ALIGN_MOZ_CENTER) {
aData->SetAutoValueIfUnset(eCSSProperty_margin_left);
aData->SetAutoValueIfUnset(eCSSProperty_margin_right);
}
// hspace is mapped into left and right margin,
// vspace is mapped into top and bottom margins
// - *** Quirks Mode only ***
if (eCompatibility_NavQuirks == mode) {
value = aAttributes->GetAttr(nsGkAtoms::hspace);
if (value && value->Type() == nsAttrValue::eInteger) {
aData->SetPixelValueIfUnset(eCSSProperty_margin_left, (float)value->GetIntegerValue());
aData->SetPixelValueIfUnset(eCSSProperty_margin_right, (float)value->GetIntegerValue());
}
// hspace is mapped into left and right margin,
// vspace is mapped into top and bottom margins
// - *** Quirks Mode only ***
if (eCompatibility_NavQuirks == mode) {
value = aAttributes->GetAttr(nsGkAtoms::hspace);
value = aAttributes->GetAttr(nsGkAtoms::vspace);
if (value && value->Type() == nsAttrValue::eInteger) {
aData->SetPixelValueIfUnset(eCSSProperty_margin_left, (float)value->GetIntegerValue());
aData->SetPixelValueIfUnset(eCSSProperty_margin_right, (float)value->GetIntegerValue());
}
value = aAttributes->GetAttr(nsGkAtoms::vspace);
if (value && value->Type() == nsAttrValue::eInteger) {
aData->SetPixelValueIfUnset(eCSSProperty_margin_top, (float)value->GetIntegerValue());
aData->SetPixelValueIfUnset(eCSSProperty_margin_bottom, (float)value->GetIntegerValue());
}
if (value && value->Type() == nsAttrValue::eInteger) {
aData->SetPixelValueIfUnset(eCSSProperty_margin_top, (float)value->GetIntegerValue());
aData->SetPixelValueIfUnset(eCSSProperty_margin_bottom, (float)value->GetIntegerValue());
}
}
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Border))) {
// bordercolor
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::bordercolor);
nscolor color;
if (value && value->GetColorValue(color)) {
aData->SetColorValueIfUnset(eCSSProperty_border_top_color, color);
aData->SetColorValueIfUnset(eCSSProperty_border_left_color, color);
aData->SetColorValueIfUnset(eCSSProperty_border_bottom_color, color);
aData->SetColorValueIfUnset(eCSSProperty_border_right_color, color);
}
// border
const nsAttrValue* borderValue = aAttributes->GetAttr(nsGkAtoms::border);
if (borderValue) {
// border = 1 pixel default
int32_t borderThickness = 1;
if (borderValue->Type() == nsAttrValue::eInteger)
borderThickness = borderValue->GetIntegerValue();
// by default, set all border sides to the specified width
aData->SetPixelValueIfUnset(eCSSProperty_border_top_width, (float)borderThickness);
aData->SetPixelValueIfUnset(eCSSProperty_border_left_width, (float)borderThickness);
aData->SetPixelValueIfUnset(eCSSProperty_border_bottom_width, (float)borderThickness);
aData->SetPixelValueIfUnset(eCSSProperty_border_right_width, (float)borderThickness);
}
// bordercolor
value = aAttributes->GetAttr(nsGkAtoms::bordercolor);
nscolor color;
if (value && value->GetColorValue(color)) {
aData->SetColorValueIfUnset(eCSSProperty_border_top_color, color);
aData->SetColorValueIfUnset(eCSSProperty_border_left_color, color);
aData->SetColorValueIfUnset(eCSSProperty_border_bottom_color, color);
aData->SetColorValueIfUnset(eCSSProperty_border_right_color, color);
}
// border
const nsAttrValue* borderValue = aAttributes->GetAttr(nsGkAtoms::border);
if (borderValue) {
// border = 1 pixel default
int32_t borderThickness = 1;
if (borderValue->Type() == nsAttrValue::eInteger)
borderThickness = borderValue->GetIntegerValue();
// by default, set all border sides to the specified width
aData->SetPixelValueIfUnset(eCSSProperty_border_top_width, (float)borderThickness);
aData->SetPixelValueIfUnset(eCSSProperty_border_left_width, (float)borderThickness);
aData->SetPixelValueIfUnset(eCSSProperty_border_bottom_width, (float)borderThickness);
aData->SetPixelValueIfUnset(eCSSProperty_border_right_width, (float)borderThickness);
}
nsGenericHTMLElement::MapImageSizeAttributesInto(aAttributes, aData);
nsGenericHTMLElement::MapBackgroundAttributesInto(aAttributes, aData);
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
@ -1055,18 +1049,16 @@ static void
MapInheritedTableAttributesIntoRule(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aData)
{
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Padding))) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::cellpadding);
if (value && value->Type() == nsAttrValue::eInteger) {
// We have cellpadding. This will override our padding values if we
// don't have any set.
float pad = float(value->GetIntegerValue());
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::cellpadding);
if (value && value->Type() == nsAttrValue::eInteger) {
// We have cellpadding. This will override our padding values if we
// don't have any set.
float pad = float(value->GetIntegerValue());
aData->SetPixelValueIfUnset(eCSSProperty_padding_top, pad);
aData->SetPixelValueIfUnset(eCSSProperty_padding_right, pad);
aData->SetPixelValueIfUnset(eCSSProperty_padding_bottom, pad);
aData->SetPixelValueIfUnset(eCSSProperty_padding_left, pad);
}
aData->SetPixelValueIfUnset(eCSSProperty_padding_top, pad);
aData->SetPixelValueIfUnset(eCSSProperty_padding_right, pad);
aData->SetPixelValueIfUnset(eCSSProperty_padding_bottom, pad);
aData->SetPixelValueIfUnset(eCSSProperty_padding_left, pad);
}
}

View File

@ -165,13 +165,11 @@ void
HTMLTableSectionElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aData)
{
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Position))) {
// height: value
if (!aData->PropertyIsSet(eCSSProperty_height)) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::height);
if (value && value->Type() == nsAttrValue::eInteger)
aData->SetPixelValue(eCSSProperty_height, (float)value->GetIntegerValue());
}
// height: value
if (!aData->PropertyIsSet(eCSSProperty_height)) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::height);
if (value && value->Type() == nsAttrValue::eInteger)
aData->SetPixelValue(eCSSProperty_height, (float)value->GetIntegerValue());
}
nsGenericHTMLElement::MapDivAlignAttributeInto(aAttributes, aData);
nsGenericHTMLElement::MapVAlignAttributeInto(aAttributes, aData);

View File

@ -450,14 +450,12 @@ void
HTMLTextAreaElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aData)
{
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Text))) {
// wrap=off
if (!aData->PropertyIsSet(eCSSProperty_white_space)) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::wrap);
if (value && value->Type() == nsAttrValue::eString &&
value->Equals(nsGkAtoms::OFF, eIgnoreCase)) {
aData->SetKeywordValue(eCSSProperty_white_space, StyleWhiteSpace::Pre);
}
// wrap=off
if (!aData->PropertyIsSet(eCSSProperty_white_space)) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::wrap);
if (value && value->Type() == nsAttrValue::eString &&
value->Equals(nsGkAtoms::OFF, eIgnoreCase)) {
aData->SetKeywordValue(eCSSProperty_white_space, StyleWhiteSpace::Pre);
}
}

View File

@ -1161,33 +1161,24 @@ nsGenericHTMLElement::ParseScrollingValue(const nsAString& aString,
static inline void
MapLangAttributeInto(const nsMappedAttributes* aAttributes, GenericSpecifiedValues* aData)
{
if (!aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Font) |
NS_STYLE_INHERIT_BIT(Text))) {
return;
}
const nsAttrValue* langValue = aAttributes->GetAttr(nsGkAtoms::lang);
if (!langValue) {
return;
}
MOZ_ASSERT(langValue->Type() == nsAttrValue::eAtom);
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Font))) {
aData->SetIdentAtomValueIfUnset(eCSSProperty__x_lang,
langValue->GetAtomValue());
}
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Text))) {
if (!aData->PropertyIsSet(eCSSProperty_text_emphasis_position)) {
const nsAtom* lang = langValue->GetAtomValue();
if (nsStyleUtil::MatchesLanguagePrefix(lang, u"zh")) {
aData->SetKeywordValue(eCSSProperty_text_emphasis_position,
NS_STYLE_TEXT_EMPHASIS_POSITION_DEFAULT_ZH);
} else if (nsStyleUtil::MatchesLanguagePrefix(lang, u"ja") ||
nsStyleUtil::MatchesLanguagePrefix(lang, u"mn")) {
// This branch is currently no part of the spec.
// See bug 1040668 comment 69 and comment 75.
aData->SetKeywordValue(eCSSProperty_text_emphasis_position,
NS_STYLE_TEXT_EMPHASIS_POSITION_DEFAULT);
}
aData->SetIdentAtomValueIfUnset(eCSSProperty__x_lang,
langValue->GetAtomValue());
if (!aData->PropertyIsSet(eCSSProperty_text_emphasis_position)) {
const nsAtom* lang = langValue->GetAtomValue();
if (nsStyleUtil::MatchesLanguagePrefix(lang, u"zh")) {
aData->SetKeywordValue(eCSSProperty_text_emphasis_position,
NS_STYLE_TEXT_EMPHASIS_POSITION_DEFAULT_ZH);
} else if (nsStyleUtil::MatchesLanguagePrefix(lang, u"ja") ||
nsStyleUtil::MatchesLanguagePrefix(lang, u"mn")) {
// This branch is currently no part of the spec.
// See bug 1040668 comment 69 and comment 75.
aData->SetKeywordValue(eCSSProperty_text_emphasis_position,
NS_STYLE_TEXT_EMPHASIS_POSITION_DEFAULT);
}
}
}
@ -1199,20 +1190,18 @@ void
nsGenericHTMLElement::MapCommonAttributesIntoExceptHidden(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aData)
{
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(UserInterface))) {
if (!aData->PropertyIsSet(eCSSProperty__moz_user_modify)) {
const nsAttrValue* value =
aAttributes->GetAttr(nsGkAtoms::contenteditable);
if (value) {
if (value->Equals(nsGkAtoms::_empty, eCaseMatters) ||
value->Equals(nsGkAtoms::_true, eIgnoreCase)) {
if (!aData->PropertyIsSet(eCSSProperty__moz_user_modify)) {
const nsAttrValue* value =
aAttributes->GetAttr(nsGkAtoms::contenteditable);
if (value) {
if (value->Equals(nsGkAtoms::_empty, eCaseMatters) ||
value->Equals(nsGkAtoms::_true, eIgnoreCase)) {
aData->SetKeywordValue(eCSSProperty__moz_user_modify,
StyleUserModify::ReadWrite);
}
else if (value->Equals(nsGkAtoms::_false, eIgnoreCase)) {
aData->SetKeywordValue(eCSSProperty__moz_user_modify,
StyleUserModify::ReadWrite);
}
else if (value->Equals(nsGkAtoms::_false, eIgnoreCase)) {
aData->SetKeywordValue(eCSSProperty__moz_user_modify,
StyleUserModify::ReadOnly);
}
StyleUserModify::ReadOnly);
}
}
}
@ -1226,11 +1215,9 @@ nsGenericHTMLElement::MapCommonAttributesInto(const nsMappedAttributes* aAttribu
{
MapCommonAttributesIntoExceptHidden(aAttributes, aData);
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Display))) {
if (!aData->PropertyIsSet(eCSSProperty_display)) {
if (aAttributes->IndexOfAttr(nsGkAtoms::hidden) >= 0) {
aData->SetKeywordValue(eCSSProperty_display, StyleDisplay::None);
}
if (!aData->PropertyIsSet(eCSSProperty_display)) {
if (aAttributes->IndexOfAttr(nsGkAtoms::hidden) >= 0) {
aData->SetKeywordValue(eCSSProperty_display, StyleDisplay::None);
}
}
}
@ -1287,26 +1274,24 @@ void
nsGenericHTMLElement::MapImageAlignAttributeInto(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aData)
{
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Display))) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
if (value && value->Type() == nsAttrValue::eEnum) {
int32_t align = value->GetEnumValue();
if (!aData->PropertyIsSet(eCSSProperty_float_)) {
if (align == NS_STYLE_TEXT_ALIGN_LEFT) {
aData->SetKeywordValue(eCSSProperty_float_, StyleFloat::Left);
} else if (align == NS_STYLE_TEXT_ALIGN_RIGHT) {
aData->SetKeywordValue(eCSSProperty_float_, StyleFloat::Right);
}
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
if (value && value->Type() == nsAttrValue::eEnum) {
int32_t align = value->GetEnumValue();
if (!aData->PropertyIsSet(eCSSProperty_float_)) {
if (align == NS_STYLE_TEXT_ALIGN_LEFT) {
aData->SetKeywordValue(eCSSProperty_float_, StyleFloat::Left);
} else if (align == NS_STYLE_TEXT_ALIGN_RIGHT) {
aData->SetKeywordValue(eCSSProperty_float_, StyleFloat::Right);
}
if (!aData->PropertyIsSet(eCSSProperty_vertical_align)) {
switch (align) {
case NS_STYLE_TEXT_ALIGN_LEFT:
case NS_STYLE_TEXT_ALIGN_RIGHT:
break;
default:
aData->SetKeywordValue(eCSSProperty_vertical_align, align);
break;
}
}
if (!aData->PropertyIsSet(eCSSProperty_vertical_align)) {
switch (align) {
case NS_STYLE_TEXT_ALIGN_LEFT:
case NS_STYLE_TEXT_ALIGN_RIGHT:
break;
default:
aData->SetKeywordValue(eCSSProperty_vertical_align, align);
break;
}
}
}
@ -1316,13 +1301,11 @@ void
nsGenericHTMLElement::MapDivAlignAttributeInto(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aData)
{
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Text))) {
if (!aData->PropertyIsSet(eCSSProperty_text_align)) {
// align: enum
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
if (value && value->Type() == nsAttrValue::eEnum)
aData->SetKeywordValue(eCSSProperty_text_align, value->GetEnumValue());
}
if (!aData->PropertyIsSet(eCSSProperty_text_align)) {
// align: enum
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
if (value && value->Type() == nsAttrValue::eEnum)
aData->SetKeywordValue(eCSSProperty_text_align, value->GetEnumValue());
}
}
@ -1330,13 +1313,11 @@ void
nsGenericHTMLElement::MapVAlignAttributeInto(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aData)
{
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Display))) {
if (!aData->PropertyIsSet(eCSSProperty_vertical_align)) {
// align: enum
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::valign);
if (value && value->Type() == nsAttrValue::eEnum)
aData->SetKeywordValue(eCSSProperty_vertical_align, value->GetEnumValue());
}
if (!aData->PropertyIsSet(eCSSProperty_vertical_align)) {
// align: enum
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::valign);
if (value && value->Type() == nsAttrValue::eEnum)
aData->SetKeywordValue(eCSSProperty_vertical_align, value->GetEnumValue());
}
}
@ -1344,9 +1325,6 @@ void
nsGenericHTMLElement::MapImageMarginAttributeInto(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aData)
{
if (!aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Margin)))
return;
const nsAttrValue* value;
// hspace: value
@ -1386,10 +1364,6 @@ void
nsGenericHTMLElement::MapWidthAttributeInto(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aData)
{
if (!aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Position))) {
return;
}
// width: value
if (!aData->PropertyIsSet(eCSSProperty_width)) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
@ -1407,9 +1381,6 @@ void
nsGenericHTMLElement::MapHeightAttributeInto(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aData)
{
if (!aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Position)))
return;
// height: value
if (!aData->PropertyIsSet(eCSSProperty_height)) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::height);
@ -1435,9 +1406,6 @@ void
nsGenericHTMLElement::MapImageBorderAttributeInto(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aData)
{
if (!(aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Border))))
return;
// border: pixels
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::border);
if (!value)
@ -1472,9 +1440,6 @@ nsGenericHTMLElement::MapBackgroundInto(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aData)
{
if (!aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Background)))
return;
if (!aData->PropertyIsSet(eCSSProperty_background_image)) {
// background
nsAttrValue* value =
@ -1489,9 +1454,6 @@ void
nsGenericHTMLElement::MapBGColorInto(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aData)
{
if (!aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Background)))
return;
if (!aData->PropertyIsSet(eCSSProperty_background_color)) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::bgcolor);
nscolor color;

View File

@ -502,280 +502,278 @@ void
nsMathMLElement::MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
GenericSpecifiedValues* aData)
{
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Font)) {
// scriptsizemultiplier
//
// "Specifies the multiplier to be used to adjust font size due to changes
// in scriptlevel.
//
// values: number
// default: 0.71
//
const nsAttrValue* value =
aAttributes->GetAttr(nsGkAtoms::scriptsizemultiplier_);
if (value && value->Type() == nsAttrValue::eString &&
!aData->PropertyIsSet(eCSSProperty__moz_script_size_multiplier)) {
nsAutoString str(value->GetStringValue());
str.CompressWhitespace();
// MathML numbers can't have leading '+'
if (str.Length() > 0 && str.CharAt(0) != '+') {
nsresult errorCode;
float floatValue = str.ToFloat(&errorCode);
// Negative scriptsizemultipliers are not parsed
if (NS_SUCCEEDED(errorCode) && floatValue >= 0.0f) {
aData->SetNumberValue(eCSSProperty__moz_script_size_multiplier, floatValue);
// scriptsizemultiplier
//
// "Specifies the multiplier to be used to adjust font size due to changes
// in scriptlevel.
//
// values: number
// default: 0.71
//
const nsAttrValue* value =
aAttributes->GetAttr(nsGkAtoms::scriptsizemultiplier_);
if (value && value->Type() == nsAttrValue::eString &&
!aData->PropertyIsSet(eCSSProperty__moz_script_size_multiplier)) {
nsAutoString str(value->GetStringValue());
str.CompressWhitespace();
// MathML numbers can't have leading '+'
if (str.Length() > 0 && str.CharAt(0) != '+') {
nsresult errorCode;
float floatValue = str.ToFloat(&errorCode);
// Negative scriptsizemultipliers are not parsed
if (NS_SUCCEEDED(errorCode) && floatValue >= 0.0f) {
aData->SetNumberValue(eCSSProperty__moz_script_size_multiplier, floatValue);
} else {
ReportParseErrorNoTag(str,
nsGkAtoms::scriptsizemultiplier_,
aData->Document());
}
}
}
// scriptminsize
//
// "Specifies the minimum font size allowed due to changes in scriptlevel.
// Note that this does not limit the font size due to changes to mathsize."
//
// values: length
// default: 8pt
//
// We don't allow negative values.
// Unitless and percent values give a multiple of the default value.
//
value = aAttributes->GetAttr(nsGkAtoms::scriptminsize_);
if (value && value->Type() == nsAttrValue::eString &&
!aData->PropertyIsSet(eCSSProperty__moz_script_min_size)) {
nsCSSValue scriptMinSize;
ParseNumericValue(value->GetStringValue(), scriptMinSize,
PARSE_ALLOW_UNITLESS | CONVERT_UNITLESS_TO_PERCENT,
aData->Document());
if (scriptMinSize.GetUnit() == eCSSUnit_Percent) {
scriptMinSize.SetFloatValue(8.0 * scriptMinSize.GetPercentValue(),
eCSSUnit_Point);
}
if (scriptMinSize.GetUnit() != eCSSUnit_Null) {
aData->SetLengthValue(eCSSProperty__moz_script_min_size, scriptMinSize);
}
}
// scriptlevel
//
// "Changes the scriptlevel in effect for the children. When the value is
// given without a sign, it sets scriptlevel to the specified value; when a
// sign is given, it increments ("+") or decrements ("-") the current
// value. (Note that large decrements can result in negative values of
// scriptlevel, but these values are considered legal.)"
//
// values: ( "+" | "-" )? unsigned-integer
// default: inherited
//
value = aAttributes->GetAttr(nsGkAtoms::scriptlevel_);
if (value && value->Type() == nsAttrValue::eString &&
!aData->PropertyIsSet(eCSSProperty__moz_script_level)) {
nsAutoString str(value->GetStringValue());
str.CompressWhitespace();
if (str.Length() > 0) {
nsresult errorCode;
int32_t intValue = str.ToInteger(&errorCode);
if (NS_SUCCEEDED(errorCode)) {
// This is kind of cheesy ... if the scriptlevel has a sign,
// then it's a relative value and we store the nsCSSValue as an
// Integer to indicate that. Otherwise we store it as a Number
// to indicate that the scriptlevel is absolute.
char16_t ch = str.CharAt(0);
if (ch == '+' || ch == '-') {
aData->SetIntValue(eCSSProperty__moz_script_level, intValue);
} else {
ReportParseErrorNoTag(str,
nsGkAtoms::scriptsizemultiplier_,
aData->Document());
aData->SetNumberValue(eCSSProperty__moz_script_level, intValue);
}
} else {
ReportParseErrorNoTag(str,
nsGkAtoms::scriptlevel_,
aData->Document());
}
}
}
// scriptminsize
//
// "Specifies the minimum font size allowed due to changes in scriptlevel.
// Note that this does not limit the font size due to changes to mathsize."
//
// values: length
// default: 8pt
//
// We don't allow negative values.
// Unitless and percent values give a multiple of the default value.
//
value = aAttributes->GetAttr(nsGkAtoms::scriptminsize_);
if (value && value->Type() == nsAttrValue::eString &&
!aData->PropertyIsSet(eCSSProperty__moz_script_min_size)) {
nsCSSValue scriptMinSize;
ParseNumericValue(value->GetStringValue(), scriptMinSize,
PARSE_ALLOW_UNITLESS | CONVERT_UNITLESS_TO_PERCENT,
aData->Document());
if (scriptMinSize.GetUnit() == eCSSUnit_Percent) {
scriptMinSize.SetFloatValue(8.0 * scriptMinSize.GetPercentValue(),
eCSSUnit_Point);
}
if (scriptMinSize.GetUnit() != eCSSUnit_Null) {
aData->SetLengthValue(eCSSProperty__moz_script_min_size, scriptMinSize);
}
}
// scriptlevel
//
// "Changes the scriptlevel in effect for the children. When the value is
// given without a sign, it sets scriptlevel to the specified value; when a
// sign is given, it increments ("+") or decrements ("-") the current
// value. (Note that large decrements can result in negative values of
// scriptlevel, but these values are considered legal.)"
//
// values: ( "+" | "-" )? unsigned-integer
// default: inherited
//
value = aAttributes->GetAttr(nsGkAtoms::scriptlevel_);
if (value && value->Type() == nsAttrValue::eString &&
!aData->PropertyIsSet(eCSSProperty__moz_script_level)) {
nsAutoString str(value->GetStringValue());
str.CompressWhitespace();
if (str.Length() > 0) {
nsresult errorCode;
int32_t intValue = str.ToInteger(&errorCode);
if (NS_SUCCEEDED(errorCode)) {
// This is kind of cheesy ... if the scriptlevel has a sign,
// then it's a relative value and we store the nsCSSValue as an
// Integer to indicate that. Otherwise we store it as a Number
// to indicate that the scriptlevel is absolute.
char16_t ch = str.CharAt(0);
if (ch == '+' || ch == '-') {
aData->SetIntValue(eCSSProperty__moz_script_level, intValue);
} else {
aData->SetNumberValue(eCSSProperty__moz_script_level, intValue);
}
} else {
ReportParseErrorNoTag(str,
nsGkAtoms::scriptlevel_,
aData->Document());
}
}
}
// mathsize
//
// "Specifies the size to display the token content. The values 'small' and
// 'big' choose a size smaller or larger than the current font size, but
// leave the exact proportions unspecified; 'normal' is allowed for
// completeness, but since it is equivalent to '100%' or '1em', it has no
// effect."
//
// values: "small" | "normal" | "big" | length
// default: inherited
//
// fontsize
//
// "Specified the size for the token. Deprecated in favor of mathsize."
//
// values: length
// default: inherited
//
// In both cases, we don't allow negative values.
// Unitless values give a multiple of the default value.
//
bool parseSizeKeywords = true;
value = aAttributes->GetAttr(nsGkAtoms::mathsize_);
if (!value) {
parseSizeKeywords = false;
value = aAttributes->GetAttr(nsGkAtoms::fontsize_);
if (value) {
WarnDeprecated(nsGkAtoms::fontsize_->GetUTF16String(),
nsGkAtoms::mathsize_->GetUTF16String(),
aData->Document());
}
}
if (value && value->Type() == nsAttrValue::eString &&
!aData->PropertyIsSet(eCSSProperty_font_size)) {
nsAutoString str(value->GetStringValue());
nsCSSValue fontSize;
if (!ParseNumericValue(str, fontSize, PARSE_SUPPRESS_WARNINGS |
PARSE_ALLOW_UNITLESS | CONVERT_UNITLESS_TO_PERCENT,
nullptr)
&& parseSizeKeywords) {
static const char sizes[3][7] = { "small", "normal", "big" };
static const int32_t values[MOZ_ARRAY_LENGTH(sizes)] = {
NS_STYLE_FONT_SIZE_SMALL, NS_STYLE_FONT_SIZE_MEDIUM,
NS_STYLE_FONT_SIZE_LARGE
};
str.CompressWhitespace();
for (uint32_t i = 0; i < ArrayLength(sizes); ++i) {
if (str.EqualsASCII(sizes[i])) {
aData->SetKeywordValue(eCSSProperty_font_size, values[i]);
break;
}
}
} else if (fontSize.GetUnit() == eCSSUnit_Percent) {
aData->SetPercentValue(eCSSProperty_font_size,
fontSize.GetPercentValue());
} else if (fontSize.GetUnit() != eCSSUnit_Null) {
aData->SetLengthValue(eCSSProperty_font_size, fontSize);
}
}
// fontfamily
//
// "Should be the name of a font that may be available to a MathML renderer,
// or a CSS font specification; See Section 6.5 Using CSS with MathML and
// CSS for more information. Deprecated in favor of mathvariant."
//
// values: string
//
value = aAttributes->GetAttr(nsGkAtoms::fontfamily_);
// mathsize
//
// "Specifies the size to display the token content. The values 'small' and
// 'big' choose a size smaller or larger than the current font size, but
// leave the exact proportions unspecified; 'normal' is allowed for
// completeness, but since it is equivalent to '100%' or '1em', it has no
// effect."
//
// values: "small" | "normal" | "big" | length
// default: inherited
//
// fontsize
//
// "Specified the size for the token. Deprecated in favor of mathsize."
//
// values: length
// default: inherited
//
// In both cases, we don't allow negative values.
// Unitless values give a multiple of the default value.
//
bool parseSizeKeywords = true;
value = aAttributes->GetAttr(nsGkAtoms::mathsize_);
if (!value) {
parseSizeKeywords = false;
value = aAttributes->GetAttr(nsGkAtoms::fontsize_);
if (value) {
WarnDeprecated(nsGkAtoms::fontfamily_->GetUTF16String(),
nsGkAtoms::mathvariant_->GetUTF16String(),
WarnDeprecated(nsGkAtoms::fontsize_->GetUTF16String(),
nsGkAtoms::mathsize_->GetUTF16String(),
aData->Document());
}
if (value && value->Type() == nsAttrValue::eString &&
!aData->PropertyIsSet(eCSSProperty_font_family)) {
aData->SetFontFamily(value->GetStringValue());
}
// fontstyle
//
// "Specified the font style to use for the token. Deprecated in favor of
// mathvariant."
//
// values: "normal" | "italic"
// default: normal (except on <mi>)
//
// Note that the font-style property is reset in layout/style/ when
// -moz-math-variant is specified.
value = aAttributes->GetAttr(nsGkAtoms::fontstyle_);
if (value) {
WarnDeprecated(nsGkAtoms::fontstyle_->GetUTF16String(),
nsGkAtoms::mathvariant_->GetUTF16String(),
aData->Document());
if (value->Type() == nsAttrValue::eString &&
!aData->PropertyIsSet(eCSSProperty_font_style)) {
nsAutoString str(value->GetStringValue());
str.CompressWhitespace();
if (str.EqualsASCII("normal")) {
aData->SetKeywordValue(eCSSProperty_font_style,
NS_STYLE_FONT_STYLE_NORMAL);
} else if (str.EqualsASCII("italic")) {
aData->SetKeywordValue(eCSSProperty_font_style,
NS_STYLE_FONT_STYLE_ITALIC);
}
}
}
// fontweight
//
// "Specified the font weight for the token. Deprecated in favor of
// mathvariant."
//
// values: "normal" | "bold"
// default: normal
//
// Note that the font-weight property is reset in layout/style/ when
// -moz-math-variant is specified.
value = aAttributes->GetAttr(nsGkAtoms::fontweight_);
if (value) {
WarnDeprecated(nsGkAtoms::fontweight_->GetUTF16String(),
nsGkAtoms::mathvariant_->GetUTF16String(),
aData->Document());
if (value->Type() == nsAttrValue::eString &&
!aData->PropertyIsSet(eCSSProperty_font_weight)) {
nsAutoString str(value->GetStringValue());
str.CompressWhitespace();
if (str.EqualsASCII("normal")) {
aData->SetKeywordValue(eCSSProperty_font_weight,
NS_STYLE_FONT_WEIGHT_NORMAL);
} else if (str.EqualsASCII("bold")) {
aData->SetKeywordValue(eCSSProperty_font_weight,
NS_STYLE_FONT_WEIGHT_BOLD);
}
}
}
// mathvariant
//
// "Specifies the logical class of the token. Note that this class is more
// than styling, it typically conveys semantic intent;"
//
// values: "normal" | "bold" | "italic" | "bold-italic" | "double-struck" |
// "bold-fraktur" | "script" | "bold-script" | "fraktur" | "sans-serif" |
// "bold-sans-serif" | "sans-serif-italic" | "sans-serif-bold-italic" |
// "monospace" | "initial" | "tailed" | "looped" | "stretched"
// default: normal (except on <mi>)
//
value = aAttributes->GetAttr(nsGkAtoms::mathvariant_);
if (value && value->Type() == nsAttrValue::eString &&
!aData->PropertyIsSet(eCSSProperty__moz_math_variant)) {
nsAutoString str(value->GetStringValue());
str.CompressWhitespace();
static const char sizes[19][23] = {
"normal", "bold", "italic", "bold-italic", "script", "bold-script",
"fraktur", "double-struck", "bold-fraktur", "sans-serif",
"bold-sans-serif", "sans-serif-italic", "sans-serif-bold-italic",
"monospace", "initial", "tailed", "looped", "stretched"
};
}
if (value && value->Type() == nsAttrValue::eString &&
!aData->PropertyIsSet(eCSSProperty_font_size)) {
nsAutoString str(value->GetStringValue());
nsCSSValue fontSize;
if (!ParseNumericValue(str, fontSize, PARSE_SUPPRESS_WARNINGS |
PARSE_ALLOW_UNITLESS | CONVERT_UNITLESS_TO_PERCENT,
nullptr)
&& parseSizeKeywords) {
static const char sizes[3][7] = { "small", "normal", "big" };
static const int32_t values[MOZ_ARRAY_LENGTH(sizes)] = {
NS_MATHML_MATHVARIANT_NORMAL, NS_MATHML_MATHVARIANT_BOLD,
NS_MATHML_MATHVARIANT_ITALIC, NS_MATHML_MATHVARIANT_BOLD_ITALIC,
NS_MATHML_MATHVARIANT_SCRIPT, NS_MATHML_MATHVARIANT_BOLD_SCRIPT,
NS_MATHML_MATHVARIANT_FRAKTUR, NS_MATHML_MATHVARIANT_DOUBLE_STRUCK,
NS_MATHML_MATHVARIANT_BOLD_FRAKTUR, NS_MATHML_MATHVARIANT_SANS_SERIF,
NS_MATHML_MATHVARIANT_BOLD_SANS_SERIF,
NS_MATHML_MATHVARIANT_SANS_SERIF_ITALIC,
NS_MATHML_MATHVARIANT_SANS_SERIF_BOLD_ITALIC,
NS_MATHML_MATHVARIANT_MONOSPACE, NS_MATHML_MATHVARIANT_INITIAL,
NS_MATHML_MATHVARIANT_TAILED, NS_MATHML_MATHVARIANT_LOOPED,
NS_MATHML_MATHVARIANT_STRETCHED
NS_STYLE_FONT_SIZE_SMALL, NS_STYLE_FONT_SIZE_MEDIUM,
NS_STYLE_FONT_SIZE_LARGE
};
str.CompressWhitespace();
for (uint32_t i = 0; i < ArrayLength(sizes); ++i) {
if (str.EqualsASCII(sizes[i])) {
aData->SetKeywordValue(eCSSProperty__moz_math_variant, values[i]);
aData->SetKeywordValue(eCSSProperty_font_size, values[i]);
break;
}
}
} else if (fontSize.GetUnit() == eCSSUnit_Percent) {
aData->SetPercentValue(eCSSProperty_font_size,
fontSize.GetPercentValue());
} else if (fontSize.GetUnit() != eCSSUnit_Null) {
aData->SetLengthValue(eCSSProperty_font_size, fontSize);
}
}
// fontfamily
//
// "Should be the name of a font that may be available to a MathML renderer,
// or a CSS font specification; See Section 6.5 Using CSS with MathML and
// CSS for more information. Deprecated in favor of mathvariant."
//
// values: string
//
value = aAttributes->GetAttr(nsGkAtoms::fontfamily_);
if (value) {
WarnDeprecated(nsGkAtoms::fontfamily_->GetUTF16String(),
nsGkAtoms::mathvariant_->GetUTF16String(),
aData->Document());
}
if (value && value->Type() == nsAttrValue::eString &&
!aData->PropertyIsSet(eCSSProperty_font_family)) {
aData->SetFontFamily(value->GetStringValue());
}
// fontstyle
//
// "Specified the font style to use for the token. Deprecated in favor of
// mathvariant."
//
// values: "normal" | "italic"
// default: normal (except on <mi>)
//
// Note that the font-style property is reset in layout/style/ when
// -moz-math-variant is specified.
value = aAttributes->GetAttr(nsGkAtoms::fontstyle_);
if (value) {
WarnDeprecated(nsGkAtoms::fontstyle_->GetUTF16String(),
nsGkAtoms::mathvariant_->GetUTF16String(),
aData->Document());
if (value->Type() == nsAttrValue::eString &&
!aData->PropertyIsSet(eCSSProperty_font_style)) {
nsAutoString str(value->GetStringValue());
str.CompressWhitespace();
if (str.EqualsASCII("normal")) {
aData->SetKeywordValue(eCSSProperty_font_style,
NS_STYLE_FONT_STYLE_NORMAL);
} else if (str.EqualsASCII("italic")) {
aData->SetKeywordValue(eCSSProperty_font_style,
NS_STYLE_FONT_STYLE_ITALIC);
}
}
}
// fontweight
//
// "Specified the font weight for the token. Deprecated in favor of
// mathvariant."
//
// values: "normal" | "bold"
// default: normal
//
// Note that the font-weight property is reset in layout/style/ when
// -moz-math-variant is specified.
value = aAttributes->GetAttr(nsGkAtoms::fontweight_);
if (value) {
WarnDeprecated(nsGkAtoms::fontweight_->GetUTF16String(),
nsGkAtoms::mathvariant_->GetUTF16String(),
aData->Document());
if (value->Type() == nsAttrValue::eString &&
!aData->PropertyIsSet(eCSSProperty_font_weight)) {
nsAutoString str(value->GetStringValue());
str.CompressWhitespace();
if (str.EqualsASCII("normal")) {
aData->SetKeywordValue(eCSSProperty_font_weight,
NS_STYLE_FONT_WEIGHT_NORMAL);
} else if (str.EqualsASCII("bold")) {
aData->SetKeywordValue(eCSSProperty_font_weight,
NS_STYLE_FONT_WEIGHT_BOLD);
}
}
}
// mathvariant
//
// "Specifies the logical class of the token. Note that this class is more
// than styling, it typically conveys semantic intent;"
//
// values: "normal" | "bold" | "italic" | "bold-italic" | "double-struck" |
// "bold-fraktur" | "script" | "bold-script" | "fraktur" | "sans-serif" |
// "bold-sans-serif" | "sans-serif-italic" | "sans-serif-bold-italic" |
// "monospace" | "initial" | "tailed" | "looped" | "stretched"
// default: normal (except on <mi>)
//
value = aAttributes->GetAttr(nsGkAtoms::mathvariant_);
if (value && value->Type() == nsAttrValue::eString &&
!aData->PropertyIsSet(eCSSProperty__moz_math_variant)) {
nsAutoString str(value->GetStringValue());
str.CompressWhitespace();
static const char sizes[19][23] = {
"normal", "bold", "italic", "bold-italic", "script", "bold-script",
"fraktur", "double-struck", "bold-fraktur", "sans-serif",
"bold-sans-serif", "sans-serif-italic", "sans-serif-bold-italic",
"monospace", "initial", "tailed", "looped", "stretched"
};
static const int32_t values[MOZ_ARRAY_LENGTH(sizes)] = {
NS_MATHML_MATHVARIANT_NORMAL, NS_MATHML_MATHVARIANT_BOLD,
NS_MATHML_MATHVARIANT_ITALIC, NS_MATHML_MATHVARIANT_BOLD_ITALIC,
NS_MATHML_MATHVARIANT_SCRIPT, NS_MATHML_MATHVARIANT_BOLD_SCRIPT,
NS_MATHML_MATHVARIANT_FRAKTUR, NS_MATHML_MATHVARIANT_DOUBLE_STRUCK,
NS_MATHML_MATHVARIANT_BOLD_FRAKTUR, NS_MATHML_MATHVARIANT_SANS_SERIF,
NS_MATHML_MATHVARIANT_BOLD_SANS_SERIF,
NS_MATHML_MATHVARIANT_SANS_SERIF_ITALIC,
NS_MATHML_MATHVARIANT_SANS_SERIF_BOLD_ITALIC,
NS_MATHML_MATHVARIANT_MONOSPACE, NS_MATHML_MATHVARIANT_INITIAL,
NS_MATHML_MATHVARIANT_TAILED, NS_MATHML_MATHVARIANT_LOOPED,
NS_MATHML_MATHVARIANT_STRETCHED
};
for (uint32_t i = 0; i < ArrayLength(sizes); ++i) {
if (str.EqualsASCII(sizes[i])) {
aData->SetKeywordValue(eCSSProperty__moz_math_variant, values[i]);
break;
}
}
}
@ -797,22 +795,19 @@ nsMathMLElement::MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
// values: color | "transparent"
// default: "transparent"
//
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Background)) {
const nsAttrValue* value =
aAttributes->GetAttr(nsGkAtoms::mathbackground_);
if (!value) {
value = aAttributes->GetAttr(nsGkAtoms::background);
if (value) {
WarnDeprecated(nsGkAtoms::background->GetUTF16String(),
nsGkAtoms::mathbackground_->GetUTF16String(),
aData->Document());
}
}
value = aAttributes->GetAttr(nsGkAtoms::mathbackground_);
if (!value) {
value = aAttributes->GetAttr(nsGkAtoms::background);
if (value) {
nscolor color;
if (value->GetColorValue(color)) {
aData->SetColorValueIfUnset(eCSSProperty_background_color, color);
}
WarnDeprecated(nsGkAtoms::background->GetUTF16String(),
nsGkAtoms::mathbackground_->GetUTF16String(),
aData->Document());
}
}
if (value) {
nscolor color;
if (value->GetColorValue(color)) {
aData->SetColorValueIfUnset(eCSSProperty_background_color, color);
}
}
@ -833,47 +828,43 @@ nsMathMLElement::MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
// values: color
// default: inherited
//
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Color)) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::mathcolor_);
if (!value) {
value = aAttributes->GetAttr(nsGkAtoms::color);
if (value) {
WarnDeprecated(nsGkAtoms::color->GetUTF16String(),
nsGkAtoms::mathcolor_->GetUTF16String(),
aData->Document());
}
}
nscolor color;
if (value && value->GetColorValue(color)) {
aData->SetColorValueIfUnset(eCSSProperty_color, color);
value = aAttributes->GetAttr(nsGkAtoms::mathcolor_);
if (!value) {
value = aAttributes->GetAttr(nsGkAtoms::color);
if (value) {
WarnDeprecated(nsGkAtoms::color->GetUTF16String(),
nsGkAtoms::mathcolor_->GetUTF16String(),
aData->Document());
}
}
nscolor color;
if (value && value->GetColorValue(color)) {
aData->SetColorValueIfUnset(eCSSProperty_color, color);
}
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) {
// width
//
// "Specifies the desired width of the entire table and is intended for
// visual user agents. When the value is a percentage value, the value is
// relative to the horizontal space a MathML renderer has available for the
// math element. When the value is "auto", the MathML renderer should
// calculate the table width from its contents using whatever layout
// algorithm it chooses. "
//
// values: "auto" | length
// default: auto
//
if (!aData->PropertyIsSet(eCSSProperty_width)) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
nsCSSValue width;
// This does not handle auto and unitless values
if (value && value->Type() == nsAttrValue::eString) {
ParseNumericValue(value->GetStringValue(), width, 0, aData->Document());
if (width.GetUnit() == eCSSUnit_Percent) {
aData->SetPercentValue(eCSSProperty_width,
width.GetPercentValue());
} else if (width.GetUnit() != eCSSUnit_Null) {
aData->SetLengthValue(eCSSProperty_width, width);
}
// width
//
// "Specifies the desired width of the entire table and is intended for
// visual user agents. When the value is a percentage value, the value is
// relative to the horizontal space a MathML renderer has available for the
// math element. When the value is "auto", the MathML renderer should
// calculate the table width from its contents using whatever layout
// algorithm it chooses. "
//
// values: "auto" | length
// default: auto
//
if (!aData->PropertyIsSet(eCSSProperty_width)) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
nsCSSValue width;
// This does not handle auto and unitless values
if (value && value->Type() == nsAttrValue::eString) {
ParseNumericValue(value->GetStringValue(), width, 0, aData->Document());
if (width.GetUnit() == eCSSUnit_Percent) {
aData->SetPercentValue(eCSSProperty_width,
width.GetPercentValue());
} else if (width.GetUnit() != eCSSUnit_Null) {
aData->SetLengthValue(eCSSProperty_width, width);
}
}
}
@ -898,20 +889,18 @@ nsMathMLElement::MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
// values: "ltr" | "rtl"
// default: inherited
//
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Visibility)) {
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::dir);
if (value && value->Type() == nsAttrValue::eString &&
!aData->PropertyIsSet(eCSSProperty_direction)) {
nsAutoString str(value->GetStringValue());
static const char dirs[][4] = { "ltr", "rtl" };
static const int32_t dirValues[MOZ_ARRAY_LENGTH(dirs)] = {
NS_STYLE_DIRECTION_LTR, NS_STYLE_DIRECTION_RTL
};
for (uint32_t i = 0; i < ArrayLength(dirs); ++i) {
if (str.EqualsASCII(dirs[i])) {
aData->SetKeywordValue(eCSSProperty_direction, dirValues[i]);
break;
}
value = aAttributes->GetAttr(nsGkAtoms::dir);
if (value && value->Type() == nsAttrValue::eString &&
!aData->PropertyIsSet(eCSSProperty_direction)) {
nsAutoString str(value->GetStringValue());
static const char dirs[][4] = { "ltr", "rtl" };
static const int32_t dirValues[MOZ_ARRAY_LENGTH(dirs)] = {
NS_STYLE_DIRECTION_LTR, NS_STYLE_DIRECTION_RTL
};
for (uint32_t i = 0; i < ArrayLength(dirs); ++i) {
if (str.EqualsASCII(dirs[i])) {
aData->SetKeywordValue(eCSSProperty_direction, dirValues[i]);
break;
}
}
}

View File

@ -18,7 +18,6 @@
#include "nsCSSValue.h"
class nsAttrValue;
struct nsRuleData;
namespace mozilla {
@ -31,9 +30,8 @@ class ServoSpecifiedValues;
class GenericSpecifiedValues
{
protected:
explicit GenericSpecifiedValues(nsIDocument* aDoc, uint32_t aSIDs)
explicit GenericSpecifiedValues(nsIDocument* aDoc)
: mDocument(aDoc)
, mSIDs(aSIDs)
{}
public:
@ -47,14 +45,6 @@ public:
// Check if we already contain a certain longhand
inline bool PropertyIsSet(nsCSSPropertyID aId);
// Check if we are able to hold longhands from a given
// style struct. Pass the result of NS_STYLE_INHERIT_BIT to this
// function. Can accept multiple inherit bits or'd together.
inline bool ShouldComputeStyleStruct(uint64_t aInheritBits)
{
return aInheritBits & mSIDs;
}
// Set a property to an identifier (string)
inline void SetIdentStringValue(nsCSSPropertyID aId, const nsString& aValue);
inline void SetIdentStringValueIfUnset(nsCSSPropertyID aId,
@ -118,7 +108,6 @@ public:
inline void SetBackgroundImage(nsAttrValue& value);
nsIDocument* const mDocument;
const uint32_t mSIDs;
};
} // namespace mozilla

View File

@ -14,7 +14,6 @@
#include "mozilla/GenericSpecifiedValues.h"
#include "mozilla/ServoBindingTypes.h"
#include "nsStyleStruct.h"
namespace mozilla {
@ -22,7 +21,7 @@ class ServoSpecifiedValues final : public GenericSpecifiedValues
{
public:
ServoSpecifiedValues(nsIDocument* aDocument, RawServoDeclarationBlock* aDecl)
: GenericSpecifiedValues(aDocument, NS_STYLE_INHERIT_MASK)
: GenericSpecifiedValues(aDocument)
, mDecl(aDecl)
{}