Blame gnulib-local/lib/libcroco/cr-statement.h

Packit Bot 06c835
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
Packit Bot 06c835
Packit Bot 06c835
/*
Packit Bot 06c835
 * This file is part of The Croco Library
Packit Bot 06c835
 *
Packit Bot 06c835
 * This program is free software; you can redistribute it and/or
Packit Bot 06c835
 * modify it under the terms of version 2.1 of the GNU Lesser General Public
Packit Bot 06c835
 * License as published by the Free Software Foundation.
Packit Bot 06c835
 *
Packit Bot 06c835
 * This program is distributed in the hope that it will be useful,
Packit Bot 06c835
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Bot 06c835
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Bot 06c835
 * GNU General Public License for more details.
Packit Bot 06c835
 *
Packit Bot 06c835
 * You should have received a copy of the GNU Lesser General Public License
Packit Bot 06c835
 * along with this program; if not, write to the Free Software
Packit Bot 06c835
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
Packit Bot 06c835
 * USA
Packit Bot 06c835
 * 
Packit Bot 06c835
 * Author: Dodji Seketeli
Packit Bot 06c835
 * See COPYRIGHTS file for copyright information.
Packit Bot 06c835
 */
Packit Bot 06c835
Packit Bot 06c835
#include <stdio.h>
Packit Bot 06c835
#include "cr-utils.h"
Packit Bot 06c835
#include "cr-term.h"
Packit Bot 06c835
#include "cr-selector.h"
Packit Bot 06c835
#include "cr-declaration.h"
Packit Bot 06c835
Packit Bot 06c835
#ifndef __CR_STATEMENT_H__
Packit Bot 06c835
#define __CR_STATEMENT_H__
Packit Bot 06c835
Packit Bot 06c835
G_BEGIN_DECLS
Packit Bot 06c835
Packit Bot 06c835
/**
Packit Bot 06c835
 *@file
Packit Bot 06c835
 *Declaration of the #CRStatement class.
Packit Bot 06c835
 */
Packit Bot 06c835
Packit Bot 06c835
/*
Packit Bot 06c835
 *forward declaration of CRStyleSheet which is defined in
Packit Bot 06c835
 *cr-stylesheet.h
Packit Bot 06c835
 */
Packit Bot 06c835
Packit Bot 06c835
struct _CRStatement ;
Packit Bot 06c835
Packit Bot 06c835
/*
Packit Bot 06c835
 *typedef struct _CRStatement CRStatement ; 
Packit Bot 06c835
 *this is forward declared in 
Packit Bot 06c835
 *cr-declaration.h already.
Packit Bot 06c835
 */
Packit Bot 06c835
Packit Bot 06c835
struct _CRAtMediaRule ;
Packit Bot 06c835
typedef struct _CRAtMediaRule CRAtMediaRule ;
Packit Bot 06c835
Packit Bot 06c835
typedef struct _CRRuleSet CRRuleSet ;
Packit Bot 06c835
Packit Bot 06c835
/**
Packit Bot 06c835
 *The abstraction of a css ruleset.
Packit Bot 06c835
 *A ruleset is made of a list of selectors,
Packit Bot 06c835
 *followed by a list of declarations.
Packit Bot 06c835
 */
Packit Bot 06c835
struct _CRRuleSet
Packit Bot 06c835
{
Packit Bot 06c835
	/**A list of instances of #CRSimpeSel*/
Packit Bot 06c835
	CRSelector *sel_list ;
Packit Bot 06c835
Packit Bot 06c835
	/**A list of instances of #CRDeclaration*/
Packit Bot 06c835
	CRDeclaration *decl_list ;
Packit Bot 06c835
	
Packit Bot 06c835
	/**
Packit Bot 06c835
	 *The parent media rule, or NULL if
Packit Bot 06c835
	 *no parent media rule exists.
Packit Bot 06c835
	 */
Packit Bot 06c835
	CRStatement *parent_media_rule ;
Packit Bot 06c835
} ;
Packit Bot 06c835
Packit Bot 06c835
/*
Packit Bot 06c835
 *a forward declaration of CRStylesheet.
Packit Bot 06c835
 *CRStylesheet is actually declared in
Packit Bot 06c835
 *cr-stylesheet.h
Packit Bot 06c835
 */
Packit Bot 06c835
struct _CRStyleSheet ;
Packit Bot 06c835
typedef struct _CRStyleSheet CRStyleSheet;
Packit Bot 06c835
Packit Bot 06c835
Packit Bot 06c835
/**The @import rule abstraction.*/
Packit Bot 06c835
typedef struct _CRAtImportRule CRAtImportRule ;
Packit Bot 06c835
struct _CRAtImportRule
Packit Bot 06c835
{
Packit Bot 06c835
	/**the url of the import rule*/
Packit Bot 06c835
	CRString *url ;
Packit Bot 06c835
Packit Bot 06c835
        GList *media_list ;
Packit Bot 06c835
Packit Bot 06c835
	/**
Packit Bot 06c835
	 *the stylesheet fetched from the url, if any.
Packit Bot 06c835
	 *this is not "owned" by #CRAtImportRule which means
Packit Bot 06c835
	 *it is not destroyed by the destructor of #CRAtImportRule.
Packit Bot 06c835
	 */
Packit Bot 06c835
	CRStyleSheet * sheet;
Packit Bot 06c835
};
Packit Bot 06c835
Packit Bot 06c835
Packit Bot 06c835
/**abstraction of an @media rule*/
Packit Bot 06c835
struct _CRAtMediaRule
Packit Bot 06c835
{
Packit Bot 06c835
	GList *media_list ;
Packit Bot 06c835
	CRStatement *rulesets ;	
Packit Bot 06c835
} ;
Packit Bot 06c835
Packit Bot 06c835
Packit Bot 06c835
typedef struct _CRAtPageRule CRAtPageRule ;
Packit Bot 06c835
/**The @page rule abstraction*/
Packit Bot 06c835
struct _CRAtPageRule
Packit Bot 06c835
{
Packit Bot 06c835
	/**a list of instances of #CRDeclaration*/
Packit Bot 06c835
	CRDeclaration *decl_list ;
Packit Bot 06c835
Packit Bot 06c835
	/**page selector. Is a pseudo selector*/
Packit Bot 06c835
	CRString *name ;
Packit Bot 06c835
	CRString *pseudo ;
Packit Bot 06c835
} ;
Packit Bot 06c835
Packit Bot 06c835
/**The @charset rule abstraction*/
Packit Bot 06c835
typedef struct _CRAtCharsetRule CRAtCharsetRule ;
Packit Bot 06c835
struct _CRAtCharsetRule
Packit Bot 06c835
{
Packit Bot 06c835
	CRString * charset ;
Packit Bot 06c835
};
Packit Bot 06c835
Packit Bot 06c835
/**The abstaction of the @font-face rule.*/
Packit Bot 06c835
typedef struct _CRAtFontFaceRule CRAtFontFaceRule ;
Packit Bot 06c835
struct _CRAtFontFaceRule
Packit Bot 06c835
{
Packit Bot 06c835
	/*a list of instanaces of #CRDeclaration*/
Packit Bot 06c835
	CRDeclaration *decl_list ;
Packit Bot 06c835
} ;
Packit Bot 06c835
Packit Bot 06c835
Packit Bot 06c835
/**
Packit Bot 06c835
 *The possible types of css2 statements.
Packit Bot 06c835
 */
Packit Bot 06c835
enum CRStatementType
Packit Bot 06c835
{
Packit Bot 06c835
	/**
Packit Bot 06c835
	 *A generic css at-rule
Packit Bot 06c835
	 *each unknown at-rule will
Packit Bot 06c835
	 *be of this type.
Packit Bot 06c835
	 */
Packit Bot 06c835
Packit Bot 06c835
        /**A css at-rule*/
Packit Bot 06c835
	AT_RULE_STMT = 0,
Packit Bot 06c835
Packit Bot 06c835
	/*A css ruleset*/
Packit Bot 06c835
	RULESET_STMT,
Packit Bot 06c835
Packit Bot 06c835
	/**A css2 import rule*/
Packit Bot 06c835
	AT_IMPORT_RULE_STMT,
Packit Bot 06c835
Packit Bot 06c835
	/**A css2 media rule*/
Packit Bot 06c835
	AT_MEDIA_RULE_STMT,
Packit Bot 06c835
Packit Bot 06c835
	/**A css2 page rule*/
Packit Bot 06c835
	AT_PAGE_RULE_STMT,
Packit Bot 06c835
Packit Bot 06c835
	/**A css2 charset rule*/
Packit Bot 06c835
	AT_CHARSET_RULE_STMT,
Packit Bot 06c835
Packit Bot 06c835
	/**A css2 font face rule*/
Packit Bot 06c835
	AT_FONT_FACE_RULE_STMT
Packit Bot 06c835
} ;
Packit Bot 06c835
Packit Bot 06c835
Packit Bot 06c835
/**
Packit Bot 06c835
 *The abstraction of css statement as defined
Packit Bot 06c835
 *in the chapter 4 and appendix D.1 of the css2 spec.
Packit Bot 06c835
 *A statement is actually a double chained list of
Packit Bot 06c835
 *statements.A statement can be a ruleset, an \@import
Packit Bot 06c835
 *rule, an \@page rule etc ...
Packit Bot 06c835
 */
Packit Bot 06c835
struct _CRStatement
Packit Bot 06c835
{
Packit Bot 06c835
	/**
Packit Bot 06c835
	 *The type of the statement.
Packit Bot 06c835
	 */
Packit Bot 06c835
	enum CRStatementType type ;
Packit Bot 06c835
Packit Bot 06c835
	union
Packit Bot 06c835
	{
Packit Bot 06c835
		CRRuleSet *ruleset ;
Packit Bot 06c835
		CRAtImportRule *import_rule ;
Packit Bot 06c835
		CRAtMediaRule *media_rule ;
Packit Bot 06c835
		CRAtPageRule *page_rule ;
Packit Bot 06c835
		CRAtCharsetRule *charset_rule ;
Packit Bot 06c835
		CRAtFontFaceRule *font_face_rule ;
Packit Bot 06c835
	} kind ;
Packit Bot 06c835
Packit Bot 06c835
        /*
Packit Bot 06c835
         *the specificity of the selector
Packit Bot 06c835
         *that matched this statement.
Packit Bot 06c835
         *This is only used by the cascading
Packit Bot 06c835
         *order determination algorithm.
Packit Bot 06c835
         */
Packit Bot 06c835
        gulong specificity ;
Packit Bot 06c835
Packit Bot 06c835
        /*
Packit Bot 06c835
         *the style sheet that contains
Packit Bot 06c835
         *this css statement.
Packit Bot 06c835
         */
Packit Bot 06c835
        CRStyleSheet *parent_sheet ;
Packit Bot 06c835
	CRStatement *next ;
Packit Bot 06c835
	CRStatement *prev ;
Packit Bot 06c835
Packit Bot 06c835
        CRParsingLocation location ;
Packit Bot 06c835
Packit Bot 06c835
        /**
Packit Bot 06c835
         *a custom pointer useable by
Packit Bot 06c835
         *applications that use libcroco.
Packit Bot 06c835
         *libcroco itself will never modify
Packit Bot 06c835
         *this pointer.
Packit Bot 06c835
         */        
Packit Bot 06c835
        gpointer app_data ;
Packit Bot 06c835
Packit Bot 06c835
        /**
Packit Bot 06c835
         *a custom pointer used
Packit Bot 06c835
         *by the upper layers of libcroco.
Packit Bot 06c835
         *application should never use this
Packit Bot 06c835
         *pointer.
Packit Bot 06c835
         */
Packit Bot 06c835
        gpointer croco_data ;
Packit Bot 06c835
Packit Bot 06c835
} ;
Packit Bot 06c835
Packit Bot 06c835
Packit Bot 06c835
gboolean
Packit Bot 06c835
cr_statement_does_buf_parses_against_core (const guchar *a_buf,
Packit Bot 06c835
                                           enum CREncoding a_encoding) ;
Packit Bot 06c835
CRStatement *
Packit Bot 06c835
cr_statement_parse_from_buf (const guchar *a_buf,
Packit Bot 06c835
			     enum CREncoding a_encoding) ;
Packit Bot 06c835
CRStatement*
Packit Bot 06c835
cr_statement_new_ruleset (CRStyleSheet *a_sheet,
Packit Bot 06c835
                          CRSelector *a_sel_list, 
Packit Bot 06c835
			  CRDeclaration *a_decl_list,
Packit Bot 06c835
			  CRStatement *a_media_rule) ;
Packit Bot 06c835
CRStatement *
Packit Bot 06c835
cr_statement_ruleset_parse_from_buf (const guchar * a_buf,
Packit Bot 06c835
				     enum CREncoding a_enc) ;
Packit Bot 06c835
Packit Bot 06c835
CRStatement*
Packit Bot 06c835
cr_statement_new_at_import_rule (CRStyleSheet *a_container_sheet,
Packit Bot 06c835
                                 CRString *a_url,
Packit Bot 06c835
                                 GList *a_media_list,
Packit Bot 06c835
				 CRStyleSheet *a_imported_sheet) ;
Packit Bot 06c835
Packit Bot 06c835
CRStatement *
Packit Bot 06c835
cr_statement_at_import_rule_parse_from_buf (const guchar * a_buf,
Packit Bot 06c835
                                            enum CREncoding a_encoding) ;
Packit Bot 06c835
Packit Bot 06c835
CRStatement *
Packit Bot 06c835
cr_statement_new_at_media_rule (CRStyleSheet *a_sheet,
Packit Bot 06c835
                                CRStatement *a_ruleset,
Packit Bot 06c835
				GList *a_media) ;
Packit Bot 06c835
CRStatement *
Packit Bot 06c835
cr_statement_at_media_rule_parse_from_buf (const guchar *a_buf,
Packit Bot 06c835
					   enum CREncoding a_enc) ;
Packit Bot 06c835
Packit Bot 06c835
CRStatement *
Packit Bot 06c835
cr_statement_new_at_charset_rule (CRStyleSheet *a_sheet,
Packit Bot 06c835
                                  CRString *a_charset) ;
Packit Bot 06c835
CRStatement *
Packit Bot 06c835
cr_statement_at_charset_rule_parse_from_buf (const guchar *a_buf,
Packit Bot 06c835
					     enum CREncoding a_encoding);
Packit Bot 06c835
Packit Bot 06c835
Packit Bot 06c835
CRStatement *
Packit Bot 06c835
cr_statement_new_at_font_face_rule (CRStyleSheet *a_sheet,
Packit Bot 06c835
                                    CRDeclaration *a_font_decls) ;
Packit Bot 06c835
CRStatement *
Packit Bot 06c835
cr_statement_font_face_rule_parse_from_buf (const guchar *a_buf,
Packit Bot 06c835
					    enum CREncoding a_encoding) ;
Packit Bot 06c835
Packit Bot 06c835
CRStatement *
Packit Bot 06c835
cr_statement_new_at_page_rule (CRStyleSheet *a_sheet,
Packit Bot 06c835
                               CRDeclaration *a_decl_list,
Packit Bot 06c835
			       CRString *a_name,
Packit Bot 06c835
			       CRString *a_pseudo) ;
Packit Bot 06c835
CRStatement *
Packit Bot 06c835
cr_statement_at_page_rule_parse_from_buf (const guchar *a_buf,
Packit Bot 06c835
					  enum CREncoding a_encoding)  ;
Packit Bot 06c835
Packit Bot 06c835
enum CRStatus
Packit Bot 06c835
cr_statement_set_parent_sheet (CRStatement *a_this, 
Packit Bot 06c835
                               CRStyleSheet *a_sheet) ;
Packit Bot 06c835
Packit Bot 06c835
enum CRStatus
Packit Bot 06c835
cr_statement_get_parent_sheet (CRStatement *a_this, 
Packit Bot 06c835
                               CRStyleSheet **a_sheet) ;
Packit Bot 06c835
Packit Bot 06c835
CRStatement *
Packit Bot 06c835
cr_statement_append (CRStatement *a_this,
Packit Bot 06c835
		     CRStatement *a_new) ;
Packit Bot 06c835
Packit Bot 06c835
CRStatement*
Packit Bot 06c835
cr_statement_prepend (CRStatement *a_this,
Packit Bot 06c835
		      CRStatement *a_new) ;
Packit Bot 06c835
Packit Bot 06c835
CRStatement *
Packit Bot 06c835
cr_statement_unlink (CRStatement *a_stmt) ;
Packit Bot 06c835
Packit Bot 06c835
enum CRStatus
Packit Bot 06c835
cr_statement_ruleset_set_sel_list (CRStatement *a_this,
Packit Bot 06c835
				   CRSelector *a_sel_list) ;
Packit Bot 06c835
Packit Bot 06c835
enum CRStatus
Packit Bot 06c835
cr_statement_ruleset_get_sel_list (CRStatement *a_this,
Packit Bot 06c835
				   CRSelector **a_list) ;
Packit Bot 06c835
Packit Bot 06c835
enum CRStatus
Packit Bot 06c835
cr_statement_ruleset_set_decl_list (CRStatement *a_this,
Packit Bot 06c835
				    CRDeclaration *a_list) ;
Packit Bot 06c835
Packit Bot 06c835
enum CRStatus
Packit Bot 06c835
cr_statement_ruleset_get_declarations (CRStatement *a_this,
Packit Bot 06c835
                                       CRDeclaration **a_decl_list) ;
Packit Bot 06c835
Packit Bot 06c835
enum CRStatus
Packit Bot 06c835
cr_statement_ruleset_append_decl2 (CRStatement *a_this,
Packit Bot 06c835
				   CRString *a_prop, CRTerm *a_value) ;
Packit Bot 06c835
Packit Bot 06c835
enum CRStatus
Packit Bot 06c835
cr_statement_ruleset_append_decl (CRStatement *a_this,
Packit Bot 06c835
				  CRDeclaration *a_decl) ;
Packit Bot 06c835
Packit Bot 06c835
enum CRStatus
Packit Bot 06c835
cr_statement_at_import_rule_set_imported_sheet (CRStatement *a_this,
Packit Bot 06c835
                                                CRStyleSheet *a_sheet) ;
Packit Bot 06c835
Packit Bot 06c835
enum CRStatus
Packit Bot 06c835
cr_statement_at_import_rule_get_imported_sheet (CRStatement *a_this,
Packit Bot 06c835
                                                CRStyleSheet **a_sheet) ;
Packit Bot 06c835
Packit Bot 06c835
enum CRStatus
Packit Bot 06c835
cr_statement_at_import_rule_set_url (CRStatement *a_this,
Packit Bot 06c835
				     CRString *a_url) ;
Packit Bot 06c835
Packit Bot 06c835
enum CRStatus
Packit Bot 06c835
cr_statement_at_import_rule_get_url (CRStatement *a_this,
Packit Bot 06c835
				     CRString **a_url) ;
Packit Bot 06c835
Packit Bot 06c835
gint
Packit Bot 06c835
cr_statement_at_media_nr_rules (CRStatement *a_this) ;
Packit Bot 06c835
Packit Bot 06c835
CRStatement *
Packit Bot 06c835
cr_statement_at_media_get_from_list (CRStatement *a_this, int itemnr) ;
Packit Bot 06c835
Packit Bot 06c835
enum CRStatus
Packit Bot 06c835
cr_statement_at_page_rule_set_sel (CRStatement *a_this,
Packit Bot 06c835
				   CRSelector *a_sel) ;
Packit Bot 06c835
Packit Bot 06c835
enum CRStatus
Packit Bot 06c835
cr_statement_at_page_rule_get_sel (CRStatement *a_this,
Packit Bot 06c835
				   CRSelector **a_sel) ;
Packit Bot 06c835
Packit Bot 06c835
enum CRStatus
Packit Bot 06c835
cr_statement_at_page_rule_set_declarations (CRStatement *a_this,
Packit Bot 06c835
					    CRDeclaration *a_decl_list) ;
Packit Bot 06c835
Packit Bot 06c835
enum CRStatus
Packit Bot 06c835
cr_statement_at_page_rule_get_declarations (CRStatement *a_this,
Packit Bot 06c835
					    CRDeclaration **a_decl_list) ;
Packit Bot 06c835
Packit Bot 06c835
enum CRStatus
Packit Bot 06c835
cr_statement_at_charset_rule_set_charset (CRStatement *a_this,
Packit Bot 06c835
					  CRString *a_charset) ;
Packit Bot 06c835
Packit Bot 06c835
enum CRStatus
Packit Bot 06c835
cr_statement_at_charset_rule_get_charset (CRStatement *a_this,
Packit Bot 06c835
					  CRString **a_charset) ;
Packit Bot 06c835
Packit Bot 06c835
enum CRStatus
Packit Bot 06c835
cr_statement_at_font_face_rule_set_decls (CRStatement *a_this,
Packit Bot 06c835
					  CRDeclaration *a_decls) ;
Packit Bot 06c835
Packit Bot 06c835
enum CRStatus
Packit Bot 06c835
cr_statement_at_font_face_rule_get_decls (CRStatement *a_this,
Packit Bot 06c835
					  CRDeclaration **a_decls) ;
Packit Bot 06c835
Packit Bot 06c835
enum CRStatus
Packit Bot 06c835
cr_statement_at_font_face_rule_add_decl (CRStatement *a_this,
Packit Bot 06c835
					 CRString *a_prop,
Packit Bot 06c835
					 CRTerm *a_value) ;
Packit Bot 06c835
Packit Bot 06c835
gchar *
Packit Bot 06c835
cr_statement_to_string (CRStatement * a_this, gulong a_indent) ;
Packit Bot 06c835
Packit Bot 06c835
gchar*
Packit Bot 06c835
cr_statement_list_to_string (CRStatement *a_this, gulong a_indent) ;
Packit Bot 06c835
Packit Bot 06c835
void
Packit Bot 06c835
cr_statement_dump (CRStatement *a_this, FILE *a_fp, gulong a_indent) ;
Packit Bot 06c835
Packit Bot 06c835
void
Packit Bot 06c835
cr_statement_dump_ruleset (CRStatement * a_this, FILE * a_fp, 
Packit Bot 06c835
                           glong a_indent) ;
Packit Bot 06c835
Packit Bot 06c835
void
Packit Bot 06c835
cr_statement_dump_font_face_rule (CRStatement * a_this, 
Packit Bot 06c835
                                  FILE * a_fp,
Packit Bot 06c835
                                  glong a_indent) ;
Packit Bot 06c835
Packit Bot 06c835
void
Packit Bot 06c835
cr_statement_dump_page (CRStatement * a_this, FILE * a_fp, 
Packit Bot 06c835
                        gulong a_indent) ;
Packit Bot 06c835
Packit Bot 06c835
Packit Bot 06c835
void
Packit Bot 06c835
cr_statement_dump_media_rule (CRStatement * a_this, 
Packit Bot 06c835
                              FILE * a_fp,
Packit Bot 06c835
                              gulong a_indent) ;
Packit Bot 06c835
Packit Bot 06c835
void
Packit Bot 06c835
cr_statement_dump_import_rule (CRStatement * a_this, FILE * a_fp,
Packit Bot 06c835
                               gulong a_indent) ; 
Packit Bot 06c835
void
Packit Bot 06c835
cr_statement_dump_charset (CRStatement * a_this, FILE * a_fp, 
Packit Bot 06c835
                           gulong a_indent) ;
Packit Bot 06c835
gint
Packit Bot 06c835
cr_statement_nr_rules (CRStatement *a_this) ;
Packit Bot 06c835
Packit Bot 06c835
CRStatement *
Packit Bot 06c835
cr_statement_get_from_list (CRStatement *a_this, int itemnr) ;
Packit Bot 06c835
Packit Bot 06c835
void
Packit Bot 06c835
cr_statement_destroy (CRStatement *a_this) ;
Packit Bot 06c835
Packit Bot 06c835
G_END_DECLS
Packit Bot 06c835
Packit Bot 06c835
#endif /*__CR_STATEMENT_H__*/