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

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : // vim:cindent:tabstop=2:expandtab:shiftwidth=2:
       3                 : /* ***** BEGIN LICENSE BLOCK *****
       4                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       5                 :  *
       6                 :  * The contents of this file are subject to the Mozilla Public License Version
       7                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       8                 :  * the License. You may obtain a copy of the License at
       9                 :  * http://www.mozilla.org/MPL/
      10                 :  *
      11                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      12                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      13                 :  * for the specific language governing rights and limitations under the
      14                 :  * License.
      15                 :  *
      16                 :  * The Original Code is mozilla.org code.
      17                 :  *
      18                 :  * The Initial Developer of the Original Code is
      19                 :  * Netscape Communications Corporation.
      20                 :  * Portions created by the Initial Developer are Copyright (C) 1998
      21                 :  * the Initial Developer. All Rights Reserved.
      22                 :  *
      23                 :  * Contributor(s):
      24                 :  *   L. David Baron <dbaron@dbaron.org>
      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                 : /*
      41                 :  * style rule processor for CSS style sheets, responsible for selector
      42                 :  * matching and cascading
      43                 :  */
      44                 : 
      45                 : #ifndef nsCSSRuleProcessor_h_
      46                 : #define nsCSSRuleProcessor_h_
      47                 : 
      48                 : #include "nsIStyleRuleProcessor.h"
      49                 : #include "nsCSSStyleSheet.h"
      50                 : #include "nsTArray.h"
      51                 : #include "nsAutoPtr.h"
      52                 : #include "nsCSSRules.h"
      53                 : #include "nsRuleWalker.h"
      54                 : #include "nsEventStates.h"
      55                 : 
      56                 : struct CascadeEnumData;
      57                 : struct nsCSSSelector;
      58                 : struct nsCSSSelectorList;
      59                 : struct RuleCascadeData;
      60                 : struct TreeMatchContext;
      61                 : class nsCSSKeyframesRule;
      62                 : 
      63                 : /**
      64                 :  * The CSS style rule processor provides a mechanism for sibling style
      65                 :  * sheets to combine their rule processing in order to allow proper
      66                 :  * cascading to happen.
      67                 :  *
      68                 :  * CSS style rule processors keep a live reference on all style sheets
      69                 :  * bound to them.  The CSS style sheets keep a weak reference to all the
      70                 :  * processors that they are bound to (many to many).  The CSS style sheet
      71                 :  * is told when the rule processor is going away (via DropRuleProcessor).
      72                 :  */
      73                 : 
      74                 : class nsCSSRuleProcessor: public nsIStyleRuleProcessor {
      75                 : public:
      76                 :   typedef nsTArray<nsRefPtr<nsCSSStyleSheet> > sheet_array_type;
      77                 : 
      78                 :   nsCSSRuleProcessor(const sheet_array_type& aSheets, PRUint8 aSheetType);
      79                 :   virtual ~nsCSSRuleProcessor();
      80                 : 
      81                 :   NS_DECL_ISUPPORTS
      82                 : 
      83                 : public:
      84                 :   nsresult ClearRuleCascades();
      85                 : 
      86                 :   static nsresult Startup();
      87                 :   static void Shutdown();
      88                 :   static void FreeSystemMetrics();
      89                 :   static bool HasSystemMetric(nsIAtom* aMetric);
      90                 : 
      91                 :   /*
      92                 :    * Returns true if the given aElement matches one of the
      93                 :    * selectors in aSelectorList.  Note that this method will assume
      94                 :    * the given aElement is not a relevant link.  aSelectorList must not
      95                 :    * include any pseudo-element selectors.  aSelectorList is allowed
      96                 :    * to be null; in this case false will be returned.
      97                 :    */
      98                 :   static bool SelectorListMatches(mozilla::dom::Element* aElement,
      99                 :                                     TreeMatchContext& aTreeMatchContext,
     100                 :                                     nsCSSSelectorList* aSelectorList);
     101                 : 
     102                 :   /*
     103                 :    * Helper to get the content state for a content node.  This may be
     104                 :    * slightly adjusted from IntrinsicState().
     105                 :    */
     106                 :   static nsEventStates GetContentState(mozilla::dom::Element* aElement);
     107                 : 
     108                 :   /*
     109                 :    * Helper to get the content state for :visited handling for an element
     110                 :    */
     111                 :   static nsEventStates GetContentStateForVisitedHandling(
     112                 :              mozilla::dom::Element* aElement,
     113                 :              nsRuleWalker::VisitedHandlingType aVisitedHandling,
     114                 :              bool aIsRelevantLink);
     115                 : 
     116                 :   /*
     117                 :    * Helper to test whether a node is a link
     118                 :    */
     119                 :   static bool IsLink(mozilla::dom::Element* aElement);
     120                 : 
     121                 :   // nsIStyleRuleProcessor
     122                 :   virtual void RulesMatching(ElementRuleProcessorData* aData);
     123                 : 
     124                 :   virtual void RulesMatching(PseudoElementRuleProcessorData* aData);
     125                 : 
     126                 :   virtual void RulesMatching(AnonBoxRuleProcessorData* aData);
     127                 : 
     128                 : #ifdef MOZ_XUL
     129                 :   virtual void RulesMatching(XULTreeRuleProcessorData* aData);
     130                 : #endif
     131                 : 
     132                 :   virtual nsRestyleHint HasStateDependentStyle(StateRuleProcessorData* aData);
     133                 : 
     134                 :   virtual bool HasDocumentStateDependentStyle(StateRuleProcessorData* aData);
     135                 : 
     136                 :   virtual nsRestyleHint
     137                 :     HasAttributeDependentStyle(AttributeRuleProcessorData* aData);
     138                 : 
     139                 :   virtual bool MediumFeaturesChanged(nsPresContext* aPresContext);
     140                 : 
     141                 :   virtual NS_MUST_OVERRIDE size_t
     142                 :     SizeOfExcludingThis(nsMallocSizeOfFun mallocSizeOf) const MOZ_OVERRIDE;
     143                 :   virtual NS_MUST_OVERRIDE size_t
     144                 :     SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf) const MOZ_OVERRIDE;
     145                 : 
     146                 :   // Append all the currently-active font face rules to aArray.  Return
     147                 :   // true for success and false for failure.
     148                 :   bool AppendFontFaceRules(nsPresContext* aPresContext,
     149                 :                            nsTArray<nsFontFaceRuleContainer>& aArray);
     150                 : 
     151                 :   bool AppendKeyframesRules(nsPresContext* aPresContext,
     152                 :                             nsTArray<nsCSSKeyframesRule*>& aArray);
     153                 : 
     154                 : #ifdef DEBUG
     155               0 :   void AssertQuirksChangeOK() {
     156               0 :     NS_ASSERTION(!mRuleCascades, "can't toggle quirks style sheet without "
     157                 :                                  "clearing rule cascades");
     158               0 :   }
     159                 : #endif
     160                 : 
     161                 : #ifdef XP_WIN
     162                 :   // Cached theme identifier for the moz-windows-theme media query.
     163                 :   static PRUint8 GetWindowsThemeIdentifier();
     164                 :   static void SetWindowsThemeIdentifier(PRUint8 aId) { 
     165                 :     sWinThemeId = aId;
     166                 :   }
     167                 : #endif
     168                 : 
     169               0 :   struct StateSelector {
     170               0 :     StateSelector(nsEventStates aStates, nsCSSSelector* aSelector)
     171                 :       : mStates(aStates),
     172               0 :         mSelector(aSelector)
     173               0 :     {}
     174                 : 
     175                 :     nsEventStates mStates;
     176                 :     nsCSSSelector* mSelector;
     177                 :   };
     178                 : 
     179                 : private:
     180                 :   static bool CascadeSheet(nsCSSStyleSheet* aSheet, CascadeEnumData* aData);
     181                 : 
     182                 :   RuleCascadeData* GetRuleCascade(nsPresContext* aPresContext);
     183                 :   void RefreshRuleCascade(nsPresContext* aPresContext);
     184                 : 
     185                 :   // The sheet order here is the same as in nsStyleSet::mSheets
     186                 :   sheet_array_type mSheets;
     187                 : 
     188                 :   // active first, then cached (most recent first)
     189                 :   RuleCascadeData* mRuleCascades;
     190                 : 
     191                 :   // The last pres context for which GetRuleCascades was called.
     192                 :   nsPresContext *mLastPresContext;
     193                 :   
     194                 :   // type of stylesheet using this processor
     195                 :   PRUint8 mSheetType;  // == nsStyleSet::sheetType
     196                 : 
     197                 : #ifdef XP_WIN
     198                 :   static PRUint8 sWinThemeId;
     199                 : #endif
     200                 : };
     201                 : 
     202                 : #endif /* nsCSSRuleProcessor_h_ */

Generated by: LCOV version 1.7