summaryrefslogtreecommitdiffstats
path: root/layout
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-05-21 15:00:59 +0200
committerGitHub <noreply@github.com>2020-05-21 15:00:59 +0200
commit5d6691e9d08dce30b461fced32ece77fd3ff1933 (patch)
treef91d5ae02b0c2bcc41a08bb1a594c8a2ebe02eef /layout
parent14f6f230d7545d3906a7fd72f3d4677f3b6503d8 (diff)
parent0a19762d3bb5f6bcaa00a8f168e469d9fdda76b9 (diff)
downloadUXP-5d6691e9d08dce30b461fced32ece77fd3ff1933.tar
UXP-5d6691e9d08dce30b461fced32ece77fd3ff1933.tar.gz
UXP-5d6691e9d08dce30b461fced32ece77fd3ff1933.tar.lz
UXP-5d6691e9d08dce30b461fced32ece77fd3ff1933.tar.xz
UXP-5d6691e9d08dce30b461fced32ece77fd3ff1933.zip
Merge pull request #1559 from athenian200/form-disabled-issue
Restore -moz-input-disabled and allow events to target disabled form controls.
Diffstat (limited to 'layout')
-rw-r--r--layout/base/nsCaret.cpp5
-rw-r--r--layout/forms/nsComboboxControlFrame.cpp4
-rw-r--r--layout/forms/nsFormControlFrame.cpp6
-rw-r--r--layout/forms/nsGfxButtonControlFrame.cpp5
-rw-r--r--layout/forms/nsImageControlFrame.cpp8
-rw-r--r--layout/forms/nsListControlFrame.cpp11
-rw-r--r--layout/generic/nsFrame.cpp13
-rw-r--r--layout/generic/nsIFrame.h5
-rw-r--r--layout/style/nsCSSProps.cpp2
-rw-r--r--layout/style/nsStyleConsts.h2
-rw-r--r--layout/style/res/forms.css1
-rw-r--r--layout/style/test/property_database.js2
12 files changed, 35 insertions, 29 deletions
diff --git a/layout/base/nsCaret.cpp b/layout/base/nsCaret.cpp
index 8396726c6..eca22f3ba 100644
--- a/layout/base/nsCaret.cpp
+++ b/layout/base/nsCaret.cpp
@@ -511,7 +511,7 @@ nsCaret::GetPaintGeometry(nsRect* aRect)
CheckSelectionLanguageChange();
int32_t frameOffset;
- nsIFrame* frame = GetFrameAndOffset(GetSelectionInternal(),
+ nsIFrame *frame = GetFrameAndOffset(GetSelectionInternal(),
mOverrideContent, mOverrideOffset, &frameOffset);
if (!frame) {
return nullptr;
@@ -521,7 +521,8 @@ nsCaret::GetPaintGeometry(nsRect* aRect)
const nsStyleUserInterface* userinterface = frame->StyleUserInterface();
if ((!mIgnoreUserModify &&
userinterface->mUserModify == StyleUserModify::ReadOnly) ||
- frame->IsContentDisabled()){
+ userinterface->mUserInput == StyleUserInput::None ||
+ userinterface->mUserInput == StyleUserInput::Disabled) {
return nullptr;
}
diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp
index 1064778d6..9db6ae5e4 100644
--- a/layout/forms/nsComboboxControlFrame.cpp
+++ b/layout/forms/nsComboboxControlFrame.cpp
@@ -1166,7 +1166,9 @@ 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.
- if (IsContentDisabled()) {
+ const nsStyleUserInterface* uiStyle = StyleUserInterface();
+ if (uiStyle->mUserInput == StyleUserInput::None ||
+ uiStyle->mUserInput == StyleUserInput::Disabled) {
return nsBlockFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
}
return NS_OK;
diff --git a/layout/forms/nsFormControlFrame.cpp b/layout/forms/nsFormControlFrame.cpp
index 8dbe564dd..4ee62acbf 100644
--- a/layout/forms/nsFormControlFrame.cpp
+++ b/layout/forms/nsFormControlFrame.cpp
@@ -183,8 +183,10 @@ nsFormControlFrame::HandleEvent(nsPresContext* aPresContext,
WidgetGUIEvent* aEvent,
nsEventStatus* aEventStatus)
{
- // Check for disabled content so that selection works properly (?).
- if (IsContentDisabled()) {
+ // Check for user-input:none style
+ const nsStyleUserInterface* uiStyle = StyleUserInterface();
+ if (uiStyle->mUserInput == StyleUserInput::None ||
+ uiStyle->mUserInput == StyleUserInput::Disabled) {
return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
}
return NS_OK;
diff --git a/layout/forms/nsGfxButtonControlFrame.cpp b/layout/forms/nsGfxButtonControlFrame.cpp
index df729c1aa..768abbc21 100644
--- a/layout/forms/nsGfxButtonControlFrame.cpp
+++ b/layout/forms/nsGfxButtonControlFrame.cpp
@@ -203,7 +203,10 @@ 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)
- if (IsContentDisabled()) {
+ // do we have user-input style?
+ const nsStyleUserInterface* uiStyle = StyleUserInterface();
+ if (uiStyle->mUserInput == StyleUserInput::None ||
+ uiStyle->mUserInput == StyleUserInput::Disabled) {
return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
}
return NS_OK;
diff --git a/layout/forms/nsImageControlFrame.cpp b/layout/forms/nsImageControlFrame.cpp
index 8aef41538..212fa9356 100644
--- a/layout/forms/nsImageControlFrame.cpp
+++ b/layout/forms/nsImageControlFrame.cpp
@@ -150,9 +150,15 @@ nsImageControlFrame::HandleEvent(nsPresContext* aPresContext,
return NS_OK;
}
- if (IsContentDisabled()) {
+ // do we have user-input style?
+ const nsStyleUserInterface* uiStyle = StyleUserInterface();
+ 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;
diff --git a/layout/forms/nsListControlFrame.cpp b/layout/forms/nsListControlFrame.cpp
index 2233c5996..7bd356a22 100644
--- a/layout/forms/nsListControlFrame.cpp
+++ b/layout/forms/nsListControlFrame.cpp
@@ -919,11 +919,16 @@ nsListControlFrame::HandleEvent(nsPresContext* aPresContext,
if (nsEventStatus_eConsumeNoDefault == *aEventStatus)
return NS_OK;
- // disabled state affects how we're selected, but we don't want to go through
- // nsHTMLScrollFrame if we're disabled.
- if (IsContentDisabled()) {
+ // 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) {
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);
}
diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp
index 1c31f517d..dd7933b03 100644
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -5596,19 +5596,6 @@ 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)
{
diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h
index 3db18a9a6..dfe83bcbe 100644
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -2441,11 +2441,6 @@ 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. May return nullptr.
*
* @see nsGkAtoms
diff --git a/layout/style/nsCSSProps.cpp b/layout/style/nsCSSProps.cpp
index 289a16ecd..ac2978c27 100644
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -2189,6 +2189,8 @@ const KTableEntry nsCSSProps::kUserFocusKTable[] = {
const KTableEntry nsCSSProps::kUserInputKTable[] = {
{ eCSSKeyword_none, StyleUserInput::None },
+ { eCSSKeyword_enabled, StyleUserInput::Enabled },
+ { eCSSKeyword_disabled, StyleUserInput::Disabled },
{ eCSSKeyword_auto, StyleUserInput::Auto },
{ eCSSKeyword_UNKNOWN, -1 }
};
diff --git a/layout/style/nsStyleConsts.h b/layout/style/nsStyleConsts.h
index 5412eed26..6d207aec9 100644
--- a/layout/style/nsStyleConsts.h
+++ b/layout/style/nsStyleConsts.h
@@ -241,6 +241,8 @@ enum class StyleUserSelect : uint8_t {
// user-input
enum class StyleUserInput : uint8_t {
None,
+ Enabled,
+ Disabled,
Auto,
};
diff --git a/layout/style/res/forms.css b/layout/style/res/forms.css
index c91c2f739..db75151d4 100644
--- a/layout/style/res/forms.css
+++ b/layout/style/res/forms.css
@@ -425,6 +425,7 @@ optgroup:disabled,
select:disabled:disabled /* Need the pseudo-class twice to have the specificity
be at least the same as select[size][multiple] above */
{
+ -moz-user-input: disabled;
color: GrayText;
background-color: ThreeDLightShadow;
cursor: inherit;
diff --git a/layout/style/test/property_database.js b/layout/style/test/property_database.js
index 3486d15d0..c75f7b498 100644
--- a/layout/style/test/property_database.js
+++ b/layout/style/test/property_database.js
@@ -2203,7 +2203,7 @@ var gCSSProperties = {
inherited: true,
type: CSS_TYPE_LONGHAND,
initial_values: [ "auto" ],
- other_values: [ "none" ],
+ other_values: [ "none", "enabled", "disabled" ],
invalid_values: []
},
"-moz-user-modify": {