Bug 1312173 - Convert NS_STYLE_USER_INPUT_* to an enum class; r?xidorn
MozReview-Commit-ID: sYiJrZryrA
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -4889,18 +4889,19 @@ EventStateManager::SetContentState(nsICo
// Hover and active are hierarchical
updateAncestors = true;
// check to see that this state is allowed by style. Check dragover too?
// XXX Is this even what we want?
if (mCurrentTarget)
{
const nsStyleUserInterface* ui = mCurrentTarget->StyleUserInterface();
- if (ui->mUserInput == NS_STYLE_USER_INPUT_NONE)
+ if (ui->mUserInput == StyleUserInput::None) {
return false;
+ }
}
if (aState == NS_EVENT_STATE_ACTIVE) {
// Editable content can never become active since their default actions
// are disabled. Watch out for editable content in native anonymous
// subtrees though, as they belong to text controls.
if (aContent && aContent->IsEditable() &&
!aContent->IsInNativeAnonymousSubtree()) {
--- a/dom/html/HTMLOptGroupElement.cpp
+++ b/dom/html/HTMLOptGroupElement.cpp
@@ -55,18 +55,18 @@ HTMLOptGroupElement::PreHandleEvent(Even
// XXXsmaug This is not the right thing to do. But what is?
if (HasAttr(kNameSpaceID_None, nsGkAtoms::disabled)) {
return NS_OK;
}
nsIFrame* frame = GetPrimaryFrame();
if (frame) {
const nsStyleUserInterface* uiStyle = frame->StyleUserInterface();
- if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE ||
- uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED) {
+ if (uiStyle->mUserInput == StyleUserInput::None ||
+ uiStyle->mUserInput == StyleUserInput::Disabled) {
return NS_OK;
}
}
return nsGenericHTMLElement::PreHandleEvent(aVisitor);
}
Element*
--- a/dom/html/nsGenericHTMLElement.cpp
+++ b/dom/html/nsGenericHTMLElement.cpp
@@ -2334,18 +2334,18 @@ nsGenericHTMLFormElement::IsElementDisab
return false;
default:
break;
}
bool disabled = IsDisabled();
if (!disabled && aFrame) {
const nsStyleUserInterface* uiStyle = aFrame->StyleUserInterface();
- disabled = uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE ||
- uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED;
+ disabled = uiStyle->mUserInput == StyleUserInput::None ||
+ uiStyle->mUserInput == StyleUserInput::Disabled;
}
return disabled;
}
void
nsGenericHTMLFormElement::UpdateFormOwner(bool aBindToTree,
Element* aFormIdElement)
--- a/layout/base/nsCaret.cpp
+++ b/layout/base/nsCaret.cpp
@@ -510,18 +510,18 @@ nsCaret::GetPaintGeometry(nsRect* aRect)
if (!frame) {
return nullptr;
}
// now we have a frame, check whether it's appropriate to show the caret here
const nsStyleUserInterface* userinterface = frame->StyleUserInterface();
if ((!mIgnoreUserModify &&
userinterface->mUserModify == NS_STYLE_USER_MODIFY_READ_ONLY) ||
- userinterface->mUserInput == NS_STYLE_USER_INPUT_NONE ||
- userinterface->mUserInput == NS_STYLE_USER_INPUT_DISABLED) {
+ userinterface->mUserInput == StyleUserInput::None ||
+ userinterface->mUserInput == StyleUserInput::Disabled) {
return nullptr;
}
// If the offset falls outside of the frame, then don't paint the caret.
int32_t startOffset, endOffset;
if (frame->GetType() == nsGkAtoms::textFrame &&
(NS_FAILED(frame->GetOffsets(startOffset, endOffset)) ||
startOffset > frameOffset ||
--- a/layout/forms/nsComboboxControlFrame.cpp
+++ b/layout/forms/nsComboboxControlFrame.cpp
@@ -1158,19 +1158,20 @@ nsComboboxControlFrame::HandleEvent(nsPr
return NS_OK;
}
}
#endif
// If we have style that affects how we are selected, feed event down to
// nsFrame::HandleEvent so that selection takes place when appropriate.
const nsStyleUserInterface* uiStyle = StyleUserInterface();
- if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE || uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
+ if (uiStyle->mUserInput == StyleUserInput::None ||
+ uiStyle->mUserInput == StyleUserInput::Disabled) {
return nsBlockFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
-
+ }
return NS_OK;
}
nsresult
nsComboboxControlFrame::SetFormProperty(nsIAtom* aName, const nsAString& aValue)
{
nsIFormControlFrame* fcFrame = do_QueryFrame(mDropdownFrame);
--- a/layout/forms/nsFormControlFrame.cpp
+++ b/layout/forms/nsFormControlFrame.cpp
@@ -180,20 +180,20 @@ nsFormControlFrame::SetFocus(bool aOn, b
nsresult
nsFormControlFrame::HandleEvent(nsPresContext* aPresContext,
WidgetGUIEvent* aEvent,
nsEventStatus* aEventStatus)
{
// Check for user-input:none style
const nsStyleUserInterface* uiStyle = StyleUserInterface();
- if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE ||
- uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
+ if (uiStyle->mUserInput == StyleUserInput::None ||
+ uiStyle->mUserInput == StyleUserInput::Disabled) {
return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
-
+ }
return NS_OK;
}
void
nsFormControlFrame::GetCurrentCheckState(bool *aState)
{
nsCOMPtr<nsIDOMHTMLInputElement> inputElement = do_QueryInterface(mContent);
if (inputElement) {
--- a/layout/forms/nsGfxButtonControlFrame.cpp
+++ b/layout/forms/nsGfxButtonControlFrame.cpp
@@ -224,13 +224,14 @@ nsGfxButtonControlFrame::HandleEvent(nsP
nsEventStatus* aEventStatus)
{
// Override the HandleEvent to prevent the nsFrame::HandleEvent
// from being called. The nsFrame::HandleEvent causes the button label
// to be selected (Drawn with an XOR rectangle over the label)
// do we have user-input style?
const nsStyleUserInterface* uiStyle = StyleUserInterface();
- if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE || uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
+ if (uiStyle->mUserInput == StyleUserInput::None ||
+ uiStyle->mUserInput == StyleUserInput::Disabled) {
return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
-
+ }
return NS_OK;
}
--- a/layout/forms/nsImageControlFrame.cpp
+++ b/layout/forms/nsImageControlFrame.cpp
@@ -147,19 +147,20 @@ nsImageControlFrame::HandleEvent(nsPresC
// Don't do anything if the event has already been handled by someone
if (nsEventStatus_eConsumeNoDefault == *aEventStatus) {
return NS_OK;
}
// do we have user-input style?
const nsStyleUserInterface* uiStyle = StyleUserInterface();
- if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE || uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
+ if (uiStyle->mUserInput == StyleUserInput::None ||
+ uiStyle->mUserInput == StyleUserInput::Disabled) {
return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
-
+ }
if (mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::disabled)) { // XXX cache disabled
return NS_OK;
}
*aEventStatus = nsEventStatus_eIgnore;
if (aEvent->mMessage == eMouseUp &&
aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton) {
--- a/layout/forms/nsListControlFrame.cpp
+++ b/layout/forms/nsListControlFrame.cpp
@@ -918,19 +918,20 @@ nsListControlFrame::HandleEvent(nsPresCo
}*/
if (nsEventStatus_eConsumeNoDefault == *aEventStatus)
return NS_OK;
// do we have style that affects how we are selected?
// do we have user-input style?
const nsStyleUserInterface* uiStyle = StyleUserInterface();
- if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE || uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
+ if (uiStyle->mUserInput == StyleUserInput::None ||
+ uiStyle->mUserInput == StyleUserInput::Disabled) {
return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
-
+ }
EventStates eventStates = mContent->AsElement()->State();
if (eventStates.HasState(NS_EVENT_STATE_DISABLED))
return NS_OK;
return nsHTMLScrollFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
}
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -2116,20 +2116,20 @@ const KTableEntry nsCSSProps::kUserFocus
{ eCSSKeyword_select_before, uint8_t(StyleUserFocus::SelectBefore) },
{ eCSSKeyword_select_after, uint8_t(StyleUserFocus::SelectAfter) },
{ eCSSKeyword_select_same, uint8_t(StyleUserFocus::SelectSame) },
{ eCSSKeyword_select_menu, uint8_t(StyleUserFocus::SelectMenu) },
{ eCSSKeyword_UNKNOWN, -1 }
};
const KTableEntry nsCSSProps::kUserInputKTable[] = {
- { eCSSKeyword_none, NS_STYLE_USER_INPUT_NONE },
- { eCSSKeyword_auto, NS_STYLE_USER_INPUT_AUTO },
- { eCSSKeyword_enabled, NS_STYLE_USER_INPUT_ENABLED },
- { eCSSKeyword_disabled, NS_STYLE_USER_INPUT_DISABLED },
+ { eCSSKeyword_none, StyleUserInput::None },
+ { eCSSKeyword_enabled, StyleUserInput::Enabled },
+ { eCSSKeyword_disabled, StyleUserInput::Disabled },
+ { eCSSKeyword_auto, StyleUserInput::Auto },
{ eCSSKeyword_UNKNOWN, -1 }
};
const KTableEntry nsCSSProps::kUserModifyKTable[] = {
{ eCSSKeyword_read_only, NS_STYLE_USER_MODIFY_READ_ONLY },
{ eCSSKeyword_read_write, NS_STYLE_USER_MODIFY_READ_WRITE },
{ eCSSKeyword_write_only, NS_STYLE_USER_MODIFY_WRITE_ONLY },
{ eCSSKeyword_UNKNOWN, -1 }
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -1412,16 +1412,17 @@ struct SetEnumValueHelper
DEFINE_ENUM_CLASS_SETTER(StyleBoxPack, Start, Justify)
DEFINE_ENUM_CLASS_SETTER(StyleBoxSizing, Content, Border)
DEFINE_ENUM_CLASS_SETTER(StyleClear, None, Both)
DEFINE_ENUM_CLASS_SETTER(StyleFillRule, Nonzero, Evenodd)
DEFINE_ENUM_CLASS_SETTER(StyleFloat, None, InlineEnd)
DEFINE_ENUM_CLASS_SETTER(StyleFloatEdge, ContentBox, MarginBox)
DEFINE_ENUM_CLASS_SETTER(StyleUserFocus, None, SelectMenu)
DEFINE_ENUM_CLASS_SETTER(StyleUserSelect, None, MozText)
+ DEFINE_ENUM_CLASS_SETTER(StyleUserInput, None, Auto)
#ifdef MOZ_XUL
DEFINE_ENUM_CLASS_SETTER(StyleDisplay, None, Popup)
#else
DEFINE_ENUM_CLASS_SETTER(StyleDisplay, None, InlineBox)
#endif
#undef DEF_SET_ENUMERATED_VALUE
};
@@ -5107,17 +5108,17 @@ nsRuleNode::ComputeUserInterfaceData(voi
}
}
// user-input: enum, inherit, initial
SetValue(*aRuleData->ValueForUserInput(),
ui->mUserInput, conditions,
SETVAL_ENUMERATED | SETVAL_UNSET_INHERIT,
parentUI->mUserInput,
- NS_STYLE_USER_INPUT_AUTO);
+ StyleUserInput::Auto);
// user-modify: enum, inherit, initial
SetValue(*aRuleData->ValueForUserModify(),
ui->mUserModify, conditions,
SETVAL_ENUMERATED | SETVAL_UNSET_INHERIT,
parentUI->mUserModify,
NS_STYLE_USER_MODIFY_READ_ONLY);
--- a/layout/style/nsStyleConsts.h
+++ b/layout/style/nsStyleConsts.h
@@ -207,20 +207,22 @@ enum class StyleUserSelect : uint8_t {
Toggle,
TriState,
Auto, // internal value - please use nsFrame::IsSelectable()
MozAll, // force selection of all children, unless an ancestor has NONE set - bug 48096
MozText, // Like TEXT, except that it won't get overridden by ancestors having ALL.
};
// user-input
-#define NS_STYLE_USER_INPUT_NONE 0
-#define NS_STYLE_USER_INPUT_ENABLED 1
-#define NS_STYLE_USER_INPUT_DISABLED 2
-#define NS_STYLE_USER_INPUT_AUTO 3
+enum class StyleUserInput : uint8_t {
+ None,
+ Enabled,
+ Disabled,
+ Auto,
+};
// user-modify
#define NS_STYLE_USER_MODIFY_READ_ONLY 0
#define NS_STYLE_USER_MODIFY_READ_WRITE 1
#define NS_STYLE_USER_MODIFY_WRITE_ONLY 2
// -moz-window-dragging
#define NS_STYLE_WINDOW_DRAGGING_DEFAULT 0
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -4018,17 +4018,17 @@ nsCursorImage::operator==(const nsCursor
"expected mHotspot{X,Y} to be 0 when mHaveHotspot is false");
return mHaveHotspot == aOther.mHaveHotspot &&
mHotspotX == aOther.mHotspotX &&
mHotspotY == aOther.mHotspotY &&
EqualImages(mImage, aOther.mImage);
}
nsStyleUserInterface::nsStyleUserInterface(StyleStructContext aContext)
- : mUserInput(NS_STYLE_USER_INPUT_AUTO)
+ : mUserInput(StyleUserInput::Auto)
, mUserModify(NS_STYLE_USER_MODIFY_READ_ONLY)
, mUserFocus(StyleUserFocus::None)
, mPointerEvents(NS_STYLE_POINTER_EVENTS_AUTO)
, mCursor(NS_STYLE_CURSOR_AUTO)
{
MOZ_COUNT_CTOR(nsStyleUserInterface);
}
@@ -4070,18 +4070,18 @@ nsStyleUserInterface::CalcDifference(con
nsChangeHint_NeedDirtyReflow; // XXX remove me: bug 876085
}
if (mUserModify != aNewData.mUserModify) {
hint |= NS_STYLE_HINT_VISUAL;
}
if (mUserInput != aNewData.mUserInput) {
- if (NS_STYLE_USER_INPUT_NONE == mUserInput ||
- NS_STYLE_USER_INPUT_NONE == aNewData.mUserInput) {
+ if (StyleUserInput::None == mUserInput ||
+ StyleUserInput::None == aNewData.mUserInput) {
hint |= nsChangeHint_ReconstructFrame;
} else {
hint |= nsChangeHint_NeutralChange;
}
}
if (mUserFocus != aNewData.mUserFocus) {
hint |= nsChangeHint_NeutralChange;
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -3382,17 +3382,17 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
nsChangeHint_NeutralChange;
}
static nsChangeHint DifferenceAlwaysHandledForDescendants() {
// CalcDifference never returns the reflow hints that are sometimes
// handled for descendants as hints not handled for descendants.
return nsChangeHint_NeedReflow;
}
- uint8_t mUserInput; // [inherited]
+ mozilla::StyleUserInput mUserInput; // [inherited]
uint8_t mUserModify; // [inherited] (modify-content)
mozilla::StyleUserFocus mUserFocus; // [inherited] (auto-select)
uint8_t mPointerEvents; // [inherited] see nsStyleConsts.h
uint8_t mCursor; // [inherited] See nsStyleConsts.h
nsTArray<nsCursorImage> mCursorImages; // [inherited] images and coords
inline uint8_t GetEffectivePointerEvents(nsIFrame* aFrame) const;