Issue #2721 - Remove nsILinkHandler.

This interface inly has a single implementation behind it, which is also
only used in 2 places after the previous commit. That's a lot of
additional complexity and compiler indirection for no good reason.
This change removes the interface and uses direct nsDocShell::Cast calls
instead of going through the interface in the few places left now that
we no longer build on a presentation context for links.
This commit is contained in:
Moonchild 2025-06-10 01:51:14 +02:00 committed by roytam1
commit c3f1c0cdba
16 changed files with 88 additions and 160 deletions

View file

@ -27,7 +27,6 @@ using mozilla::DefaultXDisplay;
#include "nsIStringStream.h"
#include "nsNetUtil.h"
#include "mozilla/Preferences.h"
#include "nsILinkHandler.h"
#include "nsIDocShellTreeItem.h"
#include "nsIWebBrowserChrome.h"
#include "nsLayoutUtils.h"
@ -46,6 +45,7 @@ using mozilla::DefaultXDisplay;
#include "nsIScriptSecurityManager.h"
#include "nsIScrollableFrame.h"
#include "nsIDocShell.h"
#include "nsDocShell.h" // for ::Cast
#include "ImageContainer.h"
#include "nsIDOMHTMLCollection.h"
#include "GLContext.h"
@ -440,10 +440,8 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL,
}
// the container of the pres context will give us the link handler
nsCOMPtr<nsISupports> container = presContext->GetContainerWeak();
nsCOMPtr<nsIDocShell> container = presContext->GetDocShell();
NS_ENSURE_TRUE(container,NS_ERROR_FAILURE);
nsCOMPtr<nsILinkHandler> lh = do_QueryInterface(container);
NS_ENSURE_TRUE(lh, NS_ERROR_FAILURE);
nsAutoString unitarget;
if ((0 == PL_strcmp(aTarget, "newwindow")) ||
@ -495,8 +493,14 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL,
triggeringPrincipal = BasePrincipal::CreateCodebasePrincipal(uri, attrs);
}
rv = lh->OnLinkClick(content, uri, unitarget.get(), NullString(),
aPostStream, headersDataStream, true, triggeringPrincipal);
rv = nsDocShell::Cast(container)->OnLinkClick(content,
uri,
unitarget.get(),
NullString(),
aPostStream,
headersDataStream,
true,
triggeringPrincipal);
return rv;
}