LCOV - code coverage report
Current view: directory - content/svg/document/src - nsSVGDocument.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 53 0 0.0 %
Date: 2012-06-02 Functions: 12 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is the Mozilla SVG project.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * Bradley Baetz.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 2001
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   Bradley Baetz <bbaetz@cs.mcgill.ca> (original author)
      24                 :  *   Jonathan Watt <jonathan.watt@strath.ac.uk>
      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                 : #include "nsSVGDocument.h"
      41                 : #include "nsContentUtils.h"
      42                 : #include "nsString.h"
      43                 : #include "nsLiteralString.h"
      44                 : #include "nsIDOMSVGSVGElement.h"
      45                 : #include "mozilla/dom/Element.h"
      46                 : #include "nsGenericElement.h"
      47                 : 
      48                 : using namespace mozilla::dom;
      49                 : 
      50                 : //----------------------------------------------------------------------
      51                 : // Implementation
      52                 : 
      53               0 : nsSVGDocument::nsSVGDocument()
      54                 : {
      55               0 : }
      56                 : 
      57               0 : nsSVGDocument::~nsSVGDocument()
      58                 : {
      59               0 : }
      60                 : 
      61                 : //----------------------------------------------------------------------
      62                 : // nsISupports methods:
      63                 : 
      64               0 : DOMCI_NODE_DATA(SVGDocument, nsSVGDocument)
      65                 : 
      66               0 : NS_INTERFACE_TABLE_HEAD(nsSVGDocument)
      67               0 :   NS_INTERFACE_TABLE_INHERITED1(nsSVGDocument,
      68                 :                                 nsIDOMSVGDocument)
      69               0 :   NS_INTERFACE_TABLE_TO_MAP_SEGUE
      70               0 :   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGDocument)
      71               0 : NS_INTERFACE_MAP_END_INHERITING(nsXMLDocument)
      72                 : 
      73               0 : NS_IMPL_ADDREF_INHERITED(nsSVGDocument, nsXMLDocument)
      74               0 : NS_IMPL_RELEASE_INHERITED(nsSVGDocument, nsXMLDocument)
      75                 : 
      76                 : //----------------------------------------------------------------------
      77                 : // nsIDOMSVGDocument methods:
      78                 : 
      79                 : /* readonly attribute DOMString domain; */
      80                 : NS_IMETHODIMP
      81               0 : nsSVGDocument::GetDomain(nsAString& aDomain)
      82                 : {
      83               0 :   SetDOMStringToNull(aDomain);
      84                 : 
      85               0 :   if (mDocumentURI) {
      86               0 :     nsCAutoString domain;
      87               0 :     nsresult rv = mDocumentURI->GetHost(domain);
      88               0 :     if (domain.IsEmpty() || NS_FAILED(rv))
      89               0 :       return rv;
      90               0 :     CopyUTF8toUTF16(domain, aDomain);
      91                 :   }
      92                 : 
      93               0 :   return NS_OK;
      94                 : }
      95                 : 
      96                 : /* readonly attribute DOMString URL; */
      97                 : NS_IMETHODIMP
      98               0 : nsSVGDocument::GetURL(nsAString& aURL)
      99                 : {
     100               0 :   SetDOMStringToNull(aURL);
     101                 : 
     102               0 :   if (mDocumentURI) {
     103               0 :     nsCAutoString url;
     104               0 :     nsresult rv = mDocumentURI->GetSpec(url);
     105               0 :     if (url.IsEmpty() || NS_FAILED(rv))
     106               0 :       return rv;
     107               0 :     CopyUTF8toUTF16(url, aURL);
     108                 :   }
     109                 : 
     110               0 :   return NS_OK;
     111                 : }
     112                 : 
     113                 : /* readonly attribute SVGSVGElement rootElement; */
     114                 : NS_IMETHODIMP
     115               0 : nsSVGDocument::GetRootElement(nsIDOMSVGSVGElement** aRootElement)
     116                 : {
     117               0 :   *aRootElement = nsnull;
     118               0 :   Element* root = nsDocument::GetRootElement();
     119                 : 
     120               0 :   return root ? CallQueryInterface(root, aRootElement) : NS_OK;
     121                 : }
     122                 : 
     123                 : nsresult
     124               0 : nsSVGDocument::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
     125                 : {
     126               0 :   NS_ASSERTION(aNodeInfo->NodeInfoManager() == mNodeInfoManager,
     127                 :                "Can't import this document into another document!");
     128                 : 
     129               0 :   nsRefPtr<nsSVGDocument> clone = new nsSVGDocument();
     130               0 :   NS_ENSURE_TRUE(clone, NS_ERROR_OUT_OF_MEMORY);
     131               0 :   nsresult rv = CloneDocHelper(clone.get());
     132               0 :   NS_ENSURE_SUCCESS(rv, rv);
     133                 : 
     134               0 :   return CallQueryInterface(clone.get(), aResult);
     135                 : }
     136                 : 
     137                 : ////////////////////////////////////////////////////////////////////////
     138                 : // Exported creation functions
     139                 : 
     140                 : nsresult
     141               0 : NS_NewSVGDocument(nsIDocument** aInstancePtrResult)
     142                 : {
     143               0 :   *aInstancePtrResult = nsnull;
     144               0 :   nsSVGDocument* doc = new nsSVGDocument();
     145                 : 
     146               0 :   if (!doc)
     147               0 :     return NS_ERROR_OUT_OF_MEMORY;
     148                 : 
     149               0 :   NS_ADDREF(doc);
     150               0 :   nsresult rv = doc->Init();
     151                 : 
     152               0 :   if (NS_FAILED(rv)) {
     153               0 :     NS_RELEASE(doc);
     154               0 :     return rv;
     155                 :   }
     156                 : 
     157               0 :   *aInstancePtrResult = doc;
     158               0 :   return rv;
     159                 : }

Generated by: LCOV version 1.7