Added to Modest: layer, glue, render

This commit is contained in:
lexborisov 2016-11-10 02:14:41 +03:00
parent c7f669c213
commit 423e892212
21 changed files with 562 additions and 182 deletions

38
include/modest/glue.h Normal file
View File

@ -0,0 +1,38 @@
/*
Copyright (C) 2016 Alexander Borisov
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
#ifndef MODEST_GLUE_H
#define MODEST_GLUE_H
#pragma once
#include <modest/myosi.h>
#include <modest/node/node.h>
#ifdef __cplusplus
extern "C" {
#endif
void modest_glue_callback_myhtml_insert_node(myhtml_tree_t* tree, myhtml_tree_node_t* node, void* ctx);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* MODEST_GLUE_H */

View File

@ -0,0 +1,39 @@
/*
Copyright (C) 2016 Alexander Borisov
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
#ifndef MODEST_LAYER_LAYER_H
#define MODEST_LAYER_LAYER_H
#pragma once
#include <modest/myosi.h>
#include <modest/modest.h>
#include <modest/style/type.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* MODEST_LAYER_LAYER_H */

View File

@ -0,0 +1,39 @@
/*
Copyright (C) 2016 Alexander Borisov
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
#ifndef MODEST_LAYER_TREE_H
#define MODEST_LAYER_TREE_H
#pragma once
#include <modest/myosi.h>
#include <modest/modest.h>
#include <modest/style/type.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* MODEST_LAYER_TREE_H */

View File

@ -45,7 +45,8 @@ extern "C" {
*/
enum modest_status {
MODEST_STATUS_OK = 0x000000,
MODEST_STATUS_ERROR_MEMORY_ALLOCATION = 0x020000
MODEST_STATUS_ERROR = 0x020000,
MODEST_STATUS_ERROR_MEMORY_ALLOCATION = 0x020001
}
typedef modest_status_t;

View File

@ -0,0 +1,39 @@
/*
Copyright (C) 2016 Alexander Borisov
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
#ifndef MODEST_RENDER_BEGIN_H
#define MODEST_RENDER_BEGIN_H
#pragma once
#include <modest/myosi.h>
#include <modest/modest.h>
#include <modest/style/type.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* MODEST_RENDER_BEGIN_H */

View File

@ -37,6 +37,8 @@ typedef bool (*mycss_declaration_serialization_f)(mycss_entry_t* entry, mycss_de
bool mycss_declaration_serialization_entry(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
void mycss_declaration_serialization_entries(mycss_entry_t* entry, mycss_declaration_entry_t* first_dec_entry, mycss_callback_serialization_f callback, void* context);
bool mycss_declaration_serialization_entry_only_value(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry,mycss_callback_serialization_f callback, void* context);
bool mycss_declaration_serialization_entry_by_type(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_property_type_t property_type, mycss_callback_serialization_f callback, void* context);
bool mycss_declaration_serialization_entry_only_value_by_type(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_property_type_t property_type, mycss_callback_serialization_f callback, void* context);
bool mycss_declaration_serialization_undef(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
bool mycss_declaration_serialization_shorthand_four(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);

View File

@ -1,7 +1,7 @@
find_files_h = $(wildcard $(SRCDIR)/modest/$(dir)/*.h)
find_files_c = $(wildcard $(SRCDIR)/modest/$(dir)/*.c)
SUBDIRS := . finder style node
SUBDIRS := . finder style node layer render
HDRS += $(foreach dir,$(SUBDIRS),$(find_files_h))
SRCS += $(foreach dir,$(SUBDIRS),$(find_files_c))

40
source/modest/glue.c Normal file
View File

@ -0,0 +1,40 @@
/*
Copyright (C) 2016 Alexander Borisov
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
#include "modest/glue.h"
void modest_glue_callback_myhtml_insert_node(myhtml_tree_t* tree, myhtml_tree_node_t* node, void* ctx)
{
if(node->tag_id == MyHTML_TAG__TEXT)
return;
modest_t *modest = (modest_t*)ctx;
/* create modest node */
modest_node_t *m_node = modest_node_create(modest);
if(m_node == NULL)
return;
modest_node_init(modest, m_node);
node->data = (void*)m_node;
}

38
source/modest/glue.h Normal file
View File

@ -0,0 +1,38 @@
/*
Copyright (C) 2016 Alexander Borisov
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
#ifndef MODEST_GLUE_H
#define MODEST_GLUE_H
#pragma once
#include "modest/myosi.h"
#include "modest/node/node.h"
#ifdef __cplusplus
extern "C" {
#endif
void modest_glue_callback_myhtml_insert_node(myhtml_tree_t* tree, myhtml_tree_node_t* node, void* ctx);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* MODEST_GLUE_H */

View File

@ -0,0 +1,21 @@
/*
Copyright (C) 2016 Alexander Borisov
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
#include "modest/layer/layer.h"

View File

@ -0,0 +1,39 @@
/*
Copyright (C) 2016 Alexander Borisov
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
#ifndef MODEST_LAYER_LAYER_H
#define MODEST_LAYER_LAYER_H
#pragma once
#include "modest/myosi.h"
#include "modest/modest.h"
#include "modest/style/type.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* MODEST_LAYER_LAYER_H */

View File

@ -0,0 +1,23 @@
/*
Copyright (C) 2016 Alexander Borisov
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
#include "modest/layer/tree.h"

View File

@ -0,0 +1,39 @@
/*
Copyright (C) 2016 Alexander Borisov
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
#ifndef MODEST_LAYER_TREE_H
#define MODEST_LAYER_TREE_H
#pragma once
#include "modest/myosi.h"
#include "modest/modest.h"
#include "modest/style/type.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* MODEST_LAYER_TREE_H */

View File

@ -45,7 +45,8 @@ extern "C" {
*/
enum modest_status {
MODEST_STATUS_OK = 0x000000,
MODEST_STATUS_ERROR_MEMORY_ALLOCATION = 0x020000
MODEST_STATUS_ERROR = 0x020000,
MODEST_STATUS_ERROR_MEMORY_ALLOCATION = 0x020001
}
typedef modest_status_t;

View File

@ -37,19 +37,19 @@ modest_status_t modest_node_init(modest_t* modest, modest_node_t *mnode)
{
mnode->stylesheet = modest_style_sheet_create(modest);
if(mnode->stylesheet == NULL)
return MODEST_STATUS_OK;
return MODEST_STATUS_ERROR_MEMORY_ALLOCATION;
modest_status_t status = modest_style_sheet_init(modest, mnode->stylesheet);
if(status)
return MODEST_STATUS_OK;
return MODEST_STATUS_ERROR;
mnode->raw_style = modest_style_raw_create(modest);
if(mnode->raw_style == NULL)
return MODEST_STATUS_OK;
return MODEST_STATUS_ERROR_MEMORY_ALLOCATION;
status = modest_style_raw_init(modest, mnode->raw_style);
if(status)
return MODEST_STATUS_OK;
return MODEST_STATUS_ERROR;
return MODEST_STATUS_OK;
}

View File

@ -20,14 +20,14 @@
#include "modest/node/serialization.h"
void modest_node_raw_serialization_declaration(mycss_entry_t* mycss_entry, mycss_declaration_entry_t* decl, mycss_callback_serialization_f callback, void* context, bool* is_use)
void modest_node_raw_serialization_declaration(mycss_entry_t* mycss_entry, mycss_declaration_entry_t* decl, mycss_property_type_t property_type, mycss_callback_serialization_f callback, void* context, bool* is_use)
{
if(decl) {
if(is_use && *is_use) {
callback(" ", 1, context);
}
mycss_declaration_serialization_entry(mycss_entry, decl, callback, context);
mycss_declaration_serialization_entry_by_type(mycss_entry, decl, property_type, callback, context);
callback(";", 1, context);
if(is_use && *is_use == false) {
@ -40,39 +40,39 @@ bool modest_node_raw_serialization(mycss_entry_t* mycss_entry, modest_node_t* mn
{
bool is_use = false;
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, width), callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, height), callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, width), MyCSS_PROPERTY_TYPE_WIDTH, callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, height), MyCSS_PROPERTY_TYPE_HEIGHT, callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, padding_top), callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, padding_right), callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, padding_bottom), callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, padding_left), callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, padding_top), MyCSS_PROPERTY_TYPE_PADDING_TOP, callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, padding_right), MyCSS_PROPERTY_TYPE_PADDING_RIGHT, callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, padding_bottom), MyCSS_PROPERTY_TYPE_PADDING_BOTTOM, callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, padding_left), MyCSS_PROPERTY_TYPE_PADDING_LEFT, callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, margin_top), callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, margin_right), callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, margin_bottom), callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, margin_left), callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, margin_top), MyCSS_PROPERTY_TYPE_MARGIN_TOP, callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, margin_right), MyCSS_PROPERTY_TYPE_MARGIN_RIGHT, callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, margin_bottom), MyCSS_PROPERTY_TYPE_MARGIN_BOTTOM, callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, margin_left), MyCSS_PROPERTY_TYPE_MARGIN_LEFT, callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, display), callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, display), MyCSS_PROPERTY_TYPE_DISPLAY, callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, border_top_width), callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, border_right_width), callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, border_bottom_width), callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, border_left_width), callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, border_top_width), MyCSS_PROPERTY_TYPE_BORDER_TOP_WIDTH, callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, border_right_width), MyCSS_PROPERTY_TYPE_BORDER_RIGHT_WIDTH, callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, border_bottom_width), MyCSS_PROPERTY_TYPE_BORDER_BOTTOM_WIDTH, callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, border_left_width), MyCSS_PROPERTY_TYPE_BORDER_LEFT_WIDTH, callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, border_top_style), callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, border_right_style), callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, border_bottom_style), callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, border_left_style), callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, border_top_style), MyCSS_PROPERTY_TYPE_BORDER_TOP_STYLE, callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, border_right_style), MyCSS_PROPERTY_TYPE_BORDER_RIGHT_STYLE, callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, border_bottom_style), MyCSS_PROPERTY_TYPE_BORDER_BOTTOM_STYLE, callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, border_left_style), MyCSS_PROPERTY_TYPE_BORDER_LEFT_STYLE, callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, box_sizing), callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, box_sizing), MyCSS_PROPERTY_TYPE_BOX_SIZING, callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, vertical_align), callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, line_height), callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, vertical_align), MyCSS_PROPERTY_TYPE_VERTICAL_ALIGN, callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, line_height), MyCSS_PROPERTY_TYPE_LINE_HEIGHT, callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, text_decoration_line), callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, text_decoration_style), callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, text_decoration_skip), callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, text_decoration_line), MyCSS_PROPERTY_TYPE_TEXT_DECORATION_LINE, callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, text_decoration_style), MyCSS_PROPERTY_TYPE_TEXT_DECORATION_STYLE, callback, context, &is_use);
modest_node_raw_serialization_declaration(mycss_entry, modest_node_raw_property(mnode, text_decoration_skip), MyCSS_PROPERTY_TYPE_TEXT_DECORATION_SKIP, callback, context, &is_use);
return true;
}

View File

@ -0,0 +1,23 @@
/*
Copyright (C) 2016 Alexander Borisov
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
#include "modest/render/begin.h"

View File

@ -0,0 +1,39 @@
/*
Copyright (C) 2016 Alexander Borisov
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
#ifndef MODEST_RENDER_BEGIN_H
#define MODEST_RENDER_BEGIN_H
#pragma once
#include "modest/myosi.h"
#include "modest/modest.h"
#include "modest/style/type.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* MODEST_RENDER_BEGIN_H */

View File

@ -77,50 +77,33 @@ void modest_style_map_collate_declaration_padding(modest_t* modest, myhtml_tree_
if(node->data == NULL || decl->value == NULL)
return;
mycss_values_shorthand_four_t val_four = *((mycss_values_shorthand_four_t*)(decl->value));
mycss_values_shorthand_four_t *val_four = (mycss_values_shorthand_four_t*)decl->value;
mycss_declaration_t* declaration = modest->mycss_entry->declaration;
if(val_four.two == NULL) {
mycss_declaration_entry_important_set(val_four.one, decl->is_important);
val_four.two = mycss_declaration_entry_clone(declaration, val_four.one, true);
val_four.three = mycss_declaration_entry_clone(declaration, val_four.one, true);
val_four.four = mycss_declaration_entry_clone(declaration, val_four.one, true);
mycss_declaration_entry_type_set(val_four.two, MyCSS_PROPERTY_TYPE_PADDING_RIGHT);
mycss_declaration_entry_type_set(val_four.three, MyCSS_PROPERTY_TYPE_PADDING_BOTTOM);
mycss_declaration_entry_type_set(val_four.four, MyCSS_PROPERTY_TYPE_PADDING_LEFT);
if(val_four->two == NULL) {
modest_style_map_collate_declaration_padding_top(modest, node, val_four->one, spec);
modest_style_map_collate_declaration_padding_right(modest, node, val_four->one, spec);
modest_style_map_collate_declaration_padding_bottom(modest, node, val_four->one, spec);
modest_style_map_collate_declaration_padding_left(modest, node, val_four->one, spec);
}
else if(val_four.three == NULL) {
mycss_declaration_entry_important_set(val_four.one, decl->is_important);
mycss_declaration_entry_important_set(val_four.two, decl->is_important);
val_four.three = mycss_declaration_entry_clone(declaration, val_four.one, true);
val_four.four = mycss_declaration_entry_clone(declaration, val_four.two, true);
mycss_declaration_entry_type_set(val_four.three, MyCSS_PROPERTY_TYPE_PADDING_BOTTOM);
mycss_declaration_entry_type_set(val_four.four, MyCSS_PROPERTY_TYPE_PADDING_LEFT);
else if(val_four->three == NULL) {
modest_style_map_collate_declaration_padding_top(modest, node, val_four->one, spec);
modest_style_map_collate_declaration_padding_right(modest, node, val_four->two, spec);
modest_style_map_collate_declaration_padding_bottom(modest, node, val_four->one, spec);
modest_style_map_collate_declaration_padding_left(modest, node, val_four->two, spec);
}
else if(val_four.four == NULL) {
mycss_declaration_entry_important_set(val_four.one, decl->is_important);
mycss_declaration_entry_important_set(val_four.two, decl->is_important);
mycss_declaration_entry_important_set(val_four.three, decl->is_important);
val_four.four = mycss_declaration_entry_clone(declaration, val_four.two, true);
mycss_declaration_entry_type_set(val_four.four, MyCSS_PROPERTY_TYPE_PADDING_LEFT);
else if(val_four->four == NULL) {
modest_style_map_collate_declaration_padding_top(modest, node, val_four->one, spec);
modest_style_map_collate_declaration_padding_right(modest, node, val_four->two, spec);
modest_style_map_collate_declaration_padding_bottom(modest, node, val_four->three, spec);
modest_style_map_collate_declaration_padding_left(modest, node, val_four->two, spec);
}
else {
mycss_declaration_entry_important_set(val_four.one, decl->is_important);
mycss_declaration_entry_important_set(val_four.two, decl->is_important);
mycss_declaration_entry_important_set(val_four.three, decl->is_important);
mycss_declaration_entry_important_set(val_four.four, decl->is_important);
modest_style_map_collate_declaration_padding_top(modest, node, val_four->one, spec);
modest_style_map_collate_declaration_padding_right(modest, node, val_four->two, spec);
modest_style_map_collate_declaration_padding_bottom(modest, node, val_four->three, spec);
modest_style_map_collate_declaration_padding_left(modest, node, val_four->four, spec);
}
modest_style_map_collate_declaration_padding_top(modest, node, val_four.one, spec);
modest_style_map_collate_declaration_padding_right(modest, node, val_four.two, spec);
modest_style_map_collate_declaration_padding_bottom(modest, node, val_four.three, spec);
modest_style_map_collate_declaration_padding_left(modest, node, val_four.four, spec);
}
void modest_style_map_collate_declaration_padding_top(modest_t* modest, myhtml_tree_node_t* node, mycss_declaration_entry_t* decl, modest_style_raw_specificity_t* spec)
@ -205,50 +188,33 @@ void modest_style_map_collate_declaration_margin(modest_t* modest, myhtml_tree_n
if(node->data == NULL || decl->value == NULL)
return;
mycss_values_shorthand_four_t val_four = *((mycss_values_shorthand_four_t*)(decl->value));
mycss_values_shorthand_four_t *val_four = (mycss_values_shorthand_four_t*)decl->value;
mycss_declaration_t* declaration = modest->mycss_entry->declaration;
if(val_four.two == NULL) {
mycss_declaration_entry_important_set(val_four.one, decl->is_important);
val_four.two = mycss_declaration_entry_clone(declaration, val_four.one, true);
val_four.three = mycss_declaration_entry_clone(declaration, val_four.one, true);
val_four.four = mycss_declaration_entry_clone(declaration, val_four.one, true);
mycss_declaration_entry_type_set(val_four.two, MyCSS_PROPERTY_TYPE_MARGIN_RIGHT);
mycss_declaration_entry_type_set(val_four.three, MyCSS_PROPERTY_TYPE_MARGIN_BOTTOM);
mycss_declaration_entry_type_set(val_four.four, MyCSS_PROPERTY_TYPE_MARGIN_LEFT);
if(val_four->two == NULL) {
modest_style_map_collate_declaration_margin_top(modest, node, val_four->one, spec);
modest_style_map_collate_declaration_margin_right(modest, node, val_four->one, spec);
modest_style_map_collate_declaration_margin_bottom(modest, node, val_four->one, spec);
modest_style_map_collate_declaration_margin_left(modest, node, val_four->one, spec);
}
else if(val_four.three == NULL) {
mycss_declaration_entry_important_set(val_four.one, decl->is_important);
mycss_declaration_entry_important_set(val_four.two, decl->is_important);
val_four.three = mycss_declaration_entry_clone(declaration, val_four.one, true);
val_four.four = mycss_declaration_entry_clone(declaration, val_four.two, true);
mycss_declaration_entry_type_set(val_four.three, MyCSS_PROPERTY_TYPE_MARGIN_BOTTOM);
mycss_declaration_entry_type_set(val_four.four, MyCSS_PROPERTY_TYPE_MARGIN_LEFT);
else if(val_four->three == NULL) {
modest_style_map_collate_declaration_margin_top(modest, node, val_four->one, spec);
modest_style_map_collate_declaration_margin_right(modest, node, val_four->two, spec);
modest_style_map_collate_declaration_margin_bottom(modest, node, val_four->one, spec);
modest_style_map_collate_declaration_margin_left(modest, node, val_four->two, spec);
}
else if(val_four.four == NULL) {
mycss_declaration_entry_important_set(val_four.one, decl->is_important);
mycss_declaration_entry_important_set(val_four.two, decl->is_important);
mycss_declaration_entry_important_set(val_four.three, decl->is_important);
val_four.four = mycss_declaration_entry_clone(declaration, val_four.two, true);
mycss_declaration_entry_type_set(val_four.four, MyCSS_PROPERTY_TYPE_MARGIN_LEFT);
else if(val_four->four == NULL) {
modest_style_map_collate_declaration_margin_top(modest, node, val_four->one, spec);
modest_style_map_collate_declaration_margin_right(modest, node, val_four->two, spec);
modest_style_map_collate_declaration_margin_bottom(modest, node, val_four->three, spec);
modest_style_map_collate_declaration_margin_left(modest, node, val_four->two, spec);
}
else {
mycss_declaration_entry_important_set(val_four.one, decl->is_important);
mycss_declaration_entry_important_set(val_four.two, decl->is_important);
mycss_declaration_entry_important_set(val_four.three, decl->is_important);
mycss_declaration_entry_important_set(val_four.four, decl->is_important);
modest_style_map_collate_declaration_margin_top(modest, node, val_four->one, spec);
modest_style_map_collate_declaration_margin_right(modest, node, val_four->two, spec);
modest_style_map_collate_declaration_margin_bottom(modest, node, val_four->three, spec);
modest_style_map_collate_declaration_margin_left(modest, node, val_four->four, spec);
}
modest_style_map_collate_declaration_margin_top(modest, node, val_four.one, spec);
modest_style_map_collate_declaration_margin_right(modest, node, val_four.two, spec);
modest_style_map_collate_declaration_margin_bottom(modest, node, val_four.three, spec);
modest_style_map_collate_declaration_margin_left(modest, node, val_four.four, spec);
}
void modest_style_map_collate_declaration_margin_bottom(modest_t* modest, myhtml_tree_node_t* node, mycss_declaration_entry_t* decl, modest_style_raw_specificity_t* spec)
@ -353,50 +319,33 @@ void modest_style_map_collate_declaration_border_width(modest_t* modest, myhtml_
if(node->data == NULL || decl->value == NULL)
return;
mycss_values_shorthand_four_t val_four = *((mycss_values_shorthand_four_t*)(decl->value));
mycss_values_shorthand_four_t *val_four = (mycss_values_shorthand_four_t*)decl->value;
mycss_declaration_t* declaration = modest->mycss_entry->declaration;
if(val_four.two == NULL) {
mycss_declaration_entry_important_set(val_four.one, decl->is_important);
val_four.two = mycss_declaration_entry_clone(declaration, val_four.one, true);
val_four.three = mycss_declaration_entry_clone(declaration, val_four.one, true);
val_four.four = mycss_declaration_entry_clone(declaration, val_four.one, true);
mycss_declaration_entry_type_set(val_four.two, MyCSS_PROPERTY_TYPE_BORDER_RIGHT_WIDTH);
mycss_declaration_entry_type_set(val_four.three, MyCSS_PROPERTY_TYPE_BORDER_BOTTOM_WIDTH);
mycss_declaration_entry_type_set(val_four.four, MyCSS_PROPERTY_TYPE_BORDER_LEFT_WIDTH);
if(val_four->two == NULL) {
modest_style_map_collate_declaration_border_top_width(modest, node, val_four->one, spec);
modest_style_map_collate_declaration_border_right_width(modest, node, val_four->one, spec);
modest_style_map_collate_declaration_border_bottom_width(modest, node, val_four->one, spec);
modest_style_map_collate_declaration_border_left_width(modest, node, val_four->one, spec);
}
else if(val_four.three == NULL) {
mycss_declaration_entry_important_set(val_four.one, decl->is_important);
mycss_declaration_entry_important_set(val_four.two, decl->is_important);
val_four.three = mycss_declaration_entry_clone(declaration, val_four.one, true);
val_four.four = mycss_declaration_entry_clone(declaration, val_four.two, true);
mycss_declaration_entry_type_set(val_four.three, MyCSS_PROPERTY_TYPE_BORDER_BOTTOM_WIDTH);
mycss_declaration_entry_type_set(val_four.four, MyCSS_PROPERTY_TYPE_BORDER_LEFT_WIDTH);
else if(val_four->three == NULL) {
modest_style_map_collate_declaration_border_top_width(modest, node, val_four->one, spec);
modest_style_map_collate_declaration_border_right_width(modest, node, val_four->two, spec);
modest_style_map_collate_declaration_border_bottom_width(modest, node, val_four->one, spec);
modest_style_map_collate_declaration_border_left_width(modest, node, val_four->two, spec);
}
else if(val_four.four == NULL) {
mycss_declaration_entry_important_set(val_four.one, decl->is_important);
mycss_declaration_entry_important_set(val_four.two, decl->is_important);
mycss_declaration_entry_important_set(val_four.three, decl->is_important);
val_four.four = mycss_declaration_entry_clone(declaration, val_four.two, true);
mycss_declaration_entry_type_set(val_four.four, MyCSS_PROPERTY_TYPE_BORDER_LEFT_WIDTH);
else if(val_four->four == NULL) {
modest_style_map_collate_declaration_border_top_width(modest, node, val_four->one, spec);
modest_style_map_collate_declaration_border_right_width(modest, node, val_four->two, spec);
modest_style_map_collate_declaration_border_bottom_width(modest, node, val_four->three, spec);
modest_style_map_collate_declaration_border_left_width(modest, node, val_four->two, spec);
}
else {
mycss_declaration_entry_important_set(val_four.one, decl->is_important);
mycss_declaration_entry_important_set(val_four.two, decl->is_important);
mycss_declaration_entry_important_set(val_four.three, decl->is_important);
mycss_declaration_entry_important_set(val_four.four, decl->is_important);
modest_style_map_collate_declaration_border_top_width(modest, node, val_four->one, spec);
modest_style_map_collate_declaration_border_right_width(modest, node, val_four->two, spec);
modest_style_map_collate_declaration_border_bottom_width(modest, node, val_four->three, spec);
modest_style_map_collate_declaration_border_left_width(modest, node, val_four->four, spec);
}
modest_style_map_collate_declaration_border_top_width(modest, node, val_four.one, spec);
modest_style_map_collate_declaration_border_right_width(modest, node, val_four.two, spec);
modest_style_map_collate_declaration_border_bottom_width(modest, node, val_four.three, spec);
modest_style_map_collate_declaration_border_left_width(modest, node, val_four.four, spec);
}
void modest_style_map_collate_declaration_border_top_width(modest_t* modest, myhtml_tree_node_t* node, mycss_declaration_entry_t* decl, modest_style_raw_specificity_t* spec)
@ -481,50 +430,33 @@ void modest_style_map_collate_declaration_border_style(modest_t* modest, myhtml_
if(node->data == NULL || decl->value == NULL)
return;
mycss_values_shorthand_four_t val_four = *((mycss_values_shorthand_four_t*)(decl->value));
mycss_values_shorthand_four_t *val_four = (mycss_values_shorthand_four_t*)decl->value;
mycss_declaration_t* declaration = modest->mycss_entry->declaration;
if(val_four.two == NULL) {
mycss_declaration_entry_important_set(val_four.one, decl->is_important);
val_four.two = mycss_declaration_entry_clone(declaration, val_four.one, true);
val_four.three = mycss_declaration_entry_clone(declaration, val_four.one, true);
val_four.four = mycss_declaration_entry_clone(declaration, val_four.one, true);
mycss_declaration_entry_type_set(val_four.two, MyCSS_PROPERTY_TYPE_BORDER_RIGHT_STYLE);
mycss_declaration_entry_type_set(val_four.three, MyCSS_PROPERTY_TYPE_BORDER_BOTTOM_STYLE);
mycss_declaration_entry_type_set(val_four.four, MyCSS_PROPERTY_TYPE_BORDER_LEFT_STYLE);
if(val_four->two == NULL) {
modest_style_map_collate_declaration_border_top_style(modest, node, val_four->one, spec);
modest_style_map_collate_declaration_border_right_style(modest, node, val_four->one, spec);
modest_style_map_collate_declaration_border_bottom_style(modest, node, val_four->one, spec);
modest_style_map_collate_declaration_border_left_style(modest, node, val_four->one, spec);
}
else if(val_four.three == NULL) {
mycss_declaration_entry_important_set(val_four.one, decl->is_important);
mycss_declaration_entry_important_set(val_four.two, decl->is_important);
val_four.three = mycss_declaration_entry_clone(declaration, val_four.one, true);
val_four.four = mycss_declaration_entry_clone(declaration, val_four.two, true);
mycss_declaration_entry_type_set(val_four.three, MyCSS_PROPERTY_TYPE_BORDER_BOTTOM_STYLE);
mycss_declaration_entry_type_set(val_four.four, MyCSS_PROPERTY_TYPE_BORDER_LEFT_STYLE);
else if(val_four->three == NULL) {
modest_style_map_collate_declaration_border_top_style(modest, node, val_four->one, spec);
modest_style_map_collate_declaration_border_right_style(modest, node, val_four->two, spec);
modest_style_map_collate_declaration_border_bottom_style(modest, node, val_four->one, spec);
modest_style_map_collate_declaration_border_left_style(modest, node, val_four->two, spec);
}
else if(val_four.four == NULL) {
mycss_declaration_entry_important_set(val_four.one, decl->is_important);
mycss_declaration_entry_important_set(val_four.two, decl->is_important);
mycss_declaration_entry_important_set(val_four.three, decl->is_important);
val_four.four = mycss_declaration_entry_clone(declaration, val_four.two, true);
mycss_declaration_entry_type_set(val_four.four, MyCSS_PROPERTY_TYPE_BORDER_LEFT_STYLE);
else if(val_four->four == NULL) {
modest_style_map_collate_declaration_border_top_style(modest, node, val_four->one, spec);
modest_style_map_collate_declaration_border_right_style(modest, node, val_four->two, spec);
modest_style_map_collate_declaration_border_bottom_style(modest, node, val_four->three, spec);
modest_style_map_collate_declaration_border_left_style(modest, node, val_four->two, spec);
}
else {
mycss_declaration_entry_important_set(val_four.one, decl->is_important);
mycss_declaration_entry_important_set(val_four.two, decl->is_important);
mycss_declaration_entry_important_set(val_four.three, decl->is_important);
mycss_declaration_entry_important_set(val_four.four, decl->is_important);
modest_style_map_collate_declaration_border_top_style(modest, node, val_four->one, spec);
modest_style_map_collate_declaration_border_right_style(modest, node, val_four->two, spec);
modest_style_map_collate_declaration_border_bottom_style(modest, node, val_four->three, spec);
modest_style_map_collate_declaration_border_left_style(modest, node, val_four->four, spec);
}
modest_style_map_collate_declaration_border_top_style(modest, node, val_four.one, spec);
modest_style_map_collate_declaration_border_right_style(modest, node, val_four.two, spec);
modest_style_map_collate_declaration_border_bottom_style(modest, node, val_four.three, spec);
modest_style_map_collate_declaration_border_left_style(modest, node, val_four.four, spec);
}
void modest_style_map_collate_declaration_border_top_style(modest_t* modest, myhtml_tree_node_t* node, mycss_declaration_entry_t* decl, modest_style_raw_specificity_t* spec)

View File

@ -50,6 +50,31 @@ bool mycss_declaration_serialization_entry_only_value(mycss_entry_t* entry, mycs
return mycss_declaration_serialization_map_by_type[ dec_entry->type ](entry, dec_entry, callback, context);
}
bool mycss_declaration_serialization_entry_by_type(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry,
mycss_property_type_t property_type,
mycss_callback_serialization_f callback, void* context)
{
if(dec_entry == NULL || property_type >= MyCSS_PROPERTY_TYPE_LAST_ENTRY)
return false;
mycss_property_serialization_type_name(property_type, callback, context);
callback(": ", 2, context);
return mycss_declaration_serialization_map_by_type[ property_type ](entry, dec_entry, callback, context);
}
bool mycss_declaration_serialization_entry_only_value_by_type(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry,
mycss_property_type_t property_type,
mycss_callback_serialization_f callback, void* context)
{
if(dec_entry == NULL || property_type >= MyCSS_PROPERTY_TYPE_LAST_ENTRY)
return false;
return mycss_declaration_serialization_map_by_type[ property_type ](entry, dec_entry, callback, context);
}
void mycss_declaration_serialization_entries(mycss_entry_t* entry, mycss_declaration_entry_t* first_dec_entry,
mycss_callback_serialization_f callback, void* context)
{

View File

@ -37,6 +37,8 @@ typedef bool (*mycss_declaration_serialization_f)(mycss_entry_t* entry, mycss_de
bool mycss_declaration_serialization_entry(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
void mycss_declaration_serialization_entries(mycss_entry_t* entry, mycss_declaration_entry_t* first_dec_entry, mycss_callback_serialization_f callback, void* context);
bool mycss_declaration_serialization_entry_only_value(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry,mycss_callback_serialization_f callback, void* context);
bool mycss_declaration_serialization_entry_by_type(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_property_type_t property_type, mycss_callback_serialization_f callback, void* context);
bool mycss_declaration_serialization_entry_only_value_by_type(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_property_type_t property_type, mycss_callback_serialization_f callback, void* context);
bool mycss_declaration_serialization_undef(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);
bool mycss_declaration_serialization_shorthand_four(mycss_entry_t* entry, mycss_declaration_entry_t* dec_entry, mycss_callback_serialization_f callback, void* context);