From 9dd8b1ad80ec1e34b973f4fc01927ac173a814a9 Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Thu, 8 Aug 2013 01:26:32 -0400 Subject: [PATCH] Bug 902732: Merge nsILink and dom::Link r=bz --- accessible/src/generic/BaseAccessibles.cpp | 1 - accessible/src/generic/ImageAccessible.cpp | 1 - content/base/src/nsDocument.cpp | 16 ++---- content/html/content/public/moz.build | 1 - content/html/content/public/nsILink.h | 52 ------------------- .../html/content/src/HTMLAnchorElement.cpp | 4 +- content/html/content/src/HTMLAnchorElement.h | 6 --- content/html/content/src/HTMLAreaElement.cpp | 4 +- content/html/content/src/HTMLAreaElement.h | 6 --- content/html/content/src/HTMLLinkElement.cpp | 10 ++-- content/html/content/src/HTMLLinkElement.h | 7 +-- .../html/content/src/nsGenericHTMLElement.cpp | 8 +-- .../mathml/content/src/nsMathMLElement.cpp | 5 +- content/mathml/content/src/nsMathMLElement.h | 4 -- content/svg/content/src/SVGAElement.cpp | 4 +- content/svg/content/src/SVGAElement.h | 6 --- layout/generic/nsImageFrame.cpp | 5 +- .../typeaheadfind/nsTypeAheadFind.cpp | 4 +- 18 files changed, 26 insertions(+), 118 deletions(-) delete mode 100644 content/html/content/public/nsILink.h diff --git a/accessible/src/generic/BaseAccessibles.cpp b/accessible/src/generic/BaseAccessibles.cpp index 0a42d9e6112..e7aa3341e3d 100644 --- a/accessible/src/generic/BaseAccessibles.cpp +++ b/accessible/src/generic/BaseAccessibles.cpp @@ -14,7 +14,6 @@ #include "States.h" #include "nsGUIEvent.h" -#include "nsILink.h" #include "nsINameSpaceManager.h" #include "nsIURI.h" diff --git a/accessible/src/generic/ImageAccessible.cpp b/accessible/src/generic/ImageAccessible.cpp index d5cead3dda1..ec5f085dc1d 100644 --- a/accessible/src/generic/ImageAccessible.cpp +++ b/accessible/src/generic/ImageAccessible.cpp @@ -15,7 +15,6 @@ #include "nsGenericHTMLElement.h" #include "nsIDocument.h" #include "nsIImageLoadingContent.h" -#include "nsILink.h" #include "nsIPresShell.h" #include "nsIServiceManager.h" #include "nsIDOMHTMLImageElement.h" diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 27d8138589e..d56e2cdd73c 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -112,7 +112,6 @@ #include "nsHTMLDocument.h" #include "nsIDOMHTMLFormElement.h" #include "nsIRequest.h" -#include "nsILink.h" #include "nsHostObjectProtocolHandler.h" #include "nsCharsetAlias.h" @@ -149,6 +148,7 @@ #include "nsObjectLoadingContent.h" #include "nsHtml5TreeOpExecutor.h" #include "nsIDOMElementReplaceEvent.h" +#include "mozilla/dom/HTMLLinkElement.h" #include "mozilla/dom/HTMLMediaElement.h" #ifdef MOZ_WEBRTC #include "IPeerConnection.h" @@ -8067,15 +8067,12 @@ nsDocument::OnPageShow(bool aPersisted, if (aPersisted && root) { // Send out notifications that our elements are attached. nsRefPtr links = NS_GetContentList(root, - kNameSpaceID_Unknown, + kNameSpaceID_XHTML, NS_LITERAL_STRING("link")); uint32_t linkCount = links->Length(true); for (uint32_t i = 0; i < linkCount; ++i) { - nsCOMPtr link = do_QueryInterface(links->Item(i, false)); - if (link) { - link->LinkAdded(); - } + static_cast(links->Item(i, false))->LinkAdded(); } } @@ -8131,15 +8128,12 @@ nsDocument::OnPageHide(bool aPersisted, Element* root = GetRootElement(); if (aPersisted && root) { nsRefPtr links = NS_GetContentList(root, - kNameSpaceID_Unknown, + kNameSpaceID_XHTML, NS_LITERAL_STRING("link")); uint32_t linkCount = links->Length(true); for (uint32_t i = 0; i < linkCount; ++i) { - nsCOMPtr link = do_QueryInterface(links->Item(i, false)); - if (link) { - link->LinkRemoved(); - } + static_cast(links->Item(i, false))->LinkRemoved(); } } diff --git a/content/html/content/public/moz.build b/content/html/content/public/moz.build index 0ca5f3d1bd8..268e6fdf800 100644 --- a/content/html/content/public/moz.build +++ b/content/html/content/public/moz.build @@ -22,7 +22,6 @@ EXPORTS += [ 'nsIFormControl.h', 'nsIFormProcessor.h', 'nsIHTMLCollection.h', - 'nsILink.h', 'nsIRadioGroupContainer.h', 'nsIRadioVisitor.h', 'nsITextControlElement.h', diff --git a/content/html/content/public/nsILink.h b/content/html/content/public/nsILink.h deleted file mode 100644 index 704a53f780a..00000000000 --- a/content/html/content/public/nsILink.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; 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 nsILink_h___ -#define nsILink_h___ - -#include "nsISupports.h" -#include "nsILinkHandler.h" // definition of nsLinkState - -class nsIURI; - -// IID for the nsILink interface -#define NS_ILINK_IID \ -{ 0x6f374a11, 0x212d, 0x47d6, \ - { 0x94, 0xd1, 0xe6, 0x7c, 0x23, 0x4d, 0x34, 0x99 } } - -/** - * This interface allows SelectorMatches to get the canonical - * URL pointed to by an element representing a link and allows - * it to store the visited state of a link element in the link. - * It is needed for performance reasons (to prevent copying of - * strings and excessive calls to history). - */ -class nsILink : public nsISupports { -public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_ILINK_IID) - - /** - * SetLinkState/GetHrefURI were moved to nsIContent. - * @see nsIContent - */ - - /** - * Dispatch a LinkAdded event to the chrome event handler for this document. - * This is used to notify the chrome listeners when restoring a page - * presentation. Currently, this only applies to HTML elements. - */ - NS_IMETHOD LinkAdded() = 0; - - /** - * Dispatch a LinkRemoved event to the chrome event handler for this - * document. This is used to notify the chrome listeners when saving a page - * presentation (since the document is not torn down). Currently, this only - * applies to HTML elements. - */ - NS_IMETHOD LinkRemoved() = 0; -}; - -NS_DEFINE_STATIC_IID_ACCESSOR(nsILink, NS_ILINK_IID) - -#endif /* nsILink_h___ */ diff --git a/content/html/content/src/HTMLAnchorElement.cpp b/content/html/content/src/HTMLAnchorElement.cpp index c2ae09d2307..488018c3461 100644 --- a/content/html/content/src/HTMLAnchorElement.cpp +++ b/content/html/content/src/HTMLAnchorElement.cpp @@ -40,8 +40,8 @@ HTMLAnchorElement::~HTMLAnchorElement() { } -NS_IMPL_ISUPPORTS_INHERITED3(HTMLAnchorElement, nsGenericHTMLElement, - nsIDOMHTMLAnchorElement, nsILink, Link) +NS_IMPL_ISUPPORTS_INHERITED2(HTMLAnchorElement, nsGenericHTMLElement, + nsIDOMHTMLAnchorElement, Link) NS_IMPL_ELEMENT_CLONE(HTMLAnchorElement) diff --git a/content/html/content/src/HTMLAnchorElement.h b/content/html/content/src/HTMLAnchorElement.h index 382780d6a8f..106066fa5c0 100644 --- a/content/html/content/src/HTMLAnchorElement.h +++ b/content/html/content/src/HTMLAnchorElement.h @@ -11,14 +11,12 @@ #include "mozilla/dom/Link.h" #include "nsGenericHTMLElement.h" #include "nsIDOMHTMLAnchorElement.h" -#include "nsILink.h" namespace mozilla { namespace dom { class HTMLAnchorElement MOZ_FINAL : public nsGenericHTMLElement, public nsIDOMHTMLAnchorElement, - public nsILink, public Link { public: @@ -44,10 +42,6 @@ public: // DOM memory reporter participant NS_DECL_SIZEOF_EXCLUDING_THIS - // nsILink - NS_IMETHOD LinkAdded() MOZ_OVERRIDE { return NS_OK; } - NS_IMETHOD LinkRemoved() MOZ_OVERRIDE { return NS_OK; } - virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, nsIContent* aBindingParent, bool aCompileEventHandlers) MOZ_OVERRIDE; diff --git a/content/html/content/src/HTMLAreaElement.cpp b/content/html/content/src/HTMLAreaElement.cpp index b930860895d..d7ebcbd088c 100644 --- a/content/html/content/src/HTMLAreaElement.cpp +++ b/content/html/content/src/HTMLAreaElement.cpp @@ -25,8 +25,8 @@ HTMLAreaElement::~HTMLAreaElement() { } -NS_IMPL_ISUPPORTS_INHERITED3(HTMLAreaElement, nsGenericHTMLElement, - nsIDOMHTMLAreaElement, nsILink, Link) +NS_IMPL_ISUPPORTS_INHERITED2(HTMLAreaElement, nsGenericHTMLElement, + nsIDOMHTMLAreaElement, Link) NS_IMPL_ELEMENT_CLONE(HTMLAreaElement) diff --git a/content/html/content/src/HTMLAreaElement.h b/content/html/content/src/HTMLAreaElement.h index a3f5e51b5dd..83b398a7985 100644 --- a/content/html/content/src/HTMLAreaElement.h +++ b/content/html/content/src/HTMLAreaElement.h @@ -12,7 +12,6 @@ #include "nsGenericHTMLElement.h" #include "nsGkAtoms.h" #include "nsIDOMHTMLAreaElement.h" -#include "nsILink.h" #include "nsIURL.h" class nsIDocument; @@ -22,7 +21,6 @@ namespace dom { class HTMLAreaElement MOZ_FINAL : public nsGenericHTMLElement, public nsIDOMHTMLAreaElement, - public nsILink, public Link { public: @@ -40,10 +38,6 @@ public: // nsIDOMHTMLAreaElement NS_DECL_NSIDOMHTMLAREAELEMENT - // nsILink - NS_IMETHOD LinkAdded() MOZ_OVERRIDE { return NS_OK; } - NS_IMETHOD LinkRemoved() MOZ_OVERRIDE { return NS_OK; } - virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE; virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE; virtual bool IsLink(nsIURI** aURI) const MOZ_OVERRIDE; diff --git a/content/html/content/src/HTMLLinkElement.cpp b/content/html/content/src/HTMLLinkElement.cpp index b2350f949b4..a44b82e8f3d 100644 --- a/content/html/content/src/HTMLLinkElement.cpp +++ b/content/html/content/src/HTMLLinkElement.cpp @@ -15,7 +15,6 @@ #include "nsIDocument.h" #include "nsIDOMEvent.h" #include "nsIDOMStyleSheet.h" -#include "nsILink.h" #include "nsIStyleSheet.h" #include "nsIStyleSheetLinkingElement.h" #include "nsIURL.h" @@ -58,10 +57,9 @@ NS_IMPL_RELEASE_INHERITED(HTMLLinkElement, Element) // QueryInterface implementation for HTMLLinkElement NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(HTMLLinkElement) - NS_INTERFACE_TABLE_INHERITED5(HTMLLinkElement, + NS_INTERFACE_TABLE_INHERITED4(HTMLLinkElement, nsIDOMHTMLLinkElement, nsIDOMLinkStyle, - nsILink, nsIStyleSheetLinkingElement, Link) NS_INTERFACE_TABLE_TAIL_INHERITING(nsGenericHTMLElement) @@ -147,18 +145,16 @@ HTMLLinkElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, return rv; } -NS_IMETHODIMP +void HTMLLinkElement::LinkAdded() { CreateAndDispatchEvent(OwnerDoc(), NS_LITERAL_STRING("DOMLinkAdded")); - return NS_OK; } -NS_IMETHODIMP +void HTMLLinkElement::LinkRemoved() { CreateAndDispatchEvent(OwnerDoc(), NS_LITERAL_STRING("DOMLinkRemoved")); - return NS_OK; } void diff --git a/content/html/content/src/HTMLLinkElement.h b/content/html/content/src/HTMLLinkElement.h index 25a48fd3db7..a74cd3ca140 100644 --- a/content/html/content/src/HTMLLinkElement.h +++ b/content/html/content/src/HTMLLinkElement.h @@ -10,7 +10,6 @@ #include "mozilla/dom/Link.h" #include "nsGenericHTMLElement.h" #include "nsIDOMHTMLLinkElement.h" -#include "nsILink.h" #include "nsStyleLinkElement.h" namespace mozilla { @@ -18,7 +17,6 @@ namespace dom { class HTMLLinkElement MOZ_FINAL : public nsGenericHTMLElement, public nsIDOMHTMLLinkElement, - public nsILink, public nsStyleLinkElement, public Link { @@ -39,9 +37,8 @@ public: // DOM memory reporter participant NS_DECL_SIZEOF_EXCLUDING_THIS - // nsILink - NS_IMETHOD LinkAdded() MOZ_OVERRIDE; - NS_IMETHOD LinkRemoved() MOZ_OVERRIDE; + void LinkAdded(); + void LinkRemoved(); // nsIDOMEventTarget virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) MOZ_OVERRIDE; diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index 9d7e6869537..182ee53353a 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -28,7 +28,6 @@ #include "nsMappedAttributes.h" #include "nsHTMLStyleSheet.h" #include "nsIHTMLDocument.h" -#include "nsILink.h" #include "nsPIDOMWindow.h" #include "nsIStyleRule.h" #include "nsIURL.h" @@ -85,6 +84,7 @@ #include "nsDOMMutationObserver.h" #include "mozilla/Preferences.h" #include "mozilla/dom/FromParser.h" +#include "mozilla/dom/Link.h" #include "mozilla/dom/UndoManager.h" #include "mozilla/BloomFilter.h" @@ -694,8 +694,8 @@ nsGenericHTMLElement::FindAncestorForm(HTMLFormElement* aCurrentForm) bool nsGenericHTMLElement::CheckHandleEventForAnchorsPreconditions(nsEventChainVisitor& aVisitor) { - NS_PRECONDITION(nsCOMPtr(do_QueryObject(this)), - "should be called only when |this| implements |nsILink|"); + NS_PRECONDITION(nsCOMPtr(do_QueryObject(this)), + "should be called only when |this| implements |Link|"); if (!aVisitor.mPresContext) { // We need a pres context to do link stuff. Some events (e.g. mutation @@ -749,7 +749,7 @@ nsGenericHTMLElement::IsHTMLLink(nsIURI** aURI) const already_AddRefed nsGenericHTMLElement::GetHrefURIForAnchors() const { - // This is used by the three nsILink implementations and + // This is used by the three Link implementations and // nsHTMLStyleElement. // Get href= attribute (relative URI). diff --git a/content/mathml/content/src/nsMathMLElement.cpp b/content/mathml/content/src/nsMathMLElement.cpp index e8d1a46f86a..03de7aba8c4 100644 --- a/content/mathml/content/src/nsMathMLElement.cpp +++ b/content/mathml/content/src/nsMathMLElement.cpp @@ -29,9 +29,8 @@ using namespace mozilla::dom; //---------------------------------------------------------------------- // nsISupports methods: -NS_IMPL_ISUPPORTS_INHERITED4(nsMathMLElement, nsMathMLElementBase, - nsIDOMElement, nsIDOMNode, - nsILink, Link) +NS_IMPL_ISUPPORTS_INHERITED3(nsMathMLElement, nsMathMLElementBase, + nsIDOMElement, nsIDOMNode, Link) static nsresult WarnDeprecated(const PRUnichar* aDeprecatedAttribute, diff --git a/content/mathml/content/src/nsMathMLElement.h b/content/mathml/content/src/nsMathMLElement.h index 6285ecd49c1..0f92afe2fa1 100644 --- a/content/mathml/content/src/nsMathMLElement.h +++ b/content/mathml/content/src/nsMathMLElement.h @@ -9,7 +9,6 @@ #include "mozilla/Attributes.h" #include "nsMappedAttributeElement.h" #include "nsIDOMElement.h" -#include "nsILink.h" #include "Link.h" class nsCSSValue; @@ -21,7 +20,6 @@ typedef nsMappedAttributeElement nsMathMLElementBase; */ class nsMathMLElement MOZ_FINAL : public nsMathMLElementBase, public nsIDOMElement, - public nsILink, public mozilla::dom::Link { public: @@ -80,8 +78,6 @@ public: return mIncrementScriptLevel; } - NS_IMETHOD LinkAdded() MOZ_OVERRIDE { return NS_OK; } - NS_IMETHOD LinkRemoved() MOZ_OVERRIDE { return NS_OK; } virtual bool IsFocusable(int32_t *aTabIndex = nullptr, bool aWithMouse = false) MOZ_OVERRIDE; virtual bool IsLink(nsIURI** aURI) const MOZ_OVERRIDE; diff --git a/content/svg/content/src/SVGAElement.cpp b/content/svg/content/src/SVGAElement.cpp index c7a6e4b48f3..1020c99f258 100644 --- a/content/svg/content/src/SVGAElement.cpp +++ b/content/svg/content/src/SVGAElement.cpp @@ -10,7 +10,6 @@ #include "nsCOMPtr.h" #include "nsContentUtils.h" #include "nsGkAtoms.h" -#include "nsILink.h" #include "nsSVGString.h" NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(A) @@ -34,11 +33,10 @@ nsSVGElement::StringInfo SVGAElement::sStringInfo[2] = //---------------------------------------------------------------------- // nsISupports methods -NS_IMPL_ISUPPORTS_INHERITED5(SVGAElement, SVGAElementBase, +NS_IMPL_ISUPPORTS_INHERITED4(SVGAElement, SVGAElementBase, nsIDOMNode, nsIDOMElement, nsIDOMSVGElement, - nsILink, Link) diff --git a/content/svg/content/src/SVGAElement.h b/content/svg/content/src/SVGAElement.h index 36533e66c98..3984d9f9d5e 100644 --- a/content/svg/content/src/SVGAElement.h +++ b/content/svg/content/src/SVGAElement.h @@ -7,7 +7,6 @@ #define mozilla_dom_SVGAElement_h #include "Link.h" -#include "nsILink.h" #include "nsSVGString.h" #include "mozilla/dom/SVGGraphicsElement.h" @@ -20,7 +19,6 @@ namespace dom { typedef SVGGraphicsElement SVGAElementBase; class SVGAElement MOZ_FINAL : public SVGAElementBase, - public nsILink, public Link { protected: @@ -38,10 +36,6 @@ public: virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) MOZ_OVERRIDE; virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE; - // nsILink - NS_IMETHOD LinkAdded() MOZ_OVERRIDE { return NS_OK; } - NS_IMETHOD LinkRemoved() MOZ_OVERRIDE { return NS_OK; } - // nsIContent virtual nsresult BindToTree(nsIDocument *aDocument, nsIContent *aParent, nsIContent *aBindingParent, diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index 5ed849d91e4..fab8f694a1a 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -36,7 +36,6 @@ #include "nsContainerFrame.h" #include "prprf.h" #include "nsCSSRendering.h" -#include "nsILink.h" #include "nsIDOMHTMLAnchorElement.h" #include "nsIDOMHTMLImageElement.h" #include "nsINameSpaceManager.h" @@ -72,6 +71,8 @@ #include "mozilla/Preferences.h" +#include "mozilla/dom/Link.h" + using namespace mozilla; // sizes (pixels) for image icon, padding and border frame @@ -1562,7 +1563,7 @@ nsImageFrame::GetAnchorHREFTargetAndNode(nsIURI** aHref, nsString& aTarget, // Walk up the content tree, looking for an nsIDOMAnchorElement for (nsIContent* content = mContent->GetParent(); content; content = content->GetParent()) { - nsCOMPtr link(do_QueryInterface(content)); + nsCOMPtr link(do_QueryInterface(content)); if (link) { nsCOMPtr href = content->GetHrefURI(); if (href) { diff --git a/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp b/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp index 4cd4a23bdeb..bc6124797b6 100644 --- a/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp +++ b/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp @@ -31,7 +31,6 @@ #include "nsIDOMHTMLElement.h" #include "nsIDocument.h" #include "nsISelection.h" -#include "nsILink.h" #include "nsTextFragment.h" #include "nsIDOMNSEditableElement.h" #include "nsIEditor.h" @@ -49,6 +48,7 @@ #include "nsIObserverService.h" #include "nsFocusManager.h" #include "mozilla/dom/Element.h" +#include "mozilla/dom/Link.h" #include "nsRange.h" #include "nsTypeAheadFind.h" @@ -851,7 +851,7 @@ nsTypeAheadFind::RangeStartsInsideLink(nsIDOMRange *aRange, // eventually we'll run out of ancestors if (startContent->IsHTML()) { - nsCOMPtr link(do_QueryInterface(startContent)); + nsCOMPtr link(do_QueryInterface(startContent)); if (link) { // Check to see if inside HTML link *aIsInsideLink = startContent->HasAttr(kNameSpaceID_None, hrefAtom);