« third_party/modest/source/modest/finder/pseudo_class.c
↑ Summary
third_party/modest/source/modest/glue.c »
| 1 | /* | ||||||||||||||
| 2 | Copyright (C) 2016-2017 Alexander Borisov | ||||||||||||||
| 3 | |||||||||||||||
| 4 | This library is free software; you can redistribute it and/or | ||||||||||||||
| 5 | modify it under the terms of the GNU Lesser General Public | ||||||||||||||
| 6 | License as published by the Free Software Foundation; either | ||||||||||||||
| 7 | version 2.1 of the License, or (at your option) any later version. | ||||||||||||||
| 8 | |||||||||||||||
| 9 | This library 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 GNU | ||||||||||||||
| 12 | Lesser General Public License for more details. | ||||||||||||||
| 13 | |||||||||||||||
| 14 | You should have received a copy of the GNU Lesser General Public | ||||||||||||||
| 15 | License along with this library; if not, write to the Free Software | ||||||||||||||
| 16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||||||||||||||
| 17 | |||||||||||||||
| 18 | Author: lex.borisov@gmail.com (Alexander Borisov) | ||||||||||||||
| 19 | */ | ||||||||||||||
| 20 | |||||||||||||||
| 21 | #include "modest/finder/type.h" | ||||||||||||||
| 22 | #include "modest/finder/resource.h" | ||||||||||||||
| 23 | |||||||||||||||
| 24 | 0 | bool modest_finder_selector_type_undef(modest_finder_t* finder, myhtml_tree_node_t* node, mycss_selectors_entry_t* selector, mycss_selectors_specificity_t* spec) | |||||||||||||
| 25 | { | ||||||||||||||
| 26 | 0 | return false; | |||||||||||||
| 27 | } | ||||||||||||||
| 28 | |||||||||||||||
| 29 | 0 | bool modest_finder_selector_type_element(modest_finder_t* finder, myhtml_tree_node_t* node, mycss_selectors_entry_t* selector, mycss_selectors_specificity_t* spec) | |||||||||||||
| 30 | { | ||||||||||||||
| 31 | /* namespace */ | ||||||||||||||
| 32 | 0 | ▶ | if(selector->ns_entry) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 33 | 0 | ▶ | if(selector->ns_entry->ns_id != MyHTML_NAMESPACE_ANY && selector->ns_entry->ns_id != node->ns) | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 34 | 0 | return false; | |||||||||||||
| 35 | } | ||||||||||||||
| 36 | |||||||||||||||
| 37 | /* tag match */ | ||||||||||||||
| 38 | 0 | mycore_string_t *str = selector->key; | |||||||||||||
| 39 | 0 | ▶ | if(str->length == 1 && *str->data == '*') | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 40 | 0 | return true; | |||||||||||||
| 41 | |||||||||||||||
| 42 | 0 | ▶ | if(node->tree) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 43 | 0 | myhtml_tag_id_t tag_id = myhtml_tag_id_by_name(node->tree, str->data, str->length); | |||||||||||||
| 44 | |||||||||||||||
| 45 | 0 | ▶ | if(tag_id == node->tag_id) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 46 | 0 | return true; | |||||||||||||
| 47 | } | ||||||||||||||
| 48 | |||||||||||||||
| 49 | 0 | return false; | |||||||||||||
| 50 | } | ||||||||||||||
| 51 | |||||||||||||||
| 52 | 0 | bool modest_finder_selector_type_id(modest_finder_t* finder, myhtml_tree_node_t* node, mycss_selectors_entry_t* selector, mycss_selectors_specificity_t* spec) | |||||||||||||
| 53 | { | ||||||||||||||
| 54 | 0 | ▶ | if(node->token == NULL) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 55 | 0 | return false; | |||||||||||||
| 56 | |||||||||||||||
| 57 | 0 | ▶ | if(node->tree) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 58 | 0 | return modest_finder_match_attribute_eq(node->token->attr_first, | |||||||||||||
| 59 | "id", 2, | ||||||||||||||
| 60 | 0 | selector->key->data, selector->key->length, | |||||||||||||
| 61 | 0 | (node->tree->compat_mode != MyHTML_TREE_COMPAT_MODE_QUIRKS)); | |||||||||||||
| 62 | } | ||||||||||||||
| 63 | |||||||||||||||
| 64 | 0 | return false; | |||||||||||||
| 65 | } | ||||||||||||||
| 66 | |||||||||||||||
| 67 | 0 | bool modest_finder_selector_type_class(modest_finder_t* finder, myhtml_tree_node_t* node, mycss_selectors_entry_t* selector, mycss_selectors_specificity_t* spec) | |||||||||||||
| 68 | { | ||||||||||||||
| 69 | 0 | ▶ | if(node->token == NULL) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 70 | 0 | return false; | |||||||||||||
| 71 | |||||||||||||||
| 72 | 0 | ▶ | if(node->tree) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 73 | 0 | return modest_finder_match_attribute_ws(node->token->attr_first, | |||||||||||||
| 74 | "class", 5, | ||||||||||||||
| 75 | 0 | selector->key->data, selector->key->length, | |||||||||||||
| 76 | 0 | (node->tree->compat_mode != MyHTML_TREE_COMPAT_MODE_QUIRKS)); | |||||||||||||
| 77 | } | ||||||||||||||
| 78 | |||||||||||||||
| 79 | 0 | return false; | |||||||||||||
| 80 | } | ||||||||||||||
| 81 | |||||||||||||||
| 82 | 0 | bool modest_finder_selector_type_attribute(modest_finder_t* finder, myhtml_tree_node_t* node, mycss_selectors_entry_t* selector, mycss_selectors_specificity_t* spec) | |||||||||||||
| 83 | { | ||||||||||||||
| 84 | /* namespace */ | ||||||||||||||
| 85 | 0 | ▶ | if(selector->ns_entry) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 86 | 0 | ▶ | if(selector->ns_entry->ns_id != MyHTML_NAMESPACE_ANY && selector->ns_entry->ns_id != node->ns) | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 87 | 0 | return false; | |||||||||||||
| 88 | } | ||||||||||||||
| 89 | |||||||||||||||
| 90 | 0 | ▶ | if(node->token == NULL) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 91 | 0 | return false; | |||||||||||||
| 92 | |||||||||||||||
| 93 | 0 | mycss_selectors_object_attribute_t *sel_attr = mycss_selector_value_attribute(selector->value); | |||||||||||||
| 94 | |||||||||||||||
| 95 | 0 | ▶ | if(sel_attr) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 96 | 0 | ▶ | if(sel_attr->value == NULL) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 97 | 0 | return false; | |||||||||||||
| 98 | |||||||||||||||
| 99 | 0 | ▶ | if(sel_attr->match < MyCSS_SELECTORS_MATCH_LAST_ENTRY) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 100 | 0 | return modest_finder_static_selector_match_map[sel_attr->match](node->token->attr_first, | |||||||||||||
| 101 | 0 | selector->key->data, selector->key->length, | |||||||||||||
| 102 | 0 | sel_attr->value->data, sel_attr->value->length, | |||||||||||||
| 103 | 0 | (sel_attr->mod & MyCSS_SELECTORS_MOD_I)); | |||||||||||||
| 104 | } | ||||||||||||||
| 105 | else { | ||||||||||||||
| 106 | 0 | return modest_finder_match_attribute_only_key(node->token->attr_first, | |||||||||||||
| 107 | 0 | selector->key->data, selector->key->length); | |||||||||||||
| 108 | } | ||||||||||||||
| 109 | |||||||||||||||
| 110 | 0 | return false; | |||||||||||||
| 111 | } | ||||||||||||||
| 112 | |||||||||||||||
| 113 | 0 | bool modest_finder_selector_type_pseudo_class_function(modest_finder_t* finder, myhtml_tree_node_t* node, mycss_selectors_entry_t* selector, mycss_selectors_specificity_t* spec) | |||||||||||||
| 114 | { | ||||||||||||||
| 115 | 0 | ▶ | if(selector->sub_type < MyCSS_SELECTORS_SUB_TYPE_PSEUDO_CLASS_FUNCTION_LAST_ENTRY) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 116 | 0 | return modest_finder_static_selector_sub_type_pseudo_class_function_map[selector->sub_type](finder, node, selector, spec); | |||||||||||||
| 117 | |||||||||||||||
| 118 | 0 | return false; | |||||||||||||
| 119 | } | ||||||||||||||
| 120 | |||||||||||||||
| 121 | 0 | bool modest_finder_selector_type_pseudo_class(modest_finder_t* finder, myhtml_tree_node_t* node, mycss_selectors_entry_t* selector, mycss_selectors_specificity_t* spec) | |||||||||||||
| 122 | { | ||||||||||||||
| 123 | 0 | ▶ | if(selector->sub_type < MyCSS_SELECTORS_SUB_TYPE_PSEUDO_CLASS_LAST_ENTRY) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 124 | 0 | return modest_finder_static_selector_sub_type_pseudo_class_map[selector->sub_type](finder, node, selector, spec); | |||||||||||||
| 125 | |||||||||||||||
| 126 | 0 | return false; | |||||||||||||
| 127 | } | ||||||||||||||
| 128 | |||||||||||||||
| 129 | 0 | bool modest_finder_selector_type_pseudo_element_function(modest_finder_t* finder, myhtml_tree_node_t* node, mycss_selectors_entry_t* selector, mycss_selectors_specificity_t* spec) | |||||||||||||
| 130 | { | ||||||||||||||
| 131 | 0 | return false; | |||||||||||||
| 132 | } | ||||||||||||||
| 133 | |||||||||||||||
| 134 | 0 | bool modest_finder_selector_type_pseudo_element(modest_finder_t* finder, myhtml_tree_node_t* node, mycss_selectors_entry_t* selector, mycss_selectors_specificity_t* spec) | |||||||||||||
| 135 | { | ||||||||||||||
| 136 | 0 | return false; | |||||||||||||
| 137 | } | ||||||||||||||
| 138 | |||||||||||||||
| 139 | |||||||||||||||