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
Родитель 2d1097c27f
Коммит b8dbfb37ef
5 изменённых файлов: 36 добавлений и 33 удалений

Просмотреть файл

@ -114,9 +114,9 @@ void HTMLIFrameElement::MapAttributesIntoRule(
// 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) {
auto frameborder = static_cast<FrameBorderProperty>(value->GetEnumValue());
if (FrameBorderProperty::No == frameborder ||
FrameBorderProperty::Zero == frameborder) {
aDecls.SetPixelValueIfUnset(eCSSProperty_border_top_width, 0.0f);
aDecls.SetPixelValueIfUnset(eCSSProperty_border_right_width, 0.0f);
aDecls.SetPixelValueIfUnset(eCSSProperty_border_bottom_width, 0.0f);

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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