зеркало из https://github.com/mozilla/pjs.git
Bug 560902 - Optimize nsFocusManager::ContentRemoved, r=enndeakin+sicking
--HG-- extra : rebase_source : 69c72c67341dd27dbd5a526c59c5ee52d2b6a813
This commit is contained in:
Родитель
3f5e5f50d6
Коммит
e24a8744d9
|
@ -58,6 +58,7 @@
|
|||
#include "nsIObserver.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#ifdef MOZ_SMIL
|
||||
#include "nsSMILAnimationController.h"
|
||||
#endif // MOZ_SMIL
|
||||
|
@ -72,7 +73,6 @@ class nsIStyleRule;
|
|||
class nsICSSStyleSheet;
|
||||
class nsIViewManager;
|
||||
class nsIScriptGlobalObject;
|
||||
class nsPIDOMWindow;
|
||||
class nsIDOMEvent;
|
||||
class nsIDOMEventTarget;
|
||||
class nsIDeviceContext;
|
||||
|
@ -115,8 +115,8 @@ class Link;
|
|||
} // namespace mozilla
|
||||
|
||||
#define NS_IDOCUMENT_IID \
|
||||
{ 0x4a0c9bfa, 0xef60, 0x4bb2, \
|
||||
{ 0x87, 0x5e, 0xac, 0xdb, 0xe8, 0xfe, 0xa1, 0xb5 } }
|
||||
{ 0x56d981ce, 0x7f03, 0x4d90, \
|
||||
{ 0xb2, 0x40, 0x72, 0x08, 0xb6, 0x28, 0x73, 0x06 } }
|
||||
|
||||
// Flag for AddStyleSheet().
|
||||
#define NS_STYLESHEET_FROM_CATALOG (1 << 0)
|
||||
|
@ -633,7 +633,10 @@ public:
|
|||
/**
|
||||
* Return the window containing the document (the outer window).
|
||||
*/
|
||||
virtual nsPIDOMWindow *GetWindow() = 0;
|
||||
nsPIDOMWindow *GetWindow()
|
||||
{
|
||||
return mWindow ? mWindow->GetOuterWindow() : GetWindowInternal();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the inner window used as the script compilation scope for
|
||||
|
@ -1348,6 +1351,9 @@ protected:
|
|||
|
||||
nsPropertyTable* GetExtraPropertyTable(PRUint16 aCategory);
|
||||
|
||||
// Never ever call this. Only call GetWindow!
|
||||
virtual nsPIDOMWindow *GetWindowInternal() = 0;
|
||||
|
||||
// Never ever call this. Only call GetInnerWindow!
|
||||
virtual nsPIDOMWindow *GetInnerWindowInternal() = 0;
|
||||
|
||||
|
|
|
@ -3817,11 +3817,9 @@ nsDocument::SetScriptHandlingObject(nsIScriptGlobalObject* aScriptObject)
|
|||
}
|
||||
|
||||
nsPIDOMWindow *
|
||||
nsDocument::GetWindow()
|
||||
nsDocument::GetWindowInternal()
|
||||
{
|
||||
if (mWindow) {
|
||||
return mWindow->GetOuterWindow();
|
||||
}
|
||||
NS_ASSERTION(!mWindow, "This should not be called when mWindow is not null!");
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(GetScriptGlobalObject()));
|
||||
|
||||
|
|
|
@ -649,11 +649,6 @@ public:
|
|||
|
||||
virtual nsIScriptGlobalObject* GetScopeObject();
|
||||
|
||||
/**
|
||||
* Return the window containing the document (the outer window).
|
||||
*/
|
||||
virtual nsPIDOMWindow *GetWindow();
|
||||
|
||||
/**
|
||||
* Get the script loader for this document
|
||||
*/
|
||||
|
@ -1011,6 +1006,7 @@ protected:
|
|||
const nsAString& aType,
|
||||
PRBool aPersisted);
|
||||
|
||||
virtual nsPIDOMWindow *GetWindowInternal();
|
||||
virtual nsPIDOMWindow *GetInnerWindowInternal();
|
||||
|
||||
// nsContentList match functions for GetElementsByClassName
|
||||
|
|
|
@ -4282,7 +4282,7 @@ nsEventStateManager::ContentRemoved(nsIDocument* aDocument, nsIContent* aContent
|
|||
{
|
||||
// inform the focus manager that the content is being removed. If this
|
||||
// content is focused, the focus will be removed without firing events.
|
||||
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
nsFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
if (fm)
|
||||
fm->ContentRemoved(aDocument, aContent);
|
||||
|
||||
|
|
|
@ -742,7 +742,7 @@ nsFocusManager::WindowLowered(nsIDOMWindow* aWindow)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsresult
|
||||
nsFocusManager::ContentRemoved(nsIDocument* aDocument, nsIContent* aContent)
|
||||
{
|
||||
NS_ENSURE_ARG(aDocument);
|
||||
|
@ -754,7 +754,7 @@ nsFocusManager::ContentRemoved(nsIDocument* aDocument, nsIContent* aContent)
|
|||
|
||||
// if the content is currently focused in the window, or is an ancestor
|
||||
// of the currently focused element, reset the focus within that window.
|
||||
nsCOMPtr<nsIContent> content = window->GetFocusedNode();
|
||||
nsIContent* content = window->GetFocusedNode();
|
||||
if (content && nsContentUtils::ContentIsDescendantOf(content, aContent)) {
|
||||
window->SetFocusedNode(nsnull);
|
||||
|
||||
|
|
|
@ -83,6 +83,11 @@ public:
|
|||
*/
|
||||
nsIContent* GetFocusedContent() { return mFocusedContent; }
|
||||
|
||||
/**
|
||||
* Called when content has been removed.
|
||||
*/
|
||||
nsresult ContentRemoved(nsIDocument* aDocument, nsIContent* aContent);
|
||||
|
||||
/**
|
||||
* Returns the content node that would be focused if aWindow was in an
|
||||
* active window. This will traverse down the frame hierarchy, starting at
|
||||
|
|
|
@ -610,7 +610,16 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(nsTimeout, AddRef)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(nsTimeout, Release)
|
||||
|
||||
|
||||
nsPIDOMWindow::nsPIDOMWindow(nsPIDOMWindow *aOuterWindow)
|
||||
: mFrameElement(nsnull), mDocShell(nsnull), mModalStateDepth(0),
|
||||
mRunningTimeout(nsnull), mMutationBits(0), mIsDocumentLoaded(PR_FALSE),
|
||||
mIsHandlingResizeEvent(PR_FALSE), mIsInnerWindow(aOuterWindow != nsnull),
|
||||
mMayHavePaintEventListener(PR_FALSE),
|
||||
mIsModalContentWindow(PR_FALSE), mIsActive(PR_FALSE),
|
||||
mInnerWindow(nsnull), mOuterWindow(aOuterWindow) {}
|
||||
|
||||
nsPIDOMWindow::~nsPIDOMWindow() {}
|
||||
|
||||
//*****************************************************************************
|
||||
//*** nsGlobalWindow: Object Management
|
||||
//*****************************************************************************
|
||||
|
@ -6912,14 +6921,6 @@ nsGlobalWindow::SetChromeEventHandler(nsPIDOMEventTarget* aChromeEventHandler)
|
|||
}
|
||||
}
|
||||
|
||||
nsIContent*
|
||||
nsGlobalWindow::GetFocusedNode()
|
||||
{
|
||||
FORWARD_TO_INNER(GetFocusedNode, (), NS_OK);
|
||||
|
||||
return mFocusedNode;
|
||||
}
|
||||
|
||||
void
|
||||
nsGlobalWindow::SetFocusedNode(nsIContent* aNode,
|
||||
PRUint32 aFocusMethod,
|
||||
|
|
|
@ -660,7 +660,6 @@ protected:
|
|||
nsIntSize DevToCSSIntPixels(nsIntSize px);
|
||||
nsIntSize CSSToDevIntPixels(nsIntSize px);
|
||||
|
||||
virtual nsIContent* GetFocusedNode();
|
||||
virtual void SetFocusedNode(nsIContent* aNode,
|
||||
PRUint32 aFocusMethod = 0,
|
||||
PRBool aNeedsFocus = PR_FALSE);
|
||||
|
@ -803,10 +802,6 @@ protected:
|
|||
|
||||
PRUint32 mTimeoutsSuspendDepth;
|
||||
|
||||
// the element within the document that is currently focused when this
|
||||
// window is active
|
||||
nsCOMPtr<nsIContent> mFocusedNode;
|
||||
|
||||
// the method that was used to focus mFocusedNode
|
||||
PRUint32 mFocusMethod;
|
||||
|
||||
|
|
|
@ -78,8 +78,8 @@ class nsIArray;
|
|||
class nsPIWindowRoot;
|
||||
|
||||
#define NS_PIDOMWINDOW_IID \
|
||||
{ 0xC5CB154D, 0x17C0, 0x49E9, \
|
||||
{ 0x9C, 0x83, 0xFF, 0xC7, 0x2C, 0x93, 0xAF, 0x24 } }
|
||||
{ 0x7cbe5277, 0x5de8, 0x45e4, \
|
||||
{ 0x9c, 0x2d, 0x81, 0x37, 0xa9, 0x5b, 0x42, 0xc6 } }
|
||||
|
||||
class nsPIDOMWindow : public nsIDOMWindowInternal
|
||||
{
|
||||
|
@ -432,7 +432,13 @@ public:
|
|||
* DO NOT CALL EITHER OF THESE METHODS DIRECTLY. USE THE FOCUS MANAGER
|
||||
* INSTEAD.
|
||||
*/
|
||||
virtual nsIContent* GetFocusedNode() = 0;
|
||||
nsIContent* GetFocusedNode()
|
||||
{
|
||||
if (IsOuterWindow()) {
|
||||
return mInnerWindow ? mInnerWindow->mFocusedNode.get() : nsnull;
|
||||
}
|
||||
return mFocusedNode;
|
||||
}
|
||||
virtual void SetFocusedNode(nsIContent* aNode,
|
||||
PRUint32 aFocusMethod = 0,
|
||||
PRBool aNeedsFocus = PR_FALSE) = 0;
|
||||
|
@ -512,15 +518,9 @@ protected:
|
|||
// be null if and only if the created window itself is an outer
|
||||
// window. In all other cases aOuterWindow should be the outer
|
||||
// window for the inner window that is being created.
|
||||
nsPIDOMWindow(nsPIDOMWindow *aOuterWindow)
|
||||
: mFrameElement(nsnull), mDocShell(nsnull), mModalStateDepth(0),
|
||||
mRunningTimeout(nsnull), mMutationBits(0), mIsDocumentLoaded(PR_FALSE),
|
||||
mIsHandlingResizeEvent(PR_FALSE), mIsInnerWindow(aOuterWindow != nsnull),
|
||||
mMayHavePaintEventListener(PR_FALSE),
|
||||
mIsModalContentWindow(PR_FALSE), mIsActive(PR_FALSE),
|
||||
mInnerWindow(nsnull), mOuterWindow(aOuterWindow)
|
||||
{
|
||||
}
|
||||
nsPIDOMWindow(nsPIDOMWindow *aOuterWindow);
|
||||
|
||||
~nsPIDOMWindow();
|
||||
|
||||
void SetChromeEventHandlerInternal(nsPIDOMEventTarget* aChromeEventHandler) {
|
||||
mChromeEventHandler = aChromeEventHandler;
|
||||
|
@ -558,6 +558,10 @@ protected:
|
|||
// And these are the references between inner and outer windows.
|
||||
nsPIDOMWindow *mInnerWindow;
|
||||
nsPIDOMWindow *mOuterWindow;
|
||||
|
||||
// the element within the document that is currently focused when this
|
||||
// window is active
|
||||
nsCOMPtr<nsIContent> mFocusedNode;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
interface nsIDocument;
|
||||
interface nsIContent;
|
||||
|
||||
[scriptable, uuid(39BB7C9F-10FC-4345-B381-5E6B3FF3A277)]
|
||||
[scriptable, uuid(5cb91200-53f6-4d35-989d-1d28ad80a0d4)]
|
||||
/**
|
||||
* The focus manager deals with all focus related behaviour. Only one element
|
||||
* in the entire application may have the focus at a time; this element
|
||||
|
@ -243,12 +243,6 @@ interface nsIFocusManager : nsISupports
|
|||
*/
|
||||
[noscript] void windowLowered(in nsIDOMWindow aWindow);
|
||||
|
||||
/**
|
||||
* Called when content has been removed.
|
||||
*/
|
||||
[noscript] void contentRemoved(in nsIDocument aDocument,
|
||||
in nsIContent aElement);
|
||||
|
||||
/**
|
||||
* Called when a new document in a window is shown.
|
||||
*
|
||||
|
|
Загрузка…
Ссылка в новой задаче