2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef nsEventStateManager_h__
|
|
|
|
#define nsEventStateManager_h__
|
|
|
|
|
2009-04-01 14:59:02 -07:00
|
|
|
#include "nsEvent.h"
|
2009-08-13 13:54:09 -07:00
|
|
|
#include "nsGUIEvent.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsWeakReference.h"
|
|
|
|
#include "nsHashtable.h"
|
|
|
|
#include "nsITimer.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsCOMArray.h"
|
2011-06-21 17:32:43 -07:00
|
|
|
#include "nsIFrameLoader.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIFrame.h"
|
2007-08-10 14:25:24 -07:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2007-10-30 12:13:37 -07:00
|
|
|
#include "nsIMarkupDocumentViewer.h"
|
2010-01-11 13:45:02 -08:00
|
|
|
#include "nsIScrollableFrame.h"
|
2010-11-05 22:04:11 -07:00
|
|
|
#include "nsFocusManager.h"
|
|
|
|
#include "nsIDocument.h"
|
2011-04-21 10:35:52 -07:00
|
|
|
#include "nsEventStates.h"
|
2011-09-06 13:14:59 -07:00
|
|
|
#include "mozilla/TimeStamp.h"
|
|
|
|
#include "nsContentUtils.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
class nsIPresShell;
|
|
|
|
class nsIDocShell;
|
|
|
|
class nsIDocShellTreeNode;
|
|
|
|
class nsIDocShellTreeItem;
|
|
|
|
class imgIContainer;
|
2008-08-27 05:07:27 -07:00
|
|
|
class nsDOMDataTransfer;
|
2011-09-18 00:45:14 -07:00
|
|
|
class MouseEnterLeaveDispatcher;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-09-23 20:28:15 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class TabParent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/*
|
|
|
|
* Event listener manager
|
|
|
|
*/
|
|
|
|
|
|
|
|
class nsEventStateManager : public nsSupportsWeakReference,
|
|
|
|
public nsIObserver
|
|
|
|
{
|
2009-09-24 03:58:04 -07:00
|
|
|
friend class nsMouseWheelTransaction;
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
2011-09-06 13:14:59 -07:00
|
|
|
|
|
|
|
typedef mozilla::TimeStamp TimeStamp;
|
|
|
|
typedef mozilla::TimeDuration TimeDuration;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsEventStateManager();
|
|
|
|
virtual ~nsEventStateManager();
|
|
|
|
|
2007-08-10 14:25:24 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
2011-04-21 10:35:52 -07:00
|
|
|
nsresult Init();
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult Shutdown();
|
|
|
|
|
|
|
|
/* 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.
|
|
|
|
*/
|
2011-04-21 10:35:52 -07:00
|
|
|
nsresult PreHandleEvent(nsPresContext* aPresContext,
|
|
|
|
nsEvent *aEvent,
|
|
|
|
nsIFrame* aTargetFrame,
|
2011-11-21 09:53:20 -08:00
|
|
|
nsEventStatus* aStatus);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* 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.
|
|
|
|
*/
|
2011-04-21 10:35:52 -07:00
|
|
|
nsresult PostHandleEvent(nsPresContext* aPresContext,
|
|
|
|
nsEvent *aEvent,
|
|
|
|
nsIFrame* aTargetFrame,
|
2011-11-21 09:53:20 -08:00
|
|
|
nsEventStatus* aStatus);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-04-21 10:35:52 -07:00
|
|
|
void NotifyDestroyPresContext(nsPresContext* aPresContext);
|
|
|
|
void SetPresContext(nsPresContext* aPresContext);
|
|
|
|
void ClearFrameRefs(nsIFrame* aFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-04-21 10:35:52 -07:00
|
|
|
nsIFrame* GetEventTarget();
|
|
|
|
already_AddRefed<nsIContent> GetEventTargetContent(nsEvent* aEvent);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-04-21 10:35:52 -07:00
|
|
|
/**
|
|
|
|
* Notify that the given NS_EVENT_STATE_* bit has changed for this content.
|
|
|
|
* @param aContent Content which has changed states
|
|
|
|
* @param aState Corresponding state flags such as NS_EVENT_STATE_FOCUS
|
2011-10-17 07:59:28 -07:00
|
|
|
* @return Whether the content was able to change all states. Returns false
|
2011-04-21 10:35:52 -07:00
|
|
|
* if a resulting DOM event causes the content node passed in
|
|
|
|
* to not change states. Note, the frame for the content may
|
|
|
|
* change as a result of the content state change, because of
|
|
|
|
* frame reconstructions that may occur, but this does not
|
|
|
|
* affect the return value.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool SetContentState(nsIContent *aContent, nsEventStates aState);
|
2011-04-21 10:35:52 -07:00
|
|
|
void ContentRemoved(nsIDocument* aDocument, nsIContent* aContent);
|
2011-09-28 23:19:26 -07:00
|
|
|
bool EventStatusOK(nsGUIEvent* aEvent);
|
2011-04-21 10:35:52 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Register accesskey on the given element. When accesskey is activated then
|
|
|
|
* the element will be notified via nsIContent::PerformAccesskey() method.
|
|
|
|
*
|
|
|
|
* @param aContent the given element
|
|
|
|
* @param aKey accesskey
|
|
|
|
*/
|
|
|
|
void RegisterAccessKey(nsIContent* aContent, PRUint32 aKey);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unregister accesskey for the given element.
|
|
|
|
*
|
|
|
|
* @param aContent the given element
|
|
|
|
* @param aKey accesskey
|
|
|
|
*/
|
|
|
|
void UnregisterAccessKey(nsIContent* aContent, PRUint32 aKey);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get accesskey registered on the given element or 0 if there is none.
|
|
|
|
*
|
|
|
|
* @param aContent the given element
|
|
|
|
* @return registered accesskey
|
|
|
|
*/
|
|
|
|
PRUint32 GetRegisteredAccessKey(nsIContent* aContent);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool GetAccessKeyLabelPrefix(nsAString& aPrefix);
|
2011-07-31 12:43:54 -07:00
|
|
|
|
2011-04-21 10:35:52 -07:00
|
|
|
nsresult SetCursor(PRInt32 aCursor, imgIContainer* aContainer,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aHaveHotspot, float aHotspotX, float aHotspotY,
|
|
|
|
nsIWidget* aWidget, bool aLockCursor);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
static void StartHandlingUserInput()
|
|
|
|
{
|
|
|
|
++sUserInputEventDepth;
|
2011-09-06 13:14:59 -07:00
|
|
|
if (sUserInputEventDepth == 1) {
|
|
|
|
sHandlingInputStart = TimeStamp::Now();
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void StopHandlingUserInput()
|
|
|
|
{
|
|
|
|
--sUserInputEventDepth;
|
2011-09-06 13:14:59 -07:00
|
|
|
if (sUserInputEventDepth == 0) {
|
|
|
|
sHandlingInputStart = TimeStamp();
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool IsHandlingUserInput()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-09-06 13:14:59 -07:00
|
|
|
if (sUserInputEventDepth <= 0) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2011-09-06 13:14:59 -07:00
|
|
|
}
|
|
|
|
TimeDuration timeout = nsContentUtils::HandlingUserInputTimeout();
|
|
|
|
return timeout <= TimeDuration(0) ||
|
|
|
|
(TimeStamp::Now() - sHandlingInputStart) <= timeout;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-04-21 10:35:52 -07:00
|
|
|
/**
|
|
|
|
* Returns true if the current code is being executed as a result of user input.
|
|
|
|
* This includes timers or anything else that is initiated from user input.
|
|
|
|
* However, mouse hover events are not counted as user input, nor are
|
|
|
|
* page load events. If this method is called from asynchronously executed code,
|
2011-09-06 13:14:59 -07:00
|
|
|
* such as during layout reflows, it will return false. If more time has elapsed
|
|
|
|
* since the user input than is specified by the
|
|
|
|
* dom.event.handling-user-input-time-limit pref (default 1 second), this
|
|
|
|
* function also returns false.
|
2011-04-21 10:35:52 -07:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD_(bool) IsHandlingUserInputExternal() { return IsHandlingUserInput(); }
|
2007-08-10 18:44:44 -07:00
|
|
|
|
2010-10-19 00:46:31 -07:00
|
|
|
nsPresContext* GetPresContext() { return mPresContext; }
|
|
|
|
|
2007-08-10 14:25:24 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsEventStateManager,
|
2011-04-21 10:35:52 -07:00
|
|
|
nsIObserver)
|
2007-08-10 14:25:24 -07:00
|
|
|
|
2010-09-17 11:56:53 -07:00
|
|
|
static nsIDocument* sMouseOverDocument;
|
|
|
|
|
2011-04-21 10:35:52 -07:00
|
|
|
static nsEventStateManager* GetActiveEventStateManager() { return sActiveESM; }
|
2010-10-20 06:49:53 -07:00
|
|
|
|
2010-10-28 07:11:15 -07:00
|
|
|
// Sets aNewESM to be the active event state manager, and
|
|
|
|
// if aContent is non-null, marks the object as active.
|
|
|
|
static void SetActiveManager(nsEventStateManager* aNewESM,
|
|
|
|
nsIContent* aContent);
|
2011-09-04 13:39:08 -07:00
|
|
|
|
|
|
|
// Sets the full-screen event state on aElement to aIsFullScreen.
|
2011-09-28 23:19:26 -07:00
|
|
|
static void SetFullScreenState(mozilla::dom::Element* aElement, bool aIsFullScreen);
|
2011-09-04 13:39:08 -07:00
|
|
|
|
2011-10-25 23:42:20 -07:00
|
|
|
static bool IsRemoteTarget(nsIContent* aTarget);
|
|
|
|
|
2012-06-20 16:38:11 -07:00
|
|
|
// Holds the point in screen coords that a mouse event was dispatched to,
|
|
|
|
// before we went into pointer lock mode. This is constantly updated while
|
|
|
|
// the pointer is not locked, but we don't update it while the pointer is
|
|
|
|
// locked. This is used by nsDOMEvent::GetScreenCoords() to make mouse
|
|
|
|
// events' screen coord appear frozen at the last mouse position while
|
|
|
|
// the pointer is locked.
|
2012-04-11 14:55:21 -07:00
|
|
|
static nsIntPoint sLastScreenPoint;
|
2012-06-20 16:38:11 -07:00
|
|
|
|
|
|
|
// Holds the point in client coords of the last mouse event. Used by
|
|
|
|
// nsDOMEvent::GetClientCoords() to make mouse events' client coords appear
|
|
|
|
// frozen at the last mouse position while the pointer is locked.
|
2012-04-11 14:55:21 -07:00
|
|
|
static nsIntPoint sLastClientPoint;
|
2012-06-20 16:38:11 -07:00
|
|
|
|
2012-04-11 14:55:21 -07:00
|
|
|
static bool sIsPointerLocked;
|
|
|
|
static nsWeakPtr sPointerLockedElement;
|
|
|
|
static nsWeakPtr sPointerLockedDoc;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
2011-09-18 00:45:14 -07:00
|
|
|
friend class MouseEnterLeaveDispatcher;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
void UpdateCursor(nsPresContext* aPresContext, nsEvent* aEvent, nsIFrame* aTargetFrame, nsEventStatus* aStatus);
|
|
|
|
/**
|
|
|
|
* Turn a GUI mouse event into a mouse event targeted at the specified
|
|
|
|
* content. This returns the primary frame for the content (or null
|
|
|
|
* if it goes away during the event).
|
|
|
|
*/
|
|
|
|
nsIFrame* DispatchMouseEvent(nsGUIEvent* aEvent, PRUint32 aMessage,
|
|
|
|
nsIContent* aTargetContent,
|
|
|
|
nsIContent* aRelatedContent);
|
|
|
|
/**
|
|
|
|
* Synthesize DOM and frame mouseover and mouseout events from this
|
|
|
|
* MOUSE_MOVE or MOUSE_EXIT event.
|
|
|
|
*/
|
|
|
|
void GenerateMouseEnterExit(nsGUIEvent* aEvent);
|
|
|
|
/**
|
|
|
|
* Tell this ESM and ESMs in parent documents that the mouse is
|
|
|
|
* over some content in this document.
|
|
|
|
*/
|
|
|
|
void NotifyMouseOver(nsGUIEvent* aEvent, nsIContent* aContent);
|
|
|
|
/**
|
|
|
|
* Tell this ESM and ESMs in affected child documents that the mouse
|
|
|
|
* has exited this document's currently hovered content.
|
|
|
|
* @param aEvent the event that triggered the mouseout
|
|
|
|
* @param aMovingInto the content node we've moved into. This is used to set
|
|
|
|
* the relatedTarget for mouseout events. Also, if it's non-null
|
|
|
|
* NotifyMouseOut will NOT change the current hover content to null;
|
|
|
|
* in that case the caller is responsible for updating hover state.
|
|
|
|
*/
|
|
|
|
void NotifyMouseOut(nsGUIEvent* aEvent, nsIContent* aMovingInto);
|
|
|
|
void GenerateDragDropEnterExit(nsPresContext* aPresContext, nsGUIEvent* aEvent);
|
2007-04-11 21:37:39 -07:00
|
|
|
/**
|
|
|
|
* Fire the dragenter and dragexit/dragleave events when the mouse moves to a
|
|
|
|
* new target.
|
|
|
|
*
|
|
|
|
* @param aRelatedTarget relatedTarget to set for the event
|
|
|
|
* @param aTargetContent target to set for the event
|
|
|
|
* @param aTargetFrame target frame for the event
|
|
|
|
*/
|
|
|
|
void FireDragEnterOrExit(nsPresContext* aPresContext,
|
|
|
|
nsGUIEvent* aEvent,
|
|
|
|
PRUint32 aMsg,
|
|
|
|
nsIContent* aRelatedTarget,
|
|
|
|
nsIContent* aTargetContent,
|
|
|
|
nsWeakFrame& aTargetFrame);
|
2009-10-06 19:51:02 -07:00
|
|
|
/**
|
|
|
|
* Update the initial drag session data transfer with any changes that occur
|
|
|
|
* on cloned data transfer objects used for events.
|
|
|
|
*/
|
|
|
|
void UpdateDragDataTransfer(nsDragEvent* dragEvent);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult SetClickCount(nsPresContext* aPresContext, nsMouseEvent *aEvent, nsEventStatus* aStatus);
|
|
|
|
nsresult CheckForAndDispatchClick(nsPresContext* aPresContext, nsMouseEvent *aEvent, nsEventStatus* aStatus);
|
|
|
|
void EnsureDocument(nsPresContext* aPresContext);
|
|
|
|
void FlushPendingEvents(nsPresContext* aPresContext);
|
|
|
|
|
2007-05-17 20:49:14 -07:00
|
|
|
/**
|
|
|
|
* The phases of HandleAccessKey processing. See below.
|
|
|
|
*/
|
2007-03-22 10:30:00 -07:00
|
|
|
typedef enum {
|
|
|
|
eAccessKeyProcessingNormal = 0,
|
|
|
|
eAccessKeyProcessingUp,
|
|
|
|
eAccessKeyProcessingDown
|
|
|
|
} ProcessingAccessKeyState;
|
2007-05-17 20:49:14 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Access key handling. If there is registered content for the accesskey
|
|
|
|
* given by the key event and modifier mask then call
|
|
|
|
* content.PerformAccesskey(), otherwise call HandleAccessKey() recursively,
|
|
|
|
* on descendant docshells first, then on the ancestor (with |aBubbledFrom|
|
|
|
|
* set to the docshell associated with |this|), until something matches.
|
|
|
|
*
|
|
|
|
* @param aPresContext the presentation context
|
|
|
|
* @param aEvent the key event
|
|
|
|
* @param aStatus the event status
|
|
|
|
* @param aBubbledFrom is used by an ancestor to avoid calling HandleAccessKey()
|
|
|
|
* on the child the call originally came from, i.e. this is the child
|
2009-01-23 01:02:09 -08:00
|
|
|
* that recursively called us in its Up phase. The initial caller
|
2007-05-17 20:49:14 -07:00
|
|
|
* passes |nsnull| here. This is to avoid an infinite loop.
|
|
|
|
* @param aAccessKeyState Normal, Down or Up processing phase (see enums
|
2008-08-25 23:53:00 -07:00
|
|
|
* above). The initial event receiver uses 'normal', then 'down' when
|
2007-05-17 20:49:14 -07:00
|
|
|
* processing children and Up when recursively calling its ancestor.
|
|
|
|
* @param aModifierMask modifier mask for the key event
|
|
|
|
*/
|
2007-03-22 10:30:00 -07:00
|
|
|
void HandleAccessKey(nsPresContext* aPresContext,
|
|
|
|
nsKeyEvent* aEvent,
|
|
|
|
nsEventStatus* aStatus,
|
2007-05-17 20:49:14 -07:00
|
|
|
nsIDocShellTreeItem* aBubbledFrom,
|
2007-03-22 10:30:00 -07:00
|
|
|
ProcessingAccessKeyState aAccessKeyState,
|
|
|
|
PRInt32 aModifierMask);
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool ExecuteAccessKey(nsTArray<PRUint32>& aAccessCharCodes,
|
|
|
|
bool aIsTrustedEvent);
|
2008-04-14 21:16:24 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//---------------------------------------------
|
|
|
|
// DocShell Focus Traversal Methods
|
|
|
|
//---------------------------------------------
|
|
|
|
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 11:00:39 -07:00
|
|
|
nsIContent* GetFocusedContent();
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsShellVisible(nsIDocShell* aShell);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-04-02 12:34:31 -07:00
|
|
|
// These functions are for mousewheel and pixel scrolling
|
|
|
|
void SendLineScrollEvent(nsIFrame* aTargetFrame,
|
|
|
|
nsMouseScrollEvent* aEvent,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
nsEventStatus* aStatus,
|
|
|
|
PRInt32 aNumLines);
|
2008-09-17 04:27:19 -07:00
|
|
|
void SendPixelScrollEvent(nsIFrame* aTargetFrame,
|
|
|
|
nsMouseScrollEvent* aEvent,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
nsEventStatus* aStatus);
|
2011-05-16 17:23:23 -07:00
|
|
|
/**
|
|
|
|
* @param aQueryEvent If you set vailid pointer for this, DoScrollText()
|
|
|
|
* computes the line-height and page size of current
|
|
|
|
* mouse wheel scroll target and sets it to the event.
|
|
|
|
* And then, this method does NOT scroll any scrollable
|
|
|
|
* elements. I.e., you can just query the scroll target
|
|
|
|
* information.
|
|
|
|
*/
|
2010-01-11 13:45:02 -08:00
|
|
|
nsresult DoScrollText(nsIFrame* aTargetFrame,
|
2009-05-19 19:05:59 -07:00
|
|
|
nsMouseScrollEvent* aMouseEvent,
|
2010-01-11 13:45:02 -08:00
|
|
|
nsIScrollableFrame::ScrollUnit aScrollQuantity,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aAllowScrollSpeedOverride,
|
2012-03-26 02:50:30 -07:00
|
|
|
nsQueryContentEvent* aQueryEvent = nsnull,
|
|
|
|
nsIAtom *aOrigin = nsnull);
|
2007-03-22 10:30:00 -07:00
|
|
|
void DoScrollHistory(PRInt32 direction);
|
2008-02-13 03:00:45 -08:00
|
|
|
void DoScrollZoom(nsIFrame *aTargetFrame, PRInt32 adjustment);
|
2007-10-30 12:13:37 -07:00
|
|
|
nsresult GetMarkupDocumentViewer(nsIMarkupDocumentViewer** aMv);
|
|
|
|
nsresult ChangeTextSize(PRInt32 change);
|
2007-10-25 16:02:20 -07:00
|
|
|
nsresult ChangeFullZoom(PRInt32 change);
|
2011-07-14 15:12:20 -07:00
|
|
|
/**
|
|
|
|
* Computes actual delta value used for scrolling. If user customized the
|
|
|
|
* scrolling speed and/or direction, this would return the customized value.
|
|
|
|
* Otherwise, it would return the original delta value of aMouseEvent.
|
|
|
|
*/
|
|
|
|
PRInt32 ComputeWheelDeltaFor(nsMouseScrollEvent* aMouseEvent);
|
2011-05-21 22:39:16 -07:00
|
|
|
/**
|
|
|
|
* Computes the action for the aMouseEvent with prefs. The result is
|
|
|
|
* MOUSE_SCROLL_N_LINES, MOUSE_SCROLL_PAGE, MOUSE_SCROLL_HISTORY,
|
|
|
|
* MOUSE_SCROLL_ZOOM, MOUSE_SCROLL_PIXELS or -1.
|
|
|
|
* When the result is -1, nothing happens for the event.
|
|
|
|
*
|
|
|
|
* @param aUseSystemSettings Set the result of UseSystemScrollSettingFor().
|
|
|
|
*/
|
|
|
|
PRInt32 ComputeWheelActionFor(nsMouseScrollEvent* aMouseEvent,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aUseSystemSettings);
|
2011-05-21 22:39:16 -07:00
|
|
|
/**
|
|
|
|
* Gets the wheel action for the aMouseEvent ONLY with the pref.
|
|
|
|
* When you actually do something for the event, probably you should use
|
|
|
|
* ComputeWheelActionFor().
|
|
|
|
*/
|
|
|
|
PRInt32 GetWheelActionFor(nsMouseScrollEvent* aMouseEvent);
|
|
|
|
/**
|
|
|
|
* Gets the pref value for line scroll amount for the aMouseEvent.
|
|
|
|
* Note that this method doesn't check whether the aMouseEvent is line scroll
|
|
|
|
* event and doesn't use system settings.
|
|
|
|
*/
|
|
|
|
PRInt32 GetScrollLinesFor(nsMouseScrollEvent* aMouseEvent);
|
|
|
|
/**
|
|
|
|
* Whether use system scroll settings or settings in our prefs for the event.
|
|
|
|
* TRUE, if use system scroll settings. Otherwise, FALSE.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool UseSystemScrollSettingFor(nsMouseScrollEvent* aMouseEvent);
|
2007-03-22 10:30:00 -07:00
|
|
|
// end mousewheel functions
|
|
|
|
|
2009-08-13 13:54:09 -07:00
|
|
|
/*
|
|
|
|
* When a touch gesture is about to start, this function determines what
|
|
|
|
* kind of gesture interaction we will want to use, based on what is
|
|
|
|
* underneath the initial touch point.
|
|
|
|
* Currently it decides between panning (finger scrolling) or dragging
|
|
|
|
* the target element, as well as the orientation to trigger panning and
|
|
|
|
* display visual boundary feedback. The decision is stored back in aEvent.
|
|
|
|
*/
|
|
|
|
void DecideGestureEvent(nsGestureNotifyEvent* aEvent, nsIFrame* targetFrame);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// routines for the d&d gesture tracking state machine
|
|
|
|
void BeginTrackingDragGesture ( nsPresContext* aPresContext, nsMouseEvent* inDownEvent,
|
|
|
|
nsIFrame* inDownFrame ) ;
|
|
|
|
void StopTrackingDragGesture ( ) ;
|
|
|
|
void GenerateDragGesture ( nsPresContext* aPresContext, nsMouseEvent *aEvent ) ;
|
2008-08-27 05:07:27 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine which node the drag should be targeted at.
|
|
|
|
* This is either the node clicked when there is a selection, or, for HTML,
|
|
|
|
* the element with a draggable property set to true.
|
|
|
|
*
|
|
|
|
* aSelectionTarget - target to check for selection
|
|
|
|
* aDataTransfer - data transfer object that will contain the data to drag
|
2012-02-17 06:16:59 -08:00
|
|
|
* aSelection - [out] set to the selection to be dragged
|
2008-08-27 05:07:27 -07:00
|
|
|
* aTargetNode - [out] the draggable node, or null if there isn't one
|
|
|
|
*/
|
|
|
|
void DetermineDragTarget(nsPresContext* aPresContext,
|
|
|
|
nsIContent* aSelectionTarget,
|
|
|
|
nsDOMDataTransfer* aDataTransfer,
|
2012-02-17 06:16:59 -08:00
|
|
|
nsISelection** aSelection,
|
2008-08-27 05:07:27 -07:00
|
|
|
nsIContent** aTargetNode);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Perform the default handling for the dragstart/draggesture event and set up a
|
2009-11-09 06:55:53 -08:00
|
|
|
* drag for aDataTransfer if it contains any data. Returns true if a drag has
|
|
|
|
* started.
|
2008-08-27 05:07:27 -07:00
|
|
|
*
|
|
|
|
* aDragEvent - the dragstart/draggesture event
|
|
|
|
* aDataTransfer - the data transfer that holds the data to be dragged
|
|
|
|
* aDragTarget - the target of the drag
|
2012-02-17 06:16:59 -08:00
|
|
|
* aSelection - the selection to be dragged
|
2008-08-27 05:07:27 -07:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool DoDefaultDragStart(nsPresContext* aPresContext,
|
2009-11-09 06:55:53 -08:00
|
|
|
nsDragEvent* aDragEvent,
|
|
|
|
nsDOMDataTransfer* aDataTransfer,
|
|
|
|
nsIContent* aDragTarget,
|
2012-02-17 06:16:59 -08:00
|
|
|
nsISelection* aSelection);
|
2008-08-27 05:07:27 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsTrackingDragGesture ( ) const { return mGestureDownContent != nsnull; }
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Set the fields of aEvent to reflect the mouse position and modifier keys
|
|
|
|
* that were set when the user first pressed the mouse button (stored by
|
|
|
|
* BeginTrackingDragGesture). aEvent->widget must be
|
2010-07-02 12:11:04 -07:00
|
|
|
* mCurrentTarget->GetNearestWidget().
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
void FillInEventFromGestureDown(nsMouseEvent* aEvent);
|
|
|
|
|
2009-08-07 08:11:17 -07:00
|
|
|
nsresult DoContentCommandEvent(nsContentCommandEvent* aEvent);
|
2010-03-10 21:25:29 -08:00
|
|
|
nsresult DoContentCommandScrollEvent(nsContentCommandEvent* aEvent);
|
2009-08-07 08:11:17 -07:00
|
|
|
|
2011-05-16 17:23:23 -07:00
|
|
|
void DoQueryScrollTargetInfo(nsQueryContentEvent* aEvent,
|
|
|
|
nsIFrame* aTargetFrame);
|
2011-09-22 02:17:40 -07:00
|
|
|
void DoQuerySelectedText(nsQueryContentEvent* aEvent);
|
2011-05-16 17:23:23 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool RemoteQueryContentEvent(nsEvent *aEvent);
|
2010-09-23 20:28:15 -07:00
|
|
|
mozilla::dom::TabParent *GetCrossProcessTarget();
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsTargetCrossProcess(nsGUIEvent *aEvent);
|
2010-08-17 01:07:44 -07:00
|
|
|
|
2012-07-16 15:19:00 -07:00
|
|
|
void DispatchCrossProcessEvent(nsEvent* aEvent, nsIFrameLoader* remote);
|
2011-09-28 23:19:26 -07:00
|
|
|
bool HandleCrossProcessEvent(nsEvent *aEvent,
|
2011-06-21 17:32:43 -07:00
|
|
|
nsIFrame* aTargetFrame,
|
|
|
|
nsEventStatus *aStatus);
|
|
|
|
|
2011-05-31 18:46:56 -07:00
|
|
|
private:
|
|
|
|
static inline void DoStateChange(mozilla::dom::Element* aElement,
|
2011-09-28 23:19:26 -07:00
|
|
|
nsEventStates aState, bool aAddState);
|
2011-05-31 18:46:56 -07:00
|
|
|
static inline void DoStateChange(nsIContent* aContent, nsEventStates aState,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aAddState);
|
2011-05-31 18:46:56 -07:00
|
|
|
static void UpdateAncestorState(nsIContent* aStartNode,
|
|
|
|
nsIContent* aStopBefore,
|
|
|
|
nsEventStates aState,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aAddState);
|
2011-05-31 18:46:56 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
PRInt32 mLockCursor;
|
|
|
|
|
2012-06-20 16:38:11 -07:00
|
|
|
// Last mouse event refPoint (the offset from the widget's origin in
|
|
|
|
// device pixels) when mouse was locked, used to restore mouse position
|
|
|
|
// after unlocking.
|
2012-04-11 14:55:21 -07:00
|
|
|
nsIntPoint mPreLockPoint;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsWeakFrame mCurrentTarget;
|
|
|
|
nsCOMPtr<nsIContent> mCurrentTargetContent;
|
|
|
|
nsWeakFrame mLastMouseOverFrame;
|
|
|
|
nsCOMPtr<nsIContent> mLastMouseOverElement;
|
2011-09-26 13:55:04 -07:00
|
|
|
static nsWeakFrame sLastDragOverFrame;
|
2012-06-20 16:38:11 -07:00
|
|
|
|
|
|
|
// Stores the refPoint (the offset from the widget's origin in device
|
|
|
|
// pixels) of the last mouse event.
|
2012-04-11 14:55:21 -07:00
|
|
|
static nsIntPoint sLastRefPoint;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// member variables for the d&d gesture state machine
|
2009-01-14 19:27:09 -08:00
|
|
|
nsIntPoint mGestureDownPoint; // screen coordinates
|
2007-03-22 10:30:00 -07:00
|
|
|
// The content to use as target if we start a d&d (what we drag).
|
|
|
|
nsCOMPtr<nsIContent> mGestureDownContent;
|
|
|
|
// The content of the frame where the mouse-down event occurred. It's the same
|
|
|
|
// as the target in most cases but not always - for example when dragging
|
|
|
|
// an <area> of an image map this is the image. (bug 289667)
|
|
|
|
nsCOMPtr<nsIContent> mGestureDownFrameOwner;
|
|
|
|
// State of keys when the original gesture-down happened
|
2012-04-24 20:00:01 -07:00
|
|
|
mozilla::widget::Modifiers mGestureModifiers;
|
2012-04-24 20:00:01 -07:00
|
|
|
PRUint16 mGestureDownButtons;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> mLastLeftMouseDownContent;
|
2010-01-25 01:21:33 -08:00
|
|
|
nsCOMPtr<nsIContent> mLastLeftMouseDownContentParent;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIContent> mLastMiddleMouseDownContent;
|
2010-01-25 01:21:33 -08:00
|
|
|
nsCOMPtr<nsIContent> mLastMiddleMouseDownContentParent;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIContent> mLastRightMouseDownContent;
|
2010-01-25 01:21:33 -08:00
|
|
|
nsCOMPtr<nsIContent> mLastRightMouseDownContentParent;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> mActiveContent;
|
|
|
|
nsCOMPtr<nsIContent> mHoverContent;
|
2011-09-26 13:55:04 -07:00
|
|
|
static nsCOMPtr<nsIContent> sDragOverContent;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIContent> mURLTargetContent;
|
|
|
|
|
|
|
|
// The last element on which we fired a mouseover event, or null if
|
|
|
|
// the last mouseover event we fired has finished processing.
|
|
|
|
nsCOMPtr<nsIContent> mFirstMouseOverEventElement;
|
|
|
|
|
|
|
|
// The last element on which we fired a mouseout event, or null if
|
|
|
|
// the last mouseout event we fired has finished processing.
|
|
|
|
nsCOMPtr<nsIContent> mFirstMouseOutEventElement;
|
|
|
|
|
|
|
|
nsPresContext* mPresContext; // Not refcnted
|
|
|
|
nsCOMPtr<nsIDocument> mDocument; // Doesn't necessarily need to be owner
|
|
|
|
|
|
|
|
PRUint32 mLClickCount;
|
|
|
|
PRUint32 mMClickCount;
|
|
|
|
PRUint32 mRClickCount;
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool m_haveShutdown;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-06 13:14:59 -07:00
|
|
|
// Time at which we began handling user input.
|
|
|
|
static TimeStamp sHandlingInputStart;
|
2010-11-07 11:07:59 -08:00
|
|
|
|
|
|
|
public:
|
|
|
|
static nsresult UpdateUserActivityTimer(void);
|
2007-11-28 12:14:12 -08:00
|
|
|
// Array for accesskey support
|
|
|
|
nsCOMArray<nsIContent> mAccessKeys;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-09-17 04:27:19 -07:00
|
|
|
// Unlocks pixel scrolling
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mLastLineScrollConsumedX;
|
|
|
|
bool mLastLineScrollConsumedY;
|
2008-09-17 04:27:19 -07:00
|
|
|
|
2010-06-16 00:36:11 -07:00
|
|
|
static PRInt32 sUserInputEventDepth;
|
2010-09-08 10:41:37 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool sNormalLMouseEventInProcess;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-09-16 06:10:18 -07:00
|
|
|
static nsEventStateManager* sActiveESM;
|
|
|
|
|
2010-10-28 07:11:15 -07:00
|
|
|
static void ClearGlobalActiveContent(nsEventStateManager* aClearer);
|
2010-09-16 06:10:18 -07:00
|
|
|
|
2010-06-16 00:36:11 -07:00
|
|
|
// Functions used for click hold context menus
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mClickHoldContextMenu;
|
2010-06-16 00:36:11 -07:00
|
|
|
nsCOMPtr<nsITimer> mClickHoldTimer;
|
2007-03-22 10:30:00 -07:00
|
|
|
void CreateClickHoldTimer ( nsPresContext* aPresContext, nsIFrame* inDownFrame,
|
|
|
|
nsGUIEvent* inMouseDownEvent ) ;
|
|
|
|
void KillClickHoldTimer ( ) ;
|
|
|
|
void FireContextClick ( ) ;
|
2012-04-11 14:55:21 -07:00
|
|
|
|
|
|
|
void SetPointerLock(nsIWidget* aWidget, nsIContent* aElement) ;
|
2007-03-22 10:30:00 -07:00
|
|
|
static void sClickHoldCallback ( nsITimer* aTimer, void* aESM ) ;
|
|
|
|
};
|
|
|
|
|
2009-09-13 06:13:16 -07:00
|
|
|
/**
|
|
|
|
* This class is used while processing real user input. During this time, popups
|
|
|
|
* are allowed. For mousedown events, mouse capturing is also permitted.
|
|
|
|
*/
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsAutoHandlingUserInputStatePusher
|
|
|
|
{
|
|
|
|
public:
|
2011-09-28 23:19:26 -07:00
|
|
|
nsAutoHandlingUserInputStatePusher(bool aIsHandlingUserInput,
|
2010-11-05 22:04:11 -07:00
|
|
|
nsEvent* aEvent,
|
|
|
|
nsIDocument* aDocument)
|
|
|
|
: mIsHandlingUserInput(aIsHandlingUserInput),
|
|
|
|
mIsMouseDown(aEvent && aEvent->message == NS_MOUSE_BUTTON_DOWN),
|
2011-10-17 07:59:28 -07:00
|
|
|
mResetFMMouseDownState(false)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (aIsHandlingUserInput) {
|
|
|
|
nsEventStateManager::StartHandlingUserInput();
|
2010-11-05 22:04:11 -07:00
|
|
|
if (mIsMouseDown) {
|
2009-09-13 06:13:16 -07:00
|
|
|
nsIPresShell::SetCapturingContent(nsnull, 0);
|
2011-10-17 07:59:28 -07:00
|
|
|
nsIPresShell::AllowMouseCapture(true);
|
2010-11-05 22:04:11 -07:00
|
|
|
if (aDocument && NS_IS_TRUSTED_EVENT(aEvent)) {
|
|
|
|
nsFocusManager* fm = nsFocusManager::GetFocusManager();
|
|
|
|
if (fm) {
|
|
|
|
fm->SetMouseButtonDownHandlingDocument(aDocument);
|
2011-10-17 07:59:28 -07:00
|
|
|
mResetFMMouseDownState = true;
|
2010-11-05 22:04:11 -07:00
|
|
|
}
|
|
|
|
}
|
2009-09-13 06:13:16 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
~nsAutoHandlingUserInputStatePusher()
|
|
|
|
{
|
|
|
|
if (mIsHandlingUserInput) {
|
|
|
|
nsEventStateManager::StopHandlingUserInput();
|
2009-09-13 06:13:16 -07:00
|
|
|
if (mIsMouseDown) {
|
2011-10-17 07:59:28 -07:00
|
|
|
nsIPresShell::AllowMouseCapture(false);
|
2010-11-05 22:04:11 -07:00
|
|
|
if (mResetFMMouseDownState) {
|
|
|
|
nsFocusManager* fm = nsFocusManager::GetFocusManager();
|
|
|
|
if (fm) {
|
|
|
|
fm->SetMouseButtonDownHandlingDocument(nsnull);
|
|
|
|
}
|
|
|
|
}
|
2009-09-13 06:13:16 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsHandlingUserInput;
|
|
|
|
bool mIsMouseDown;
|
|
|
|
bool mResetFMMouseDownState;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Hide so that this class can only be stack-allocated
|
|
|
|
static void* operator new(size_t /*size*/) CPP_THROW_NEW { return nsnull; }
|
|
|
|
static void operator delete(void* /*memory*/) {}
|
|
|
|
};
|
|
|
|
|
2012-06-07 03:06:39 -07:00
|
|
|
// Click and double-click events need to be handled even for content that
|
|
|
|
// has no frame. This is required for Web compatibility.
|
|
|
|
#define NS_EVENT_NEEDS_FRAME(event) \
|
|
|
|
(!NS_IS_ACTIVATION_EVENT(event) && (event)->message != NS_MOUSE_CLICK && \
|
|
|
|
(event)->message != NS_MOUSE_DOUBLECLICK)
|
2011-04-21 10:35:52 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif // nsEventStateManager_h__
|