Bug 581916 - Fetching mouse cursor from window trough DOM window utils API. r=Olli.Pettay a=approval2.0

This commit is contained in:
Juha Kotiranta 2010-09-17 11:56:53 -07:00
Родитель b84267821a
Коммит bbbc2fd341
4 изменённых файлов: 50 добавлений и 1 удалений

Просмотреть файл

@ -186,6 +186,7 @@ static PRInt32 sChromeAccessModifier = 0, sContentAccessModifier = 0;
PRInt32 nsEventStateManager::sUserInputEventDepth = 0;
PRBool nsEventStateManager::sNormalLMouseEventInProcess = PR_FALSE;
nsEventStateManager* nsEventStateManager::sActiveESM = nsnull;
nsIDocument* nsEventStateManager::sMouseOverDocument = nsnull;
static PRUint32 gMouseOrKeyboardEventCounter = 0;
static nsITimer* gUserInteractionTimer = nsnull;
@ -860,6 +861,9 @@ nsEventStateManager::~nsEventStateManager()
if (mClickHoldContextMenu)
KillClickHoldTimer();
if (mDocument == sMouseOverDocument)
sMouseOverDocument = nsnull;
--sESMInstanceCount;
if(sESMInstanceCount == 0) {
nsMouseWheelTransaction::Shutdown();
@ -3410,6 +3414,10 @@ nsEventStateManager::SetCursor(PRInt32 aCursor, imgIContainer* aContainer,
float aHotspotX, float aHotspotY,
nsIWidget* aWidget, PRBool aLockCursor)
{
EnsureDocument(mPresContext);
NS_ENSURE_TRUE(mDocument, NS_ERROR_FAILURE);
sMouseOverDocument = mDocument.get();
nsCursor c;
NS_ENSURE_TRUE(aWidget, NS_ERROR_FAILURE);

Просмотреть файл

@ -147,6 +147,8 @@ public:
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsEventStateManager,
nsIEventStateManager)
static nsIDocument* sMouseOverDocument;
protected:
void UpdateCursor(nsPresContext* aPresContext, nsEvent* aEvent, nsIFrame* aTargetFrame, nsEventStatus* aStatus);
/**

Просмотреть файл

@ -47,6 +47,7 @@
#include "nsIDocument.h"
#include "nsFocusManager.h"
#include "nsIEventStateManager.h"
#include "nsEventStateManager.h"
#include "nsIScrollableFrame.h"
@ -1575,3 +1576,35 @@ nsDOMWindowUtils::RenderDocument(const nsRect& aRect,
// Render Document
return presShell->RenderDocument(aRect, aFlags, aBackgroundColor, aThebesContext);
}
NS_IMETHODIMP
nsDOMWindowUtils::GetCursorType(PRInt16 *aCursor)
{
NS_ENSURE_ARG_POINTER(aCursor);
PRBool isSameDoc = PR_FALSE;
nsCOMPtr<nsIDocument> doc(do_QueryInterface(mWindow->GetExtantDocument()));
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
do {
if (nsEventStateManager::sMouseOverDocument == doc.get()) {
isSameDoc = PR_TRUE;
break;
}
} while ((doc = doc->GetParentDocument()));
if (!isSameDoc) {
*aCursor = eCursor_none;
return NS_OK;
}
nsCOMPtr<nsIWidget> widget = GetWidget();
if (!widget)
return NS_ERROR_FAILURE;
// fetch cursor value from window's widget
*aCursor = widget->GetCursor();
return NS_OK;
}

Просмотреть файл

@ -60,7 +60,7 @@ interface nsIDOMEvent;
interface nsITransferable;
interface nsIQueryContentEventResult;
[scriptable, uuid(74fdd125-52c7-4345-a086-270df15b829a)]
[scriptable, uuid(8707ed93-3277-42a5-a235-533aa661a263)]
interface nsIDOMWindowUtils : nsISupports {
/**
@ -89,6 +89,12 @@ interface nsIDOMWindowUtils : nsISupports {
*/
readonly attribute boolean docCharsetIsForced;
/**
* Get current cursor type from this window
* @return the current value of nsCursor
*/
short getCursorType();
/**
* Function to get metadata associated with the window's current document
* @param aName the name of the metadata. This should be all lowercase.