/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */
/** * Most of this class is for the old user activation model. The new model * defined in the spec [1] is implemented by `dom::WindowContext` (see * `WindowContext::GetUserActivationState` etc.) since the state defined in the * spec is associated with the `window` object. * * [1]: * https://html.spec.whatwg.org/multipage/interaction.html#user-activation-data-model
*/ class UserActivation final : public nsISupports, public nsWrapperCache { public: // WebIDL UserActivation
enumclass State : uint8_t { // Not activated.
None, // It is considered as has-been-activated, but not transient-activated given // that it is being consumed.
HasBeenActivated, // It is considered as has-been-activated, and also transient-activated if // haven't timed out.
FullActivated,
EndGuard_
};
class StateAndModifiers;
// Modifier keys held while the user activation. class Modifiers { public: static constexpr uint8_t Shift = 0x10; static constexpr uint8_t Meta = 0x20; static constexpr uint8_t Control = 0x40; static constexpr uint8_t Alt = 0x80; static constexpr uint8_t MiddleMouse = 0x08;
/** * Returns true if the current code is being executed as a result of * 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.
*/ staticbool IsHandlingUserInput(); staticbool IsHandlingKeyboardInput();
/** * Returns true if the event is considered as user interaction event. I.e., * enough obvious input to allow to open popup, etc. Otherwise, returns false.
*/ staticbool IsUserInteractionEvent(const WidgetEvent* aEvent);
/** * 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.
*/ staticvoid StartHandlingUserInput(EventMessage aMessage); staticvoid StopHandlingUserInput(EventMessage aMessage);
static TimeStamp GetHandlingInputStart();
/** * 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();
private:
~UserActivation() = default;
nsCOMPtr<nsPIDOMWindowInner> mWindow;
};
/** * This class is used while processing real user input. During this time, popups * are allowed. For mousedown events, mouse capturing is also permitted.
*/ class MOZ_RAII AutoHandlingUserInputStatePusher final { public: explicit AutoHandlingUserInputStatePusher(bool aIsHandlingUserInput,
WidgetEvent* aEvent = nullptr);
~AutoHandlingUserInputStatePusher();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.