LCOV - code coverage report
Current view: directory - content/html/content/src - nsHTMLElement.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 36 12 33.3 %
Date: 2012-06-02 Functions: 106 7 6.6 %

       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 mozilla.org code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is Mozilla Foundation
      18                 :  * Portions created by the Initial Developer are Copyright (C) 2010
      19                 :  * the Initial Developer. All Rights Reserved.
      20                 :  *
      21                 :  * Contributor(s):
      22                 :  *   Mounir Lamouri <mounir.lamouri@mozilla.com> (original author)
      23                 :  *
      24                 :  * Alternatively, the contents of this file may be used under the terms of
      25                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      26                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      27                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      28                 :  * of those above. If you wish to allow use of your version of this file only
      29                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      30                 :  * use your version of this file under the terms of the MPL, indicate your
      31                 :  * decision by deleting the provisions above and replace them with the notice
      32                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      33                 :  * the provisions above, a recipient may use your version of this file under
      34                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      35                 :  *
      36                 :  * ***** END LICENSE BLOCK ***** */
      37                 : 
      38                 : #include "nsGenericHTMLElement.h"
      39                 : #include "nsIDOMHTMLElement.h"
      40                 : 
      41                 : #include "nsContentUtils.h"
      42                 : 
      43                 : using namespace mozilla::dom;
      44                 : 
      45                 : class nsHTMLElement : public nsGenericHTMLElement,
      46                 :                       public nsIDOMHTMLElement
      47                 : {
      48                 : public:
      49                 :   nsHTMLElement(already_AddRefed<nsINodeInfo> aNodeInfo);
      50                 :   virtual ~nsHTMLElement();
      51                 : 
      52                 :   // nsISupports
      53                 :   NS_DECL_ISUPPORTS_INHERITED
      54                 : 
      55                 :   // nsIDOMNode
      56               0 :   NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::)
      57                 : 
      58                 :   // nsIDOMElement
      59               0 :   NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::)
      60                 : 
      61                 :   // nsIDOMHTMLElement
      62               0 :   NS_FORWARD_NSIDOMHTMLELEMENT_BASIC(nsGenericHTMLElement::)
      63               0 :   NS_SCRIPTABLE NS_IMETHOD Click() {
      64               0 :     return nsGenericHTMLElement::Click();
      65                 :   }
      66               0 :   NS_SCRIPTABLE NS_IMETHOD GetTabIndex(PRInt32* aTabIndex) {
      67               0 :     return nsGenericHTMLElement::GetTabIndex(aTabIndex);
      68                 :   }
      69               0 :   NS_SCRIPTABLE NS_IMETHOD SetTabIndex(PRInt32 aTabIndex) {
      70               0 :     return nsGenericHTMLElement::SetTabIndex(aTabIndex);
      71                 :   }
      72               0 :   NS_SCRIPTABLE NS_IMETHOD Focus() {
      73               0 :     return nsGenericHTMLElement::Focus();
      74                 :   }
      75               0 :   NS_SCRIPTABLE NS_IMETHOD GetDraggable(bool* aDraggable) {
      76               0 :     return nsGenericHTMLElement::GetDraggable(aDraggable);
      77                 :   }
      78                 :   NS_SCRIPTABLE NS_IMETHOD GetInnerHTML(nsAString& aInnerHTML);
      79               0 :   NS_SCRIPTABLE NS_IMETHOD SetInnerHTML(const nsAString& aInnerHTML) {
      80               0 :     return nsGenericHTMLElement::SetInnerHTML(aInnerHTML);
      81                 :   }
      82                 : 
      83                 :   nsresult Clone(nsINodeInfo* aNodeInfo, nsINode** aResult) const;
      84                 : 
      85                 :   virtual nsXPCClassInfo* GetClassInfo();
      86                 : };
      87                 : 
      88                 : // Here, we expand 'NS_IMPL_NS_NEW_HTML_ELEMENT()' by hand.
      89                 : // (Calling the macro directly (with no args) produces compiler warnings.)
      90                 : nsGenericHTMLElement*
      91               1 : NS_NewHTMLElement(already_AddRefed<nsINodeInfo> aNodeInfo,
      92                 :                   FromParser aFromParser)
      93                 : {
      94               1 :   return new nsHTMLElement(aNodeInfo);
      95                 : }
      96                 : 
      97               1 : nsHTMLElement::nsHTMLElement(already_AddRefed<nsINodeInfo> aNodeInfo)
      98               1 :   : nsGenericHTMLElement(aNodeInfo)
      99                 : {
     100               1 : }
     101                 : 
     102               2 : nsHTMLElement::~nsHTMLElement()
     103                 : {
     104               4 : }
     105                 : 
     106              11 : NS_IMPL_ADDREF_INHERITED(nsHTMLElement, nsGenericElement)
     107              11 : NS_IMPL_RELEASE_INHERITED(nsHTMLElement, nsGenericElement)
     108                 : 
     109               0 : DOMCI_NODE_DATA(HTMLElement, nsHTMLElement)
     110                 : 
     111              24 : NS_INTERFACE_TABLE_HEAD(nsHTMLElement)
     112              24 :   NS_HTML_CONTENT_INTERFACE_TABLE0(nsHTMLElement)
     113              24 :   NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLElement,
     114                 :                                                nsGenericHTMLElement)
     115               0 : NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLElement)
     116                 : 
     117               0 : NS_IMPL_ELEMENT_CLONE(nsHTMLElement)
     118                 : 
     119                 : nsresult
     120               0 : nsHTMLElement::GetInnerHTML(nsAString& aInnerHTML)
     121                 : {
     122                 :   /**
     123                 :    * nsGenericHTMLElement::GetInnerHTML escapes < and > characters (at least).
     124                 :    * .innerHTML should return the HTML code for xmp and plaintext element.
     125                 :    *
     126                 :    * This code is a workaround until we implement a HTML5 Serializer
     127                 :    * with this behavior.
     128                 :    */
     129               0 :   if (mNodeInfo->Equals(nsGkAtoms::xmp) ||
     130               0 :       mNodeInfo->Equals(nsGkAtoms::plaintext)) {
     131               0 :     nsContentUtils::GetNodeTextContent(this, false, aInnerHTML);
     132               0 :     return NS_OK;
     133                 :   }
     134                 : 
     135               0 :   return nsGenericHTMLElement::GetInnerHTML(aInnerHTML);
     136                 : }
     137                 : 

Generated by: LCOV version 1.7