Don't QI a node to nsIDOMElement and back to nsIContent for every call to nsEventStateManager::GetContentState. (Bug 509889) r=enndeakin

This commit is contained in:
L. David Baron 2009-08-13 19:09:49 -07:00
parent c163cbee6e
commit ed026ed2f0
3 changed files with 13 additions and 12 deletions

View File

@ -3927,15 +3927,9 @@ nsEventStateManager::GetContentState(nsIContent *aContent, PRInt32& aState)
}
}
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
if (fm) {
nsCOMPtr<nsIDOMElement> focusedElement;
fm->GetFocusedElement(getter_AddRefs(focusedElement));
nsCOMPtr<nsIContent> focusedContent = do_QueryInterface(focusedElement);
if (aContent == focusedContent) {
aState |= NS_EVENT_STATE_FOCUS;
}
nsFocusManager* fm = nsFocusManager::GetFocusManager();
if (fm && aContent == fm->GetFocusedContent()) {
aState |= NS_EVENT_STATE_FOCUS;
}
if (aContent == mDragOverContent) {
aState |= NS_EVENT_STATE_DRAGOVER;

View File

@ -149,7 +149,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
nsIFocusManager* nsFocusManager::sInstance = nsnull;
nsFocusManager* nsFocusManager::sInstance = nsnull;
nsFocusManager::nsFocusManager()
{ }

View File

@ -73,7 +73,14 @@ public:
/**
* Retrieve the single focus manager.
*/
static nsIFocusManager* GetFocusManager() { return sInstance; }
static nsFocusManager* GetFocusManager() { return sInstance; }
/**
* A faster version of nsIFocusManager::GetFocusedElement, returning a
* raw nsIContent pointer (instead of having AddRef-ed nsIDOMElement
* pointer filled in to an out-parameter).
*/
nsIContent* GetFocusedContent() { return mFocusedContent; }
/**
* Returns the content node that would be focused if aWindow was in an
@ -437,7 +444,7 @@ protected:
nsTArray<nsDelayedBlurOrFocusEvent> mDelayedBlurFocusEvents;
// the single focus manager
static nsIFocusManager* sInstance;
static nsFocusManager* sInstance;
};
nsresult