home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / libstyle / jssrules.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  2.7 KB  |  84 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. /*   jssrules.h --- private style sheet routines
  20.  */
  21. #ifndef __JSSRULES_H_
  22. #define __JSSRULES_H_
  23.  
  24. /*
  25.  * A JSS rule consists of a list of selectors, a list of declarations,
  26.  * and a specificity of its selector
  27.  */
  28. struct _StyleRule {
  29.     StyleTag    tag;
  30.     unsigned    nSelectors;
  31.     StyleTag  **selectors;  /* array of pointers to StyleTag structures */
  32.     StyleRule  *next;
  33. };
  34.  
  35. /*
  36.  * Specificity is implemented as three 8-bit components: the number of tags    in
  37.  * the selector (the least significant component), the number of classes in the
  38.  * selector, and the number of ids in the selector (the most significant component)
  39.  */
  40. #define JSS_SPECIFICITY(nTags, nClasses, nIDs)\
  41.     ((uint32)(nTags) | ((uint32)(nClasses)<<8) | ((uint32)(nIDs)<<16))
  42.  
  43. /*
  44.  * This routine creates a new rule object and adds it to the list of existing
  45.  * rules
  46.  *
  47.  * Returns the new rule if successful; 0 otherwise
  48.  */
  49. extern StyleRule *
  50. jss_NewRule(JSContext *mc, unsigned nSelectors, jsval *selectors);
  51.  
  52. /* Destroys a list of rules */
  53. extern void
  54. jss_DestroyRules(StyleRule *);
  55.  
  56. /*
  57.  * Given a list of rules and a contextual selector (array of simple
  58.  * selectors), looks to see if the contextual selector matches that of an
  59.  * existing rule
  60.  */
  61. extern StyleRule *
  62. jss_LookupRule(JSContext *mc, StyleRule *rules, unsigned nSelectors, jsval *selectors);
  63.  
  64. /*
  65.  * Callback function for jss_EnumApplicableRules(). Return MOCHA_TRUE to continuing
  66.  * iterating and MOCHA_FALSE to stop
  67.  */
  68. typedef JSBool (* RULECALLBACK)(StyleTag *tag, void    *data);
  69.  
  70. /*
  71.  * This routine takes as an argument a list of rules, a stack of open HTML
  72.  * elements, and a callback function. The callback function is called once for
  73.  * each rule that applies
  74.  */
  75. extern JSBool
  76. jss_EnumApplicableRules(JSSContext         *jc,
  77.                         StyleRule         *rules,
  78.                         StyleAndTagStack *styleStack,
  79.                         RULECALLBACK      callback,
  80.                         void             *data);
  81.  
  82. #endif /* __JSSRULES_H_ */
  83.  
  84.