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
|
|
|
|
2014-03-31 21:09:23 -07:00
|
|
|
#ifndef mozilla_EventStateManager_h_
|
|
|
|
#define mozilla_EventStateManager_h_
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-09-25 04:21:16 -07:00
|
|
|
#include "mozilla/EventForwards.h"
|
2013-01-28 16:33:17 -08:00
|
|
|
#include "mozilla/TypedEnum.h"
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsWeakReference.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsCOMArray.h"
|
2007-08-10 14:25:24 -07:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2011-09-06 13:14:59 -07:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2012-08-05 20:00:57 -07:00
|
|
|
#include "nsIFrame.h"
|
2013-07-10 02:55:05 -07:00
|
|
|
#include "Units.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-10-22 06:27:35 -07:00
|
|
|
class nsFrameLoader;
|
2013-03-21 17:05:20 -07:00
|
|
|
class nsIContent;
|
2013-03-21 17:05:19 -07:00
|
|
|
class nsIDocument;
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsIDocShell;
|
|
|
|
class nsIDocShellTreeItem;
|
|
|
|
class imgIContainer;
|
2014-02-10 22:34:51 -08:00
|
|
|
class EnterLeaveDispatcher;
|
2014-07-09 14:27:49 -07:00
|
|
|
class nsIContentViewer;
|
2013-08-29 14:18:25 -07:00
|
|
|
class nsIScrollableFrame;
|
|
|
|
class nsITimer;
|
2014-03-31 21:09:23 -07:00
|
|
|
class nsPresContext;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-09-23 20:28:15 -07:00
|
|
|
namespace mozilla {
|
2014-03-31 21:09:24 -07:00
|
|
|
|
2014-03-31 21:09:23 -07:00
|
|
|
class EnterLeaveDispatcher;
|
2014-04-02 21:18:36 -07:00
|
|
|
class EventStates;
|
2014-04-23 17:36:15 -07:00
|
|
|
class IMEContentObserver;
|
2014-03-31 21:09:22 -07:00
|
|
|
class ScrollbarsForWheel;
|
2014-03-31 21:09:22 -07:00
|
|
|
class WheelTransaction;
|
2014-03-31 21:09:24 -07:00
|
|
|
|
2010-09-23 20:28:15 -07:00
|
|
|
namespace dom {
|
2013-08-12 07:45:33 -07:00
|
|
|
class DataTransfer;
|
2010-09-23 20:28:15 -07:00
|
|
|
class TabParent;
|
2014-03-31 21:09:24 -07:00
|
|
|
} // namespace dom
|
2010-09-23 20:28:15 -07:00
|
|
|
|
2014-02-10 22:33:35 -08:00
|
|
|
class OverOutElementsWrapper MOZ_FINAL : public nsISupports
|
|
|
|
{
|
2014-06-23 12:56:07 -07:00
|
|
|
~OverOutElementsWrapper();
|
|
|
|
|
2014-02-10 22:33:35 -08:00
|
|
|
public:
|
2014-03-31 21:09:23 -07:00
|
|
|
OverOutElementsWrapper();
|
2014-02-10 22:33:35 -08:00
|
|
|
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS(OverOutElementsWrapper)
|
|
|
|
|
|
|
|
nsWeakFrame mLastOverFrame;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> mLastOverElement;
|
|
|
|
|
|
|
|
// The last element on which we fired a over event, or null if
|
|
|
|
// the last over event we fired has finished processing.
|
|
|
|
nsCOMPtr<nsIContent> mFirstOverEventElement;
|
|
|
|
|
|
|
|
// The last element on which we fired a out event, or null if
|
|
|
|
// the last out event we fired has finished processing.
|
|
|
|
nsCOMPtr<nsIContent> mFirstOutEventElement;
|
|
|
|
};
|
|
|
|
|
2014-03-31 21:09:23 -07:00
|
|
|
class EventStateManager : public nsSupportsWeakReference,
|
|
|
|
public nsIObserver
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2014-03-31 21:09:23 -07:00
|
|
|
friend class mozilla::EnterLeaveDispatcher;
|
2014-03-31 21:09:22 -07:00
|
|
|
friend class mozilla::ScrollbarsForWheel;
|
2014-03-31 21:09:22 -07:00
|
|
|
friend class mozilla::WheelTransaction;
|
|
|
|
|
2014-06-23 12:56:07 -07:00
|
|
|
virtual ~EventStateManager();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
2014-03-31 21:09:23 -07:00
|
|
|
EventStateManager();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
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,
|
2014-03-31 21:09:23 -07:00
|
|
|
WidgetEvent* aEvent,
|
2011-04-21 10:35:52 -07:00
|
|
|
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,
|
2014-03-31 21:09:23 -07:00
|
|
|
WidgetEvent* aEvent,
|
2011-04-21 10:35:52 -07:00
|
|
|
nsIFrame* aTargetFrame,
|
2011-11-21 09:53:20 -08:00
|
|
|
nsEventStatus* aStatus);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-11 18:42:35 -07:00
|
|
|
/**
|
|
|
|
* DispatchLegacyMouseScrollEvents() dispatches NS_MOUSE_SCROLL event and
|
|
|
|
* NS_MOUSE_PIXEL_SCROLL event for compatiblity with old Gecko.
|
|
|
|
*/
|
|
|
|
void DispatchLegacyMouseScrollEvents(nsIFrame* aTargetFrame,
|
2014-03-31 21:09:23 -07:00
|
|
|
WidgetWheelEvent* aEvent,
|
2012-08-11 18:42:35 -07:00
|
|
|
nsEventStatus* aStatus);
|
|
|
|
|
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();
|
2014-03-31 21:09:23 -07:00
|
|
|
already_AddRefed<nsIContent> GetEventTargetContent(WidgetEvent* 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.
|
|
|
|
*/
|
2014-04-02 21:18:36 -07:00
|
|
|
bool SetContentState(nsIContent* aContent, EventStates aState);
|
2011-04-21 10:35:52 -07:00
|
|
|
void ContentRemoved(nsIDocument* aDocument, nsIContent* aContent);
|
2014-03-31 21:09:23 -07:00
|
|
|
bool EventStatusOK(WidgetGUIEvent* aEvent);
|
2011-04-21 10:35:52 -07:00
|
|
|
|
2014-04-23 17:36:15 -07:00
|
|
|
/**
|
|
|
|
* EventStateManager stores IMEContentObserver while it's observing contents.
|
|
|
|
* Following mehtods are called by IMEContentObserver when it starts to
|
|
|
|
* observe or stops observing the content.
|
|
|
|
*/
|
|
|
|
void OnStartToObserveContent(IMEContentObserver* aIMEContentObserver);
|
|
|
|
void OnStopObservingContent(IMEContentObserver* aIMEContentObserver);
|
|
|
|
|
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
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
void RegisterAccessKey(nsIContent* aContent, uint32_t aKey);
|
2011-04-21 10:35:52 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Unregister accesskey for the given element.
|
|
|
|
*
|
|
|
|
* @param aContent the given element
|
|
|
|
* @param aKey accesskey
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
void UnregisterAccessKey(nsIContent* aContent, uint32_t aKey);
|
2011-04-21 10:35:52 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get accesskey registered on the given element or 0 if there is none.
|
|
|
|
*
|
2012-09-06 00:14:49 -07:00
|
|
|
* @param aContent the given element (must not be null)
|
2011-04-21 10:35:52 -07:00
|
|
|
* @return registered accesskey
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t 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
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
nsresult SetCursor(int32_t 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
|
|
|
}
|
|
|
|
|
2012-11-20 21:25:20 -08: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 over events are not counted as user input, nor are
|
|
|
|
* page load events. If this method is called from asynchronously executed code,
|
|
|
|
* 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.
|
|
|
|
*/
|
2013-01-23 11:39:34 -08:00
|
|
|
static bool IsHandlingUserInput();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-10-19 00:46:31 -07:00
|
|
|
nsPresContext* GetPresContext() { return mPresContext; }
|
|
|
|
|
2014-03-31 21:09:23 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(EventStateManager,
|
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;
|
|
|
|
|
2014-03-31 21:09:23 -07:00
|
|
|
static EventStateManager* 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.
|
2014-03-31 21:09:23 -07:00
|
|
|
static void SetActiveManager(EventStateManager* aNewESM,
|
2010-10-28 07:11:15 -07:00
|
|
|
nsIContent* aContent);
|
2011-09-04 13:39:08 -07:00
|
|
|
|
|
|
|
// Sets the full-screen event state on aElement to aIsFullScreen.
|
2014-03-31 21:09:23 -07:00
|
|
|
static void SetFullScreenState(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);
|
2014-03-31 21:09:23 -07:00
|
|
|
static LayoutDeviceIntPoint GetChildProcessOffset(nsFrameLoader* aFrameLoader,
|
|
|
|
const WidgetEvent& aEvent);
|
2011-10-25 23:42:20 -07:00
|
|
|
|
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
|
2014-03-04 16:37:43 -08:00
|
|
|
// locked. This is used by dom::Event::GetScreenCoords() to make mouse
|
2012-06-20 16:38:11 -07:00
|
|
|
// 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
|
2014-03-04 16:37:43 -08:00
|
|
|
// dom::Event::GetClientCoords() to make mouse events' client coords appear
|
2012-06-20 16:38:11 -07:00
|
|
|
// frozen at the last mouse position while the pointer is locked.
|
2014-03-31 21:09:23 -07:00
|
|
|
static CSSIntPoint 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:
|
2013-08-21 19:31:26 -07:00
|
|
|
/**
|
|
|
|
* Prefs class capsules preference management.
|
|
|
|
*/
|
|
|
|
class Prefs
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static bool KeyCausesActivation() { return sKeyCausesActivation; }
|
|
|
|
static bool ClickHoldContextMenu() { return sClickHoldContextMenu; }
|
2013-08-21 19:31:26 -07:00
|
|
|
static int32_t ChromeAccessModifierMask();
|
|
|
|
static int32_t ContentAccessModifierMask();
|
2013-08-21 19:31:26 -07:00
|
|
|
|
|
|
|
static void Init();
|
2013-12-10 15:10:01 -08:00
|
|
|
static void OnChange(const char* aPrefName, void*);
|
2013-08-21 19:31:26 -07:00
|
|
|
static void Shutdown();
|
|
|
|
|
|
|
|
private:
|
|
|
|
static bool sKeyCausesActivation;
|
|
|
|
static bool sClickHoldContextMenu;
|
2013-08-21 19:31:26 -07:00
|
|
|
static int32_t sGenericAccessModifierKey;
|
|
|
|
static int32_t sChromeAccessModifierMask;
|
|
|
|
static int32_t sContentAccessModifierMask;
|
|
|
|
|
|
|
|
static int32_t GetAccessModifierMask(int32_t aItemType);
|
2013-08-21 19:31:26 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-08-21 19:31:26 -07:00
|
|
|
* Get appropriate access modifier mask for the aDocShell. Returns -1 if
|
2013-08-21 19:31:26 -07:00
|
|
|
* access key isn't available.
|
|
|
|
*/
|
2013-08-21 19:31:26 -07:00
|
|
|
static int32_t GetAccessModifierMaskFor(nsISupports* aDocShell);
|
2013-08-21 19:31:26 -07:00
|
|
|
|
2014-05-27 18:12:29 -07:00
|
|
|
/*
|
|
|
|
* If aTargetFrame's widget has a cached cursor value, resets the cursor
|
|
|
|
* such that the next call to SetCursor on the widget will force an update
|
|
|
|
* of the native cursor. For use in getting puppet widget to update its
|
|
|
|
* cursor between mouse exit / enter transitions. This call basically wraps
|
|
|
|
* nsIWidget ClearCachedCursor.
|
|
|
|
*/
|
|
|
|
void ClearCachedWidgetCursor(nsIFrame* aTargetFrame);
|
|
|
|
|
2013-10-01 20:46:04 -07:00
|
|
|
void UpdateCursor(nsPresContext* aPresContext,
|
2014-03-31 21:09:23 -07:00
|
|
|
WidgetEvent* aEvent,
|
2013-10-01 20:46:04 -07:00
|
|
|
nsIFrame* aTargetFrame,
|
|
|
|
nsEventStatus* aStatus);
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2014-02-10 22:34:51 -08:00
|
|
|
* Turn a GUI mouse/pointer event into a mouse/pointer event targeted at the specified
|
2007-03-22 10:30:00 -07:00
|
|
|
* content. This returns the primary frame for the content (or null
|
|
|
|
* if it goes away during the event).
|
|
|
|
*/
|
2014-03-31 21:09:23 -07:00
|
|
|
nsIFrame* DispatchMouseOrPointerEvent(WidgetMouseEvent* aMouseEvent,
|
2014-02-10 22:34:51 -08:00
|
|
|
uint32_t aMessage,
|
|
|
|
nsIContent* aTargetContent,
|
|
|
|
nsIContent* aRelatedContent);
|
2014-06-17 22:12:00 -07:00
|
|
|
/**
|
|
|
|
* Synthesize DOM pointerover and pointerout events
|
|
|
|
*/
|
|
|
|
void GeneratePointerEnterExit(uint32_t aMessage, WidgetMouseEvent* aEvent);
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Synthesize DOM and frame mouseover and mouseout events from this
|
|
|
|
* MOUSE_MOVE or MOUSE_EXIT event.
|
|
|
|
*/
|
2014-03-31 21:09:23 -07:00
|
|
|
void GenerateMouseEnterExit(WidgetMouseEvent* aMouseEvent);
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Tell this ESM and ESMs in parent documents that the mouse is
|
|
|
|
* over some content in this document.
|
|
|
|
*/
|
2014-03-31 21:09:23 -07:00
|
|
|
void NotifyMouseOver(WidgetMouseEvent* aMouseEvent,
|
2013-10-22 01:55:20 -07:00
|
|
|
nsIContent* aContent);
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Tell this ESM and ESMs in affected child documents that the mouse
|
|
|
|
* has exited this document's currently hovered content.
|
2013-10-22 01:55:20 -07:00
|
|
|
* @param aMouseEvent the event that triggered the mouseout
|
2007-03-22 10:30:00 -07:00
|
|
|
* @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.
|
|
|
|
*/
|
2014-03-31 21:09:23 -07:00
|
|
|
void NotifyMouseOut(WidgetMouseEvent* aMouseEvent,
|
2013-10-22 01:55:20 -07:00
|
|
|
nsIContent* aMovingInto);
|
2013-10-01 20:46:03 -07:00
|
|
|
void GenerateDragDropEnterExit(nsPresContext* aPresContext,
|
2014-03-31 21:09:23 -07:00
|
|
|
WidgetDragEvent* aDragEvent);
|
2014-02-10 22:33:35 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return mMouseEnterLeaveHelper or relevant mPointersEnterLeaveHelper elements wrapper.
|
|
|
|
* If mPointersEnterLeaveHelper does not contain wrapper for pointerId it create new one
|
|
|
|
*/
|
2014-03-31 21:09:23 -07:00
|
|
|
OverOutElementsWrapper* GetWrapperByEventID(WidgetMouseEvent* aMouseEvent);
|
2014-02-10 22:33:35 -08:00
|
|
|
|
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,
|
2014-03-31 21:09:23 -07:00
|
|
|
WidgetDragEvent* aDragEvent,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aMsg,
|
2007-04-11 21:37:39 -07:00
|
|
|
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.
|
|
|
|
*/
|
2014-03-31 21:09:23 -07:00
|
|
|
void UpdateDragDataTransfer(WidgetDragEvent* dragEvent);
|
2009-10-06 19:51:02 -07:00
|
|
|
|
2013-10-01 23:38:27 -07:00
|
|
|
nsresult SetClickCount(nsPresContext* aPresContext,
|
2014-03-31 21:09:23 -07:00
|
|
|
WidgetMouseEvent* aEvent,
|
2013-10-01 23:38:27 -07:00
|
|
|
nsEventStatus* aStatus);
|
|
|
|
nsresult CheckForAndDispatchClick(nsPresContext* aPresContext,
|
2014-03-31 21:09:23 -07:00
|
|
|
WidgetMouseEvent* aEvent,
|
2013-10-01 23:38:27 -07:00
|
|
|
nsEventStatus* aStatus);
|
2007-03-22 10:30:00 -07:00
|
|
|
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
|
2012-07-30 07:20:58 -07:00
|
|
|
* passes |nullptr| here. This is to avoid an infinite loop.
|
2007-05-17 20:49:14 -07:00
|
|
|
* @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,
|
2014-03-31 21:09:23 -07:00
|
|
|
WidgetKeyboardEvent* aEvent,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsEventStatus* aStatus,
|
2007-05-17 20:49:14 -07:00
|
|
|
nsIDocShellTreeItem* aBubbledFrom,
|
2007-03-22 10:30:00 -07:00
|
|
|
ProcessingAccessKeyState aAccessKeyState,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aModifierMask);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
bool ExecuteAccessKey(nsTArray<uint32_t>& aAccessCharCodes,
|
2011-09-28 23:19:26 -07:00
|
|
|
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
|
2012-08-11 18:42:34 -07:00
|
|
|
|
|
|
|
class WheelPrefs
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static WheelPrefs* GetInstance();
|
|
|
|
static void Shutdown();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ApplyUserPrefsToDelta() overrides the wheel event's delta values with
|
|
|
|
* user prefs.
|
|
|
|
*/
|
2014-03-31 21:09:23 -07:00
|
|
|
void ApplyUserPrefsToDelta(WidgetWheelEvent* aEvent);
|
2012-08-11 18:42:34 -07:00
|
|
|
|
2012-08-11 18:42:36 -07:00
|
|
|
/**
|
|
|
|
* If ApplyUserPrefsToDelta() changed the delta values with customized
|
|
|
|
* prefs, the overflowDelta values would be inflated.
|
|
|
|
* CancelApplyingUserPrefsFromOverflowDelta() cancels the inflation.
|
|
|
|
*/
|
2014-03-31 21:09:23 -07:00
|
|
|
void CancelApplyingUserPrefsFromOverflowDelta(WidgetWheelEvent* aEvent);
|
2012-08-11 18:42:36 -07:00
|
|
|
|
2012-08-11 18:42:35 -07:00
|
|
|
/**
|
2012-08-11 18:42:36 -07:00
|
|
|
* Computes the default action for the aEvent with the prefs.
|
2012-08-11 18:42:35 -07:00
|
|
|
*/
|
2012-12-07 20:08:19 -08:00
|
|
|
enum Action MOZ_ENUM_TYPE(uint8_t)
|
2012-08-11 18:42:35 -07:00
|
|
|
{
|
|
|
|
ACTION_NONE = 0,
|
|
|
|
ACTION_SCROLL,
|
|
|
|
ACTION_HISTORY,
|
|
|
|
ACTION_ZOOM,
|
|
|
|
ACTION_LAST = ACTION_ZOOM
|
|
|
|
};
|
2014-03-31 21:09:23 -07:00
|
|
|
Action ComputeActionFor(WidgetWheelEvent* aEvent);
|
2012-08-11 18:42:35 -07:00
|
|
|
|
2012-08-11 18:42:36 -07:00
|
|
|
/**
|
|
|
|
* NeedToComputeLineOrPageDelta() returns if the aEvent needs to be
|
|
|
|
* computed the lineOrPageDelta values.
|
|
|
|
*/
|
2014-03-31 21:09:23 -07:00
|
|
|
bool NeedToComputeLineOrPageDelta(WidgetWheelEvent* aEvent);
|
2012-08-11 18:42:36 -07:00
|
|
|
|
2012-10-30 16:22:23 -07:00
|
|
|
/**
|
|
|
|
* IsOverOnePageScrollAllowed*() checks whether wheel scroll amount should
|
|
|
|
* be rounded down to the page width/height (false) or not (true).
|
|
|
|
*/
|
2014-03-31 21:09:23 -07:00
|
|
|
bool IsOverOnePageScrollAllowedX(WidgetWheelEvent* aEvent);
|
|
|
|
bool IsOverOnePageScrollAllowedY(WidgetWheelEvent* aEvent);
|
2012-10-30 16:22:23 -07:00
|
|
|
|
2012-08-11 18:42:34 -07:00
|
|
|
private:
|
|
|
|
WheelPrefs();
|
|
|
|
~WheelPrefs();
|
|
|
|
|
2013-12-10 15:10:01 -08:00
|
|
|
static void OnPrefChanged(const char* aPrefName, void* aClosure);
|
2012-08-11 18:42:34 -07:00
|
|
|
|
|
|
|
enum Index
|
|
|
|
{
|
|
|
|
INDEX_DEFAULT = 0,
|
|
|
|
INDEX_ALT,
|
|
|
|
INDEX_CONTROL,
|
|
|
|
INDEX_META,
|
|
|
|
INDEX_SHIFT,
|
|
|
|
INDEX_OS,
|
|
|
|
COUNT_OF_MULTIPLIERS
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GetIndexFor() returns the index of the members which should be used for
|
|
|
|
* the aEvent. When only one modifier key of MODIFIER_ALT,
|
|
|
|
* MODIFIER_CONTROL, MODIFIER_META, MODIFIER_SHIFT or MODIFIER_OS is
|
|
|
|
* pressed, returns the index for the modifier. Otherwise, this return the
|
|
|
|
* default index which is used at either no modifier key is pressed or
|
|
|
|
* two or modifier keys are pressed.
|
|
|
|
*/
|
2014-03-31 21:09:23 -07:00
|
|
|
Index GetIndexFor(WidgetWheelEvent* aEvent);
|
2012-08-11 18:42:34 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GetPrefNameBase() returns the base pref name for aEvent.
|
|
|
|
* It's decided by GetModifierForPref() which modifier should be used for
|
|
|
|
* the aEvent.
|
|
|
|
*
|
2012-08-11 18:42:35 -07:00
|
|
|
* @param aBasePrefName The result, must be "mousewheel.with_*." or
|
|
|
|
* "mousewheel.default.".
|
2012-08-11 18:42:34 -07:00
|
|
|
*/
|
|
|
|
void GetBasePrefName(Index aIndex, nsACString& aBasePrefName);
|
|
|
|
|
|
|
|
void Init(Index aIndex);
|
|
|
|
|
|
|
|
void Reset();
|
|
|
|
|
2012-10-30 16:22:23 -07:00
|
|
|
/**
|
|
|
|
* If the abosolute values of mMultiplierX and/or mMultiplierY are equals or
|
|
|
|
* larger than this value, the computed scroll amount isn't rounded down to
|
|
|
|
* the page width or height.
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
MIN_MULTIPLIER_VALUE_ALLOWING_OVER_ONE_PAGE_SCROLL = 1000
|
|
|
|
};
|
|
|
|
|
2012-08-11 18:42:34 -07:00
|
|
|
bool mInit[COUNT_OF_MULTIPLIERS];
|
|
|
|
double mMultiplierX[COUNT_OF_MULTIPLIERS];
|
|
|
|
double mMultiplierY[COUNT_OF_MULTIPLIERS];
|
2012-08-11 18:42:36 -07:00
|
|
|
double mMultiplierZ[COUNT_OF_MULTIPLIERS];
|
2012-08-11 18:42:35 -07:00
|
|
|
Action mActions[COUNT_OF_MULTIPLIERS];
|
2012-12-07 20:08:19 -08:00
|
|
|
/**
|
|
|
|
* action values overridden by .override_x pref.
|
|
|
|
* If an .override_x value is -1, same as the
|
|
|
|
* corresponding mActions value.
|
|
|
|
*/
|
|
|
|
Action mOverriddenActionsX[COUNT_OF_MULTIPLIERS];
|
2012-08-11 18:42:34 -07:00
|
|
|
|
|
|
|
static WheelPrefs* sInstance;
|
|
|
|
};
|
|
|
|
|
2012-08-11 18:42:35 -07:00
|
|
|
/**
|
|
|
|
* DeltaDirection is used for specifying whether the called method should
|
|
|
|
* handle vertical delta or horizontal delta.
|
|
|
|
* This is clearer than using bool.
|
|
|
|
*/
|
|
|
|
enum DeltaDirection
|
|
|
|
{
|
|
|
|
DELTA_DIRECTION_X = 0,
|
|
|
|
DELTA_DIRECTION_Y
|
|
|
|
};
|
|
|
|
|
2013-12-08 07:51:16 -08:00
|
|
|
struct MOZ_STACK_CLASS EventState
|
|
|
|
{
|
|
|
|
bool mDefaultPrevented;
|
|
|
|
bool mDefaultPreventedByContent;
|
|
|
|
|
|
|
|
EventState() :
|
|
|
|
mDefaultPrevented(false), mDefaultPreventedByContent(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-08-11 18:42:35 -07:00
|
|
|
/**
|
|
|
|
* SendLineScrollEvent() dispatches a DOMMouseScroll event for the
|
2013-10-16 02:37:36 -07:00
|
|
|
* WidgetWheelEvent. This method shouldn't be called for non-trusted
|
2012-08-11 18:42:35 -07:00
|
|
|
* wheel event because it's not necessary for compatiblity.
|
|
|
|
*
|
|
|
|
* @param aTargetFrame The event target of wheel event.
|
|
|
|
* @param aEvent The original Wheel event.
|
2013-12-08 07:51:16 -08:00
|
|
|
* @param aState The event which should be set to the dispatching
|
|
|
|
* event. This also returns the dispatched event
|
|
|
|
* state.
|
2012-08-11 18:42:35 -07:00
|
|
|
* @param aDelta The delta value of the event.
|
|
|
|
* @param aDeltaDirection The X/Y direction of dispatching event.
|
|
|
|
*/
|
2009-04-02 12:34:31 -07:00
|
|
|
void SendLineScrollEvent(nsIFrame* aTargetFrame,
|
2014-03-31 21:09:23 -07:00
|
|
|
WidgetWheelEvent* aEvent,
|
2013-12-08 07:51:16 -08:00
|
|
|
EventState& aState,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aDelta,
|
2012-08-11 18:42:35 -07:00
|
|
|
DeltaDirection aDeltaDirection);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SendPixelScrollEvent() dispatches a MozMousePixelScroll event for the
|
2013-10-16 02:37:36 -07:00
|
|
|
* WidgetWheelEvent. This method shouldn't be called for non-trusted
|
2012-08-11 18:42:35 -07:00
|
|
|
* wheel event because it's not necessary for compatiblity.
|
|
|
|
*
|
|
|
|
* @param aTargetFrame The event target of wheel event.
|
|
|
|
* @param aEvent The original Wheel event.
|
2013-12-08 07:51:16 -08:00
|
|
|
* @param aState The event which should be set to the dispatching
|
|
|
|
* event. This also returns the dispatched event
|
|
|
|
* state.
|
2012-08-11 18:42:35 -07:00
|
|
|
* @param aPixelDelta The delta value of the event.
|
|
|
|
* @param aDeltaDirection The X/Y direction of dispatching event.
|
|
|
|
*/
|
2008-09-17 04:27:19 -07:00
|
|
|
void SendPixelScrollEvent(nsIFrame* aTargetFrame,
|
2014-03-31 21:09:23 -07:00
|
|
|
WidgetWheelEvent* aEvent,
|
2013-12-08 07:51:16 -08:00
|
|
|
EventState& aState,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aPixelDelta,
|
2012-08-11 18:42:35 -07:00
|
|
|
DeltaDirection aDeltaDirection);
|
2012-08-11 18:42:34 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ComputeScrollTarget() returns the scrollable frame which should be
|
|
|
|
* scrolled.
|
|
|
|
*
|
|
|
|
* @param aTargetFrame The event target of the wheel event.
|
|
|
|
* @param aEvent The handling mouse wheel event.
|
2012-09-04 01:39:28 -07:00
|
|
|
* @param aOptions The options for finding the scroll target.
|
|
|
|
* Callers should use COMPUTE_*.
|
2012-08-11 18:42:34 -07:00
|
|
|
* @return The scrollable frame which should be scrolled.
|
|
|
|
*/
|
2012-09-04 01:39:28 -07:00
|
|
|
// These flags are used in ComputeScrollTarget(). Callers should use
|
|
|
|
// COMPUTE_*.
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PREFER_MOUSE_WHEEL_TRANSACTION = 1,
|
|
|
|
PREFER_ACTUAL_SCROLLABLE_TARGET_ALONG_X_AXIS = 2,
|
|
|
|
PREFER_ACTUAL_SCROLLABLE_TARGET_ALONG_Y_AXIS = 4,
|
|
|
|
START_FROM_PARENT = 8
|
|
|
|
};
|
|
|
|
enum ComputeScrollTargetOptions
|
|
|
|
{
|
|
|
|
// At computing scroll target for legacy mouse events, we should return
|
|
|
|
// first scrollable element even when it's not scrollable to the direction.
|
|
|
|
COMPUTE_LEGACY_MOUSE_SCROLL_EVENT_TARGET = 0,
|
|
|
|
// Default action prefers the scrolled element immediately before if it's
|
|
|
|
// still under the mouse cursor. Otherwise, it prefers the nearest
|
|
|
|
// scrollable ancestor which will be scrolled actually.
|
|
|
|
COMPUTE_DEFAULT_ACTION_TARGET =
|
|
|
|
(PREFER_MOUSE_WHEEL_TRANSACTION |
|
|
|
|
PREFER_ACTUAL_SCROLLABLE_TARGET_ALONG_X_AXIS |
|
|
|
|
PREFER_ACTUAL_SCROLLABLE_TARGET_ALONG_Y_AXIS),
|
|
|
|
// Look for the nearest scrollable ancestor which can be scrollable with
|
|
|
|
// aEvent.
|
|
|
|
COMPUTE_SCROLLABLE_ANCESTOR_ALONG_X_AXIS =
|
|
|
|
(PREFER_ACTUAL_SCROLLABLE_TARGET_ALONG_X_AXIS | START_FROM_PARENT),
|
|
|
|
COMPUTE_SCROLLABLE_ANCESTOR_ALONG_Y_AXIS =
|
|
|
|
(PREFER_ACTUAL_SCROLLABLE_TARGET_ALONG_Y_AXIS | START_FROM_PARENT)
|
|
|
|
};
|
2012-08-11 18:42:34 -07:00
|
|
|
nsIScrollableFrame* ComputeScrollTarget(nsIFrame* aTargetFrame,
|
2014-03-31 21:09:23 -07:00
|
|
|
WidgetWheelEvent* aEvent,
|
2012-09-04 01:39:28 -07:00
|
|
|
ComputeScrollTargetOptions aOptions);
|
2013-08-16 14:17:40 -07:00
|
|
|
|
|
|
|
nsIScrollableFrame* ComputeScrollTarget(nsIFrame* aTargetFrame,
|
|
|
|
double aDirectionX,
|
|
|
|
double aDirectionY,
|
2014-03-31 21:09:23 -07:00
|
|
|
WidgetWheelEvent* aEvent,
|
2013-08-16 14:17:40 -07:00
|
|
|
ComputeScrollTargetOptions aOptions);
|
2012-08-11 18:42:34 -07:00
|
|
|
|
|
|
|
/**
|
2012-08-11 18:42:35 -07:00
|
|
|
* GetScrollAmount() returns the scroll amount in app uints of one line or
|
|
|
|
* one page. If the wheel event scrolls a page, returns the page width and
|
|
|
|
* height. Otherwise, returns line height for both its width and height.
|
2012-08-11 18:42:34 -07:00
|
|
|
*
|
|
|
|
* @param aScrollableFrame A frame which will be scrolled by the event.
|
|
|
|
* The result of ComputeScrollTarget() is
|
|
|
|
* expected for this value.
|
2013-04-02 18:14:24 -07:00
|
|
|
* This can be nullptr if there is no scrollable
|
2012-08-11 18:42:34 -07:00
|
|
|
* frame. Then, this method uses root frame's
|
2012-08-11 18:42:35 -07:00
|
|
|
* line height or visible area's width and height.
|
2012-08-11 18:42:34 -07:00
|
|
|
*/
|
2012-08-11 18:42:35 -07:00
|
|
|
nsSize GetScrollAmount(nsPresContext* aPresContext,
|
2014-03-31 21:09:23 -07:00
|
|
|
WidgetWheelEvent* aEvent,
|
2012-08-11 18:42:35 -07:00
|
|
|
nsIScrollableFrame* aScrollableFrame);
|
2012-08-11 18:42:34 -07:00
|
|
|
|
2011-05-16 17:23:23 -07:00
|
|
|
/**
|
2012-08-11 18:42:35 -07:00
|
|
|
* DoScrollText() scrolls the scrollable frame for aEvent.
|
2011-05-16 17:23:23 -07:00
|
|
|
*/
|
2012-08-11 18:42:35 -07:00
|
|
|
void DoScrollText(nsIScrollableFrame* aScrollableFrame,
|
2014-03-31 21:09:23 -07:00
|
|
|
WidgetWheelEvent* aEvent);
|
2012-08-11 18:42:35 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void DoScrollHistory(int32_t direction);
|
|
|
|
void DoScrollZoom(nsIFrame *aTargetFrame, int32_t adjustment);
|
2014-07-09 14:27:49 -07:00
|
|
|
nsresult GetContentViewer(nsIContentViewer** aCv);
|
2012-08-22 08:56:38 -07:00
|
|
|
nsresult ChangeTextSize(int32_t change);
|
|
|
|
nsresult ChangeFullZoom(int32_t change);
|
2012-08-11 18:42:35 -07:00
|
|
|
|
2012-08-11 18:42:35 -07:00
|
|
|
/**
|
2012-08-11 18:42:36 -07:00
|
|
|
* DeltaAccumulator class manages delta values for dispatching DOMMouseScroll
|
|
|
|
* event. If wheel events are caused by pixel scroll only devices or
|
|
|
|
* the delta values are customized by prefs, this class stores the delta
|
|
|
|
* values and set lineOrPageDelta values.
|
2012-08-11 18:42:35 -07:00
|
|
|
*/
|
2012-08-11 18:42:36 -07:00
|
|
|
class DeltaAccumulator
|
2012-08-11 18:42:35 -07:00
|
|
|
{
|
|
|
|
public:
|
2012-08-11 18:42:36 -07:00
|
|
|
static DeltaAccumulator* GetInstance()
|
2012-08-11 18:42:35 -07:00
|
|
|
{
|
|
|
|
if (!sInstance) {
|
2012-08-11 18:42:36 -07:00
|
|
|
sInstance = new DeltaAccumulator;
|
2012-08-11 18:42:35 -07:00
|
|
|
}
|
|
|
|
return sInstance;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void Shutdown()
|
|
|
|
{
|
|
|
|
delete sInstance;
|
|
|
|
sInstance = nullptr;
|
|
|
|
}
|
|
|
|
|
2012-09-27 23:57:33 -07:00
|
|
|
bool IsInTransaction() { return mHandlingDeltaMode != UINT32_MAX; }
|
2012-08-19 09:46:21 -07:00
|
|
|
|
2012-08-11 18:42:35 -07:00
|
|
|
/**
|
2013-10-16 02:37:36 -07:00
|
|
|
* InitLineOrPageDelta() stores pixel delta values of WidgetWheelEvents
|
|
|
|
* which are caused if it's needed. And if the accumulated delta becomes a
|
2012-08-11 18:42:36 -07:00
|
|
|
* line height, sets lineOrPageDeltaX and lineOrPageDeltaY automatically.
|
2012-08-11 18:42:35 -07:00
|
|
|
*/
|
2012-08-11 18:42:36 -07:00
|
|
|
void InitLineOrPageDelta(nsIFrame* aTargetFrame,
|
2014-03-31 21:09:23 -07:00
|
|
|
EventStateManager* aESM,
|
|
|
|
WidgetWheelEvent* aEvent);
|
2012-08-11 18:42:36 -07:00
|
|
|
|
2012-08-11 18:42:35 -07:00
|
|
|
/**
|
2012-08-19 09:46:21 -07:00
|
|
|
* Reset() resets all members.
|
2012-08-11 18:42:35 -07:00
|
|
|
*/
|
|
|
|
void Reset();
|
|
|
|
|
2012-08-19 09:46:21 -07:00
|
|
|
/**
|
|
|
|
* ComputeScrollAmountForDefaultAction() computes the default action's
|
|
|
|
* scroll amount in device pixels with mPendingScrollAmount*.
|
|
|
|
*/
|
|
|
|
nsIntPoint ComputeScrollAmountForDefaultAction(
|
2014-03-31 21:09:23 -07:00
|
|
|
WidgetWheelEvent* aEvent,
|
2012-08-19 09:46:21 -07:00
|
|
|
const nsIntSize& aScrollAmountInDevPixels);
|
|
|
|
|
2012-08-11 18:42:35 -07:00
|
|
|
private:
|
2012-08-11 18:42:36 -07:00
|
|
|
DeltaAccumulator() :
|
2012-08-19 09:46:21 -07:00
|
|
|
mX(0.0), mY(0.0), mPendingScrollAmountX(0.0), mPendingScrollAmountY(0.0),
|
2014-07-07 02:54:14 -07:00
|
|
|
mHandlingDeltaMode(UINT32_MAX), mIsNoLineOrPageDeltaDevice(false)
|
2012-08-11 18:42:35 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-11 18:42:36 -07:00
|
|
|
double mX;
|
|
|
|
double mY;
|
2012-08-19 09:46:21 -07:00
|
|
|
|
|
|
|
// When default action of a wheel event is scroll but some delta values
|
|
|
|
// are ignored because the computed amount values are not integer, the
|
|
|
|
// fractional values are saved by these members.
|
|
|
|
double mPendingScrollAmountX;
|
|
|
|
double mPendingScrollAmountY;
|
|
|
|
|
2012-08-11 18:42:35 -07:00
|
|
|
TimeStamp mLastTime;
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mHandlingDeltaMode;
|
2014-07-07 02:54:14 -07:00
|
|
|
bool mIsNoLineOrPageDeltaDevice;
|
2012-08-11 18:42:36 -07:00
|
|
|
|
|
|
|
static DeltaAccumulator* sInstance;
|
2012-08-11 18:42:35 -07:00
|
|
|
};
|
|
|
|
|
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.
|
|
|
|
*/
|
2014-03-31 21:09:23 -07:00
|
|
|
void DecideGestureEvent(WidgetGestureNotifyEvent* aEvent,
|
2013-09-26 23:20:57 -07:00
|
|
|
nsIFrame* targetFrame);
|
2009-08-13 13:54:09 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// routines for the d&d gesture tracking state machine
|
2013-10-01 23:38:27 -07:00
|
|
|
void BeginTrackingDragGesture(nsPresContext* aPresContext,
|
2014-03-31 21:09:23 -07:00
|
|
|
WidgetMouseEvent* aDownEvent,
|
2013-10-01 23:38:27 -07:00
|
|
|
nsIFrame* aDownFrame);
|
|
|
|
void StopTrackingDragGesture();
|
|
|
|
void GenerateDragGesture(nsPresContext* aPresContext,
|
2014-03-31 21:09:23 -07:00
|
|
|
WidgetMouseEvent* 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
|
|
|
|
*/
|
2014-02-26 19:23:31 -08:00
|
|
|
void DetermineDragTarget(nsPIDOMWindow* aWindow,
|
2008-08-27 05:07:27 -07:00
|
|
|
nsIContent* aSelectionTarget,
|
2014-03-31 21:09:23 -07:00
|
|
|
dom::DataTransfer* 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,
|
2014-03-31 21:09:23 -07:00
|
|
|
WidgetDragEvent* aDragEvent,
|
|
|
|
dom::DataTransfer* aDataTransfer,
|
2013-10-01 00:23:02 -07:00
|
|
|
nsIContent* aDragTarget,
|
|
|
|
nsISelection* aSelection);
|
2008-08-27 05:07:27 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
bool IsTrackingDragGesture ( ) const { return mGestureDownContent != nullptr; }
|
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
|
|
|
*/
|
2014-03-31 21:09:23 -07:00
|
|
|
void FillInEventFromGestureDown(WidgetMouseEvent* aEvent);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-03-31 21:09:23 -07:00
|
|
|
nsresult DoContentCommandEvent(WidgetContentCommandEvent* aEvent);
|
|
|
|
nsresult DoContentCommandScrollEvent(WidgetContentCommandEvent* aEvent);
|
2009-08-07 08:11:17 -07:00
|
|
|
|
2014-03-31 21:09:23 -07:00
|
|
|
void DoQuerySelectedText(WidgetQueryContentEvent* aEvent);
|
2011-05-16 17:23:23 -07:00
|
|
|
|
2014-03-31 21:09:23 -07:00
|
|
|
bool RemoteQueryContentEvent(WidgetEvent* aEvent);
|
|
|
|
dom::TabParent *GetCrossProcessTarget();
|
|
|
|
bool IsTargetCrossProcess(WidgetGUIEvent* aEvent);
|
2010-08-17 01:07:44 -07:00
|
|
|
|
2014-03-31 21:09:23 -07:00
|
|
|
bool DispatchCrossProcessEvent(WidgetEvent* aEvent,
|
2013-10-01 20:46:04 -07:00
|
|
|
nsFrameLoader* aRemote,
|
2011-06-21 17:32:43 -07:00
|
|
|
nsEventStatus *aStatus);
|
2014-03-31 21:09:23 -07:00
|
|
|
bool HandleCrossProcessEvent(WidgetEvent* aEvent,
|
2013-10-01 20:46:04 -07:00
|
|
|
nsEventStatus* aStatus);
|
2011-06-21 17:32:43 -07:00
|
|
|
|
2014-04-23 17:36:15 -07:00
|
|
|
void ReleaseCurrentIMEContentObserver();
|
|
|
|
|
2011-05-31 18:46:56 -07:00
|
|
|
private:
|
2014-03-31 21:09:23 -07:00
|
|
|
static inline void DoStateChange(dom::Element* aElement,
|
2014-04-02 21:18:36 -07:00
|
|
|
EventStates aState, bool aAddState);
|
|
|
|
static inline void DoStateChange(nsIContent* aContent, EventStates 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,
|
2014-04-02 21:18:36 -07:00
|
|
|
EventStates aState,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aAddState);
|
2014-02-10 22:33:35 -08:00
|
|
|
static PLDHashOperator ResetLastOverForContent(const uint32_t& aIdx,
|
|
|
|
nsRefPtr<OverOutElementsWrapper>& aChunk,
|
|
|
|
void* aClosure);
|
2011-05-31 18:46:56 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mLockCursor;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
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.
|
2014-03-31 21:09:23 -07:00
|
|
|
LayoutDeviceIntPoint mPreLockPoint;
|
2012-04-11 14:55:21 -07:00
|
|
|
|
2012-09-24 16:44:03 -07:00
|
|
|
// Stores the refPoint of the last synthetic mouse move we dispatched
|
|
|
|
// to re-center the mouse when we were pointer locked. If this is (-1,-1) it
|
|
|
|
// means we've not recently dispatched a centering event. We use this to
|
|
|
|
// detect when we receive the synth event, so we can cancel and not send it
|
|
|
|
// to content.
|
2014-03-31 21:09:23 -07:00
|
|
|
static LayoutDeviceIntPoint sSynthCenteringPoint;
|
2012-09-24 16:44:03 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsWeakFrame mCurrentTarget;
|
|
|
|
nsCOMPtr<nsIContent> mCurrentTargetContent;
|
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.
|
2014-03-31 21:09:23 -07:00
|
|
|
static LayoutDeviceIntPoint sLastRefPoint;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// member variables for the d&d gesture state machine
|
2014-03-31 21:09:23 -07:00
|
|
|
LayoutDeviceIntPoint 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
|
2014-03-31 21:09:23 -07:00
|
|
|
Modifiers mGestureModifiers;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint16_t 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;
|
|
|
|
|
|
|
|
nsPresContext* mPresContext; // Not refcnted
|
|
|
|
nsCOMPtr<nsIDocument> mDocument; // Doesn't necessarily need to be owner
|
|
|
|
|
2014-04-23 17:36:15 -07:00
|
|
|
nsRefPtr<IMEContentObserver> mIMEContentObserver;
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mLClickCount;
|
|
|
|
uint32_t mMClickCount;
|
|
|
|
uint32_t mRClickCount;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
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
|
|
|
|
2014-02-10 22:33:35 -08:00
|
|
|
nsRefPtr<OverOutElementsWrapper> mMouseEnterLeaveHelper;
|
|
|
|
nsRefPtrHashtable<nsUint32HashKey, OverOutElementsWrapper> mPointersEnterLeaveHelper;
|
|
|
|
|
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
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
static int32_t 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
|
|
|
|
2014-03-31 21:09:23 -07:00
|
|
|
static EventStateManager* sActiveESM;
|
2010-09-16 06:10:18 -07:00
|
|
|
|
2014-03-31 21:09:23 -07:00
|
|
|
static void ClearGlobalActiveContent(EventStateManager* aClearer);
|
2010-09-16 06:10:18 -07:00
|
|
|
|
2010-06-16 00:36:11 -07:00
|
|
|
// Functions used for click hold context menus
|
|
|
|
nsCOMPtr<nsITimer> mClickHoldTimer;
|
2013-10-01 20:46:03 -07:00
|
|
|
void CreateClickHoldTimer(nsPresContext* aPresContext,
|
|
|
|
nsIFrame* aDownFrame,
|
2014-03-31 21:09:23 -07:00
|
|
|
WidgetGUIEvent* aMouseDownEvent);
|
2013-10-01 20:46:03 -07:00
|
|
|
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.
|
|
|
|
*/
|
2013-10-22 06:27:35 -07:00
|
|
|
class AutoHandlingUserInputStatePusher
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2013-10-22 06:27:35 -07:00
|
|
|
AutoHandlingUserInputStatePusher(bool aIsHandlingUserInput,
|
|
|
|
WidgetEvent* aEvent,
|
|
|
|
nsIDocument* aDocument);
|
|
|
|
~AutoHandlingUserInputStatePusher();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
protected:
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsHandlingUserInput;
|
|
|
|
bool mIsMouseDown;
|
2014-06-17 23:13:00 -07:00
|
|
|
bool mResetFMMouseButtonHandlingState;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-06-17 23:13:01 -07:00
|
|
|
nsCOMPtr<nsIDocument> mMouseButtonEventHandlingDocument;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
private:
|
|
|
|
// Hide so that this class can only be stack-allocated
|
2012-07-30 07:20:58 -07:00
|
|
|
static void* operator new(size_t /*size*/) CPP_THROW_NEW { return nullptr; }
|
2007-03-22 10:30:00 -07:00
|
|
|
static void operator delete(void* /*memory*/) {}
|
|
|
|
};
|
|
|
|
|
2013-10-22 06:27:35 -07:00
|
|
|
} // namespace mozilla
|
|
|
|
|
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) \
|
2013-09-24 03:04:16 -07:00
|
|
|
(!(event)->HasPluginActivationEventMessage() && \
|
|
|
|
(event)->message != NS_MOUSE_CLICK && \
|
2012-06-07 03:06:39 -07:00
|
|
|
(event)->message != NS_MOUSE_DOUBLECLICK)
|
2011-04-21 10:35:52 -07:00
|
|
|
|
2014-03-31 21:09:23 -07:00
|
|
|
#endif // mozilla_EventStateManager_h_
|