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"
|
2020-11-23 19:21:38 +03:00
|
|
|
#include "nsRefPtrHashtable.h"
|
2021-01-14 16:24:16 +03:00
|
|
|
#include "mozilla/Attributes.h"
|
2011-09-07 00:14:59 +04:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2020-08-19 03:51:46 +03:00
|
|
|
#include "mozilla/layers/APZPublicUtils.h"
|
2021-06-25 22:40:36 +03:00
|
|
|
#include "mozilla/dom/Record.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
|
|
|
|
2013-10-22 17:27:35 +04:00
|
|
|
class nsFrameLoader;
|
2013-03-22 04:05:20 +04:00
|
|
|
class nsIContent;
|
2020-11-11 14:14:05 +03:00
|
|
|
class nsICookieJarSettings;
|
2001-05-23 03:52:17 +04:00
|
|
|
class nsIDocShell;
|
2001-10-23 02:43:52 +04:00
|
|
|
class nsIDocShellTreeItem;
|
2020-07-15 16:44:39 +03:00
|
|
|
class nsIFrame;
|
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
|
|
|
|
2021-06-10 02:51:37 +03:00
|
|
|
class EditorBase;
|
2014-04-01 08:09:23 +04:00
|
|
|
class EnterLeaveDispatcher;
|
2014-04-24 04:36:15 +04:00
|
|
|
class IMEContentObserver;
|
2014-04-01 08:09:22 +04:00
|
|
|
class ScrollbarsForWheel;
|
2021-07-14 04:20:20 +03:00
|
|
|
class TextControlElement;
|
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;
|
2019-01-02 16:05:23 +03:00
|
|
|
class Document;
|
2014-10-15 09:42:00 +04:00
|
|
|
class Element;
|
2018-05-08 20:52:36 +03:00
|
|
|
class Selection;
|
2019-04-10 00:38:15 +03:00
|
|
|
class BrowserParent;
|
2019-05-14 18:04:38 +03:00
|
|
|
class RemoteDragStartData;
|
|
|
|
|
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-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 {
|
|
|
|
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;
|
|
|
|
|
2022-06-08 02:09:52 +03:00
|
|
|
using ElementState = dom::ElementState;
|
|
|
|
|
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
|
|
|
*/
|
2019-03-13 03:43:48 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2011-04-21 21:35:52 +04:00
|
|
|
nsresult PreHandleEvent(nsPresContext* aPresContext, WidgetEvent* aEvent,
|
2015-04-14 18:46:39 +03:00
|
|
|
nsIFrame* aTargetFrame, 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.
|
|
|
|
*/
|
2019-03-13 03:43:48 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2011-04-21 21:35:52 +04:00
|
|
|
nsresult PostHandleEvent(nsPresContext* aPresContext, WidgetEvent* aEvent,
|
2018-03-29 19:22:59 +03:00
|
|
|
nsIFrame* aTargetFrame, nsEventStatus* aStatus,
|
|
|
|
nsIContent* aOverrideClickTarget);
|
1998-11-18 08:25:26 +03:00
|
|
|
|
2021-12-16 20:17:07 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT void PostHandleKeyboardEvent(
|
|
|
|
WidgetKeyboardEvent* aKeyboardEvent, 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
|
|
|
*/
|
2021-12-16 20:17:07 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY void DispatchLegacyMouseScrollEvents(
|
|
|
|
nsIFrame* aTargetFrame, WidgetWheelEvent* aEvent, nsEventStatus* aStatus);
|
2012-08-12 05:42:35 +04:00
|
|
|
|
2022-05-26 07:37:21 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY void NotifyDestroyPresContext(
|
|
|
|
nsPresContext* aPresContext);
|
2011-04-21 21:35:52 +04:00
|
|
|
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
|
|
|
|
2019-03-29 20:20:39 +03:00
|
|
|
// We manage 4 states here: ACTIVE, HOVER, DRAGOVER, URLTARGET
|
2022-06-08 02:09:52 +03:00
|
|
|
static bool ManagesState(ElementState aState) {
|
|
|
|
return aState == ElementState::ACTIVE || aState == ElementState::HOVER ||
|
|
|
|
aState == ElementState::DRAGOVER ||
|
|
|
|
aState == ElementState::URLTARGET;
|
2019-03-29 20:20:39 +03:00
|
|
|
}
|
|
|
|
|
2011-04-21 21:35:52 +04:00
|
|
|
/**
|
2022-06-08 02:09:52 +03:00
|
|
|
* Notify that the given ElementState::* bit has changed for this content.
|
2011-04-21 21:35:52 +04:00
|
|
|
* @param aContent Content which has changed states
|
2022-06-08 02:09:52 +03:00
|
|
|
* @param aState Corresponding state flags such as ElementState::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.
|
|
|
|
*/
|
2022-06-08 02:09:52 +03:00
|
|
|
bool SetContentState(nsIContent* aContent, ElementState aState);
|
2018-05-14 15:49:40 +03:00
|
|
|
|
|
|
|
void NativeAnonymousContentRemoved(nsIContent* aAnonContent);
|
2022-05-26 07:37:20 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY void ContentRemoved(dom::Document* aDocument,
|
|
|
|
nsIContent* aContent);
|
2017-09-08 06:01:22 +03:00
|
|
|
|
2021-07-14 04:20:20 +03:00
|
|
|
/**
|
|
|
|
* Called when a native anonymous <div> element which is root element of
|
|
|
|
* text editor will be removed.
|
|
|
|
*/
|
|
|
|
void TextControlRootWillBeRemoved(TextControlElement& aTextControlElement);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when a native anonymous <div> element which is root element of
|
|
|
|
* text editor is created.
|
|
|
|
*/
|
|
|
|
void TextControlRootAdded(dom::Element& aAnonymousDivElement,
|
|
|
|
TextControlElement& aTextControlElement);
|
|
|
|
|
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();
|
|
|
|
|
2022-04-04 16:33:35 +03:00
|
|
|
static bool IsKeyboardEventUserActivity(WidgetEvent* aEvent);
|
|
|
|
|
2011-04-21 21:35:52 +04:00
|
|
|
/**
|
|
|
|
* Register accesskey on the given element. When accesskey is activated then
|
2021-03-25 19:09:53 +03:00
|
|
|
* the element will be notified via Element::PerformAccesskey() method.
|
2011-04-21 21:35:52 +04:00
|
|
|
*
|
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) {
|
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);
|
|
|
|
|
2021-05-05 12:41:24 +03:00
|
|
|
nsresult SetCursor(StyleCursorKind, imgIContainer*, const ImageResolution&,
|
|
|
|
const Maybe<gfx::IntPoint>& aHotspot, nsIWidget* aWidget,
|
|
|
|
bool aLockCursor);
|
2000-04-24 08:41:27 +04:00
|
|
|
|
2019-09-18 05:06:32 +03:00
|
|
|
/**
|
|
|
|
* Checks if the current mouse over element matches the given
|
|
|
|
* Element (which has a remote frame), and if so, notifies
|
|
|
|
* the BrowserParent of the mouse enter.
|
|
|
|
* Called when we reconstruct the BrowserParent and need to
|
|
|
|
* recompute state on the new object.
|
|
|
|
*/
|
2019-11-29 23:39:36 +03:00
|
|
|
void RecomputeMouseEnterStateForRemoteFrame(dom::Element& aElement);
|
2019-09-18 05:06:32 +03:00
|
|
|
|
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, nsIObserver)
|
2007-08-11 01:25:24 +04:00
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
static dom::Document* sMouseOverDocument;
|
2010-09-17 22:56:53 +04:00
|
|
|
|
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
|
|
|
|
2020-06-18 23:38:34 +03:00
|
|
|
static bool IsRemoteTarget(nsIContent* target);
|
|
|
|
|
|
|
|
static bool IsTopLevelRemoteTarget(nsIContent* aTarget);
|
2011-10-26 10:42:20 +04:00
|
|
|
|
2018-05-01 05:11:10 +03:00
|
|
|
// Returns the kind of APZ action the given WidgetWheelEvent will perform.
|
|
|
|
static Maybe<layers::APZWheelAction> APZWheelActionFor(
|
|
|
|
const WidgetWheelEvent* aEvent);
|
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
|
|
|
|
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
|
|
|
|
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 };
|
|
|
|
|
2018-10-10 15:04:17 +03:00
|
|
|
/**
|
|
|
|
* HandleMiddleClickPaste() handles middle mouse button event as pasting
|
2021-06-10 02:51:37 +03:00
|
|
|
* clipboard text. Note that if aEditorBase is nullptr, this only
|
2018-10-10 15:06:17 +03:00
|
|
|
* dispatches ePaste event because it's necessary for some web apps which
|
|
|
|
* want to implement their own editor and supports middle click paste.
|
2018-10-10 15:04:17 +03:00
|
|
|
*
|
|
|
|
* @param aPresShell The PresShell for the ESM. This lifetime
|
|
|
|
* should be guaranteed by the caller.
|
|
|
|
* @param aMouseEvent The eMouseClick event which caused the
|
|
|
|
* paste.
|
|
|
|
* @param aStatus The event status of aMouseEvent.
|
2021-06-10 02:51:37 +03:00
|
|
|
* @param aEditorBase EditorBase which may be pasted the
|
2018-10-10 15:04:17 +03:00
|
|
|
* clipboard text by the middle click.
|
2018-10-10 15:06:17 +03:00
|
|
|
* If there is no editor for aMouseEvent,
|
|
|
|
* set nullptr.
|
2018-10-10 15:04:17 +03:00
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2019-04-30 04:35:30 +03:00
|
|
|
nsresult HandleMiddleClickPaste(PresShell* aPresShell,
|
2018-10-10 15:04:17 +03:00
|
|
|
WidgetMouseEvent* aMouseEvent,
|
|
|
|
nsEventStatus* aStatus,
|
2021-06-10 02:51:37 +03:00
|
|
|
EditorBase* aEditorBase);
|
2018-10-10 15:04:17 +03:00
|
|
|
|
2021-06-25 22:40:36 +03:00
|
|
|
static void ConsumeInteractionData(
|
|
|
|
dom::Record<nsString, dom::InteractionData>& aInteractions);
|
|
|
|
|
2021-07-14 21:40:18 +03:00
|
|
|
// Stop tracking a possible drag. If aClearInChildProcesses is true, send
|
|
|
|
// a notification to any child processes that are in the drag service that
|
|
|
|
// tried to start a drag.
|
|
|
|
void StopTrackingDragGesture(bool aClearInChildProcesses);
|
|
|
|
|
1998-06-24 01:53:02 +04:00
|
|
|
protected:
|
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, WidgetEvent* aEvent,
|
|
|
|
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
|
2005-03-29 03:39:13 +04:00
|
|
|
* specified 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
|
|
|
*/
|
2021-12-16 20:17:08 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT nsIFrame* DispatchMouseOrPointerEvent(
|
|
|
|
WidgetMouseEvent* aMouseEvent, EventMessage aMessage,
|
|
|
|
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.
|
|
|
|
*/
|
2021-12-16 20:17:08 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY void NotifyMouseOver(
|
|
|
|
WidgetMouseEvent* aMouseEvent, 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.
|
2021-12-16 20:17:08 +03:00
|
|
|
* TODO: Convert this to MOZ_CAN_RUN_SCRIPT (bug 1415230)
|
|
|
|
*
|
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
|
|
|
*/
|
2021-12-16 20:17:08 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY void NotifyMouseOut(WidgetMouseEvent* aMouseEvent,
|
|
|
|
nsIContent* aMovingInto);
|
2021-07-29 18:03:44 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT void GenerateDragDropEnterExit(
|
|
|
|
nsPresContext* aPresContext, 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
|
|
|
|
*/
|
2021-07-29 18:03:44 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT void FireDragEnterOrExit(nsPresContext* aPresContext,
|
|
|
|
WidgetDragEvent* aDragEvent,
|
|
|
|
EventMessage aMessage,
|
|
|
|
nsIContent* aRelatedTarget,
|
|
|
|
nsIContent* aTargetContent,
|
|
|
|
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
|
|
|
|
2018-10-10 15:01:57 +03:00
|
|
|
/**
|
|
|
|
* InitAndDispatchClickEvent() dispatches a click event.
|
|
|
|
*
|
|
|
|
* @param aMouseUpEvent eMouseUp event which causes the click event.
|
|
|
|
* EventCausesClickEvents() must return true
|
|
|
|
* if this event is set to it.
|
|
|
|
* @param aStatus Returns the result of click event.
|
2018-10-10 15:02:50 +03:00
|
|
|
* If the status indicates consumed, the
|
|
|
|
* value won't be overwritten with
|
|
|
|
* nsEventStatus_eIgnore.
|
2018-10-10 15:01:57 +03:00
|
|
|
* @param aMessage Should be eMouseClick, eMouseDoubleClick or
|
|
|
|
* eMouseAuxClick.
|
|
|
|
* @param aPresShell The PresShell.
|
|
|
|
* @param aMouseUpContent The event target of aMouseUpEvent.
|
|
|
|
* @param aCurrentTarget Current target of the caller.
|
|
|
|
* @param aNoContentDispatch true if the event shouldn't be exposed to
|
|
|
|
* web contents (although will be fired on
|
|
|
|
* document and window).
|
|
|
|
* @param aOverrideClickTarget Preferred click event target. If this is
|
|
|
|
* not nullptr, aMouseUpContent and
|
|
|
|
* aCurrentTarget are ignored.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
static nsresult InitAndDispatchClickEvent(
|
|
|
|
WidgetMouseEvent* aMouseUpEvent, nsEventStatus* aStatus,
|
2019-04-30 04:35:30 +03:00
|
|
|
EventMessage aMessage, PresShell* aPresShell, nsIContent* aMouseUpContent,
|
|
|
|
AutoWeakFrame aCurrentTarget, bool aNoContentDispatch,
|
|
|
|
nsIContent* aOverrideClickTarget);
|
2018-10-10 15:01:57 +03:00
|
|
|
|
2018-03-29 19:22:59 +03:00
|
|
|
nsresult SetClickCount(WidgetMouseEvent* aEvent, nsEventStatus* aStatus,
|
|
|
|
nsIContent* aOverrideClickTarget = nullptr);
|
2018-10-10 15:01:57 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* EventCausesClickEvents() returns true when aMouseEvent is an eMouseUp
|
|
|
|
* event and it should cause eMouseClick, eMouseDoubleClick and/or
|
|
|
|
* eMouseAuxClick events. Note that this method assumes that
|
|
|
|
* aMouseEvent.mClickCount has already been initialized with SetClickCount().
|
|
|
|
*/
|
|
|
|
static bool EventCausesClickEvents(const WidgetMouseEvent& aMouseEvent);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PostHandleMouseUp() handles default actions of eMouseUp event.
|
|
|
|
*
|
|
|
|
* @param aMouseUpEvent eMouseUp event which causes the click event.
|
|
|
|
* EventCausesClickEvents() must return true
|
|
|
|
* if this event is set to it.
|
|
|
|
* @param aStatus Returns the result of event status.
|
|
|
|
* If one of dispatching event is consumed or
|
|
|
|
* this does something as default action,
|
|
|
|
* returns nsEventStatus_eConsumeNoDefault.
|
|
|
|
* @param aOverrideClickTarget Preferred click event target. If nullptr,
|
|
|
|
* aMouseUpEvent target and current target
|
|
|
|
* are used.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
nsresult PostHandleMouseUp(WidgetMouseEvent* aMouseUpEvent,
|
|
|
|
nsEventStatus* aStatus,
|
|
|
|
nsIContent* aOverrideClickTarget);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DispatchClickEvents() dispatches eMouseClick, eMouseDoubleClick and
|
|
|
|
* eMouseAuxClick events for aMouseUpEvent. aMouseUpEvent should cause
|
|
|
|
* click event.
|
|
|
|
*
|
|
|
|
* @param aPresShell The PresShell.
|
|
|
|
* @param aMouseUpEvent eMouseUp event which causes the click event.
|
|
|
|
* EventCausesClickEvents() must return true
|
|
|
|
* if this event is set to it.
|
|
|
|
* @param aStatus Returns the result of event status.
|
|
|
|
* If one of dispatching click event is
|
|
|
|
* consumed, returns
|
|
|
|
* nsEventStatus_eConsumeNoDefault.
|
|
|
|
* @param aMouseUpContent The event target of aMouseUpEvent.
|
|
|
|
* @param aOverrideClickTarget Preferred click event target. If this is
|
|
|
|
* not nullptr, aMouseUpContent and
|
|
|
|
* current target frame of the ESM are ignored.
|
|
|
|
*/
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2019-04-30 04:35:30 +03:00
|
|
|
nsresult DispatchClickEvents(PresShell* aPresShell,
|
2018-10-10 15:01:57 +03:00
|
|
|
WidgetMouseEvent* aMouseUpEvent,
|
|
|
|
nsEventStatus* aStatus,
|
|
|
|
nsIContent* aMouseUpContent,
|
|
|
|
nsIContent* aOverrideClickTarget);
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
void EnsureDocument(nsPresContext* aPresContext);
|
2019-04-13 15:43:57 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
2019-10-03 14:26:39 +03:00
|
|
|
void FlushLayout(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
|
|
|
*/
|
2021-08-07 13:36:35 +03:00
|
|
|
enum ProcessingAccessKeyState {
|
2002-09-03 09:48:06 +04:00
|
|
|
eAccessKeyProcessingNormal = 0,
|
|
|
|
eAccessKeyProcessingUp,
|
|
|
|
eAccessKeyProcessingDown
|
2021-08-07 13:36:35 +03:00
|
|
|
};
|
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.
|
2021-03-25 19:09:53 +03:00
|
|
|
* If there is registered element for the accesskey given by the key event
|
|
|
|
* and modifier mask then call element.PerformAccesskey(), otherwise call
|
2017-07-20 11:33:53 +03:00
|
|
|
* 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.
|
|
|
|
*/
|
2020-12-04 00:34:06 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY bool LookForAccessKeyAndExecute(
|
|
|
|
nsTArray<uint32_t>& aAccessCharCodes, bool aIsTrustedEvent,
|
|
|
|
bool aIsRepeat, bool aExecute);
|
2008-04-15 08:16:24 +04:00
|
|
|
|
2001-05-23 03:52:17 +04:00
|
|
|
//---------------------------------------------
|
|
|
|
// DocShell Focus Traversal Methods
|
|
|
|
//---------------------------------------------
|
|
|
|
|
2021-03-20 02:21:21 +03:00
|
|
|
dom::Element* GetFocusedElement();
|
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,
|
2018-05-02 23:51:27 +03:00
|
|
|
ACTION_PINCH_ZOOM,
|
|
|
|
ACTION_LAST = ACTION_PINCH_ZOOM,
|
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
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
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.
|
|
|
|
*/
|
2021-12-16 20:17:07 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT void SendLineScrollEvent(nsIFrame* aTargetFrame,
|
|
|
|
WidgetWheelEvent* aEvent,
|
|
|
|
EventState& aState,
|
|
|
|
int32_t aDelta,
|
|
|
|
DeltaDirection aDeltaDirection);
|
2012-08-12 05:42:35 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2021-12-16 20:17:07 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT void SendPixelScrollEvent(nsIFrame* aTargetFrame,
|
|
|
|
WidgetWheelEvent* aEvent,
|
|
|
|
EventState& aState,
|
|
|
|
int32_t aPixelDelta,
|
|
|
|
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.
|
2021-05-10 13:29:20 +03:00
|
|
|
COMPUTE_DEFAULT_ACTION_TARGET =
|
2016-02-26 03:41:59 +03:00
|
|
|
(PREFER_MOUSE_WHEEL_TRANSACTION |
|
|
|
|
PREFER_ACTUAL_SCROLLABLE_TARGET_ALONG_X_AXIS |
|
|
|
|
PREFER_ACTUAL_SCROLLABLE_TARGET_ALONG_Y_AXIS),
|
2018-03-19 12:05:45 +03:00
|
|
|
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
|
|
|
};
|
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, WidgetWheelEvent* aEvent,
|
|
|
|
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);
|
2020-04-30 19:35:35 +03:00
|
|
|
void ChangeZoom(bool aIncrease);
|
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, EventStateManager* aESM,
|
2014-04-01 08:09:23 +04:00
|
|
|
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(
|
|
|
|
WidgetWheelEvent* aEvent, const nsIntSize& aScrollAmountInDevPixels);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
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
|
|
|
|
2018-11-16 00:22:49 +03:00
|
|
|
void SetGestureDownPoint(WidgetGUIEvent* aEvent);
|
|
|
|
|
|
|
|
LayoutDeviceIntPoint GetEventRefPoint(WidgetEvent* aEvent) const;
|
|
|
|
|
2019-04-10 00:38:15 +03:00
|
|
|
friend class mozilla::dom::BrowserParent;
|
2019-05-14 18:04:38 +03:00
|
|
|
void BeginTrackingRemoteDragGesture(nsIContent* aContent,
|
|
|
|
dom::RemoteDragStartData* aDragStartData);
|
2019-10-01 17:07:27 +03:00
|
|
|
|
2019-05-06 16:15:05 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2013-10-02 10:38:27 +04:00
|
|
|
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.
|
|
|
|
*/
|
2019-05-06 16:15:05 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2017-09-18 13:41:36 +03:00
|
|
|
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
|
2019-10-08 00:01:57 +03:00
|
|
|
* aAllowEmptyDataTransfer - [out] set to true, if dnd operation can be
|
|
|
|
* started even if DataTransfer is empty
|
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
|
2019-01-04 06:16:46 +03:00
|
|
|
* aPrincipal - [out] set to the triggering principal of the drag, or null
|
|
|
|
* if it's from browser chrome or OS
|
2020-11-11 14:14:05 +03:00
|
|
|
* aCookieJarSettings - [out] set to the cookieJarSettings of the drag, or
|
|
|
|
* null if it's from browser chrome or OS.
|
2008-08-27 16:07:27 +04:00
|
|
|
*/
|
2019-05-14 18:04:38 +03:00
|
|
|
void DetermineDragTargetAndDefaultData(
|
|
|
|
nsPIDOMWindowOuter* aWindow, nsIContent* aSelectionTarget,
|
2019-10-08 00:01:57 +03:00
|
|
|
dom::DataTransfer* aDataTransfer, bool* aAllowEmptyDataTransfer,
|
|
|
|
dom::Selection** aSelection,
|
2019-05-14 18:04:38 +03:00
|
|
|
dom::RemoteDragStartData** aRemoteDragStartData, nsIContent** aTargetNode,
|
2020-11-11 14:14:05 +03:00
|
|
|
nsIPrincipal** aPrincipal, nsIContentSecurityPolicy** aCsp,
|
|
|
|
nsICookieJarSettings** aCookieJarSettings);
|
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
|
2019-10-08 00:01:57 +03:00
|
|
|
* aAllowEmptyDataTransfer - if true, dnd can be started even if there is no
|
|
|
|
* data to drag
|
2008-08-27 16:07:27 +04:00
|
|
|
* aDragTarget - the target of the drag
|
2012-02-17 18:16:59 +04:00
|
|
|
* aSelection - the selection to be dragged
|
2019-05-14 18:04:38 +03:00
|
|
|
* aData - information pertaining to a drag started in a child process
|
2019-01-04 06:16:46 +03:00
|
|
|
* aPrincipal - the triggering principal of the drag, or null if it's from
|
|
|
|
* browser chrome or OS
|
2020-11-11 14:14:05 +03:00
|
|
|
* aCookieJarSettings - the cookieJarSettings of the drag. or null if it's
|
|
|
|
* from browser chrome or OS.
|
2008-08-27 16:07:27 +04:00
|
|
|
*/
|
2019-05-09 23:21:28 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2020-11-11 14:14:05 +03:00
|
|
|
bool DoDefaultDragStart(
|
|
|
|
nsPresContext* aPresContext, WidgetDragEvent* aDragEvent,
|
|
|
|
dom::DataTransfer* aDataTransfer, bool aAllowEmptyDataTransfer,
|
|
|
|
nsIContent* aDragTarget, dom::Selection* aSelection,
|
|
|
|
dom::RemoteDragStartData* aDragStartData, nsIPrincipal* aPrincipal,
|
|
|
|
nsIContentSecurityPolicy* aCsp, nsICookieJarSettings* aCookieJarSettings);
|
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
|
|
|
|
2019-03-13 03:43:48 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2014-04-01 08:09:23 +04:00
|
|
|
nsresult DoContentCommandEvent(WidgetContentCommandEvent* aEvent);
|
2021-05-18 09:30:35 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
nsresult DoContentCommandInsertTextEvent(WidgetContentCommandEvent* aEvent);
|
2014-04-01 08:09:23 +04:00
|
|
|
nsresult DoContentCommandScrollEvent(WidgetContentCommandEvent* aEvent);
|
2009-08-07 19:11:17 +04:00
|
|
|
|
2019-04-10 00:38:15 +03:00
|
|
|
dom::BrowserParent* GetCrossProcessTarget();
|
2014-04-01 08:09:23 +04:00
|
|
|
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().
|
|
|
|
*/
|
2020-04-29 14:58:14 +03:00
|
|
|
void DispatchCrossProcessEvent(WidgetEvent* aEvent,
|
|
|
|
dom::BrowserParent* aRemoteTarget,
|
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, nsEventStatus* aStatus);
|
2011-06-22 04:32:43 +04:00
|
|
|
|
2014-04-24 04:36:15 +04:00
|
|
|
void ReleaseCurrentIMEContentObserver();
|
|
|
|
|
2020-10-09 05:37:47 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT void HandleQueryContentEvent(
|
|
|
|
WidgetQueryContentEvent* aEvent);
|
2015-09-08 06:54:14 +03:00
|
|
|
|
2011-06-01 05:46:56 +04:00
|
|
|
private:
|
2018-05-14 15:49:40 +03:00
|
|
|
// Removes a node from the :hover / :active chain if needed, notifying if the
|
|
|
|
// node is not a NAC subtree.
|
|
|
|
//
|
|
|
|
// Only meant to be called from ContentRemoved and
|
|
|
|
// NativeAnonymousContentRemoved.
|
2022-06-08 02:09:52 +03:00
|
|
|
void RemoveNodeFromChainIfNeeded(ElementState aState,
|
2018-05-14 15:49:40 +03:00
|
|
|
nsIContent* aContentRemoved, bool aNotify);
|
2018-04-30 05:45:41 +03:00
|
|
|
|
|
|
|
bool IsEventOutsideDragThreshold(WidgetInputEvent* aEvent) const;
|
|
|
|
|
2022-06-08 02:09:52 +03:00
|
|
|
static inline void DoStateChange(dom::Element* aElement, ElementState aState,
|
2014-04-03 08:18:36 +04:00
|
|
|
bool aAddState);
|
2022-06-08 02:09:52 +03:00
|
|
|
static inline void DoStateChange(nsIContent* aContent, ElementState aState,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aAddState);
|
2011-06-01 05:46:56 +04:00
|
|
|
static void UpdateAncestorState(nsIContent* aStartNode,
|
2022-06-08 02:09:52 +03:00
|
|
|
nsIContent* aStopBefore, ElementState aState,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aAddState);
|
2021-03-17 18:49:46 +03:00
|
|
|
static void ResetLastOverForContent(
|
|
|
|
const uint32_t& aIdx, const 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);
|
|
|
|
|
2019-01-15 17:05:45 +03:00
|
|
|
StyleCursorKind 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).
|
2021-12-23 19:27:26 +03:00
|
|
|
RefPtr<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;
|
2019-05-14 18:04:38 +03:00
|
|
|
// Data associated with a drag started in a content process.
|
|
|
|
RefPtr<dom::RemoteDragStartData> mGestureDownDragStartData;
|
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;
|
|
|
|
nsCOMPtr<nsIContent> mLastMiddleMouseDownContent;
|
|
|
|
nsCOMPtr<nsIContent> mLastRightMouseDownContent;
|
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
|
2019-01-02 16:05:23 +03:00
|
|
|
RefPtr<dom::Document> mDocument; // Doesn't necessarily need to be owner
|
2002-12-17 05:10:57 +03:00
|
|
|
|
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
|
|
|
|
2021-03-09 04:59:43 +03:00
|
|
|
bool mShouldAlwaysUseLineDeltas : 1;
|
|
|
|
bool mShouldAlwaysUseLineDeltasInitialized : 1;
|
|
|
|
|
2021-07-14 04:20:20 +03:00
|
|
|
bool mGestureDownInTextControl : 1;
|
|
|
|
|
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-10-18 08:24:48 +03:00
|
|
|
RefPtr<OverOutElementsWrapper> mMouseEnterLeaveHelper;
|
2014-02-11 10:33:35 +04:00
|
|
|
nsRefPtrHashtable<nsUint32HashKey, OverOutElementsWrapper>
|
|
|
|
mPointersEnterLeaveHelper;
|
|
|
|
|
2021-03-20 02:21:22 +03:00
|
|
|
// Array for accesskey support
|
|
|
|
nsCOMArray<dom::Element> mAccessKeys;
|
|
|
|
|
2021-03-09 04:59:43 +03:00
|
|
|
bool ShouldAlwaysUseLineDeltas();
|
|
|
|
|
2010-11-07 22:07:59 +03:00
|
|
|
public:
|
|
|
|
static nsresult UpdateUserActivityTimer(void);
|
2002-02-01 08:14:44 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool sNormalLMouseEventInProcess;
|
2019-05-22 22:16:31 +03:00
|
|
|
static int16_t sCurrentMouseBtn;
|
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();
|
2021-01-14 16:24:16 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY void FireContextClick();
|
2012-04-12 01:55:21 +04:00
|
|
|
|
2019-05-09 23:21:28 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT 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
|
|
|
};
|
|
|
|
|
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.
|
2022-04-27 04:15:29 +03:00
|
|
|
#define NS_EVENT_NEEDS_FRAME(event) \
|
|
|
|
((event)->mMessage != eMouseClick && \
|
|
|
|
(event)->mMessage != eMouseDoubleClick && \
|
2016-12-01 03:48:02 +03:00
|
|
|
(event)->mMessage != eMouseAuxClick)
|
2011-04-21 21:35:52 +04:00
|
|
|
|
2014-04-01 08:09:23 +04:00
|
|
|
#endif // mozilla_EventStateManager_h_
|