LCOV - code coverage report
Current view: directory - layout/style - nsIStyleRule.h (source / functions) Found Hit Coverage
Test: app.info Lines: 1 1 100.0 %
Date: 2012-06-02 Functions: 1 1 100.0 %

       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                 : /*
      39                 :  * internal abstract interface for objects providing immutable style
      40                 :  * information
      41                 :  */
      42                 : 
      43                 : #ifndef nsIStyleRule_h___
      44                 : #define nsIStyleRule_h___
      45                 : 
      46                 : #include <stdio.h>
      47                 : 
      48                 : #include "nsISupports.h"
      49                 : 
      50                 : struct nsRuleData;
      51                 : 
      52                 : // IID for the nsIStyleRule interface {f75f3f70-435d-43a6-a01b-65970489ca26}
      53                 : #define NS_ISTYLE_RULE_IID     \
      54                 : { 0xf75f3f70, 0x435d, 0x43a6, \
      55                 :  { 0xa0, 0x1b, 0x65, 0x97, 0x04, 0x89, 0xca, 0x26 } }
      56                 : 
      57                 : /**
      58                 :  * An object implementing |nsIStyleRule| (henceforth, a rule) represents
      59                 :  * immutable stylistic information that either applies or does not apply
      60                 :  * to a given element.  It belongs to an object or group of objects that
      61                 :  * implement |nsIStyleSheet| and |nsIStyleRuleProcessor| (henceforth, a
      62                 :  * sheet).
      63                 :  *
      64                 :  * A rule becomes relevant to the computation of style data when
      65                 :  * |nsIStyleRuleProcessor::RulesMatching| creates a rule node that
      66                 :  * points to the rule.  (A rule node, |nsRuleNode|, is a node in the
      67                 :  * rule tree, which is a lexicographic tree indexed by rules.  The path
      68                 :  * from the root of the rule tree to the |nsRuleNode| for a given
      69                 :  * |nsStyleContext| contains exactly the rules that match the element
      70                 :  * that the style context is for, in priority (weight, origin,
      71                 :  * specificity) order.)
      72                 :  *
      73                 :  * The computation of style data uses the rule tree, which calls
      74                 :  * |nsIStyleRule::MapRuleInfoInto| below.
      75                 :  *
      76                 :  * It is worth emphasizing that the data represented by a rule
      77                 :  * implementation are immutable.  When the data need to be changed, a
      78                 :  * new rule object must be created.  Failing to do this will lead to
      79                 :  * bugs in the handling of dynamic style changes, since the rule tree
      80                 :  * caches the results of |MapRuleInfoInto|.
      81                 :  *
      82                 :  * |nsIStyleRule| objects are owned by |nsRuleNode| objects (in addition
      83                 :  * to typically being owned by their sheet), which are in turn garbage
      84                 :  * collected (with the garbage collection roots being style contexts).
      85                 :  */
      86                 : 
      87                 : 
      88             938 : class nsIStyleRule : public nsISupports {
      89                 : public:
      90                 :   NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISTYLE_RULE_IID)
      91                 : 
      92                 :   /**
      93                 :    * |nsIStyleRule::MapRuleInfoInto| is a request to copy all stylistic
      94                 :    * data represented by the rule that:
      95                 :    *   + are relevant for any structs in |aRuleData->mSIDs| (style
      96                 :    *     struct ID bits)
      97                 :    *   + are not already filled into the data struct
      98                 :    * into the appropriate data struct in |aRuleData|.  It is important
      99                 :    * that only empty data are filled in, since the rule tree is walked
     100                 :    * from highest priority rule to least, so that the walk can stop if
     101                 :    * all needed data are found.  Thus overwriting non-empty data will
     102                 :    * break CSS cascading rules.
     103                 :    */
     104                 :   virtual void MapRuleInfoInto(nsRuleData* aRuleData)=0;
     105                 : 
     106                 : #ifdef DEBUG
     107                 :   virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const = 0;
     108                 : #endif
     109                 : };
     110                 : 
     111                 : NS_DEFINE_STATIC_IID_ACCESSOR(nsIStyleRule, NS_ISTYLE_RULE_IID)
     112                 : 
     113                 : #endif /* nsIStyleRule_h___ */

Generated by: LCOV version 1.7