LCOV - code coverage report
Current view: top level - dom/html - HTMLAreaElement.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 89 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 54 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #include "mozilla/dom/HTMLAreaElement.h"
       8             : 
       9             : #include "mozilla/Attributes.h"
      10             : #include "mozilla/dom/HTMLAnchorElement.h"
      11             : #include "mozilla/dom/HTMLAreaElementBinding.h"
      12             : #include "mozilla/EventDispatcher.h"
      13             : #include "mozilla/EventStates.h"
      14             : #include "mozilla/MemoryReporting.h"
      15             : 
      16           0 : NS_IMPL_NS_NEW_HTML_ELEMENT(Area)
      17             : 
      18             : namespace mozilla {
      19             : namespace dom {
      20             : 
      21           0 : HTMLAreaElement::HTMLAreaElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
      22             :   : nsGenericHTMLElement(aNodeInfo)
      23           0 :   , Link(this)
      24             : {
      25           0 : }
      26             : 
      27           0 : HTMLAreaElement::~HTMLAreaElement()
      28             : {
      29           0 : }
      30             : 
      31           0 : NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(HTMLAreaElement)
      32           0 :   NS_INTERFACE_TABLE_INHERITED(HTMLAreaElement,
      33             :                                nsIDOMHTMLAreaElement,
      34             :                                Link)
      35           0 : NS_INTERFACE_TABLE_TAIL_INHERITING(nsGenericHTMLElement)
      36             : 
      37           0 : NS_IMPL_ADDREF_INHERITED(HTMLAreaElement, Element)
      38           0 : NS_IMPL_RELEASE_INHERITED(HTMLAreaElement, Element)
      39             : 
      40             : NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLAreaElement)
      41             : 
      42           0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLAreaElement,
      43             :                                                   nsGenericHTMLElement)
      44           0 :   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRelList)
      45           0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
      46             : 
      47           0 : NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLAreaElement,
      48             :                                                 nsGenericHTMLElement)
      49           0 :   NS_IMPL_CYCLE_COLLECTION_UNLINK(mRelList)
      50           0 : NS_IMPL_CYCLE_COLLECTION_UNLINK_END
      51             : 
      52           0 : NS_IMPL_ELEMENT_CLONE(HTMLAreaElement)
      53             : 
      54             : 
      55           0 : NS_IMPL_STRING_ATTR(HTMLAreaElement, Alt, alt)
      56           0 : NS_IMPL_STRING_ATTR(HTMLAreaElement, Coords, coords)
      57           0 : NS_IMPL_URI_ATTR(HTMLAreaElement, Href, href)
      58           0 : NS_IMPL_BOOL_ATTR(HTMLAreaElement, NoHref, nohref)
      59           0 : NS_IMPL_STRING_ATTR(HTMLAreaElement, Shape, shape)
      60           0 : NS_IMPL_STRING_ATTR(HTMLAreaElement, Download, download)
      61             : 
      62             : int32_t
      63           0 : HTMLAreaElement::TabIndexDefault()
      64             : {
      65           0 :   return 0;
      66             : }
      67             : 
      68             : NS_IMETHODIMP
      69           0 : HTMLAreaElement::GetTarget(nsAString& aValue)
      70             : {
      71           0 :   if (!GetAttr(kNameSpaceID_None, nsGkAtoms::target, aValue)) {
      72           0 :     GetBaseTarget(aValue);
      73             :   }
      74           0 :   return NS_OK;
      75             : }
      76             : 
      77             : NS_IMETHODIMP
      78           0 : HTMLAreaElement::SetTarget(const nsAString& aValue)
      79             : {
      80           0 :   return SetAttr(kNameSpaceID_None, nsGkAtoms::target, aValue, true);
      81             : }
      82             : 
      83             : nsresult
      84           0 : HTMLAreaElement::GetEventTargetParent(EventChainPreVisitor& aVisitor)
      85             : {
      86           0 :   return GetEventTargetParentForAnchors(aVisitor);
      87             : }
      88             : 
      89             : nsresult
      90           0 : HTMLAreaElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
      91             : {
      92           0 :   return PostHandleEventForAnchors(aVisitor);
      93             : }
      94             : 
      95             : bool
      96           0 : HTMLAreaElement::IsLink(nsIURI** aURI) const
      97             : {
      98           0 :   return IsHTMLLink(aURI);
      99             : }
     100             : 
     101             : void
     102           0 : HTMLAreaElement::GetLinkTarget(nsAString& aTarget)
     103             : {
     104           0 :   GetAttr(kNameSpaceID_None, nsGkAtoms::target, aTarget);
     105           0 :   if (aTarget.IsEmpty()) {
     106           0 :     GetBaseTarget(aTarget);
     107             :   }
     108           0 : }
     109             : 
     110             : nsDOMTokenList*
     111           0 : HTMLAreaElement::RelList()
     112             : {
     113           0 :   if (!mRelList) {
     114             :     mRelList = new nsDOMTokenList(this, nsGkAtoms::rel,
     115           0 :                                   HTMLAnchorElement::sSupportedRelValues);
     116             :   }
     117           0 :   return mRelList;
     118             : }
     119             : 
     120             : nsresult
     121           0 : HTMLAreaElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
     122             :                             nsIContent* aBindingParent,
     123             :                             bool aCompileEventHandlers)
     124             : {
     125           0 :   Link::ResetLinkState(false, Link::ElementHasHref());
     126           0 :   nsresult rv = nsGenericHTMLElement::BindToTree(aDocument, aParent,
     127             :                                                  aBindingParent,
     128           0 :                                                  aCompileEventHandlers);
     129           0 :   NS_ENSURE_SUCCESS(rv, rv);
     130             : 
     131           0 :   nsIDocument* doc = GetComposedDoc();
     132           0 :   if (doc) {
     133           0 :     doc->RegisterPendingLinkUpdate(this);
     134             :   }
     135           0 :   return rv;
     136             : }
     137             : 
     138             : void
     139           0 : HTMLAreaElement::UnbindFromTree(bool aDeep, bool aNullParent)
     140             : {
     141             :   // If this link is ever reinserted into a document, it might
     142             :   // be under a different xml:base, so forget the cached state now.
     143           0 :   Link::ResetLinkState(false, Link::ElementHasHref());
     144             : 
     145           0 :   nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
     146           0 : }
     147             : 
     148             : nsresult
     149           0 : HTMLAreaElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
     150             :                               const nsAttrValue* aValue,
     151             :                               const nsAttrValue* aOldValue, bool aNotify)
     152             : {
     153           0 :   if (aNamespaceID == kNameSpaceID_None) {
     154             :     // This must happen after the attribute is set. We will need the updated
     155             :     // attribute value because notifying the document that content states have
     156             :     // changed will call IntrinsicState, which will try to get updated
     157             :     // information about the visitedness from Link.
     158           0 :     if (aName == nsGkAtoms::href) {
     159           0 :       Link::ResetLinkState(aNotify, !!aValue);
     160             :     }
     161             :   }
     162             : 
     163           0 :   return nsGenericHTMLElement::AfterSetAttr(aNamespaceID, aName, aValue,
     164           0 :                                             aOldValue, aNotify);
     165             : }
     166             : 
     167             : #define IMPL_URI_PART(_part)                                 \
     168             :   NS_IMETHODIMP                                              \
     169             :   HTMLAreaElement::Get##_part(nsAString& a##_part)           \
     170             :   {                                                          \
     171             :     Link::Get##_part(a##_part);                              \
     172             :     return NS_OK;                                            \
     173             :   }                                                          \
     174             :   NS_IMETHODIMP                                              \
     175             :   HTMLAreaElement::Set##_part(const nsAString& a##_part)     \
     176             :   {                                                          \
     177             :     Link::Set##_part(a##_part);                              \
     178             :     return NS_OK;                                            \
     179             :   }
     180             : 
     181           0 : IMPL_URI_PART(Protocol)
     182           0 : IMPL_URI_PART(Host)
     183           0 : IMPL_URI_PART(Hostname)
     184           0 : IMPL_URI_PART(Pathname)
     185           0 : IMPL_URI_PART(Search)
     186           0 : IMPL_URI_PART(Port)
     187           0 : IMPL_URI_PART(Hash)
     188             : 
     189             : #undef IMPL_URI_PART
     190             : 
     191             : NS_IMETHODIMP
     192           0 : HTMLAreaElement::ToString(nsAString& aSource)
     193             : {
     194           0 :   return GetHref(aSource);
     195             : }
     196             : 
     197             : NS_IMETHODIMP
     198           0 : HTMLAreaElement::GetPing(nsAString& aValue)
     199             : {
     200           0 :   GetAttr(kNameSpaceID_None, nsGkAtoms::ping, aValue);
     201           0 :   return NS_OK;
     202             : }
     203             : 
     204             : NS_IMETHODIMP
     205           0 : HTMLAreaElement::SetPing(const nsAString& aValue)
     206             : {
     207           0 :   return SetAttr(kNameSpaceID_None, nsGkAtoms::ping, aValue, true);
     208             : }
     209             : 
     210             : already_AddRefed<nsIURI>
     211           0 : HTMLAreaElement::GetHrefURI() const
     212             : {
     213           0 :   return GetHrefURIForAnchors();
     214             : }
     215             : 
     216             : EventStates
     217           0 : HTMLAreaElement::IntrinsicState() const
     218             : {
     219           0 :   return Link::LinkState() | nsGenericHTMLElement::IntrinsicState();
     220             : }
     221             : 
     222             : size_t
     223           0 : HTMLAreaElement::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
     224             : {
     225           0 :   return nsGenericHTMLElement::SizeOfExcludingThis(aMallocSizeOf) +
     226           0 :          Link::SizeOfExcludingThis(aMallocSizeOf);
     227             : }
     228             : 
     229             : JSObject*
     230           0 : HTMLAreaElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
     231             : {
     232           0 :   return HTMLAreaElementBinding::Wrap(aCx, this, aGivenProto);
     233             : }
     234             : 
     235             : } // namespace dom
     236             : } // namespace mozilla

Generated by: LCOV version 1.13