2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04: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/. */
|
1998-06-24 01:53:02 +04:00
|
|
|
|
2014-04-01 08:09:23 +04:00
|
|
|
#ifndef mozilla_EventStateManager_h_
|
|
|
|
#define mozilla_EventStateManager_h_
|
1998-06-24 01:53:02 +04:00
|
|
|
|
2013-09-25 15:21:16 +04:00
|
|
|
#include "mozilla/EventForwards.h"
|
2013-01-29 04:33:17 +04:00
|
|
|
|
2000-03-15 07:03:44 +03:00
|
|
|
#include "nsIObserver.h"
|
2000-05-09 23:04:13 +04:00
|
|
|
#include "nsWeakReference.h"
|
2003-07-04 00:34:52 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2003-03-18 02:08:36 +03:00
|
|
|
#include "nsCOMArray.h"
|
2007-08-11 01:25:24 +04:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2011-09-07 00:14:59 +04:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2012-08-06 07:00:57 +04:00
|
|
|
#include "nsIFrame.h"
|
2013-07-10 13:55:05 +04:00
|
|
|
#include "Units.h"
|
2000-03-15 07:03:44 +03:00
|
|
|
|
2013-10-22 17:27:35 +04:00
|
|
|
class nsFrameLoader;
|
2013-03-22 04:05:20 +04:00
|
|
|
class nsIContent;
|
2013-03-22 04:05:19 +04:00
|
|
|
class nsIDocument;
|
2001-05-23 03:52:17 +04:00
|
|
|
class nsIDocShell;
|
2001-10-23 02:43:52 +04:00
|
|
|
class nsIDocShellTreeItem;
|
2004-12-31 00:56:11 +03:00
|
|
|
class imgIContainer;
|
2014-02-11 10:34:51 +04:00
|
|
|
class EnterLeaveDispatcher;
|
2014-07-10 01:27:49 +04:00
|
|
|
class nsIContentViewer;
|
2013-08-30 01:18:25 +04:00
|
|
|
class nsIScrollableFrame;
|
|
|
|
class nsITimer;
|
2014-04-01 08:09:23 +04:00
|
|
|
class nsPresContext;
|
2001-03-30 08:45:40 +04:00
|
|
|
|
2010-09-24 07:28:15 +04:00
|
|
|
namespace mozilla {
|
2014-04-01 08:09:24 +04:00
|
|
|
|
2014-04-01 08:09:23 +04:00
|
|
|
class EnterLeaveDispatcher;
|
2014-04-03 08:18:36 +04:00
|
|
|
class EventStates;
|
2014-04-24 04:36:15 +04:00
|
|
|
class IMEContentObserver;
|
2014-04-01 08:09:22 +04:00
|
|
|
class ScrollbarsForWheel;
|
2014-04-01 08:09:22 +04:00
|
|
|
class WheelTransaction;
|
2014-04-01 08:09:24 +04:00
|
|
|
|
2010-09-24 07:28:15 +04:00
|
|
|
namespace dom {
|
2013-08-12 18:45:33 +04:00
|
|
|
class DataTransfer;
|
2014-10-15 09:42:00 +04:00
|
|
|
class Element;
|
2010-09-24 07:28:15 +04:00
|
|
|
class TabParent;
|
2014-04-01 08:09:24 +04:00
|
|
|
} // namespace dom
|
2010-09-24 07:28:15 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class OverOutElementsWrapper final : public nsISupports
|
2014-02-11 10:33:35 +04:00
|
|
|
{
|
2014-06-23 23:56:07 +04:00
|
|
|
~OverOutElementsWrapper();
|
|
|
|
|
2014-02-11 10:33:35 +04:00
|
|
|
public:
|
2014-04-01 08:09:23 +04:00
|
|
|
OverOutElementsWrapper();
|
2014-02-11 10:33:35 +04: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-04-01 08:09:23 +04:00
|
|
|
class EventStateManager : public nsSupportsWeakReference,
|
|
|
|
public nsIObserver
|
2000-03-15 07:03:44 +03:00
|
|
|
{
|
2014-04-01 08:09:23 +04:00
|
|
|
friend class mozilla::EnterLeaveDispatcher;
|
2014-04-01 08:09:22 +04:00
|
|
|
friend class mozilla::ScrollbarsForWheel;
|
2014-04-01 08:09:22 +04:00
|
|
|
friend class mozilla::WheelTransaction;
|
|
|
|
|
2014-06-23 23:56:07 +04:00
|
|
|
virtual ~EventStateManager();
|
|
|
|
|
1998-06-24 01:53:02 +04:00
|
|
|
public:
|
2014-04-01 08:09:23 +04:00
|
|
|
EventStateManager();
|
1998-06-24 01:53:02 +04:00
|
|
|
|
2007-08-11 01:25:24 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2000-03-15 07:03:44 +03:00
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
2011-04-21 21:35:52 +04:00
|
|
|
nsresult Init();
|
2000-03-15 07:03:44 +03:00
|
|
|
nsresult Shutdown();
|
1998-06-24 01:53:02 +04:00
|
|
|
|
1999-12-04 05:22:21 +03:00
|
|
|
/* 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 21:35:52 +04:00
|
|
|
nsresult PreHandleEvent(nsPresContext* aPresContext,
|
2014-04-01 08:09:23 +04:00
|
|
|
WidgetEvent* aEvent,
|
2011-04-21 21:35:52 +04:00
|
|
|
nsIFrame* aTargetFrame,
|
2015-04-14 18:46:39 +03:00
|
|
|
nsIContent* aTargetContent,
|
2011-11-21 21:53:20 +04:00
|
|
|
nsEventStatus* aStatus);
|
1998-11-24 10:46:58 +03:00
|
|
|
|
1999-12-04 05:22:21 +03: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 21:35:52 +04:00
|
|
|
nsresult PostHandleEvent(nsPresContext* aPresContext,
|
2014-04-01 08:09:23 +04:00
|
|
|
WidgetEvent* aEvent,
|
2011-04-21 21:35:52 +04:00
|
|
|
nsIFrame* aTargetFrame,
|
2011-11-21 21:53:20 +04:00
|
|
|
nsEventStatus* aStatus);
|
1998-11-18 08:25:26 +03:00
|
|
|
|
2016-03-15 08:49:19 +03:00
|
|
|
void PostHandleKeyboardEvent(WidgetKeyboardEvent* aKeyboardEvent,
|
|
|
|
nsEventStatus& aStatus,
|
|
|
|
bool dispatchedToContentProcess);
|
|
|
|
|
2012-08-12 05:42:35 +04:00
|
|
|
/**
|
2015-09-10 04:40:04 +03:00
|
|
|
* DispatchLegacyMouseScrollEvents() dispatches eLegacyMouseLineOrPageScroll
|
2015-09-10 04:40:04 +03:00
|
|
|
* event and eLegacyMousePixelScroll event for compatibility with old Gecko.
|
2012-08-12 05:42:35 +04:00
|
|
|
*/
|
|
|
|
void DispatchLegacyMouseScrollEvents(nsIFrame* aTargetFrame,
|
2014-04-01 08:09:23 +04:00
|
|
|
WidgetWheelEvent* aEvent,
|
2012-08-12 05:42:35 +04:00
|
|
|
nsEventStatus* aStatus);
|
|
|
|
|
2011-04-21 21:35:52 +04:00
|
|
|
void NotifyDestroyPresContext(nsPresContext* aPresContext);
|
|
|
|
void SetPresContext(nsPresContext* aPresContext);
|
|
|
|
void ClearFrameRefs(nsIFrame* aFrame);
|
1998-06-24 01:53:02 +04:00
|
|
|
|
2011-04-21 21:35:52 +04:00
|
|
|
nsIFrame* GetEventTarget();
|
2014-04-01 08:09:23 +04:00
|
|
|
already_AddRefed<nsIContent> GetEventTargetContent(WidgetEvent* aEvent);
|
1998-08-07 08:45:03 +04:00
|
|
|
|
2011-04-21 21:35:52 +04: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 18:59:28 +04:00
|
|
|
* @return Whether the content was able to change all states. Returns false
|
2011-04-21 21:35:52 +04: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-03 08:18:36 +04:00
|
|
|
bool SetContentState(nsIContent* aContent, EventStates aState);
|
2011-04-21 21:35:52 +04:00
|
|
|
void ContentRemoved(nsIDocument* aDocument, nsIContent* aContent);
|
2014-04-01 08:09:23 +04:00
|
|
|
bool EventStatusOK(WidgetGUIEvent* aEvent);
|
2011-04-21 21:35:52 +04:00
|
|
|
|
2014-04-24 04:36:15 +04: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);
|
|
|
|
|
2015-11-10 05:49:05 +03:00
|
|
|
/**
|
|
|
|
* TryToFlushPendingNotificationsToIME() suggests flushing pending
|
|
|
|
* notifications to IME to IMEContentObserver.
|
|
|
|
*/
|
|
|
|
void TryToFlushPendingNotificationsToIME();
|
|
|
|
|
2011-04-21 21:35:52 +04: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 19:56:38 +04:00
|
|
|
void RegisterAccessKey(nsIContent* aContent, uint32_t aKey);
|
2011-04-21 21:35:52 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Unregister accesskey for the given element.
|
|
|
|
*
|
|
|
|
* @param aContent the given element
|
|
|
|
* @param aKey accesskey
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
void UnregisterAccessKey(nsIContent* aContent, uint32_t aKey);
|
2011-04-21 21:35:52 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get accesskey registered on the given element or 0 if there is none.
|
|
|
|
*
|
2012-09-06 11:14:49 +04:00
|
|
|
* @param aContent the given element (must not be null)
|
2011-04-21 21:35:52 +04:00
|
|
|
* @return registered accesskey
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t GetRegisteredAccessKey(nsIContent* aContent);
|
2000-02-09 18:14:55 +03:00
|
|
|
|
2014-10-15 09:42:00 +04:00
|
|
|
static void GetAccessKeyLabelPrefix(dom::Element* aElement, nsAString& aPrefix);
|
2011-07-31 23:43:54 +04:00
|
|
|
|
2016-05-11 15:56:42 +03:00
|
|
|
bool HandleAccessKey(WidgetKeyboardEvent* aEvent,
|
|
|
|
nsPresContext* aPresContext,
|
2015-09-18 15:18:07 +03:00
|
|
|
nsTArray<uint32_t>& aAccessCharCodes,
|
2016-05-11 15:56:42 +03:00
|
|
|
int32_t aModifierMask,
|
|
|
|
bool aMatchesContentAccessKey)
|
2015-09-18 15:18:07 +03:00
|
|
|
{
|
2016-05-11 15:56:42 +03:00
|
|
|
return HandleAccessKey(aEvent, aPresContext, aAccessCharCodes,
|
|
|
|
aMatchesContentAccessKey, nullptr,
|
|
|
|
eAccessKeyProcessingNormal, aModifierMask);
|
2015-09-18 15:18:07 +03:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
nsresult SetCursor(int32_t aCursor, imgIContainer* aContainer,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aHaveHotspot, float aHotspotX, float aHotspotY,
|
|
|
|
nsIWidget* aWidget, bool aLockCursor);
|
2000-04-24 08:41:27 +04:00
|
|
|
|
2004-09-04 23:28:46 +04:00
|
|
|
static void StartHandlingUserInput()
|
|
|
|
{
|
|
|
|
++sUserInputEventDepth;
|
2015-12-04 04:40:45 +03:00
|
|
|
++sUserInputCounter;
|
2011-09-07 00:14:59 +04:00
|
|
|
if (sUserInputEventDepth == 1) {
|
2015-12-04 04:40:45 +03:00
|
|
|
sLatestUserInputStart = sHandlingInputStart = TimeStamp::Now();
|
2011-09-07 00:14:59 +04:00
|
|
|
}
|
2004-09-04 23:28:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void StopHandlingUserInput()
|
|
|
|
{
|
|
|
|
--sUserInputEventDepth;
|
2011-09-07 00:14:59 +04:00
|
|
|
if (sUserInputEventDepth == 0) {
|
|
|
|
sHandlingInputStart = TimeStamp();
|
|
|
|
}
|
2004-09-04 23:28:46 +04:00
|
|
|
}
|
|
|
|
|
2012-11-21 09:25:20 +04:00
|
|
|
/**
|
2015-12-04 04:40:45 +03:00
|
|
|
* Returns true if the current code is being executed as a result of
|
|
|
|
* user input. This includes anything that is initiated by user,
|
|
|
|
* with the exception of page load events or mouse over 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.
|
2012-11-21 09:25:20 +04:00
|
|
|
*/
|
2013-01-23 23:39:34 +04:00
|
|
|
static bool IsHandlingUserInput();
|
2004-09-04 23:28:46 +04:00
|
|
|
|
2015-12-04 04:40:45 +03:00
|
|
|
/**
|
|
|
|
* Get the number of user inputs handled since process start. This
|
|
|
|
* includes anything that is initiated by user, with the exception
|
|
|
|
* of page load events or mouse over events.
|
|
|
|
*/
|
|
|
|
static uint64_t UserInputCount()
|
|
|
|
{
|
|
|
|
return sUserInputCounter;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the timestamp at which the latest user input was handled.
|
|
|
|
*
|
|
|
|
* Guaranteed to be monotonic. Until the first user input, return
|
|
|
|
* the epoch.
|
|
|
|
*/
|
|
|
|
static TimeStamp LatestUserInputStart()
|
|
|
|
{
|
|
|
|
return sLatestUserInputStart;
|
|
|
|
}
|
|
|
|
|
2010-10-19 11:46:31 +04:00
|
|
|
nsPresContext* GetPresContext() { return mPresContext; }
|
|
|
|
|
2014-04-01 08:09:23 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(EventStateManager,
|
2011-04-21 21:35:52 +04:00
|
|
|
nsIObserver)
|
2007-08-11 01:25:24 +04:00
|
|
|
|
2010-09-17 22:56:53 +04:00
|
|
|
static nsIDocument* sMouseOverDocument;
|
|
|
|
|
2014-04-01 08:09:23 +04:00
|
|
|
static EventStateManager* GetActiveEventStateManager() { return sActiveESM; }
|
2010-10-20 17:49:53 +04:00
|
|
|
|
2010-10-28 18:11:15 +04:00
|
|
|
// Sets aNewESM to be the active event state manager, and
|
|
|
|
// if aContent is non-null, marks the object as active.
|
2014-04-01 08:09:23 +04:00
|
|
|
static void SetActiveManager(EventStateManager* aNewESM,
|
2010-10-28 18:11:15 +04:00
|
|
|
nsIContent* aContent);
|
2011-09-05 00:39:08 +04:00
|
|
|
|
|
|
|
// Sets the full-screen event state on aElement to aIsFullScreen.
|
2014-04-01 08:09:23 +04:00
|
|
|
static void SetFullScreenState(dom::Element* aElement, bool aIsFullScreen);
|
2011-09-05 00:39:08 +04:00
|
|
|
|
2011-10-26 10:42:20 +04:00
|
|
|
static bool IsRemoteTarget(nsIContent* aTarget);
|
|
|
|
|
2015-02-02 22:28:19 +03:00
|
|
|
// Returns true if the given WidgetWheelEvent will resolve to a scroll action.
|
|
|
|
static bool WheelEventIsScrollAction(WidgetWheelEvent* aEvent);
|
|
|
|
|
2015-12-02 00:46:07 +03:00
|
|
|
// Returns user-set multipliers for a wheel event.
|
|
|
|
static void GetUserPrefsForWheelEvent(WidgetWheelEvent* aEvent,
|
|
|
|
double* aOutMultiplierX,
|
|
|
|
double* aOutMultiplierY);
|
2015-03-25 00:58:49 +03:00
|
|
|
|
2015-03-07 01:26:59 +03:00
|
|
|
// Returns whether or not a frame can be vertically scrolled with a mouse
|
|
|
|
// wheel (as opposed to, say, a selection or touch scroll).
|
|
|
|
static bool CanVerticallyScrollFrameWithWheel(nsIFrame* aFrame);
|
|
|
|
|
2012-06-21 03:38:11 +04: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-05 04:37:43 +04:00
|
|
|
// locked. This is used by dom::Event::GetScreenCoords() to make mouse
|
2012-06-21 03:38:11 +04:00
|
|
|
// events' screen coord appear frozen at the last mouse position while
|
|
|
|
// the pointer is locked.
|
2015-11-10 19:32:40 +03:00
|
|
|
static CSSIntPoint sLastScreenPoint;
|
2012-06-21 03:38:11 +04:00
|
|
|
|
|
|
|
// Holds the point in client coords of the last mouse event. Used by
|
2014-03-05 04:37:43 +04:00
|
|
|
// dom::Event::GetClientCoords() to make mouse events' client coords appear
|
2012-06-21 03:38:11 +04:00
|
|
|
// frozen at the last mouse position while the pointer is locked.
|
2014-04-01 08:09:23 +04:00
|
|
|
static CSSIntPoint sLastClientPoint;
|
2012-06-21 03:38:11 +04:00
|
|
|
|
2012-04-12 01:55:21 +04:00
|
|
|
static bool sIsPointerLocked;
|
|
|
|
static nsWeakPtr sPointerLockedElement;
|
|
|
|
static nsWeakPtr sPointerLockedDoc;
|
|
|
|
|
2016-04-12 07:06:49 +03:00
|
|
|
/**
|
|
|
|
* If the absolute values of mMultiplierX and/or mMultiplierY are equal 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
|
|
|
|
};
|
|
|
|
|
1998-06-24 01:53:02 +04:00
|
|
|
protected:
|
2013-08-22 06:31:26 +04:00
|
|
|
/**
|
|
|
|
* Prefs class capsules preference management.
|
|
|
|
*/
|
|
|
|
class Prefs
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static bool KeyCausesActivation() { return sKeyCausesActivation; }
|
|
|
|
static bool ClickHoldContextMenu() { return sClickHoldContextMenu; }
|
2013-08-22 06:31:26 +04:00
|
|
|
static int32_t ChromeAccessModifierMask();
|
|
|
|
static int32_t ContentAccessModifierMask();
|
2013-08-22 06:31:26 +04:00
|
|
|
|
|
|
|
static void Init();
|
2013-12-11 03:10:01 +04:00
|
|
|
static void OnChange(const char* aPrefName, void*);
|
2013-08-22 06:31:26 +04:00
|
|
|
static void Shutdown();
|
|
|
|
|
|
|
|
private:
|
|
|
|
static bool sKeyCausesActivation;
|
|
|
|
static bool sClickHoldContextMenu;
|
2013-08-22 06:31:26 +04:00
|
|
|
static int32_t sGenericAccessModifierKey;
|
|
|
|
static int32_t sChromeAccessModifierMask;
|
|
|
|
static int32_t sContentAccessModifierMask;
|
|
|
|
|
|
|
|
static int32_t GetAccessModifierMask(int32_t aItemType);
|
2013-08-22 06:31:26 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-08-22 06:31:26 +04:00
|
|
|
* Get appropriate access modifier mask for the aDocShell. Returns -1 if
|
2013-08-22 06:31:26 +04:00
|
|
|
* access key isn't available.
|
|
|
|
*/
|
2013-08-22 06:31:26 +04:00
|
|
|
static int32_t GetAccessModifierMaskFor(nsISupports* aDocShell);
|
2013-08-22 06:31:26 +04:00
|
|
|
|
2014-05-28 05:12:29 +04: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-02 07:46:04 +04:00
|
|
|
void UpdateCursor(nsPresContext* aPresContext,
|
2014-04-01 08:09:23 +04:00
|
|
|
WidgetEvent* aEvent,
|
2013-10-02 07:46:04 +04:00
|
|
|
nsIFrame* aTargetFrame,
|
|
|
|
nsEventStatus* aStatus);
|
2002-12-18 10:13:51 +03:00
|
|
|
/**
|
2014-02-11 10:34:51 +04:00
|
|
|
* Turn a GUI mouse/pointer event into a mouse/pointer event targeted at the specified
|
2005-03-29 03:39:13 +04:00
|
|
|
* content. This returns the primary frame for the content (or null
|
|
|
|
* if it goes away during the event).
|
2002-12-18 10:13:51 +03:00
|
|
|
*/
|
2014-04-01 08:09:23 +04:00
|
|
|
nsIFrame* DispatchMouseOrPointerEvent(WidgetMouseEvent* aMouseEvent,
|
2015-08-26 15:56:59 +03:00
|
|
|
EventMessage aMessage,
|
2014-02-11 10:34:51 +04:00
|
|
|
nsIContent* aTargetContent,
|
|
|
|
nsIContent* aRelatedContent);
|
2014-06-18 09:12:00 +04:00
|
|
|
/**
|
|
|
|
* Synthesize DOM pointerover and pointerout events
|
|
|
|
*/
|
2015-08-26 15:56:59 +03:00
|
|
|
void GeneratePointerEnterExit(EventMessage aMessage,
|
|
|
|
WidgetMouseEvent* aEvent);
|
2005-03-29 03:39:13 +04:00
|
|
|
/**
|
|
|
|
* Synthesize DOM and frame mouseover and mouseout events from this
|
|
|
|
* MOUSE_MOVE or MOUSE_EXIT event.
|
|
|
|
*/
|
2014-04-01 08:09:23 +04:00
|
|
|
void GenerateMouseEnterExit(WidgetMouseEvent* aMouseEvent);
|
2005-03-29 03:39:13 +04:00
|
|
|
/**
|
|
|
|
* Tell this ESM and ESMs in parent documents that the mouse is
|
|
|
|
* over some content in this document.
|
|
|
|
*/
|
2014-04-01 08:09:23 +04:00
|
|
|
void NotifyMouseOver(WidgetMouseEvent* aMouseEvent,
|
2013-10-22 12:55:20 +04:00
|
|
|
nsIContent* aContent);
|
2005-03-29 03:39:13 +04:00
|
|
|
/**
|
|
|
|
* Tell this ESM and ESMs in affected child documents that the mouse
|
|
|
|
* has exited this document's currently hovered content.
|
2013-10-22 12:55:20 +04:00
|
|
|
* @param aMouseEvent the event that triggered the mouseout
|
2005-05-03 20:05:48 +04: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.
|
2005-03-29 03:39:13 +04:00
|
|
|
*/
|
2014-04-01 08:09:23 +04:00
|
|
|
void NotifyMouseOut(WidgetMouseEvent* aMouseEvent,
|
2013-10-22 12:55:20 +04:00
|
|
|
nsIContent* aMovingInto);
|
2013-10-02 07:46:03 +04:00
|
|
|
void GenerateDragDropEnterExit(nsPresContext* aPresContext,
|
2014-04-01 08:09:23 +04:00
|
|
|
WidgetDragEvent* aDragEvent);
|
2014-02-11 10:33:35 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return mMouseEnterLeaveHelper or relevant mPointersEnterLeaveHelper elements wrapper.
|
|
|
|
* If mPointersEnterLeaveHelper does not contain wrapper for pointerId it create new one
|
|
|
|
*/
|
2014-04-01 08:09:23 +04:00
|
|
|
OverOutElementsWrapper* GetWrapperByEventID(WidgetMouseEvent* aMouseEvent);
|
2014-02-11 10:33:35 +04:00
|
|
|
|
2007-04-12 08:37:39 +04: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-04-01 08:09:23 +04:00
|
|
|
WidgetDragEvent* aDragEvent,
|
2015-08-26 15:56:59 +03:00
|
|
|
EventMessage aMessage,
|
2007-04-12 08:37:39 +04:00
|
|
|
nsIContent* aRelatedTarget,
|
|
|
|
nsIContent* aTargetContent,
|
|
|
|
nsWeakFrame& aTargetFrame);
|
2009-10-07 06:51:02 +04:00
|
|
|
/**
|
|
|
|
* Update the initial drag session data transfer with any changes that occur
|
|
|
|
* on cloned data transfer objects used for events.
|
|
|
|
*/
|
2014-04-01 08:09:23 +04:00
|
|
|
void UpdateDragDataTransfer(WidgetDragEvent* dragEvent);
|
2009-10-07 06:51:02 +04:00
|
|
|
|
2016-12-01 03:48:02 +03:00
|
|
|
static nsresult InitAndDispatchClickEvent(WidgetMouseEvent* aEvent,
|
|
|
|
nsEventStatus* aStatus,
|
|
|
|
EventMessage aMessage,
|
|
|
|
nsIPresShell* aPresShell,
|
|
|
|
nsIContent* aMouseTarget,
|
|
|
|
nsWeakFrame aCurrentTarget,
|
|
|
|
bool aNoContentDispatch);
|
2015-12-07 04:15:53 +03:00
|
|
|
nsresult SetClickCount(WidgetMouseEvent* aEvent, nsEventStatus* aStatus);
|
|
|
|
nsresult CheckForAndDispatchClick(WidgetMouseEvent* aEvent,
|
2013-10-02 10:38:27 +04:00
|
|
|
nsEventStatus* aStatus);
|
2004-08-01 03:15:21 +04:00
|
|
|
void EnsureDocument(nsPresContext* aPresContext);
|
|
|
|
void FlushPendingEvents(nsPresContext* aPresContext);
|
1999-11-21 04:46:41 +03:00
|
|
|
|
2007-05-18 07:49:14 +04:00
|
|
|
/**
|
|
|
|
* The phases of HandleAccessKey processing. See below.
|
|
|
|
*/
|
2002-09-03 09:48:06 +04:00
|
|
|
typedef enum {
|
|
|
|
eAccessKeyProcessingNormal = 0,
|
|
|
|
eAccessKeyProcessingUp,
|
|
|
|
eAccessKeyProcessingDown
|
|
|
|
} ProcessingAccessKeyState;
|
2007-05-18 07:49:14 +04: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.
|
|
|
|
*
|
2016-05-11 15:56:42 +03:00
|
|
|
* @param aEvent the keyboard event triggering the acccess key
|
2007-05-18 07:49:14 +04:00
|
|
|
* @param aPresContext the presentation context
|
2015-09-18 15:18:07 +03:00
|
|
|
* @param aAccessCharCodes list of charcode candidates
|
2016-05-11 15:56:42 +03:00
|
|
|
* @param aMatchesContentAccessKey true if the content accesskey modifier is pressed
|
2007-05-18 07:49:14 +04:00
|
|
|
* @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 12:02:09 +03:00
|
|
|
* that recursively called us in its Up phase. The initial caller
|
2012-07-30 18:20:58 +04:00
|
|
|
* passes |nullptr| here. This is to avoid an infinite loop.
|
2007-05-18 07:49:14 +04:00
|
|
|
* @param aAccessKeyState Normal, Down or Up processing phase (see enums
|
2008-08-26 10:53:00 +04:00
|
|
|
* above). The initial event receiver uses 'normal', then 'down' when
|
2007-05-18 07:49:14 +04:00
|
|
|
* processing children and Up when recursively calling its ancestor.
|
|
|
|
* @param aModifierMask modifier mask for the key event
|
|
|
|
*/
|
2016-05-11 15:56:42 +03:00
|
|
|
bool HandleAccessKey(WidgetKeyboardEvent* aEvent,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
nsTArray<uint32_t>& aAccessCharCodes,
|
|
|
|
bool aMatchesContentAccessKey,
|
|
|
|
nsIDocShellTreeItem* aBubbledFrom,
|
|
|
|
ProcessingAccessKeyState aAccessKeyState,
|
|
|
|
int32_t aModifierMask);
|
2002-09-03 09:48:06 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
bool ExecuteAccessKey(nsTArray<uint32_t>& aAccessCharCodes,
|
2016-05-11 15:56:42 +03:00
|
|
|
bool aIsTrustedEvent);
|
2008-04-15 08:16:24 +04:00
|
|
|
|
2001-05-23 03:52:17 +04: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 22:00:39 +04:00
|
|
|
nsIContent* GetFocusedContent();
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsShellVisible(nsIDocShell* aShell);
|
2001-05-23 03:52:17 +04:00
|
|
|
|
2009-04-02 23:34:31 +04:00
|
|
|
// These functions are for mousewheel and pixel scrolling
|
2012-08-12 05:42:34 +04:00
|
|
|
|
|
|
|
class WheelPrefs
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static WheelPrefs* GetInstance();
|
|
|
|
static void Shutdown();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ApplyUserPrefsToDelta() overrides the wheel event's delta values with
|
|
|
|
* user prefs.
|
|
|
|
*/
|
2014-04-01 08:09:23 +04:00
|
|
|
void ApplyUserPrefsToDelta(WidgetWheelEvent* aEvent);
|
2012-08-12 05:42:34 +04:00
|
|
|
|
2015-03-25 00:58:49 +03:00
|
|
|
/**
|
|
|
|
* Returns whether or not ApplyUserPrefsToDelta() would change the delta
|
|
|
|
* values of an event.
|
|
|
|
*/
|
2015-12-02 00:46:07 +03:00
|
|
|
void GetUserPrefsForEvent(WidgetWheelEvent* aEvent,
|
|
|
|
double* aOutMultiplierX,
|
|
|
|
double* aOutMultiplierY);
|
2015-03-25 00:58:49 +03:00
|
|
|
|
2012-08-12 05:42:36 +04:00
|
|
|
/**
|
|
|
|
* If ApplyUserPrefsToDelta() changed the delta values with customized
|
|
|
|
* prefs, the overflowDelta values would be inflated.
|
|
|
|
* CancelApplyingUserPrefsFromOverflowDelta() cancels the inflation.
|
|
|
|
*/
|
2014-04-01 08:09:23 +04:00
|
|
|
void CancelApplyingUserPrefsFromOverflowDelta(WidgetWheelEvent* aEvent);
|
2012-08-12 05:42:36 +04:00
|
|
|
|
2012-08-12 05:42:35 +04:00
|
|
|
/**
|
2012-08-12 05:42:36 +04:00
|
|
|
* Computes the default action for the aEvent with the prefs.
|
2012-08-12 05:42:35 +04:00
|
|
|
*/
|
2015-01-21 16:35:19 +03:00
|
|
|
enum Action : uint8_t
|
2012-08-12 05:42:35 +04:00
|
|
|
{
|
|
|
|
ACTION_NONE = 0,
|
|
|
|
ACTION_SCROLL,
|
|
|
|
ACTION_HISTORY,
|
|
|
|
ACTION_ZOOM,
|
2015-10-16 07:19:27 +03:00
|
|
|
ACTION_LAST = ACTION_ZOOM,
|
|
|
|
// Following actions are used only by internal processing. So, cannot
|
|
|
|
// specified by prefs.
|
|
|
|
ACTION_SEND_TO_PLUGIN
|
2012-08-12 05:42:35 +04:00
|
|
|
};
|
2014-04-01 08:09:23 +04:00
|
|
|
Action ComputeActionFor(WidgetWheelEvent* aEvent);
|
2012-08-12 05:42:35 +04:00
|
|
|
|
2012-08-12 05:42:36 +04:00
|
|
|
/**
|
|
|
|
* NeedToComputeLineOrPageDelta() returns if the aEvent needs to be
|
|
|
|
* computed the lineOrPageDelta values.
|
|
|
|
*/
|
2014-04-01 08:09:23 +04:00
|
|
|
bool NeedToComputeLineOrPageDelta(WidgetWheelEvent* aEvent);
|
2012-08-12 05:42:36 +04:00
|
|
|
|
2012-10-31 03:22:23 +04:00
|
|
|
/**
|
|
|
|
* IsOverOnePageScrollAllowed*() checks whether wheel scroll amount should
|
|
|
|
* be rounded down to the page width/height (false) or not (true).
|
|
|
|
*/
|
2014-04-01 08:09:23 +04:00
|
|
|
bool IsOverOnePageScrollAllowedX(WidgetWheelEvent* aEvent);
|
|
|
|
bool IsOverOnePageScrollAllowedY(WidgetWheelEvent* aEvent);
|
2012-10-31 03:22:23 +04:00
|
|
|
|
2016-02-26 03:41:59 +03:00
|
|
|
/**
|
|
|
|
* WheelEventsEnabledOnPlugins() returns true if user wants to use mouse
|
|
|
|
* wheel on plugins.
|
|
|
|
*/
|
|
|
|
static bool WheelEventsEnabledOnPlugins();
|
|
|
|
|
2012-08-12 05:42:34 +04:00
|
|
|
private:
|
|
|
|
WheelPrefs();
|
|
|
|
~WheelPrefs();
|
|
|
|
|
2013-12-11 03:10:01 +04:00
|
|
|
static void OnPrefChanged(const char* aPrefName, void* aClosure);
|
2012-08-12 05:42:34 +04: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-04-01 08:09:23 +04:00
|
|
|
Index GetIndexFor(WidgetWheelEvent* aEvent);
|
2012-08-12 05:42:34 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GetPrefNameBase() returns the base pref name for aEvent.
|
|
|
|
* It's decided by GetModifierForPref() which modifier should be used for
|
|
|
|
* the aEvent.
|
|
|
|
*
|
2012-08-12 05:42:35 +04:00
|
|
|
* @param aBasePrefName The result, must be "mousewheel.with_*." or
|
|
|
|
* "mousewheel.default.".
|
2012-08-12 05:42:34 +04:00
|
|
|
*/
|
|
|
|
void GetBasePrefName(Index aIndex, nsACString& aBasePrefName);
|
|
|
|
|
|
|
|
void Init(Index aIndex);
|
|
|
|
|
|
|
|
void Reset();
|
|
|
|
|
|
|
|
bool mInit[COUNT_OF_MULTIPLIERS];
|
|
|
|
double mMultiplierX[COUNT_OF_MULTIPLIERS];
|
|
|
|
double mMultiplierY[COUNT_OF_MULTIPLIERS];
|
2012-08-12 05:42:36 +04:00
|
|
|
double mMultiplierZ[COUNT_OF_MULTIPLIERS];
|
2012-08-12 05:42:35 +04:00
|
|
|
Action mActions[COUNT_OF_MULTIPLIERS];
|
2012-12-08 08:08:19 +04: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-12 05:42:34 +04:00
|
|
|
|
|
|
|
static WheelPrefs* sInstance;
|
2016-02-26 03:41:59 +03:00
|
|
|
|
|
|
|
static bool sWheelEventsEnabledOnPlugins;
|
2012-08-12 05:42:34 +04:00
|
|
|
};
|
|
|
|
|
2012-08-12 05:42:35 +04: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 19:51:16 +04:00
|
|
|
struct MOZ_STACK_CLASS EventState
|
|
|
|
{
|
|
|
|
bool mDefaultPrevented;
|
|
|
|
bool mDefaultPreventedByContent;
|
|
|
|
|
|
|
|
EventState() :
|
|
|
|
mDefaultPrevented(false), mDefaultPreventedByContent(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-08-12 05:42:35 +04:00
|
|
|
/**
|
|
|
|
* SendLineScrollEvent() dispatches a DOMMouseScroll event for the
|
2013-10-16 13:37:36 +04:00
|
|
|
* WidgetWheelEvent. This method shouldn't be called for non-trusted
|
2012-08-12 05:42:35 +04: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 19:51:16 +04:00
|
|
|
* @param aState The event which should be set to the dispatching
|
|
|
|
* event. This also returns the dispatched event
|
|
|
|
* state.
|
2012-08-12 05:42:35 +04:00
|
|
|
* @param aDelta The delta value of the event.
|
|
|
|
* @param aDeltaDirection The X/Y direction of dispatching event.
|
|
|
|
*/
|
2009-04-02 23:34:31 +04:00
|
|
|
void SendLineScrollEvent(nsIFrame* aTargetFrame,
|
2014-04-01 08:09:23 +04:00
|
|
|
WidgetWheelEvent* aEvent,
|
2013-12-08 19:51:16 +04:00
|
|
|
EventState& aState,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aDelta,
|
2012-08-12 05:42:35 +04:00
|
|
|
DeltaDirection aDeltaDirection);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SendPixelScrollEvent() dispatches a MozMousePixelScroll event for the
|
2013-10-16 13:37:36 +04:00
|
|
|
* WidgetWheelEvent. This method shouldn't be called for non-trusted
|
2012-08-12 05:42:35 +04: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 19:51:16 +04:00
|
|
|
* @param aState The event which should be set to the dispatching
|
|
|
|
* event. This also returns the dispatched event
|
|
|
|
* state.
|
2012-08-12 05:42:35 +04:00
|
|
|
* @param aPixelDelta The delta value of the event.
|
|
|
|
* @param aDeltaDirection The X/Y direction of dispatching event.
|
|
|
|
*/
|
2008-09-17 15:27:19 +04:00
|
|
|
void SendPixelScrollEvent(nsIFrame* aTargetFrame,
|
2014-04-01 08:09:23 +04:00
|
|
|
WidgetWheelEvent* aEvent,
|
2013-12-08 19:51:16 +04:00
|
|
|
EventState& aState,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aPixelDelta,
|
2012-08-12 05:42:35 +04:00
|
|
|
DeltaDirection aDeltaDirection);
|
2012-08-12 05:42:34 +04: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 12:39:28 +04:00
|
|
|
* @param aOptions The options for finding the scroll target.
|
|
|
|
* Callers should use COMPUTE_*.
|
2012-08-12 05:42:34 +04:00
|
|
|
* @return The scrollable frame which should be scrolled.
|
|
|
|
*/
|
2012-09-04 12:39:28 +04:00
|
|
|
// These flags are used in ComputeScrollTarget(). Callers should use
|
|
|
|
// COMPUTE_*.
|
|
|
|
enum
|
|
|
|
{
|
2015-10-16 07:19:27 +03:00
|
|
|
PREFER_MOUSE_WHEEL_TRANSACTION = 0x00000001,
|
|
|
|
PREFER_ACTUAL_SCROLLABLE_TARGET_ALONG_X_AXIS = 0x00000002,
|
|
|
|
PREFER_ACTUAL_SCROLLABLE_TARGET_ALONG_Y_AXIS = 0x00000004,
|
|
|
|
START_FROM_PARENT = 0x00000008,
|
|
|
|
INCLUDE_PLUGIN_AS_TARGET = 0x00000010
|
2012-09-04 12:39:28 +04:00
|
|
|
};
|
|
|
|
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.
|
2016-02-26 03:41:59 +03:00
|
|
|
COMPUTE_DEFAULT_ACTION_TARGET_EXCEPT_PLUGIN =
|
|
|
|
(PREFER_MOUSE_WHEEL_TRANSACTION |
|
|
|
|
PREFER_ACTUAL_SCROLLABLE_TARGET_ALONG_X_AXIS |
|
|
|
|
PREFER_ACTUAL_SCROLLABLE_TARGET_ALONG_Y_AXIS),
|
2015-10-16 07:19:27 +03:00
|
|
|
// When this is specified, the result may be nsPluginFrame. In such case,
|
|
|
|
// the frame doesn't have nsIScrollableFrame interface.
|
2012-09-04 12:39:28 +04:00
|
|
|
COMPUTE_DEFAULT_ACTION_TARGET =
|
2016-02-26 03:41:59 +03:00
|
|
|
(COMPUTE_DEFAULT_ACTION_TARGET_EXCEPT_PLUGIN |
|
2015-10-16 07:19:27 +03:00
|
|
|
INCLUDE_PLUGIN_AS_TARGET),
|
2012-09-04 12:39:28 +04:00
|
|
|
// 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)
|
|
|
|
};
|
2016-02-26 03:41:59 +03:00
|
|
|
static ComputeScrollTargetOptions RemovePluginFromTarget(
|
|
|
|
ComputeScrollTargetOptions aOptions)
|
|
|
|
{
|
|
|
|
switch (aOptions) {
|
|
|
|
case COMPUTE_DEFAULT_ACTION_TARGET:
|
|
|
|
return COMPUTE_DEFAULT_ACTION_TARGET_EXCEPT_PLUGIN;
|
|
|
|
default:
|
|
|
|
MOZ_ASSERT(!(aOptions & INCLUDE_PLUGIN_AS_TARGET));
|
|
|
|
return aOptions;
|
|
|
|
}
|
|
|
|
}
|
2015-10-16 07:19:27 +03:00
|
|
|
nsIFrame* ComputeScrollTarget(nsIFrame* aTargetFrame,
|
|
|
|
WidgetWheelEvent* aEvent,
|
|
|
|
ComputeScrollTargetOptions aOptions);
|
|
|
|
|
|
|
|
nsIFrame* ComputeScrollTarget(nsIFrame* aTargetFrame,
|
|
|
|
double aDirectionX,
|
|
|
|
double aDirectionY,
|
|
|
|
WidgetWheelEvent* aEvent,
|
|
|
|
ComputeScrollTargetOptions aOptions);
|
2012-08-12 05:42:34 +04:00
|
|
|
|
|
|
|
/**
|
2012-08-12 05:42:35 +04: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-12 05:42:34 +04:00
|
|
|
*
|
|
|
|
* @param aScrollableFrame A frame which will be scrolled by the event.
|
|
|
|
* The result of ComputeScrollTarget() is
|
|
|
|
* expected for this value.
|
2013-04-03 05:14:24 +04:00
|
|
|
* This can be nullptr if there is no scrollable
|
2012-08-12 05:42:34 +04:00
|
|
|
* frame. Then, this method uses root frame's
|
2012-08-12 05:42:35 +04:00
|
|
|
* line height or visible area's width and height.
|
2012-08-12 05:42:34 +04:00
|
|
|
*/
|
2012-08-12 05:42:35 +04:00
|
|
|
nsSize GetScrollAmount(nsPresContext* aPresContext,
|
2014-04-01 08:09:23 +04:00
|
|
|
WidgetWheelEvent* aEvent,
|
2012-08-12 05:42:35 +04:00
|
|
|
nsIScrollableFrame* aScrollableFrame);
|
2012-08-12 05:42:34 +04:00
|
|
|
|
2011-05-17 04:23:23 +04:00
|
|
|
/**
|
2012-08-12 05:42:35 +04:00
|
|
|
* DoScrollText() scrolls the scrollable frame for aEvent.
|
2011-05-17 04:23:23 +04:00
|
|
|
*/
|
2012-08-12 05:42:35 +04:00
|
|
|
void DoScrollText(nsIScrollableFrame* aScrollableFrame,
|
2014-04-01 08:09:23 +04:00
|
|
|
WidgetWheelEvent* aEvent);
|
2012-08-12 05:42:35 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void DoScrollHistory(int32_t direction);
|
|
|
|
void DoScrollZoom(nsIFrame *aTargetFrame, int32_t adjustment);
|
2014-07-10 01:27:49 +04:00
|
|
|
nsresult GetContentViewer(nsIContentViewer** aCv);
|
2012-08-22 19:56:38 +04:00
|
|
|
nsresult ChangeTextSize(int32_t change);
|
|
|
|
nsresult ChangeFullZoom(int32_t change);
|
2012-08-12 05:42:35 +04:00
|
|
|
|
2012-08-12 05:42:35 +04:00
|
|
|
/**
|
2012-08-12 05:42:36 +04: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-12 05:42:35 +04:00
|
|
|
*/
|
2012-08-12 05:42:36 +04:00
|
|
|
class DeltaAccumulator
|
2012-08-12 05:42:35 +04:00
|
|
|
{
|
|
|
|
public:
|
2012-08-12 05:42:36 +04:00
|
|
|
static DeltaAccumulator* GetInstance()
|
2012-08-12 05:42:35 +04:00
|
|
|
{
|
|
|
|
if (!sInstance) {
|
2012-08-12 05:42:36 +04:00
|
|
|
sInstance = new DeltaAccumulator;
|
2012-08-12 05:42:35 +04:00
|
|
|
}
|
|
|
|
return sInstance;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void Shutdown()
|
|
|
|
{
|
|
|
|
delete sInstance;
|
|
|
|
sInstance = nullptr;
|
|
|
|
}
|
|
|
|
|
2012-09-28 10:57:33 +04:00
|
|
|
bool IsInTransaction() { return mHandlingDeltaMode != UINT32_MAX; }
|
2012-08-19 20:46:21 +04:00
|
|
|
|
2012-08-12 05:42:35 +04:00
|
|
|
/**
|
2013-10-16 13:37:36 +04:00
|
|
|
* InitLineOrPageDelta() stores pixel delta values of WidgetWheelEvents
|
|
|
|
* which are caused if it's needed. And if the accumulated delta becomes a
|
2012-08-12 05:42:36 +04:00
|
|
|
* line height, sets lineOrPageDeltaX and lineOrPageDeltaY automatically.
|
2012-08-12 05:42:35 +04:00
|
|
|
*/
|
2012-08-12 05:42:36 +04:00
|
|
|
void InitLineOrPageDelta(nsIFrame* aTargetFrame,
|
2014-04-01 08:09:23 +04:00
|
|
|
EventStateManager* aESM,
|
|
|
|
WidgetWheelEvent* aEvent);
|
2012-08-12 05:42:36 +04:00
|
|
|
|
2012-08-12 05:42:35 +04:00
|
|
|
/**
|
2012-08-19 20:46:21 +04:00
|
|
|
* Reset() resets all members.
|
2012-08-12 05:42:35 +04:00
|
|
|
*/
|
|
|
|
void Reset();
|
|
|
|
|
2012-08-19 20:46:21 +04:00
|
|
|
/**
|
|
|
|
* ComputeScrollAmountForDefaultAction() computes the default action's
|
|
|
|
* scroll amount in device pixels with mPendingScrollAmount*.
|
|
|
|
*/
|
|
|
|
nsIntPoint ComputeScrollAmountForDefaultAction(
|
2014-04-01 08:09:23 +04:00
|
|
|
WidgetWheelEvent* aEvent,
|
2012-08-19 20:46:21 +04:00
|
|
|
const nsIntSize& aScrollAmountInDevPixels);
|
|
|
|
|
2012-08-12 05:42:35 +04:00
|
|
|
private:
|
2012-08-12 05:42:36 +04:00
|
|
|
DeltaAccumulator() :
|
2012-08-19 20:46:21 +04:00
|
|
|
mX(0.0), mY(0.0), mPendingScrollAmountX(0.0), mPendingScrollAmountY(0.0),
|
2014-07-07 13:54:14 +04:00
|
|
|
mHandlingDeltaMode(UINT32_MAX), mIsNoLineOrPageDeltaDevice(false)
|
2012-08-12 05:42:35 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-12 05:42:36 +04:00
|
|
|
double mX;
|
|
|
|
double mY;
|
2012-08-19 20:46:21 +04: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-12 05:42:35 +04:00
|
|
|
TimeStamp mLastTime;
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mHandlingDeltaMode;
|
2014-07-07 13:54:14 +04:00
|
|
|
bool mIsNoLineOrPageDeltaDevice;
|
2012-08-12 05:42:36 +04:00
|
|
|
|
|
|
|
static DeltaAccumulator* sInstance;
|
2012-08-12 05:42:35 +04:00
|
|
|
};
|
|
|
|
|
2000-03-16 06:34:52 +03:00
|
|
|
// end mousewheel functions
|
1998-11-18 08:25:26 +03:00
|
|
|
|
2009-08-14 00:54:09 +04: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-04-01 08:09:23 +04:00
|
|
|
void DecideGestureEvent(WidgetGestureNotifyEvent* aEvent,
|
2013-09-27 10:20:57 +04:00
|
|
|
nsIFrame* targetFrame);
|
2009-08-14 00:54:09 +04:00
|
|
|
|
1999-08-19 23:48:45 +04:00
|
|
|
// routines for the d&d gesture tracking state machine
|
2013-10-02 10:38:27 +04:00
|
|
|
void BeginTrackingDragGesture(nsPresContext* aPresContext,
|
2014-04-01 08:09:23 +04:00
|
|
|
WidgetMouseEvent* aDownEvent,
|
2013-10-02 10:38:27 +04:00
|
|
|
nsIFrame* aDownFrame);
|
2015-04-08 21:48:11 +03:00
|
|
|
|
|
|
|
friend class mozilla::dom::TabParent;
|
|
|
|
void BeginTrackingRemoteDragGesture(nsIContent* aContent);
|
2013-10-02 10:38:27 +04:00
|
|
|
void StopTrackingDragGesture();
|
|
|
|
void GenerateDragGesture(nsPresContext* aPresContext,
|
2014-04-01 08:09:23 +04:00
|
|
|
WidgetMouseEvent* aEvent);
|
2008-08-27 16:07:27 +04: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 18:16:59 +04:00
|
|
|
* aSelection - [out] set to the selection to be dragged
|
2008-08-27 16:07:27 +04:00
|
|
|
* aTargetNode - [out] the draggable node, or null if there isn't one
|
|
|
|
*/
|
2016-01-30 20:05:36 +03:00
|
|
|
void DetermineDragTargetAndDefaultData(nsPIDOMWindowOuter* aWindow,
|
2015-04-08 21:48:11 +03:00
|
|
|
nsIContent* aSelectionTarget,
|
|
|
|
dom::DataTransfer* aDataTransfer,
|
|
|
|
nsISelection** aSelection,
|
|
|
|
nsIContent** aTargetNode);
|
2008-08-27 16:07:27 +04:00
|
|
|
|
|
|
|
/*
|
2016-05-27 22:43:17 +03:00
|
|
|
* Perform the default handling for the dragstart event and set up a
|
2009-11-09 17:55:53 +03:00
|
|
|
* drag for aDataTransfer if it contains any data. Returns true if a drag has
|
|
|
|
* started.
|
2008-08-27 16:07:27 +04:00
|
|
|
*
|
2016-05-27 22:43:17 +03:00
|
|
|
* aDragEvent - the dragstart event
|
2008-08-27 16:07:27 +04:00
|
|
|
* aDataTransfer - the data transfer that holds the data to be dragged
|
|
|
|
* aDragTarget - the target of the drag
|
2012-02-17 18:16:59 +04:00
|
|
|
* aSelection - the selection to be dragged
|
2008-08-27 16:07:27 +04:00
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool DoDefaultDragStart(nsPresContext* aPresContext,
|
2014-04-01 08:09:23 +04:00
|
|
|
WidgetDragEvent* aDragEvent,
|
|
|
|
dom::DataTransfer* aDataTransfer,
|
2013-10-01 11:23:02 +04:00
|
|
|
nsIContent* aDragTarget,
|
|
|
|
nsISelection* aSelection);
|
2008-08-27 16:07:27 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
bool IsTrackingDragGesture ( ) const { return mGestureDownContent != nullptr; }
|
2005-04-20 03:03:23 +04: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
|
2016-04-14 11:03:14 +03:00
|
|
|
* BeginTrackingDragGesture). aEvent->mWidget must be
|
2010-07-02 23:11:04 +04:00
|
|
|
* mCurrentTarget->GetNearestWidget().
|
2005-04-20 03:03:23 +04:00
|
|
|
*/
|
2014-04-01 08:09:23 +04:00
|
|
|
void FillInEventFromGestureDown(WidgetMouseEvent* aEvent);
|
1999-08-19 23:48:45 +04:00
|
|
|
|
2014-04-01 08:09:23 +04:00
|
|
|
nsresult DoContentCommandEvent(WidgetContentCommandEvent* aEvent);
|
|
|
|
nsresult DoContentCommandScrollEvent(WidgetContentCommandEvent* aEvent);
|
2009-08-07 19:11:17 +04:00
|
|
|
|
2014-04-01 08:09:23 +04:00
|
|
|
dom::TabParent *GetCrossProcessTarget();
|
|
|
|
bool IsTargetCrossProcess(WidgetGUIEvent* aEvent);
|
2010-08-17 12:07:44 +04:00
|
|
|
|
2014-04-01 08:09:23 +04:00
|
|
|
bool DispatchCrossProcessEvent(WidgetEvent* aEvent,
|
2013-10-02 07:46:04 +04:00
|
|
|
nsFrameLoader* aRemote,
|
2011-06-22 04:32:43 +04:00
|
|
|
nsEventStatus *aStatus);
|
2014-04-01 08:09:23 +04:00
|
|
|
bool HandleCrossProcessEvent(WidgetEvent* aEvent,
|
2013-10-02 07:46:04 +04:00
|
|
|
nsEventStatus* aStatus);
|
2011-06-22 04:32:43 +04:00
|
|
|
|
2014-04-24 04:36:15 +04:00
|
|
|
void ReleaseCurrentIMEContentObserver();
|
|
|
|
|
2015-09-08 06:54:14 +03:00
|
|
|
void HandleQueryContentEvent(WidgetQueryContentEvent* aEvent);
|
|
|
|
|
2011-06-01 05:46:56 +04:00
|
|
|
private:
|
2014-04-01 08:09:23 +04:00
|
|
|
static inline void DoStateChange(dom::Element* aElement,
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates aState, bool aAddState);
|
|
|
|
static inline void DoStateChange(nsIContent* aContent, EventStates aState,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aAddState);
|
2011-06-01 05:46:56 +04:00
|
|
|
static void UpdateAncestorState(nsIContent* aStartNode,
|
|
|
|
nsIContent* aStopBefore,
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates aState,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aAddState);
|
2016-01-29 01:08:19 +03:00
|
|
|
static void ResetLastOverForContent(const uint32_t& aIdx,
|
|
|
|
RefPtr<OverOutElementsWrapper>& aChunk,
|
|
|
|
nsIContent* aClosure);
|
2011-06-01 05:46:56 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mLockCursor;
|
2015-11-20 20:00:12 +03:00
|
|
|
bool mLastFrameConsumedSetCursor;
|
2004-04-30 03:34:19 +04:00
|
|
|
|
2016-04-18 17:09:02 +03:00
|
|
|
// Last mouse event mRefPoint (the offset from the widget's origin in
|
2012-06-21 03:38:11 +04:00
|
|
|
// device pixels) when mouse was locked, used to restore mouse position
|
|
|
|
// after unlocking.
|
2016-12-21 04:02:24 +03:00
|
|
|
static LayoutDeviceIntPoint sPreLockPoint;
|
2012-04-12 01:55:21 +04:00
|
|
|
|
2016-04-18 17:09:02 +03:00
|
|
|
// Stores the mRefPoint of the last synthetic mouse move we dispatched
|
2012-09-25 03:44:03 +04:00
|
|
|
// 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-04-01 08:09:23 +04:00
|
|
|
static LayoutDeviceIntPoint sSynthCenteringPoint;
|
2012-09-25 03:44:03 +04:00
|
|
|
|
2006-07-14 11:55:51 +04:00
|
|
|
nsWeakFrame mCurrentTarget;
|
2002-12-17 05:10:57 +03:00
|
|
|
nsCOMPtr<nsIContent> mCurrentTargetContent;
|
2011-09-27 00:55:04 +04:00
|
|
|
static nsWeakFrame sLastDragOverFrame;
|
2012-06-21 03:38:11 +04:00
|
|
|
|
2016-04-18 17:09:02 +03:00
|
|
|
// Stores the mRefPoint (the offset from the widget's origin in device
|
2012-06-21 03:38:11 +04:00
|
|
|
// pixels) of the last mouse event.
|
2014-04-01 08:09:23 +04:00
|
|
|
static LayoutDeviceIntPoint sLastRefPoint;
|
2001-02-15 08:07:46 +03:00
|
|
|
|
1999-08-19 23:48:45 +04:00
|
|
|
// member variables for the d&d gesture state machine
|
2014-04-01 08:09:23 +04:00
|
|
|
LayoutDeviceIntPoint mGestureDownPoint; // screen coordinates
|
2005-06-29 01:40:15 +04:00
|
|
|
// The content to use as target if we start a d&d (what we drag).
|
2005-03-30 06:14:41 +04:00
|
|
|
nsCOMPtr<nsIContent> mGestureDownContent;
|
2005-06-29 01:40:15 +04:00
|
|
|
// 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;
|
2005-04-20 03:03:23 +04:00
|
|
|
// State of keys when the original gesture-down happened
|
2014-04-01 08:09:23 +04:00
|
|
|
Modifiers mGestureModifiers;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t mGestureDownButtons;
|
1998-11-24 10:46:58 +03:00
|
|
|
|
2002-12-17 05:10:57 +03:00
|
|
|
nsCOMPtr<nsIContent> mLastLeftMouseDownContent;
|
2010-01-25 12:21:33 +03:00
|
|
|
nsCOMPtr<nsIContent> mLastLeftMouseDownContentParent;
|
2002-12-17 05:10:57 +03:00
|
|
|
nsCOMPtr<nsIContent> mLastMiddleMouseDownContent;
|
2010-01-25 12:21:33 +03:00
|
|
|
nsCOMPtr<nsIContent> mLastMiddleMouseDownContentParent;
|
2002-12-17 05:10:57 +03:00
|
|
|
nsCOMPtr<nsIContent> mLastRightMouseDownContent;
|
2010-01-25 12:21:33 +03:00
|
|
|
nsCOMPtr<nsIContent> mLastRightMouseDownContentParent;
|
1999-03-29 02:22:54 +04:00
|
|
|
|
2002-12-17 05:10:57 +03:00
|
|
|
nsCOMPtr<nsIContent> mActiveContent;
|
|
|
|
nsCOMPtr<nsIContent> mHoverContent;
|
2011-09-27 00:55:04 +04:00
|
|
|
static nsCOMPtr<nsIContent> sDragOverContent;
|
2003-01-14 02:10:53 +03:00
|
|
|
nsCOMPtr<nsIContent> mURLTargetContent;
|
2005-03-29 03:39:13 +04:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext* mPresContext; // Not refcnted
|
2002-12-17 05:10:57 +03:00
|
|
|
nsCOMPtr<nsIDocument> mDocument; // Doesn't necessarily need to be owner
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<IMEContentObserver> mIMEContentObserver;
|
2014-04-24 04:36:15 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mLClickCount;
|
|
|
|
uint32_t mMClickCount;
|
|
|
|
uint32_t mRClickCount;
|
1999-09-22 06:29:33 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool m_haveShutdown;
|
2002-12-24 23:21:40 +03:00
|
|
|
|
2015-12-04 04:40:45 +03:00
|
|
|
// Time at which we began handling user input. Reset to the epoch
|
|
|
|
// once we have finished handling user input.
|
2011-09-07 00:14:59 +04:00
|
|
|
static TimeStamp sHandlingInputStart;
|
2010-11-07 22:07:59 +03:00
|
|
|
|
2015-12-04 04:40:45 +03:00
|
|
|
// Time at which we began handling the latest user input. Not reset
|
|
|
|
// at the end of the input.
|
|
|
|
static TimeStamp sLatestUserInputStart;
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<OverOutElementsWrapper> mMouseEnterLeaveHelper;
|
2014-02-11 10:33:35 +04:00
|
|
|
nsRefPtrHashtable<nsUint32HashKey, OverOutElementsWrapper> mPointersEnterLeaveHelper;
|
|
|
|
|
2010-11-07 22:07:59 +03:00
|
|
|
public:
|
|
|
|
static nsresult UpdateUserActivityTimer(void);
|
2007-11-28 23:14:12 +03:00
|
|
|
// Array for accesskey support
|
|
|
|
nsCOMArray<nsIContent> mAccessKeys;
|
2002-02-01 08:14:44 +03:00
|
|
|
|
2015-12-04 04:40:45 +03:00
|
|
|
// The number of user inputs handled since process start. This
|
|
|
|
// includes anything that is initiated by user, with the exception
|
|
|
|
// of page load events or mouse over events.
|
|
|
|
static uint64_t sUserInputCounter;
|
|
|
|
|
|
|
|
// The current depth of user inputs. This includes anything that is
|
|
|
|
// initiated by user, with the exception of page load events or
|
|
|
|
// mouse over events. Incremented whenever we start handling a user
|
|
|
|
// input, decremented when we have finished handling a user
|
|
|
|
// input. This depth is *not* reset in case of nested event loops.
|
2012-08-22 19:56:38 +04:00
|
|
|
static int32_t sUserInputEventDepth;
|
2010-09-08 21:41:37 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool sNormalLMouseEventInProcess;
|
2001-03-30 08:45:40 +04:00
|
|
|
|
2014-04-01 08:09:23 +04:00
|
|
|
static EventStateManager* sActiveESM;
|
2010-09-16 17:10:18 +04:00
|
|
|
|
2014-04-01 08:09:23 +04:00
|
|
|
static void ClearGlobalActiveContent(EventStateManager* aClearer);
|
2010-09-16 17:10:18 +04:00
|
|
|
|
2010-06-16 11:36:11 +04:00
|
|
|
// Functions used for click hold context menus
|
|
|
|
nsCOMPtr<nsITimer> mClickHoldTimer;
|
2013-10-02 07:46:03 +04:00
|
|
|
void CreateClickHoldTimer(nsPresContext* aPresContext,
|
|
|
|
nsIFrame* aDownFrame,
|
2014-04-01 08:09:23 +04:00
|
|
|
WidgetGUIEvent* aMouseDownEvent);
|
2013-10-02 07:46:03 +04:00
|
|
|
void KillClickHoldTimer();
|
|
|
|
void FireContextClick();
|
2012-04-12 01:55:21 +04:00
|
|
|
|
2016-12-21 04:02:24 +03:00
|
|
|
static void SetPointerLock(nsIWidget* aWidget, nsIContent* aElement) ;
|
2001-03-30 08:45:40 +04:00
|
|
|
static void sClickHoldCallback ( nsITimer* aTimer, void* aESM ) ;
|
2004-09-04 23:28:46 +04:00
|
|
|
};
|
|
|
|
|
2009-09-13 17:13:16 +04: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 17:27:35 +04:00
|
|
|
class AutoHandlingUserInputStatePusher
|
2004-09-04 23:28:46 +04:00
|
|
|
{
|
|
|
|
public:
|
2013-10-22 17:27:35 +04:00
|
|
|
AutoHandlingUserInputStatePusher(bool aIsHandlingUserInput,
|
|
|
|
WidgetEvent* aEvent,
|
|
|
|
nsIDocument* aDocument);
|
|
|
|
~AutoHandlingUserInputStatePusher();
|
2004-09-04 23:28:46 +04:00
|
|
|
|
|
|
|
protected:
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mIsHandlingUserInput;
|
|
|
|
bool mIsMouseDown;
|
2014-06-18 10:13:00 +04:00
|
|
|
bool mResetFMMouseButtonHandlingState;
|
2004-09-04 23:28:46 +04:00
|
|
|
|
2014-06-18 10:13:01 +04:00
|
|
|
nsCOMPtr<nsIDocument> mMouseButtonEventHandlingDocument;
|
|
|
|
|
2004-09-04 23:28:46 +04:00
|
|
|
private:
|
2004-09-30 02:10:30 +04:00
|
|
|
// Hide so that this class can only be stack-allocated
|
2012-07-30 18:20:58 +04:00
|
|
|
static void* operator new(size_t /*size*/) CPP_THROW_NEW { return nullptr; }
|
2004-09-30 02:10:30 +04:00
|
|
|
static void operator delete(void* /*memory*/) {}
|
1998-06-24 01:53:02 +04:00
|
|
|
};
|
|
|
|
|
2013-10-22 17:27:35 +04:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2012-06-07 14:06:39 +04: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 14:04:16 +04:00
|
|
|
(!(event)->HasPluginActivationEventMessage() && \
|
2015-08-29 02:58:32 +03:00
|
|
|
(event)->mMessage != eMouseClick && \
|
2016-12-01 03:48:02 +03:00
|
|
|
(event)->mMessage != eMouseDoubleClick && \
|
|
|
|
(event)->mMessage != eMouseAuxClick)
|
2011-04-21 21:35:52 +04:00
|
|
|
|
2014-04-01 08:09:23 +04:00
|
|
|
#endif // mozilla_EventStateManager_h_
|