зеркало из https://github.com/mozilla/pjs.git
Fix bug 14836, keep disabled control from responding to events. r:pollmann@netscape.com
This commit is contained in:
Родитель
98fa585872
Коммит
805ffa761a
|
@ -98,7 +98,6 @@ nsEventStateManager::nsEventStateManager()
|
|||
mPresContext = nsnull;
|
||||
mCurrentTabIndex = 0;
|
||||
mLastWindowToHaveFocus = nsnull;
|
||||
mConsumeFocusEvents = PR_FALSE;
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
++mInstanceCount;
|
||||
|
@ -142,12 +141,6 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext,
|
|||
{
|
||||
NS_ENSURE_ARG_POINTER(aStatus);
|
||||
NS_ENSURE_ARG(aPresContext);
|
||||
// This is an experiement and may be temporary
|
||||
// this consumes the very next focus event
|
||||
if (mConsumeFocusEvents && aEvent->message == NS_GOTFOCUS) {
|
||||
//mConsumeFocusEvents = PR_FALSE;
|
||||
return NS_ERROR_FAILURE; // this should consume the event
|
||||
}
|
||||
|
||||
mCurrentTarget = aTargetFrame;
|
||||
NS_IF_RELEASE(mCurrentTargetContent);
|
||||
|
@ -932,14 +925,49 @@ nsEventStateManager::GetNearestSelfScrollingFrame(nsIFrame* aFrame)
|
|||
return nsnull;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsEventStateManager::CheckDisabled(nsIContent* aContent)
|
||||
{
|
||||
nsIAtom* tag;
|
||||
PRBool disabled = PR_FALSE;
|
||||
|
||||
aContent->GetTag(tag);
|
||||
|
||||
if (nsHTMLAtoms::input == tag ||
|
||||
nsHTMLAtoms::select == tag ||
|
||||
nsHTMLAtoms::textarea == tag ||
|
||||
nsHTMLAtoms::button == tag) {
|
||||
nsAutoString empty;
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttribute(kNameSpaceID_HTML,
|
||||
nsHTMLAtoms::disabled,
|
||||
empty)) {
|
||||
disabled = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return disabled;
|
||||
}
|
||||
|
||||
void
|
||||
nsEventStateManager::UpdateCursor(nsIPresContext* aPresContext, nsPoint& aPoint, nsIFrame* aTargetFrame,
|
||||
nsEventStatus* aStatus)
|
||||
{
|
||||
PRInt32 cursor;
|
||||
nsCursor c;
|
||||
nsCOMPtr<nsIContent> targetContent;
|
||||
|
||||
aTargetFrame->GetCursor(aPresContext, aPoint, cursor);
|
||||
if (mCurrentTarget) {
|
||||
mCurrentTarget->GetContent(getter_AddRefs(targetContent));
|
||||
}
|
||||
|
||||
//Check if the current target is disabled. If so use the default pointer.
|
||||
if (targetContent && CheckDisabled(targetContent)) {
|
||||
cursor = NS_STYLE_CURSOR_DEFAULT;
|
||||
}
|
||||
//If not disabled, check for the right cursor.
|
||||
else {
|
||||
aTargetFrame->GetCursor(aPresContext, aPoint, cursor);
|
||||
}
|
||||
|
||||
switch (cursor) {
|
||||
default:
|
||||
|
|
|
@ -41,12 +41,24 @@ public:
|
|||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
/* The PreHandleEvent method is called before event dispatch to either
|
||||
* the DOM or frames. Any processing which must not be prevented or
|
||||
* cancelled should occur here. Any processing which is intended to
|
||||
* be conditional based on either DOM or frame processing should occur in
|
||||
* PostHandleEvent. Any centralized event processing which must occur before
|
||||
* DOM or frame event handling should occur here as well.
|
||||
*/
|
||||
NS_IMETHOD PreHandleEvent(nsIPresContext* aPresContext,
|
||||
nsGUIEvent *aEvent,
|
||||
nsIFrame* aTargetFrame,
|
||||
nsEventStatus* aStatus,
|
||||
nsIView* aView);
|
||||
|
||||
/* The PostHandleEvent method should contain all system processing which
|
||||
* should occur conditionally based on DOM or frame processing. It should
|
||||
* also contain any centralized event processing which must occur after
|
||||
* DOM and frame processing.
|
||||
*/
|
||||
NS_IMETHOD PostHandleEvent(nsIPresContext* aPresContext,
|
||||
nsGUIEvent *aEvent,
|
||||
nsIFrame* aTargetFrame,
|
||||
|
@ -84,6 +96,7 @@ protected:
|
|||
NS_IMETHOD SendFocusBlur(nsIPresContext* aPresContext, nsIContent *aContent);
|
||||
nsIScrollableView* GetNearestScrollingView(nsIView* aView);
|
||||
nsISelfScrollingFrame* GetNearestSelfScrollingFrame(nsIFrame* aFrame);
|
||||
PRBool CheckDisabled(nsIContent* aContent);
|
||||
|
||||
nsIFrame* GetDocumentFrame(nsIPresContext* aPresContext);
|
||||
|
||||
|
|
|
@ -415,6 +415,14 @@ nsHTMLButtonElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
{
|
||||
NS_ENSURE_ARG(aPresContext);
|
||||
NS_ENSURE_ARG_POINTER(aEventStatus);
|
||||
|
||||
// Do not process any DOM events if the element is disabled
|
||||
PRBool disabled;
|
||||
nsresult rv = GetDisabled(&disabled);
|
||||
if (NS_FAILED(rv) || disabled) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Try script event handlers first
|
||||
nsresult ret = mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags, aEventStatus);
|
||||
|
|
|
@ -638,6 +638,13 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// Do not process any DOM events if the element is disabled
|
||||
PRBool disabled;
|
||||
nsresult rv = GetDisabled(&disabled);
|
||||
if (NS_FAILED(rv) || disabled) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Try script event handlers first
|
||||
nsresult ret = mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags, aEventStatus);
|
||||
|
|
|
@ -187,6 +187,13 @@ nsHTMLOptGroupElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
// Do not process any DOM events if the element is disabled
|
||||
PRBool disabled;
|
||||
nsresult rv = GetDisabled(&disabled);
|
||||
if (NS_FAILED(rv) || disabled) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags, aEventStatus);
|
||||
}
|
||||
|
|
|
@ -827,6 +827,13 @@ nsHTMLSelectElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
// Do not process any DOM events if the element is disabled
|
||||
PRBool disabled;
|
||||
nsresult rv = GetDisabled(&disabled);
|
||||
if (NS_FAILED(rv) || disabled) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags, aEventStatus);
|
||||
}
|
||||
|
|
|
@ -487,6 +487,13 @@ nsHTMLTextAreaElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
// Do not process any DOM events if the element is disabled
|
||||
PRBool disabled;
|
||||
nsresult rv = GetDisabled(&disabled);
|
||||
if (NS_FAILED(rv) || disabled) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags, aEventStatus);
|
||||
}
|
||||
|
|
|
@ -98,7 +98,6 @@ nsEventStateManager::nsEventStateManager()
|
|||
mPresContext = nsnull;
|
||||
mCurrentTabIndex = 0;
|
||||
mLastWindowToHaveFocus = nsnull;
|
||||
mConsumeFocusEvents = PR_FALSE;
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
++mInstanceCount;
|
||||
|
@ -142,12 +141,6 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext,
|
|||
{
|
||||
NS_ENSURE_ARG_POINTER(aStatus);
|
||||
NS_ENSURE_ARG(aPresContext);
|
||||
// This is an experiement and may be temporary
|
||||
// this consumes the very next focus event
|
||||
if (mConsumeFocusEvents && aEvent->message == NS_GOTFOCUS) {
|
||||
//mConsumeFocusEvents = PR_FALSE;
|
||||
return NS_ERROR_FAILURE; // this should consume the event
|
||||
}
|
||||
|
||||
mCurrentTarget = aTargetFrame;
|
||||
NS_IF_RELEASE(mCurrentTargetContent);
|
||||
|
@ -932,14 +925,49 @@ nsEventStateManager::GetNearestSelfScrollingFrame(nsIFrame* aFrame)
|
|||
return nsnull;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsEventStateManager::CheckDisabled(nsIContent* aContent)
|
||||
{
|
||||
nsIAtom* tag;
|
||||
PRBool disabled = PR_FALSE;
|
||||
|
||||
aContent->GetTag(tag);
|
||||
|
||||
if (nsHTMLAtoms::input == tag ||
|
||||
nsHTMLAtoms::select == tag ||
|
||||
nsHTMLAtoms::textarea == tag ||
|
||||
nsHTMLAtoms::button == tag) {
|
||||
nsAutoString empty;
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttribute(kNameSpaceID_HTML,
|
||||
nsHTMLAtoms::disabled,
|
||||
empty)) {
|
||||
disabled = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return disabled;
|
||||
}
|
||||
|
||||
void
|
||||
nsEventStateManager::UpdateCursor(nsIPresContext* aPresContext, nsPoint& aPoint, nsIFrame* aTargetFrame,
|
||||
nsEventStatus* aStatus)
|
||||
{
|
||||
PRInt32 cursor;
|
||||
nsCursor c;
|
||||
nsCOMPtr<nsIContent> targetContent;
|
||||
|
||||
aTargetFrame->GetCursor(aPresContext, aPoint, cursor);
|
||||
if (mCurrentTarget) {
|
||||
mCurrentTarget->GetContent(getter_AddRefs(targetContent));
|
||||
}
|
||||
|
||||
//Check if the current target is disabled. If so use the default pointer.
|
||||
if (targetContent && CheckDisabled(targetContent)) {
|
||||
cursor = NS_STYLE_CURSOR_DEFAULT;
|
||||
}
|
||||
//If not disabled, check for the right cursor.
|
||||
else {
|
||||
aTargetFrame->GetCursor(aPresContext, aPoint, cursor);
|
||||
}
|
||||
|
||||
switch (cursor) {
|
||||
default:
|
||||
|
|
|
@ -41,12 +41,24 @@ public:
|
|||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
/* The PreHandleEvent method is called before event dispatch to either
|
||||
* the DOM or frames. Any processing which must not be prevented or
|
||||
* cancelled should occur here. Any processing which is intended to
|
||||
* be conditional based on either DOM or frame processing should occur in
|
||||
* PostHandleEvent. Any centralized event processing which must occur before
|
||||
* DOM or frame event handling should occur here as well.
|
||||
*/
|
||||
NS_IMETHOD PreHandleEvent(nsIPresContext* aPresContext,
|
||||
nsGUIEvent *aEvent,
|
||||
nsIFrame* aTargetFrame,
|
||||
nsEventStatus* aStatus,
|
||||
nsIView* aView);
|
||||
|
||||
/* The PostHandleEvent method should contain all system processing which
|
||||
* should occur conditionally based on DOM or frame processing. It should
|
||||
* also contain any centralized event processing which must occur after
|
||||
* DOM and frame processing.
|
||||
*/
|
||||
NS_IMETHOD PostHandleEvent(nsIPresContext* aPresContext,
|
||||
nsGUIEvent *aEvent,
|
||||
nsIFrame* aTargetFrame,
|
||||
|
@ -84,6 +96,7 @@ protected:
|
|||
NS_IMETHOD SendFocusBlur(nsIPresContext* aPresContext, nsIContent *aContent);
|
||||
nsIScrollableView* GetNearestScrollingView(nsIView* aView);
|
||||
nsISelfScrollingFrame* GetNearestSelfScrollingFrame(nsIFrame* aFrame);
|
||||
PRBool CheckDisabled(nsIContent* aContent);
|
||||
|
||||
nsIFrame* GetDocumentFrame(nsIPresContext* aPresContext);
|
||||
|
||||
|
|
|
@ -415,6 +415,14 @@ nsHTMLButtonElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
{
|
||||
NS_ENSURE_ARG(aPresContext);
|
||||
NS_ENSURE_ARG_POINTER(aEventStatus);
|
||||
|
||||
// Do not process any DOM events if the element is disabled
|
||||
PRBool disabled;
|
||||
nsresult rv = GetDisabled(&disabled);
|
||||
if (NS_FAILED(rv) || disabled) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Try script event handlers first
|
||||
nsresult ret = mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags, aEventStatus);
|
||||
|
|
|
@ -638,6 +638,13 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// Do not process any DOM events if the element is disabled
|
||||
PRBool disabled;
|
||||
nsresult rv = GetDisabled(&disabled);
|
||||
if (NS_FAILED(rv) || disabled) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Try script event handlers first
|
||||
nsresult ret = mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags, aEventStatus);
|
||||
|
|
|
@ -187,6 +187,13 @@ nsHTMLOptGroupElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
// Do not process any DOM events if the element is disabled
|
||||
PRBool disabled;
|
||||
nsresult rv = GetDisabled(&disabled);
|
||||
if (NS_FAILED(rv) || disabled) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags, aEventStatus);
|
||||
}
|
||||
|
|
|
@ -827,6 +827,13 @@ nsHTMLSelectElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
// Do not process any DOM events if the element is disabled
|
||||
PRBool disabled;
|
||||
nsresult rv = GetDisabled(&disabled);
|
||||
if (NS_FAILED(rv) || disabled) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags, aEventStatus);
|
||||
}
|
||||
|
|
|
@ -487,6 +487,13 @@ nsHTMLTextAreaElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
// Do not process any DOM events if the element is disabled
|
||||
PRBool disabled;
|
||||
nsresult rv = GetDisabled(&disabled);
|
||||
if (NS_FAILED(rv) || disabled) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||
aFlags, aEventStatus);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче