LCOV - code coverage report
Current view: directory - layout/style - nsDOMCSSValueList.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 52 0 0.0 %
Date: 2012-06-02 Functions: 12 0 0.0 %

       1                 : /* ***** BEGIN LICENSE BLOCK *****
       2                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       3                 :  *
       4                 :  * The contents of this file are subject to the Mozilla Public License Version
       5                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       6                 :  * the License. You may obtain a copy of the License at
       7                 :  * http://www.mozilla.org/MPL/
       8                 :  *
       9                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      10                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      11                 :  * for the specific language governing rights and limitations under the
      12                 :  * License.
      13                 :  *
      14                 :  * The Original Code is mozilla.org code.
      15                 :  *
      16                 :  * The Initial Developer of the Original Code is
      17                 :  * Netscape Communications Corporation.
      18                 :  * Portions created by the Initial Developer are Copyright (C) 2002
      19                 :  * the Initial Developer. All Rights Reserved.
      20                 :  *
      21                 :  * Contributor(s):
      22                 :  *   Christopher A. Aillon <christopher@aillon.com> (original author)
      23                 :  *
      24                 :  * Alternatively, the contents of this file may be used under the terms of
      25                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      26                 :  * 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                 : /* DOM object representing lists of values in DOM computed style */
      39                 : 
      40                 : #include "nsDOMCSSValueList.h"
      41                 : #include "nsCOMPtr.h"
      42                 : #include "nsDOMError.h"
      43                 : #include "prtypes.h"
      44                 : #include "nsContentUtils.h"
      45                 : 
      46               0 : nsDOMCSSValueList::nsDOMCSSValueList(bool aCommaDelimited, bool aReadonly)
      47               0 :   : mCommaDelimited(aCommaDelimited), mReadonly(aReadonly)
      48                 : {
      49               0 : }
      50                 : 
      51               0 : nsDOMCSSValueList::~nsDOMCSSValueList()
      52                 : {
      53               0 : }
      54                 : 
      55               0 : NS_IMPL_ADDREF(nsDOMCSSValueList)
      56               0 : NS_IMPL_RELEASE(nsDOMCSSValueList)
      57                 : 
      58                 : DOMCI_DATA(CSSValueList, nsDOMCSSValueList)
      59                 : 
      60                 : // QueryInterface implementation for nsDOMCSSValueList
      61               0 : NS_INTERFACE_MAP_BEGIN(nsDOMCSSValueList)
      62               0 :   NS_INTERFACE_MAP_ENTRY(nsIDOMCSSValueList)
      63               0 :   NS_INTERFACE_MAP_ENTRY(nsIDOMCSSValue)
      64               0 :   NS_INTERFACE_MAP_ENTRY(nsISupports)
      65               0 :   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSValueList)
      66               0 : NS_INTERFACE_MAP_END
      67                 : 
      68                 : void
      69               0 : nsDOMCSSValueList::AppendCSSValue(nsIDOMCSSValue* aValue)
      70                 : {
      71               0 :   mCSSValues.AppendElement(aValue);
      72               0 : }
      73                 : 
      74                 : // nsIDOMCSSValueList
      75                 : 
      76                 : NS_IMETHODIMP
      77               0 : nsDOMCSSValueList::GetLength(PRUint32* aLength)
      78                 : {
      79               0 :   *aLength = mCSSValues.Length();
      80                 : 
      81               0 :   return NS_OK;
      82                 : }
      83                 : 
      84                 : NS_IMETHODIMP
      85               0 : nsDOMCSSValueList::Item(PRUint32 aIndex, nsIDOMCSSValue **aReturn)
      86                 : {
      87               0 :   NS_ENSURE_ARG_POINTER(aReturn);
      88                 : 
      89               0 :   NS_IF_ADDREF(*aReturn = GetItemAt(aIndex));
      90                 : 
      91               0 :   return NS_OK;
      92                 : }
      93                 : 
      94                 : // nsIDOMCSSValue
      95                 : 
      96                 : NS_IMETHODIMP
      97               0 : nsDOMCSSValueList::GetCssText(nsAString& aCssText)
      98                 : {
      99               0 :   aCssText.Truncate();
     100                 : 
     101               0 :   PRUint32 count = mCSSValues.Length();
     102                 : 
     103               0 :   nsAutoString separator;
     104               0 :   if (mCommaDelimited) {
     105               0 :     separator.AssignLiteral(", ");
     106                 :   }
     107                 :   else {
     108               0 :     separator.Assign(PRUnichar(' '));
     109                 :   }
     110                 : 
     111               0 :   nsCOMPtr<nsIDOMCSSValue> cssValue;
     112               0 :   nsAutoString tmpStr;
     113               0 :   for (PRUint32 i = 0; i < count; ++i) {
     114               0 :     cssValue = mCSSValues[i];
     115               0 :     NS_ASSERTION(cssValue, "Eek!  Someone filled the value list with null CSSValues!");
     116               0 :     if (cssValue) {
     117               0 :       cssValue->GetCssText(tmpStr);
     118                 : 
     119               0 :       if (tmpStr.IsEmpty()) {
     120                 : 
     121                 : #ifdef DEBUG_caillon
     122                 :         NS_ERROR("Eek!  An empty CSSValue!  Bad!");
     123                 : #endif
     124                 : 
     125               0 :         continue;
     126                 :       }
     127                 : 
     128                 :       // If this isn't the first item in the list, then
     129                 :       // it's ok to append a separator.
     130               0 :       if (!aCssText.IsEmpty()) {
     131               0 :         aCssText.Append(separator);
     132                 :       }
     133               0 :       aCssText.Append(tmpStr);
     134                 :     }
     135                 :   }
     136                 : 
     137               0 :   return NS_OK;
     138                 : }
     139                 : 
     140                 : NS_IMETHODIMP
     141               0 : nsDOMCSSValueList::SetCssText(const nsAString& aCssText)
     142                 : {
     143               0 :   if (mReadonly) {
     144               0 :     return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
     145                 :   }
     146                 : 
     147               0 :   NS_NOTYETIMPLEMENTED("Can't SetCssText yet: please write me!");
     148               0 :   return NS_OK;
     149                 : }
     150                 : 
     151                 : 
     152                 : NS_IMETHODIMP
     153               0 : nsDOMCSSValueList::GetCssValueType(PRUint16* aValueType)
     154                 : {
     155               0 :   NS_ENSURE_ARG_POINTER(aValueType);
     156               0 :   *aValueType = nsIDOMCSSValue::CSS_VALUE_LIST;
     157               0 :   return NS_OK;
     158                 : }
     159                 : 

Generated by: LCOV version 1.7