Bug 1312173 - Convert NS_STYLE_USER_INPUT_* to an enum class; r=manishearth,xidorn

MozReview-Commit-ID: sYiJrZryrA
This commit is contained in:
Adam Velebil
2016-10-23 00:08:18 +02:00
parent 61f7bcc46d
commit 2c22de0ff7
14 changed files with 39 additions and 31 deletions

View File

@@ -4894,8 +4894,9 @@ EventStateManager::SetContentState(nsIContent* aContent, EventStates aState)
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) {

View File

@@ -60,8 +60,8 @@ HTMLOptGroupElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
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;
}
}

View File

@@ -2339,8 +2339,8 @@ nsGenericHTMLFormElement::IsElementDisabledForEvents(EventMessage aMessage,
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;

View File

@@ -515,8 +515,8 @@ nsCaret::GetPaintGeometry(nsRect* aRect)
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;
}

View File

@@ -1163,9 +1163,10 @@ nsComboboxControlFrame::HandleEvent(nsPresContext* aPresContext,
// 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;
}

View File

@@ -185,10 +185,10 @@ nsFormControlFrame::HandleEvent(nsPresContext* aPresContext,
{
// 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;
}

View File

@@ -229,8 +229,9 @@ nsGfxButtonControlFrame::HandleEvent(nsPresContext* aPresContext,
// 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;
}

View File

@@ -152,9 +152,10 @@ nsImageControlFrame::HandleEvent(nsPresContext* aPresContext,
// 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;
}

View File

@@ -923,9 +923,10 @@ nsListControlFrame::HandleEvent(nsPresContext* aPresContext,
// 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;

View File

@@ -2121,10 +2121,10 @@ const KTableEntry nsCSSProps::kUserFocusKTable[] = {
};
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 }
};

View File

@@ -1417,6 +1417,7 @@ struct SetEnumValueHelper
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
@@ -5112,7 +5113,7 @@ nsRuleNode::ComputeUserInterfaceData(void* aStartStruct,
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(),

View File

@@ -212,10 +212,12 @@ enum class StyleUserSelect : uint8_t {
};
// 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

View File

@@ -4017,7 +4017,7 @@ nsCursorImage::operator==(const nsCursorImage& aOther) const
}
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)
@@ -4069,8 +4069,8 @@ nsStyleUserInterface::CalcDifference(const nsStyleUserInterface& aNewData) const
}
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;

View File

@@ -3385,7 +3385,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleUserInterface
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