Bug 902732: Merge nsILink and dom::Link r=bz

This commit is contained in:
David Zbarsky 2013-08-08 01:26:32 -04:00
Родитель d7a04ba80c
Коммит 9b8bb85a9c
18 изменённых файлов: 26 добавлений и 118 удалений

Просмотреть файл

@ -14,7 +14,6 @@
#include "States.h"
#include "nsGUIEvent.h"
#include "nsILink.h"
#include "nsINameSpaceManager.h"
#include "nsIURI.h"

Просмотреть файл

@ -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"

Просмотреть файл

@ -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 <link> elements are attached.
nsRefPtr<nsContentList> 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<nsILink> link = do_QueryInterface(links->Item(i, false));
if (link) {
link->LinkAdded();
}
static_cast<HTMLLinkElement*>(links->Item(i, false))->LinkAdded();
}
}
@ -8131,15 +8128,12 @@ nsDocument::OnPageHide(bool aPersisted,
Element* root = GetRootElement();
if (aPersisted && root) {
nsRefPtr<nsContentList> 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<nsILink> link = do_QueryInterface(links->Item(i, false));
if (link) {
link->LinkRemoved();
}
static_cast<HTMLLinkElement*>(links->Item(i, false))->LinkRemoved();
}
}

Просмотреть файл

@ -22,7 +22,6 @@ EXPORTS += [
'nsIFormControl.h',
'nsIFormProcessor.h',
'nsIHTMLCollection.h',
'nsILink.h',
'nsIRadioGroupContainer.h',
'nsIRadioVisitor.h',
'nsITextControlElement.h',

Просмотреть файл

@ -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 <link> 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 <link> elements.
*/
NS_IMETHOD LinkRemoved() = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsILink, NS_ILINK_IID)
#endif /* nsILink_h___ */

Просмотреть файл

@ -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)

Просмотреть файл

@ -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;

Просмотреть файл

@ -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)

Просмотреть файл

@ -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;

Просмотреть файл

@ -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

Просмотреть файл

@ -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;

Просмотреть файл

@ -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<nsILink>(do_QueryObject(this)),
"should be called only when |this| implements |nsILink|");
NS_PRECONDITION(nsCOMPtr<Link>(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<nsIURI>
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).

Просмотреть файл

@ -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,

Просмотреть файл

@ -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;

Просмотреть файл

@ -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)

Просмотреть файл

@ -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,

Просмотреть файл

@ -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<nsILink> link(do_QueryInterface(content));
nsCOMPtr<dom::Link> link(do_QueryInterface(content));
if (link) {
nsCOMPtr<nsIURI> href = content->GetHrefURI();
if (href) {

Просмотреть файл

@ -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<nsILink> link(do_QueryInterface(startContent));
nsCOMPtr<mozilla::dom::Link> link(do_QueryInterface(startContent));
if (link) {
// Check to see if inside HTML link
*aIsInsideLink = startContent->HasAttr(kNameSpaceID_None, hrefAtom);