LCOV - code coverage report
Current view: directory - editor/libeditor/html - TypeInState.h (source / functions) Found Hit Coverage
Test: app.info Lines: 3 1 33.3 %
Date: 2012-06-02 Functions: 6 1 16.7 %

       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
      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                 : #ifndef TypeInState_h__
      39                 : #define TypeInState_h__
      40                 : 
      41                 : #include "nsCOMPtr.h"
      42                 : #include "nsIDOMNode.h"
      43                 : #include "nsISelection.h"
      44                 : #include "nsISelectionListener.h"
      45                 : #include "nsEditProperty.h"
      46                 : #include "nsString.h"
      47                 : #include "nsTArray.h"
      48                 : #include "nsCycleCollectionParticipant.h"
      49                 : 
      50                 : struct PropItem
      51               0 : {
      52                 :   nsIAtom *tag;
      53                 :   nsString attr;
      54                 :   nsString value;
      55                 :   
      56                 :   PropItem();
      57                 :   PropItem(nsIAtom *aTag, const nsAString &aAttr, const nsAString &aValue);
      58                 :   ~PropItem();
      59                 : };
      60                 : 
      61                 : class TypeInState : public nsISelectionListener
      62                 : {
      63                 : public:
      64                 : 
      65               0 :   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
      66            1464 :   NS_DECL_CYCLE_COLLECTION_CLASS(TypeInState)
      67                 : 
      68                 :   TypeInState();
      69                 :   void Reset();
      70                 :   virtual ~TypeInState();
      71                 : 
      72                 :   nsresult UpdateSelState(nsISelection *aSelection);
      73                 : 
      74                 :   // nsISelectionListener
      75                 :   NS_DECL_NSISELECTIONLISTENER
      76                 : 
      77                 :   nsresult SetProp(nsIAtom *aProp, const nsString &aAttr, const nsString &aValue);
      78                 : 
      79                 :   nsresult ClearAllProps();
      80                 :   nsresult ClearProp(nsIAtom *aProp, const nsString &aAttr);
      81                 :   
      82                 :   //**************************************************************************
      83                 :   //    TakeClearProperty: hands back next property item on the clear list.
      84                 :   //                       caller assumes ownership of PropItem and must delete it.
      85                 :   nsresult TakeClearProperty(PropItem **outPropItem);
      86                 : 
      87                 :   //**************************************************************************
      88                 :   //    TakeSetProperty: hands back next property item on the set list.
      89                 :   //                     caller assumes ownership of PropItem and must delete it.
      90                 :   nsresult TakeSetProperty(PropItem **outPropItem);
      91                 : 
      92                 :   //**************************************************************************
      93                 :   //    TakeRelativeFontSize: hands back relative font value, which is then
      94                 :   //                          cleared out.
      95                 :   nsresult TakeRelativeFontSize(PRInt32 *outRelSize);
      96                 : 
      97                 :   nsresult GetTypingState(bool &isSet, bool &theSetting, nsIAtom *aProp);
      98                 :   nsresult GetTypingState(bool &isSet, bool &theSetting, nsIAtom *aProp, 
      99                 :                           const nsString &aAttr, nsString* outValue);
     100                 : 
     101                 :   static   bool FindPropInList(nsIAtom *aProp, const nsAString &aAttr, nsAString *outValue, nsTArray<PropItem*> &aList, PRInt32 &outIndex);
     102                 : 
     103                 : protected:
     104                 : 
     105                 :   nsresult RemovePropFromSetList(nsIAtom *aProp, const nsString &aAttr);
     106                 :   nsresult RemovePropFromClearedList(nsIAtom *aProp, const nsString &aAttr);
     107                 :   bool IsPropSet(nsIAtom *aProp, const nsString &aAttr, nsString* outValue);
     108                 :   bool IsPropSet(nsIAtom *aProp, const nsString &aAttr, nsString* outValue, PRInt32 &outIndex);
     109                 :   bool IsPropCleared(nsIAtom *aProp, const nsString &aAttr);
     110                 :   bool IsPropCleared(nsIAtom *aProp, const nsString &aAttr, PRInt32 &outIndex);
     111                 : 
     112                 :   nsTArray<PropItem*> mSetArray;
     113                 :   nsTArray<PropItem*> mClearedArray;
     114                 :   PRInt32 mRelativeFontSize;
     115                 :   nsCOMPtr<nsIDOMNode> mLastSelectionContainer;
     116                 :   PRInt32 mLastSelectionOffset;
     117                 :   
     118                 :   friend class nsHTMLEditRules;
     119                 : };
     120                 : 
     121                 : 
     122                 : 
     123                 : #endif  // TypeInState_h__
     124                 : 

Generated by: LCOV version 1.7