Bug 1793483 - [refactor] Migrate NS_STYLE_FRAME_* defines r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D158526
This commit is contained in:
Ben Freist 2022-10-26 18:51:45 +00:00
parent 2d1097c27f
commit b8dbfb37ef
5 changed files with 36 additions and 33 deletions

View file

@ -114,9 +114,9 @@ void HTMLIFrameElement::MapAttributesIntoRule(
// else leave it as the value set in html.css // else leave it as the value set in html.css
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::frameborder); const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::frameborder);
if (value && value->Type() == nsAttrValue::eEnum) { if (value && value->Type() == nsAttrValue::eEnum) {
int32_t frameborder = value->GetEnumValue(); auto frameborder = static_cast<FrameBorderProperty>(value->GetEnumValue());
if (NS_STYLE_FRAME_0 == frameborder || NS_STYLE_FRAME_NO == frameborder || if (FrameBorderProperty::No == frameborder ||
NS_STYLE_FRAME_OFF == frameborder) { FrameBorderProperty::Zero == frameborder) {
aDecls.SetPixelValueIfUnset(eCSSProperty_border_top_width, 0.0f); aDecls.SetPixelValueIfUnset(eCSSProperty_border_top_width, 0.0f);
aDecls.SetPixelValueIfUnset(eCSSProperty_border_right_width, 0.0f); aDecls.SetPixelValueIfUnset(eCSSProperty_border_right_width, 0.0f);
aDecls.SetPixelValueIfUnset(eCSSProperty_border_bottom_width, 0.0f); aDecls.SetPixelValueIfUnset(eCSSProperty_border_bottom_width, 0.0f);

View file

@ -1013,18 +1013,22 @@ static const nsAttrValue::EnumTable kDivAlignTable[] = {
{nullptr, 0}}; {nullptr, 0}};
static const nsAttrValue::EnumTable kFrameborderTable[] = { static const nsAttrValue::EnumTable kFrameborderTable[] = {
{"yes", NS_STYLE_FRAME_YES}, {"yes", FrameBorderProperty::Yes},
{"no", NS_STYLE_FRAME_NO}, {"no", FrameBorderProperty::No},
{"1", NS_STYLE_FRAME_1}, {"1", FrameBorderProperty::One},
{"0", NS_STYLE_FRAME_0}, {"0", FrameBorderProperty::Zero},
{nullptr, 0}}; {nullptr, 0}};
// TODO(emilio): Nobody uses the parsed attribute here. // TODO(emilio): Nobody uses the parsed attribute here.
static const nsAttrValue::EnumTable kScrollingTable[] = { static const nsAttrValue::EnumTable kScrollingTable[] = {
{"yes", NS_STYLE_FRAME_YES}, {"no", NS_STYLE_FRAME_NO}, {"yes", ScrollingAttribute::Yes},
{"on", NS_STYLE_FRAME_ON}, {"off", NS_STYLE_FRAME_OFF}, {"no", ScrollingAttribute::No},
{"scroll", NS_STYLE_FRAME_SCROLL}, {"noscroll", NS_STYLE_FRAME_NOSCROLL}, {"on", ScrollingAttribute::On},
{"auto", NS_STYLE_FRAME_AUTO}, {nullptr, 0}}; {"off", ScrollingAttribute::Off},
{"scroll", ScrollingAttribute::Scroll},
{"noscroll", ScrollingAttribute::Noscroll},
{"auto", ScrollingAttribute::Auto},
{nullptr, 0}};
static const nsAttrValue::EnumTable kTableVAlignTable[] = { static const nsAttrValue::EnumTable kTableVAlignTable[] = {
{"top", StyleVerticalAlignKeyword::Top}, {"top", StyleVerticalAlignKeyword::Top},

View file

@ -216,10 +216,10 @@ void nsGenericHTMLFrameElement::UnbindFromTree(bool aNullParent) {
ScrollbarPreference nsGenericHTMLFrameElement::MapScrollingAttribute( ScrollbarPreference nsGenericHTMLFrameElement::MapScrollingAttribute(
const nsAttrValue* aValue) { const nsAttrValue* aValue) {
if (aValue && aValue->Type() == nsAttrValue::eEnum) { if (aValue && aValue->Type() == nsAttrValue::eEnum) {
switch (aValue->GetEnumValue()) { auto scrolling = static_cast<ScrollingAttribute>(aValue->GetEnumValue());
case NS_STYLE_FRAME_OFF: if (scrolling == ScrollingAttribute::Off ||
case NS_STYLE_FRAME_NOSCROLL: scrolling == ScrollingAttribute::Noscroll ||
case NS_STYLE_FRAME_NO: scrolling == ScrollingAttribute::No) {
return ScrollbarPreference::Never; return ScrollbarPreference::Never;
} }
} }

View file

@ -682,13 +682,13 @@ static nsFrameborder GetFrameBorderHelper(nsGenericHTMLElement* aContent) {
if (nullptr != aContent) { if (nullptr != aContent) {
const nsAttrValue* attr = aContent->GetParsedAttr(nsGkAtoms::frameborder); const nsAttrValue* attr = aContent->GetParsedAttr(nsGkAtoms::frameborder);
if (attr && attr->Type() == nsAttrValue::eEnum) { if (attr && attr->Type() == nsAttrValue::eEnum) {
switch (attr->GetEnumValue()) { switch (static_cast<FrameBorderProperty>(attr->GetEnumValue())) {
case NS_STYLE_FRAME_YES: case FrameBorderProperty::Yes:
case NS_STYLE_FRAME_1: case FrameBorderProperty::One:
return eFrameborder_Yes; return eFrameborder_Yes;
case NS_STYLE_FRAME_NO: case FrameBorderProperty::No:
case NS_STYLE_FRAME_0: case FrameBorderProperty::Zero:
return eFrameborder_No; return eFrameborder_No;
} }
} }

View file

@ -401,18 +401,17 @@ enum class StylePositionProperty : uint8_t {
Sticky, Sticky,
}; };
// FRAME/FRAMESET/IFRAME specific values including backward compatibility. enum class FrameBorderProperty : uint8_t { Yes, No, One, Zero };
// Boolean values with the same meaning (e.g. 1 & yes) may need to be
// distinguished for correct mode processing enum class ScrollingAttribute : uint8_t {
#define NS_STYLE_FRAME_YES 0 Yes,
#define NS_STYLE_FRAME_NO 1 No,
#define NS_STYLE_FRAME_0 2 On,
#define NS_STYLE_FRAME_1 3 Off,
#define NS_STYLE_FRAME_ON 4 Scroll,
#define NS_STYLE_FRAME_OFF 5 Noscroll,
#define NS_STYLE_FRAME_AUTO 6 Auto
#define NS_STYLE_FRAME_SCROLL 7 };
#define NS_STYLE_FRAME_NOSCROLL 8
// See nsStyleList // See nsStyleList
#define NS_STYLE_LIST_STYLE_CUSTOM -1 // for @counter-style #define NS_STYLE_LIST_STYLE_CUSTOM -1 // for @counter-style