Skip to content

Added support for opacity #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions include/mycss/declaration/default_entries.h
Original file line number Diff line number Diff line change
Expand Up @@ -813,4 +813,13 @@ static mycss_declaration_entry_t mycss_declaration_default_entry_border_spacing
NULL, NULL
};

static mycss_declaration_entry_t mycss_declaration_default_entry_opacity = {
MyCSS_PROPERTY_TYPE_OPACITY,
MyCSS_PROPERTY_VALUE__NUMBER,
&(mycss_values_number_t) {{1}, false},
false,
MyCSS_DECLARATION_FLAGS_READ_ONLY,
NULL, NULL
};

#endif /* MyCSS_DECLARATION_DEFAULT_ENTRIES_H */
2 changes: 1 addition & 1 deletion include/mycss/declaration/default_resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ static mycss_declaration_entry_t * mycss_declaration_default_entry_index_type[My
&mycss_declaration_default_entry_undef,
&mycss_declaration_default_entry_undef,
&mycss_declaration_default_entry_undef,
&mycss_declaration_default_entry_undef,
&mycss_declaration_default_entry_opacity,
&mycss_declaration_default_entry_undef,
&mycss_declaration_default_entry_undef,
&mycss_declaration_default_entry_undef,
Expand Down
9 changes: 8 additions & 1 deletion source/mycss/declaration/default_entries.h
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,6 @@ static mycss_declaration_entry_t mycss_declaration_default_entry_vertical_align
NULL, NULL
};


static mycss_declaration_entry_t mycss_declaration_default_entry_border_spacing = {
MyCSS_PROPERTY_TYPE_BORDER_SPACING,
MyCSS_PROPERTY_VALUE_UNDEF,
Expand All @@ -814,4 +813,12 @@ static mycss_declaration_entry_t mycss_declaration_default_entry_border_spacing
NULL, NULL
};

static mycss_declaration_entry_t mycss_declaration_default_entry_opacity = {
MyCSS_PROPERTY_TYPE_OPACITY,
MyCSS_PROPERTY_VALUE__NUMBER,
&(mycss_values_number_t) {{1}, false},
false,
MyCSS_DECLARATION_FLAGS_READ_ONLY,
NULL, NULL
};
#endif /* MyCSS_DECLARATION_DEFAULT_ENTRIES_H */
2 changes: 1 addition & 1 deletion source/mycss/declaration/default_resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ static mycss_declaration_entry_t * mycss_declaration_default_entry_index_type[My
&mycss_declaration_default_entry_undef,
&mycss_declaration_default_entry_undef,
&mycss_declaration_default_entry_undef,
&mycss_declaration_default_entry_undef,
&mycss_declaration_default_entry_opacity,
&mycss_declaration_default_entry_undef,
&mycss_declaration_default_entry_undef,
&mycss_declaration_default_entry_undef,
Expand Down
15 changes: 14 additions & 1 deletion source/mycss/property/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -3233,7 +3233,20 @@ bool mycss_property_parser_offset_start(mycss_entry_t* entry, mycss_token_t* tok

bool mycss_property_parser_opacity(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
{
return mycss_property_shared_switch_to_parse_error(entry);
if(token->type == MyCSS_TOKEN_TYPE_WHITESPACE)
return true;

mycore_string_t str = {0};
mycss_declaration_entry_t* declr_entry = entry->declaration->entry_last;

if (mycss_property_shared_percentage(entry, token, &declr_entry->value, &declr_entry->value_type, &str))
return mycss_property_parser_destroy_string(&str, mycss_property_shared_switch_to_find_important(entry));

if (mycss_property_shared_number(entry, token, &declr_entry->value, &declr_entry->value_type, &str))
return mycss_property_parser_destroy_string(&str, mycss_property_shared_switch_to_find_important(entry));

return mycss_property_parser_destroy_string(&str, mycss_property_shared_switch_to_parse_error(entry));

}

bool mycss_property_parser_order(mycss_entry_t* entry, mycss_token_t* token, bool last_response)
Expand Down
2 changes: 1 addition & 1 deletion utils/MyCSS/data/property.txt
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ zoom-in | zoom-out | inherit | initial | unset" initial="auto" default="cursor">
<!-- https://drafts.csswg.org/css-color/#propdef-color -->
<property name="color" value="<color> | inherit | initial | unset" initial="" default="color"></property>
<!-- https://drafts.csswg.org/css-color/#propdef-opacity -->
<property name="opacity" value="" initial="1"></property>
<property name="opacity" value="" initial="1" default="opacity"></property>
<!-- https://drafts.csswg.org/css-color/#propdef-color-adjust -->
<property name="color-adjust" value="economy | exact" initial="economy"></property>

Expand Down