home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / libstyle / stystack.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  4.3 KB  |  128 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. #ifndef NSPR20
  20. #include "prhash.h"
  21. #else
  22. #include "plhash.h"
  23. #endif
  24.  
  25. #ifndef SML_HEADER
  26. #define SML_HEADER
  27.  
  28. #define STYLESTACK_Init(self, context)                (*self->vtable->Init)(self,context)
  29. #define STYLESTACK_PopTag(self,name)                (*self->vtable->PopTag)(self,name)
  30. #define STYLESTACK_PopTagByIndex(self,name, index)        (*self->vtable->PopTagByIndex)(self,name,index)
  31. #define STYLESTACK_PushTag(self,name,class_name,id)        (*self->vtable->PushTag)(self,name,class_name,id)
  32. #define STYLESTACK_GetTagByIndex(self, i)            (*self->vtable->GetTagByIndex)(self, i)
  33. #define STYLESTACK_GetTagByReverseIndex(self, i)    (*self->vtable->GetTagByReverseIndex)(self, i)
  34. #define STYLESTACK_GetStyleByIndex(self, i)            (*self->vtable->GetStyleByIndex)(self, i)
  35. #define STYLESTACK_GetStyleByReverseIndex(self, i)    (*self->vtable->GetStyleByReverseIndex)(self, i)
  36. #define STYLESTACK_FreeTagStruct(self,tag)            (*self->vtable->FreeTagStruct)(self,tag)
  37. #define STYLESTACK_NewTagStruct(self,name,class_name,id)    (*self->vtable->NewTagStruct)(self,name,class_name,id)
  38. #define STYLESTACK_Delete(self)                        (*self->vtable->Delete)(self)
  39. #define STYLESTACK_Purge(self)                        (*self->vtable->Purge)(self)
  40. #define STYLESTACK_SetSaveOn(self, i)                    (*self->vtable->SetSaveOn)(self, i)
  41. #define STYLESTACK_IsSaveOn(self)                    (*self->vtable->IsSaveOn)(self)
  42.  
  43.  
  44.  
  45.  
  46. typedef struct {
  47.  
  48.     char *name;
  49.     char *class_name;
  50.     char *id;
  51.  
  52. } TagStruct;
  53.  
  54. typedef enum {
  55. PUSH_TAG_ERROR,
  56. PUSH_TAG_SUCCESS,
  57. PUSH_TAG_BLOCKED
  58. } PushTagStatus;
  59.  
  60. typedef struct _StyleAndTagStackInterface StyleAndTagStackInterface;
  61.  
  62. typedef struct {
  63.     StyleAndTagStackInterface  *vtable;
  64.     int32                       refcount;
  65. } StyleAndTagStack;
  66.  
  67. struct _StyleAndTagStackInterface {
  68.     void                 (*Init)
  69.             (StyleAndTagStack *self, MWContext *context);
  70.     TagStruct *         (*NewTagStruct)
  71.             (StyleAndTagStack *self, char *name, char *class_name, char *id);
  72.     void                 (*FreeTagStruct)
  73.             (StyleAndTagStack *self, TagStruct *tag);
  74.     PushTagStatus         (*PushTag)
  75.             (StyleAndTagStack *self, char *name, char *class_name, char *id);
  76.     void                  (*PopTag)
  77.             (StyleAndTagStack *self, char *name);
  78.     void                  (*PopTagByIndex)
  79.             (StyleAndTagStack *self, char *name, int32 index);
  80.     TagStruct *         (*GetTagByIndex)    
  81.             (StyleAndTagStack *self, int32 index);
  82.     TagStruct *         (*GetTagByReverseIndex)    
  83.             (StyleAndTagStack *self, int32 index);
  84.     StyleStruct *         (*GetStyleByIndex)    
  85.             (StyleAndTagStack *self, int32 index);
  86.     StyleStruct *         (*GetStyleByReverseIndex)    
  87.             (StyleAndTagStack *self, int32 index);
  88.     StyleStruct *         (*Delete)    
  89.             (StyleAndTagStack *self);
  90.     StyleStruct *         (*Purge)    
  91.             (StyleAndTagStack *self);
  92.     void                 (*SetSaveOn)    
  93.             (StyleAndTagStack *self, XP_Bool on_flag);
  94.     XP_Bool                (*IsSaveOn)    
  95.             (StyleAndTagStack *self);
  96. };
  97.  
  98.  
  99. /* initializer */
  100. extern StyleAndTagStack * SML_StyleStack_Factory_Create(void);
  101.  
  102. typedef enum JSSObjectTypeEnum {
  103.     JSSTags = 1, /* document.tags */
  104.     JSSIds,        /* document.ids */
  105.     JSSClasses,  /* document.classes */
  106.     JSSClass     /* document.classes.<some class> */
  107. } JSSObjectType;
  108.  
  109. typedef struct _StyleObject {
  110.     PRHashTable       *table;
  111.     JSSObjectType    type;
  112.     char           *name;  /* only used when type is JSSClass */
  113. } StyleObject;
  114.  
  115. extern void
  116. SML_SetObjectRefs(StyleAndTagStack *styleStack,
  117.                   StyleObject       *tags,
  118.                   StyleObject       *classes,
  119.                   StyleObject       *ids);
  120.  
  121. /* Helper routine to assemble the JSSContext */
  122. struct JSSContext;
  123.  
  124. extern void
  125. sml_GetJSSContext(StyleAndTagStack *styleStack, struct JSSContext *jc);
  126.  
  127. #endif /* SML_HEADER */
  128.