#579: M1218456 +backbugs -nsILinkHandler removal, with changes for 45
This commit is contained in:
parent
d89529ac0b
commit
5e0cd430c2
|
@ -16,6 +16,7 @@
|
||||||
#include "mozilla/DebugOnly.h"
|
#include "mozilla/DebugOnly.h"
|
||||||
#include "mozilla/dom/Animation.h"
|
#include "mozilla/dom/Animation.h"
|
||||||
#include "mozilla/dom/Attr.h"
|
#include "mozilla/dom/Attr.h"
|
||||||
|
#include "nsDocShell.h"
|
||||||
#include "nsDOMAttributeMap.h"
|
#include "nsDOMAttributeMap.h"
|
||||||
#include "nsIAtom.h"
|
#include "nsIAtom.h"
|
||||||
#include "nsIContentInlines.h"
|
#include "nsIContentInlines.h"
|
||||||
|
@ -26,7 +27,6 @@
|
||||||
#include "nsIContentIterator.h"
|
#include "nsIContentIterator.h"
|
||||||
#include "nsFocusManager.h"
|
#include "nsFocusManager.h"
|
||||||
#include "nsFrameManager.h"
|
#include "nsFrameManager.h"
|
||||||
#include "nsILinkHandler.h"
|
|
||||||
#include "nsIScriptGlobalObject.h"
|
#include "nsIScriptGlobalObject.h"
|
||||||
#include "nsIURL.h"
|
#include "nsIURL.h"
|
||||||
#include "nsContainerFrame.h"
|
#include "nsContainerFrame.h"
|
||||||
|
@ -2171,12 +2171,15 @@ Element::GetPrimaryFrame(mozFlushType aType)
|
||||||
nsresult
|
nsresult
|
||||||
Element::LeaveLink(nsPresContext* aPresContext)
|
Element::LeaveLink(nsPresContext* aPresContext)
|
||||||
{
|
{
|
||||||
nsILinkHandler *handler = aPresContext->GetLinkHandler();
|
if (!aPresContext || !aPresContext->Document()->LinkHandlingEnabled()) {
|
||||||
if (!handler) {
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
return handler->OnLeaveLink();
|
nsIDocShell* shell = aPresContext->Document()->GetDocShell();
|
||||||
|
if (!shell) {
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
return nsDocShell::Cast(shell)->OnLeaveLink();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
@ -2941,7 +2944,6 @@ Element::CheckHandleEventForLinksPrecondition(EventChainVisitor& aVisitor,
|
||||||
(aVisitor.mEvent->mMessage != eMouseClick) &&
|
(aVisitor.mEvent->mMessage != eMouseClick) &&
|
||||||
(aVisitor.mEvent->mMessage != eKeyPress) &&
|
(aVisitor.mEvent->mMessage != eKeyPress) &&
|
||||||
(aVisitor.mEvent->mMessage != eLegacyDOMActivate)) ||
|
(aVisitor.mEvent->mMessage != eLegacyDOMActivate)) ||
|
||||||
!aVisitor.mPresContext ||
|
|
||||||
aVisitor.mEvent->mFlags.mMultipleActionsPrevented) {
|
aVisitor.mEvent->mFlags.mMultipleActionsPrevented) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2985,7 +2987,7 @@ Element::PreHandleEventForLinks(EventChainPreVisitor& aVisitor)
|
||||||
if (!focusEvent || !focusEvent->isRefocus) {
|
if (!focusEvent || !focusEvent->isRefocus) {
|
||||||
nsAutoString target;
|
nsAutoString target;
|
||||||
GetLinkTarget(target);
|
GetLinkTarget(target);
|
||||||
nsContentUtils::TriggerLink(this, aVisitor.mPresContext, absURI, target,
|
nsContentUtils::TriggerLink(this, absURI, target,
|
||||||
false, true, true);
|
false, true, true);
|
||||||
// Make sure any ancestor links don't also TriggerLink
|
// Make sure any ancestor links don't also TriggerLink
|
||||||
aVisitor.mEvent->mFlags.mMultipleActionsPrevented = true;
|
aVisitor.mEvent->mFlags.mMultipleActionsPrevented = true;
|
||||||
|
@ -3038,27 +3040,28 @@ Element::PostHandleEventForLinks(EventChainPostVisitor& aVisitor)
|
||||||
case eMouseDown:
|
case eMouseDown:
|
||||||
{
|
{
|
||||||
if (aVisitor.mEvent->AsMouseEvent()->button ==
|
if (aVisitor.mEvent->AsMouseEvent()->button ==
|
||||||
WidgetMouseEvent::eLeftButton) {
|
WidgetMouseEvent::eLeftButton &&
|
||||||
// don't make the link grab the focus if there is no link handler
|
OwnerDoc()->LinkHandlingEnabled()) {
|
||||||
nsILinkHandler *handler = aVisitor.mPresContext->GetLinkHandler();
|
aVisitor.mEvent->mFlags.mMultipleActionsPrevented = true;
|
||||||
nsIDocument *document = GetComposedDoc();
|
if (IsInComposedDoc()) {
|
||||||
if (handler && document) {
|
if (nsIFocusManager* fm = nsFocusManager::GetFocusManager()) {
|
||||||
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
|
|
||||||
if (fm) {
|
|
||||||
aVisitor.mEvent->mFlags.mMultipleActionsPrevented = true;
|
|
||||||
nsCOMPtr<nsIDOMElement> elem = do_QueryInterface(this);
|
nsCOMPtr<nsIDOMElement> elem = do_QueryInterface(this);
|
||||||
fm->SetFocus(elem, nsIFocusManager::FLAG_BYMOUSE |
|
fm->SetFocus(elem, nsIFocusManager::FLAG_BYMOUSE |
|
||||||
nsIFocusManager::FLAG_NOSCROLL);
|
nsIFocusManager::FLAG_NOSCROLL);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aVisitor.mPresContext) {
|
||||||
EventStateManager::SetActiveManager(
|
EventStateManager::SetActiveManager(
|
||||||
aVisitor.mPresContext->EventStateManager(), this);
|
aVisitor.mPresContext->EventStateManager(), this);
|
||||||
|
}
|
||||||
|
|
||||||
// OK, we're pretty sure we're going to load, so warm up a speculative
|
// OK, we're pretty sure we're going to load, so warm up a speculative
|
||||||
// connection to be sure we have one ready when we open the channel.
|
// connection to be sure we have one ready when we open the channel.
|
||||||
|
if (nsIDocShell* shell = OwnerDoc()->GetDocShell()) {
|
||||||
nsCOMPtr<nsISpeculativeConnect>
|
nsCOMPtr<nsISpeculativeConnect>
|
||||||
speculator(do_QueryInterface(nsContentUtils::GetIOService()));
|
speculator(do_QueryInterface(nsContentUtils::GetIOService()));
|
||||||
nsCOMPtr<nsIInterfaceRequestor> ir = do_QueryInterface(handler);
|
nsCOMPtr<nsIInterfaceRequestor> ir = do_QueryInterface(shell);
|
||||||
// We need bug 1304219 for this part, but this will suffice for now.
|
// We need bug 1304219 for this part, but this will suffice for now.
|
||||||
//speculator->SpeculativeConnect2(absURI, NodePrincipal(), ir);
|
//speculator->SpeculativeConnect2(absURI, NodePrincipal(), ir);
|
||||||
speculator->SpeculativeConnect(absURI, ir);
|
speculator->SpeculativeConnect(absURI, ir);
|
||||||
|
@ -3076,19 +3079,16 @@ Element::PostHandleEventForLinks(EventChainPostVisitor& aVisitor)
|
||||||
}
|
}
|
||||||
|
|
||||||
// The default action is simply to dispatch DOMActivate
|
// The default action is simply to dispatch DOMActivate
|
||||||
nsCOMPtr<nsIPresShell> shell = aVisitor.mPresContext->GetPresShell();
|
nsEventStatus status = nsEventStatus_eIgnore;
|
||||||
if (shell) {
|
// DOMActive event should be trusted since the activation is actually
|
||||||
// single-click
|
// occurred even if the cause is an untrusted click event.
|
||||||
nsEventStatus status = nsEventStatus_eIgnore;
|
InternalUIEvent actEvent(true, eLegacyDOMActivate, mouseEvent);
|
||||||
// DOMActive event should be trusted since the activation is actually
|
actEvent.detail = 1;
|
||||||
// occurred even if the cause is an untrusted click event.
|
|
||||||
InternalUIEvent actEvent(true, eLegacyDOMActivate, mouseEvent);
|
|
||||||
actEvent.detail = 1;
|
|
||||||
|
|
||||||
rv = shell->HandleDOMEventWithTarget(this, &actEvent, &status);
|
rv = EventDispatcher::Dispatch(this, aVisitor.mPresContext, &actEvent,
|
||||||
if (NS_SUCCEEDED(rv)) {
|
nullptr, &status);
|
||||||
aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
|
if (NS_SUCCEEDED(rv)) {
|
||||||
}
|
aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -3100,7 +3100,7 @@ Element::PostHandleEventForLinks(EventChainPostVisitor& aVisitor)
|
||||||
GetLinkTarget(target);
|
GetLinkTarget(target);
|
||||||
const InternalUIEvent* activeEvent = aVisitor.mEvent->AsUIEvent();
|
const InternalUIEvent* activeEvent = aVisitor.mEvent->AsUIEvent();
|
||||||
MOZ_ASSERT(activeEvent);
|
MOZ_ASSERT(activeEvent);
|
||||||
nsContentUtils::TriggerLink(this, aVisitor.mPresContext, absURI, target,
|
nsContentUtils::TriggerLink(this, absURI, target,
|
||||||
true, true, activeEvent->IsTrustable());
|
true, true, activeEvent->IsTrustable());
|
||||||
aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
|
aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
#include "mozilla/EventStates.h" // for member
|
#include "mozilla/EventStates.h" // for member
|
||||||
#include "mozilla/dom/DirectionalityUtils.h"
|
#include "mozilla/dom/DirectionalityUtils.h"
|
||||||
#include "nsIDOMElement.h"
|
#include "nsIDOMElement.h"
|
||||||
#include "nsILinkHandler.h"
|
|
||||||
#include "nsINodeList.h"
|
#include "nsINodeList.h"
|
||||||
#include "nsNodeUtils.h"
|
#include "nsNodeUtils.h"
|
||||||
#include "nsAttrAndChildArray.h"
|
#include "nsAttrAndChildArray.h"
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
#include "nsIDOMNodeList.h"
|
#include "nsIDOMNodeList.h"
|
||||||
#include "nsIContentIterator.h"
|
#include "nsIContentIterator.h"
|
||||||
#include "nsFocusManager.h"
|
#include "nsFocusManager.h"
|
||||||
#include "nsILinkHandler.h"
|
|
||||||
#include "nsIScriptGlobalObject.h"
|
#include "nsIScriptGlobalObject.h"
|
||||||
#include "nsIURL.h"
|
#include "nsIURL.h"
|
||||||
#include "nsNetUtil.h"
|
#include "nsNetUtil.h"
|
||||||
|
|
|
@ -81,6 +81,7 @@
|
||||||
#include "nsCycleCollectionParticipant.h"
|
#include "nsCycleCollectionParticipant.h"
|
||||||
#include "nsCycleCollector.h"
|
#include "nsCycleCollector.h"
|
||||||
#include "nsDataHashtable.h"
|
#include "nsDataHashtable.h"
|
||||||
|
#include "nsDocShell.h"
|
||||||
#include "nsDocShellCID.h"
|
#include "nsDocShellCID.h"
|
||||||
#include "nsDocument.h"
|
#include "nsDocument.h"
|
||||||
#include "nsDOMCID.h"
|
#include "nsDOMCID.h"
|
||||||
|
@ -4795,25 +4796,24 @@ nsContentUtils::CombineResourcePrincipals(nsCOMPtr<nsIPrincipal>* aResourcePrinc
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
void
|
void
|
||||||
nsContentUtils::TriggerLink(nsIContent *aContent, nsPresContext *aPresContext,
|
nsContentUtils::TriggerLink(nsIContent *aContent,
|
||||||
nsIURI *aLinkURI, const nsString &aTargetSpec,
|
nsIURI *aLinkURI, const nsString &aTargetSpec,
|
||||||
bool aClick, bool aIsUserTriggered,
|
bool aClick, bool aIsUserTriggered,
|
||||||
bool aIsTrusted)
|
bool aIsTrusted)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(aPresContext, "Need a nsPresContext");
|
|
||||||
NS_PRECONDITION(aLinkURI, "No link URI");
|
NS_PRECONDITION(aLinkURI, "No link URI");
|
||||||
|
|
||||||
if (aContent->IsEditable()) {
|
if (aContent->IsEditable() || !aContent->OwnerDoc()->LinkHandlingEnabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsILinkHandler *handler = aPresContext->GetLinkHandler();
|
nsCOMPtr<nsIDocShell> docShell = aContent->OwnerDoc()->GetDocShell();
|
||||||
if (!handler) {
|
if (!docShell) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!aClick) {
|
if (!aClick) {
|
||||||
handler->OnOverLink(aContent, aLinkURI, aTargetSpec.get());
|
nsDocShell::Cast(docShell)->OnOverLink(aContent, aLinkURI, aTargetSpec.get());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4848,7 +4848,7 @@ nsContentUtils::TriggerLink(nsIContent *aContent, nsPresContext *aPresContext,
|
||||||
fileName.SetIsVoid(true); // No actionable download attribute was found.
|
fileName.SetIsVoid(true); // No actionable download attribute was found.
|
||||||
}
|
}
|
||||||
|
|
||||||
handler->OnLinkClick(aContent, aLinkURI,
|
nsDocShell::Cast(docShell)->OnLinkClick(aContent, aLinkURI,
|
||||||
fileName.IsVoid() ? aTargetSpec.get() : EmptyString().get(),
|
fileName.IsVoid() ? aTargetSpec.get() : EmptyString().get(),
|
||||||
fileName, nullptr, nullptr, aIsTrusted);
|
fileName, nullptr, nullptr, aIsTrusted);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1506,7 +1506,6 @@ public:
|
||||||
* security check using aContent's principal.
|
* security check using aContent's principal.
|
||||||
*
|
*
|
||||||
* @param aContent the node on which a link was triggered.
|
* @param aContent the node on which a link was triggered.
|
||||||
* @param aPresContext the pres context, must be non-null.
|
|
||||||
* @param aLinkURI the URI of the link, must be non-null.
|
* @param aLinkURI the URI of the link, must be non-null.
|
||||||
* @param aTargetSpec the target (like target=, may be empty).
|
* @param aTargetSpec the target (like target=, may be empty).
|
||||||
* @param aClick whether this was a click or not (if false, this method
|
* @param aClick whether this was a click or not (if false, this method
|
||||||
|
@ -1517,7 +1516,7 @@ public:
|
||||||
* @param aIsTrusted If false, JS Context will be pushed to stack
|
* @param aIsTrusted If false, JS Context will be pushed to stack
|
||||||
* when the link is triggered.
|
* when the link is triggered.
|
||||||
*/
|
*/
|
||||||
static void TriggerLink(nsIContent *aContent, nsPresContext *aPresContext,
|
static void TriggerLink(nsIContent *aContent,
|
||||||
nsIURI *aLinkURI, const nsString& aTargetSpec,
|
nsIURI *aLinkURI, const nsString& aTargetSpec,
|
||||||
bool aClick, bool aIsUserTriggered,
|
bool aClick, bool aIsUserTriggered,
|
||||||
bool aIsTrusted);
|
bool aIsTrusted);
|
||||||
|
|
|
@ -1435,6 +1435,7 @@ nsIDocument::nsIDocument()
|
||||||
mPostedFlushUserFontSet(false),
|
mPostedFlushUserFontSet(false),
|
||||||
mDidFireDOMContentLoaded(true),
|
mDidFireDOMContentLoaded(true),
|
||||||
mFrameRequestCallbacksScheduled(false),
|
mFrameRequestCallbacksScheduled(false),
|
||||||
|
mLinksEnabled(true),
|
||||||
mPartID(0),
|
mPartID(0),
|
||||||
mUserHasInteracted(false)
|
mUserHasInteracted(false)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1358,7 +1358,8 @@ public:
|
||||||
virtual void SetContainer(nsDocShell* aContainer);
|
virtual void SetContainer(nsDocShell* aContainer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the container (docshell) for this document.
|
* Get the container (docshell) for this document. Virtual so that
|
||||||
|
* the shell service can call it.
|
||||||
*/
|
*/
|
||||||
virtual nsISupports* GetContainer() const;
|
virtual nsISupports* GetContainer() const;
|
||||||
|
|
||||||
|
@ -2679,6 +2680,9 @@ public:
|
||||||
|
|
||||||
bool InlineScriptAllowedByCSP();
|
bool InlineScriptAllowedByCSP();
|
||||||
|
|
||||||
|
void SetLinkHandlingEnabled(bool aValue) { mLinksEnabled = aValue; }
|
||||||
|
bool LinkHandlingEnabled() { return mLinksEnabled; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool GetUseCounter(mozilla::UseCounter aUseCounter)
|
bool GetUseCounter(mozilla::UseCounter aUseCounter)
|
||||||
{
|
{
|
||||||
|
@ -2960,6 +2964,10 @@ protected:
|
||||||
// UpdateFrameRequestCallbackSchedulingState.
|
// UpdateFrameRequestCallbackSchedulingState.
|
||||||
bool mFrameRequestCallbacksScheduled : 1;
|
bool mFrameRequestCallbacksScheduled : 1;
|
||||||
|
|
||||||
|
// False if we've disabled link handling for elements inside this document,
|
||||||
|
// true otherwise.
|
||||||
|
bool mLinksEnabled : 1;
|
||||||
|
|
||||||
enum Type {
|
enum Type {
|
||||||
eUnknown, // should never be used
|
eUnknown, // should never be used
|
||||||
eHTML,
|
eHTML,
|
||||||
|
|
|
@ -61,7 +61,6 @@
|
||||||
#include "nsIDOMNodeList.h"
|
#include "nsIDOMNodeList.h"
|
||||||
#include "nsIEditor.h"
|
#include "nsIEditor.h"
|
||||||
#include "nsIEditorIMESupport.h"
|
#include "nsIEditorIMESupport.h"
|
||||||
#include "nsILinkHandler.h"
|
|
||||||
#include "mozilla/dom/NodeInfo.h"
|
#include "mozilla/dom/NodeInfo.h"
|
||||||
#include "mozilla/dom/NodeInfoInlines.h"
|
#include "mozilla/dom/NodeInfoInlines.h"
|
||||||
#include "nsIPresShell.h"
|
#include "nsIPresShell.h"
|
||||||
|
|
|
@ -215,16 +215,9 @@ HTMLAnchorElement::IsHTMLFocusable(bool aWithMouse,
|
||||||
}
|
}
|
||||||
|
|
||||||
// cannot focus links if there is no link handler
|
// cannot focus links if there is no link handler
|
||||||
nsIDocument* doc = GetComposedDoc();
|
if (!OwnerDoc()->LinkHandlingEnabled()) {
|
||||||
if (doc) {
|
*aIsFocusable = false;
|
||||||
nsIPresShell* presShell = doc->GetShell();
|
return false;
|
||||||
if (presShell) {
|
|
||||||
nsPresContext* presContext = presShell->GetPresContext();
|
|
||||||
if (presContext && !presContext->GetLinkHandler()) {
|
|
||||||
*aIsFocusable = false;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Links that are in an editable region should never be focusable, even if
|
// Links that are in an editable region should never be focusable, even if
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "nsPresContext.h"
|
#include "nsPresContext.h"
|
||||||
#include "nsIDocument.h"
|
#include "nsIDocument.h"
|
||||||
#include "nsIFormControlFrame.h"
|
#include "nsIFormControlFrame.h"
|
||||||
|
#include "nsILinkHandler.h"
|
||||||
#include "nsError.h"
|
#include "nsError.h"
|
||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
#include "nsInterfaceHashtable.h"
|
#include "nsInterfaceHashtable.h"
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsIForm.h"
|
#include "nsIForm.h"
|
||||||
#include "nsILinkHandler.h"
|
|
||||||
#include "nsIDocument.h"
|
#include "nsIDocument.h"
|
||||||
#include "nsGkAtoms.h"
|
#include "nsGkAtoms.h"
|
||||||
#include "nsIFormControl.h"
|
#include "nsIFormControl.h"
|
||||||
|
|
|
@ -653,22 +653,9 @@ nsGenericHTMLElement::CheckHandleEventForAnchorsPreconditions(
|
||||||
{
|
{
|
||||||
NS_PRECONDITION(nsCOMPtr<Link>(do_QueryObject(this)),
|
NS_PRECONDITION(nsCOMPtr<Link>(do_QueryObject(this)),
|
||||||
"should be called only when |this| implements |Link|");
|
"should be called only when |this| implements |Link|");
|
||||||
|
// When disconnected, only <a> should navigate away per
|
||||||
if (!aVisitor.mPresContext) {
|
// https://html.spec.whatwg.org/#cannot-navigate
|
||||||
// We need a pres context to do link stuff. Some events (e.g. mutation
|
return IsInComposedDoc() || IsHTMLElement(nsGkAtoms::a);
|
||||||
// events) don't have one.
|
|
||||||
// XXX: ideally, shouldn't we be able to do what we need without one?
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Need to check if we hit an imagemap area and if so see if we're handling
|
|
||||||
//the event on that map or on a link farther up the tree. If we're on a
|
|
||||||
//link farther up, do nothing.
|
|
||||||
nsCOMPtr<nsIContent> target = aVisitor.mPresContext->EventStateManager()->
|
|
||||||
GetEventTargetContent(aVisitor.mEvent);
|
|
||||||
|
|
||||||
return !target || !target->IsHTMLElement(nsGkAtoms::area) ||
|
|
||||||
IsHTMLElement(nsGkAtoms::area);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
|
|
@ -187,6 +187,12 @@ SVGAElement::IsAttributeMapped(const nsIAtom* name) const
|
||||||
bool
|
bool
|
||||||
SVGAElement::IsFocusableInternal(int32_t *aTabIndex, bool aWithMouse)
|
SVGAElement::IsFocusableInternal(int32_t *aTabIndex, bool aWithMouse)
|
||||||
{
|
{
|
||||||
|
// There are some backbugs in
|
||||||
|
// https://hg.mozilla.org/mozilla-central/rev/fc09b999be43
|
||||||
|
if (!OwnerDoc()->LinkHandlingEnabled()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIURI> uri;
|
nsCOMPtr<nsIURI> uri;
|
||||||
if (IsLink(getter_AddRefs(uri))) {
|
if (IsLink(getter_AddRefs(uri))) {
|
||||||
if (aTabIndex) {
|
if (aTabIndex) {
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
#include "nsIDOMHTMLAnchorElement.h"
|
#include "nsIDOMHTMLAnchorElement.h"
|
||||||
#include "nsISelectionController.h"
|
#include "nsISelectionController.h"
|
||||||
#include "nsIDOMHTMLDocument.h"
|
#include "nsIDOMHTMLDocument.h"
|
||||||
#include "nsILinkHandler.h"
|
|
||||||
#include "nsIInlineSpellChecker.h"
|
#include "nsIInlineSpellChecker.h"
|
||||||
|
|
||||||
#include "mozilla/CSSStyleSheet.h"
|
#include "mozilla/CSSStyleSheet.h"
|
||||||
|
@ -143,13 +142,10 @@ nsHTMLEditor::~nsHTMLEditor()
|
||||||
// free any default style propItems
|
// free any default style propItems
|
||||||
RemoveAllDefaultProperties();
|
RemoveAllDefaultProperties();
|
||||||
|
|
||||||
if (mLinkHandler && mDocWeak)
|
if (mDisabledLinkHandling) {
|
||||||
{
|
nsCOMPtr<nsIDocument> doc = GetDocument();
|
||||||
nsCOMPtr<nsIPresShell> ps = GetPresShell();
|
if (doc) {
|
||||||
|
doc->SetLinkHandlingEnabled(mOldLinkHandlingEnabled);
|
||||||
if (ps && ps->GetPresContext())
|
|
||||||
{
|
|
||||||
ps->GetPresContext()->SetLinkHandler(mLinkHandler);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,14 +264,12 @@ nsHTMLEditor::Init(nsIDOMDocument *aDoc,
|
||||||
mHTMLCSSUtils = new nsHTMLCSSUtils(this);
|
mHTMLCSSUtils = new nsHTMLCSSUtils(this);
|
||||||
|
|
||||||
// disable links
|
// disable links
|
||||||
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
|
nsCOMPtr<nsIDocument> doc = GetDocument();
|
||||||
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
|
||||||
nsPresContext *context = presShell->GetPresContext();
|
|
||||||
NS_ENSURE_TRUE(context, NS_ERROR_NULL_POINTER);
|
|
||||||
if (!IsPlaintextEditor() && !IsInteractionAllowed()) {
|
if (!IsPlaintextEditor() && !IsInteractionAllowed()) {
|
||||||
mLinkHandler = context->GetLinkHandler();
|
mDisabledLinkHandling = true;
|
||||||
|
mOldLinkHandlingEnabled = doc->LinkHandlingEnabled();
|
||||||
context->SetLinkHandler(nullptr);
|
doc->SetLinkHandlingEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// init the type-in state
|
// init the type-in state
|
||||||
|
|
|
@ -46,7 +46,6 @@ class nsITransferable;
|
||||||
class nsIClipboard;
|
class nsIClipboard;
|
||||||
class TypeInState;
|
class TypeInState;
|
||||||
class nsIContentFilter;
|
class nsIContentFilter;
|
||||||
class nsILinkHandler;
|
|
||||||
class nsTableOuterFrame;
|
class nsTableOuterFrame;
|
||||||
class nsIDOMRange;
|
class nsIDOMRange;
|
||||||
class nsRange;
|
class nsRange;
|
||||||
|
@ -954,7 +953,8 @@ protected:
|
||||||
void AddMouseClickListener(nsIDOMElement * aElement);
|
void AddMouseClickListener(nsIDOMElement * aElement);
|
||||||
void RemoveMouseClickListener(nsIDOMElement * aElement);
|
void RemoveMouseClickListener(nsIDOMElement * aElement);
|
||||||
|
|
||||||
nsCOMPtr<nsILinkHandler> mLinkHandler;
|
bool mDisabledLinkHandling = false;
|
||||||
|
bool mOldLinkHandlingEnabled = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include "nsIWritablePropertyBag2.h"
|
#include "nsIWritablePropertyBag2.h"
|
||||||
#include "nsSubDocumentFrame.h"
|
#include "nsSubDocumentFrame.h"
|
||||||
|
|
||||||
#include "nsILinkHandler.h"
|
|
||||||
#include "nsIDOMDocument.h"
|
#include "nsIDOMDocument.h"
|
||||||
#include "nsISelectionListener.h"
|
#include "nsISelectionListener.h"
|
||||||
#include "mozilla/dom/Selection.h"
|
#include "mozilla/dom/Selection.h"
|
||||||
|
@ -884,12 +883,7 @@ nsDocumentViewer::InitInternal(nsIWidget* aParentWidget,
|
||||||
nsCOMPtr<nsIInterfaceRequestor> requestor(mContainer);
|
nsCOMPtr<nsIInterfaceRequestor> requestor(mContainer);
|
||||||
if (requestor) {
|
if (requestor) {
|
||||||
if (mPresContext) {
|
if (mPresContext) {
|
||||||
nsCOMPtr<nsILinkHandler> linkHandler;
|
|
||||||
requestor->GetInterface(NS_GET_IID(nsILinkHandler),
|
|
||||||
getter_AddRefs(linkHandler));
|
|
||||||
|
|
||||||
mPresContext->SetContainer(mContainer);
|
mPresContext->SetContainer(mContainer);
|
||||||
mPresContext->SetLinkHandler(linkHandler);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set script-context-owner in the document
|
// Set script-context-owner in the document
|
||||||
|
@ -1368,7 +1362,6 @@ AttachContainerRecurse(nsIDocShell* aShell)
|
||||||
viewer->GetPresContext(getter_AddRefs(pc));
|
viewer->GetPresContext(getter_AddRefs(pc));
|
||||||
if (pc) {
|
if (pc) {
|
||||||
pc->SetContainer(static_cast<nsDocShell*>(aShell));
|
pc->SetContainer(static_cast<nsDocShell*>(aShell));
|
||||||
pc->SetLinkHandler(nsCOMPtr<nsILinkHandler>(do_QueryInterface(aShell)));
|
|
||||||
}
|
}
|
||||||
nsCOMPtr<nsIPresShell> presShell;
|
nsCOMPtr<nsIPresShell> presShell;
|
||||||
viewer->GetPresShell(getter_AddRefs(presShell));
|
viewer->GetPresShell(getter_AddRefs(presShell));
|
||||||
|
@ -2081,12 +2074,6 @@ nsDocumentViewer::Show(void)
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
if (mPresContext && base_win) {
|
if (mPresContext && base_win) {
|
||||||
nsCOMPtr<nsILinkHandler> linkHandler(do_GetInterface(base_win));
|
|
||||||
|
|
||||||
if (linkHandler) {
|
|
||||||
mPresContext->SetLinkHandler(linkHandler);
|
|
||||||
}
|
|
||||||
|
|
||||||
mPresContext->SetContainer(mContainer);
|
mPresContext->SetContainer(mContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1720,7 +1720,6 @@ nsPresContext::GetDocShell() const
|
||||||
nsPresContext::Detach()
|
nsPresContext::Detach()
|
||||||
{
|
{
|
||||||
SetContainer(nullptr);
|
SetContainer(nullptr);
|
||||||
SetLinkHandler(nullptr);
|
|
||||||
if (mShell) {
|
if (mShell) {
|
||||||
mShell->CancelInvalidatePresShellIfHidden();
|
mShell->CancelInvalidatePresShellIfHidden();
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,6 @@ class nsITheme;
|
||||||
class nsIContent;
|
class nsIContent;
|
||||||
class nsIFrame;
|
class nsIFrame;
|
||||||
class nsFrameManager;
|
class nsFrameManager;
|
||||||
class nsILinkHandler;
|
|
||||||
class nsIAtom;
|
class nsIAtom;
|
||||||
class nsIRunnable;
|
class nsIRunnable;
|
||||||
class gfxUserFontEntry;
|
class gfxUserFontEntry;
|
||||||
|
@ -436,13 +435,8 @@ public:
|
||||||
|
|
||||||
nsIDocShell* GetDocShell() const;
|
nsIDocShell* GetDocShell() const;
|
||||||
|
|
||||||
// XXX this are going to be replaced with set/get container
|
|
||||||
void SetLinkHandler(nsILinkHandler* aHandler) { mLinkHandler = aHandler; }
|
|
||||||
nsILinkHandler* GetLinkHandler() { return mLinkHandler; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detach this pres context - i.e. cancel relevant timers,
|
* Detach this pres context - i.e. cancel relevant timers, etc.
|
||||||
* SetLinkHandler(null), SetContainer(null) etc.
|
|
||||||
* Only to be used by the DocumentViewer.
|
* Only to be used by the DocumentViewer.
|
||||||
*/
|
*/
|
||||||
virtual void Detach();
|
virtual void Detach();
|
||||||
|
@ -1228,10 +1222,6 @@ protected:
|
||||||
nsIAtom* MOZ_UNSAFE_REF("always a static atom") mMedium; // initialized by subclass ctors
|
nsIAtom* MOZ_UNSAFE_REF("always a static atom") mMedium; // initialized by subclass ctors
|
||||||
nsCOMPtr<nsIAtom> mMediaEmulated;
|
nsCOMPtr<nsIAtom> mMediaEmulated;
|
||||||
|
|
||||||
// This pointer is nulled out through SetLinkHandler() in the destructors of
|
|
||||||
// the classes which set it. (using SetLinkHandler() again).
|
|
||||||
nsILinkHandler* MOZ_NON_OWNING_REF mLinkHandler;
|
|
||||||
|
|
||||||
// Formerly mLangGroup; moving from charset-oriented langGroup to
|
// Formerly mLangGroup; moving from charset-oriented langGroup to
|
||||||
// maintaining actual language settings everywhere (see bug 524107).
|
// maintaining actual language settings everywhere (see bug 524107).
|
||||||
// This may in fact hold a langGroup such as x-western rather than
|
// This may in fact hold a langGroup such as x-western rather than
|
||||||
|
|
|
@ -1333,9 +1333,6 @@ PresShell::Destroy()
|
||||||
// to us. To avoid the pres context having a dangling reference, set its
|
// to us. To avoid the pres context having a dangling reference, set its
|
||||||
// pres shell to nullptr
|
// pres shell to nullptr
|
||||||
mPresContext->SetShell(nullptr);
|
mPresContext->SetShell(nullptr);
|
||||||
|
|
||||||
// Clear the link handler (weak reference) as well
|
|
||||||
mPresContext->SetLinkHandler(nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mHaveShutDown = true;
|
mHaveShutDown = true;
|
||||||
|
|
|
@ -2061,7 +2061,7 @@ nsImageFrame::HandleEvent(nsPresContext* aPresContext,
|
||||||
*aEventStatus = nsEventStatus_eConsumeDoDefault;
|
*aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||||
clicked = true;
|
clicked = true;
|
||||||
}
|
}
|
||||||
nsContentUtils::TriggerLink(anchorNode, aPresContext, uri, target,
|
nsContentUtils::TriggerLink(anchorNode, uri, target,
|
||||||
clicked, true, true);
|
clicked, true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#include "nsIPresShell.h"
|
#include "nsIPresShell.h"
|
||||||
#include "nsIDocument.h"
|
#include "nsIDocument.h"
|
||||||
#include "nsImageMap.h"
|
#include "nsImageMap.h"
|
||||||
#include "nsILinkHandler.h"
|
|
||||||
#include "nsIURL.h"
|
#include "nsIURL.h"
|
||||||
#include "nsILoadGroup.h"
|
#include "nsILoadGroup.h"
|
||||||
#include "nsContainerFrame.h"
|
#include "nsContainerFrame.h"
|
||||||
|
|
Loading…
Reference in New Issue