LCOV - app.info - content/base/src/Link.h

LCOV - code coverage report
| Current view: | directory - content/base/src - Link.h (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 6 | 0 | 0.0 %
| Date: | 2012-07-07 | Functions: | 5 | 0 | 0.0 %

           1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
           2                 :  * vim: sw=2 ts=2 et :
           3                 :  * ***** BEGIN LICENSE BLOCK *****
           4                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
           5                 :  *
           6                 :  * The contents of this file are subject to the Mozilla Public License Version
           7                 :  * 1.1 (the "License"); you may not use this file except in compliance with
           8                 :  * the License. You may obtain a copy of the License at
           9                 :  * http://www.mozilla.org/MPL/
          10                 :  *
          11                 :  * Software distributed under the License is distributed on an "AS IS" basis,
          12                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
          13                 :  * for the specific language governing rights and limitations under the
          14                 :  * License.
          15                 :  *
          16                 :  * The Original Code is mozilla.org code.
          17                 :  *
          18                 :  * The Initial Developer of the Original Code is
          19                 :  * Mozilla Foundation.
          20                 :  * Portions created by the Initial Developer are Copyright (C) 2009
          21                 :  * the Initial Developer. All Rights Reserved.
          22                 :  *
          23                 :  * Contributor(s):
          24                 :  *   Shawn Wilsher <me@shawnwilsher.com> (Original Author)
          25                 :  *
          26                 :  * Alternatively, the contents of this file may be used under the terms of
          27                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
          28                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
          29                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
          30                 :  * of those above. If you wish to allow use of your version of this file only
          31                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
          32                 :  * use your version of this file under the terms of the MPL, indicate your
          33                 :  * decision by deleting the provisions above and replace them with the notice
          34                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
          35                 :  * the provisions above, a recipient may use your version of this file under
          36                 :  * the terms of any one of the MPL, the GPL or the LGPL.
          37                 :  *
          38                 :  * ***** END LICENSE BLOCK ***** */
          39                 :
          40                 : /**
          41                 :  * This is the base class for all link classes.
          42                 :  */
          43                 :
          44                 : #ifndef mozilla_dom_Link_h__
          45                 : #define mozilla_dom_Link_h__
          46                 :
          47                 : #include "mozilla/dom/Element.h"
          48                 : #include "mozilla/IHistory.h"
          49                 :
          50                 : namespace mozilla {
          51                 : namespace dom {
          52                 :
          53                 : #define MOZILLA_DOM_LINK_IMPLEMENTATION_IID \
          54                 :   { 0x7EA57721, 0xE373, 0x458E, \
          55                 :     {0x8F, 0x44, 0xF8, 0x96, 0x56, 0xB4, 0x14, 0xF5 } }
          56                 :
          57                 : class Link : public nsISupports
          58                 : {
          59                 : public:
          60                 :   NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_DOM_LINK_IMPLEMENTATION_IID)
          61                 :
          62                 :   static const nsLinkState defaultState = eLinkState_Unknown;
          63                 :
          64                 :   /**
          65                 :    * aElement is the element pointer corresponding to this link.
          66                 :    */
          67                 :   Link(Element* aElement);
          68                 :   nsLinkState GetLinkState() const;
          69                 :   virtual void SetLinkState(nsLinkState aState);
          70                 :
          71                 :   /**
          72                 :    * @return NS_EVENT_STATE_VISITED if this link is visited,
          73                 :    *         NS_EVENT_STATE_UNVISTED if this link is not visited, or 0 if this
          74                 :    *         link is not actually a link.
          75                 :    */
          76                 :   nsEventStates LinkState() const;
          77                 :
          78                 :   /**
          79                 :    * @return the URI this link is for, if available.
          80                 :    */
          81                 :   already_AddRefed<nsIURI> GetURI() const;
          82               0 :   virtual already_AddRefed<nsIURI> GetURIExternal() const {
          83               0 :     return GetURI();
          84                 :   }
          85                 :
          86                 :   /**
          87                 :    * Helper methods for modifying and obtaining parts of the URI of the Link.
          88                 :    */
          89                 :   nsresult SetProtocol(const nsAString &aProtocol);
          90                 :   nsresult SetHost(const nsAString &aHost);
          91                 :   nsresult SetHostname(const nsAString &aHostname);
          92                 :   nsresult SetPathname(const nsAString &aPathname);
          93                 :   nsresult SetSearch(const nsAString &aSearch);
          94                 :   nsresult SetPort(const nsAString &aPort);
          95                 :   nsresult SetHash(const nsAString &aHash);
          96                 :   nsresult GetProtocol(nsAString &_protocol);
          97                 :   nsresult GetHost(nsAString &_host);
          98                 :   nsresult GetHostname(nsAString &_hostname);
          99                 :   nsresult GetPathname(nsAString &_pathname);
         100                 :   nsresult GetSearch(nsAString &_search);
         101                 :   nsresult GetPort(nsAString &_port);
         102                 :   nsresult GetHash(nsAString &_hash);
         103                 :
         104                 :   /**
         105                 :    * Invalidates any link caching, and resets the state to the default.
         106                 :    *
         107                 :    * @param aNotify
         108                 :    *        true if ResetLinkState should notify the owning document about style
         109                 :    *        changes or false if it should not.
         110                 :    */
         111                 :   void ResetLinkState(bool aNotify);
         112                 :
         113                 :   // This method nevers returns a null element.
         114                 :   Element* GetElement() const { return mElement; }
         115                 :
         116                 :   /**
         117                 :    * DNS prefetch has been deferred until later, e.g. page load complete.
         118                 :    */
         119               0 :   virtual void OnDNSPrefetchDeferred() { /*do nothing*/ }
         120                 :
         121                 :   /**
         122                 :    * DNS prefetch has been submitted to Host Resolver.
         123                 :    */
         124               0 :   virtual void OnDNSPrefetchRequested() { /*do nothing*/ }
         125                 :
         126                 :   /**
         127                 :    * Checks if DNS Prefetching is ok
         128                 :    *
         129                 :    * @returns boolean
         130                 :    *          Defaults to true; should be overridden for specialised cases
         131                 :    */
         132               0 :   virtual bool HasDeferredDNSPrefetchRequest() { return true; }
         133                 :
         134                 :   virtual size_t
         135                 :     SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
         136                 :
         137                 : protected:
         138                 :   virtual ~Link();
         139                 :
         140               0 :   bool HasCachedURI() const { return !!mCachedURI; }
         141                 :
         142                 : private:
         143                 :   /**
         144                 :    * Unregisters from History so this node no longer gets notifications about
         145                 :    * changes to visitedness.
         146                 :    */
         147                 :   void UnregisterFromHistory();
         148                 :
         149                 :   already_AddRefed<nsIURI> GetURIToMutate();
         150                 :   void SetHrefAttribute(nsIURI *aURI);
         151                 :
         152                 :   nsLinkState mLinkState;
         153                 :
         154                 :   mutable nsCOMPtr<nsIURI> mCachedURI;
         155                 :
         156                 :   bool mRegistered;
         157                 :
         158                 :   Element * const mElement;
         159                 :
         160                 :   // Strong reference to History.  The link has to unregister before History
         161                 :   // can disappear.
         162                 :   nsCOMPtr<IHistory> mHistory;
         163                 : };
         164                 :
         165                 : NS_DEFINE_STATIC_IID_ACCESSOR(Link, MOZILLA_DOM_LINK_IMPLEMENTATION_IID)
         166                 :
         167                 : } // namespace dom
         168                 : } // namespace mozilla
         169                 :
         170                 : #endif // mozilla_dom_Link_h__

Generated by: LCOV version 1.7