Fixing bug 225837. DeCOMtaminating nsIContent more, making GetTag() return a weak raw pointer, and renaming GetTag() to Tag(), and making GetRangeList() return an const nsVoidArray*, and changing GetContentID() to return the id, and renaming it to ContentID(). r=jonas@sicking.cc, sr=bryner@brianryner.com.

git-svn-id: svn://10.0.0.236/trunk@149527 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
jst%mozilla.jstenback.com
2003-11-19 01:20:56 +00:00
parent 19a3086422
commit 2affc5b4f0
132 changed files with 1831 additions and 2341 deletions

View File

@@ -146,7 +146,8 @@ NS_INTERFACE_MAP_END
// nsDocShellTreeOwner::nsIInterfaceRequestor
//*****************************************************************************
NS_IMETHODIMP nsDocShellTreeOwner::GetInterface(const nsIID& aIID, void** aSink)
NS_IMETHODIMP
nsDocShellTreeOwner::GetInterface(const nsIID& aIID, void** aSink)
{
NS_ENSURE_ARG_POINTER(aSink);
@@ -190,8 +191,10 @@ NS_IMETHODIMP nsDocShellTreeOwner::GetInterface(const nsIID& aIID, void** aSink)
// nsDocShellTreeOwner::nsIDocShellTreeOwner
//*****************************************************************************
NS_IMETHODIMP nsDocShellTreeOwner::FindItemWithName(const PRUnichar* aName,
nsIDocShellTreeItem* aRequestor, nsIDocShellTreeItem** aFoundItem)
NS_IMETHODIMP
nsDocShellTreeOwner::FindItemWithName(const PRUnichar* aName,
nsIDocShellTreeItem* aRequestor,
nsIDocShellTreeItem** aFoundItem)
{
NS_ENSURE_ARG(aName);
NS_ENSURE_ARG_POINTER(aFoundItem);
@@ -253,9 +256,10 @@ NS_IMETHODIMP nsDocShellTreeOwner::FindItemWithName(const PRUnichar* aName,
return NS_OK; // failed
}
nsresult nsDocShellTreeOwner::FindChildWithName(const PRUnichar *aName,
PRBool aRecurse, nsIDocShellTreeItem* aRequestor,
nsIDocShellTreeItem **aFoundItem)
nsresult
nsDocShellTreeOwner::FindChildWithName(const PRUnichar *aName, PRBool aRecurse,
nsIDocShellTreeItem* aRequestor,
nsIDocShellTreeItem **aFoundItem)
{
if (!mWebBrowser)
return NS_OK;
@@ -296,9 +300,9 @@ nsresult nsDocShellTreeOwner::FindChildWithName(const PRUnichar *aName,
return rv;
}
nsresult nsDocShellTreeOwner::FindItemWithNameAcrossWindows(
const PRUnichar* aName,
nsIDocShellTreeItem** aFoundItem)
nsresult
nsDocShellTreeOwner::FindItemWithNameAcrossWindows(const PRUnichar* aName,
nsIDocShellTreeItem** aFoundItem)
{
// search for the item across the list of top-level windows
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
@@ -339,7 +343,8 @@ nsresult nsDocShellTreeOwner::FindItemWithNameAcrossWindows(
return rv;
}
void nsDocShellTreeOwner::EnsurePrompter()
void
nsDocShellTreeOwner::EnsurePrompter()
{
if (mPrompter)
return;
@@ -353,7 +358,8 @@ void nsDocShellTreeOwner::EnsurePrompter()
}
}
void nsDocShellTreeOwner::EnsureAuthPrompter()
void
nsDocShellTreeOwner::EnsureAuthPrompter()
{
if (mAuthPrompter)
return;
@@ -367,8 +373,9 @@ void nsDocShellTreeOwner::EnsureAuthPrompter()
}
}
void nsDocShellTreeOwner::AddToWatcher() {
void
nsDocShellTreeOwner::AddToWatcher()
{
if (mWebBrowser) {
nsCOMPtr<nsIDOMWindow> domWindow;
mWebBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
@@ -380,8 +387,9 @@ void nsDocShellTreeOwner::AddToWatcher() {
}
}
void nsDocShellTreeOwner::RemoveFromWatcher() {
void
nsDocShellTreeOwner::RemoveFromWatcher()
{
if (mWebBrowser) {
nsCOMPtr<nsIDOMWindow> domWindow;
mWebBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
@@ -394,8 +402,9 @@ void nsDocShellTreeOwner::RemoveFromWatcher() {
}
NS_IMETHODIMP nsDocShellTreeOwner::ContentShellAdded(nsIDocShellTreeItem* aContentShell,
PRBool aPrimary, const PRUnichar* aID)
NS_IMETHODIMP
nsDocShellTreeOwner::ContentShellAdded(nsIDocShellTreeItem* aContentShell,
PRBool aPrimary, const PRUnichar* aID)
{
if(mTreeOwner)
return mTreeOwner->ContentShellAdded(aContentShell, aPrimary, aID);
@@ -405,7 +414,8 @@ NS_IMETHODIMP nsDocShellTreeOwner::ContentShellAdded(nsIDocShellTreeItem* aConte
return NS_OK;
}
NS_IMETHODIMP nsDocShellTreeOwner::GetPrimaryContentShell(nsIDocShellTreeItem** aShell)
NS_IMETHODIMP
nsDocShellTreeOwner::GetPrimaryContentShell(nsIDocShellTreeItem** aShell)
{
NS_ENSURE_ARG_POINTER(aShell);
@@ -418,8 +428,9 @@ NS_IMETHODIMP nsDocShellTreeOwner::GetPrimaryContentShell(nsIDocShellTreeItem**
return NS_OK;
}
NS_IMETHODIMP nsDocShellTreeOwner::SizeShellTo(nsIDocShellTreeItem* aShellItem,
PRInt32 aCX, PRInt32 aCY)
NS_IMETHODIMP
nsDocShellTreeOwner::SizeShellTo(nsIDocShellTreeItem* aShellItem,
PRInt32 aCX, PRInt32 aCY)
{
NS_ENSURE_STATE(mTreeOwner || mWebBrowserChrome);
@@ -490,145 +501,165 @@ nsDocShellTreeOwner::GetPersistence(PRBool* aPersistPosition,
//*****************************************************************************
NS_IMETHODIMP nsDocShellTreeOwner::InitWindow(nativeWindow aParentNativeWindow,
nsIWidget* aParentWidget, PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY)
NS_IMETHODIMP
nsDocShellTreeOwner::InitWindow(nativeWindow aParentNativeWindow,
nsIWidget* aParentWidget, PRInt32 aX,
PRInt32 aY, PRInt32 aCX, PRInt32 aCY)
{
return NS_ERROR_NULL_POINTER;
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::Create()
NS_IMETHODIMP
nsDocShellTreeOwner::Create()
{
return NS_ERROR_NULL_POINTER;
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::Destroy()
NS_IMETHODIMP
nsDocShellTreeOwner::Destroy()
{
if (mOwnerWin)
{
return mWebBrowserChrome->DestroyBrowserWindow();
}
return NS_ERROR_NULL_POINTER;
if (mOwnerWin)
{
return mWebBrowserChrome->DestroyBrowserWindow();
}
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::SetPosition(PRInt32 aX, PRInt32 aY)
NS_IMETHODIMP
nsDocShellTreeOwner::SetPosition(PRInt32 aX, PRInt32 aY)
{
if (mOwnerWin)
{
return mOwnerWin->SetDimensions(nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION,
aX, aY, 0, 0);
}
return NS_ERROR_NULL_POINTER;
if (mOwnerWin)
{
return mOwnerWin->SetDimensions(nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION,
aX, aY, 0, 0);
}
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::GetPosition(PRInt32* aX, PRInt32* aY)
NS_IMETHODIMP
nsDocShellTreeOwner::GetPosition(PRInt32* aX, PRInt32* aY)
{
if (mOwnerWin)
{
return mOwnerWin->GetDimensions(nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION,
aX, aY, nsnull, nsnull);
}
return NS_ERROR_NULL_POINTER;
if (mOwnerWin)
{
return mOwnerWin->GetDimensions(nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION,
aX, aY, nsnull, nsnull);
}
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::SetSize(PRInt32 aCX, PRInt32 aCY, PRBool aRepaint)
NS_IMETHODIMP
nsDocShellTreeOwner::SetSize(PRInt32 aCX, PRInt32 aCY, PRBool aRepaint)
{
if (mOwnerWin)
{
return mOwnerWin->SetDimensions(nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER,
0, 0, aCX, aCY);
}
return NS_ERROR_NULL_POINTER;
if (mOwnerWin)
{
return mOwnerWin->SetDimensions(nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER,
0, 0, aCX, aCY);
}
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::GetSize(PRInt32* aCX, PRInt32* aCY)
NS_IMETHODIMP
nsDocShellTreeOwner::GetSize(PRInt32* aCX, PRInt32* aCY)
{
if (mOwnerWin)
{
return mOwnerWin->GetDimensions(nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER,
nsnull, nsnull, aCX, aCY);
}
return NS_ERROR_NULL_POINTER;
if (mOwnerWin)
{
return mOwnerWin->GetDimensions(nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER,
nsnull, nsnull, aCX, aCY);
}
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::SetPositionAndSize(PRInt32 aX, PRInt32 aY,
PRInt32 aCX, PRInt32 aCY, PRBool aRepaint)
NS_IMETHODIMP
nsDocShellTreeOwner::SetPositionAndSize(PRInt32 aX, PRInt32 aY, PRInt32 aCX,
PRInt32 aCY, PRBool aRepaint)
{
if (mOwnerWin)
{
return mOwnerWin->SetDimensions(nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER |
nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION,
aX, aY, aCX, aCY);
}
return NS_ERROR_NULL_POINTER;
if (mOwnerWin)
{
return mOwnerWin->SetDimensions(nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER |
nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION,
aX, aY, aCX, aCY);
}
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::GetPositionAndSize(PRInt32* aX, PRInt32* aY,
PRInt32* aCX, PRInt32* aCY)
NS_IMETHODIMP
nsDocShellTreeOwner::GetPositionAndSize(PRInt32* aX, PRInt32* aY, PRInt32* aCX,
PRInt32* aCY)
{
if (mOwnerWin)
{
return mOwnerWin->GetDimensions(nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER |
nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION,
aX, aY, aCX, aCY);
}
return NS_ERROR_NULL_POINTER;
if (mOwnerWin)
{
return mOwnerWin->GetDimensions(nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER |
nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION,
aX, aY, aCX, aCY);
}
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::Repaint(PRBool aForce)
NS_IMETHODIMP
nsDocShellTreeOwner::Repaint(PRBool aForce)
{
return NS_ERROR_NULL_POINTER;
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::GetParentWidget(nsIWidget** aParentWidget)
NS_IMETHODIMP
nsDocShellTreeOwner::GetParentWidget(nsIWidget** aParentWidget)
{
return NS_ERROR_NULL_POINTER;
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::SetParentWidget(nsIWidget* aParentWidget)
NS_IMETHODIMP
nsDocShellTreeOwner::SetParentWidget(nsIWidget* aParentWidget)
{
return NS_ERROR_NULL_POINTER;
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::GetParentNativeWindow(nativeWindow* aParentNativeWindow)
NS_IMETHODIMP
nsDocShellTreeOwner::GetParentNativeWindow(nativeWindow* aParentNativeWindow)
{
if (mOwnerWin)
{
return mOwnerWin->GetSiteWindow(aParentNativeWindow);
}
return NS_ERROR_NULL_POINTER;
if (mOwnerWin)
{
return mOwnerWin->GetSiteWindow(aParentNativeWindow);
}
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::SetParentNativeWindow(nativeWindow aParentNativeWindow)
NS_IMETHODIMP
nsDocShellTreeOwner::SetParentNativeWindow(nativeWindow aParentNativeWindow)
{
return NS_ERROR_NULL_POINTER;
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::GetVisibility(PRBool* aVisibility)
NS_IMETHODIMP
nsDocShellTreeOwner::GetVisibility(PRBool* aVisibility)
{
if (mOwnerWin)
{
return mOwnerWin->GetVisibility(aVisibility);
}
return NS_ERROR_NULL_POINTER;
if (mOwnerWin)
{
return mOwnerWin->GetVisibility(aVisibility);
}
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::SetVisibility(PRBool aVisibility)
NS_IMETHODIMP
nsDocShellTreeOwner::SetVisibility(PRBool aVisibility)
{
if (mOwnerWin)
{
return mOwnerWin->SetVisibility(aVisibility);
}
return NS_ERROR_NULL_POINTER;
if (mOwnerWin)
{
return mOwnerWin->SetVisibility(aVisibility);
}
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::GetEnabled(PRBool *aEnabled)
NS_IMETHODIMP
nsDocShellTreeOwner::GetEnabled(PRBool *aEnabled)
{
NS_ENSURE_ARG_POINTER(aEnabled);
*aEnabled = PR_TRUE;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsDocShellTreeOwner::SetEnabled(PRBool aEnabled)
NS_IMETHODIMP
nsDocShellTreeOwner::SetEnabled(PRBool aEnabled)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
@@ -647,12 +678,14 @@ nsDocShellTreeOwner::SetBlurSuppression(PRBool aBlurSuppression)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsDocShellTreeOwner::GetMainWidget(nsIWidget** aMainWidget)
NS_IMETHODIMP
nsDocShellTreeOwner::GetMainWidget(nsIWidget** aMainWidget)
{
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::SetFocus()
NS_IMETHODIMP
nsDocShellTreeOwner::SetFocus()
{
if (mOwnerWin)
{
@@ -661,7 +694,8 @@ NS_IMETHODIMP nsDocShellTreeOwner::SetFocus()
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::GetTitle(PRUnichar** aTitle)
NS_IMETHODIMP
nsDocShellTreeOwner::GetTitle(PRUnichar** aTitle)
{
if (mOwnerWin)
{
@@ -670,7 +704,8 @@ NS_IMETHODIMP nsDocShellTreeOwner::GetTitle(PRUnichar** aTitle)
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsDocShellTreeOwner::SetTitle(const PRUnichar* aTitle)
NS_IMETHODIMP
nsDocShellTreeOwner::SetTitle(const PRUnichar* aTitle)
{
if (mOwnerWin)
{
@@ -708,9 +743,10 @@ nsDocShellTreeOwner::OnStateChange(nsIWebProgress* aProgress,
return NS_OK;
}
NS_IMETHODIMP nsDocShellTreeOwner::OnLocationChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
nsIURI* aURI)
NS_IMETHODIMP
nsDocShellTreeOwner::OnLocationChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
nsIURI* aURI)
{
return NS_OK;
}
@@ -741,7 +777,8 @@ nsDocShellTreeOwner::OnSecurityChange(nsIWebProgress *aWebProgress,
// nsDocShellTreeOwner: Accessors
//*****************************************************************************
void nsDocShellTreeOwner::WebBrowser(nsWebBrowser* aWebBrowser)
void
nsDocShellTreeOwner::WebBrowser(nsWebBrowser* aWebBrowser)
{
if ( !aWebBrowser )
RemoveChromeListeners();
@@ -753,47 +790,48 @@ void nsDocShellTreeOwner::WebBrowser(nsWebBrowser* aWebBrowser)
mWebBrowser = aWebBrowser;
}
nsWebBrowser* nsDocShellTreeOwner::WebBrowser()
nsWebBrowser *
nsDocShellTreeOwner::WebBrowser()
{
return mWebBrowser;
}
NS_IMETHODIMP nsDocShellTreeOwner::SetTreeOwner(nsIDocShellTreeOwner* aTreeOwner)
NS_IMETHODIMP
nsDocShellTreeOwner::SetTreeOwner(nsIDocShellTreeOwner* aTreeOwner)
{
if(aTreeOwner) {
nsCOMPtr<nsIWebBrowserChrome> webBrowserChrome(do_GetInterface(aTreeOwner));
NS_ENSURE_TRUE(webBrowserChrome, NS_ERROR_INVALID_ARG);
NS_ENSURE_SUCCESS(SetWebBrowserChrome(webBrowserChrome), NS_ERROR_INVALID_ARG);
mTreeOwner = aTreeOwner;
}
else if(mWebBrowserChrome)
mTreeOwner = nsnull;
else {
mTreeOwner = nsnull;
NS_ENSURE_SUCCESS(SetWebBrowserChrome(nsnull), NS_ERROR_FAILURE);
}
if(aTreeOwner) {
nsCOMPtr<nsIWebBrowserChrome> webBrowserChrome(do_GetInterface(aTreeOwner));
NS_ENSURE_TRUE(webBrowserChrome, NS_ERROR_INVALID_ARG);
NS_ENSURE_SUCCESS(SetWebBrowserChrome(webBrowserChrome), NS_ERROR_INVALID_ARG);
mTreeOwner = aTreeOwner;
}
else if(mWebBrowserChrome)
mTreeOwner = nsnull;
else {
mTreeOwner = nsnull;
NS_ENSURE_SUCCESS(SetWebBrowserChrome(nsnull), NS_ERROR_FAILURE);
}
return NS_OK;
return NS_OK;
}
NS_IMETHODIMP nsDocShellTreeOwner::SetWebBrowserChrome(nsIWebBrowserChrome* aWebBrowserChrome)
NS_IMETHODIMP
nsDocShellTreeOwner::SetWebBrowserChrome(nsIWebBrowserChrome* aWebBrowserChrome)
{
if(!aWebBrowserChrome) {
mWebBrowserChrome = nsnull;
mOwnerWin = nsnull;
mOwnerRequestor = nsnull;
}
else
{
nsCOMPtr<nsIEmbeddingSiteWindow> ownerWin(do_QueryInterface(aWebBrowserChrome));
nsCOMPtr<nsIInterfaceRequestor> requestor(do_QueryInterface(aWebBrowserChrome));
if(!aWebBrowserChrome) {
mWebBrowserChrome = nsnull;
mOwnerWin = nsnull;
mOwnerRequestor = nsnull;
} else {
nsCOMPtr<nsIEmbeddingSiteWindow> ownerWin(do_QueryInterface(aWebBrowserChrome));
nsCOMPtr<nsIInterfaceRequestor> requestor(do_QueryInterface(aWebBrowserChrome));
// it's ok for ownerWin or requestor to be null.
mWebBrowserChrome = aWebBrowserChrome;
mOwnerWin = ownerWin;
mOwnerRequestor = requestor;
}
return NS_OK;
// it's ok for ownerWin or requestor to be null.
mWebBrowserChrome = aWebBrowserChrome;
mOwnerWin = ownerWin;
mOwnerRequestor = requestor;
}
return NS_OK;
}
@@ -804,7 +842,7 @@ NS_IMETHODIMP nsDocShellTreeOwner::SetWebBrowserChrome(nsIWebBrowserChrome* aWeb
// has implemented the right interfaces.
//
NS_IMETHODIMP
nsDocShellTreeOwner :: AddChromeListeners ( )
nsDocShellTreeOwner::AddChromeListeners()
{
nsresult rv = NS_OK;
@@ -855,7 +893,7 @@ nsDocShellTreeOwner :: AddChromeListeners ( )
NS_IMETHODIMP
nsDocShellTreeOwner :: RemoveChromeListeners ( )
nsDocShellTreeOwner::RemoveChromeListeners()
{
if ( mChromeTooltipListener ) {
mChromeTooltipListener->RemoveChromeListeners();
@@ -905,7 +943,9 @@ DefaultTooltipTextProvider::DefaultTooltipTextProvider()
}
/* void getNodeText (in nsIDOMNode aNode, out wstring aText); */
NS_IMETHODIMP DefaultTooltipTextProvider::GetNodeText(nsIDOMNode *aNode, PRUnichar **aText, PRBool *_retval)
NS_IMETHODIMP
DefaultTooltipTextProvider::GetNodeText(nsIDOMNode *aNode, PRUnichar **aText,
PRBool *_retval)
{
NS_ENSURE_ARG_POINTER(aNode);
NS_ENSURE_ARG_POINTER(aText);
@@ -919,8 +959,7 @@ NS_IMETHODIMP DefaultTooltipTextProvider::GetNodeText(nsIDOMNode *aNode, PRUnich
if ( currElement ) {
nsCOMPtr<nsIContent> content(do_QueryInterface(currElement));
if (content) {
nsCOMPtr<nsIAtom> tagAtom;
content->GetTag(getter_AddRefs(tagAtom));
nsIAtom *tagAtom = content->Tag();
if (tagAtom != mTag_dialog &&
tagAtom != mTag_dialogheader &&
tagAtom != mTag_window) {
@@ -969,7 +1008,8 @@ NS_INTERFACE_MAP_END
// ChromeTooltipListener ctor
//
ChromeTooltipListener :: ChromeTooltipListener ( nsWebBrowser* inBrowser, nsIWebBrowserChrome* inChrome )
ChromeTooltipListener::ChromeTooltipListener(nsWebBrowser* inBrowser,
nsIWebBrowserChrome* inChrome)
: mWebBrowser(inBrowser), mWebBrowserChrome(inChrome),
mTooltipListenerInstalled(PR_FALSE),
mMouseClientX(0), mMouseClientY(0),
@@ -986,7 +1026,7 @@ ChromeTooltipListener :: ChromeTooltipListener ( nsWebBrowser* inBrowser, nsIWeb
//
// ChromeTooltipListener dtor
//
ChromeTooltipListener :: ~ChromeTooltipListener ( )
ChromeTooltipListener::~ChromeTooltipListener()
{
} // dtor
@@ -999,7 +1039,7 @@ ChromeTooltipListener :: ~ChromeTooltipListener ( )
// has implemented the right interfaces.
//
NS_IMETHODIMP
ChromeTooltipListener :: AddChromeListeners ( )
ChromeTooltipListener::AddChromeListeners()
{
if ( !mEventReceiver )
GetEventReceiver(mWebBrowser, getter_AddRefs(mEventReceiver));
@@ -1027,7 +1067,7 @@ ChromeTooltipListener :: AddChromeListeners ( )
// of how many succeed so we can clean up correctly in Release().
//
NS_IMETHODIMP
ChromeTooltipListener :: AddTooltipListener()
ChromeTooltipListener::AddTooltipListener()
{
if (mEventReceiver) {
nsIDOMMouseListener *pListener = NS_STATIC_CAST(nsIDOMMouseListener *, this);
@@ -1050,7 +1090,7 @@ ChromeTooltipListener :: AddTooltipListener()
// Unsubscribe from the various things we've hooked up to the window root.
//
NS_IMETHODIMP
ChromeTooltipListener :: RemoveChromeListeners ( )
ChromeTooltipListener::RemoveChromeListeners ( )
{
HideTooltip();
@@ -1072,7 +1112,7 @@ ChromeTooltipListener :: RemoveChromeListeners ( )
// Unsubscribe from all the various tooltip events that we were listening to
//
NS_IMETHODIMP
ChromeTooltipListener :: RemoveTooltipListener()
ChromeTooltipListener::RemoveTooltipListener()
{
if (mEventReceiver) {
nsIDOMMouseListener *pListener = NS_STATIC_CAST(nsIDOMMouseListener *, this);
@@ -1097,7 +1137,6 @@ nsresult
ChromeTooltipListener::KeyDown(nsIDOMEvent* aMouseEvent)
{
return HideTooltip();
} // KeyDown
@@ -1232,7 +1271,8 @@ ChromeTooltipListener::MouseMove(nsIDOMEvent* aMouseEvent)
// Tell the registered chrome that they should show the tooltip
//
NS_IMETHODIMP
ChromeTooltipListener :: ShowTooltip ( PRInt32 inXCoords, PRInt32 inYCoords, const nsAString & inTipText )
ChromeTooltipListener::ShowTooltip(PRInt32 inXCoords, PRInt32 inYCoords,
const nsAString & inTipText)
{
nsresult rv = NS_OK;
@@ -1256,7 +1296,7 @@ ChromeTooltipListener :: ShowTooltip ( PRInt32 inXCoords, PRInt32 inYCoords, con
// NOTE: This routine is safe to call even if the popup is already closed.
//
NS_IMETHODIMP
ChromeTooltipListener :: HideTooltip ( )
ChromeTooltipListener::HideTooltip()
{
nsresult rv = NS_OK;
@@ -1300,7 +1340,8 @@ ChromeTooltipListener :: HideTooltip ( )
// -- the dom node the user hovered over (mPossibleTooltipNode)
//
void
ChromeTooltipListener :: sTooltipCallback (nsITimer *aTimer, void *aChromeTooltipListener)
ChromeTooltipListener::sTooltipCallback(nsITimer *aTimer,
void *aChromeTooltipListener)
{
ChromeTooltipListener* self = NS_STATIC_CAST(ChromeTooltipListener*, aChromeTooltipListener);
if ( self && self->mPossibleTooltipNode ) {
@@ -1335,7 +1376,7 @@ ChromeTooltipListener :: sTooltipCallback (nsITimer *aTimer, void *aChromeToolti
// Create a new timer to see if we should auto-hide. It's ok if this fails.
//
void
ChromeTooltipListener :: CreateAutoHideTimer ( )
ChromeTooltipListener::CreateAutoHideTimer()
{
// just to be anal (er, safe)
if ( mAutoHideTimer ) {
@@ -1359,7 +1400,7 @@ ChromeTooltipListener :: CreateAutoHideTimer ( )
// be called multiple times, even if the tip has already been closed.
//
void
ChromeTooltipListener :: sAutoHideCallback ( nsITimer *aTimer, void* aListener )
ChromeTooltipListener::sAutoHideCallback(nsITimer *aTimer, void* aListener)
{
ChromeTooltipListener* self = NS_STATIC_CAST(ChromeTooltipListener*, aListener);
if ( self )
@@ -1389,7 +1430,7 @@ NS_INTERFACE_MAP_END
//
// ChromeTooltipListener ctor
//
ChromeContextMenuListener :: ChromeContextMenuListener ( nsWebBrowser* inBrowser, nsIWebBrowserChrome* inChrome )
ChromeContextMenuListener::ChromeContextMenuListener(nsWebBrowser* inBrowser, nsIWebBrowserChrome* inChrome )
: mContextMenuListenerInstalled(PR_FALSE),
mWebBrowser(inBrowser),
mWebBrowserChrome(inChrome)
@@ -1400,9 +1441,8 @@ ChromeContextMenuListener :: ChromeContextMenuListener ( nsWebBrowser* inBrowser
//
// ChromeTooltipListener dtor
//
ChromeContextMenuListener :: ~ChromeContextMenuListener ( )
ChromeContextMenuListener::~ChromeContextMenuListener()
{
} // dtor
@@ -1413,7 +1453,7 @@ ChromeContextMenuListener :: ~ChromeContextMenuListener ( )
// is just the context-menu DOM event.
//
NS_IMETHODIMP
ChromeContextMenuListener :: AddContextMenuListener()
ChromeContextMenuListener::AddContextMenuListener()
{
if (mEventReceiver) {
nsIDOMContextMenuListener *pListener = NS_STATIC_CAST(nsIDOMContextMenuListener *, this);
@@ -1432,7 +1472,7 @@ ChromeContextMenuListener :: AddContextMenuListener()
// Unsubscribe from all the various context menu events that we were listening to.
//
NS_IMETHODIMP
ChromeContextMenuListener :: RemoveContextMenuListener()
ChromeContextMenuListener::RemoveContextMenuListener()
{
if (mEventReceiver) {
nsIDOMContextMenuListener *pListener = NS_STATIC_CAST(nsIDOMContextMenuListener *, this);
@@ -1452,7 +1492,7 @@ ChromeContextMenuListener :: RemoveContextMenuListener()
// has implemented the right interfaces.
//
NS_IMETHODIMP
ChromeContextMenuListener :: AddChromeListeners ( )
ChromeContextMenuListener::AddChromeListeners()
{
if ( !mEventReceiver )
GetEventReceiver(mWebBrowser, getter_AddRefs(mEventReceiver));
@@ -1477,7 +1517,7 @@ ChromeContextMenuListener :: AddChromeListeners ( )
// Unsubscribe from the various things we've hooked up to the window root.
//
NS_IMETHODIMP
ChromeContextMenuListener :: RemoveChromeListeners ( )
ChromeContextMenuListener::RemoveChromeListeners()
{
if ( mContextMenuListenerInstalled )
RemoveContextMenuListener();
@@ -1499,7 +1539,7 @@ ChromeContextMenuListener :: RemoveChromeListeners ( )
// end chrome.
//
NS_IMETHODIMP
ChromeContextMenuListener :: ContextMenu ( nsIDOMEvent* aMouseEvent )
ChromeContextMenuListener::ContextMenu(nsIDOMEvent* aMouseEvent)
{
nsCOMPtr<nsIDOMEventTarget> targetNode;
nsresult res = aMouseEvent->GetTarget(getter_AddRefs(targetNode));
@@ -1532,24 +1572,23 @@ ChromeContextMenuListener :: ContextMenu ( nsIDOMEvent* aMouseEvent )
PRUint32 flags = nsIContextMenuListener::CONTEXT_NONE;
PRUint32 flags2 = nsIContextMenuListener2::CONTEXT_NONE;
nsCOMPtr<nsIDOMHTMLElement> element;
nsCOMPtr<nsIContent> content;
do {
// XXX test for selected text
element = do_QueryInterface(node);
if (element)
{
nsAutoString tag;
element->GetTagName(tag);
content = do_QueryInterface(node);
if (content && content->IsContentOfType(nsIContent::eHTML)) {
const char *tagStr;
content->Tag()->GetUTF8String(&tagStr);
// Test what kind of element we're dealing with here
if (tag.Equals(NS_LITERAL_STRING("img"), nsCaseInsensitiveStringComparator()))
if (strcmp(tagStr, "img") == 0)
{
flags |= nsIContextMenuListener::CONTEXT_IMAGE;
flags2 |= nsIContextMenuListener2::CONTEXT_IMAGE;
targetDOMnode = node;
// if we see an image, keep searching for a possible anchor
}
else if (tag.Equals(NS_LITERAL_STRING("input"), nsCaseInsensitiveStringComparator()))
else if (strcmp(tagStr, "input") == 0)
{
// INPUT element - button, combo, checkbox, text etc.
flags |= nsIContextMenuListener::CONTEXT_INPUT;
@@ -1568,7 +1607,7 @@ ChromeContextMenuListener :: ContextMenu ( nsIDOMEvent* aMouseEvent )
}
break; // exit do-while
}
else if (tag.Equals(NS_LITERAL_STRING("textarea"), nsCaseInsensitiveStringComparator()))
else if (strcmp(tagStr, "textarea") == 0)
{
// text area
flags |= nsIContextMenuListener::CONTEXT_TEXT;
@@ -1576,7 +1615,7 @@ ChromeContextMenuListener :: ContextMenu ( nsIDOMEvent* aMouseEvent )
targetDOMnode = node;
break; // exit do-while
}
else if (tag.Equals(NS_LITERAL_STRING("html"), nsCaseInsensitiveStringComparator()))
else if (strcmp(tagStr, "html") == 0)
{
if (!flags && !flags2) {
// only care about this if no other context was found.
@@ -1593,30 +1632,28 @@ ChromeContextMenuListener :: ContextMenu ( nsIDOMEvent* aMouseEvent )
}
break; // exit do-while
}
else if ( tag.EqualsWithConversion("object", PR_TRUE) || /* XXX what about images and documents? */
tag.EqualsWithConversion("embed", PR_TRUE) ||
tag.EqualsWithConversion("applet", PR_TRUE) )
else if (strcmp(tagStr, "object") == 0 || /* XXX what about images and documents? */
strcmp(tagStr, "embed") == 0 ||
strcmp(tagStr, "applet") == 0)
{ // always consume events for plugins and Java
return NS_OK; // who may throw their own context menus
}
// Test if the element has an associated link
nsCOMPtr<nsIDOMNamedNodeMap> attributes;
node->GetAttributes(getter_AddRefs(attributes));
if (attributes)
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(node));
PRBool hasAttr = PR_FALSE;
res = element->HasAttribute(NS_LITERAL_STRING("href"), &hasAttr);
if (NS_SUCCEEDED(res) && hasAttr)
{
nsCOMPtr<nsIDOMNode> hrefNode;
attributes->GetNamedItem(NS_LITERAL_STRING("href"), getter_AddRefs(hrefNode));
if (hrefNode)
{
flags |= nsIContextMenuListener::CONTEXT_LINK;
flags2 |= nsIContextMenuListener2::CONTEXT_LINK;
if (!targetDOMnode)
targetDOMnode = node;
if (menuInfoImpl)
menuInfoImpl->SetAssociatedLink(node);
break; // exit do-while
}
flags |= nsIContextMenuListener::CONTEXT_LINK;
flags2 |= nsIContextMenuListener2::CONTEXT_LINK;
if (!targetDOMnode)
targetDOMnode = node;
if (menuInfoImpl)
menuInfoImpl->SetAssociatedLink(node);
break; // exit do-while
}
}
@@ -1662,5 +1699,3 @@ ChromeContextMenuListener :: ContextMenu ( nsIDOMEvent* aMouseEvent )
return NS_OK;
} // MouseDown