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"
|
2018-03-15 11:31:07 +03:00
|
|
|
#include "WheelHandlingHelper.h" // for WheelDeltaAdjustmentStrategy
|
2000-03-15 07:03:44 +03:00
|
|
|
|
2017-09-06 20:18:11 +03:00
|
|
|
#define NS_USER_INTERACTION_INTERVAL 5000 // ms
|
|
|
|
|
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-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)
|
|
|
|
|
2017-03-01 20:03:14 +03:00
|
|
|
WeakFrame mLastOverFrame;
|
2014-02-11 10:33:35 +04:00
|
|
|
|
|
|
|
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.
|
2018-03-29 19:22:59 +03:00
|
|
|
*
|
|
|
|
* aOverrideClickTarget can be used to indicate which element should be
|
|
|
|
* used as the *up target when deciding whether to send click event.
|
|
|
|
* This is used when releasing pointer capture. Otherwise null.
|
1999-12-04 05:22:21 +03:00
|
|
|
*/
|
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,
|
2018-03-29 19:22:59 +03:00
|
|
|
nsEventStatus* aStatus,
|
|
|
|
nsIContent* aOverrideClickTarget);
|
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,
|
2018-03-29 19:22:59 +03:00
|
|
|
nsEventStatus* aStatus,
|
|
|
|
nsIContent* aOverrideClickTarget);
|
1998-11-18 08:25:26 +03:00
|
|
|
|
2016-03-15 08:49:19 +03:00
|
|
|
void PostHandleKeyboardEvent(WidgetKeyboardEvent* aKeyboardEvent,
|
2017-03-21 10:44:12 +03:00
|
|
|
nsIFrame* aTargetFrame, nsEventStatus& aStatus);
|
2016-03-15 08:49:19 +03:00
|
|
|
|
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);
|
2017-09-08 06:01:22 +03:00
|
|
|
void ContentRemoved(nsIDocument* aDocument, nsIContent* aMaybeContainer,
|
|
|
|
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.
|
2017-06-29 14:46:11 +03:00
|
|
|
* Doesn't do anything in child processes where flushing happens
|
|
|
|
* asynchronously.
|
2015-11-10 05:49:05 +03:00
|
|
|
*/
|
|
|
|
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.
|
|
|
|
*
|
2017-12-07 21:13:50 +03:00
|
|
|
* @param aElement the given element
|
2011-04-21 21:35:52 +04:00
|
|
|
* @param aKey accesskey
|
|
|
|
*/
|
2017-12-07 21:13:50 +03:00
|
|
|
void RegisterAccessKey(dom::Element* aElement, uint32_t aKey);
|
2011-04-21 21:35:52 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Unregister accesskey for the given element.
|
|
|
|
*
|
2017-12-07 21:13:50 +03:00
|
|
|
* @param aElement the given element
|
2011-04-21 21:35:52 +04:00
|
|
|
* @param aKey accesskey
|
|
|
|
*/
|
2017-12-07 21:13:50 +03:00
|
|
|
void UnregisterAccessKey(dom::Element* aElement, uint32_t aKey);
|
2011-04-21 21:35:52 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get accesskey registered on the given element or 0 if there is none.
|
|
|
|
*
|
2017-12-07 21:13:50 +03:00
|
|
|
* @param aElement the given element (must not be null)
|
2011-04-21 21:35:52 +04:00
|
|
|
* @return registered accesskey
|
|
|
|
*/
|
2017-12-07 21:13:50 +03:00
|
|
|
uint32_t GetRegisteredAccessKey(dom::Element* 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
|
|
|
|
2017-07-20 11:33:53 +03:00
|
|
|
/**
|
|
|
|
* HandleAccessKey() looks for access keys which matches with aEvent and
|
|
|
|
* execute when it matches with a chrome access key or some content access
|
|
|
|
* keys.
|
|
|
|
* If the event may match chrome access keys, this handles the access key
|
|
|
|
* synchronously (if there are nested ESMs, their HandleAccessKey() are
|
|
|
|
* also called recursively).
|
|
|
|
* If the event may match content access keys and focused target is a remote
|
|
|
|
* process, this does nothing for the content because when this is called,
|
|
|
|
* it should already have been handled in the remote process.
|
|
|
|
* If the event may match content access keys and focused target is not in
|
|
|
|
* remote process but there are some remote children, this will post
|
|
|
|
* HandleAccessKey messages to all remote children.
|
|
|
|
*
|
|
|
|
* @return true if there is accesskey which aEvent and
|
|
|
|
* aAccessCharCodes match with. Otherwise, false.
|
|
|
|
* I.e., when this returns true, a target is executed
|
|
|
|
* or focused.
|
|
|
|
* Note that even if this returns false, a target in
|
|
|
|
* remote process may be executed or focused
|
|
|
|
* asynchronously.
|
|
|
|
*/
|
2016-05-11 15:56:42 +03:00
|
|
|
bool HandleAccessKey(WidgetKeyboardEvent* aEvent,
|
|
|
|
nsPresContext* aPresContext,
|
2017-07-06 11:36:19 +03:00
|
|
|
nsTArray<uint32_t>& aAccessCharCodes)
|
2015-09-18 15:18:07 +03:00
|
|
|
{
|
2017-07-20 11:33:53 +03:00
|
|
|
return WalkESMTreeToHandleAccessKey(aEvent, aPresContext, aAccessCharCodes,
|
|
|
|
nullptr, eAccessKeyProcessingNormal,
|
|
|
|
true);
|
2015-09-18 15:18:07 +03:00
|
|
|
}
|
|
|
|
|
2017-07-20 11:33:53 +03:00
|
|
|
/**
|
|
|
|
* CheckIfEventMatchesAccessKey() looks for access key which matches with
|
|
|
|
* aEvent in the process but won't execute it.
|
|
|
|
*
|
|
|
|
* @return true if there is accesskey which aEvent matches with
|
|
|
|
* in this process. Otherwise, false.
|
|
|
|
*/
|
|
|
|
bool CheckIfEventMatchesAccessKey(WidgetKeyboardEvent* aEvent,
|
|
|
|
nsPresContext* aPresContext);
|
|
|
|
|
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,
|
2017-07-06 15:00:35 +03:00
|
|
|
nsIWidget* aWidget, bool aLockCursor);
|
2000-04-24 08:41:27 +04:00
|
|
|
|
Bug 1406446 - part 1: InputContextAction should treat focus change during handling a user input as caused by user input even if it's caused by JS r=smaug
Currently, widget doesn't show VKB when input context change is caused by JS.
However, if it's caused by an event handler of a user input, user may expect
to open VKB. For example, if a touch event in fake editor causes moving
focus to actual editable node, user expect to show VKB.
Therefore, InputContextAction should declare two causes. One is unknown but
occurred during handling non-keyboard event. The other is unknown but occurred
during handling keyboard event.
However, EventStateManager doesn't have an API to check if it's being handling
a keyboard event. Therefore, this patch adds it first.
AutoHandlingUserInputStatePusher sends event type to StartHandlingUserInput()
and StopHandlingUserInput() of EventStateManager and sUserKeyboardEventDepth
manages the number of nested keyboard event handling. Therefore,
EventStateManager::IsHandlingKeyboardInput() can return if it's handling a
keyboard event.
IMEStateManager uses this new API to adjust the cause of changes of input
context.
Finally, InputContextAction::IsUserInput() is renamed to IsHandlingUserInput()
for consistency with EventStateManager and starts to return true when the
input context change is caused by script while it's handling a user input.
MozReview-Commit-ID: 5JsLqdqeGah
--HG--
extra : rebase_source : 9fcf7687d1bf90eeebbf6eac62d4488ff64b083c
2017-10-23 20:46:15 +03:00
|
|
|
/**
|
|
|
|
* StartHandlingUserInput() is called when we start to handle a user input.
|
|
|
|
* StopHandlingUserInput() is called when we finish handling a user input.
|
|
|
|
* If the caller knows which input event caused that, it should set
|
|
|
|
* aMessage to the event message. Otherwise, set eVoidEvent.
|
|
|
|
* Note that StopHandlingUserInput() caller should call it with exactly same
|
|
|
|
* event message as its corresponding StartHandlingUserInput() call because
|
|
|
|
* these methods may count the number of specific event message.
|
|
|
|
*/
|
|
|
|
static void StartHandlingUserInput(EventMessage aMessage);
|
|
|
|
static void StopHandlingUserInput(EventMessage aMessage);
|
2004-09-04 23:28:46 +04:00
|
|
|
|
2017-05-08 19:03:42 +03:00
|
|
|
static TimeStamp GetHandlingInputStart() {
|
|
|
|
return sHandlingInputStart;
|
|
|
|
}
|
|
|
|
|
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
|
Bug 1406446 - part 1: InputContextAction should treat focus change during handling a user input as caused by user input even if it's caused by JS r=smaug
Currently, widget doesn't show VKB when input context change is caused by JS.
However, if it's caused by an event handler of a user input, user may expect
to open VKB. For example, if a touch event in fake editor causes moving
focus to actual editable node, user expect to show VKB.
Therefore, InputContextAction should declare two causes. One is unknown but
occurred during handling non-keyboard event. The other is unknown but occurred
during handling keyboard event.
However, EventStateManager doesn't have an API to check if it's being handling
a keyboard event. Therefore, this patch adds it first.
AutoHandlingUserInputStatePusher sends event type to StartHandlingUserInput()
and StopHandlingUserInput() of EventStateManager and sUserKeyboardEventDepth
manages the number of nested keyboard event handling. Therefore,
EventStateManager::IsHandlingKeyboardInput() can return if it's handling a
keyboard event.
IMEStateManager uses this new API to adjust the cause of changes of input
context.
Finally, InputContextAction::IsUserInput() is renamed to IsHandlingUserInput()
for consistency with EventStateManager and starts to return true when the
input context change is caused by script while it's handling a user input.
MozReview-Commit-ID: 5JsLqdqeGah
--HG--
extra : rebase_source : 9fcf7687d1bf90eeebbf6eac62d4488ff64b083c
2017-10-23 20:46:15 +03:00
|
|
|
* user input or keyboard input. The former includes anything that is
|
|
|
|
* initiated by user, with the exception of page load events or mouse
|
|
|
|
* over events. And the latter returns true when one of the user inputs
|
|
|
|
* is an input from keyboard. If these methods are called from asynchronously
|
|
|
|
* executed code, such as during layout reflows, it will return false.
|
2012-11-21 09:25:20 +04:00
|
|
|
*/
|
2013-01-23 23:39:34 +04:00
|
|
|
static bool IsHandlingUserInput();
|
Bug 1406446 - part 1: InputContextAction should treat focus change during handling a user input as caused by user input even if it's caused by JS r=smaug
Currently, widget doesn't show VKB when input context change is caused by JS.
However, if it's caused by an event handler of a user input, user may expect
to open VKB. For example, if a touch event in fake editor causes moving
focus to actual editable node, user expect to show VKB.
Therefore, InputContextAction should declare two causes. One is unknown but
occurred during handling non-keyboard event. The other is unknown but occurred
during handling keyboard event.
However, EventStateManager doesn't have an API to check if it's being handling
a keyboard event. Therefore, this patch adds it first.
AutoHandlingUserInputStatePusher sends event type to StartHandlingUserInput()
and StopHandlingUserInput() of EventStateManager and sUserKeyboardEventDepth
manages the number of nested keyboard event handling. Therefore,
EventStateManager::IsHandlingKeyboardInput() can return if it's handling a
keyboard event.
IMEStateManager uses this new API to adjust the cause of changes of input
context.
Finally, InputContextAction::IsUserInput() is renamed to IsHandlingUserInput()
for consistency with EventStateManager and starts to return true when the
input context change is caused by script while it's handling a user input.
MozReview-Commit-ID: 5JsLqdqeGah
--HG--
extra : rebase_source : 9fcf7687d1bf90eeebbf6eac62d4488ff64b083c
2017-10-23 20:46:15 +03:00
|
|
|
static bool IsHandlingKeyboardInput();
|
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.
|
Bug 143038 Make users can scroll contents horizontally with vertical wheel operation with a modifier r=smaug
This patch declares a new default action, "horizontal scroll", this scrolls
content horizontally with deltaY of wheel events and ignores deltaX and deltaZ.
This is used for default action with Shift key in default setting except on
macOS. On macOS, legacy mouse's vertical wheel operation with Shift key causes
native horizontal wheel event. Therefore, we don't need to use this new
default action on macOS. Additionally, old default action with Shift key,
navigating history, is moved to with Alt key. This makes same settings between
macOS and the others. So, this is better for users who use macOS and another
OS and web app developers who check wheel events only on macOS or other
platform(s).
For simpler implementation, default action handlers moves deltaY values to
deltaX values temporarily *only* while they handle wheel events. This is
performed by AutoWheelDeltaAdjuster and restored after handling it
automatically.
So, in other words, even if default action is "horizontal scroll", web apps
receives wheel events whose deltaY is not zero but its content will be
scrolled horizontally. This is same as Chromium, so, this behavior shouldn't
cause any incompatible behavior with it.
MozReview-Commit-ID: E4X3yZzLEAl
--HG--
extra : rebase_source : e20d854c6b0a181ad4c9e7304bd9ad14256481ff
2017-10-04 19:12:35 +03:00
|
|
|
static bool WheelEventIsScrollAction(const WidgetWheelEvent* aEvent);
|
|
|
|
|
2018-03-15 11:31:07 +03:00
|
|
|
// For some kinds of scrollings, the delta values of WidgetWheelEvent are
|
|
|
|
// possbile to be adjusted. This function is used to detect such scrollings
|
|
|
|
// and returns a wheel delta adjustment strategy to use, which is corresponded
|
|
|
|
// to the kind of the scrolling.
|
2018-03-15 16:57:19 +03:00
|
|
|
// It returns WheelDeltaAdjustmentStrategy::eAutoDir if the current default
|
|
|
|
// action is auto-dir scrolling which honours the scrolling target(The
|
|
|
|
// comments in WheelDeltaAdjustmentStrategy describes the concept in detail).
|
|
|
|
// It returns WheelDeltaAdjustmentStrategy::eAutoDirWithRootHonour if the
|
|
|
|
// current action is auto-dir scrolling which honours the root element in the
|
|
|
|
// document where the scrolling target is(The comments in
|
|
|
|
// WheelDeltaAdjustmentStrategy describes the concept in detail).
|
2018-03-15 11:31:07 +03:00
|
|
|
// It returns WheelDeltaAdjustmentStrategy::eHorizontalize if the current
|
|
|
|
// default action is horizontalized scrolling.
|
|
|
|
// It returns WheelDeltaAdjustmentStrategy::eNone to mean no delta adjustment
|
|
|
|
// strategy should be used if the scrolling is just a tranditional scrolling
|
|
|
|
// whose delta values are never possible to be adjusted.
|
|
|
|
static WheelDeltaAdjustmentStrategy
|
|
|
|
GetWheelDeltaAdjustmentStrategy(const WidgetWheelEvent& aEvent);
|
2015-02-02 22:28:19 +03:00
|
|
|
|
2015-12-02 00:46:07 +03:00
|
|
|
// Returns user-set multipliers for a wheel event.
|
Bug 143038 Make users can scroll contents horizontally with vertical wheel operation with a modifier r=smaug
This patch declares a new default action, "horizontal scroll", this scrolls
content horizontally with deltaY of wheel events and ignores deltaX and deltaZ.
This is used for default action with Shift key in default setting except on
macOS. On macOS, legacy mouse's vertical wheel operation with Shift key causes
native horizontal wheel event. Therefore, we don't need to use this new
default action on macOS. Additionally, old default action with Shift key,
navigating history, is moved to with Alt key. This makes same settings between
macOS and the others. So, this is better for users who use macOS and another
OS and web app developers who check wheel events only on macOS or other
platform(s).
For simpler implementation, default action handlers moves deltaY values to
deltaX values temporarily *only* while they handle wheel events. This is
performed by AutoWheelDeltaAdjuster and restored after handling it
automatically.
So, in other words, even if default action is "horizontal scroll", web apps
receives wheel events whose deltaY is not zero but its content will be
scrolled horizontally. This is same as Chromium, so, this behavior shouldn't
cause any incompatible behavior with it.
MozReview-Commit-ID: E4X3yZzLEAl
--HG--
extra : rebase_source : e20d854c6b0a181ad4c9e7304bd9ad14256481ff
2017-10-04 19:12:35 +03:00
|
|
|
static void GetUserPrefsForWheelEvent(const WidgetWheelEvent* aEvent,
|
2015-12-02 00:46:07 +03:00
|
|
|
double* aOutMultiplierX,
|
|
|
|
double* aOutMultiplierY);
|
2015-03-25 00:58:49 +03:00
|
|
|
|
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; }
|
|
|
|
|
|
|
|
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 GetAccessModifierMask(int32_t aItemType);
|
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,
|
2017-03-01 20:03:14 +03:00
|
|
|
AutoWeakFrame& 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,
|
2017-03-01 20:03:14 +03:00
|
|
|
AutoWeakFrame aCurrentTarget,
|
2018-03-29 19:22:59 +03:00
|
|
|
bool aNoContentDispatch,
|
|
|
|
nsIContent* aOverrideClickTarget);
|
|
|
|
nsresult SetClickCount(WidgetMouseEvent* aEvent, nsEventStatus* aStatus,
|
|
|
|
nsIContent* aOverrideClickTarget = nullptr);
|
2015-12-07 04:15:53 +03:00
|
|
|
nsresult CheckForAndDispatchClick(WidgetMouseEvent* aEvent,
|
2018-03-29 19:22:59 +03:00
|
|
|
nsEventStatus* aStatus,
|
|
|
|
nsIContent* aOverrideClickTarget);
|
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
|
|
|
/**
|
2017-07-20 11:33:53 +03:00
|
|
|
* The phases of WalkESMTreeToHandleAccessKey processing. See below.
|
2007-05-18 07:49:14 +04:00
|
|
|
*/
|
2002-09-03 09:48:06 +04:00
|
|
|
typedef enum {
|
|
|
|
eAccessKeyProcessingNormal = 0,
|
|
|
|
eAccessKeyProcessingUp,
|
|
|
|
eAccessKeyProcessingDown
|
|
|
|
} ProcessingAccessKeyState;
|
2007-05-18 07:49:14 +04:00
|
|
|
|
|
|
|
/**
|
2017-07-20 11:33:53 +03:00
|
|
|
* Walk EMS to look for access key and execute found access key when aExecute
|
|
|
|
* is true.
|
|
|
|
* If there is registered content for the accesskey given by the key event
|
|
|
|
* and modifier mask then call content.PerformAccesskey(), otherwise call
|
|
|
|
* WalkESMTreeToHandleAccessKey() recursively, on descendant docshells first,
|
|
|
|
* then on the ancestor (with |aBubbledFrom| set to the docshell associated
|
|
|
|
* with |this|), until something matches.
|
2007-05-18 07:49:14 +04:00
|
|
|
*
|
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
|
2017-07-20 11:33:53 +03:00
|
|
|
* @param aBubbledFrom is used by an ancestor to avoid calling
|
|
|
|
* WalkESMTreeToHandleAccessKey() on the child the call originally
|
|
|
|
* came from, i.e. this is the child that recursively called us in
|
|
|
|
* its Up phase. The initial caller 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.
|
2017-07-20 11:33:53 +03:00
|
|
|
* @param aExecute is true, execute an accesskey if it's found. Otherwise,
|
|
|
|
* found accesskey won't be executed.
|
|
|
|
*
|
|
|
|
* @return true if there is a target which aEvent and
|
|
|
|
* aAccessCharCodes match with in this process.
|
|
|
|
* Otherwise, false. I.e., when this returns true and
|
|
|
|
* aExecute is true, a target is executed or focused.
|
|
|
|
* Note that even if this returns false, a target in
|
|
|
|
* remote process may be executed or focused
|
|
|
|
* asynchronously.
|
2007-05-18 07:49:14 +04:00
|
|
|
*/
|
2017-07-20 11:33:53 +03:00
|
|
|
bool WalkESMTreeToHandleAccessKey(WidgetKeyboardEvent* aEvent,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
nsTArray<uint32_t>& aAccessCharCodes,
|
|
|
|
nsIDocShellTreeItem* aBubbledFrom,
|
|
|
|
ProcessingAccessKeyState aAccessKeyState,
|
|
|
|
bool aExecute);
|
2002-09-03 09:48:06 +04:00
|
|
|
|
2017-07-20 11:33:53 +03:00
|
|
|
/**
|
|
|
|
* Look for access key and execute found access key if aExecute is true in
|
|
|
|
* the instance.
|
|
|
|
*
|
|
|
|
* @return true if there is a target which matches with
|
|
|
|
* aAccessCharCodes and aIsTrustedEvent. Otherwise,
|
|
|
|
* false. I.e., when this returns true and aExecute
|
|
|
|
* is true, a target is executed or focused.
|
|
|
|
*/
|
|
|
|
bool LookForAccessKeyAndExecute(nsTArray<uint32_t>& aAccessCharCodes,
|
|
|
|
bool aIsTrustedEvent,
|
|
|
|
bool aExecute);
|
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.
|
|
|
|
*/
|
Bug 143038 Make users can scroll contents horizontally with vertical wheel operation with a modifier r=smaug
This patch declares a new default action, "horizontal scroll", this scrolls
content horizontally with deltaY of wheel events and ignores deltaX and deltaZ.
This is used for default action with Shift key in default setting except on
macOS. On macOS, legacy mouse's vertical wheel operation with Shift key causes
native horizontal wheel event. Therefore, we don't need to use this new
default action on macOS. Additionally, old default action with Shift key,
navigating history, is moved to with Alt key. This makes same settings between
macOS and the others. So, this is better for users who use macOS and another
OS and web app developers who check wheel events only on macOS or other
platform(s).
For simpler implementation, default action handlers moves deltaY values to
deltaX values temporarily *only* while they handle wheel events. This is
performed by AutoWheelDeltaAdjuster and restored after handling it
automatically.
So, in other words, even if default action is "horizontal scroll", web apps
receives wheel events whose deltaY is not zero but its content will be
scrolled horizontally. This is same as Chromium, so, this behavior shouldn't
cause any incompatible behavior with it.
MozReview-Commit-ID: E4X3yZzLEAl
--HG--
extra : rebase_source : e20d854c6b0a181ad4c9e7304bd9ad14256481ff
2017-10-04 19:12:35 +03:00
|
|
|
void GetUserPrefsForEvent(const WidgetWheelEvent* aEvent,
|
2015-12-02 00:46:07 +03:00
|
|
|
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,
|
2018-03-15 11:31:07 +03:00
|
|
|
// Horizontalized scrolling means treating vertical wheel scrolling as
|
|
|
|
// horizontal scrolling during the process of its default action and
|
|
|
|
// plugins handling scrolling. Note that delta values as the event object
|
|
|
|
// in a DOM event listener won't be affected, and will be still the
|
|
|
|
// original values. For more details, refer to
|
|
|
|
// mozilla::WheelDeltaAdjustmentStrategy::eHorizontalize
|
|
|
|
ACTION_HORIZONTALIZED_SCROLL,
|
|
|
|
ACTION_LAST = ACTION_HORIZONTALIZED_SCROLL,
|
2015-10-16 07:19:27 +03:00
|
|
|
// Following actions are used only by internal processing. So, cannot
|
|
|
|
// specified by prefs.
|
Bug 143038 Make users can scroll contents horizontally with vertical wheel operation with a modifier r=smaug
This patch declares a new default action, "horizontal scroll", this scrolls
content horizontally with deltaY of wheel events and ignores deltaX and deltaZ.
This is used for default action with Shift key in default setting except on
macOS. On macOS, legacy mouse's vertical wheel operation with Shift key causes
native horizontal wheel event. Therefore, we don't need to use this new
default action on macOS. Additionally, old default action with Shift key,
navigating history, is moved to with Alt key. This makes same settings between
macOS and the others. So, this is better for users who use macOS and another
OS and web app developers who check wheel events only on macOS or other
platform(s).
For simpler implementation, default action handlers moves deltaY values to
deltaX values temporarily *only* while they handle wheel events. This is
performed by AutoWheelDeltaAdjuster and restored after handling it
automatically.
So, in other words, even if default action is "horizontal scroll", web apps
receives wheel events whose deltaY is not zero but its content will be
scrolled horizontally. This is same as Chromium, so, this behavior shouldn't
cause any incompatible behavior with it.
MozReview-Commit-ID: E4X3yZzLEAl
--HG--
extra : rebase_source : e20d854c6b0a181ad4c9e7304bd9ad14256481ff
2017-10-04 19:12:35 +03:00
|
|
|
ACTION_SEND_TO_PLUGIN,
|
2012-08-12 05:42:35 +04:00
|
|
|
};
|
Bug 143038 Make users can scroll contents horizontally with vertical wheel operation with a modifier r=smaug
This patch declares a new default action, "horizontal scroll", this scrolls
content horizontally with deltaY of wheel events and ignores deltaX and deltaZ.
This is used for default action with Shift key in default setting except on
macOS. On macOS, legacy mouse's vertical wheel operation with Shift key causes
native horizontal wheel event. Therefore, we don't need to use this new
default action on macOS. Additionally, old default action with Shift key,
navigating history, is moved to with Alt key. This makes same settings between
macOS and the others. So, this is better for users who use macOS and another
OS and web app developers who check wheel events only on macOS or other
platform(s).
For simpler implementation, default action handlers moves deltaY values to
deltaX values temporarily *only* while they handle wheel events. This is
performed by AutoWheelDeltaAdjuster and restored after handling it
automatically.
So, in other words, even if default action is "horizontal scroll", web apps
receives wheel events whose deltaY is not zero but its content will be
scrolled horizontally. This is same as Chromium, so, this behavior shouldn't
cause any incompatible behavior with it.
MozReview-Commit-ID: E4X3yZzLEAl
--HG--
extra : rebase_source : e20d854c6b0a181ad4c9e7304bd9ad14256481ff
2017-10-04 19:12:35 +03:00
|
|
|
Action ComputeActionFor(const 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.
|
|
|
|
*/
|
Bug 143038 Make users can scroll contents horizontally with vertical wheel operation with a modifier r=smaug
This patch declares a new default action, "horizontal scroll", this scrolls
content horizontally with deltaY of wheel events and ignores deltaX and deltaZ.
This is used for default action with Shift key in default setting except on
macOS. On macOS, legacy mouse's vertical wheel operation with Shift key causes
native horizontal wheel event. Therefore, we don't need to use this new
default action on macOS. Additionally, old default action with Shift key,
navigating history, is moved to with Alt key. This makes same settings between
macOS and the others. So, this is better for users who use macOS and another
OS and web app developers who check wheel events only on macOS or other
platform(s).
For simpler implementation, default action handlers moves deltaY values to
deltaX values temporarily *only* while they handle wheel events. This is
performed by AutoWheelDeltaAdjuster and restored after handling it
automatically.
So, in other words, even if default action is "horizontal scroll", web apps
receives wheel events whose deltaY is not zero but its content will be
scrolled horizontally. This is same as Chromium, so, this behavior shouldn't
cause any incompatible behavior with it.
MozReview-Commit-ID: E4X3yZzLEAl
--HG--
extra : rebase_source : e20d854c6b0a181ad4c9e7304bd9ad14256481ff
2017-10-04 19:12:35 +03:00
|
|
|
bool NeedToComputeLineOrPageDelta(const 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).
|
|
|
|
*/
|
Bug 143038 Make users can scroll contents horizontally with vertical wheel operation with a modifier r=smaug
This patch declares a new default action, "horizontal scroll", this scrolls
content horizontally with deltaY of wheel events and ignores deltaX and deltaZ.
This is used for default action with Shift key in default setting except on
macOS. On macOS, legacy mouse's vertical wheel operation with Shift key causes
native horizontal wheel event. Therefore, we don't need to use this new
default action on macOS. Additionally, old default action with Shift key,
navigating history, is moved to with Alt key. This makes same settings between
macOS and the others. So, this is better for users who use macOS and another
OS and web app developers who check wheel events only on macOS or other
platform(s).
For simpler implementation, default action handlers moves deltaY values to
deltaX values temporarily *only* while they handle wheel events. This is
performed by AutoWheelDeltaAdjuster and restored after handling it
automatically.
So, in other words, even if default action is "horizontal scroll", web apps
receives wheel events whose deltaY is not zero but its content will be
scrolled horizontally. This is same as Chromium, so, this behavior shouldn't
cause any incompatible behavior with it.
MozReview-Commit-ID: E4X3yZzLEAl
--HG--
extra : rebase_source : e20d854c6b0a181ad4c9e7304bd9ad14256481ff
2017-10-04 19:12:35 +03:00
|
|
|
bool IsOverOnePageScrollAllowedX(const WidgetWheelEvent* aEvent);
|
|
|
|
bool IsOverOnePageScrollAllowedY(const 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();
|
|
|
|
|
2018-03-15 16:57:19 +03:00
|
|
|
/**
|
|
|
|
* Returns whether the auto-dir feature is enabled for wheel scrolling. For
|
|
|
|
* detailed information on auto-dir,
|
|
|
|
* @see mozilla::WheelDeltaAdjustmentStrategy.
|
|
|
|
*/
|
|
|
|
static bool IsAutoDirEnabled();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether auto-dir scrolling honours root elements instead of the
|
|
|
|
* scrolling targets. For detailed information on auto-dir,
|
|
|
|
* @see mozilla::WheelDeltaAdjustmentStrategy.
|
|
|
|
*/
|
|
|
|
static bool HonoursRootForAutoDir();
|
|
|
|
|
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.
|
|
|
|
*/
|
Bug 143038 Make users can scroll contents horizontally with vertical wheel operation with a modifier r=smaug
This patch declares a new default action, "horizontal scroll", this scrolls
content horizontally with deltaY of wheel events and ignores deltaX and deltaZ.
This is used for default action with Shift key in default setting except on
macOS. On macOS, legacy mouse's vertical wheel operation with Shift key causes
native horizontal wheel event. Therefore, we don't need to use this new
default action on macOS. Additionally, old default action with Shift key,
navigating history, is moved to with Alt key. This makes same settings between
macOS and the others. So, this is better for users who use macOS and another
OS and web app developers who check wheel events only on macOS or other
platform(s).
For simpler implementation, default action handlers moves deltaY values to
deltaX values temporarily *only* while they handle wheel events. This is
performed by AutoWheelDeltaAdjuster and restored after handling it
automatically.
So, in other words, even if default action is "horizontal scroll", web apps
receives wheel events whose deltaY is not zero but its content will be
scrolled horizontally. This is same as Chromium, so, this behavior shouldn't
cause any incompatible behavior with it.
MozReview-Commit-ID: E4X3yZzLEAl
--HG--
extra : rebase_source : e20d854c6b0a181ad4c9e7304bd9ad14256481ff
2017-10-04 19:12:35 +03:00
|
|
|
Index GetIndexFor(const 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();
|
|
|
|
|
Bug 143038 Make users can scroll contents horizontally with vertical wheel operation with a modifier r=smaug
This patch declares a new default action, "horizontal scroll", this scrolls
content horizontally with deltaY of wheel events and ignores deltaX and deltaZ.
This is used for default action with Shift key in default setting except on
macOS. On macOS, legacy mouse's vertical wheel operation with Shift key causes
native horizontal wheel event. Therefore, we don't need to use this new
default action on macOS. Additionally, old default action with Shift key,
navigating history, is moved to with Alt key. This makes same settings between
macOS and the others. So, this is better for users who use macOS and another
OS and web app developers who check wheel events only on macOS or other
platform(s).
For simpler implementation, default action handlers moves deltaY values to
deltaX values temporarily *only* while they handle wheel events. This is
performed by AutoWheelDeltaAdjuster and restored after handling it
automatically.
So, in other words, even if default action is "horizontal scroll", web apps
receives wheel events whose deltaY is not zero but its content will be
scrolled horizontally. This is same as Chromium, so, this behavior shouldn't
cause any incompatible behavior with it.
MozReview-Commit-ID: E4X3yZzLEAl
--HG--
extra : rebase_source : e20d854c6b0a181ad4c9e7304bd9ad14256481ff
2017-10-04 19:12:35 +03:00
|
|
|
/**
|
|
|
|
* Retrieve multiplier for aEvent->mDeltaX and aEvent->mDeltaY.
|
2018-03-15 11:31:07 +03:00
|
|
|
*
|
|
|
|
* Note that if the default action is ACTION_HORIZONTALIZED_SCROLL and the
|
|
|
|
* delta values have been adjusted by WheelDeltaHorizontalizer() before this
|
|
|
|
* function is called, this function will swap the X and Y multipliers. By
|
|
|
|
* doing this, multipliers will still apply to the delta values they
|
|
|
|
* originally corresponded to.
|
Bug 143038 Make users can scroll contents horizontally with vertical wheel operation with a modifier r=smaug
This patch declares a new default action, "horizontal scroll", this scrolls
content horizontally with deltaY of wheel events and ignores deltaX and deltaZ.
This is used for default action with Shift key in default setting except on
macOS. On macOS, legacy mouse's vertical wheel operation with Shift key causes
native horizontal wheel event. Therefore, we don't need to use this new
default action on macOS. Additionally, old default action with Shift key,
navigating history, is moved to with Alt key. This makes same settings between
macOS and the others. So, this is better for users who use macOS and another
OS and web app developers who check wheel events only on macOS or other
platform(s).
For simpler implementation, default action handlers moves deltaY values to
deltaX values temporarily *only* while they handle wheel events. This is
performed by AutoWheelDeltaAdjuster and restored after handling it
automatically.
So, in other words, even if default action is "horizontal scroll", web apps
receives wheel events whose deltaY is not zero but its content will be
scrolled horizontally. This is same as Chromium, so, this behavior shouldn't
cause any incompatible behavior with it.
MozReview-Commit-ID: E4X3yZzLEAl
--HG--
extra : rebase_source : e20d854c6b0a181ad4c9e7304bd9ad14256481ff
2017-10-04 19:12:35 +03:00
|
|
|
*
|
|
|
|
* @param aEvent The event which is being handled.
|
|
|
|
* @param aIndex The index of mMultiplierX and mMultiplierY.
|
|
|
|
* Should be result of GetIndexFor(aEvent).
|
|
|
|
* @param aMultiplierForDeltaX Will be set to multiplier for
|
|
|
|
* aEvent->mDeltaX.
|
|
|
|
* @param aMultiplierForDeltaY Will be set to multiplier for
|
|
|
|
* aEvent->mDeltaY.
|
|
|
|
*/
|
|
|
|
void GetMultiplierForDeltaXAndY(const WidgetWheelEvent* aEvent,
|
|
|
|
Index aIndex,
|
|
|
|
double* aMultiplierForDeltaX,
|
|
|
|
double* aMultiplierForDeltaY);
|
|
|
|
|
2012-08-12 05:42:34 +04:00
|
|
|
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;
|
2018-03-15 16:57:19 +03:00
|
|
|
static bool sIsAutoDirEnabled;
|
|
|
|
static bool sHonoursRootForAutoDir;
|
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
|
|
|
|
|
|
|
/**
|
2018-03-19 12:05:45 +03:00
|
|
|
* ComputeScrollTargetAndMayAdjustWheelEvent() returns the scrollable frame
|
|
|
|
* which should be scrolled.
|
2012-08-12 05:42:34 +04:00
|
|
|
*
|
|
|
|
* @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.
|
|
|
|
*/
|
2018-03-19 12:05:45 +03:00
|
|
|
// These flags are used in ComputeScrollTargetAndMayAdjustWheelEvent().
|
|
|
|
// Callers should use COMPUTE_*.
|
2012-09-04 12:39:28 +04:00
|
|
|
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,
|
2018-03-19 12:05:45 +03:00
|
|
|
INCLUDE_PLUGIN_AS_TARGET = 0x00000010,
|
|
|
|
// Indicates the wheel scroll event being computed is an auto-dir scroll, so
|
|
|
|
// its delta may be adjusted after being computed.
|
|
|
|
MAY_BE_ADJUSTED_BY_AUTO_DIR = 0x00000020,
|
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),
|
2018-03-19 12:05:45 +03:00
|
|
|
COMPUTE_DEFAULT_ACTION_TARGET_WITH_AUTO_DIR_EXCEPT_PLUGIN =
|
|
|
|
(COMPUTE_DEFAULT_ACTION_TARGET_EXCEPT_PLUGIN |
|
|
|
|
MAY_BE_ADJUSTED_BY_AUTO_DIR),
|
|
|
|
COMPUTE_DEFAULT_ACTION_TARGET_WITH_AUTO_DIR =
|
|
|
|
(COMPUTE_DEFAULT_ACTION_TARGET |
|
|
|
|
MAY_BE_ADJUSTED_BY_AUTO_DIR),
|
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 =
|
2018-03-19 12:05:45 +03:00
|
|
|
(PREFER_ACTUAL_SCROLLABLE_TARGET_ALONG_Y_AXIS | START_FROM_PARENT),
|
|
|
|
COMPUTE_SCROLLABLE_ANCESTOR_ALONG_X_AXIS_WITH_AUTO_DIR =
|
|
|
|
(COMPUTE_SCROLLABLE_ANCESTOR_ALONG_X_AXIS | MAY_BE_ADJUSTED_BY_AUTO_DIR),
|
|
|
|
COMPUTE_SCROLLABLE_ANCESTOR_ALONG_Y_AXIS_WITH_AUTO_DIR =
|
|
|
|
(COMPUTE_SCROLLABLE_ANCESTOR_ALONG_Y_AXIS | MAY_BE_ADJUSTED_BY_AUTO_DIR),
|
2012-09-04 12:39:28 +04:00
|
|
|
};
|
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;
|
2018-03-19 12:05:45 +03:00
|
|
|
case COMPUTE_DEFAULT_ACTION_TARGET_WITH_AUTO_DIR:
|
|
|
|
return COMPUTE_DEFAULT_ACTION_TARGET_WITH_AUTO_DIR_EXCEPT_PLUGIN;
|
2016-02-26 03:41:59 +03:00
|
|
|
default:
|
|
|
|
MOZ_ASSERT(!(aOptions & INCLUDE_PLUGIN_AS_TARGET));
|
|
|
|
return aOptions;
|
|
|
|
}
|
|
|
|
}
|
2018-03-19 12:05:45 +03:00
|
|
|
|
|
|
|
// Compute the scroll target.
|
|
|
|
// The delta values in the wheel event may be changed if the event is for
|
|
|
|
// auto-dir scrolling. For information on auto-dir,
|
|
|
|
// @see mozilla::WheelDeltaAdjustmentStrategy
|
|
|
|
nsIFrame* ComputeScrollTargetAndMayAdjustWheelEvent(
|
|
|
|
nsIFrame* aTargetFrame,
|
|
|
|
WidgetWheelEvent* aEvent,
|
|
|
|
ComputeScrollTargetOptions aOptions);
|
|
|
|
|
|
|
|
nsIFrame* ComputeScrollTargetAndMayAdjustWheelEvent(
|
|
|
|
nsIFrame* aTargetFrame,
|
|
|
|
double aDirectionX,
|
|
|
|
double aDirectionY,
|
|
|
|
WidgetWheelEvent* aEvent,
|
|
|
|
ComputeScrollTargetOptions aOptions);
|
|
|
|
|
2015-10-16 07:19:27 +03:00
|
|
|
nsIFrame* ComputeScrollTarget(nsIFrame* aTargetFrame,
|
|
|
|
WidgetWheelEvent* aEvent,
|
2018-03-19 12:05:45 +03:00
|
|
|
ComputeScrollTargetOptions aOptions)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!(aOptions & MAY_BE_ADJUSTED_BY_AUTO_DIR),
|
|
|
|
"aEvent may be modified by auto-dir");
|
|
|
|
return ComputeScrollTargetAndMayAdjustWheelEvent(aTargetFrame, aEvent,
|
|
|
|
aOptions);
|
|
|
|
}
|
2015-10-16 07:19:27 +03:00
|
|
|
|
|
|
|
nsIFrame* ComputeScrollTarget(nsIFrame* aTargetFrame,
|
|
|
|
double aDirectionX,
|
|
|
|
double aDirectionY,
|
|
|
|
WidgetWheelEvent* aEvent,
|
2018-03-19 12:05:45 +03:00
|
|
|
ComputeScrollTargetOptions aOptions)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!(aOptions & MAY_BE_ADJUSTED_BY_AUTO_DIR),
|
|
|
|
"aEvent may be modified by auto-dir");
|
|
|
|
return ComputeScrollTargetAndMayAdjustWheelEvent(aTargetFrame,
|
|
|
|
aDirectionX, aDirectionY,
|
|
|
|
aEvent, 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.
|
2018-03-19 12:05:45 +03:00
|
|
|
* The result of
|
|
|
|
* ComputeScrollTargetAndMayAdjustWheelEvent() is
|
2012-08-12 05:42:34 +04:00
|
|
|
* 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,
|
2017-01-03 18:55:48 +03:00
|
|
|
WidgetInputEvent* aEvent);
|
2008-08-27 16:07:27 +04:00
|
|
|
|
2017-09-18 13:41:36 +03:00
|
|
|
/**
|
|
|
|
* When starting a dnd session, UA must fire a pointercancel event and stop
|
|
|
|
* firing the subsequent pointer events.
|
|
|
|
*/
|
|
|
|
void MaybeFirePointerCancel(WidgetInputEvent* 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
|
2018-02-09 04:43:53 +03:00
|
|
|
* aPrincipalURISpec - [out] set to the URI of the triggering principal of
|
|
|
|
* the drag, or an empty string if it's from
|
|
|
|
* browser chrome or OS
|
2008-08-27 16:07:27 +04:00
|
|
|
*/
|
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,
|
2018-02-09 04:43:53 +03:00
|
|
|
nsIContent** aTargetNode,
|
|
|
|
nsACString& aPrincipalURISpec);
|
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
|
2018-02-09 04:43:53 +03:00
|
|
|
* aPrincipalURISpec - the URI of the triggering principal of the drag,
|
|
|
|
* or an empty string if it's from browser chrome or OS
|
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,
|
2018-02-09 04:43:53 +03:00
|
|
|
nsISelection* aSelection,
|
|
|
|
const nsACString& aPrincipalURISpec);
|
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
|
|
|
|
2017-07-05 12:59:44 +03:00
|
|
|
/**
|
|
|
|
* DispatchCrossProcessEvent() try to post aEvent to target remote process.
|
|
|
|
* If you need to check if the event is posted to a remote process, you
|
|
|
|
* can use aEvent->HasBeenPostedToRemoteProcess().
|
|
|
|
*/
|
|
|
|
void DispatchCrossProcessEvent(WidgetEvent* aEvent,
|
2013-10-02 07:46:04 +04:00
|
|
|
nsFrameLoader* aRemote,
|
2011-06-22 04:32:43 +04:00
|
|
|
nsEventStatus *aStatus);
|
2017-07-05 12:59:44 +03:00
|
|
|
/**
|
|
|
|
* HandleCrossProcessEvent() may post aEvent to target remote processes.
|
|
|
|
* When it succeeded to post the event to at least one remote process,
|
|
|
|
* returns true. Otherwise, including the case not tried to dispatch to
|
|
|
|
* post the event, returns false.
|
|
|
|
* If you need to check if the event is posted to at least one remote
|
|
|
|
* process, you can use aEvent->HasBeenPostedToRemoteProcess().
|
|
|
|
*/
|
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
|
|
|
|
2017-09-18 10:07:41 +03:00
|
|
|
/**
|
|
|
|
* Update the attribute mLastRefPoint of the mouse event. It should be
|
|
|
|
* the center of the window while the pointer is locked.
|
|
|
|
* the same value as mRefPoint while there is no known last ref point.
|
|
|
|
* the same value as the last known mRefPoint.
|
|
|
|
*/
|
|
|
|
static void UpdateLastRefPointOfMouseEvent(WidgetMouseEvent* aMouseEvent);
|
|
|
|
|
|
|
|
static void ResetPointerToWindowCenterWhilePointerLocked(
|
|
|
|
WidgetMouseEvent* aMouseEvent);
|
|
|
|
|
|
|
|
// Update the last known ref point to the current event's mRefPoint.
|
|
|
|
static void UpdateLastPointerPosition(WidgetMouseEvent* aMouseEvent);
|
|
|
|
|
2017-11-14 09:48:18 +03:00
|
|
|
/**
|
|
|
|
* Notify target when user has been interaction with some speicific user
|
|
|
|
* gestures which are eKeyUp, eMouseUp, eTouchEnd.
|
|
|
|
*/
|
|
|
|
void NotifyTargetUserActivation(WidgetEvent* aEvent,
|
|
|
|
nsIContent* aTargetContent);
|
|
|
|
|
2018-03-29 19:22:59 +03:00
|
|
|
already_AddRefed<EventStateManager> ESMFromContentOrThis(nsIContent* aContent);
|
|
|
|
|
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
|
|
|
|
2017-03-01 20:03:14 +03:00
|
|
|
WeakFrame mCurrentTarget;
|
2002-12-17 05:10:57 +03:00
|
|
|
nsCOMPtr<nsIContent> mCurrentTargetContent;
|
2017-03-01 20:03:14 +03:00
|
|
|
static AutoWeakFrame 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
|
|
|
|
2017-01-03 18:55:48 +03:00
|
|
|
bool mInTouchDrag;
|
|
|
|
|
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;
|
|
|
|
|
Bug 1406446 - part 1: InputContextAction should treat focus change during handling a user input as caused by user input even if it's caused by JS r=smaug
Currently, widget doesn't show VKB when input context change is caused by JS.
However, if it's caused by an event handler of a user input, user may expect
to open VKB. For example, if a touch event in fake editor causes moving
focus to actual editable node, user expect to show VKB.
Therefore, InputContextAction should declare two causes. One is unknown but
occurred during handling non-keyboard event. The other is unknown but occurred
during handling keyboard event.
However, EventStateManager doesn't have an API to check if it's being handling
a keyboard event. Therefore, this patch adds it first.
AutoHandlingUserInputStatePusher sends event type to StartHandlingUserInput()
and StopHandlingUserInput() of EventStateManager and sUserKeyboardEventDepth
manages the number of nested keyboard event handling. Therefore,
EventStateManager::IsHandlingKeyboardInput() can return if it's handling a
keyboard event.
IMEStateManager uses this new API to adjust the cause of changes of input
context.
Finally, InputContextAction::IsUserInput() is renamed to IsHandlingUserInput()
for consistency with EventStateManager and starts to return true when the
input context change is caused by script while it's handling a user input.
MozReview-Commit-ID: 5JsLqdqeGah
--HG--
extra : rebase_source : 9fcf7687d1bf90eeebbf6eac62d4488ff64b083c
2017-10-23 20:46:15 +03:00
|
|
|
// The current depth of user and keyboard inputs. sUserInputEventDepth
|
|
|
|
// is the number of any user input events, page load events and mouse over
|
|
|
|
// events. sUserKeyboardEventDepth is the number of keyboard input 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;
|
Bug 1406446 - part 1: InputContextAction should treat focus change during handling a user input as caused by user input even if it's caused by JS r=smaug
Currently, widget doesn't show VKB when input context change is caused by JS.
However, if it's caused by an event handler of a user input, user may expect
to open VKB. For example, if a touch event in fake editor causes moving
focus to actual editable node, user expect to show VKB.
Therefore, InputContextAction should declare two causes. One is unknown but
occurred during handling non-keyboard event. The other is unknown but occurred
during handling keyboard event.
However, EventStateManager doesn't have an API to check if it's being handling
a keyboard event. Therefore, this patch adds it first.
AutoHandlingUserInputStatePusher sends event type to StartHandlingUserInput()
and StopHandlingUserInput() of EventStateManager and sUserKeyboardEventDepth
manages the number of nested keyboard event handling. Therefore,
EventStateManager::IsHandlingKeyboardInput() can return if it's handling a
keyboard event.
IMEStateManager uses this new API to adjust the cause of changes of input
context.
Finally, InputContextAction::IsUserInput() is renamed to IsHandlingUserInput()
for consistency with EventStateManager and starts to return true when the
input context change is caused by script while it's handling a user input.
MozReview-Commit-ID: 5JsLqdqeGah
--HG--
extra : rebase_source : 9fcf7687d1bf90eeebbf6eac62d4488ff64b083c
2017-10-23 20:46:15 +03:00
|
|
|
static int32_t sUserKeyboardEventDepth;
|
2017-07-06 15:00:35 +03: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;
|
2017-07-06 15:00:35 +03: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:
|
Bug 1406446 - part 1: InputContextAction should treat focus change during handling a user input as caused by user input even if it's caused by JS r=smaug
Currently, widget doesn't show VKB when input context change is caused by JS.
However, if it's caused by an event handler of a user input, user may expect
to open VKB. For example, if a touch event in fake editor causes moving
focus to actual editable node, user expect to show VKB.
Therefore, InputContextAction should declare two causes. One is unknown but
occurred during handling non-keyboard event. The other is unknown but occurred
during handling keyboard event.
However, EventStateManager doesn't have an API to check if it's being handling
a keyboard event. Therefore, this patch adds it first.
AutoHandlingUserInputStatePusher sends event type to StartHandlingUserInput()
and StopHandlingUserInput() of EventStateManager and sUserKeyboardEventDepth
manages the number of nested keyboard event handling. Therefore,
EventStateManager::IsHandlingKeyboardInput() can return if it's handling a
keyboard event.
IMEStateManager uses this new API to adjust the cause of changes of input
context.
Finally, InputContextAction::IsUserInput() is renamed to IsHandlingUserInput()
for consistency with EventStateManager and starts to return true when the
input context change is caused by script while it's handling a user input.
MozReview-Commit-ID: 5JsLqdqeGah
--HG--
extra : rebase_source : 9fcf7687d1bf90eeebbf6eac62d4488ff64b083c
2017-10-23 20:46:15 +03:00
|
|
|
nsCOMPtr<nsIDocument> mMouseButtonEventHandlingDocument;
|
|
|
|
EventMessage mMessage;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mIsHandlingUserInput;
|
2004-09-04 23:28:46 +04:00
|
|
|
|
Bug 1406446 - part 1: InputContextAction should treat focus change during handling a user input as caused by user input even if it's caused by JS r=smaug
Currently, widget doesn't show VKB when input context change is caused by JS.
However, if it's caused by an event handler of a user input, user may expect
to open VKB. For example, if a touch event in fake editor causes moving
focus to actual editable node, user expect to show VKB.
Therefore, InputContextAction should declare two causes. One is unknown but
occurred during handling non-keyboard event. The other is unknown but occurred
during handling keyboard event.
However, EventStateManager doesn't have an API to check if it's being handling
a keyboard event. Therefore, this patch adds it first.
AutoHandlingUserInputStatePusher sends event type to StartHandlingUserInput()
and StopHandlingUserInput() of EventStateManager and sUserKeyboardEventDepth
manages the number of nested keyboard event handling. Therefore,
EventStateManager::IsHandlingKeyboardInput() can return if it's handling a
keyboard event.
IMEStateManager uses this new API to adjust the cause of changes of input
context.
Finally, InputContextAction::IsUserInput() is renamed to IsHandlingUserInput()
for consistency with EventStateManager and starts to return true when the
input context change is caused by script while it's handling a user input.
MozReview-Commit-ID: 5JsLqdqeGah
--HG--
extra : rebase_source : 9fcf7687d1bf90eeebbf6eac62d4488ff64b083c
2017-10-23 20:46:15 +03:00
|
|
|
bool NeedsToResetFocusManagerMouseButtonHandlingState() const
|
|
|
|
{
|
|
|
|
return mMessage == eMouseDown || mMessage == eMouseUp;
|
|
|
|
}
|
2014-06-18 10:13:01 +04:00
|
|
|
|
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_
|