Bug 1405087: Don't use -moz-user-input: disabled to decide event handling stuff. r=smaug
We only set it on disabled form controls anyway, so use the content state directly. MozReview-Commit-ID: 7jJ75dvszyC
This commit is contained in:
@@ -46,15 +46,14 @@ HTMLOptGroupElement::GetEventTargetParent(EventChainPreVisitor& aVisitor)
|
||||
aVisitor.mCanHandle = false;
|
||||
// Do not process any DOM events if the element is disabled
|
||||
// XXXsmaug This is not the right thing to do. But what is?
|
||||
if (HasAttr(kNameSpaceID_None, nsGkAtoms::disabled)) {
|
||||
if (IsDisabled()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIFrame* frame = GetPrimaryFrame();
|
||||
if (frame) {
|
||||
const nsStyleUserInterface* uiStyle = frame->StyleUserInterface();
|
||||
if (uiStyle->mUserInput == StyleUserInput::None ||
|
||||
uiStyle->mUserInput == StyleUserInput::Disabled) {
|
||||
if (nsIFrame* frame = GetPrimaryFrame()) {
|
||||
// FIXME(emilio): This poking at the style of the frame is broken unless we
|
||||
// flush before every event handling, which we don't really want to.
|
||||
if (frame->StyleUserInterface()->mUserInput == StyleUserInput::None) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2221,14 +2221,14 @@ nsGenericHTMLFormElement::IsElementDisabledForEvents(EventMessage aMessage,
|
||||
break;
|
||||
}
|
||||
|
||||
bool disabled = IsDisabled();
|
||||
if (!disabled && aFrame) {
|
||||
const nsStyleUserInterface* uiStyle = aFrame->StyleUserInterface();
|
||||
disabled = uiStyle->mUserInput == StyleUserInput::None ||
|
||||
uiStyle->mUserInput == StyleUserInput::Disabled;
|
||||
|
||||
// FIXME(emilio): This poking at the style of the frame is slightly bogus
|
||||
// unless we flush before every event, which we don't really want to do.
|
||||
if (aFrame &&
|
||||
aFrame->StyleUserInterface()->mUserInput == StyleUserInput::None) {
|
||||
return true;
|
||||
}
|
||||
return disabled;
|
||||
|
||||
return IsDisabled();
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -517,7 +517,7 @@ nsCaret::GetPaintGeometry(nsRect* aRect)
|
||||
CheckSelectionLanguageChange();
|
||||
|
||||
int32_t frameOffset;
|
||||
nsIFrame *frame = GetFrameAndOffset(GetSelectionInternal(),
|
||||
nsIFrame* frame = GetFrameAndOffset(GetSelectionInternal(),
|
||||
mOverrideContent, mOverrideOffset, &frameOffset);
|
||||
if (!frame) {
|
||||
return nullptr;
|
||||
@@ -527,8 +527,7 @@ nsCaret::GetPaintGeometry(nsRect* aRect)
|
||||
const nsStyleUserInterface* userinterface = frame->StyleUserInterface();
|
||||
if ((!mIgnoreUserModify &&
|
||||
userinterface->mUserModify == StyleUserModify::ReadOnly) ||
|
||||
userinterface->mUserInput == StyleUserInput::None ||
|
||||
userinterface->mUserInput == StyleUserInput::Disabled) {
|
||||
frame->IsContentDisabled()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -185,10 +185,8 @@ nsCheckboxRadioFrame::HandleEvent(nsPresContext* aPresContext,
|
||||
WidgetGUIEvent* aEvent,
|
||||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
// Check for user-input:none style
|
||||
const nsStyleUserInterface* uiStyle = StyleUserInterface();
|
||||
if (uiStyle->mUserInput == StyleUserInput::None ||
|
||||
uiStyle->mUserInput == StyleUserInput::Disabled) {
|
||||
// Check for disabled content so that selection works properly (?).
|
||||
if (IsContentDisabled()) {
|
||||
return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
}
|
||||
return NS_OK;
|
||||
|
||||
@@ -1189,9 +1189,7 @@ 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 == StyleUserInput::None ||
|
||||
uiStyle->mUserInput == StyleUserInput::Disabled) {
|
||||
if (IsContentDisabled()) {
|
||||
return nsBlockFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
}
|
||||
return NS_OK;
|
||||
|
||||
@@ -190,10 +190,7 @@ nsGfxButtonControlFrame::HandleEvent(nsPresContext* aPresContext,
|
||||
// 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 == StyleUserInput::None ||
|
||||
uiStyle->mUserInput == StyleUserInput::Disabled) {
|
||||
if (IsContentDisabled()) {
|
||||
return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
}
|
||||
return NS_OK;
|
||||
|
||||
@@ -143,18 +143,10 @@ nsImageControlFrame::HandleEvent(nsPresContext* aPresContext,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// do we have user-input style?
|
||||
const nsStyleUserInterface* uiStyle = StyleUserInterface();
|
||||
if (uiStyle->mUserInput == StyleUserInput::None ||
|
||||
uiStyle->mUserInput == StyleUserInput::Disabled) {
|
||||
if (IsContentDisabled()) {
|
||||
return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
}
|
||||
|
||||
if (mContent->AsElement()->HasAttr(kNameSpaceID_None, nsGkAtoms::disabled)) {
|
||||
// XXX cache disabled
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*aEventStatus = nsEventStatus_eIgnore;
|
||||
|
||||
if (aEvent->mMessage == eMouseUp &&
|
||||
|
||||
@@ -925,16 +925,11 @@ nsListControlFrame::HandleEvent(nsPresContext* aPresContext,
|
||||
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 == StyleUserInput::None ||
|
||||
uiStyle->mUserInput == StyleUserInput::Disabled) {
|
||||
// disabled state affects how we're selected, but we don't want to go through
|
||||
// nsHTMLScrollFrame if we're disabled.
|
||||
if (IsContentDisabled()) {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -6550,6 +6550,19 @@ nsFrame::Reflow(nsPresContext* aPresContext,
|
||||
NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize);
|
||||
}
|
||||
|
||||
bool
|
||||
nsIFrame::IsContentDisabled() const
|
||||
{
|
||||
// FIXME(emilio): Doing this via CSS means callers must ensure the style is up
|
||||
// to date, and they don't!
|
||||
if (StyleUserInterface()->mUserInput == StyleUserInput::None) {
|
||||
return true;
|
||||
}
|
||||
|
||||
auto* element = nsGenericHTMLElement::FromContentOrNull(GetContent());
|
||||
return element && element->IsDisabled();
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFrame::CharacterDataChanged(CharacterDataChangeInfo* aInfo)
|
||||
{
|
||||
|
||||
@@ -2785,6 +2785,11 @@ public:
|
||||
*/
|
||||
nsIWidget* GetNearestWidget(nsPoint& aOffset) const;
|
||||
|
||||
/**
|
||||
* Whether the content for this frame is disabled, used for event handling.
|
||||
*/
|
||||
bool IsContentDisabled() const;
|
||||
|
||||
/**
|
||||
* Get the "type" of the frame.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user