cr-doc-handler.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
  2. /*
  3. * This file is part of The Croco Library
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of version 2.1 of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  17. * USA
  18. *
  19. * See the COPYRIGHTS file for copyright information.
  20. */
  21. #ifndef __CR_DOC_HANDLER_H__
  22. #define __CR_DOC_HANDLER_H__
  23. /**
  24. *@file
  25. *The declaration of the #CRDocumentHandler class.
  26. *This class is actually the parsing events handler.
  27. */
  28. #include <glib.h>
  29. #include "cr-utils.h"
  30. #include "cr-input.h"
  31. #include "cr-stylesheet.h"
  32. G_BEGIN_DECLS
  33. typedef struct _CRDocHandler CRDocHandler ;
  34. struct _CRDocHandlerPriv ;
  35. typedef struct _CRDocHandlerPriv CRDocHandlerPriv ;
  36. /**
  37. *The SAC document handler.
  38. *An instance of this class is to
  39. *be passed to a parser. Then, during the parsing
  40. *the parser calls the convenient function pointer
  41. *whenever a particular event (a css construction) occurs.
  42. */
  43. struct _CRDocHandler
  44. {
  45. CRDocHandlerPriv *priv ;
  46. /**
  47. *This pointer is to be used by the application for
  48. *it custom needs. It is there to extend the doc handler.
  49. */
  50. gpointer app_data ;
  51. /**
  52. *Is called at the beginning of the parsing of the document.
  53. *@param a_this a pointer to the current instance of
  54. *#CRDocHandler.
  55. */
  56. void (*start_document) (CRDocHandler *a_this) ;
  57. /**
  58. *Is called to notify the end of the parsing of the document.
  59. *@param a_this a pointer to the current instance of
  60. *#CRDocHandler.
  61. */
  62. void (*end_document) (CRDocHandler *a_this) ;
  63. /**
  64. *Is called to notify an at charset rule.
  65. *@param a_this the document handler.
  66. *@param a_charset the declared charset.
  67. */
  68. void (*charset) (CRDocHandler *a_this,
  69. CRString *a_charset,
  70. CRParsingLocation *a_charset_sym_location) ;
  71. /**
  72. *Is called to notify an import statement in
  73. *the stylesheet.
  74. *@param a_this the current instance of #CRDocHandler.
  75. *@param a_media_list a doubly linked list of GString objects.
  76. *Each GString object contains a string which is the
  77. *destination media for style information.
  78. *@param a_uri the uri of the imported style sheet.
  79. *@param a_uri_default_ns the default namespace of URI
  80. *@param a_location the parsing location of the '\@import'
  81. *keyword.
  82. *of the imported style sheet.
  83. */
  84. void (*import_style) (CRDocHandler *a_this,
  85. GList *a_media_list,
  86. CRString *a_uri,
  87. CRString *a_uri_default_ns,
  88. CRParsingLocation *a_location) ;
  89. void (*import_style_result) (CRDocHandler *a_this,
  90. GList *a_media_list,
  91. CRString *a_uri,
  92. CRString *a_uri_default_ns,
  93. CRStyleSheet *a_sheet) ;
  94. /**
  95. *Is called to notify a namespace declaration.
  96. *Not used yet.
  97. *@param a_this the current instance of #CRDocHandler.
  98. *@param a_prefix the prefix of the namespace.
  99. *@param a_uri the uri of the namespace.
  100. *@param a_location the location of the "@namespace" keyword.
  101. */
  102. void (*namespace_declaration) (CRDocHandler *a_this,
  103. CRString *a_prefix,
  104. CRString *a_uri,
  105. CRParsingLocation *a_location) ;
  106. /**
  107. *Is called to notify a comment.
  108. *@param a_this a pointer to the current instance
  109. *of #CRDocHandler.
  110. *@param a_comment the comment.
  111. */
  112. void (*comment) (CRDocHandler *a_this,
  113. CRString *a_comment) ;
  114. /**
  115. *Is called to notify the beginning of a rule
  116. *statement.
  117. *@param a_this the current instance of #CRDocHandler.
  118. *@param a_selector_list the list of selectors that precedes
  119. *the rule declarations.
  120. */
  121. void (*start_selector) (CRDocHandler * a_this,
  122. CRSelector *a_selector_list) ;
  123. /**
  124. *Is called to notify the end of a rule statement.
  125. *@param a_this the current instance of #CRDocHandler.
  126. *@param a_selector_list the list of selectors that precedes
  127. *the rule declarations. This pointer is the same as
  128. *the one passed to start_selector() ;
  129. */
  130. void (*end_selector) (CRDocHandler *a_this,
  131. CRSelector *a_selector_list) ;
  132. /**
  133. *Is called to notify a declaration.
  134. *@param a_this a pointer to the current instance
  135. *of #CRDocHandler.
  136. *@param a_name the name of the parsed property.
  137. *@param a_expression a css expression that represents
  138. *the value of the property. A css expression is
  139. *actually a linked list of 'terms'. Each term can
  140. *be linked to other using operators.
  141. *
  142. */
  143. void (*property) (CRDocHandler *a_this,
  144. CRString *a_name,
  145. CRTerm *a_expression,
  146. gboolean a_is_important) ;
  147. /**
  148. *Is called to notify the start of a font face statement.
  149. *The parser invokes this method at the beginning of every
  150. *font face statement in the style sheet. There will
  151. *be a corresponding end_font_face () event for every
  152. *start_font_face () event.
  153. *
  154. *@param a_this a pointer to the current instance of
  155. *#CRDocHandler.
  156. *@param a_location the parsing location of the "\@font-face"
  157. *keyword.
  158. */
  159. void (*start_font_face) (CRDocHandler *a_this,
  160. CRParsingLocation *a_location) ;
  161. /**
  162. *Is called to notify the end of a font face statement.
  163. *@param a_this a pointer to the current instance of
  164. *#CRDocHandler.
  165. */
  166. void (*end_font_face) (CRDocHandler *a_this) ;
  167. /**
  168. *Is called to notify the beginning of a media statement.
  169. *The parser will invoke this method at the beginning of
  170. *every media statement in the style sheet. There will be
  171. *a corresponding end_media() event for every start_media()
  172. *event.
  173. *@param a_this a pointer to the current instance of
  174. *#CRDocHandler.
  175. *@param a_media_list a double linked list of
  176. #CRString * objects.
  177. *Each CRString objects is actually a destination media for
  178. *the style information.
  179. */
  180. void (*start_media) (CRDocHandler *a_this,
  181. GList *a_media_list,
  182. CRParsingLocation *a_location) ;
  183. /**
  184. *Is called to notify the end of a media statement.
  185. *@param a_this a pointer to the current instance
  186. *of #CRDocHandler.
  187. *@param a_media_list a double linked list of GString * objects.
  188. *Each GString objects is actually a destination media for
  189. *the style information.
  190. */
  191. void (*end_media) (CRDocHandler *a_this,
  192. GList *a_media_list) ;
  193. /**
  194. *Is called to notify the beginning of a page statement.
  195. *The parser invokes this function at the beginning of
  196. *every page statement in the style sheet. There will be
  197. *a corresponding end_page() event for every single
  198. *start_page() event.
  199. *@param a_this a pointer to the current instance of
  200. *#CRDocHandler.
  201. *@param a_name the name of the page (if any, null otherwise).
  202. *@param a_pseudo_page the pseudo page (if any, null otherwise).
  203. *@param a_location the parsing location of the "\@page" keyword.
  204. */
  205. void (*start_page) (CRDocHandler *a_this,
  206. CRString *a_name,
  207. CRString *a_pseudo_page,
  208. CRParsingLocation *a_location) ;
  209. /**
  210. *Is called to notify the end of a page statement.
  211. *@param a_this a pointer to the current instance of
  212. *#CRDocHandler.
  213. *@param a_name the name of the page (if any, null otherwise).
  214. *@param a_pseudo_page the pseudo page (if any, null otherwise).
  215. */
  216. void (*end_page) (CRDocHandler *a_this,
  217. CRString *a_name,
  218. CRString *pseudo_page) ;
  219. /**
  220. *Is Called to notify an unknown at-rule not supported
  221. *by this parser.
  222. */
  223. void (*ignorable_at_rule) (CRDocHandler *a_this,
  224. CRString *a_name) ;
  225. /**
  226. *Is called to notify a parsing error. After this error
  227. *the application must ignore the rule being parsed, if
  228. *any. After completion of this callback,
  229. *the parser will then try to resume the parsing,
  230. *ignoring the current error.
  231. */
  232. void (*error) (CRDocHandler *a_this) ;
  233. /**
  234. *Is called to notify an unrecoverable parsing error.
  235. *This is the place to put emergency routines that free allocated
  236. *resources.
  237. */
  238. void (*unrecoverable_error) (CRDocHandler *a_this) ;
  239. gboolean resolve_import ;
  240. gulong ref_count ;
  241. } ;
  242. CRDocHandler * cr_doc_handler_new (void) ;
  243. enum CRStatus cr_doc_handler_set_result (CRDocHandler *a_this, gpointer a_result) ;
  244. enum CRStatus cr_doc_handler_get_result (CRDocHandler const *a_this, gpointer * a_result) ;
  245. enum CRStatus cr_doc_handler_set_ctxt (CRDocHandler *a_this, gpointer a_ctxt) ;
  246. enum CRStatus cr_doc_handler_get_ctxt (CRDocHandler const *a_this, gpointer * a_ctxt) ;
  247. enum CRStatus cr_doc_handler_set_default_sac_handler (CRDocHandler *a_this) ;
  248. void cr_doc_handler_associate_a_parser (CRDocHandler *a_this,
  249. gpointer a_parser) ;
  250. void cr_doc_handler_ref (CRDocHandler *a_this) ;
  251. gboolean cr_doc_handler_unref (CRDocHandler *a_this) ;
  252. void cr_doc_handler_destroy (CRDocHandler *a_this) ;
  253. G_END_DECLS
  254. #endif /*__CR_DOC_HANDLER_H__*/