Revert "Issue #2721 - Remove nsILinkHandler."

This reverts commit c3f1c0cdba.
This commit is contained in:
wuggy 2026-09-19 07:22:05 -07:00
commit 733789f40b
16 changed files with 160 additions and 88 deletions

View file

@ -38,6 +38,7 @@ XPIDL_MODULE = 'docshell'
EXPORTS += [
'nsDocShellLoadTypes.h',
'nsILinkHandler.h',
'nsIScrollObserver.h',
'nsIWebShellServices.h',
'SerializedLoadContext.h',

View file

@ -956,6 +956,7 @@ NS_INTERFACE_MAP_BEGIN(nsDocShell)
NS_INTERFACE_MAP_ENTRY(nsIAuthPromptProvider)
NS_INTERFACE_MAP_ENTRY(nsILoadContext)
NS_INTERFACE_MAP_ENTRY(nsIWebShellServices)
NS_INTERFACE_MAP_ENTRY(nsILinkHandler)
NS_INTERFACE_MAP_ENTRY(nsIClipboardCommands)
NS_INTERFACE_MAP_ENTRY(nsIDOMStorageManager)
NS_INTERFACE_MAP_ENTRY(nsINetworkInterceptController)
@ -14057,7 +14058,7 @@ OnLinkClickEvent::OnLinkClickEvent(nsDocShell* aHandler,
{
}
nsresult
NS_IMETHODIMP
nsDocShell::OnLinkClick(nsIContent* aContent,
nsIURI* aURI,
const char16_t* aTargetSpec,
@ -14109,7 +14110,7 @@ nsDocShell::OnLinkClick(nsIContent* aContent,
return NS_DispatchToCurrentThread(ev);
}
nsresult
NS_IMETHODIMP
nsDocShell::OnLinkClickSync(nsIContent* aContent,
nsIURI* aURI,
const char16_t* aTargetSpec,
@ -14275,7 +14276,7 @@ nsDocShell::OnLinkClickSync(nsIContent* aContent,
return rv;
}
nsresult
NS_IMETHODIMP
nsDocShell::OnOverLink(nsIContent* aContent,
nsIURI* aURI,
const char16_t* aTargetSpec)
@ -14328,7 +14329,7 @@ nsDocShell::OnOverLink(nsIContent* aContent,
return rv;
}
nsresult
NS_IMETHODIMP
nsDocShell::OnLeaveLink()
{
nsCOMPtr<nsIWebBrowserChrome> browserChrome(do_GetInterface(mTreeOwner));

View file

@ -51,6 +51,7 @@
#include "nsIAuthPromptProvider.h"
#include "nsILoadContext.h"
#include "nsIWebShellServices.h"
#include "nsILinkHandler.h"
#include "nsIClipboardCommands.h"
#include "nsITabParent.h"
#include "nsCRT.h"
@ -142,6 +143,7 @@ class nsDocShell final
, public nsIAuthPromptProvider
, public nsILoadContext
, public nsIWebShellServices
, public nsILinkHandler
, public nsIClipboardCommands
, public nsIDOMStorageManager
, public nsINetworkInterceptController
@ -191,70 +193,28 @@ public:
// nsIWebProgressListener has methods with identical names...
NS_FORWARD_NSISECURITYEVENTSINK(nsDocLoader::)
/**
* Process a click on a link.
*
* @param aContent the content for the frame that generated the trigger
* @param aURI a URI object that defines the destination for the link
* @param aTargetSpec indicates where the link is targeted (may be an empty
* string)
* @param aFileName non-null when the link should be downloaded as the given file
* @param aPostDataStream the POST data to send
* @param aHeadersDataStream ??? (only used for plugins)
* @param aIsTrusted false if the triggerer is an untrusted DOM event.
* @param aTriggeringPrincipal, if not passed explicitly we fall back to
* the document's principal.
*/
nsresult OnLinkClick(nsIContent* aContent,
nsIURI* aURI,
const char16_t* aTargetSpec,
const nsAString& aFileName,
nsIInputStream* aPostDataStream,
nsIInputStream* aHeadersDataStream,
bool aIsTrusted,
nsIPrincipal* aTriggeringPrincipal);
/**
* Process a click on a link.
*
* Works the same as OnLinkClick() except it happens immediately rather than
* through an event.
*
* @param aContent the content for the frame that generated the trigger
* @param aURI a URI obect that defines the destination for the link
* @param aTargetSpec indicates where the link is targeted (may be an empty
* string)
* @param aFileName non-null when the link should be downloaded as the given file
* @param aPostDataStream the POST data to send
* @param aHeadersDataStream ??? (only used for plugins)
* @param aDocShell (out-param) the DocShell that the request was opened on
* @param aRequest the request that was opened
* @param aTriggeringPrincipal, if not passed explicitly we fall back to
* the document's principal.
*/
nsresult OnLinkClickSync(nsIContent* aContent,
nsIURI* aURI,
const char16_t* aTargetSpec,
const nsAString& aFileName,
nsIInputStream* aPostDataStream = nullptr,
nsIInputStream* aHeadersDataStream = nullptr,
nsIDocShell** aDocShell = nullptr,
nsIRequest** aRequest = nullptr,
nsIPrincipal* aTriggeringPrincipal = nullptr);
/**
* Process a mouse-over a link.
*
* @param aContent the linked content.
* @param aURI an URI object that defines the destination for the link
* @param aTargetSpec indicates where the link is targeted (it may be an empty
* string)
*/
nsresult OnOverLink(nsIContent* aContent,
nsIURI* aURI,
const char16_t* aTargetSpec);
/**
* Process the mouse leaving a link.
*/
nsresult OnLeaveLink();
// nsILinkHandler
NS_IMETHOD OnLinkClick(nsIContent* aContent,
nsIURI* aURI,
const char16_t* aTargetSpec,
const nsAString& aFileName,
nsIInputStream* aPostDataStream,
nsIInputStream* aHeadersDataStream,
bool aIsTrusted,
nsIPrincipal* aTriggeringPrincipal) override;
NS_IMETHOD OnLinkClickSync(nsIContent* aContent,
nsIURI* aURI,
const char16_t* aTargetSpec,
const nsAString& aFileName,
nsIInputStream* aPostDataStream = 0,
nsIInputStream* aHeadersDataStream = 0,
nsIDocShell** aDocShell = 0,
nsIRequest** aRequest = 0,
nsIPrincipal* aTriggeringPrincipal = nullptr) override;
NS_IMETHOD OnOverLink(nsIContent* aContent,
nsIURI* aURI,
const char16_t* aTargetSpec) override;
NS_IMETHOD OnLeaveLink() override;
nsDocShellInfoLoadType ConvertLoadTypeToDocShellLoadInfo(uint32_t aLoadType);
uint32_t ConvertDocShellLoadInfoToLoadType(

View file

@ -0,0 +1,99 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsILinkHandler_h___
#define nsILinkHandler_h___
#include "nsISupports.h"
#include "mozilla/EventForwards.h"
class nsIContent;
class nsIDocShell;
class nsIInputStream;
class nsIRequest;
#define NS_ILINKHANDLER_IID \
{ 0xceb9aade, 0x43da, 0x4f1a, \
{ 0xac, 0x8a, 0xc7, 0x09, 0xfb, 0x22, 0x46, 0x64 } }
/**
* Interface used for handling clicks on links
*/
class nsILinkHandler : public nsISupports
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ILINKHANDLER_IID)
/**
* Process a click on a link.
*
* @param aContent the content for the frame that generated the trigger
* @param aURI a URI object that defines the destination for the link
* @param aTargetSpec indicates where the link is targeted (may be an empty
* string)
* @param aPostDataStream the POST data to send
* @param aFileName non-null when the link should be downloaded as the given file
* @param aHeadersDataStream ???
* @param aIsTrusted false if the triggerer is an untrusted DOM event.
* @param aTriggeringPrincipal, if not passed explicitly we fall back to
* the document's principal.
*/
NS_IMETHOD OnLinkClick(nsIContent* aContent,
nsIURI* aURI,
const char16_t* aTargetSpec,
const nsAString& aFileName,
nsIInputStream* aPostDataStream,
nsIInputStream* aHeadersDataStream,
bool aIsTrusted,
nsIPrincipal* aTriggeringPrincipal) = 0;
/**
* Process a click on a link.
*
* Works the same as OnLinkClick() except it happens immediately rather than
* through an event.
*
* @param aContent the content for the frame that generated the trigger
* @param aURI a URI obect that defines the destination for the link
* @param aTargetSpec indicates where the link is targeted (may be an empty
* string)
* @param aFileName non-null when the link should be downloaded as the given file
* @param aPostDataStream the POST data to send
* @param aHeadersDataStream ???
* @param aDocShell (out-param) the DocShell that the request was opened on
* @param aRequest the request that was opened
* @param aTriggeringPrincipal, if not passed explicitly we fall back to
* the document's principal.
*/
NS_IMETHOD OnLinkClickSync(nsIContent* aContent,
nsIURI* aURI,
const char16_t* aTargetSpec,
const nsAString& aFileName,
nsIInputStream* aPostDataStream = 0,
nsIInputStream* aHeadersDataStream = 0,
nsIDocShell** aDocShell = 0,
nsIRequest** aRequest = 0,
nsIPrincipal* aTriggeringPrincipal = nullptr) = 0;
/**
* Process a mouse-over a link.
*
* @param aContent the linked content.
* @param aURI an URI object that defines the destination for the link
* @param aTargetSpec indicates where the link is targeted (it may be an empty
* string)
*/
NS_IMETHOD OnOverLink(nsIContent* aContent,
nsIURI* aURLSpec,
const char16_t* aTargetSpec) = 0;
/**
* Process the mouse leaving a link.
*/
NS_IMETHOD OnLeaveLink() = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsILinkHandler, NS_ILINKHANDLER_IID)
#endif /* nsILinkHandler_h___ */