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/. */
|
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
|
|
|
|
|
|
|
#ifndef nsFocusManager_h___
|
|
|
|
#define nsFocusManager_h___
|
|
|
|
|
2013-03-22 04:05:20 +04:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2017-05-19 23:20:48 +03:00
|
|
|
#include "nsIContent.h"
|
2019-01-02 16:05:23 +03:00
|
|
|
#include "mozilla/dom/Document.h"
|
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
|
|
|
#include "nsIFocusManager.h"
|
|
|
|
#include "nsIObserver.h"
|
2011-11-27 15:51:52 +04:00
|
|
|
#include "nsIWidget.h"
|
2013-03-22 04:05:20 +04:00
|
|
|
#include "nsWeakReference.h"
|
2012-06-15 06:31:55 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2018-04-26 17:37:47 +03:00
|
|
|
#include "mozilla/RefPtr.h"
|
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
|
|
|
|
|
|
|
#define FOCUSMETHOD_MASK 0xF000
|
2010-04-21 18:53:42 +04:00
|
|
|
#define FOCUSMETHODANDRING_MASK 0xF0F000
|
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
|
|
|
|
|
|
|
#define FOCUSMANAGER_CONTRACTID "@mozilla.org/focus-manager;1"
|
|
|
|
|
2013-03-22 04:05:20 +04:00
|
|
|
class nsIContent;
|
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
|
|
|
class nsIDocShellTreeItem;
|
2016-01-30 20:05:36 +03:00
|
|
|
class nsPIDOMWindowOuter;
|
2011-06-18 04:08:32 +04:00
|
|
|
|
2015-07-13 13:07:49 +03:00
|
|
|
namespace mozilla {
|
2019-04-23 04:34:24 +03:00
|
|
|
class PresShell;
|
2015-07-13 13:07:49 +03:00
|
|
|
namespace dom {
|
2018-04-26 17:37:47 +03:00
|
|
|
class Element;
|
2019-04-12 11:16:47 +03:00
|
|
|
struct FocusOptions;
|
2019-04-10 00:38:15 +03:00
|
|
|
class BrowserParent;
|
2015-07-13 13:07:49 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
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
|
|
|
struct nsDelayedBlurOrFocusEvent;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The focus manager keeps track of where the focus is, that is, the node
|
|
|
|
* which receives key events.
|
|
|
|
*/
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsFocusManager final : public nsIFocusManager,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsIObserver,
|
|
|
|
public nsSupportsWeakReference {
|
2011-11-27 15:51:52 +04:00
|
|
|
typedef mozilla::widget::InputContextAction InputContextAction;
|
2019-01-02 16:05:23 +03:00
|
|
|
typedef mozilla::dom::Document Document;
|
2011-11-27 15:51:52 +04:00
|
|
|
|
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
|
|
|
public:
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsFocusManager, nsIFocusManager)
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
NS_DECL_NSIFOCUSMANAGER
|
|
|
|
|
|
|
|
// called to initialize and stop the focus manager at startup and shutdown
|
|
|
|
static nsresult Init();
|
|
|
|
static void Shutdown();
|
|
|
|
|
2019-06-03 22:42:28 +03:00
|
|
|
// Simple helper to call SetFocusedWindow on the instance.
|
|
|
|
//
|
|
|
|
// This raises the window and switches to the tab as needed.
|
|
|
|
static void FocusWindow(nsPIDOMWindowOuter* aWindow);
|
|
|
|
|
2018-07-05 23:36:07 +03:00
|
|
|
void PrefChanged(const char* aPref);
|
|
|
|
|
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
|
|
|
/**
|
|
|
|
* Retrieve the single focus manager.
|
|
|
|
*/
|
2009-08-14 06:09:49 +04:00
|
|
|
static nsFocusManager* GetFocusManager() { return sInstance; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A faster version of nsIFocusManager::GetFocusedElement, returning a
|
2018-04-27 06:37:34 +03:00
|
|
|
* raw Element pointer (instead of having AddRef-ed Element
|
2009-08-14 06:09:49 +04:00
|
|
|
* pointer filled in to an out-parameter).
|
|
|
|
*/
|
2018-04-26 22:28:31 +03:00
|
|
|
mozilla::dom::Element* GetFocusedElement() { return mFocusedElement; }
|
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
|
|
|
|
2017-08-03 22:07:14 +03:00
|
|
|
/**
|
|
|
|
* Returns true if aContent currently has focus.
|
|
|
|
*/
|
|
|
|
bool IsFocused(nsIContent* aContent);
|
|
|
|
|
2018-09-10 16:03:04 +03:00
|
|
|
/**
|
|
|
|
* Returns true if test mode is enabled.
|
|
|
|
*/
|
|
|
|
bool IsTestMode();
|
|
|
|
|
2012-05-22 13:25:44 +04:00
|
|
|
/**
|
|
|
|
* Return a focused window. Version of nsIFocusManager::GetFocusedWindow.
|
|
|
|
*/
|
2016-01-30 20:05:36 +03:00
|
|
|
nsPIDOMWindowOuter* GetFocusedWindow() const { return mFocusedWindow; }
|
2012-05-22 13:25:44 +04:00
|
|
|
|
2012-05-23 03:48:35 +04:00
|
|
|
/**
|
|
|
|
* Return an active window. Version of nsIFocusManager::GetActiveWindow.
|
|
|
|
*/
|
2016-01-30 20:05:36 +03:00
|
|
|
nsPIDOMWindowOuter* GetActiveWindow() const { return mActiveWindow; }
|
2012-05-23 03:48:35 +04:00
|
|
|
|
2010-04-27 13:58:58 +04:00
|
|
|
/**
|
|
|
|
* Called when content has been removed.
|
|
|
|
*/
|
2019-01-02 16:05:23 +03:00
|
|
|
nsresult ContentRemoved(Document* aDocument, nsIContent* aContent);
|
2010-04-27 13:58:58 +04:00
|
|
|
|
2010-11-06 08:04:11 +03:00
|
|
|
/**
|
2014-06-18 10:13:00 +04:00
|
|
|
* Called when mouse button event handling is started and finished.
|
2010-11-06 08:04:11 +03:00
|
|
|
*/
|
2019-01-02 16:05:23 +03:00
|
|
|
already_AddRefed<Document> SetMouseButtonHandlingDocument(
|
|
|
|
Document* aDocument) {
|
|
|
|
RefPtr<Document> handlingDocument = mMouseButtonEventHandlingDocument;
|
2014-06-18 10:13:00 +04:00
|
|
|
mMouseButtonEventHandlingDocument = aDocument;
|
2014-06-18 10:13:01 +04:00
|
|
|
return handlingDocument.forget();
|
2010-11-06 08:04:11 +03:00
|
|
|
}
|
|
|
|
|
2018-04-26 17:37:47 +03:00
|
|
|
void NeedsFlushBeforeEventHandling(mozilla::dom::Element* aElement) {
|
2018-04-26 22:28:31 +03:00
|
|
|
if (mFocusedElement == aElement) {
|
2017-05-19 23:20:48 +03:00
|
|
|
mEventHandlingNeedsFlush = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-23 14:34:06 +03:00
|
|
|
bool CanSkipFocus(nsIContent* aContent);
|
2017-05-19 23:20:48 +03:00
|
|
|
|
|
|
|
void FlushBeforeEventHandlingIfNeeded(nsIContent* aContent) {
|
|
|
|
if (mEventHandlingNeedsFlush) {
|
2019-01-02 16:05:23 +03:00
|
|
|
nsCOMPtr<Document> doc = aContent->GetComposedDoc();
|
2017-05-19 23:20:48 +03:00
|
|
|
if (doc) {
|
|
|
|
mEventHandlingNeedsFlush = false;
|
|
|
|
doc->FlushPendingNotifications(mozilla::FlushType::Layout);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-22 07:28:43 +04:00
|
|
|
/**
|
|
|
|
* Update the caret with current mode (whether in caret browsing mode or not).
|
|
|
|
*/
|
|
|
|
void UpdateCaretForCaretBrowsingMode();
|
|
|
|
|
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
|
|
|
/**
|
|
|
|
* Returns the content node that would be focused if aWindow was in an
|
|
|
|
* active window. This will traverse down the frame hierarchy, starting at
|
|
|
|
* the given window aWindow. Sets aFocusedWindow to the window with the
|
|
|
|
* document containing aFocusedContent. If no element is focused,
|
|
|
|
* aFocusedWindow may be still be set -- this means that the document is
|
|
|
|
* focused but no element within it is focused.
|
|
|
|
*
|
|
|
|
* aWindow and aFocusedWindow must both be non-null.
|
|
|
|
*/
|
2017-09-07 16:54:49 +03:00
|
|
|
enum SearchRange {
|
|
|
|
// Return focused content in aWindow. So, aFocusedWindow is always aWindow.
|
|
|
|
eOnlyCurrentWindow,
|
|
|
|
// Return focused content in aWindow or one of all sub windows.
|
|
|
|
eIncludeAllDescendants,
|
|
|
|
// Return focused content in aWindow or one of visible sub windows.
|
|
|
|
eIncludeVisibleDescendants,
|
|
|
|
};
|
2018-04-26 17:37:47 +03:00
|
|
|
static mozilla::dom::Element* GetFocusedDescendant(
|
|
|
|
nsPIDOMWindowOuter* aWindow, SearchRange aSearchRange,
|
|
|
|
nsPIDOMWindowOuter** aFocusedWindow);
|
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
|
|
|
|
2019-04-05 11:12:27 +03:00
|
|
|
/**
|
|
|
|
* Helper function for MoveFocus which determines the next element
|
|
|
|
* to move the focus to and returns it in aNextContent.
|
|
|
|
*
|
|
|
|
* aWindow is the window to adjust the focus within, and aStart is
|
|
|
|
* the element to start navigation from. For tab key navigation,
|
|
|
|
* this should be the currently focused element.
|
|
|
|
*
|
|
|
|
* aType is the type passed to MoveFocus. If aNoParentTraversal is set,
|
|
|
|
* navigation is not done to parent documents and iteration returns to the
|
|
|
|
* beginning (or end) of the starting document.
|
|
|
|
*/
|
|
|
|
nsresult DetermineElementToMoveFocus(nsPIDOMWindowOuter* aWindow,
|
|
|
|
nsIContent* aStart, int32_t aType,
|
|
|
|
bool aNoParentTraversal,
|
|
|
|
nsIContent** aNextContent);
|
|
|
|
|
2019-04-29 23:06:22 +03:00
|
|
|
/**
|
|
|
|
* Given an element, which must be the focused element, activate the remote
|
|
|
|
* frame it embeds, if any.
|
|
|
|
*/
|
|
|
|
void ActivateRemoteFrameIfNeeded(mozilla::dom::Element&);
|
|
|
|
|
2019-04-12 11:16:47 +03:00
|
|
|
static uint32_t FocusOptionsToFocusManagerFlags(
|
|
|
|
const mozilla::dom::FocusOptions& aOptions);
|
|
|
|
|
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
|
|
|
/**
|
|
|
|
* Returns the content node that focus will be redirected to if aContent was
|
|
|
|
* focused. This is used for the special case of certain XUL elements such
|
2016-05-24 00:27:00 +03:00
|
|
|
* as textboxes or input number which redirect focus to an anonymous child.
|
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
|
|
|
*
|
|
|
|
* aContent must be non-null.
|
|
|
|
*
|
|
|
|
* XXXndeakin this should be removed eventually but I want to do that as
|
|
|
|
* followup work.
|
|
|
|
*/
|
2018-04-26 17:37:47 +03:00
|
|
|
static mozilla::dom::Element* GetRedirectedFocus(nsIContent* aContent);
|
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
|
|
|
|
2011-04-20 16:47:40 +04:00
|
|
|
/**
|
2011-11-27 15:51:52 +04:00
|
|
|
* Returns an InputContextAction cause for aFlags.
|
2011-04-20 16:47:40 +04:00
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
static InputContextAction::Cause GetFocusMoveActionCause(uint32_t aFlags);
|
2011-04-20 16:47:40 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool sMouseFocusesFormControl;
|
2010-08-09 20:15:47 +04:00
|
|
|
|
2013-11-24 23:35:34 +04:00
|
|
|
static void MarkUncollectableForCCGeneration(uint32_t aGeneration);
|
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
|
|
|
|
|
|
|
protected:
|
|
|
|
nsFocusManager();
|
|
|
|
~nsFocusManager();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ensure that the widget associated with the currently focused window is
|
|
|
|
* focused at the widget level.
|
|
|
|
*/
|
|
|
|
void EnsureCurrentWidgetFocused();
|
|
|
|
|
2014-11-27 16:28:26 +03:00
|
|
|
/**
|
|
|
|
* Activate or deactivate the window and send the activate/deactivate events.
|
|
|
|
*/
|
2016-01-30 20:05:36 +03:00
|
|
|
void ActivateOrDeactivate(nsPIDOMWindowOuter* aWindow, bool aActive);
|
2014-11-27 16:28:26 +03:00
|
|
|
|
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
|
|
|
/**
|
|
|
|
* Blur whatever is currently focused and focus aNewContent. aFlags is a
|
|
|
|
* bitmask of the flags defined in nsIFocusManager. If aFocusChanged is
|
|
|
|
* true, then the focus has actually shifted and the caret position will be
|
|
|
|
* updated to the new focus, aNewContent will be scrolled into view (unless
|
|
|
|
* a flag disables this) and the focus method for the window will be updated.
|
2010-11-16 00:12:50 +03:00
|
|
|
* If aAdjustWidget is false, don't change the widget focus state.
|
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
|
|
|
*
|
|
|
|
* All actual focus changes must use this method to do so. (as opposed
|
|
|
|
* to those that update the focus in an inactive window for instance).
|
|
|
|
*/
|
2019-04-23 04:34:24 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
2018-04-26 17:37:47 +03:00
|
|
|
void SetFocusInner(mozilla::dom::Element* aNewContent, int32_t aFlags,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aFocusChanged, bool aAdjustWidget);
|
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
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if aPossibleAncestor is the same as aWindow or an
|
|
|
|
* ancestor of aWindow.
|
|
|
|
*/
|
2016-01-30 20:05:36 +03:00
|
|
|
bool IsSameOrAncestor(nsPIDOMWindowOuter* aPossibleAncestor,
|
|
|
|
nsPIDOMWindowOuter* aWindow);
|
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
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the window that is the lowest common ancestor of both aWindow1
|
|
|
|
* and aWindow2, or null if they share no common ancestor.
|
|
|
|
*/
|
2016-01-30 20:05:36 +03:00
|
|
|
already_AddRefed<nsPIDOMWindowOuter> GetCommonAncestor(
|
|
|
|
nsPIDOMWindowOuter* aWindow1, nsPIDOMWindowOuter* aWindow2);
|
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
|
|
|
|
|
|
|
/**
|
|
|
|
* When aNewWindow is focused, adjust the ancestors of aNewWindow so that they
|
|
|
|
* also have their corresponding frames focused. Thus, one can start at
|
|
|
|
* the active top-level window and navigate down the currently focused
|
|
|
|
* elements for each frame in the tree to get to aNewWindow.
|
|
|
|
*/
|
2016-01-30 20:05:36 +03:00
|
|
|
void AdjustWindowFocus(nsPIDOMWindowOuter* aNewWindow, bool aCheckPermission);
|
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
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if aWindow is visible.
|
|
|
|
*/
|
2016-01-30 20:05:36 +03:00
|
|
|
bool IsWindowVisible(nsPIDOMWindowOuter* aWindow);
|
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
|
|
|
|
2010-04-21 17:13:08 +04:00
|
|
|
/**
|
|
|
|
* Returns true if aContent is a root element and not focusable.
|
|
|
|
* I.e., even if aContent is editable root element, this returns true when
|
|
|
|
* the document is in designMode.
|
|
|
|
*
|
|
|
|
* @param aContent must not be null and must be in a document.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsNonFocusableRoot(nsIContent* aContent);
|
2010-04-21 17:13:08 +04:00
|
|
|
|
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
|
|
|
/**
|
2019-04-17 10:01:34 +03:00
|
|
|
* First flushes the pending notifications to ensure the PresShell and frames
|
|
|
|
* are updated.
|
|
|
|
* Checks and returns aElement if it may be focused, another element node if
|
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
|
|
|
* the focus should be retargeted at another node, or null if the node
|
|
|
|
* cannot be focused. aFlags are the flags passed to SetFocus and similar
|
|
|
|
* methods.
|
|
|
|
*
|
|
|
|
* An element is focusable if it is in a document, the document isn't in
|
|
|
|
* print preview mode and the element has an nsIFrame where the
|
2019-04-17 10:01:34 +03:00
|
|
|
* IsFocusable method returns true. For <area> elements, there is no
|
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
|
|
|
* frame, so only the IsFocusable method on the content node must be
|
|
|
|
* true.
|
|
|
|
*/
|
2019-04-17 10:01:34 +03:00
|
|
|
mozilla::dom::Element* FlushAndCheckIfFocusable(
|
|
|
|
mozilla::dom::Element* aElement, uint32_t aFlags);
|
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
|
|
|
|
|
|
|
/**
|
2009-06-21 04:04:04 +04:00
|
|
|
* Blurs the currently focused element. Returns false if another element was
|
|
|
|
* focused as a result. This would mean that the caller should not proceed
|
|
|
|
* with a pending call to Focus. Normally, true would be returned.
|
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
|
|
|
*
|
|
|
|
* The currently focused element within aWindowToClear will be cleared.
|
|
|
|
* aWindowToClear may be null, which means that no window is cleared. This
|
|
|
|
* will be the case, for example, when lowering a window, as we want to fire
|
|
|
|
* a blur, but not actually change what element would be focused, so that
|
|
|
|
* the same element will be focused again when the window is raised.
|
|
|
|
*
|
|
|
|
* aAncestorWindowToFocus should be set to the common ancestor of the window
|
|
|
|
* that is being blurred and the window that is going to focused, when
|
|
|
|
* switching focus to a sibling window.
|
|
|
|
*
|
|
|
|
* aIsLeavingDocument should be set to true if the document/window is being
|
|
|
|
* blurred as well. Document/window blur events will be fired. It should be
|
|
|
|
* false if an element is the same document is about to be focused.
|
2010-11-16 00:12:50 +03:00
|
|
|
*
|
|
|
|
* If aAdjustWidget is false, don't change the widget focus state.
|
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
|
|
|
*/
|
2018-01-29 22:35:17 +03:00
|
|
|
// MOZ_CAN_RUN_SCRIPT_BOUNDARY for now, until we annotate callers.
|
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
2016-01-30 20:05:36 +03:00
|
|
|
bool Blur(nsPIDOMWindowOuter* aWindowToClear,
|
|
|
|
nsPIDOMWindowOuter* aAncestorWindowToFocus, bool aIsLeavingDocument,
|
2016-03-30 01:53:00 +03:00
|
|
|
bool aAdjustWidget, nsIContent* aContentToFocus = nullptr);
|
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
|
|
|
|
|
|
|
/**
|
|
|
|
* Focus an element in the active window and child frame.
|
|
|
|
*
|
|
|
|
* aWindow is the window containing the element aContent to focus.
|
|
|
|
*
|
|
|
|
* aFlags is the flags passed to the various focus methods in
|
|
|
|
* nsIFocusManager.
|
|
|
|
*
|
|
|
|
* aIsNewDocument should be true if a new document is being focused.
|
|
|
|
* Document/window focus events will be fired.
|
|
|
|
*
|
|
|
|
* aFocusChanged should be true if a new content node is being focused, so
|
|
|
|
* the focused content will be scrolled into view and the caret position
|
|
|
|
* will be updated. If false is passed, then a window is simply being
|
|
|
|
* refocused, for instance, due to a window being raised, or a tab is being
|
|
|
|
* switched to.
|
|
|
|
*
|
|
|
|
* If aFocusChanged is true, then the focus has moved to a new location.
|
|
|
|
* Otherwise, the focus is just being updated because the window was
|
|
|
|
* raised.
|
|
|
|
*
|
|
|
|
* aWindowRaised should be true if the window is being raised. In this case,
|
|
|
|
* command updaters will not be called.
|
2010-11-16 00:12:50 +03:00
|
|
|
*
|
|
|
|
* If aAdjustWidget is false, don't change the widget focus state.
|
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
|
|
|
*/
|
2019-04-23 04:34:24 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
2016-01-30 20:05:36 +03:00
|
|
|
void Focus(nsPIDOMWindowOuter* aWindow, mozilla::dom::Element* aContent,
|
2011-09-29 10:19:26 +04:00
|
|
|
uint32_t aFlags, bool aIsNewDocument, bool aFocusChanged,
|
|
|
|
bool aWindowRaised, bool aAdjustWidget,
|
2016-03-30 01:53:00 +03:00
|
|
|
nsIContent* aContentLostFocus = nullptr);
|
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
|
|
|
|
|
|
|
/**
|
2017-04-30 20:00:11 +03:00
|
|
|
* Send a focus or blur event at aTarget. It may be added to the delayed
|
|
|
|
* event queue if the document is suppressing events.
|
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
|
|
|
*
|
2015-09-02 09:08:00 +03:00
|
|
|
* aEventMessage should be either eFocus or eBlur.
|
2015-08-26 15:56:59 +03:00
|
|
|
* For blur events, aFocusMethod should normally be non-zero.
|
2009-10-01 21:53:10 +04:00
|
|
|
*
|
|
|
|
* aWindowRaised should only be true if called from WindowRaised.
|
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
|
|
|
*/
|
2015-08-26 15:56:59 +03:00
|
|
|
void SendFocusOrBlurEvent(
|
2019-04-30 04:35:30 +03:00
|
|
|
mozilla::EventMessage aEventMessage, mozilla::PresShell* aPresShell,
|
2019-01-02 16:05:23 +03:00
|
|
|
Document* aDocument, nsISupports* aTarget, uint32_t aFocusMethod,
|
2016-03-30 01:53:00 +03:00
|
|
|
bool aWindowRaised, bool aIsRefocus = false,
|
|
|
|
mozilla::dom::EventTarget* aRelatedTarget = nullptr);
|
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
|
|
|
|
2016-10-07 04:39:53 +03:00
|
|
|
/**
|
2017-04-30 20:00:11 +03:00
|
|
|
* Fire a focus or blur event at aTarget.
|
|
|
|
*
|
|
|
|
* aEventMessage should be either eFocus or eBlur.
|
|
|
|
* For blur events, aFocusMethod should normally be non-zero.
|
|
|
|
*
|
|
|
|
* aWindowRaised should only be true if called from WindowRaised.
|
|
|
|
*/
|
|
|
|
void FireFocusOrBlurEvent(
|
2019-04-30 04:35:30 +03:00
|
|
|
mozilla::EventMessage aEventMessage, mozilla::PresShell* aPresShell,
|
2017-04-30 20:00:11 +03:00
|
|
|
nsISupports* aTarget, bool aWindowRaised, bool aIsRefocus = false,
|
|
|
|
mozilla::dom::EventTarget* aRelatedTarget = nullptr);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fire a focusin or focusout event
|
2016-10-07 04:39:53 +03:00
|
|
|
*
|
|
|
|
* aEventMessage should be either eFocusIn or eFocusOut.
|
|
|
|
*
|
|
|
|
* aTarget is the content the event will fire on (the object that gained
|
|
|
|
* focus for focusin, the object blurred for focusout).
|
|
|
|
*
|
|
|
|
* aCurrentFocusedWindow is the window focused before the focus/blur event
|
|
|
|
* was fired.
|
|
|
|
*
|
|
|
|
* aCurrentFocusedContent is the content focused before the focus/blur event
|
|
|
|
* was fired.
|
|
|
|
*
|
|
|
|
* aRelatedTarget is the content related to the event (the object
|
|
|
|
* losing focus for focusin, the object getting focus for focusout).
|
|
|
|
*/
|
2017-04-30 20:00:11 +03:00
|
|
|
void FireFocusInOrOutEvent(
|
2019-04-30 04:35:30 +03:00
|
|
|
mozilla::EventMessage aEventMessage, mozilla::PresShell* aPresShell,
|
2016-10-07 04:39:53 +03:00
|
|
|
nsISupports* aTarget, nsPIDOMWindowOuter* aCurrentFocusedWindow,
|
|
|
|
nsIContent* aCurrentFocusedContent,
|
|
|
|
mozilla::dom::EventTarget* aRelatedTarget = nullptr);
|
|
|
|
|
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
|
|
|
/**
|
|
|
|
* Scrolls aContent into view unless the FLAG_NOSCROLL flag is set.
|
|
|
|
*/
|
2019-04-23 04:34:24 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
void ScrollIntoView(mozilla::PresShell* aPresShell, nsIContent* aContent,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aFlags);
|
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
|
|
|
|
|
|
|
/**
|
|
|
|
* Raises the top-level window aWindow at the widget level.
|
|
|
|
*/
|
2016-01-30 20:05:36 +03:00
|
|
|
void RaiseWindow(nsPIDOMWindowOuter* aWindow);
|
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
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the caret positon and visibility to match the focus.
|
|
|
|
*
|
|
|
|
* aMoveCaretToFocus should be true to move the caret to aContent.
|
|
|
|
*
|
|
|
|
* aUpdateVisibility should be true to update whether the caret is
|
|
|
|
* visible or not.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
void UpdateCaret(bool aMoveCaretToFocus, bool aUpdateVisibility,
|
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* aContent);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper method to move the caret to the focused element aContent.
|
|
|
|
*/
|
2019-04-30 04:35:30 +03:00
|
|
|
void MoveCaretToFocus(mozilla::PresShell* aPresShell, nsIContent* aContent);
|
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
|
|
|
|
|
|
|
/**
|
|
|
|
* Makes the caret visible or not, depending on aVisible.
|
|
|
|
*/
|
2019-04-30 04:35:30 +03:00
|
|
|
nsresult SetCaretVisible(mozilla::PresShell* aPresShell, bool aVisible,
|
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* aContent);
|
|
|
|
|
|
|
|
// the remaining functions are used for tab key and document-navigation
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves the start and end points of the current selection for
|
|
|
|
* aDocument and stores them in aStartContent and aEndContent.
|
|
|
|
*/
|
2019-04-30 04:35:30 +03:00
|
|
|
nsresult GetSelectionLocation(Document* aDocument,
|
|
|
|
mozilla::PresShell* aPresShell,
|
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** aStartContent,
|
|
|
|
nsIContent** aEndContent);
|
|
|
|
|
2018-01-26 18:49:06 +03:00
|
|
|
/**
|
|
|
|
* Retrieve the next tabbable element in scope owned by aOwner, using
|
|
|
|
* focusability and tabindex to determine the tab order.
|
|
|
|
*
|
|
|
|
* aOwner is the owner of scope to search in.
|
|
|
|
*
|
|
|
|
* aStartContent is the starting point for this call of this method.
|
|
|
|
*
|
2018-04-28 16:07:06 +03:00
|
|
|
* aOriginalStartContent is the initial starting point for sequential
|
|
|
|
* navigation.
|
|
|
|
*
|
2018-01-26 18:49:06 +03:00
|
|
|
* aForward should be true for forward navigation or false for backward
|
|
|
|
* navigation.
|
|
|
|
*
|
|
|
|
* aCurrentTabIndex is the current tabindex.
|
|
|
|
*
|
|
|
|
* aIgnoreTabIndex to ignore the current tabindex and find the element
|
|
|
|
* irrespective or the tab index.
|
|
|
|
*
|
2018-04-28 16:07:06 +03:00
|
|
|
* aForDocumentNavigation informs whether we're navigating only through
|
|
|
|
* documents.
|
|
|
|
*
|
2018-01-26 18:49:06 +03:00
|
|
|
* aSkipOwner to skip owner while searching. The flag is set when caller is
|
|
|
|
* |GetNextTabbableContent| in order to let caller handle owner.
|
|
|
|
*
|
|
|
|
* NOTE:
|
|
|
|
* Consider the method searches downwards in flattened subtree
|
|
|
|
* rooted at aOwner.
|
|
|
|
*/
|
|
|
|
nsIContent* GetNextTabbableContentInScope(
|
|
|
|
nsIContent* aOwner, nsIContent* aStartContent,
|
2018-04-28 16:07:06 +03:00
|
|
|
nsIContent* aOriginalStartContent, bool aForward,
|
2018-01-26 18:49:06 +03:00
|
|
|
int32_t aCurrentTabIndex, bool aIgnoreTabIndex,
|
2018-04-28 16:07:06 +03:00
|
|
|
bool aForDocumentNavigation, bool aSkipOwner);
|
2018-01-26 18:49:06 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieve the next tabbable element in scope including aStartContent
|
|
|
|
* and the scope's ancestor scopes, using focusability and tabindex to
|
|
|
|
* determine the tab order.
|
|
|
|
*
|
2019-01-22 10:41:36 +03:00
|
|
|
* aStartOwner is the scope owner of the aStartContent.
|
|
|
|
*
|
2018-01-26 18:49:06 +03:00
|
|
|
* aStartContent an in/out paremeter. It as input is the starting point
|
|
|
|
* for this call of this method; as output it is the shadow host in
|
|
|
|
* light DOM if the next tabbable element is not found in shadow DOM,
|
|
|
|
* in order to continue searching in light DOM.
|
|
|
|
*
|
2018-04-28 16:07:06 +03:00
|
|
|
* aOriginalStartContent is the initial starting point for sequential
|
|
|
|
* navigation.
|
|
|
|
*
|
2018-01-26 18:49:06 +03:00
|
|
|
* aForward should be true for forward navigation or false for backward
|
|
|
|
* navigation.
|
|
|
|
*
|
|
|
|
* aCurrentTabIndex returns tab index of shadow host in light DOM if the
|
|
|
|
* next tabbable element is not found in shadow DOM, in order to continue
|
|
|
|
* searching in light DOM.
|
|
|
|
*
|
|
|
|
* aIgnoreTabIndex to ignore the current tabindex and find the element
|
|
|
|
* irrespective or the tab index.
|
|
|
|
*
|
2018-04-28 16:07:06 +03:00
|
|
|
* aForDocumentNavigation informs whether we're navigating only through
|
|
|
|
* documents.
|
|
|
|
*
|
2018-01-26 18:49:06 +03:00
|
|
|
* NOTE:
|
|
|
|
* Consider the method searches upwards in all shadow host- or slot-rooted
|
|
|
|
* flattened subtrees that contains aStartContent as non-root, except
|
|
|
|
* the flattened subtree rooted at shadow host in light DOM.
|
|
|
|
*/
|
|
|
|
nsIContent* GetNextTabbableContentInAncestorScopes(
|
2019-01-22 10:41:36 +03:00
|
|
|
nsIContent* aStartOwner, nsIContent** aStartContent,
|
|
|
|
nsIContent* aOriginalStartContent, bool aForward,
|
|
|
|
int32_t* aCurrentTabIndex, bool aIgnoreTabIndex,
|
2018-04-28 16:07:06 +03:00
|
|
|
bool aForDocumentNavigation);
|
2018-01-26 18:49:06 +03:00
|
|
|
|
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
|
|
|
/**
|
|
|
|
* Retrieve the next tabbable element within a document, using focusability
|
|
|
|
* and tabindex to determine the tab order. The element is returned in
|
|
|
|
* aResultContent.
|
|
|
|
*
|
|
|
|
* aRootContent is the root node -- nodes above this will not be examined.
|
|
|
|
* Typically this will be the root node of a document, but could also be
|
|
|
|
* a popup node.
|
|
|
|
*
|
|
|
|
* aOriginalStartContent is the content which was originally the starting
|
|
|
|
* node, in the case of recursive or looping calls.
|
|
|
|
*
|
|
|
|
* aStartContent is the starting point for this call of this method.
|
2009-11-20 15:09:33 +03:00
|
|
|
* If aStartContent doesn't have visual representation, the next content
|
|
|
|
* object, which does have a primary frame, will be used as a start.
|
|
|
|
* If that content object is focusable, the method may return it.
|
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
|
|
|
*
|
|
|
|
* aForward should be true for forward navigation or false for backward
|
|
|
|
* navigation.
|
|
|
|
*
|
|
|
|
* aCurrentTabIndex is the current tabindex.
|
|
|
|
*
|
|
|
|
* aIgnoreTabIndex to ignore the current tabindex and find the element
|
|
|
|
* irrespective or the tab index. This will be true when a selection is
|
|
|
|
* active, since we just want to focus the next element in tree order
|
|
|
|
* from where the selection is. Similarly, if the starting element isn't
|
|
|
|
* focusable, since it doesn't really have a defined tab index.
|
|
|
|
*/
|
|
|
|
nsresult GetNextTabbableContent(
|
2019-04-30 04:35:30 +03:00
|
|
|
mozilla::PresShell* aPresShell, nsIContent* aRootContent,
|
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* aOriginalStartContent, nsIContent* aStartContent,
|
2012-08-22 19:56:38 +04:00
|
|
|
bool aForward, int32_t aCurrentTabIndex, bool aIgnoreTabIndex,
|
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
|
|
|
bool aForDocumentNavigation, nsIContent** aResultContent);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the next tabbable image map area and returns it.
|
|
|
|
*
|
|
|
|
* aForward should be true for forward navigation or false for backward
|
|
|
|
* navigation.
|
|
|
|
*
|
|
|
|
* aCurrentTabIndex is the current tabindex.
|
|
|
|
*
|
|
|
|
* aImageContent is the image.
|
|
|
|
*
|
|
|
|
* aStartContent is the current image map area.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
nsIContent* GetNextTabbableMapArea(bool aForward, int32_t aCurrentTabIndex,
|
2017-12-07 21:13:50 +03:00
|
|
|
mozilla::dom::Element* aImageContent,
|
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* aStartContent);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the next valid tabindex value after aCurrentTabIndex, if aForward
|
|
|
|
* is true, or the previous tabindex value if aForward is false. aParent is
|
|
|
|
* the node from which to start looking for tab indicies.
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t GetNextTabIndex(nsIContent* aParent, int32_t aCurrentTabIndex,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aForward);
|
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
|
|
|
|
2015-07-13 13:07:49 +03:00
|
|
|
/**
|
|
|
|
* Focus the first focusable content within the document with a root node of
|
|
|
|
* aRootContent. For content documents, this will be aRootContent itself, but
|
|
|
|
* for chrome documents, this will locate the next focusable content.
|
|
|
|
*/
|
2017-12-07 21:13:50 +03:00
|
|
|
nsresult FocusFirst(mozilla::dom::Element* aRootContent,
|
|
|
|
nsIContent** aNextContent);
|
2015-07-13 13:07:49 +03:00
|
|
|
|
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
|
|
|
/**
|
|
|
|
* Retrieves and returns the root node from aDocument to be focused. Will
|
|
|
|
* return null if the root node cannot be focused. There are several reasons
|
|
|
|
* for this:
|
|
|
|
*
|
2015-07-13 13:07:49 +03:00
|
|
|
* - if aForDocumentNavigation is false and aWindow is a chrome shell.
|
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
|
|
|
* - if aCheckVisibility is true and the aWindow is not visible.
|
|
|
|
* - if aDocument is a frameset document.
|
|
|
|
*/
|
2017-12-07 21:13:50 +03:00
|
|
|
mozilla::dom::Element* GetRootForFocus(nsPIDOMWindowOuter* aWindow,
|
2019-01-02 16:05:23 +03:00
|
|
|
Document* aDocument,
|
2017-12-07 21:13:50 +03:00
|
|
|
bool aForDocumentNavigation,
|
|
|
|
bool aCheckVisibility);
|
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
|
|
|
|
|
|
|
/**
|
2015-07-13 13:07:49 +03:00
|
|
|
* Retrieves and returns the root node as with GetRootForFocus but only if
|
|
|
|
* aContent is a frame with a valid child document.
|
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
|
|
|
*/
|
2017-12-07 21:13:50 +03:00
|
|
|
mozilla::dom::Element* GetRootForChildDocument(nsIContent* aContent);
|
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
|
|
|
|
|
|
|
/**
|
|
|
|
* Retreives a focusable element within the current selection of aWindow.
|
|
|
|
* Currently, this only detects links.
|
2017-07-06 15:00:35 +03:00
|
|
|
*
|
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
|
|
|
* This is used when MoveFocus is called with a type of MOVEFOCUS_CARET,
|
|
|
|
* which is used, for example, to focus links as the caret is moved over
|
|
|
|
* them.
|
|
|
|
*/
|
2016-01-30 20:05:36 +03:00
|
|
|
void GetFocusInSelection(nsPIDOMWindowOuter* aWindow,
|
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* aStartSelection,
|
|
|
|
nsIContent* aEndSelection,
|
|
|
|
nsIContent** aFocusedContent);
|
|
|
|
|
2011-06-01 05:46:56 +04:00
|
|
|
private:
|
|
|
|
// Notify that the focus state of aContent has changed. Note that
|
|
|
|
// we need to pass in whether the window should show a focus ring
|
|
|
|
// before the SetFocusedNode call on it happened when losing focus
|
|
|
|
// and after the SetFocusedNode call when gaining focus, which is
|
|
|
|
// why that information needs to be an explicit argument instead of
|
|
|
|
// just passing in the window and asking it whether it should show
|
|
|
|
// focus rings: in the losing focus case that information could be
|
|
|
|
// wrong..
|
|
|
|
static void NotifyFocusStateChange(nsIContent* aContent,
|
2017-05-03 13:41:24 +03:00
|
|
|
nsIContent* aContentToFocus,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aWindowShouldShowFocusRing,
|
|
|
|
bool aGettingFocus);
|
2011-06-01 05:46:56 +04:00
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
void SetFocusedWindowInternal(nsPIDOMWindowOuter* aWindow);
|
2013-03-24 14:32:44 +04:00
|
|
|
|
2018-04-28 16:07:06 +03:00
|
|
|
bool TryDocumentNavigation(nsIContent* aCurrentContent,
|
|
|
|
bool* aCheckSubDocument,
|
|
|
|
nsIContent** aResultContent);
|
|
|
|
|
|
|
|
bool TryToMoveFocusToSubDocument(nsIContent* aCurrentContent,
|
|
|
|
nsIContent* aOriginalStartContent,
|
|
|
|
bool aForward, bool aForDocumentNavigation,
|
|
|
|
nsIContent** aResultContent);
|
|
|
|
|
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
|
|
|
// the currently active and front-most top-most window
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> mActiveWindow;
|
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
|
|
|
|
|
|
|
// the child or top-level window that is currently focused. This window will
|
|
|
|
// either be the same window as mActiveWindow or a descendant of it.
|
2013-03-24 14:32:44 +04:00
|
|
|
// Except during shutdown use SetFocusedWindowInternal to set mFocusedWindow!
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> mFocusedWindow;
|
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
|
|
|
|
|
|
|
// the currently focused content, which is always inside mFocusedWindow. This
|
|
|
|
// is a cached copy of the mFocusedWindow's current content. This may be null
|
|
|
|
// if no content is focused.
|
2018-04-26 22:28:31 +03:00
|
|
|
RefPtr<mozilla::dom::Element> mFocusedElement;
|
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
|
|
|
|
|
|
|
// these fields store a content node temporarily while it is being focused
|
|
|
|
// or blurred to ensure that a recursive call doesn't refire the same event.
|
|
|
|
// They will always be cleared afterwards.
|
|
|
|
nsCOMPtr<nsIContent> mFirstBlurEvent;
|
|
|
|
nsCOMPtr<nsIContent> mFirstFocusEvent;
|
|
|
|
|
|
|
|
// keep track of a window while it is being lowered
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> mWindowBeingLowered;
|
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
|
|
|
|
|
|
|
// synchronized actions cannot be interrupted with events, so queue these up
|
|
|
|
// and fire them later.
|
|
|
|
nsTArray<nsDelayedBlurOrFocusEvent> mDelayedBlurFocusEvents;
|
|
|
|
|
2014-06-18 10:13:00 +04:00
|
|
|
// A document which is handling a mouse button event.
|
2010-11-06 08:04:11 +03:00
|
|
|
// When a mouse down event process is finished, ESM sets focus to the target
|
2014-06-18 10:13:00 +04:00
|
|
|
// content if it's not consumed. Therefore, while DOM event handlers are
|
|
|
|
// handling mouse down events or preceding mosue down event is consumed but
|
|
|
|
// handling mouse up events, they should be able to steal focus from any
|
|
|
|
// elements even if focus is in chrome content. So, if this isn't nullptr
|
|
|
|
// and the caller can access the document node, the caller should succeed in
|
|
|
|
// moving focus.
|
2019-01-02 16:05:23 +03:00
|
|
|
RefPtr<Document> mMouseButtonEventHandlingDocument;
|
2010-11-06 08:04:11 +03:00
|
|
|
|
2017-05-19 23:20:48 +03:00
|
|
|
// If set to true, layout of the document of the event target should be
|
|
|
|
// flushed before handling focus depending events.
|
|
|
|
bool mEventHandlingNeedsFlush;
|
|
|
|
|
2012-01-13 16:42:18 +04:00
|
|
|
static bool sTestMode;
|
|
|
|
|
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
|
|
|
// the single focus manager
|
2009-08-14 06:09:49 +04:00
|
|
|
static nsFocusManager* sInstance;
|
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
|
|
|
};
|
|
|
|
|
|
|
|
nsresult NS_NewFocusManager(nsIFocusManager** aResult);
|
|
|
|
|
|
|
|
#endif
|