LCOV - code coverage report
Current view: directory - content/html/content/src - nsHTMLLIElement.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 40 11 27.5 %
Date: 2012-06-02 Functions: 114 7 6.1 %

       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 Communicator client code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * Netscape Communications Corporation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 1998
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      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 "mozilla/Util.h"
      39                 : 
      40                 : #include "nsIDOMHTMLLIElement.h"
      41                 : #include "nsIDOMEventTarget.h"
      42                 : #include "nsGenericHTMLElement.h"
      43                 : #include "nsGkAtoms.h"
      44                 : #include "nsStyleConsts.h"
      45                 : #include "nsMappedAttributes.h"
      46                 : #include "nsRuleData.h"
      47                 : 
      48                 : using namespace mozilla;
      49                 : 
      50                 : class nsHTMLLIElement : public nsGenericHTMLElement,
      51                 :                         public nsIDOMHTMLLIElement
      52                 : {
      53                 : public:
      54                 :   nsHTMLLIElement(already_AddRefed<nsINodeInfo> aNodeInfo);
      55                 :   virtual ~nsHTMLLIElement();
      56                 : 
      57                 :   // nsISupports
      58                 :   NS_DECL_ISUPPORTS_INHERITED
      59                 : 
      60                 :   // nsIDOMNode
      61               0 :   NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::)
      62                 : 
      63                 :   // nsIDOMElement
      64               0 :   NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::)
      65                 : 
      66                 :   // nsIDOMHTMLElement
      67               0 :   NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
      68                 : 
      69                 :   // nsIDOMHTMLLIElement
      70                 :   NS_DECL_NSIDOMHTMLLIELEMENT
      71                 : 
      72                 :   virtual bool ParseAttribute(PRInt32 aNamespaceID,
      73                 :                                 nsIAtom* aAttribute,
      74                 :                                 const nsAString& aValue,
      75                 :                                 nsAttrValue& aResult);
      76                 :   NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
      77                 :   virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
      78                 :   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
      79                 :   virtual nsXPCClassInfo* GetClassInfo();
      80                 : };
      81                 : 
      82                 : 
      83              16 : NS_IMPL_NS_NEW_HTML_ELEMENT(LI)
      84                 : 
      85                 : 
      86               8 : nsHTMLLIElement::nsHTMLLIElement(already_AddRefed<nsINodeInfo> aNodeInfo)
      87               8 :   : nsGenericHTMLElement(aNodeInfo)
      88                 : {
      89               8 : }
      90                 : 
      91              16 : nsHTMLLIElement::~nsHTMLLIElement()
      92                 : {
      93              32 : }
      94                 : 
      95                 : 
      96              80 : NS_IMPL_ADDREF_INHERITED(nsHTMLLIElement, nsGenericElement)
      97              80 : NS_IMPL_RELEASE_INHERITED(nsHTMLLIElement, nsGenericElement)
      98                 : 
      99                 : 
     100               0 : DOMCI_NODE_DATA(HTMLLIElement, nsHTMLLIElement)
     101                 : 
     102                 : // QueryInterface implementation for nsHTMLLIElement
     103             218 : NS_INTERFACE_TABLE_HEAD(nsHTMLLIElement)
     104             218 :   NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLLIElement, nsIDOMHTMLLIElement)
     105             218 :   NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLLIElement,
     106                 :                                                nsGenericHTMLElement)
     107               0 : NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLLIElement)
     108                 : 
     109                 : 
     110               0 : NS_IMPL_ELEMENT_CLONE(nsHTMLLIElement)
     111                 : 
     112                 : 
     113               0 : NS_IMPL_STRING_ATTR(nsHTMLLIElement, Type, type)
     114               0 : NS_IMPL_INT_ATTR(nsHTMLLIElement, Value, value)
     115                 : 
     116                 : // values that are handled case-insensitively
     117                 : static const nsAttrValue::EnumTable kUnorderedListItemTypeTable[] = {
     118                 :   { "disc", NS_STYLE_LIST_STYLE_DISC },
     119                 :   { "circle", NS_STYLE_LIST_STYLE_CIRCLE },
     120                 :   { "round", NS_STYLE_LIST_STYLE_CIRCLE },
     121                 :   { "square", NS_STYLE_LIST_STYLE_SQUARE },
     122                 :   { 0 }
     123                 : };
     124                 : 
     125                 : // values that are handled case-sensitively
     126                 : static const nsAttrValue::EnumTable kOrderedListItemTypeTable[] = {
     127                 :   { "A", NS_STYLE_LIST_STYLE_UPPER_ALPHA },
     128                 :   { "a", NS_STYLE_LIST_STYLE_LOWER_ALPHA },
     129                 :   { "I", NS_STYLE_LIST_STYLE_UPPER_ROMAN },
     130                 :   { "i", NS_STYLE_LIST_STYLE_LOWER_ROMAN },
     131                 :   { "1", NS_STYLE_LIST_STYLE_DECIMAL },
     132                 :   { 0 }
     133                 : };
     134                 : 
     135                 : bool
     136               0 : nsHTMLLIElement::ParseAttribute(PRInt32 aNamespaceID,
     137                 :                                 nsIAtom* aAttribute,
     138                 :                                 const nsAString& aValue,
     139                 :                                 nsAttrValue& aResult)
     140                 : {
     141               0 :   if (aNamespaceID == kNameSpaceID_None) {
     142               0 :     if (aAttribute == nsGkAtoms::type) {
     143                 :       return aResult.ParseEnumValue(aValue, kOrderedListItemTypeTable,
     144               0 :                                     true) ||
     145               0 :              aResult.ParseEnumValue(aValue, kUnorderedListItemTypeTable, false);
     146                 :     }
     147               0 :     if (aAttribute == nsGkAtoms::value) {
     148               0 :       return aResult.ParseIntValue(aValue);
     149                 :     }
     150                 :   }
     151                 : 
     152                 :   return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
     153               0 :                                               aResult);
     154                 : }
     155                 : 
     156                 : static void
     157               0 : MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
     158                 :                       nsRuleData* aData)
     159                 : {
     160               0 :   if (aData->mSIDs & NS_STYLE_INHERIT_BIT(List)) {
     161               0 :     nsCSSValue* listStyleType = aData->ValueForListStyleType();
     162               0 :     if (listStyleType->GetUnit() == eCSSUnit_Null) {
     163                 :       // type: enum
     164               0 :       const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::type);
     165               0 :       if (value && value->Type() == nsAttrValue::eEnum)
     166               0 :         listStyleType->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated);
     167                 :     }
     168                 :   }
     169                 : 
     170               0 :   nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
     171               0 : }
     172                 : 
     173                 : NS_IMETHODIMP_(bool)
     174               0 : nsHTMLLIElement::IsAttributeMapped(const nsIAtom* aAttribute) const
     175                 : {
     176                 :   static const MappedAttributeEntry attributes[] = {
     177                 :     { &nsGkAtoms::type },
     178                 :     { nsnull },
     179                 :   };
     180                 : 
     181                 :   static const MappedAttributeEntry* const map[] = {
     182                 :     attributes,
     183                 :     sCommonAttributeMap,
     184                 :   };
     185                 : 
     186               0 :   return FindAttributeDependence(aAttribute, map);
     187                 : }
     188                 : 
     189                 : 
     190                 : 
     191                 : nsMapRuleToAttributesFunc
     192               0 : nsHTMLLIElement::GetAttributeMappingFunction() const
     193                 : {
     194               0 :   return &MapAttributesIntoRule;
     195                 : }

Generated by: LCOV version 1.7