From b8dbfb37ef89873df53e896cd9c2a47703800f2c Mon Sep 17 00:00:00 2001 From: Ben Freist Date: Wed, 26 Oct 2022 18:51:45 +0000 Subject: [PATCH] Bug 1793483 - [refactor] Migrate NS_STYLE_FRAME_* defines r=emilio Differential Revision: https://phabricator.services.mozilla.com/D158526 --- dom/html/HTMLIFrameElement.cpp | 6 +++--- dom/html/nsGenericHTMLElement.cpp | 20 ++++++++++++-------- dom/html/nsGenericHTMLFrameElement.cpp | 10 +++++----- layout/generic/nsFrameSetFrame.cpp | 10 +++++----- layout/style/nsStyleConsts.h | 23 +++++++++++------------ 5 files changed, 36 insertions(+), 33 deletions(-) diff --git a/dom/html/HTMLIFrameElement.cpp b/dom/html/HTMLIFrameElement.cpp index 567767bd7e49..91c69e57013b 100644 --- a/dom/html/HTMLIFrameElement.cpp +++ b/dom/html/HTMLIFrameElement.cpp @@ -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(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); diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp index de114e11063d..b43eb52840ff 100644 --- a/dom/html/nsGenericHTMLElement.cpp +++ b/dom/html/nsGenericHTMLElement.cpp @@ -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}, diff --git a/dom/html/nsGenericHTMLFrameElement.cpp b/dom/html/nsGenericHTMLFrameElement.cpp index cc9de8947995..03de779d3995 100644 --- a/dom/html/nsGenericHTMLFrameElement.cpp +++ b/dom/html/nsGenericHTMLFrameElement.cpp @@ -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(aValue->GetEnumValue()); + if (scrolling == ScrollingAttribute::Off || + scrolling == ScrollingAttribute::Noscroll || + scrolling == ScrollingAttribute::No) { + return ScrollbarPreference::Never; } } return ScrollbarPreference::Auto; diff --git a/layout/generic/nsFrameSetFrame.cpp b/layout/generic/nsFrameSetFrame.cpp index 19763ba4a1bf..31d1af300414 100644 --- a/layout/generic/nsFrameSetFrame.cpp +++ b/layout/generic/nsFrameSetFrame.cpp @@ -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(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; } } diff --git a/layout/style/nsStyleConsts.h b/layout/style/nsStyleConsts.h index fbc9b25d6aab..f5d4a5239eee 100644 --- a/layout/style/nsStyleConsts.h +++ b/layout/style/nsStyleConsts.h @@ -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